odant-work 1.0.104 → 1.0.106
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/$server/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js +15 -12
- package/$server/$folder/$class/$module/$mcp/handlers/pages/form/system/mcp/$handler/class.js +17 -24
- package/$server/$folder/$class/$module/$provider/handlers/pages/form/system/ai/$handler/class.js +15 -12
- package/$server/$folder/$class/$structure/$project/class.js +39 -5
- package/$server/$folder/$class/$structure/$project/handlers/pages/form/system/modules/$handler/class.js +40 -25
- package/$server/$folder/$class/$structure/$project/handlers/pages/form/system/requisites/$handler/class.js +1 -0
- package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/license/$handler/class.js +13 -12
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/calendar/$handler/class.js +12 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/email/$handler/class.js +12 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/folder/$handler/class.js +12 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/profile/$handler/class.js +30 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/search/$handler/class.js +12 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/$handler/class.js +14 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +5 -4
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js +1 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/requisites/$handler/class.js +3 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/settings/$handler/class.js +6 -37
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/skills/$handler/class.js +5 -4
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/tokens/$handler/class.js +10 -2
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/users/$handler/class.js +1 -0
- package/$server/$folder/$class/$structure/class.js +15 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +82 -23
- package/$server/$folder/$class/$structure/handlers/pages/form/system/agent/$handler/class.js +5 -29
- package/$server/$folder/$class/$structure/handlers/pages/form/system/database/$handler/class.js +1 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/system/messengers/$handler/class.js +1 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/system/skills/$handler/class.js +276 -179
- package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +1 -0
- package/$server/$folder/$class/ai/system.md +2 -2
- package/$server/$folder/$class/class.js +5 -1
- package/$server/$folder/$class/handlers/pages/form/system/requisites/$handler/class.js +39 -45
- package/$server/$folder/handlers/pages/form/$handler/class.js +194 -2
- package/$server/$folder/handlers/pages/form/folder/$handler/class.js +2 -611
- package/$server/$folder/lib/consultant/consultant.js +123 -66
- package/$server/$folder/lib/explorer/explorer.js +9 -21
- package/$server/$folder/lib/folder-browser/folder-browser.js +793 -0
- package/$server/$folder/lib/folder-browser/readme.md +5 -0
- package/$server/$folder/lib/prompt-bar/prompt-bar.js +24 -1
- package/$server/$folder/lib/tree/tree.js +16 -6
- package/AGENTS.md +2 -2
- package/MODULES/$domain/class.js +1 -0
- package/MODULES/$domain/handlers/pages/form/system/mcp/$handler/class.js +10 -21
- package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/handlers/pages/form/system/engine/$handler/class.js +1 -0
- package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/handlers/pages/form/system/models/$handler/class.js +5 -10
- package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/handlers/pages/form/system/training/$handler/class.js +1 -0
- package/MODULES//320/243/321/207/321/221/321/202 /320/270 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/321/213/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/241/321/207/321/221/321/202 /320/275/320/260 /320/276/320/277/320/273/320/260/321/202/321/203.html" +5 -1
- package/MODULES//320/243/321/207/321/221/321/202 /320/270 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/321/213/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/242/320/276/320/262/320/260/321/200/320/275/320/260/321/217 /320/275/320/260/320/272/320/273/320/260/320/264/320/275/320/260/321/217.html" +1 -1
- package/oda/components/layouts/editor-form/editor-form.js +54 -9
- package/package.json +1 -1
- package/sources/client.js +1 -1
- package/sources/data/print.js +27 -3
- package/sources/host/websocket.js +11 -1
- package/sources/modules/user-profile/user-tokens.js +0 -46
- package/sources/server/access/gateway.js +32 -6
- package/sources/server/chat-threads.js +32 -3
- package/sources/server/class/base-template.js +18 -18
- package/sources/server/class/feed.js +24 -12
- package/sources/server/class/security.js +97 -31
- package/sources/server/class.js +9 -0
- package/sources/server/handler.js +6 -0
- package/sources/server/user.js +12 -4
|
@@ -44,6 +44,10 @@ export async function dbForThreadStorage(storage, kind = '') {
|
|
|
44
44
|
return LOGS.dbForStorage(storage);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
function isSysSession(params = {}) {
|
|
48
|
+
return DEV_MODE || !params?.session || params.session.$user === globalThis.WORK;
|
|
49
|
+
}
|
|
50
|
+
|
|
47
51
|
function resolveActorUid(storage, params = {}) {
|
|
48
52
|
const uid = storage?.constructor?.resolveUid?.(params);
|
|
49
53
|
if (uid)
|
|
@@ -127,6 +131,12 @@ export async function openThread(storage, params = {}) {
|
|
|
127
131
|
if (!peerId)
|
|
128
132
|
throw new Error('Не указан собеседник (peerId)');
|
|
129
133
|
const threadId = dmThreadId(uid, peerId);
|
|
134
|
+
const existing = getThreadWithMeta(db, threadId, uid);
|
|
135
|
+
if (!existing && peerId !== uid && !isSysSession(params)) {
|
|
136
|
+
const contacts = await visibleContacts(storage, params).catch(() => []);
|
|
137
|
+
if (!contacts.some(c => c.id === peerId))
|
|
138
|
+
throw new Error(ACCESS_DENIED);
|
|
139
|
+
}
|
|
130
140
|
const title = String(params.title || '').trim();
|
|
131
141
|
tx(db, () => {
|
|
132
142
|
db.prepare(`
|
|
@@ -354,6 +364,12 @@ export async function sendMessage(storage, params = {}) {
|
|
|
354
364
|
const isParticipant = thread.participants.some(p => p.uid === uid);
|
|
355
365
|
if (!isParticipant && !isTwinBot)
|
|
356
366
|
throw new Error(ACCESS_DENIED);
|
|
367
|
+
if (thread.kind !== 'dm' && !isTwinBot && !isSysSession(params)) {
|
|
368
|
+
const canSee = await storage.canSee?.(storage, params).catch(() => false);
|
|
369
|
+
const roles = await storage.roles?.(params).catch(() => []) || [];
|
|
370
|
+
if (!canSee && !roles.length)
|
|
371
|
+
throw new Error(ACCESS_DENIED);
|
|
372
|
+
}
|
|
357
373
|
|
|
358
374
|
const content = String(params.message ?? params.content ?? '');
|
|
359
375
|
const msgKind = String(params.kind || 'text').trim() || 'text';
|
|
@@ -561,14 +577,26 @@ export async function visibleContacts(storage, params = {}) {
|
|
|
561
577
|
});
|
|
562
578
|
}
|
|
563
579
|
|
|
580
|
+
await Promise.resolve(globalThis.WORK?.init).catch(() => {});
|
|
581
|
+
const rootBossIds = new Set(
|
|
582
|
+
(Array.isArray(globalThis.WORK?.DATA?.['#security']?.BOSS) ? globalThis.WORK.DATA['#security'].BOSS : [])
|
|
583
|
+
.filter(id => id && !WORKPLACES.isPseudoUser(id))
|
|
584
|
+
);
|
|
585
|
+
|
|
564
586
|
const isWorkBoss = uid && globalThis.WORK
|
|
565
|
-
? (
|
|
587
|
+
? (isSysSession(params) || await globalThis.WORK._isWorkBoss?.(params).catch(() => false))
|
|
566
588
|
: Boolean(DEV_MODE);
|
|
567
589
|
|
|
568
590
|
const visibleIds = new Set();
|
|
569
591
|
const externalOnlyIds = new Set();
|
|
570
592
|
if (uid && userMap.has(uid))
|
|
571
593
|
visibleIds.add(uid);
|
|
594
|
+
if (uid) {
|
|
595
|
+
for (const bossId of rootBossIds) {
|
|
596
|
+
if (userMap.has(bossId))
|
|
597
|
+
visibleIds.add(bossId);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
572
600
|
|
|
573
601
|
if (isWorkBoss) {
|
|
574
602
|
for (const id of userMap.keys())
|
|
@@ -581,7 +609,7 @@ export async function visibleContacts(storage, params = {}) {
|
|
|
581
609
|
const containers = dom ? ((await dom.items) || []).filter(c => c && c.id && c.id[0] !== '$') : [];
|
|
582
610
|
for (const base of containers) {
|
|
583
611
|
const units = [base];
|
|
584
|
-
const sub = await base.items
|
|
612
|
+
const sub = await Promise.resolve(base.items).catch(() => []) || [];
|
|
585
613
|
for (const s of sub) {
|
|
586
614
|
if (s?.type === '$structure' || s?.DATA?.isDepartment)
|
|
587
615
|
units.push(s);
|
|
@@ -590,7 +618,7 @@ export async function visibleContacts(storage, params = {}) {
|
|
|
590
618
|
const internalSet = new Set();
|
|
591
619
|
const externalSet = new Set();
|
|
592
620
|
for (const u of units) {
|
|
593
|
-
await u.init
|
|
621
|
+
await Promise.resolve(u.init).catch(() => {});
|
|
594
622
|
const sec = u.DATA?.['#security'] || {};
|
|
595
623
|
const roles = await u.roles?.(params).catch(() => []) || [];
|
|
596
624
|
if (roles.length)
|
|
@@ -650,6 +678,7 @@ export async function visibleContacts(storage, params = {}) {
|
|
|
650
678
|
out.push({
|
|
651
679
|
...entry,
|
|
652
680
|
external: externalOnlyIds.has(id),
|
|
681
|
+
superBoss: rootBossIds.has(id),
|
|
653
682
|
});
|
|
654
683
|
}
|
|
655
684
|
return out;
|
|
@@ -72,29 +72,29 @@ export function buildBasePassportClassJs({
|
|
|
72
72
|
|
|
73
73
|
const obj = {
|
|
74
74
|
label: cleanLabel,
|
|
75
|
+
full_name: preset === 'empty' ? '' : cleanLabel,
|
|
75
76
|
inn: preset === 'empty' ? '' : '7701000000',
|
|
76
77
|
kpp: preset === 'empty' ? '' : '770101001',
|
|
77
78
|
ogrn: preset === 'empty' ? '' : '1027700000000',
|
|
79
|
+
okpo: preset === 'empty' ? '' : '00000001',
|
|
80
|
+
okato: preset === 'empty' ? '' : '45286585000',
|
|
78
81
|
address: preset === 'empty' ? '' : '101000, г. Москва, ул. Промышленная, д. 1',
|
|
82
|
+
actual_address: preset === 'empty' ? '' : '101000, г. Москва, ул. Промышленная, д. 1',
|
|
79
83
|
phone: preset === 'empty' ? '' : '+7 (495) 000-00-00',
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
{ id: 'account', label: 'Р/с', type: 'string' },
|
|
95
|
-
{ id: 'corr', label: 'К/с', type: 'string' },
|
|
96
|
-
],
|
|
97
|
-
},
|
|
84
|
+
email: '',
|
|
85
|
+
director_title: preset === 'empty' ? '' : 'Генеральный директор',
|
|
86
|
+
director: '',
|
|
87
|
+
chief_accountant: '',
|
|
88
|
+
bank_accounts: preset === 'empty' ? [] : [
|
|
89
|
+
{
|
|
90
|
+
name: 'Основной',
|
|
91
|
+
bank: 'ПАО «Расчётный Банк»',
|
|
92
|
+
bik: '044525000',
|
|
93
|
+
account: '40702810000000000001',
|
|
94
|
+
corr: '30101810000000000000',
|
|
95
|
+
is_default: true,
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
98
|
icon: 'fontawesome:s-building',
|
|
99
99
|
};
|
|
100
100
|
|
|
@@ -11,6 +11,18 @@ import { DEV_MODE } from '../../host/config.js';
|
|
|
11
11
|
|
|
12
12
|
const ACCESS_DENIED = 'Доступ запрещён';
|
|
13
13
|
|
|
14
|
+
function mergeChatPost(params = {}, post) {
|
|
15
|
+
let body = post ?? params?.post ?? params?.body ?? params?.data;
|
|
16
|
+
if (typeof body === 'string' && body.trim()) {
|
|
17
|
+
try { body = JSON.parse(body); } catch { /* ignore */ }
|
|
18
|
+
}
|
|
19
|
+
if (body && typeof body === 'object' && !Array.isArray(body)) {
|
|
20
|
+
const { session: _drop, ...safeBody } = body;
|
|
21
|
+
return { ...safeBody, ...params, session: params?.session };
|
|
22
|
+
}
|
|
23
|
+
return params;
|
|
24
|
+
}
|
|
25
|
+
|
|
14
26
|
export const classFeedMethods = {
|
|
15
27
|
/** Может ли вызывающий принудительно открыть местный лог точки (роль BOSS здесь или выше по дереву). */
|
|
16
28
|
async _canViewLocalFeed(params = {}) {
|
|
@@ -161,28 +173,28 @@ export const classFeedMethods = {
|
|
|
161
173
|
},
|
|
162
174
|
|
|
163
175
|
/** Открыть/создать беседу мессенджера (twin на $structure, dm на $user, group). */
|
|
164
|
-
async chat_thread_open(params = {}) {
|
|
165
|
-
return CHAT.openThread(this, params);
|
|
176
|
+
async chat_thread_open(params = {}, post) {
|
|
177
|
+
return CHAT.openThread(this, mergeChatPost(params, post));
|
|
166
178
|
},
|
|
167
179
|
|
|
168
180
|
/** Список бесед (mine — свои, audit — взаимодействия пользователей с Агентом для BOSS). */
|
|
169
|
-
async chat_threads_list(params = {}) {
|
|
170
|
-
return CHAT.listThreads(this, params);
|
|
181
|
+
async chat_threads_list(params = {}, post) {
|
|
182
|
+
return CHAT.listThreads(this, mergeChatPost(params, post));
|
|
171
183
|
},
|
|
172
184
|
|
|
173
185
|
/** Сообщения беседы с проверкой прав (участник или BOSS для twin-аудита). */
|
|
174
|
-
async chat_messages_list(params = {}) {
|
|
175
|
-
return CHAT.listMessages(this, params);
|
|
186
|
+
async chat_messages_list(params = {}, post) {
|
|
187
|
+
return CHAT.listMessages(this, mergeChatPost(params, post));
|
|
176
188
|
},
|
|
177
189
|
|
|
178
190
|
/** Отправить сообщение в беседу + рассылка по WebSocket. */
|
|
179
|
-
async chat_send(params = {}) {
|
|
180
|
-
return CHAT.sendMessage(this, params);
|
|
191
|
+
async chat_send(params = {}, post) {
|
|
192
|
+
return CHAT.sendMessage(this, mergeChatPost(params, post));
|
|
181
193
|
},
|
|
182
194
|
|
|
183
195
|
/** Отметить беседу прочитанной. */
|
|
184
|
-
async chat_mark_read(params = {}) {
|
|
185
|
-
return CHAT.markRead(this, params);
|
|
196
|
+
async chat_mark_read(params = {}, post) {
|
|
197
|
+
return CHAT.markRead(this, mergeChatPost(params, post));
|
|
186
198
|
},
|
|
187
199
|
|
|
188
200
|
/** Сводка непрочитанного. */
|
|
@@ -191,8 +203,8 @@ export const classFeedMethods = {
|
|
|
191
203
|
},
|
|
192
204
|
|
|
193
205
|
/** Подтвердить/отклонить карточку действия (kind = 'approval') в беседе. */
|
|
194
|
-
async chat_action(params = {}) {
|
|
195
|
-
return CHAT.resolveApproval(this, params);
|
|
206
|
+
async chat_action(params = {}, post) {
|
|
207
|
+
return CHAT.resolveApproval(this, mergeChatPost(params, post));
|
|
196
208
|
},
|
|
197
209
|
|
|
198
210
|
/** Вычисляемый список видимых контактов («Люди»). */
|
|
@@ -575,6 +575,8 @@ export const classSecurityMethods = {
|
|
|
575
575
|
}
|
|
576
576
|
if (this._isSystemItem(item))
|
|
577
577
|
return true;
|
|
578
|
+
if (this._hasRootBossOnlyAncestor(item) || this._hasRootBossOnlyAncestor(this))
|
|
579
|
+
return false;
|
|
578
580
|
if (this.areaOf(item).kind === POLICY.AREA.SECRET)
|
|
579
581
|
return false;
|
|
580
582
|
const isUserSession = Boolean(uid && params.session?.principal?.kind !== 'node');
|
|
@@ -712,41 +714,101 @@ export const classSecurityMethods = {
|
|
|
712
714
|
},
|
|
713
715
|
|
|
714
716
|
/** Есть ли у субъекта хотя бы одна внутренняя роль сотрудника (BOSS или не-external должность), а не только внешняя. */
|
|
715
|
-
async
|
|
716
|
-
if (
|
|
717
|
-
return true;
|
|
717
|
+
async _roleSummary(params = {}) {
|
|
718
|
+
if (this._isSysSession(params)) {
|
|
719
|
+
return { hasInternal: true, hasExternal: false, isWorkBoss: true, isUnitBoss: true, hasAnyRole: true };
|
|
720
|
+
}
|
|
718
721
|
const uid = this.constructor.resolveUid(params);
|
|
719
|
-
if (!uid)
|
|
720
|
-
return false;
|
|
721
|
-
|
|
722
|
-
|
|
722
|
+
if (!uid) {
|
|
723
|
+
return { hasInternal: false, hasExternal: false, isWorkBoss: false, isUnitBoss: false, hasAnyRole: false };
|
|
724
|
+
}
|
|
725
|
+
let hasInternal = false;
|
|
726
|
+
let hasExternal = false;
|
|
727
|
+
let isWorkBoss = false;
|
|
728
|
+
let isUnitBoss = false;
|
|
729
|
+
let hasAnyRole = false;
|
|
730
|
+
|
|
731
|
+
const inspectNode = async (node, isRoot = false) => {
|
|
732
|
+
const r = await Promise.resolve(node?.roles?.(params)).catch(() => []) || [];
|
|
723
733
|
if (!r.length)
|
|
724
|
-
return
|
|
734
|
+
return;
|
|
735
|
+
hasAnyRole = true;
|
|
725
736
|
const decl = node._declaredRolesSync?.() || {};
|
|
726
|
-
|
|
737
|
+
if (r.includes(this.constructor.ROLES.BOSS)) {
|
|
738
|
+
hasInternal = true;
|
|
739
|
+
if (isRoot)
|
|
740
|
+
isWorkBoss = true;
|
|
741
|
+
else
|
|
742
|
+
isUnitBoss = true;
|
|
743
|
+
}
|
|
744
|
+
for (const id of r) {
|
|
745
|
+
if (id === this.constructor.ROLES.BOSS || !decl[id]?.external)
|
|
746
|
+
hasInternal = true;
|
|
747
|
+
else
|
|
748
|
+
hasExternal = true;
|
|
749
|
+
}
|
|
727
750
|
};
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
751
|
+
|
|
752
|
+
if (globalThis.WORK)
|
|
753
|
+
await inspectNode(globalThis.WORK, true);
|
|
754
|
+
|
|
755
|
+
const dom = await globalThis.WORK?.get_item?.('/PROJECTS').catch(() => null);
|
|
756
|
+
const roots = dom ? ((await Promise.resolve(dom.items).catch(() => [])) || []).filter(b => b && b.id?.[0] !== '$') : [];
|
|
757
|
+
const stack = roots.map(node => ({ node, depth: 0 }));
|
|
758
|
+
while (stack.length) {
|
|
759
|
+
const { node, depth } = stack.pop();
|
|
760
|
+
await inspectNode(node, false);
|
|
761
|
+
if (isUnitBoss && hasInternal && hasExternal)
|
|
762
|
+
break;
|
|
763
|
+
if (depth >= 5)
|
|
764
|
+
continue;
|
|
765
|
+
const sub = await Promise.resolve(node.items).catch(() => []) || [];
|
|
766
|
+
for (const s of sub) {
|
|
767
|
+
if (s && (s.type === '$structure' || s.DATA?.isDepartment) && s.id?.[0] !== '$')
|
|
768
|
+
stack.push({ node: s, depth: depth + 1 });
|
|
745
769
|
}
|
|
770
|
+
}
|
|
771
|
+
return { hasInternal, hasExternal, isWorkBoss, isUnitBoss, hasAnyRole };
|
|
772
|
+
},
|
|
773
|
+
|
|
774
|
+
async _hasInternalWorkRole(params = {}) {
|
|
775
|
+
const sum = await this._roleSummary(params);
|
|
776
|
+
return sum.hasInternal;
|
|
777
|
+
},
|
|
778
|
+
|
|
779
|
+
_isSysSession(params) {
|
|
780
|
+
return DEV_MODE || !params?.session || params.session.$user === globalThis.WORK;
|
|
781
|
+
},
|
|
782
|
+
|
|
783
|
+
async _canAccessUsersContainer(params = {}) {
|
|
784
|
+
if (this._isSysSession(params))
|
|
785
|
+
return true;
|
|
786
|
+
if (params?.session?.principal?.kind === 'node')
|
|
787
|
+
return false;
|
|
788
|
+
const uid = this.constructor.resolveUid(params);
|
|
789
|
+
if (!uid)
|
|
746
790
|
return false;
|
|
791
|
+
const sum = await this._roleSummary(params);
|
|
792
|
+
// Внутренние сотрудники и неназначенные пользователи видят /USERS; внешние (external-only) — нет
|
|
793
|
+
return sum.hasInternal || !sum.hasExternal;
|
|
794
|
+
},
|
|
795
|
+
|
|
796
|
+
/** Сводка ролевого контекста текущего пользователя (для UI профиля и Консультанта). */
|
|
797
|
+
async my_scope(params = {}) {
|
|
798
|
+
const uid = this.constructor.resolveUid(params);
|
|
799
|
+
const sum = await this._roleSummary(params);
|
|
800
|
+
return {
|
|
801
|
+
uid: uid || '',
|
|
802
|
+
...sum,
|
|
803
|
+
isUnassigned: Boolean(uid && !sum.hasAnyRole && !sum.isWorkBoss),
|
|
747
804
|
};
|
|
748
|
-
|
|
749
|
-
|
|
805
|
+
},
|
|
806
|
+
|
|
807
|
+
_hasRootBossOnlyAncestor(node) {
|
|
808
|
+
for (let cur = node; cur && cur instanceof FS.$folder; cur = cur.$parent) {
|
|
809
|
+
if (cur.DATA?.rootBossOnly === true && (!cur.$parent || !cur.$parent.$parent))
|
|
810
|
+
return true;
|
|
811
|
+
}
|
|
750
812
|
return false;
|
|
751
813
|
},
|
|
752
814
|
|
|
@@ -769,15 +831,19 @@ export const classSecurityMethods = {
|
|
|
769
831
|
},
|
|
770
832
|
|
|
771
833
|
async allowAccess(params) {
|
|
772
|
-
const isSysSession =
|
|
834
|
+
const isSysSession = this._isSysSession(params);
|
|
773
835
|
await this.init;
|
|
774
|
-
// Раздел /USERS (usersContainer): виден внутренним
|
|
836
|
+
// Раздел /USERS (usersContainer): виден внутренним и неназначенным пользователям; скрыт от external-only и гостей
|
|
775
837
|
if (this.DATA?.usersContainer === true) {
|
|
838
|
+
return this._canAccessUsersContainer(params);
|
|
839
|
+
}
|
|
840
|
+
// Корневой контейнер с rootBossOnly (например /MODULES): виден в дереве и API только BOSS корня WORK
|
|
841
|
+
if (this._hasRootBossOnlyAncestor(this)) {
|
|
776
842
|
if (isSysSession)
|
|
777
843
|
return true;
|
|
778
844
|
if (params?.session?.principal?.kind === 'node')
|
|
779
845
|
return false;
|
|
780
|
-
return this.
|
|
846
|
+
return Boolean(await this._isWorkBoss(params));
|
|
781
847
|
}
|
|
782
848
|
// Домен-контейнер (например /PROJECTS, /MODULES): виден только BOSS или при наличии хотя бы одного доступного потомка
|
|
783
849
|
if (this.DATA?.container === true && !this.hasAssignments()) {
|
package/sources/server/class.js
CHANGED
|
@@ -219,6 +219,15 @@ export class $class extends $folder {
|
|
|
219
219
|
get mainTreeChildren() {
|
|
220
220
|
return this.DATA?.mainTreeChildren;
|
|
221
221
|
},
|
|
222
|
+
get isStructure() {
|
|
223
|
+
return this.DATA?.isStructure;
|
|
224
|
+
},
|
|
225
|
+
get isProject() {
|
|
226
|
+
return this.DATA?.isProject;
|
|
227
|
+
},
|
|
228
|
+
get isDepartment() {
|
|
229
|
+
return this.DATA?.isDepartment;
|
|
230
|
+
},
|
|
222
231
|
get objectCount() {
|
|
223
232
|
return this.DATA?.objectCount;
|
|
224
233
|
},
|
|
@@ -153,6 +153,12 @@ export class $handler extends $class {
|
|
|
153
153
|
data.group = this.DATA.group;
|
|
154
154
|
if (this.DATA?.tag)
|
|
155
155
|
data.tag = this.DATA.tag;
|
|
156
|
+
if (typeof this.DATA?.title === 'string' && this.DATA.title)
|
|
157
|
+
data.title = this.DATA.title;
|
|
158
|
+
if (typeof this.DATA?.description === 'string' && this.DATA.description)
|
|
159
|
+
data.description = this.DATA.description;
|
|
160
|
+
if (this.DATA?.hideHeader != null)
|
|
161
|
+
data.hideHeader = Boolean(this.DATA.hideHeader);
|
|
156
162
|
if (this.DATA?.isModuleSelf != null)
|
|
157
163
|
data.isModuleSelf = Boolean(this.DATA.isModuleSelf);
|
|
158
164
|
return data;
|
package/sources/server/user.js
CHANGED
|
@@ -150,13 +150,21 @@ export class $user extends $class {
|
|
|
150
150
|
await this.init;
|
|
151
151
|
if (this.DATA?.usersContainer === true)
|
|
152
152
|
return super.allowAccess(params);
|
|
153
|
-
|
|
154
|
-
if (DEV_MODE)
|
|
153
|
+
if (DEV_MODE || !params?.session || params.session.$user === globalThis.WORK)
|
|
155
154
|
return true;
|
|
156
|
-
// профили пользователей
|
|
155
|
+
// профили пользователей закрыты для узлов сети и анонимных запросов
|
|
157
156
|
if (params?.session?.principal?.kind === 'node')
|
|
158
157
|
return false;
|
|
159
|
-
|
|
158
|
+
const uid = this.constructor.resolveUid(params);
|
|
159
|
+
if (!uid)
|
|
160
|
+
return false;
|
|
161
|
+
if (this.id === uid)
|
|
162
|
+
return true;
|
|
163
|
+
if (globalThis.WORK && await this._isWorkBoss(params))
|
|
164
|
+
return true;
|
|
165
|
+
const { visibleContacts } = await import('./chat-threads.js');
|
|
166
|
+
const contacts = await visibleContacts(this, params);
|
|
167
|
+
return contacts.some(c => c.id === this.id);
|
|
160
168
|
}
|
|
161
169
|
}
|
|
162
170
|
$user.type_chain = Object.create(null);
|