@abtnode/core 1.17.8-beta-20260121-102603-f9d0176f → 1.17.8-beta-20260125-093329-64b43854
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.
|
@@ -2,6 +2,8 @@ const logger = require('@abtnode/logger')('@abtnode/core:api:team:org-crud');
|
|
|
2
2
|
const { CustomError } = require('@blocklet/error');
|
|
3
3
|
const md5 = require('@abtnode/util/lib/md5');
|
|
4
4
|
const { sanitizeTag } = require('@abtnode/util/lib/sanitize');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const fs = require('fs-extra');
|
|
5
7
|
|
|
6
8
|
const { createOrgValidators } = require('../../util/org');
|
|
7
9
|
const { createOrgInputSchema, updateOrgInputSchema } = require('../../validators/org');
|
|
@@ -159,7 +161,33 @@ async function updateOrg(api, { teamDid, org }, context) {
|
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
const state = await api.getOrgState(teamDid);
|
|
162
|
-
|
|
164
|
+
|
|
165
|
+
// 获取旧的 org 数据,用于比对 avatar 是否发生变化
|
|
166
|
+
const oldOrg = await state.getOrg(org.id);
|
|
167
|
+
|
|
168
|
+
const result = await state.updateOrg({ org: sanitizedOrg }, context);
|
|
169
|
+
|
|
170
|
+
// 如果 avatar 发生变化,删除旧的 avatar 文件(不影响主流程)
|
|
171
|
+
try {
|
|
172
|
+
if (oldOrg?.avatar && result.avatar && oldOrg.avatar !== result.avatar) {
|
|
173
|
+
const blocklet = await getBlocklet({
|
|
174
|
+
did: teamDid,
|
|
175
|
+
states: api.states,
|
|
176
|
+
dataDirs: api.dataDirs,
|
|
177
|
+
useCache: true,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const oldAvatarPath = path.resolve(blocklet.env.dataDir, 'orgs', oldOrg.avatar);
|
|
181
|
+
if (fs.existsSync(oldAvatarPath)) {
|
|
182
|
+
await fs.remove(oldAvatarPath);
|
|
183
|
+
logger.info('Successfully removed old org avatar', { teamDid, orgId: result.id, oldAvatar: oldOrg.avatar });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
} catch (err) {
|
|
187
|
+
logger.error('remove org avatar file', { err, teamDid, orgId: result.id, avatar: result.avatar });
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return result;
|
|
163
191
|
} catch (err) {
|
|
164
192
|
logger.error('Failed to update org', { err, teamDid });
|
|
165
193
|
throw err;
|
|
@@ -38823,7 +38823,8 @@ const USER_PROFILE_SYNC_FIELDS = [
|
|
|
38823
38823
|
"phoneVerified",
|
|
38824
38824
|
"metadata",
|
|
38825
38825
|
"address",
|
|
38826
|
-
"extra"
|
|
38826
|
+
"extra",
|
|
38827
|
+
"name"
|
|
38827
38828
|
];
|
|
38828
38829
|
const SITE_SYNC_FIELDS = [
|
|
38829
38830
|
"action",
|
|
@@ -39096,7 +39097,7 @@ exports.isSystemRole = isSystemRole;
|
|
|
39096
39097
|
/***/ ((module) => {
|
|
39097
39098
|
|
|
39098
39099
|
"use strict";
|
|
39099
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.17.7","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.7","@abtnode/auth":"1.17.7","@abtnode/certificate-manager":"1.17.7","@abtnode/constant":"1.17.7","@abtnode/cron":"1.17.7","@abtnode/db-cache":"1.17.7","@abtnode/docker-utils":"1.17.7","@abtnode/logger":"1.17.7","@abtnode/models":"1.17.7","@abtnode/queue":"1.17.7","@abtnode/rbac":"1.17.7","@abtnode/router-provider":"1.17.7","@abtnode/util":"1.17.7","@arcblock/did":"^1.28.
|
|
39100
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.17.7","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.7","@abtnode/auth":"1.17.7","@abtnode/certificate-manager":"1.17.7","@abtnode/constant":"1.17.7","@abtnode/cron":"1.17.7","@abtnode/db-cache":"1.17.7","@abtnode/docker-utils":"1.17.7","@abtnode/logger":"1.17.7","@abtnode/models":"1.17.7","@abtnode/queue":"1.17.7","@abtnode/rbac":"1.17.7","@abtnode/router-provider":"1.17.7","@abtnode/util":"1.17.7","@arcblock/did":"^1.28.6","@arcblock/did-connect-js":"^1.28.6","@arcblock/did-ext":"^1.28.6","@arcblock/did-motif":"^1.1.14","@arcblock/did-util":"^1.28.6","@arcblock/event-hub":"^1.28.6","@arcblock/jwt":"^1.28.6","@arcblock/pm2-events":"^0.0.5","@arcblock/validator":"^1.28.6","@arcblock/vc":"^1.28.6","@blocklet/constant":"1.17.7","@blocklet/did-space-js":"^1.2.15","@blocklet/env":"1.17.7","@blocklet/error":"^0.3.5","@blocklet/meta":"1.17.7","@blocklet/resolver":"1.17.7","@blocklet/sdk":"1.17.7","@blocklet/server-js":"1.17.7","@blocklet/store":"1.17.7","@blocklet/theme":"^3.4.10","@fidm/x509":"^1.2.1","@ocap/mcrypto":"^1.28.6","@ocap/util":"^1.28.6","@ocap/wallet":"^1.28.6","@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"}');
|
|
39100
39101
|
|
|
39101
39102
|
/***/ }),
|
|
39102
39103
|
|
package/lib/event/index.js
CHANGED
|
@@ -829,9 +829,6 @@ module.exports = ({
|
|
|
829
829
|
listen(teamAPI, BlockletEvents.updated, onEvent);
|
|
830
830
|
|
|
831
831
|
listen(teamManager, BlockletEvents.storeChange, onEvent);
|
|
832
|
-
listen(teamManager, EVENTS.NOTIFICATION_BLOCKLET_CREATE, (name, data) => {
|
|
833
|
-
onEvent(name, data, true);
|
|
834
|
-
});
|
|
835
832
|
|
|
836
833
|
[EVENTS.NOTIFICATION_BLOCKLET_READ, EVENTS.NOTIFICATION_READ].forEach((eventName) => {
|
|
837
834
|
listen(teamManager, eventName, onEvent);
|
package/lib/states/user.js
CHANGED
|
@@ -553,12 +553,13 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
553
553
|
}
|
|
554
554
|
|
|
555
555
|
/**
|
|
556
|
-
* get user by did
|
|
556
|
+
* get user by did or name
|
|
557
557
|
* @param {string} did user's did
|
|
558
558
|
*/
|
|
559
559
|
async getUser(
|
|
560
560
|
did,
|
|
561
561
|
{
|
|
562
|
+
name,
|
|
562
563
|
enableConnectedAccount = false,
|
|
563
564
|
includeTags = false,
|
|
564
565
|
includePassports = true,
|
|
@@ -566,10 +567,17 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
566
567
|
selection = {},
|
|
567
568
|
} = {}
|
|
568
569
|
) {
|
|
569
|
-
|
|
570
|
+
const where = {};
|
|
571
|
+
if (did) {
|
|
572
|
+
where.did = did;
|
|
573
|
+
} else if (name) {
|
|
574
|
+
where.name = name;
|
|
575
|
+
}
|
|
576
|
+
let user = await this.findOne({ where, include: includeTags ? [this.getTagInclude()] : [] }, selection);
|
|
570
577
|
|
|
571
578
|
// search in connected accounts
|
|
572
579
|
if (!user && enableConnectedAccount) {
|
|
580
|
+
// connectedAccounts don't have name field, so we can only search by did
|
|
573
581
|
const connectedAccount = await this.connectedAccount.findOne({ did });
|
|
574
582
|
if (connectedAccount) {
|
|
575
583
|
user = await this.findOne({ did: connectedAccount.userDid }, selection);
|
package/lib/validators/org.js
CHANGED
|
@@ -4,6 +4,7 @@ const createOrgInputSchema = Joi.object({
|
|
|
4
4
|
name: Joi.string().required().trim().min(1).max(64),
|
|
5
5
|
description: Joi.string().optional().allow('').trim().min(1).max(255),
|
|
6
6
|
ownerDid: Joi.DID().optional().allow('').allow(null),
|
|
7
|
+
avatar: Joi.string().optional().allow('').trim().min(1).max(255),
|
|
7
8
|
});
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -13,6 +14,7 @@ const updateOrgInputSchema = Joi.object({
|
|
|
13
14
|
id: Joi.string().required(),
|
|
14
15
|
name: Joi.string().required().trim().min(1).max(20),
|
|
15
16
|
description: Joi.string().optional().allow('').trim().min(1).max(255),
|
|
17
|
+
avatar: Joi.string().optional().allow('').trim().min(1).max(255),
|
|
16
18
|
});
|
|
17
19
|
|
|
18
20
|
exports.createOrgInputSchema = createOrgInputSchema;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.17.8-beta-
|
|
6
|
+
"version": "1.17.8-beta-20260125-093329-64b43854",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -17,43 +17,43 @@
|
|
|
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.8-beta-
|
|
21
|
-
"@abtnode/auth": "1.17.8-beta-
|
|
22
|
-
"@abtnode/certificate-manager": "1.17.8-beta-
|
|
23
|
-
"@abtnode/constant": "1.17.8-beta-
|
|
24
|
-
"@abtnode/cron": "1.17.8-beta-
|
|
25
|
-
"@abtnode/db-cache": "1.17.8-beta-
|
|
26
|
-
"@abtnode/docker-utils": "1.17.8-beta-
|
|
27
|
-
"@abtnode/logger": "1.17.8-beta-
|
|
28
|
-
"@abtnode/models": "1.17.8-beta-
|
|
29
|
-
"@abtnode/queue": "1.17.8-beta-
|
|
30
|
-
"@abtnode/rbac": "1.17.8-beta-
|
|
31
|
-
"@abtnode/router-provider": "1.17.8-beta-
|
|
32
|
-
"@abtnode/util": "1.17.8-beta-
|
|
33
|
-
"@arcblock/did": "^1.28.
|
|
34
|
-
"@arcblock/did-connect-js": "^1.28.
|
|
35
|
-
"@arcblock/did-ext": "^1.28.
|
|
20
|
+
"@abtnode/analytics": "1.17.8-beta-20260125-093329-64b43854",
|
|
21
|
+
"@abtnode/auth": "1.17.8-beta-20260125-093329-64b43854",
|
|
22
|
+
"@abtnode/certificate-manager": "1.17.8-beta-20260125-093329-64b43854",
|
|
23
|
+
"@abtnode/constant": "1.17.8-beta-20260125-093329-64b43854",
|
|
24
|
+
"@abtnode/cron": "1.17.8-beta-20260125-093329-64b43854",
|
|
25
|
+
"@abtnode/db-cache": "1.17.8-beta-20260125-093329-64b43854",
|
|
26
|
+
"@abtnode/docker-utils": "1.17.8-beta-20260125-093329-64b43854",
|
|
27
|
+
"@abtnode/logger": "1.17.8-beta-20260125-093329-64b43854",
|
|
28
|
+
"@abtnode/models": "1.17.8-beta-20260125-093329-64b43854",
|
|
29
|
+
"@abtnode/queue": "1.17.8-beta-20260125-093329-64b43854",
|
|
30
|
+
"@abtnode/rbac": "1.17.8-beta-20260125-093329-64b43854",
|
|
31
|
+
"@abtnode/router-provider": "1.17.8-beta-20260125-093329-64b43854",
|
|
32
|
+
"@abtnode/util": "1.17.8-beta-20260125-093329-64b43854",
|
|
33
|
+
"@arcblock/did": "^1.28.6",
|
|
34
|
+
"@arcblock/did-connect-js": "^1.28.6",
|
|
35
|
+
"@arcblock/did-ext": "^1.28.6",
|
|
36
36
|
"@arcblock/did-motif": "^1.1.14",
|
|
37
|
-
"@arcblock/did-util": "^1.28.
|
|
38
|
-
"@arcblock/event-hub": "^1.28.
|
|
39
|
-
"@arcblock/jwt": "^1.28.
|
|
37
|
+
"@arcblock/did-util": "^1.28.6",
|
|
38
|
+
"@arcblock/event-hub": "^1.28.6",
|
|
39
|
+
"@arcblock/jwt": "^1.28.6",
|
|
40
40
|
"@arcblock/pm2-events": "^0.0.5",
|
|
41
|
-
"@arcblock/validator": "^1.28.
|
|
42
|
-
"@arcblock/vc": "^1.28.
|
|
43
|
-
"@blocklet/constant": "1.17.8-beta-
|
|
41
|
+
"@arcblock/validator": "^1.28.6",
|
|
42
|
+
"@arcblock/vc": "^1.28.6",
|
|
43
|
+
"@blocklet/constant": "1.17.8-beta-20260125-093329-64b43854",
|
|
44
44
|
"@blocklet/did-space-js": "^1.2.15",
|
|
45
|
-
"@blocklet/env": "1.17.8-beta-
|
|
45
|
+
"@blocklet/env": "1.17.8-beta-20260125-093329-64b43854",
|
|
46
46
|
"@blocklet/error": "^0.3.5",
|
|
47
|
-
"@blocklet/meta": "1.17.8-beta-
|
|
48
|
-
"@blocklet/resolver": "1.17.8-beta-
|
|
49
|
-
"@blocklet/sdk": "1.17.8-beta-
|
|
50
|
-
"@blocklet/server-js": "1.17.8-beta-
|
|
51
|
-
"@blocklet/store": "1.17.8-beta-
|
|
52
|
-
"@blocklet/theme": "^3.4.
|
|
47
|
+
"@blocklet/meta": "1.17.8-beta-20260125-093329-64b43854",
|
|
48
|
+
"@blocklet/resolver": "1.17.8-beta-20260125-093329-64b43854",
|
|
49
|
+
"@blocklet/sdk": "1.17.8-beta-20260125-093329-64b43854",
|
|
50
|
+
"@blocklet/server-js": "1.17.8-beta-20260125-093329-64b43854",
|
|
51
|
+
"@blocklet/store": "1.17.8-beta-20260125-093329-64b43854",
|
|
52
|
+
"@blocklet/theme": "^3.4.10",
|
|
53
53
|
"@fidm/x509": "^1.2.1",
|
|
54
|
-
"@ocap/mcrypto": "^1.28.
|
|
55
|
-
"@ocap/util": "^1.28.
|
|
56
|
-
"@ocap/wallet": "^1.28.
|
|
54
|
+
"@ocap/mcrypto": "^1.28.6",
|
|
55
|
+
"@ocap/util": "^1.28.6",
|
|
56
|
+
"@ocap/wallet": "^1.28.6",
|
|
57
57
|
"@slack/webhook": "^7.0.6",
|
|
58
58
|
"archiver": "^7.0.1",
|
|
59
59
|
"axios": "^1.7.9",
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"express": "^4.18.2",
|
|
114
114
|
"unzipper": "^0.10.11"
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "241254785bda907be2296228869b4fc9c1679a6b"
|
|
117
117
|
}
|