@openinc/parse-server-opendash 4.30.0 → 4.31.0

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.
@@ -29,7 +29,21 @@ async function init() {
29
29
  const email = user?.getEmail();
30
30
  console.log("[@openinc/parse-server-opendash][Notification]", `notification="${object.id}"`, `type="email"`, `to="${email}"`);
31
31
  if (email) {
32
- await (0, index_js_3.sendSimpleEmail)(email, title, await buildEmailBody(description, object.get("data")?.url, user));
32
+ const link = await buildEmailLink(object.get("data")?.url, user);
33
+ await (0, index_js_3.sendTemplateEmail)({
34
+ template: "openinc-notification",
35
+ to: email,
36
+ subject: title,
37
+ fallback: link
38
+ ? `${description || ""}\n\n${link}`
39
+ : description || "",
40
+ data: {
41
+ title,
42
+ description,
43
+ link,
44
+ data: object.get("data"),
45
+ },
46
+ });
33
47
  }
34
48
  }
35
49
  // Handle Push
@@ -51,24 +65,20 @@ async function init() {
51
65
  });
52
66
  }
53
67
  /**
54
- * Plain-text body of a notification email: the (already translated)
55
- * description, followed by a link to the thing the notification is about.
68
+ * Link to the thing a notification is about, for the notification email.
56
69
  *
57
70
  * Producers store that link in `data.url` as an app-relative path (e.g.
58
71
  * `/service/tickets/<id>`), because the host depends on the recipient's tenant
59
72
  * and is only known here, at delivery time — the frontend renders the same
60
73
  * notification by route and never needs it. Absolute URLs are passed through
61
- * unchanged for producers that resolved a host themselves.
74
+ * unchanged for producers that resolved a host themselves. Returns an empty
75
+ * string when the notification has no link.
62
76
  */
63
- async function buildEmailBody(description, url, user) {
64
- const body = description || "";
77
+ async function buildEmailLink(url, user) {
65
78
  if (typeof url !== "string" || url === "") {
66
- return body;
79
+ return "";
67
80
  }
68
- const link = /^https?:\/\//i.test(url)
69
- ? url
70
- : `${await (0, appLinks_js_1.getAppBaseUrl)(user)}${url}`;
71
- return `${body}\n\n${link}`;
81
+ return /^https?:\/\//i.test(url) ? url : `${await (0, appLinks_js_1.getAppBaseUrl)(user)}${url}`;
72
82
  }
73
83
  async function sendWebPush(subscription, id, title, description, icon, data) {
74
84
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "4.30.0",
3
+ "version": "4.31.0",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@12.8.1",
6
6
  "keywords": [