@xuda.io/notification_module 1.1.98 → 1.1.100
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 +9 -26
- package/index_ms.mjs +6 -2
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -14,6 +14,7 @@ const _common = await import(path.join(process.env.XUDA_HOME, 'common', 'xuda_no
|
|
|
14
14
|
const module_path = path.join(process.env.XUDA_HOME, 'cpi') + (!_conf.is_debug ? '/node_modules/@xuda.io' : '');
|
|
15
15
|
const db_module = await import(`${module_path}/db_module/index.mjs`);
|
|
16
16
|
const email_ms = await import(`${module_path}/email_module/index_ms.mjs`);
|
|
17
|
+
const ws_dashboard_ms = await import(`${module_path}/ws_dashboard_module/index_ms.mjs`);
|
|
17
18
|
|
|
18
19
|
//////////////////// FCM /////////////////////
|
|
19
20
|
const serviceAccount = _conf.firebase_serviceAccount;
|
|
@@ -53,20 +54,10 @@ export const update_notification_status = async (req) => {
|
|
|
53
54
|
notification_doc.stat_ts = Date.now();
|
|
54
55
|
notification_doc.stat = stat;
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
method: 'notification',
|
|
61
|
-
|
|
62
|
-
data: {
|
|
63
|
-
to: notification_doc.system ? uid : notification_doc.uid,
|
|
64
|
-
data: notification_doc,
|
|
65
|
-
},
|
|
66
|
-
}),
|
|
67
|
-
),
|
|
68
|
-
);
|
|
69
|
-
|
|
57
|
+
ws_dashboard_ms.notification({
|
|
58
|
+
to: notification_doc.system ? uid : notification_doc.uid,
|
|
59
|
+
data: notification_doc,
|
|
60
|
+
});
|
|
70
61
|
return await db_module.save_couch_doc('xuda_notification', notification_doc);
|
|
71
62
|
};
|
|
72
63
|
|
|
@@ -163,18 +154,10 @@ export const submit_notification = async (req, _ch = global[`_notification_modul
|
|
|
163
154
|
case 'banner':
|
|
164
155
|
case 'consent':
|
|
165
156
|
case 'alert':
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
method: 'notification',
|
|
171
|
-
data: {
|
|
172
|
-
to: uid,
|
|
173
|
-
data: obj,
|
|
174
|
-
},
|
|
175
|
-
}),
|
|
176
|
-
),
|
|
177
|
-
);
|
|
157
|
+
ws_dashboard_ms.notification({
|
|
158
|
+
to: uid,
|
|
159
|
+
data: obj,
|
|
160
|
+
});
|
|
178
161
|
|
|
179
162
|
break;
|
|
180
163
|
case 'push':
|
package/index_ms.mjs
CHANGED
|
@@ -46,7 +46,7 @@ const send_to_queue =async function(ms_method, ...args) {
|
|
|
46
46
|
const timeout = setTimeout(() => {
|
|
47
47
|
delete queue[queue_id];
|
|
48
48
|
reject(new Error(`Queue timeout for ${ms_method}`));
|
|
49
|
-
},
|
|
49
|
+
}, 300000); // 300 second timeout
|
|
50
50
|
|
|
51
51
|
// Wrap resolve to clean up
|
|
52
52
|
queue[queue_id].resolve = (value) => {
|
|
@@ -61,7 +61,8 @@ const send_to_queue =async function(ms_method, ...args) {
|
|
|
61
61
|
delete queue[queue_id];
|
|
62
62
|
reject(error);
|
|
63
63
|
};
|
|
64
|
-
|
|
64
|
+
|
|
65
|
+
try{
|
|
65
66
|
global[`_${global.module_in}_ch`].sendToQueue(
|
|
66
67
|
'notification_module',
|
|
67
68
|
Buffer.from(
|
|
@@ -74,6 +75,9 @@ const send_to_queue =async function(ms_method, ...args) {
|
|
|
74
75
|
)
|
|
75
76
|
);
|
|
76
77
|
|
|
78
|
+
}catch(err){
|
|
79
|
+
debugger
|
|
80
|
+
}
|
|
77
81
|
})
|
|
78
82
|
|
|
79
83
|
};
|