@abtnode/blocklet-services 1.16.38-beta-20250123-083218-c7ea9693 → 1.16.38-beta-20250125-130409-89d4849d
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/api/index.js +116 -19
- package/api/services/dashboard/index.js +10 -0
- package/api/services/notification/index.js +32 -1
- package/api/socket/channel/did.js +386 -53
- package/dist/assets/{Add-CbZXB9BN.js → Add-B2yJ7-eq.js} +1 -1
- package/dist/assets/{ArrowDropDown-CCP1plk6.js → ArrowDropDown-D34En9iv.js} +1 -1
- package/dist/assets/{CheckCircle-DhGEqk47.js → CheckCircle-BFXaMcKG.js} +1 -1
- package/dist/assets/{ChevronLeft-md-2eRHz.js → ChevronLeft-BXNAWRN5.js} +1 -1
- package/dist/assets/{ChevronRight-DAi6_yC8.js → ChevronRight-bqoO4ITE.js} +1 -1
- package/dist/assets/{DeleteOutline-mNy4Y7aW.js → DeleteOutline-_fdI9SLO.js} +1 -1
- package/dist/assets/{Done-BW0pdQ5b.js → Done-BegjCX44.js} +1 -1
- package/dist/assets/{Download-Dn7Gxwef.js → Download-ynxZ21_h.js} +1 -1
- package/dist/assets/{EditIcon-BKaoBwhT.js → EditIcon-D6Lk4OxD.js} +1 -1
- package/dist/assets/{Error-bTFr7mrN.js → Error-Dy9JDlUO.js} +1 -1
- package/dist/assets/{Google-Df86UadJ.js → Google-oUsdET4E.js} +1 -1
- package/dist/assets/{InfoOutlined-CD_kKD1R.js → InfoOutlined-CNFvZjEE.js} +1 -1
- package/dist/assets/{Launch-C4oayzSh.js → Launch-DrBfpSUO.js} +1 -1
- package/dist/assets/{LaunchOutlined-o-scAjX1.js → LaunchOutlined-BstP_JKj.js} +1 -1
- package/dist/assets/{LockIcon-CJS2b0V1.js → LockIcon-BITD3hjp.js} +1 -1
- package/dist/assets/{Loop-CgXdPi-b.js → Loop-CuBUpP_g.js} +1 -1
- package/dist/assets/{MoreHoriz-CE_TiTTu.js → MoreHoriz-jduVqLUc.js} +1 -1
- package/dist/assets/{PlayArrow-CNURzidt.js → PlayArrow-CauLC4o_.js} +1 -1
- package/dist/assets/{QuestionMarkCircle-yIKrKrCO.js → QuestionMarkCircle-SCPzvU7T.js} +1 -1
- package/dist/assets/{ServerLogo-BtnYTJe2.js → ServerLogo-DRTZsm8x.js} +1 -1
- package/dist/assets/{ViewList-BK6mc3zl.js → ViewList-CePklU1n.js} +1 -1
- package/dist/assets/{access-control-C_TECevI.js → access-control-DMs8KTjf.js} +1 -1
- package/dist/assets/{actions-DQhRPM_-.js → actions-B31e80dT.js} +1 -1
- package/dist/assets/{add-component-core-ZKcNoEdg.js → add-component-core-BRZ3frb6.js} +1 -1
- package/dist/assets/{add-resource-DeyN_YP2.js → add-resource-CpU17Psd.js} +1 -1
- package/dist/assets/{addon-BQVku5Pw.js → addon-DTkR7c7s.js} +1 -1
- package/dist/assets/analytics-BdRFij_g.js +11 -0
- package/dist/assets/api-K65cLqol.js +1 -0
- package/dist/assets/ar-DV4YJwQy.js +3 -0
- package/dist/assets/{audit-logs-DfI45rXd.js → audit-logs-B5tzv9w6.js} +1 -1
- package/dist/assets/{base32-DwpD8kXz.js → base32-Bxy_Ng3r.js} +1 -1
- package/dist/assets/{branding-B9FP7-vo.js → branding-DEsr5kE0.js} +2 -2
- package/dist/assets/{bundle-avatar-Fs8xar2D.js → bundle-avatar-BSrkMwWG.js} +1 -1
- package/dist/assets/button-CT_SqdC_.js +1 -0
- package/dist/assets/{click-to-copy-BK1KcsDP.js → click-to-copy-DG6oCsDy.js} +1 -1
- package/dist/assets/{cloneDeep-gFMzIJP-.js → cloneDeep-BRiLvZjr.js} +1 -1
- package/dist/assets/{complete-C8dsbaZL.js → complete-B7fQAviW.js} +1 -1
- package/dist/assets/{component-CY2siZu6.js → component-L5_5YcjO.js} +38 -38
- package/dist/assets/{config-DefjxKJo.js → config-Bi4mtKrp.js} +1 -1
- package/dist/assets/{config-oy6r1Urw.js → config-DfNCVYae.js} +1 -1
- package/dist/assets/{config-navigation-D5ZGtEAj.js → config-navigation-BEXQaINe.js} +3 -3
- package/dist/assets/{config-space-B3_Fcx4w.js → config-space-C1WFdLmf.js} +1 -1
- package/dist/assets/{confirm-BoaULvDn.js → confirm-Cbx82b25.js} +1 -1
- package/dist/assets/connect-Cp12hGV2.js +1 -0
- package/dist/assets/{connect-BLZbqoZH.js → connect-kW-GMUG3.js} +1 -1
- package/dist/assets/connect-to-D5VZBQsq.js +1 -0
- package/dist/assets/{content-layout-DAGIv17a.js → content-layout-CzrxMNjA.js} +1 -1
- package/dist/assets/dashboard-uG_G13IR.js +86 -0
- package/dist/assets/de-C2Y_05d1.js +3 -0
- package/dist/assets/{did-address-lZEH-yVL.js → did-address-DhC4Z1Ef.js} +1 -1
- package/dist/assets/{domain-CL1k3ZX_.js → domain-DvrEWdQ8.js} +2 -2
- package/dist/assets/domain-list-B1J4C6ST.js +15 -0
- package/dist/assets/{email-BEAIuGC5.js → email-Cs87G5pr.js} +1 -1
- package/dist/assets/es-DPVOSPPn.js +3 -0
- package/dist/assets/{exchange-passport-mOSW3xXw.js → exchange-passport-Crhw_vMf.js} +1 -1
- package/dist/assets/{form-text-input-CKzsC-YU.js → form-text-input-COijwVFy.js} +1 -1
- package/dist/assets/fr-C8dIIOc9.js +3 -0
- package/dist/assets/{fuel-e3tdVb--.js → fuel-DxcT-75B.js} +1 -1
- package/dist/assets/{fullpage-CkKHaYU0.js → fullpage-CAAXK4pO.js} +1 -1
- package/dist/assets/{get-safe-url-C4tgGDKq.js → get-safe-url-CJIsC1HE.js} +1 -1
- package/dist/assets/{get-safe-url-C_f_ODLw.js → get-safe-url-jf8X-XpV.js} +1 -1
- package/dist/assets/hi-C5r4WQDs.js +1 -0
- package/dist/assets/{home-BNIXkVh5.js → home-Ckf42YJd.js} +1 -1
- package/dist/assets/id-BQK45J6o.js +3 -0
- package/dist/assets/{iframe-SU3hkiQZ.js → iframe-BYvZHXU-.js} +1 -1
- package/dist/assets/{index-HmBDrYyO.js → index-2NCgoG1i.js} +1 -1
- package/dist/assets/{index-B1LvzL9_.js → index-3PobA81m.js} +1 -1
- package/dist/assets/{index-D3LlfacS.js → index-B86l7aCe.js} +1 -1
- package/dist/assets/{index-XcirhJQa.js → index-BJpEKQ4d.js} +12 -12
- package/dist/assets/{index-CbOZ5xd2.js → index-BNCJw59G.js} +1 -1
- package/dist/assets/index-BUstrRo5.js +61 -0
- package/dist/assets/{index-CzV3SmGK.js → index-BvLMNAG0.js} +1 -1
- package/dist/assets/{index-Dh7hy74S.js → index-Bw3pdP7q.js} +1 -1
- package/dist/assets/{index-DwFu84UU.js → index-C0uUrAqS.js} +1 -1
- package/dist/assets/{index-Dkwa_Vhl.js → index-C2fPoxDR.js} +1 -1
- package/dist/assets/index-C7s7t2aN.js +5 -0
- package/dist/assets/{index-CV6rNC-Y.js → index-CRaD-3s4.js} +9 -9
- package/dist/assets/index-D5mFr1eo.js +1 -0
- package/dist/assets/{index-B2Tt5B_m.js → index-DBxnR425.js} +1 -1
- package/dist/assets/{index-DvtOujRp.js → index-DE_r-gh_.js} +1 -1
- package/dist/assets/{index-BDDBFVc2.js → index-Dnxf7bfY.js} +1 -1
- package/dist/assets/{index-96CXu6nL.js → index-KhsqOaMW.js} +7 -7
- package/dist/assets/{index-CV9CYyTl.js → index-PxlbAHCL.js} +36 -36
- package/dist/assets/{index-jQnnlRfC.js → index-Xsfh2QSh.js} +2 -2
- package/dist/assets/index-_ph5477y.js +291 -0
- package/dist/assets/{invitation-B0m5kk5c.js → invitation-DbGm8k25.js} +1 -1
- package/dist/assets/{invite-RA9kQH1W.js → invite-6nyN-oEv.js} +1 -1
- package/dist/assets/{issue-passport-DHpO_ACu.js → issue-passport-YNIanHYf.js} +1 -1
- package/dist/assets/{item-BieIEWMb.js → item-DvkqLmAe.js} +1 -1
- package/dist/assets/ja-DsJERrpD.js +3 -0
- package/dist/assets/ko-t760ZSCl.js +3 -0
- package/dist/assets/{launch-result-message-CeThGm85.js → launch-result-message-C_UhVRcl.js} +1 -1
- package/dist/assets/{layout-BG2jsdXo.js → layout-BVSGD29L.js} +1 -1
- package/dist/assets/list-DrMoP89n.js +160 -0
- package/dist/assets/{list-header-CiUgmzBx.js → list-header-Br_UsG2e.js} +1 -1
- package/dist/assets/localization-V7oQS6wL.js +1 -0
- package/dist/assets/{log-C6bNY6ja.js → log-DCaMhKsI.js} +1 -1
- package/dist/assets/{login-Cvj7T07b.js → login-CHKXy0wB.js} +1 -1
- package/dist/assets/{login-oauth-callback-Di8KYSE_.js → login-oauth-callback-BSX9wejc.js} +1 -1
- package/dist/assets/{logo-uploader-CdOV1A5h.js → logo-uploader-D3pYQBpx.js} +3 -3
- package/dist/assets/{lost-passport-DUSDA_sN.js → lost-passport-BDU3b7Z_.js} +1 -1
- package/dist/assets/{open-window-DF6F9kh-.js → open-window-DrK6iGmf.js} +1 -1
- package/dist/assets/{overview-16UWFtH0.js → overview-BdW7-A5w.js} +1 -1
- package/dist/assets/{page-header-D0CahNv0.js → page-header-JASV_XcR.js} +1 -1
- package/dist/assets/{permission-CKZlVSQ7.js → permission-BkijBCin.js} +1 -1
- package/dist/assets/{preferences-DHuTV8VO.js → preferences-CtlqLrD7.js} +1 -1
- package/dist/assets/pt-BkjUa7uv.js +1 -0
- package/dist/assets/publish-resource-CsuZRYMx.js +1 -0
- package/dist/assets/{react-beautiful-dnd.esm-CfBtdMfF.js → react-beautiful-dnd.esm-C5Uq3rbJ.js} +1 -1
- package/dist/assets/{relative-time-BMfPIJBi.js → relative-time-CQ0hJZC_.js} +1 -1
- package/dist/assets/ru-1WsQFvuL.js +1 -0
- package/dist/assets/sdk-CncrP2i9.js +1 -0
- package/dist/assets/session-ClC5u_ou.js +1 -0
- package/dist/assets/{setup-bES2Uf5W.js → setup-DdTSQTvr.js} +3 -3
- package/dist/assets/{shorten-label-B08EnqgB.js → shorten-label-CYJeMT7h.js} +1 -1
- package/dist/assets/{simple-select-mThFfFp5.js → simple-select-CAyDBkK6.js} +1 -1
- package/dist/assets/{slicedToArray-Ct1Y7NnY.js → slicedToArray-CV571vyX.js} +2 -2
- package/dist/assets/{start-MoamILfR.js → start-Byudzjg5.js} +1 -1
- package/dist/assets/{step-actions-CuwaxH_E.js → step-actions-Zk6bKoYE.js} +1 -1
- package/dist/assets/{studio-CO68-4Oq.js → studio-BGgRA_ZI.js} +1 -1
- package/dist/assets/{switch-control-BpWvMK7z.js → switch-control-BmI39UF6.js} +1 -1
- package/dist/assets/th-CecKmVWf.js +1 -0
- package/dist/assets/traffic-B70zlTcA.js +37 -0
- package/dist/assets/{transfer-DzCBkPdX.js → transfer-C-8HxdfL.js} +1 -1
- package/dist/assets/{unsubscribe-DnKJ4RoU.js → unsubscribe-CrmlZkSk.js} +1 -1
- package/dist/assets/{use-mobile-DoeLOxx6.js → use-mobile-Bk8quGt9.js} +1 -1
- package/dist/assets/{useAsync-DCGc7Pdb.js → useAsync-Ua5iss51.js} +1 -1
- package/dist/assets/{useAsyncRetry-0k7mm5ej.js → useAsyncRetry-EMRT9Ldq.js} +1 -1
- package/dist/assets/{useLocalStorage-BGtJBKln.js → useLocalStorage-CTToOZ4l.js} +1 -1
- package/dist/assets/user-center-BB2CLc7Q.js +71 -0
- package/dist/assets/{util-DQVMHOUo.js → util-BnCdSUGw.js} +1 -1
- package/dist/assets/util-DowdN-NO.js +1 -0
- package/dist/assets/vendor-arcblock-CVRRnBv2.js +3506 -0
- package/dist/assets/{vendor-hooks-DWAhU9cy.js → vendor-hooks-BKxTDk_P.js} +1 -1
- package/dist/assets/{vendor-mui-core-jh6OMVvU.js → vendor-mui-core-CCMNKHtm.js} +1 -1
- package/dist/assets/{vendor-mui-x-BRRfPRl8.js → vendor-mui-x-DmPVvZFJ.js} +1 -1
- package/dist/assets/vendor-utils-5TjOM6td.js +11 -0
- package/dist/assets/vi-CDrTp7No.js +1 -0
- package/dist/assets/wrap-locale-CNuv_qkt.js +1 -0
- package/dist/assets/zh-Bqr2c2To.js +4 -0
- package/dist/assets/zh-tw-CUyoe2CD.js +3 -0
- package/dist/index.html +5 -5
- package/dist/service-worker.js +1 -1
- package/dist/share/shared-service-worker.js +1 -123
- package/package.json +43 -43
- package/dist/assets/analytics-CABOV3VR.js +0 -47
- package/dist/assets/api-hLQrqHOJ.js +0 -1
- package/dist/assets/ar-D1VagXPW.js +0 -3
- package/dist/assets/button-DkniumtB.js +0 -1
- package/dist/assets/connect-o0-zMzhz.js +0 -1
- package/dist/assets/connect-to-CLRCxFvc.js +0 -1
- package/dist/assets/dashboard-BsuKKhWa.js +0 -86
- package/dist/assets/de-CvDV7d-6.js +0 -3
- package/dist/assets/domain-list-Hq4lMkF7.js +0 -15
- package/dist/assets/es-DGK_gDT-.js +0 -3
- package/dist/assets/fr-BuGbCF-_.js +0 -3
- package/dist/assets/hi-w7-Xo0pj.js +0 -1
- package/dist/assets/id-DfsK8869.js +0 -3
- package/dist/assets/index-ChG5I_m-.js +0 -1
- package/dist/assets/index-DZkcShk4.js +0 -2
- package/dist/assets/index-Dg_5HpPS.js +0 -5
- package/dist/assets/index-Dyaz7ZHB.js +0 -291
- package/dist/assets/ja-CQJHpvK1.js +0 -3
- package/dist/assets/ko-9oNzTJow.js +0 -3
- package/dist/assets/localization-BhAxNGA4.js +0 -1
- package/dist/assets/pt-DMLN8oh9.js +0 -1
- package/dist/assets/publish-resource-CAkJ3GaW.js +0 -1
- package/dist/assets/ru-CGG1vu9C.js +0 -1
- package/dist/assets/sdk-CBXPdpcP.js +0 -1
- package/dist/assets/session-BTTqSeVf.js +0 -1
- package/dist/assets/th-D-lApkQp.js +0 -1
- package/dist/assets/user-center-BkJieuxf.js +0 -232
- package/dist/assets/vendor-arcblock-CwZ35cSm.js +0 -3509
- package/dist/assets/vendor-utils-u2ViqIqX.js +0 -11
- package/dist/assets/vi-D45dg9B_.js +0 -1
- package/dist/assets/wrap-locale-DTfWnUqX.js +0 -1
- package/dist/assets/zh-CcLxBIl6.js +0 -4
- package/dist/assets/zh-tw-Bqy7j8qE.js +0 -3
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
NOTIFICATION_TYPES,
|
|
6
6
|
} = require('@blocklet/sdk/lib/validators/notification');
|
|
7
7
|
const { Joi } = require('@arcblock/validator');
|
|
8
|
-
const { NODE_MODES } = require('@abtnode/constant');
|
|
8
|
+
const { NODE_MODES, NOTIFICATION_SEND_STATUS, NOTIFICATION_SEND_FAILED_REASON } = require('@abtnode/constant');
|
|
9
9
|
const { getWalletDid } = require('@blocklet/sdk/lib/did');
|
|
10
10
|
const JWT = require('@arcblock/jwt');
|
|
11
11
|
const pMap = require('p-map');
|
|
@@ -23,31 +23,65 @@ const { getBlockletInfo } = require('../../cache');
|
|
|
23
23
|
const { nanoid } = require('../../util');
|
|
24
24
|
|
|
25
25
|
const CHANNEL_FIELD_MAP = {
|
|
26
|
-
wallet: ['walletSendStatus', 'walletSendAt'],
|
|
27
|
-
pushKit: ['pushKitSendStatus', 'pushKitSendAt'],
|
|
28
|
-
email: ['emailSendStatus', 'emailSendAt'],
|
|
26
|
+
wallet: ['walletSendStatus', 'walletSendAt', 'walletSendFailedReason', 'walletSendRecord'],
|
|
27
|
+
pushKit: ['pushKitSendStatus', 'pushKitSendAt', 'pushKitSendFailedReason', 'pushKitSendRecord'],
|
|
28
|
+
email: ['emailSendStatus', 'emailSendAt', 'emailSendFailedReason', 'emailSendRecord'],
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
const updateNotificationSendStatus = async ({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const updateNotificationSendStatus = async ({
|
|
32
|
+
node,
|
|
33
|
+
teamDid,
|
|
34
|
+
notificationId,
|
|
35
|
+
receivers = [],
|
|
36
|
+
channel = '',
|
|
37
|
+
status,
|
|
38
|
+
failedReason = '',
|
|
39
|
+
webhookParams = {},
|
|
40
|
+
}) => {
|
|
41
|
+
if (!node || !notificationId || !receivers.length) {
|
|
42
|
+
return undefined;
|
|
35
43
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
if (channel === 'webhook' && Object.keys(webhookParams).length > 0) {
|
|
45
|
+
const updateParams = {
|
|
46
|
+
receivers,
|
|
47
|
+
teamDid,
|
|
48
|
+
notificationId,
|
|
49
|
+
updates: {
|
|
50
|
+
webhookParams,
|
|
51
|
+
},
|
|
41
52
|
};
|
|
42
|
-
await node.updateNotificationStatus({ receivers: res, teamDid, notificationId, updates });
|
|
43
|
-
};
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
const res = await node.updateNotificationStatus(updateParams);
|
|
55
|
+
return res;
|
|
47
56
|
}
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
|
|
58
|
+
const [field, at, reasonField, recordField] = CHANNEL_FIELD_MAP[channel];
|
|
59
|
+
if (!field || !at) {
|
|
60
|
+
return undefined;
|
|
50
61
|
}
|
|
62
|
+
|
|
63
|
+
const updates = {
|
|
64
|
+
[field]: status,
|
|
65
|
+
[at]: new Date(),
|
|
66
|
+
...(failedReason ? { [reasonField]: failedReason } : {}),
|
|
67
|
+
};
|
|
68
|
+
const updateParams = {
|
|
69
|
+
receivers,
|
|
70
|
+
teamDid,
|
|
71
|
+
notificationId,
|
|
72
|
+
updates,
|
|
73
|
+
};
|
|
74
|
+
updates.record = {
|
|
75
|
+
field: recordField,
|
|
76
|
+
content: {
|
|
77
|
+
sendStatus: status,
|
|
78
|
+
sendAt: updates[at],
|
|
79
|
+
...(failedReason ? { failedReason } : {}),
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const res = await node.updateNotificationStatus(updateParams);
|
|
84
|
+
return res;
|
|
51
85
|
};
|
|
52
86
|
|
|
53
87
|
/**
|
|
@@ -82,8 +116,11 @@ const sendToUserDid = async ({ sender, receiver: rawDid, notification, options,
|
|
|
82
116
|
const receiver = receivers.map((r) => r.did);
|
|
83
117
|
|
|
84
118
|
let receiverPushDidList = [];
|
|
119
|
+
let notEnabledPushReceiverList = [];
|
|
85
120
|
let receiverAppDidList = [];
|
|
121
|
+
let notEnabledAppReceiverList = [];
|
|
86
122
|
let receiverEmailList = [];
|
|
123
|
+
let notEnabledEmailReceiverList = [];
|
|
87
124
|
let webhookList = [];
|
|
88
125
|
|
|
89
126
|
const webhookSenders = new Map();
|
|
@@ -96,6 +133,15 @@ const sendToUserDid = async ({ sender, receiver: rawDid, notification, options,
|
|
|
96
133
|
|
|
97
134
|
const receiverDid = getWalletDid(user) || user.did;
|
|
98
135
|
const receiverEmail = user?.email;
|
|
136
|
+
if (!walletEnabled) {
|
|
137
|
+
notEnabledAppReceiverList.push(receiverDid);
|
|
138
|
+
}
|
|
139
|
+
if (!pushEnabled) {
|
|
140
|
+
notEnabledPushReceiverList.push(receiverDid);
|
|
141
|
+
}
|
|
142
|
+
if (!emailEnabled) {
|
|
143
|
+
notEnabledEmailReceiverList.push(receiverDid);
|
|
144
|
+
}
|
|
99
145
|
|
|
100
146
|
if (receiverDid && (walletEnabled || pushEnabled)) {
|
|
101
147
|
try {
|
|
@@ -123,6 +169,8 @@ const sendToUserDid = async ({ sender, receiver: rawDid, notification, options,
|
|
|
123
169
|
} catch (error) {
|
|
124
170
|
logger.error(`Skip invalid email receiver: ${receiverEmail}`, { error });
|
|
125
171
|
}
|
|
172
|
+
} else {
|
|
173
|
+
notEnabledEmailReceiverList.push(receiverDid);
|
|
126
174
|
}
|
|
127
175
|
|
|
128
176
|
if (Array.isArray(webhooks)) {
|
|
@@ -159,6 +207,16 @@ const sendToUserDid = async ({ sender, receiver: rawDid, notification, options,
|
|
|
159
207
|
receiverEmailList = uniqBy(receiverEmailList, 'email');
|
|
160
208
|
webhookList = uniqBy(webhookList, 'url');
|
|
161
209
|
|
|
210
|
+
notEnabledAppReceiverList = uniq(notEnabledAppReceiverList);
|
|
211
|
+
notEnabledPushReceiverList = uniq(notEnabledPushReceiverList);
|
|
212
|
+
notEnabledEmailReceiverList = uniq(notEnabledEmailReceiverList);
|
|
213
|
+
|
|
214
|
+
const disabledChannelReceivers = [
|
|
215
|
+
[notEnabledAppReceiverList, 'wallet'],
|
|
216
|
+
[notEnabledPushReceiverList, 'pushKit'],
|
|
217
|
+
[notEnabledEmailReceiverList, 'email'],
|
|
218
|
+
];
|
|
219
|
+
|
|
162
220
|
let wallet;
|
|
163
221
|
|
|
164
222
|
if (sender.type !== 'server') {
|
|
@@ -195,6 +253,24 @@ const sendToUserDid = async ({ sender, receiver: rawDid, notification, options,
|
|
|
195
253
|
|
|
196
254
|
// 为消息添加一个ID,wallet钱包接受消息会使用这个字段
|
|
197
255
|
data.id = data.id || doc?.id || nanoid();
|
|
256
|
+
const commonParams = {
|
|
257
|
+
node,
|
|
258
|
+
teamDid: _teamDid,
|
|
259
|
+
notificationId: doc?.id,
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// 更新用户未开启渠道状态
|
|
263
|
+
disabledChannelReceivers.forEach(([_receivers, channel]) => {
|
|
264
|
+
// 向用户对应的渠道发送消息但是用户没有开启对应渠道;属于发送失败
|
|
265
|
+
updateNotificationSendStatus({
|
|
266
|
+
...commonParams,
|
|
267
|
+
receivers: _receivers,
|
|
268
|
+
channel,
|
|
269
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
270
|
+
failedReason: NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED,
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
198
274
|
// 发送钱包消息
|
|
199
275
|
if (channels.includes('app')) {
|
|
200
276
|
for (const receiverDid of receiverAppDidList) {
|
|
@@ -202,18 +278,31 @@ const sendToUserDid = async ({ sender, receiver: rawDid, notification, options,
|
|
|
202
278
|
if (count <= 0 && keepForOfflineUser) {
|
|
203
279
|
logger.error('Online client was not found', { userDid: receiverDid });
|
|
204
280
|
await states.message.insert({ did: receiverDid, event: EVENTS.MESSAGE, data });
|
|
281
|
+
updateNotificationSendStatus({
|
|
282
|
+
...commonParams,
|
|
283
|
+
receivers: [receiverDid],
|
|
284
|
+
channel: 'wallet',
|
|
285
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
286
|
+
failedReason: NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE,
|
|
287
|
+
});
|
|
205
288
|
} else {
|
|
206
289
|
updateNotificationSendStatus({
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
notificationId: doc?.id,
|
|
210
|
-
successRes: [receiverDid],
|
|
211
|
-
failedRes: [],
|
|
290
|
+
...commonParams,
|
|
291
|
+
receivers: [receiverDid],
|
|
212
292
|
channel: 'wallet',
|
|
293
|
+
status: NOTIFICATION_SEND_STATUS.SENT,
|
|
213
294
|
});
|
|
214
295
|
}
|
|
215
296
|
});
|
|
216
297
|
}
|
|
298
|
+
} else {
|
|
299
|
+
updateNotificationSendStatus({
|
|
300
|
+
...commonParams,
|
|
301
|
+
receivers: receiverAppDidList,
|
|
302
|
+
channel: 'wallet',
|
|
303
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
304
|
+
failedReason: NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED,
|
|
305
|
+
});
|
|
217
306
|
}
|
|
218
307
|
|
|
219
308
|
if (channels.includes('push')) {
|
|
@@ -222,30 +311,37 @@ const sendToUserDid = async ({ sender, receiver: rawDid, notification, options,
|
|
|
222
311
|
sendPush(receiverPushDidList, data, { teamDid, node })
|
|
223
312
|
.then((res) => {
|
|
224
313
|
updateNotificationSendStatus({
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
notificationId: doc?.id,
|
|
228
|
-
successRes: res ? receiverPushDidList : [],
|
|
229
|
-
failedRes: [],
|
|
314
|
+
...commonParams,
|
|
315
|
+
receivers: receiverPushDidList,
|
|
230
316
|
channel: 'pushKit',
|
|
317
|
+
status: res ? NOTIFICATION_SEND_STATUS.SENT : NOTIFICATION_SEND_STATUS.FAILED,
|
|
318
|
+
failedReason: res ? null : NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE,
|
|
231
319
|
});
|
|
232
320
|
})
|
|
233
321
|
.catch((err) => {
|
|
234
322
|
// 即使失败也不应该导致程序异常,还是需要发送其他渠道
|
|
235
323
|
logger.error('Failed to send pushKit', { error: err });
|
|
236
324
|
updateNotificationSendStatus({
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
notificationId: doc?.id,
|
|
240
|
-
successRes: [],
|
|
241
|
-
failedRes: receiverPushDidList,
|
|
325
|
+
...commonParams,
|
|
326
|
+
receivers: receiverPushDidList,
|
|
242
327
|
channel: 'pushKit',
|
|
328
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
329
|
+
failedReason: err.message,
|
|
243
330
|
});
|
|
244
331
|
});
|
|
332
|
+
} else {
|
|
333
|
+
updateNotificationSendStatus({
|
|
334
|
+
...commonParams,
|
|
335
|
+
receivers: receiverPushDidList,
|
|
336
|
+
channel: 'pushKit',
|
|
337
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
338
|
+
failedReason: NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED,
|
|
339
|
+
});
|
|
245
340
|
}
|
|
246
341
|
|
|
247
342
|
// Do not send email for component activities
|
|
248
343
|
// server 的通知暂不支持发送邮箱
|
|
344
|
+
// 不建议通过这种方式禁止发送消息,要根据传入的 channel 判断
|
|
249
345
|
if (data.source !== 'app' && sender.type !== 'server') {
|
|
250
346
|
// 发送邮件消息
|
|
251
347
|
// NOTICE: 目前只有 notification 的通知能够发送邮件,并且 type 可能为 undefined
|
|
@@ -278,28 +374,34 @@ const sendToUserDid = async ({ sender, receiver: rawDid, notification, options,
|
|
|
278
374
|
},
|
|
279
375
|
});
|
|
280
376
|
updateNotificationSendStatus({
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
notificationId: doc?.id,
|
|
284
|
-
successRes: res ? [userDid] : [],
|
|
285
|
-
failedRes: [],
|
|
377
|
+
...commonParams,
|
|
378
|
+
receivers: [userDid],
|
|
286
379
|
channel: 'email',
|
|
380
|
+
status: res ? NOTIFICATION_SEND_STATUS.SENT : NOTIFICATION_SEND_STATUS.FAILED,
|
|
381
|
+
failedReason: res ? null : NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE,
|
|
287
382
|
});
|
|
288
383
|
} catch (error) {
|
|
289
384
|
logger.error('Failed to send email');
|
|
290
385
|
updateNotificationSendStatus({
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
notificationId: doc?.id,
|
|
294
|
-
successRes: [],
|
|
295
|
-
failedRes: [receiverItem?.did],
|
|
386
|
+
...commonParams,
|
|
387
|
+
receivers: [receiverItem?.did],
|
|
296
388
|
channel: 'email',
|
|
389
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
390
|
+
failedReason: error.message,
|
|
297
391
|
});
|
|
298
392
|
}
|
|
299
393
|
});
|
|
300
394
|
});
|
|
301
395
|
Promise.all(sendEmailList);
|
|
302
396
|
}
|
|
397
|
+
} else {
|
|
398
|
+
updateNotificationSendStatus({
|
|
399
|
+
...commonParams,
|
|
400
|
+
receivers: receiverEmailList.map((item) => item.did),
|
|
401
|
+
channel: 'email',
|
|
402
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
403
|
+
failedReason: NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED,
|
|
404
|
+
});
|
|
303
405
|
}
|
|
304
406
|
|
|
305
407
|
if (channels.includes('webhook') && !isSaveSkipped) {
|
|
@@ -311,30 +413,132 @@ const sendToUserDid = async ({ sender, receiver: rawDid, notification, options,
|
|
|
311
413
|
webhookSenders.set(webhook.type, webhookSender);
|
|
312
414
|
}
|
|
313
415
|
|
|
314
|
-
|
|
416
|
+
const webhookParams = {
|
|
417
|
+
[webhook.url]: {
|
|
418
|
+
type: webhook.type ?? 'api',
|
|
419
|
+
sendAt: new Date(),
|
|
420
|
+
},
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
webhookSender
|
|
424
|
+
.sendNotification(webhook.url, data)
|
|
425
|
+
.then((res) => {
|
|
426
|
+
webhookParams[webhook.url] = {
|
|
427
|
+
...webhookParams[webhook.url],
|
|
428
|
+
status: res ? NOTIFICATION_SEND_STATUS.SENT : NOTIFICATION_SEND_STATUS.FAILED,
|
|
429
|
+
failedReason: res ? '' : NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE,
|
|
430
|
+
};
|
|
431
|
+
updateNotificationSendStatus({
|
|
432
|
+
...commonParams,
|
|
433
|
+
receivers: receivers.map((item) => item.did),
|
|
434
|
+
channel: 'webhook',
|
|
435
|
+
webhookParams,
|
|
436
|
+
});
|
|
437
|
+
})
|
|
438
|
+
.catch((err) => {
|
|
439
|
+
logger.error('Failed to send webhook', { error: err });
|
|
440
|
+
webhookParams[webhook.url] = {
|
|
441
|
+
...webhookParams[webhook.url],
|
|
442
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
443
|
+
failedReason: err.message,
|
|
444
|
+
};
|
|
445
|
+
updateNotificationSendStatus({
|
|
446
|
+
...commonParams,
|
|
447
|
+
receivers: receivers.map((item) => item.did),
|
|
448
|
+
channel: 'webhook',
|
|
449
|
+
webhookParams,
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
} else {
|
|
454
|
+
// eslint-disable-next-line no-lonely-if
|
|
455
|
+
if (webhookList.length > 0) {
|
|
456
|
+
const webhookParams = {};
|
|
457
|
+
for (const webhook of webhookList) {
|
|
458
|
+
webhookParams[webhook.url] = {
|
|
459
|
+
type: webhook.type ?? 'url',
|
|
460
|
+
sendAt: new Date(),
|
|
461
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
462
|
+
failedReason: NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED,
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
updateNotificationSendStatus({
|
|
466
|
+
...commonParams,
|
|
467
|
+
receivers: receivers.map((item) => item.did),
|
|
468
|
+
channel: 'webhook',
|
|
469
|
+
webhookParams,
|
|
470
|
+
});
|
|
315
471
|
}
|
|
316
472
|
}
|
|
473
|
+
} else {
|
|
474
|
+
updateNotificationSendStatus({
|
|
475
|
+
...commonParams,
|
|
476
|
+
receivers: receiverEmailList.map((item) => item.did),
|
|
477
|
+
channel: 'email',
|
|
478
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
479
|
+
failedReason: NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED,
|
|
480
|
+
});
|
|
481
|
+
if (webhookList.length > 0) {
|
|
482
|
+
const webhookParams = {};
|
|
483
|
+
for (const webhook of webhookList) {
|
|
484
|
+
webhookParams[webhook.url] = {
|
|
485
|
+
type: webhook.type ?? 'url',
|
|
486
|
+
sendAt: new Date(),
|
|
487
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
488
|
+
failedReason: NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED,
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
updateNotificationSendStatus({
|
|
492
|
+
...commonParams,
|
|
493
|
+
receivers: receivers.map((item) => item.did),
|
|
494
|
+
channel: 'webhook',
|
|
495
|
+
webhookParams,
|
|
496
|
+
});
|
|
497
|
+
}
|
|
317
498
|
}
|
|
318
499
|
})
|
|
319
500
|
);
|
|
320
501
|
};
|
|
321
502
|
|
|
322
503
|
// server send notification to app
|
|
323
|
-
const sendToAppDid = async ({ event, appDid, data, node, wsServer }) => {
|
|
504
|
+
const sendToAppDid = async ({ event, sender, notification, receiver, appDid, data, node, wsServer }) => {
|
|
505
|
+
if (notification && sender) {
|
|
506
|
+
const teamDid = sender.appDid;
|
|
507
|
+
const { id } = notification;
|
|
508
|
+
const nodeInfo = await node.getNodeInfo({ useCache: true });
|
|
509
|
+
const isServer = teamDid === nodeInfo.did;
|
|
510
|
+
wsServer.broadcast(receiver, EVENTS.MESSAGE, notification, {}, ({ count } = {}) => {
|
|
511
|
+
if (!isServer) {
|
|
512
|
+
updateNotificationSendStatus({
|
|
513
|
+
node,
|
|
514
|
+
teamDid,
|
|
515
|
+
notificationId: id,
|
|
516
|
+
receivers: [receiver],
|
|
517
|
+
channel: 'wallet',
|
|
518
|
+
status: count > 0 ? NOTIFICATION_SEND_STATUS.SENT : NOTIFICATION_SEND_STATUS.FAILED,
|
|
519
|
+
failedReason: count > 0 ? null : NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE,
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
if (count <= 0) {
|
|
523
|
+
logger.error('Online client was not found', { userDid: receiver });
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
324
528
|
const senderInfo = await getSenderServer({ node });
|
|
325
529
|
|
|
326
|
-
const
|
|
530
|
+
const _notification = {
|
|
327
531
|
data,
|
|
328
532
|
};
|
|
329
533
|
|
|
330
|
-
|
|
534
|
+
_notification.sender = {
|
|
331
535
|
did: senderInfo.wallet.address,
|
|
332
536
|
pk: senderInfo.wallet.publicKey,
|
|
333
537
|
token: JWT.sign(senderInfo.wallet.address, senderInfo.wallet.secretKey),
|
|
334
538
|
name: senderInfo.name,
|
|
335
539
|
};
|
|
336
540
|
|
|
337
|
-
wsServer.broadcast(appDid, event,
|
|
541
|
+
wsServer.broadcast(appDid, event, _notification, { noCluster: true });
|
|
338
542
|
};
|
|
339
543
|
|
|
340
544
|
const sendCachedMessages = async (wsServer, did) => {
|
|
@@ -417,11 +621,90 @@ const onAuthenticate = async ({ channel, did, payload }) => {
|
|
|
417
621
|
}
|
|
418
622
|
};
|
|
419
623
|
|
|
624
|
+
const sendToWebhook = async ({ sender, receiver, notification, node }) => {
|
|
625
|
+
const teamDid = sender.appDid;
|
|
626
|
+
const { id, appInfo, ...rest } = notification;
|
|
627
|
+
const webhooks = appInfo?.webhooks ?? [];
|
|
628
|
+
if (!webhooks.length) {
|
|
629
|
+
throw new Error('Invalid webhook: empty');
|
|
630
|
+
}
|
|
631
|
+
if (webhooks.every((webhook) => !webhook.url)) {
|
|
632
|
+
throw new Error('Invalid webhook: url empty');
|
|
633
|
+
}
|
|
634
|
+
const nodeInfo = await node.getNodeInfo({ useCache: true });
|
|
635
|
+
|
|
636
|
+
if (nodeInfo.mode !== NODE_MODES.DEBUG) {
|
|
637
|
+
await validateNotification(notification);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
const senderInfo = await ensureSenderApp({ sender, node, nodeInfo });
|
|
641
|
+
|
|
642
|
+
// 发送消息前要添加 sender 内容。否则邮件中没有 blocklet 的信息
|
|
643
|
+
const notifications = parseNotification({ id, ...rest }, senderInfo);
|
|
644
|
+
const webhookSenderMap = new Map();
|
|
645
|
+
|
|
646
|
+
return Promise.all(
|
|
647
|
+
webhooks.map(async (webhook) => {
|
|
648
|
+
let webhookSender = webhookSenderMap.get(webhook.type);
|
|
649
|
+
if (!webhookSender) {
|
|
650
|
+
webhookSender = node.getMessageSender(webhook.type);
|
|
651
|
+
webhookSenderMap.set(webhook.type, webhookSender);
|
|
652
|
+
}
|
|
653
|
+
const webhookParams = {
|
|
654
|
+
[webhook.url]: {
|
|
655
|
+
type: webhook.type ?? 'api',
|
|
656
|
+
sendAt: new Date(),
|
|
657
|
+
},
|
|
658
|
+
};
|
|
659
|
+
try {
|
|
660
|
+
const res = await webhookSender.sendNotification(webhook.url, notifications[0]);
|
|
661
|
+
webhookParams[webhook.url] = {
|
|
662
|
+
...webhookParams[webhook.url],
|
|
663
|
+
status: res ? NOTIFICATION_SEND_STATUS.SENT : NOTIFICATION_SEND_STATUS.FAILED,
|
|
664
|
+
failedReason: res ? '' : NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE,
|
|
665
|
+
};
|
|
666
|
+
await updateNotificationSendStatus({
|
|
667
|
+
node,
|
|
668
|
+
teamDid,
|
|
669
|
+
notificationId: id,
|
|
670
|
+
receivers: [receiver],
|
|
671
|
+
channel: 'webhook',
|
|
672
|
+
webhookParams,
|
|
673
|
+
});
|
|
674
|
+
return res;
|
|
675
|
+
} catch (error) {
|
|
676
|
+
logger.error('Failed to send webhook', { error });
|
|
677
|
+
webhookParams[webhook.url] = {
|
|
678
|
+
...webhookParams[webhook.url],
|
|
679
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
680
|
+
failedReason: error.message,
|
|
681
|
+
};
|
|
682
|
+
updateNotificationSendStatus({
|
|
683
|
+
node,
|
|
684
|
+
teamDid,
|
|
685
|
+
notificationId: id,
|
|
686
|
+
receivers: [receiver],
|
|
687
|
+
channel: 'webhook',
|
|
688
|
+
webhookParams,
|
|
689
|
+
});
|
|
690
|
+
const err = new Error('Failed to send webhook');
|
|
691
|
+
err.details = error;
|
|
692
|
+
throw err;
|
|
693
|
+
}
|
|
694
|
+
})
|
|
695
|
+
);
|
|
696
|
+
};
|
|
697
|
+
|
|
420
698
|
/**
|
|
421
699
|
* app send email to user
|
|
422
700
|
*/
|
|
423
701
|
const emailSchema = Joi.string().email().required();
|
|
424
702
|
const sendToMail = async ({ sender, receiver, notification, options, node }) => {
|
|
703
|
+
const teamDid = sender.appDid;
|
|
704
|
+
const { id, appInfo, ...rest } = notification;
|
|
705
|
+
|
|
706
|
+
const receiverDid = appInfo?.receiverDid;
|
|
707
|
+
|
|
425
708
|
const receivers = uniq(Array.isArray(receiver) ? receiver : [receiver]).filter(Boolean);
|
|
426
709
|
if (receivers.length === 0) {
|
|
427
710
|
throw new Error('Invalid receiver: empty');
|
|
@@ -443,24 +726,43 @@ const sendToMail = async ({ sender, receiver, notification, options, node }) =>
|
|
|
443
726
|
}
|
|
444
727
|
|
|
445
728
|
const nodeInfo = await node.getNodeInfo({ useCache: true });
|
|
729
|
+
|
|
730
|
+
const isServer = teamDid === nodeInfo.did;
|
|
446
731
|
if (nodeInfo.mode !== NODE_MODES.DEBUG) {
|
|
447
732
|
await validateNotification(notification);
|
|
448
733
|
}
|
|
449
734
|
|
|
450
|
-
await ensureSenderApp({ sender, node, nodeInfo });
|
|
735
|
+
const senderInfo = await ensureSenderApp({ sender, node, nodeInfo });
|
|
736
|
+
|
|
737
|
+
// 发送消息前要移除 appInfo 内容。否则邮件中没有 blocklet 的信息
|
|
738
|
+
const notifications = parseNotification({ id, ...rest }, senderInfo);
|
|
451
739
|
|
|
452
740
|
const { locale = 'en' } = options || {};
|
|
453
741
|
const results = await Promise.allSettled(
|
|
454
742
|
receivers.map((email) => {
|
|
455
|
-
return sendEmail(email,
|
|
743
|
+
return sendEmail(email, notifications[0], {
|
|
456
744
|
teamDid: sender.appDid,
|
|
457
745
|
node,
|
|
458
746
|
locale,
|
|
459
747
|
});
|
|
460
748
|
})
|
|
461
749
|
);
|
|
462
|
-
|
|
463
750
|
return results.map((item) => {
|
|
751
|
+
if (!isServer && receiverDid) {
|
|
752
|
+
updateNotificationSendStatus({
|
|
753
|
+
node,
|
|
754
|
+
teamDid,
|
|
755
|
+
notificationId: id,
|
|
756
|
+
receivers: [receiverDid],
|
|
757
|
+
channel: 'email',
|
|
758
|
+
status: item.status === 'rejected' ? NOTIFICATION_SEND_STATUS.FAILED : NOTIFICATION_SEND_STATUS.SENT,
|
|
759
|
+
...(item.status === 'rejected'
|
|
760
|
+
? {
|
|
761
|
+
failedReason: item.reason instanceof Error ? item.reason?.message : item.reason,
|
|
762
|
+
}
|
|
763
|
+
: {}),
|
|
764
|
+
});
|
|
765
|
+
}
|
|
464
766
|
if (item.status === 'rejected') {
|
|
465
767
|
return {
|
|
466
768
|
...item,
|
|
@@ -472,6 +774,9 @@ const sendToMail = async ({ sender, receiver, notification, options, node }) =>
|
|
|
472
774
|
};
|
|
473
775
|
|
|
474
776
|
const sendToPush = async ({ sender, receiver, notification, options, node }) => {
|
|
777
|
+
const teamDid = sender.appDid;
|
|
778
|
+
const { id } = notification;
|
|
779
|
+
|
|
475
780
|
const receivers = uniq(Array.isArray(receiver) ? receiver : [receiver]).filter(Boolean);
|
|
476
781
|
if (receivers.length === 0) {
|
|
477
782
|
throw new Error('Invalid receiver: empty');
|
|
@@ -487,6 +792,7 @@ const sendToPush = async ({ sender, receiver, notification, options, node }) =>
|
|
|
487
792
|
}
|
|
488
793
|
|
|
489
794
|
const nodeInfo = await node.getNodeInfo({ useCache: true });
|
|
795
|
+
const isServer = teamDid === nodeInfo.did;
|
|
490
796
|
if (nodeInfo.mode !== NODE_MODES.DEBUG) {
|
|
491
797
|
await validateNotification(notification);
|
|
492
798
|
}
|
|
@@ -500,7 +806,33 @@ const sendToPush = async ({ sender, receiver, notification, options, node }) =>
|
|
|
500
806
|
teamDid: sender.appDid,
|
|
501
807
|
node,
|
|
502
808
|
locale,
|
|
503
|
-
})
|
|
809
|
+
})
|
|
810
|
+
.then((res) => {
|
|
811
|
+
if (!isServer) {
|
|
812
|
+
updateNotificationSendStatus({
|
|
813
|
+
node,
|
|
814
|
+
teamDid,
|
|
815
|
+
notificationId: id,
|
|
816
|
+
receivers,
|
|
817
|
+
channel: 'pushKit',
|
|
818
|
+
status: res ? NOTIFICATION_SEND_STATUS.SENT : NOTIFICATION_SEND_STATUS.FAILED,
|
|
819
|
+
failedReason: res ? null : NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE,
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
return res;
|
|
823
|
+
})
|
|
824
|
+
.catch((err) => {
|
|
825
|
+
logger.error('Failed to send pushKit', { error: err });
|
|
826
|
+
updateNotificationSendStatus({
|
|
827
|
+
node,
|
|
828
|
+
teamDid,
|
|
829
|
+
notificationId: id,
|
|
830
|
+
receivers,
|
|
831
|
+
channel: 'pushKit',
|
|
832
|
+
status: NOTIFICATION_SEND_STATUS.FAILED,
|
|
833
|
+
failedReason: err.message,
|
|
834
|
+
});
|
|
835
|
+
});
|
|
504
836
|
};
|
|
505
837
|
|
|
506
838
|
module.exports = {
|
|
@@ -512,4 +844,5 @@ module.exports = {
|
|
|
512
844
|
sendToMail,
|
|
513
845
|
sendToPush,
|
|
514
846
|
emailSchema,
|
|
847
|
+
sendToWebhook,
|
|
515
848
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a1 as r,j as t}from"./vendor-mui-core-
|
|
1
|
+
import{a1 as r,j as t}from"./vendor-mui-core-CCMNKHtm.js";import{_ as a}from"./vendor-arcblock-CVRRnBv2.js";var e={},o=r;Object.defineProperty(e,"__esModule",{value:!0});var u=e.default=void 0,d=o(a()),v=t;u=e.default=(0,d.default)((0,v.jsx)("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add");export{u as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a1 as r,j as t}from"./vendor-mui-core-
|
|
1
|
+
import{a1 as r,j as t}from"./vendor-mui-core-CCMNKHtm.js";import{_ as a}from"./vendor-arcblock-CVRRnBv2.js";var e={},o=r;Object.defineProperty(e,"__esModule",{value:!0});var u=e.default=void 0,i=o(a()),p=t;u=e.default=(0,i.default)((0,p.jsx)("path",{d:"m7 10 5 5 5-5z"}),"ArrowDropDown");export{u as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a1 as r,j as t}from"./vendor-mui-core-
|
|
1
|
+
import{a1 as r,j as t}from"./vendor-mui-core-CCMNKHtm.js";import{_ as a}from"./vendor-arcblock-CVRRnBv2.js";var e={},o=r;Object.defineProperty(e,"__esModule",{value:!0});var u=e.default=void 0,i=o(a()),l=t;u=e.default=(0,i.default)((0,l.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"}),"CheckCircle");export{u as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a1 as r,j as t}from"./vendor-mui-core-
|
|
1
|
+
import{a1 as r,j as t}from"./vendor-mui-core-CCMNKHtm.js";import{_ as a}from"./vendor-arcblock-CVRRnBv2.js";var e={},o=r;Object.defineProperty(e,"__esModule",{value:!0});var u=e.default=void 0,f=o(a()),i=t;u=e.default=(0,f.default)((0,i.jsx)("path",{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"}),"ChevronLeft");export{u as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a1 as r,j as t}from"./vendor-mui-core-
|
|
1
|
+
import{a1 as r,j as t}from"./vendor-mui-core-CCMNKHtm.js";import{_ as a}from"./vendor-arcblock-CVRRnBv2.js";var e={},o=r;Object.defineProperty(e,"__esModule",{value:!0});var u=e.default=void 0,i=o(a()),v=t;u=e.default=(0,i.default)((0,v.jsx)("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),"ChevronRight");export{u as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a1 as t,j as r}from"./vendor-mui-core-
|
|
1
|
+
import{a1 as t,j as r}from"./vendor-mui-core-CCMNKHtm.js";import{_ as a}from"./vendor-arcblock-CVRRnBv2.js";var e={},u=t;Object.defineProperty(e,"__esModule",{value:!0});var o=e.default=void 0,i=u(a()),l=r;o=e.default=(0,i.default)((0,l.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM8 9h8v10H8zm7.5-5-1-1h-5l-1 1H5v2h14V4z"}),"DeleteOutline");export{o as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a1 as r,j as t}from"./vendor-mui-core-
|
|
1
|
+
import{a1 as r,j as t}from"./vendor-mui-core-CCMNKHtm.js";import{_ as a}from"./vendor-arcblock-CVRRnBv2.js";var e={},o=r;Object.defineProperty(e,"__esModule",{value:!0});var u=e.default=void 0,i=o(a()),l=t;u=e.default=(0,i.default)((0,l.jsx)("path",{d:"M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z"}),"Done");export{u as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a1 as r,j as a}from"./vendor-mui-core-
|
|
1
|
+
import{a1 as r,j as a}from"./vendor-mui-core-CCMNKHtm.js";import{_ as t}from"./vendor-arcblock-CVRRnBv2.js";var e={},o=r;Object.defineProperty(e,"__esModule",{value:!0});var u=e.default=void 0,d=o(t()),i=a;u=e.default=(0,d.default)((0,i.jsx)("path",{d:"M5 20h14v-2H5zM19 9h-4V3H9v6H5l7 7z"}),"Download");export{u as d};
|