@contentgrowth/content-emailing 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -992,6 +992,7 @@ var EmailService = class {
992
992
  const processedData = this._preprocessData(data);
993
993
  const subject = Mustache.render(template.subject_template, processedData);
994
994
  let markdown = Mustache.render(template.body_markdown, processedData);
995
+ markdown = markdown.replace(/\[([^\]]+)\]\(([^)]+)\)(?!\s*\(\2\))/g, '[$1]($2) <span style="font-size: 0.8em; color: #888;">($2)</span>');
995
996
  markdown = markdown.replace(/\\n/g, "\n");
996
997
  marked.use({
997
998
  mangle: false,
@@ -1493,7 +1494,7 @@ function createTemplateRoutes(config = {}) {
1493
1494
  app.post("/send-test", async (c) => {
1494
1495
  const emailService = new EmailService(c.env, config);
1495
1496
  try {
1496
- const { template_id, to, variables } = await c.req.json();
1497
+ const { template_id, to, variables, profile = "system", tenantId } = await c.req.json();
1497
1498
  let tid = template_id;
1498
1499
  if (!tid || !to) {
1499
1500
  return c.json({ error: "Missing required fields (template_id, to)" }, 400);
@@ -1502,11 +1503,16 @@ function createTemplateRoutes(config = {}) {
1502
1503
  const recipientUserId = user?.id || null;
1503
1504
  const result = await emailService.sendViaTemplate(tid, variables || {}, {
1504
1505
  to,
1505
- profile: "test",
1506
+ profile,
1507
+ tenantId,
1506
1508
  recipientUserId
1507
1509
  });
1510
+ if (!result.success) {
1511
+ return c.json({ error: result.error || "Failed to send test email" }, 400);
1512
+ }
1508
1513
  return c.json({ success: true, result });
1509
1514
  } catch (err) {
1515
+ console.error("[TemplateRoutes] Send test error:", err);
1510
1516
  return c.json({ error: `Failed to send test email: ${err.message}` }, 500);
1511
1517
  }
1512
1518
  });