@abtnode/core 1.17.3-beta-20251117-230305-4637416e → 1.17.3-beta-20251119-034511-f26047c0
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 +49 -0
- package/lib/blocklet/manager/disk.js +1 -1
- package/lib/blocklet/manager/helper/install-component-from-url.js +1 -1
- package/lib/blocklet/migration-dist/migration.cjs +1227 -1227
- package/lib/index.js +1 -0
- package/lib/states/notification.js +47 -0
- package/lib/util/blocklet.js +13 -14
- package/lib/util/notification.js +185 -1
- package/package.json +24 -24
package/lib/api/team.js
CHANGED
|
@@ -68,6 +68,7 @@ const { passportDisplaySchema } = require('../validators/util');
|
|
|
68
68
|
const { validateUserRolePassport } = require('../util/validate-user-role-passport');
|
|
69
69
|
const { getOrgInviteLink, createOrgValidators, isOrgOwner, isAdmingPath } = require('../util/org');
|
|
70
70
|
const { createOrgInputSchema, updateOrgInputSchema } = require('../validators/org');
|
|
71
|
+
const { checkPushChannelAvailable, getNotificationPushState } = require('../util/notification');
|
|
71
72
|
|
|
72
73
|
const sanitizeUrl = (url) => {
|
|
73
74
|
if (!url) {
|
|
@@ -3410,6 +3411,54 @@ class TeamAPI extends EventEmitter {
|
|
|
3410
3411
|
throw err;
|
|
3411
3412
|
}
|
|
3412
3413
|
}
|
|
3414
|
+
|
|
3415
|
+
async getNotificationStats({ teamDid, since = '1h' }) {
|
|
3416
|
+
let startTime = dayjs().subtract(1, 'hours').toDate();
|
|
3417
|
+
|
|
3418
|
+
if (since && typeof since === 'string') {
|
|
3419
|
+
const sinceMatch = since.match(/^(\d+)h$/);
|
|
3420
|
+
if (sinceMatch) {
|
|
3421
|
+
const hours = parseInt(sinceMatch[1], 10);
|
|
3422
|
+
if (hours >= 1 && hours <= 24) {
|
|
3423
|
+
startTime = dayjs().subtract(hours, 'hours').toDate();
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
|
|
3428
|
+
try {
|
|
3429
|
+
const state = await this.getNotificationState(teamDid);
|
|
3430
|
+
const isServer = this.teamManager.isNodeTeam(teamDid);
|
|
3431
|
+
const blocklet = isServer
|
|
3432
|
+
? {}
|
|
3433
|
+
: await getBlocklet({ did: teamDid, states: this.states, dataDirs: this.dataDirs });
|
|
3434
|
+
const channelsAvailable = checkPushChannelAvailable(blocklet, isServer);
|
|
3435
|
+
const results = await state.getNotificationsBySince({ since });
|
|
3436
|
+
|
|
3437
|
+
if (results.length === 0) {
|
|
3438
|
+
return {
|
|
3439
|
+
healthy: true,
|
|
3440
|
+
message: `There have been no push records since ${startTime}. Please choose another time range`,
|
|
3441
|
+
since: startTime,
|
|
3442
|
+
channels: channelsAvailable,
|
|
3443
|
+
};
|
|
3444
|
+
}
|
|
3445
|
+
|
|
3446
|
+
const pushState = getNotificationPushState(results, channelsAvailable, isServer);
|
|
3447
|
+
|
|
3448
|
+
return {
|
|
3449
|
+
healthy: true,
|
|
3450
|
+
since: startTime,
|
|
3451
|
+
channels: pushState,
|
|
3452
|
+
};
|
|
3453
|
+
} catch (err) {
|
|
3454
|
+
logger.error('Get notification service health failed', err, { teamDid });
|
|
3455
|
+
return {
|
|
3456
|
+
healthy: false,
|
|
3457
|
+
error: err.message,
|
|
3458
|
+
since: startTime,
|
|
3459
|
+
};
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3413
3462
|
}
|
|
3414
3463
|
|
|
3415
3464
|
module.exports = TeamAPI;
|
|
@@ -575,7 +575,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
575
575
|
context.headers = Object.assign(context?.headers || {}, {
|
|
576
576
|
'x-server-did': info.did,
|
|
577
577
|
'x-server-public-key': info.pk,
|
|
578
|
-
'x-server-signature': sign(info.did, info.sk, {
|
|
578
|
+
'x-server-signature': await sign(info.did, info.sk, {
|
|
579
579
|
exp: (Date.now() + 5 * 60 * 1000) / 1000,
|
|
580
580
|
}),
|
|
581
581
|
});
|
|
@@ -62,7 +62,7 @@ const installComponentFromUrl = async ({
|
|
|
62
62
|
headers: {
|
|
63
63
|
'x-server-did': info.did,
|
|
64
64
|
'x-server-public-key': info.pk,
|
|
65
|
-
'x-server-signature': sign(info.did, info.sk, {
|
|
65
|
+
'x-server-signature': await sign(info.did, info.sk, {
|
|
66
66
|
exp: (Date.now() + 5 * 60 * 1000) / 1000,
|
|
67
67
|
}),
|
|
68
68
|
},
|