@abtnode/core 1.17.6-beta-20251216-081847-bf91c4db → 1.17.6-beta-20251216-223535-283b9ffe
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/lib/api/team.js +8 -6
- package/lib/blocklet/manager/disk.js +11 -7
- package/lib/blocklet/manager/helper/blue-green-upgrade-blocklet.js +5 -3
- package/lib/blocklet/manager/helper/install-component-from-url.js +2 -1
- package/lib/blocklet/manager/helper/upgrade-components.js +3 -1
- package/lib/blocklet/migration-dist/migration.cjs +1 -1
- package/lib/states/notification.js +67 -9
- package/package.json +25 -25
package/lib/api/team.js
CHANGED
|
@@ -2311,9 +2311,9 @@ class TeamAPI extends EventEmitter {
|
|
|
2311
2311
|
return notification;
|
|
2312
2312
|
}
|
|
2313
2313
|
|
|
2314
|
-
async getNotificationsUnreadCount({ teamDid, receiver }) {
|
|
2314
|
+
async getNotificationsUnreadCount({ teamDid, receiver }, context) {
|
|
2315
2315
|
const notificationState = await this.getNotificationState(teamDid);
|
|
2316
|
-
return notificationState.getUnreadCount({ receiver });
|
|
2316
|
+
return notificationState.getUnreadCount({ receiver }, context);
|
|
2317
2317
|
}
|
|
2318
2318
|
|
|
2319
2319
|
async createNotificationReceiver({ teamDid, receiverInstance, ...rest }, context) {
|
|
@@ -2324,11 +2324,12 @@ class TeamAPI extends EventEmitter {
|
|
|
2324
2324
|
async markAllNotificationsAsRead({ teamDid, ...rest }, context) {
|
|
2325
2325
|
const notificationState = await this.getNotificationState(teamDid);
|
|
2326
2326
|
const result = await notificationState.makeAllAsRead(rest, context);
|
|
2327
|
-
const { numAffected, notificationIds } = result;
|
|
2327
|
+
const { numAffected, notificationIds, effectRows } = result;
|
|
2328
2328
|
this.teamManager.emitReadNotification(teamDid, {
|
|
2329
2329
|
readCount: numAffected,
|
|
2330
2330
|
notificationIds,
|
|
2331
2331
|
receiver: rest.receiver,
|
|
2332
|
+
effectRows,
|
|
2332
2333
|
});
|
|
2333
2334
|
return result;
|
|
2334
2335
|
}
|
|
@@ -2351,13 +2352,14 @@ class TeamAPI extends EventEmitter {
|
|
|
2351
2352
|
|
|
2352
2353
|
async readNotifications({ teamDid, ...rest }, context) {
|
|
2353
2354
|
const notificationState = await this.getNotificationState(teamDid);
|
|
2354
|
-
const
|
|
2355
|
+
const { numAffected, effectRows } = await notificationState.read({ teamDid, ...rest }, context);
|
|
2355
2356
|
this.teamManager.emitReadNotification(teamDid, {
|
|
2356
|
-
readCount,
|
|
2357
|
+
readCount: numAffected,
|
|
2357
2358
|
receiver: rest.receiver,
|
|
2358
2359
|
notificationIds: rest.notificationIds ?? [],
|
|
2360
|
+
effectRows,
|
|
2359
2361
|
});
|
|
2360
|
-
return
|
|
2362
|
+
return numAffected;
|
|
2361
2363
|
}
|
|
2362
2364
|
|
|
2363
2365
|
async unreadNotifications({ teamDid, ...rest }, context) {
|
|
@@ -1025,7 +1025,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1025
1025
|
errorBlockletDids.map((x) => x.did)
|
|
1026
1026
|
)} start failed for ${getDisplayName(nextBlocklet)}: ${errorBlockletDids.map((x) => x.error.message).join('. ')}`;
|
|
1027
1027
|
this._createNotification(did, {
|
|
1028
|
-
title: 'Component start
|
|
1028
|
+
title: `${errorBlockletDids.length > 1 ? `${errorBlockletDids.length} components` : 'Component'} failed to start for ${getDisplayName(nextBlocklet)}`,
|
|
1029
1029
|
description: errorDescription,
|
|
1030
1030
|
entityType: 'blocklet',
|
|
1031
1031
|
entityId: did,
|
|
@@ -1371,9 +1371,9 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1371
1371
|
if (reason === SUSPENDED_REASON.expired) {
|
|
1372
1372
|
description = `${description} Reason: The subscription has expired.`;
|
|
1373
1373
|
}
|
|
1374
|
-
|
|
1374
|
+
const stopLength = componentDids?.length || 0;
|
|
1375
1375
|
this._createNotification(did, {
|
|
1376
|
-
title: 'Component
|
|
1376
|
+
title: `${stopLength > 1 ? `${stopLength} components` : 'Component'} stopped successfully for ${getDisplayName(blocklet)}`,
|
|
1377
1377
|
description,
|
|
1378
1378
|
entityType: 'blocklet',
|
|
1379
1379
|
entityId: did,
|
|
@@ -1485,8 +1485,9 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1485
1485
|
const description = `${getComponentNamesWithVersion(result, componentDids)} restart failed for ${getDisplayName(
|
|
1486
1486
|
result
|
|
1487
1487
|
)}: ${err.message || 'queue exception'}`;
|
|
1488
|
+
const upgradeLength = dids.length;
|
|
1488
1489
|
this._createNotification(did, {
|
|
1489
|
-
title: 'Component restart
|
|
1490
|
+
title: `${upgradeLength > 1 ? `${upgradeLength} components` : 'Component'} failed to restart for ${getDisplayName(result)}`,
|
|
1490
1491
|
description,
|
|
1491
1492
|
entityType: 'blocklet',
|
|
1492
1493
|
entityId: did,
|
|
@@ -3511,7 +3512,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
3511
3512
|
},
|
|
3512
3513
|
});
|
|
3513
3514
|
this._createNotification(did, {
|
|
3514
|
-
title: 'Component download
|
|
3515
|
+
title: `${childrenToDownload.length > 1 ? `${childrenToDownload.length} components` : 'Component'} failed to download for ${getDisplayName(blocklet)}`,
|
|
3515
3516
|
description: `${childrenToDownload
|
|
3516
3517
|
.map((x) => `${x.meta.title}@${x.meta.version}`)
|
|
3517
3518
|
.join(', ')} download failed for ${getDisplayName(blocklet)}: ${err.message}`,
|
|
@@ -4836,8 +4837,10 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
4836
4837
|
|
|
4837
4838
|
this.emit(notificationEvent, { ...blocklet, componentDids, oldBlocklet, context });
|
|
4838
4839
|
|
|
4840
|
+
const upgradeLength = componentDids?.length || 0;
|
|
4841
|
+
|
|
4839
4842
|
this._createNotification(did, {
|
|
4840
|
-
title: `Component ${actionName}
|
|
4843
|
+
title: `${upgradeLength > 1 ? `${upgradeLength} components` : 'Component'} ${actionName} successfully for ${title}`,
|
|
4841
4844
|
description: `${getComponentNamesWithVersion(
|
|
4842
4845
|
newBlocklet,
|
|
4843
4846
|
componentDids
|
|
@@ -4896,8 +4899,9 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
4896
4899
|
context,
|
|
4897
4900
|
});
|
|
4898
4901
|
|
|
4902
|
+
const upgradeLength = componentDids?.length || 0;
|
|
4899
4903
|
this._createNotification(did, {
|
|
4900
|
-
title: `Component ${actionName}
|
|
4904
|
+
title: `${upgradeLength > 1 ? `${upgradeLength} components` : 'Component'} failed to ${actionName} for ${title}`,
|
|
4901
4905
|
description: `${getComponentNamesWithVersion(newBlocklet, componentDids)} ${actionName} failed for ${title}: ${
|
|
4902
4906
|
err.message
|
|
4903
4907
|
}.`,
|
|
@@ -131,8 +131,10 @@ const blueGreenUpgradeBlocklet = async (
|
|
|
131
131
|
|
|
132
132
|
manager.emit(notificationEvent, { ...blocklet, componentDids, oldBlocklet, context });
|
|
133
133
|
|
|
134
|
+
const upgradeLength = componentDids?.length || 0;
|
|
135
|
+
|
|
134
136
|
manager._createNotification(did, {
|
|
135
|
-
title: `Component ${actionName}
|
|
137
|
+
title: `${upgradeLength > 1 ? `${upgradeLength} components` : 'Component'} ${actionName} successfully for ${title}`,
|
|
136
138
|
description: `${getComponentNamesWithVersion(
|
|
137
139
|
newBlocklet,
|
|
138
140
|
componentDids
|
|
@@ -218,9 +220,9 @@ const blueGreenUpgradeBlocklet = async (
|
|
|
218
220
|
blocklet: { ...newBlocklet, componentDids, error: { message: err.message } },
|
|
219
221
|
context,
|
|
220
222
|
});
|
|
221
|
-
|
|
223
|
+
const upgradeLength = componentDids?.length || 0;
|
|
222
224
|
manager._createNotification(did, {
|
|
223
|
-
title: `Component ${actionName}
|
|
225
|
+
title: `${upgradeLength > 1 ? `${upgradeLength} components` : 'Component'} failed to ${actionName} for ${title}`,
|
|
224
226
|
description: `${getComponentNamesWithVersion(newBlocklet, componentDids)} ${actionName} failed for ${title}: ${
|
|
225
227
|
err.message
|
|
226
228
|
}.`,
|
|
@@ -207,8 +207,9 @@ const installComponentFromUrl = async ({
|
|
|
207
207
|
context: { ...context, createAuditLog: false },
|
|
208
208
|
});
|
|
209
209
|
|
|
210
|
+
const installLength = componentDids.length;
|
|
210
211
|
manager._createNotification(rootDid, {
|
|
211
|
-
title: `Component ${actionName}
|
|
212
|
+
title: `${installLength > 1 ? `${installLength} components` : 'Component'} failed to ${actionName} for ${newBlocklet.meta.title}`,
|
|
212
213
|
description: `${getComponentNamesWithVersion(newBlocklet, componentDids)} ${actionName} failed for ${
|
|
213
214
|
newBlocklet.meta.title
|
|
214
215
|
}: ${err.message || 'queue exception'}.`,
|
|
@@ -157,8 +157,10 @@ const upgrade = async ({ updateId, componentDids, context, states, manager }) =>
|
|
|
157
157
|
context: { ...context, createAuditLog: false },
|
|
158
158
|
});
|
|
159
159
|
|
|
160
|
+
const upgradeLength = componentDids?.length || 0;
|
|
161
|
+
|
|
160
162
|
manager._createNotification(did, {
|
|
161
|
-
title: 'Component upgrade
|
|
163
|
+
title: `${upgradeLength > 1 ? `${upgradeLength} components` : 'Component'} failed to upgrade for ${oldBlocklet.meta.title}`,
|
|
162
164
|
description: `${getComponentNamesWithVersion(oldBlocklet, componentDids)} upgrade failed for ${
|
|
163
165
|
oldBlocklet.meta.title
|
|
164
166
|
}: ${err.message || 'queue exception'}.`,
|
|
@@ -39044,7 +39044,7 @@ module.exports = require("zlib");
|
|
|
39044
39044
|
/***/ ((module) => {
|
|
39045
39045
|
|
|
39046
39046
|
"use strict";
|
|
39047
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.17.5","description":"","main":"lib/index.js","files":["lib"],"scripts":{"lint":"eslint tests lib --ignore-pattern \'tests/assets/*\'","lint:fix":"eslint --fix tests lib"},"keywords":[],"author":"wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)","license":"Apache-2.0","dependencies":{"@abtnode/analytics":"1.17.5","@abtnode/auth":"1.17.5","@abtnode/certificate-manager":"1.17.5","@abtnode/constant":"1.17.5","@abtnode/cron":"1.17.5","@abtnode/db-cache":"1.17.5","@abtnode/docker-utils":"1.17.5","@abtnode/logger":"1.17.5","@abtnode/models":"1.17.5","@abtnode/queue":"1.17.5","@abtnode/rbac":"1.17.5","@abtnode/router-provider":"1.17.5","@abtnode/static-server":"1.17.5","@abtnode/timemachine":"1.17.5","@abtnode/util":"1.17.5","@aigne/aigne-hub":"^0.10.15","@arcblock/did":"^1.27.15","@arcblock/did-connect-js":"^1.27.15","@arcblock/did-ext":"^1.27.15","@arcblock/did-motif":"^1.1.14","@arcblock/did-util":"^1.27.15","@arcblock/event-hub":"^1.27.15","@arcblock/jwt":"^1.27.15","@arcblock/pm2-events":"^0.0.5","@arcblock/validator":"^1.27.15","@arcblock/vc":"^1.27.15","@blocklet/constant":"1.17.5","@blocklet/did-space-js":"^1.2.10","@blocklet/env":"1.17.5","@blocklet/error":"^0.3.5","@blocklet/meta":"1.17.5","@blocklet/resolver":"1.17.5","@blocklet/sdk":"1.17.5","@blocklet/server-js":"1.17.5","@blocklet/store":"1.17.5","@blocklet/theme":"^3.2.14","@fidm/x509":"^1.2.1","@ocap/mcrypto":"^1.27.15","@ocap/util":"^1.27.15","@ocap/wallet":"^1.27.15","@slack/webhook":"^7.0.6","archiver":"^7.0.1","axios":"^1.7.9","axon":"^2.0.3","chalk":"^4.1.2","cross-spawn":"^7.0.3","dayjs":"^1.11.13","deep-diff":"^1.0.2","detect-port":"^1.5.1","envfile":"^7.1.0","escape-string-regexp":"^4.0.0","fast-glob":"^3.3.2","filesize":"^10.1.1","flat":"^5.0.2","fs-extra":"^11.2.0","get-port":"^5.1.1","hasha":"^5.2.2","is-base64":"^1.1.0","is-cidr":"4","is-ip":"3","is-url":"^1.2.4","joi":"17.12.2","joi-extension-semver":"^5.0.0","js-yaml":"^4.1.0","kill-port":"^2.0.1","lodash":"^4.17.21","node-stream-zip":"^1.15.0","p-all":"^3.0.0","p-limit":"^3.1.0","p-map":"^4.0.0","p-retry":"^4.6.2","p-wait-for":"^3.2.0","private-ip":"^2.3.4","rate-limiter-flexible":"^5.0.5","read-last-lines":"^1.8.0","semver":"^7.6.3","sequelize":"^6.35.0","shelljs":"^0.8.5","slugify":"^1.6.6","ssri":"^8.0.1","stream-throttle":"^0.1.3","stream-to-promise":"^3.0.0","systeminformation":"^5.23.3","tail":"^2.2.4","tar":"^6.1.11","transliteration":"
|
|
39047
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.17.5","description":"","main":"lib/index.js","files":["lib"],"scripts":{"lint":"eslint tests lib --ignore-pattern \'tests/assets/*\'","lint:fix":"eslint --fix tests lib"},"keywords":[],"author":"wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)","license":"Apache-2.0","dependencies":{"@abtnode/analytics":"1.17.5","@abtnode/auth":"1.17.5","@abtnode/certificate-manager":"1.17.5","@abtnode/constant":"1.17.5","@abtnode/cron":"1.17.5","@abtnode/db-cache":"1.17.5","@abtnode/docker-utils":"1.17.5","@abtnode/logger":"1.17.5","@abtnode/models":"1.17.5","@abtnode/queue":"1.17.5","@abtnode/rbac":"1.17.5","@abtnode/router-provider":"1.17.5","@abtnode/static-server":"1.17.5","@abtnode/timemachine":"1.17.5","@abtnode/util":"1.17.5","@aigne/aigne-hub":"^0.10.15","@arcblock/did":"^1.27.15","@arcblock/did-connect-js":"^1.27.15","@arcblock/did-ext":"^1.27.15","@arcblock/did-motif":"^1.1.14","@arcblock/did-util":"^1.27.15","@arcblock/event-hub":"^1.27.15","@arcblock/jwt":"^1.27.15","@arcblock/pm2-events":"^0.0.5","@arcblock/validator":"^1.27.15","@arcblock/vc":"^1.27.15","@blocklet/constant":"1.17.5","@blocklet/did-space-js":"^1.2.10","@blocklet/env":"1.17.5","@blocklet/error":"^0.3.5","@blocklet/meta":"1.17.5","@blocklet/resolver":"1.17.5","@blocklet/sdk":"1.17.5","@blocklet/server-js":"1.17.5","@blocklet/store":"1.17.5","@blocklet/theme":"^3.2.14","@fidm/x509":"^1.2.1","@ocap/mcrypto":"^1.27.15","@ocap/util":"^1.27.15","@ocap/wallet":"^1.27.15","@slack/webhook":"^7.0.6","archiver":"^7.0.1","axios":"^1.7.9","axon":"^2.0.3","chalk":"^4.1.2","cross-spawn":"^7.0.3","dayjs":"^1.11.13","deep-diff":"^1.0.2","detect-port":"^1.5.1","envfile":"^7.1.0","escape-string-regexp":"^4.0.0","fast-glob":"^3.3.2","filesize":"^10.1.1","flat":"^5.0.2","fs-extra":"^11.2.0","get-port":"^5.1.1","hasha":"^5.2.2","is-base64":"^1.1.0","is-cidr":"4","is-ip":"3","is-url":"^1.2.4","joi":"17.12.2","joi-extension-semver":"^5.0.0","js-yaml":"^4.1.0","kill-port":"^2.0.1","lodash":"^4.17.21","node-stream-zip":"^1.15.0","p-all":"^3.0.0","p-limit":"^3.1.0","p-map":"^4.0.0","p-retry":"^4.6.2","p-wait-for":"^3.2.0","private-ip":"^2.3.4","rate-limiter-flexible":"^5.0.5","read-last-lines":"^1.8.0","semver":"^7.6.3","sequelize":"^6.35.0","shelljs":"^0.8.5","slugify":"^1.6.6","ssri":"^8.0.1","stream-throttle":"^0.1.3","stream-to-promise":"^3.0.0","systeminformation":"^5.23.3","tail":"^2.2.4","tar":"^6.1.11","transliteration":"2.3.5","ua-parser-js":"^1.0.2","ufo":"^1.5.3","uuid":"^11.1.0","valid-url":"^1.0.9","which":"^2.0.2","xbytes":"^1.8.0"},"devDependencies":{"axios-mock-adapter":"^2.1.0","expand-tilde":"^2.0.2","express":"^4.18.2","unzipper":"^0.10.11"},"gitHead":"e5764f753181ed6a7c615cd4fc6682aacf0cb7cd"}');
|
|
39048
39048
|
|
|
39049
39049
|
/***/ }),
|
|
39050
39050
|
|
|
@@ -38,6 +38,16 @@ const pagingSchema = Joi.object({
|
|
|
38
38
|
pageSize: Joi.number().integer().min(1).default(10),
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
+
const isAdminRole = (role) => {
|
|
42
|
+
return [
|
|
43
|
+
ROLES.ADMIN,
|
|
44
|
+
ROLES.OWNER,
|
|
45
|
+
SERVER_ROLES.BLOCKLET_ADMIN,
|
|
46
|
+
SERVER_ROLES.BLOCKLET_OWNER,
|
|
47
|
+
SERVER_ROLES.BLOCKLET_SDK,
|
|
48
|
+
].includes(role);
|
|
49
|
+
};
|
|
50
|
+
|
|
41
51
|
/**
|
|
42
52
|
* @extends BaseState<import('@abtnode/models').NotificationState>
|
|
43
53
|
*/
|
|
@@ -256,6 +266,10 @@ class NotificationState extends BaseState {
|
|
|
256
266
|
const conditions = ["n.type = 'notification'"];
|
|
257
267
|
const dids = await this.getUserDids(receiver);
|
|
258
268
|
const replacements = { dids };
|
|
269
|
+
const { role } = context.user;
|
|
270
|
+
if (!isAdminRole(role)) {
|
|
271
|
+
conditions.push("n.source != 'system'");
|
|
272
|
+
}
|
|
259
273
|
|
|
260
274
|
if (typeof read === 'boolean') {
|
|
261
275
|
conditions.push('nr.read = :read');
|
|
@@ -445,14 +459,35 @@ class NotificationState extends BaseState {
|
|
|
445
459
|
if (errorMsg) {
|
|
446
460
|
throw new Error(errorMsg);
|
|
447
461
|
}
|
|
462
|
+
|
|
448
463
|
logger.info('mark notification as read', { notificationIds });
|
|
449
464
|
const receiverDids = await this.getUserDids(receiver);
|
|
465
|
+
const { role } = context.user;
|
|
466
|
+
|
|
467
|
+
// 根据角色过滤通知 ID,非管理员用户不能标记系统通知为已读
|
|
468
|
+
let filteredNotificationIds = notificationIds;
|
|
469
|
+
if (!isAdminRole(role)) {
|
|
470
|
+
const nonSystemNotifications = await this.find({
|
|
471
|
+
id: { $in: notificationIds },
|
|
472
|
+
source: { $ne: 'system' },
|
|
473
|
+
});
|
|
474
|
+
filteredNotificationIds = nonSystemNotifications.map((n) => n.id);
|
|
475
|
+
}
|
|
476
|
+
|
|
450
477
|
const conditions = {
|
|
451
|
-
notificationId: { $in:
|
|
478
|
+
notificationId: { $in: filteredNotificationIds },
|
|
452
479
|
receiver: { $in: receiverDids },
|
|
453
480
|
};
|
|
454
|
-
const [numAffected] = await this.notificationReceivers.update(
|
|
455
|
-
|
|
481
|
+
const [numAffected, rows] = await this.notificationReceivers.update(
|
|
482
|
+
conditions,
|
|
483
|
+
{ $set: { read: true } },
|
|
484
|
+
{ returnBeforeUpdatedDocs: true }
|
|
485
|
+
);
|
|
486
|
+
|
|
487
|
+
const notifications = await this.find({ id: { $in: rows.map((row) => row.notificationId) } }, { id: 1, source: 1 });
|
|
488
|
+
const sourceMap = Object.fromEntries(notifications.map((n) => [n.id, { source: n.source }]));
|
|
489
|
+
|
|
490
|
+
return { numAffected, effectRows: sourceMap };
|
|
456
491
|
}
|
|
457
492
|
|
|
458
493
|
async unread({ notificationIds, receiver }, context) {
|
|
@@ -548,12 +583,13 @@ class NotificationState extends BaseState {
|
|
|
548
583
|
/**
|
|
549
584
|
* 获取当前用户未读消息数量
|
|
550
585
|
*/
|
|
551
|
-
getUnreadCount({ receiver }) {
|
|
552
|
-
|
|
553
|
-
|
|
586
|
+
getUnreadCount({ receiver }, context) {
|
|
587
|
+
const errorMsg = receiverDidValidation(receiver, context);
|
|
588
|
+
if (errorMsg) {
|
|
589
|
+
throw new Error(errorMsg);
|
|
554
590
|
}
|
|
555
591
|
|
|
556
|
-
return this.getUnreadNotificationCount({ receiver });
|
|
592
|
+
return this.getUnreadNotificationCount({ receiver }, context);
|
|
557
593
|
}
|
|
558
594
|
|
|
559
595
|
/**
|
|
@@ -566,20 +602,37 @@ class NotificationState extends BaseState {
|
|
|
566
602
|
}
|
|
567
603
|
|
|
568
604
|
const receiverDids = await this.getUserDids(receiver);
|
|
605
|
+
const { role } = context.user;
|
|
606
|
+
|
|
607
|
+
// 根据角色构建查询条件,非管理员用户不能标记系统通知为已读
|
|
608
|
+
let notificationIdCondition = {};
|
|
609
|
+
if (!isAdminRole(role)) {
|
|
610
|
+
const nonSystemNotifications = await this.find({
|
|
611
|
+
source: { $ne: 'system' },
|
|
612
|
+
});
|
|
613
|
+
notificationIdCondition = {
|
|
614
|
+
notificationId: { [Op.in]: nonSystemNotifications.map((n) => n.id) },
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
|
|
569
618
|
const [numAffected, rows] = await this.notificationReceivers.update(
|
|
570
619
|
{
|
|
571
620
|
where: {
|
|
572
621
|
receiver: { [Op.in]: receiverDids },
|
|
573
622
|
read: false,
|
|
623
|
+
...notificationIdCondition,
|
|
574
624
|
},
|
|
575
625
|
attributes: ['notificationId'],
|
|
576
626
|
},
|
|
577
627
|
{ $set: { read: true } },
|
|
578
628
|
{ returnBeforeUpdatedDocs: true }
|
|
579
629
|
);
|
|
630
|
+
const notifications = await this.find({ id: { $in: rows.map((row) => row.notificationId) } }, { id: 1, source: 1 });
|
|
631
|
+
const sourceMap = Object.fromEntries(notifications.map((n) => [n.id, { source: n.source }]));
|
|
580
632
|
return {
|
|
581
633
|
numAffected,
|
|
582
634
|
notificationIds: rows.map((item) => item.notificationId),
|
|
635
|
+
effectRows: sourceMap,
|
|
583
636
|
};
|
|
584
637
|
}
|
|
585
638
|
|
|
@@ -898,10 +951,10 @@ class NotificationState extends BaseState {
|
|
|
898
951
|
throw new Error(errorMsg);
|
|
899
952
|
}
|
|
900
953
|
|
|
901
|
-
return this.getUnreadNotificationCount({ receiver, ...rest });
|
|
954
|
+
return this.getUnreadNotificationCount({ receiver, ...rest }, context);
|
|
902
955
|
}
|
|
903
956
|
|
|
904
|
-
async getUnreadNotificationCount({ receiver, severity, componentDid, entityId, source } = {}) {
|
|
957
|
+
async getUnreadNotificationCount({ receiver, severity, componentDid, entityId, source } = {}, context) {
|
|
905
958
|
// 构建基础查询条件
|
|
906
959
|
const conditions = ["n.type = 'notification'"];
|
|
907
960
|
const dids = await this.getUserDids(receiver);
|
|
@@ -911,6 +964,11 @@ class NotificationState extends BaseState {
|
|
|
911
964
|
conditions.push('nr.read = :read');
|
|
912
965
|
replacements.read = false;
|
|
913
966
|
|
|
967
|
+
const { role } = context.user;
|
|
968
|
+
if (!isAdminRole(role)) {
|
|
969
|
+
conditions.push("n.source != 'system'");
|
|
970
|
+
}
|
|
971
|
+
|
|
914
972
|
if (severity && severity.length) {
|
|
915
973
|
conditions.push('n.severity IN (:severity)');
|
|
916
974
|
replacements.severity = severity;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.17.6-beta-20251216-
|
|
6
|
+
"version": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -17,21 +17,21 @@
|
|
|
17
17
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@abtnode/analytics": "1.17.6-beta-20251216-
|
|
21
|
-
"@abtnode/auth": "1.17.6-beta-20251216-
|
|
22
|
-
"@abtnode/certificate-manager": "1.17.6-beta-20251216-
|
|
23
|
-
"@abtnode/constant": "1.17.6-beta-20251216-
|
|
24
|
-
"@abtnode/cron": "1.17.6-beta-20251216-
|
|
25
|
-
"@abtnode/db-cache": "1.17.6-beta-20251216-
|
|
26
|
-
"@abtnode/docker-utils": "1.17.6-beta-20251216-
|
|
27
|
-
"@abtnode/logger": "1.17.6-beta-20251216-
|
|
28
|
-
"@abtnode/models": "1.17.6-beta-20251216-
|
|
29
|
-
"@abtnode/queue": "1.17.6-beta-20251216-
|
|
30
|
-
"@abtnode/rbac": "1.17.6-beta-20251216-
|
|
31
|
-
"@abtnode/router-provider": "1.17.6-beta-20251216-
|
|
32
|
-
"@abtnode/static-server": "1.17.6-beta-20251216-
|
|
33
|
-
"@abtnode/timemachine": "1.17.6-beta-20251216-
|
|
34
|
-
"@abtnode/util": "1.17.6-beta-20251216-
|
|
20
|
+
"@abtnode/analytics": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
21
|
+
"@abtnode/auth": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
22
|
+
"@abtnode/certificate-manager": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
23
|
+
"@abtnode/constant": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
24
|
+
"@abtnode/cron": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
25
|
+
"@abtnode/db-cache": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
26
|
+
"@abtnode/docker-utils": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
27
|
+
"@abtnode/logger": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
28
|
+
"@abtnode/models": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
29
|
+
"@abtnode/queue": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
30
|
+
"@abtnode/rbac": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
31
|
+
"@abtnode/router-provider": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
32
|
+
"@abtnode/static-server": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
33
|
+
"@abtnode/timemachine": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
34
|
+
"@abtnode/util": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
35
35
|
"@aigne/aigne-hub": "^0.10.15",
|
|
36
36
|
"@arcblock/did": "^1.27.15",
|
|
37
37
|
"@arcblock/did-connect-js": "^1.27.15",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
"@arcblock/pm2-events": "^0.0.5",
|
|
44
44
|
"@arcblock/validator": "^1.27.15",
|
|
45
45
|
"@arcblock/vc": "^1.27.15",
|
|
46
|
-
"@blocklet/constant": "1.17.6-beta-20251216-
|
|
46
|
+
"@blocklet/constant": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
47
47
|
"@blocklet/did-space-js": "^1.2.10",
|
|
48
|
-
"@blocklet/env": "1.17.6-beta-20251216-
|
|
48
|
+
"@blocklet/env": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
49
49
|
"@blocklet/error": "^0.3.5",
|
|
50
|
-
"@blocklet/meta": "1.17.6-beta-20251216-
|
|
51
|
-
"@blocklet/resolver": "1.17.6-beta-20251216-
|
|
52
|
-
"@blocklet/sdk": "1.17.6-beta-20251216-
|
|
53
|
-
"@blocklet/server-js": "1.17.6-beta-20251216-
|
|
54
|
-
"@blocklet/store": "1.17.6-beta-20251216-
|
|
50
|
+
"@blocklet/meta": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
51
|
+
"@blocklet/resolver": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
52
|
+
"@blocklet/sdk": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
53
|
+
"@blocklet/server-js": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
54
|
+
"@blocklet/store": "1.17.6-beta-20251216-223535-283b9ffe",
|
|
55
55
|
"@blocklet/theme": "^3.2.14",
|
|
56
56
|
"@fidm/x509": "^1.2.1",
|
|
57
57
|
"@ocap/mcrypto": "^1.27.15",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"systeminformation": "^5.23.3",
|
|
103
103
|
"tail": "^2.2.4",
|
|
104
104
|
"tar": "^6.1.11",
|
|
105
|
-
"transliteration": "
|
|
105
|
+
"transliteration": "2.3.5",
|
|
106
106
|
"ua-parser-js": "^1.0.2",
|
|
107
107
|
"ufo": "^1.5.3",
|
|
108
108
|
"uuid": "^11.1.0",
|
|
@@ -116,5 +116,5 @@
|
|
|
116
116
|
"express": "^4.18.2",
|
|
117
117
|
"unzipper": "^0.10.11"
|
|
118
118
|
},
|
|
119
|
-
"gitHead": "
|
|
119
|
+
"gitHead": "00f2aa2d19ce17e3e15b8ab7a200830f633e9030"
|
|
120
120
|
}
|