@xuda.io/notification_module 1.1.113 → 1.1.114
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/index.mjs +33 -2
- package/index_msa.mjs +4 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -138,8 +138,18 @@ export const submit_notification = async (req) => {
|
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
switch (delivery_method_item) {
|
|
141
|
-
case 'email':
|
|
142
|
-
|
|
141
|
+
case 'email': {
|
|
142
|
+
// Honor an explicit email, else fall back to the recipient's account.
|
|
143
|
+
// System notifications skip the lookup above, so resolve it here
|
|
144
|
+
// (superuser alert recipients have real accounts with emails).
|
|
145
|
+
let resolved_email = email;
|
|
146
|
+
if (!resolved_email) {
|
|
147
|
+
if (!account_ret) {
|
|
148
|
+
account_ret = await db_module.get_couch_doc('xuda_accounts', uid).catch(() => null);
|
|
149
|
+
}
|
|
150
|
+
resolved_email = account_ret?.data?.account_info?.email || '';
|
|
151
|
+
}
|
|
152
|
+
obj.email = resolved_email;
|
|
143
153
|
if (!obj.email) {
|
|
144
154
|
send_result[uid] = false;
|
|
145
155
|
return;
|
|
@@ -153,6 +163,7 @@ export const submit_notification = async (req) => {
|
|
|
153
163
|
app_id: obj.app_id,
|
|
154
164
|
});
|
|
155
165
|
break;
|
|
166
|
+
}
|
|
156
167
|
|
|
157
168
|
case 'banner':
|
|
158
169
|
case 'consent':
|
|
@@ -431,6 +442,26 @@ export const submit_superuser_notification = async (req) => {
|
|
|
431
442
|
}
|
|
432
443
|
};
|
|
433
444
|
|
|
445
|
+
// Ops/admin alert for the AI error resolver. Renders the `error_resolver`
|
|
446
|
+
// template (notification_templates.mjs -> system category) and delivers to the
|
|
447
|
+
// superuser accounts (which have real emails) via the standard notification path.
|
|
448
|
+
export const submit_error_resolver_alert = async (req) => {
|
|
449
|
+
const { params = {} } = req || {};
|
|
450
|
+
try {
|
|
451
|
+
const recipients = _conf.superuser_account_ids || [];
|
|
452
|
+
if (!recipients.length) return { code: -1, data: 'no superuser recipients configured' };
|
|
453
|
+
return await submit_notification({
|
|
454
|
+
type: 'system',
|
|
455
|
+
topic: 'error_resolver',
|
|
456
|
+
uid_arr: recipients,
|
|
457
|
+
system: true,
|
|
458
|
+
params,
|
|
459
|
+
});
|
|
460
|
+
} catch (err) {
|
|
461
|
+
return { code: -1, data: err.message };
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
|
|
434
465
|
export const submit_app_notification = async (req) => {
|
|
435
466
|
const { uid, subject, delivery_method, body, display_type, to_uid = [], to_app_id, app_id, system, type } = req;
|
|
436
467
|
try {
|
package/index_msa.mjs
CHANGED
|
@@ -41,6 +41,10 @@ export const submit_superuser_notification = function (...args) {
|
|
|
41
41
|
broker.send_to_queue_async("submit_superuser_notification", ...args);
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
export const submit_error_resolver_alert = function (...args) {
|
|
45
|
+
broker.send_to_queue_async("submit_error_resolver_alert", ...args);
|
|
46
|
+
};
|
|
47
|
+
|
|
44
48
|
export const submit_app_notification = function (...args) {
|
|
45
49
|
broker.send_to_queue_async("submit_app_notification", ...args);
|
|
46
50
|
};
|