odant-work 1.0.107 → 1.0.108
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/$structure/handlers/pages/form/chat/$handler/class.js +2 -2
- package/$server/$folder/handlers/pages/form/$handler/class.js +17 -1
- package/$server/$folder/lib/icon/icon.js +2 -1
- package/$server/$folder/lib/prompt-bar/prompt-bar.js +1 -1
- package/$server/$folder/lib/tree/tree.js +10 -5
- package/package.json +1 -1
- package/sources/client.js +27 -1
- package/sources/host/websocket.js +3 -3
- package/sources/server/chat-threads.js +15 -0
- package/sources/server/class/security.js +5 -0
- package/sources/server/user.js +2 -0
|
@@ -313,7 +313,7 @@ ODA({
|
|
|
313
313
|
$item: {
|
|
314
314
|
$def: null,
|
|
315
315
|
set($item) {
|
|
316
|
-
|
|
316
|
+
this.receivers = [];
|
|
317
317
|
if ($item) {
|
|
318
318
|
this._hydrateModel();
|
|
319
319
|
this._loadDepartmentContext($item);
|
|
@@ -515,7 +515,7 @@ ODA({
|
|
|
515
515
|
<microchat-voice ~if="voiceOn"></microchat-voice>
|
|
516
516
|
<work-prompt-bar style="margin: 8px;" @tap="focusedItem = null"
|
|
517
517
|
::value ::files :ai="isAIMode" :placeholder :pending="awaitTask"
|
|
518
|
-
::model ::tts-mode
|
|
518
|
+
::model ::tts-mode :receivers="isForeignPrivate ? [] : receivers" :dept-users="isForeignPrivate ? [] : deptUsers" :operation-classes="isForeignPrivate ? [] : operationClasses" :show-tts="!isForeignPrivate"
|
|
519
519
|
@receivers-changed="onReceiversChanged($event)" @create-operation="onCreateOperation($event)"
|
|
520
520
|
@send="onBarSend" @stop="onBarStop" @clear="clear" @prompt-key="_onPromptKey"></work-prompt-bar>
|
|
521
521
|
</div>
|
|
@@ -1584,13 +1584,22 @@ ODA({is: 'work-form',
|
|
|
1584
1584
|
return this.loadFormViews($item, role);
|
|
1585
1585
|
},
|
|
1586
1586
|
_myScope: null,
|
|
1587
|
+
_isForeignUserItem(item = this.currentItem) {
|
|
1588
|
+
if (!item || item.DATA?.usersContainer)
|
|
1589
|
+
return false;
|
|
1590
|
+
const isUsr = Boolean(item.DATA?.isUser || item.isUser);
|
|
1591
|
+
return Boolean(isUsr && item.id && globalThis.WORK?.uid && item.id !== globalThis.WORK.uid);
|
|
1592
|
+
},
|
|
1587
1593
|
get visibleFormViews() {
|
|
1588
1594
|
const views = this.formViews;
|
|
1589
1595
|
if (!Array.isArray(views))
|
|
1590
1596
|
return [];
|
|
1597
|
+
if (this._isForeignUserItem(this.currentItem)) {
|
|
1598
|
+
return views.filter(v => v?.id === 'chat');
|
|
1599
|
+
}
|
|
1591
1600
|
const hideSystemForUnassigned = Boolean(
|
|
1592
1601
|
this._myScope?.isUnassigned
|
|
1593
|
-
&& this.currentItem?.DATA?.isUser
|
|
1602
|
+
&& (this.currentItem?.DATA?.isUser || this.currentItem?.isUser)
|
|
1594
1603
|
&& !this.currentItem?.DATA?.usersContainer
|
|
1595
1604
|
);
|
|
1596
1605
|
return views.filter(v => {
|
|
@@ -1632,6 +1641,11 @@ ODA({is: 'work-form',
|
|
|
1632
1641
|
let views = $item === this.currentItem ? await this.formViews : await this.loadFormViews($item, role);
|
|
1633
1642
|
if ((!Array.isArray(views) || !views.length) && $item)
|
|
1634
1643
|
views = await this.loadFormViews($item, role);
|
|
1644
|
+
if (this._isForeignUserItem($item) && !globalThis.WORK?.DEV_MODE) {
|
|
1645
|
+
const chatView = (views || []).find(v => v?.id === 'chat');
|
|
1646
|
+
if (chatView)
|
|
1647
|
+
return chatView;
|
|
1648
|
+
}
|
|
1635
1649
|
if (name) {
|
|
1636
1650
|
const parts = String(name).split('/').filter(Boolean);
|
|
1637
1651
|
const first = parts[0];
|
|
@@ -1779,6 +1793,8 @@ ODA({is: 'work-form',
|
|
|
1779
1793
|
if (!n || n.DATA?.usersContainer || n.DATA?.container || n.DATA?.objects)
|
|
1780
1794
|
return [];
|
|
1781
1795
|
if (n.DATA?.isUser || n.isUser) {
|
|
1796
|
+
if (n.DATA?.enabled === false || n.DATA?.blocked === true)
|
|
1797
|
+
return [];
|
|
1782
1798
|
return (WORK?.uid && n.id && n.id !== WORK.uid) ? [n] : [];
|
|
1783
1799
|
}
|
|
1784
1800
|
if (!n.DATA?.isStructure)
|
|
@@ -47,9 +47,10 @@ export default {
|
|
|
47
47
|
$attr: true,
|
|
48
48
|
get() {
|
|
49
49
|
if (this.isUser) {
|
|
50
|
+
this.$item?.__version;
|
|
50
51
|
if (this.$item?.DATA?.enabled === false || this.$item?.DATA?.blocked === true)
|
|
51
52
|
return false;
|
|
52
|
-
return this.$item?.online;
|
|
53
|
+
return Boolean(this.$item?.DATA?.online ?? this.$item?.online);
|
|
53
54
|
}
|
|
54
55
|
return false;
|
|
55
56
|
}
|
|
@@ -432,7 +432,7 @@ ODA({ is: 'work-prompt-bar',
|
|
|
432
432
|
<textarea id="text" rows="1" :placeholder="recording ? 'Говорите…' : placeholder" :value="value" :readonly="recording"
|
|
433
433
|
@input="onInput" @keydown="_onKeydown" @click="_onCaretMove" @keyup="_onCaretMove" @blur="_onBlur" @paste="_onPaste"></textarea>
|
|
434
434
|
<div class="row">
|
|
435
|
-
<oda-button class="icon-btn" icon="carbon:add" :icon-size="20" title="Действия: прикрепить файлы, выбрать получателей, создать операцию" @tap="onPlusTap($event)"></oda-button>
|
|
435
|
+
<oda-button class="icon-btn" icon="carbon:add" :icon-size="20" :title="(deptUsers?.length || operationClasses?.length) ? 'Действия: прикрепить файлы, выбрать получателей, создать операцию' : 'Прикрепить файлы'" @tap="onPlusTap($event)"></oda-button>
|
|
436
436
|
<oda-button class="icon-btn" ~if="deptUsers?.length" icon="icons:supervisor-account" :icon-size="18" title="Получатели подразделения (если не выбраны — создаётся задача ИИ)" @tap="chooseReceivers($event)"></oda-button>
|
|
437
437
|
<button class="pill" ~if="modes?.length" :plan="mode === 'plan'" :ask="mode === 'ask'" :title="modeMeta?.hint" @tap="chooseMode">
|
|
438
438
|
<oda-icon :icon="modeMeta?.icon" :icon-size="14"></oda-icon><span>{{modeMeta?.label}}</span><oda-icon icon="carbon:chevron-down" :icon-size="12"></oda-icon>
|
|
@@ -704,9 +704,9 @@ ODA({is: 'oda-tree-node',
|
|
|
704
704
|
@apply --no-flex;
|
|
705
705
|
align-items: center;
|
|
706
706
|
overflow: hidden;
|
|
707
|
-
height:
|
|
708
|
-
min-height:
|
|
709
|
-
padding: 0
|
|
707
|
+
height: 32px;
|
|
708
|
+
min-height: 32px;
|
|
709
|
+
padding: 0 4px;
|
|
710
710
|
box-sizing: border-box;
|
|
711
711
|
background: var(--content-background);
|
|
712
712
|
color: var(--content-color);
|
|
@@ -1168,13 +1168,18 @@ ODA({is: 'oda-tree-node',
|
|
|
1168
1168
|
if (this.isModule && nextEnabled && it.DATA?.systemBlocked)
|
|
1169
1169
|
return;
|
|
1170
1170
|
try {
|
|
1171
|
-
const res = await it.fetch('set_enabled', { enabled: nextEnabled });
|
|
1172
|
-
if (
|
|
1171
|
+
const res = await it.fetch('set_enabled', { enabled: nextEnabled }, {});
|
|
1172
|
+
if (res && typeof res === 'object') {
|
|
1173
|
+
it.DATA ??= {};
|
|
1173
1174
|
it.DATA.enabled = res.enabled;
|
|
1174
1175
|
if ('localEnabled' in res) it.DATA.localEnabled = res.localEnabled;
|
|
1175
1176
|
if ('systemBlocked' in res) it.DATA.systemBlocked = res.systemBlocked;
|
|
1176
1177
|
if ('moduleStatus' in res) it.DATA.moduleStatus = res.moduleStatus;
|
|
1177
1178
|
if ('moduleStatusReason' in res) it.DATA.moduleStatusReason = res.moduleStatusReason;
|
|
1179
|
+
if (this.$item?.type === '$user' && !res.enabled)
|
|
1180
|
+
it.DATA.online = false;
|
|
1181
|
+
Reactor?.invalidate?.(it, 'DATA');
|
|
1182
|
+
Reactor?.invalidate?.(it, 'online');
|
|
1178
1183
|
}
|
|
1179
1184
|
if (!res?.enabled)
|
|
1180
1185
|
this.expanded = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.108",
|
|
4
4
|
"description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "sources/work.js",
|
package/sources/client.js
CHANGED
|
@@ -104,7 +104,7 @@ WORK.fetch = function (url, method = '', params = {}, postObject) {
|
|
|
104
104
|
url = encodeURI(url + (method ? '?' + method : ''));
|
|
105
105
|
url += Object.keys(params).reduce((res, p) => {
|
|
106
106
|
let val = params[p];
|
|
107
|
-
if(val)
|
|
107
|
+
if (val !== undefined && val !== null && val !== '')
|
|
108
108
|
res += ((res || method) ? '&' : '?') + encodeURIComponent(p) + '=' + encodeURIComponent(val);
|
|
109
109
|
return res;
|
|
110
110
|
}, '');
|
|
@@ -502,6 +502,15 @@ WORK.login = async function(force = false){
|
|
|
502
502
|
WORK._anonExitSynced = false;
|
|
503
503
|
if (authChanged || !WORK.USER)
|
|
504
504
|
await WORK.syncAuthUI();
|
|
505
|
+
const ownTreeUser = (WORK.USER?.short && CORE.$item.ITEMS[WORK.USER.short])
|
|
506
|
+
|| Object.values(CORE.$item.ITEMS).find(i => i?.id === uid && i?.DATA?.isUser);
|
|
507
|
+
if (ownTreeUser && WORK.USER?.DATA) {
|
|
508
|
+
Object.assign(ownTreeUser.DATA ??= {}, { online: Boolean(WORK.USER.DATA.online ?? true) });
|
|
509
|
+
Reactor.invalidate(ownTreeUser, 'DATA');
|
|
510
|
+
Reactor.invalidate(ownTreeUser, 'online');
|
|
511
|
+
ownTreeUser.increaseVersion?.();
|
|
512
|
+
ownTreeUser.fire?.('changed', { path: ownTreeUser.short, initiator: uid, online: true });
|
|
513
|
+
}
|
|
505
514
|
await WORK.loadUserSettings?.();
|
|
506
515
|
WORK.refreshChatUnread?.();
|
|
507
516
|
if (authChanged) {
|
|
@@ -939,6 +948,23 @@ class WebSocketEvents {
|
|
|
939
948
|
// версия — до fire: слушатели changed делают load(), а его URL (и дедуп WORK.fetch) включает версию;
|
|
940
949
|
// старый порядок склеивал reload с висящим прежним запросом и отдавал устаревший JSON
|
|
941
950
|
item.increaseVersion();
|
|
951
|
+
if (item.DATA?.isUser && !item.DATA?.usersContainer) {
|
|
952
|
+
if (typeof data.online === 'boolean') {
|
|
953
|
+
(item.DATA ??= {}).online = data.online;
|
|
954
|
+
Reactor.invalidate(item, 'DATA');
|
|
955
|
+
Reactor.invalidate(item, 'online');
|
|
956
|
+
item.increaseVersion();
|
|
957
|
+
}
|
|
958
|
+
else if (!WORK._roleRefresh.has(item)) {
|
|
959
|
+
WORK._roleRefresh.add(item);
|
|
960
|
+
item.fetch('info').then(() => {
|
|
961
|
+
Reactor.invalidate(item, 'DATA');
|
|
962
|
+
Reactor.invalidate(item, 'online');
|
|
963
|
+
item.increaseVersion();
|
|
964
|
+
item.fire('changed', data);
|
|
965
|
+
}).catch(() => { }).finally(() => WORK._roleRefresh.delete(item));
|
|
966
|
+
}
|
|
967
|
+
}
|
|
942
968
|
// роли пользователей и флаги безопасности (roleIds, hasSecurity, icon, label) приходят в info:
|
|
943
969
|
// подтянуть свежие данные и уведомить дерево
|
|
944
970
|
if (item.DATA?.roleIds && !(item instanceof CORE.$user) && !WORK._roleRefresh.has(item)) {
|
|
@@ -39,10 +39,10 @@ const allSessions = () => Object.values($server?.sessions || {});
|
|
|
39
39
|
/** Уведомить сессии о смене presence пользователя (online).
|
|
40
40
|
* F24: анонимным сессиям (без вошедшего) местоположение людей не рассылаем.
|
|
41
41
|
* Экспортировано для теста фильтра. */
|
|
42
|
-
export function broadcastUserPath(
|
|
43
|
-
if (
|
|
42
|
+
export function broadcastUserPath(user) {
|
|
43
|
+
if (!user?.short)
|
|
44
44
|
return;
|
|
45
|
-
const message = JSON.stringify({ path:
|
|
45
|
+
const message = JSON.stringify({ path: user.short, initiator: user.id, online: Boolean(user.online) });
|
|
46
46
|
for (const session of allSessions()) {
|
|
47
47
|
if (!session?.$user)
|
|
48
48
|
continue; // анонимная сессия — без присутствия
|
|
@@ -364,6 +364,15 @@ export async function sendMessage(storage, params = {}) {
|
|
|
364
364
|
const isParticipant = thread.participants.some(p => p.uid === uid);
|
|
365
365
|
if (!isParticipant && !isTwinBot)
|
|
366
366
|
throw new Error(ACCESS_DENIED);
|
|
367
|
+
if (thread.kind === 'dm' && !isTwinBot && !isSysSession(params)) {
|
|
368
|
+
const peerIds = thread.participants.map(p => p.uid).filter(id => id && id !== uid);
|
|
369
|
+
const usersRoot = peerIds.length ? await Promise.resolve(globalThis.WORK?.$users).catch(() => null) : null;
|
|
370
|
+
for (const peerId of peerIds) {
|
|
371
|
+
const peerNode = usersRoot ? await Promise.resolve(usersRoot.get_item?.('//' + peerId)).catch(() => null) : null;
|
|
372
|
+
if (peerNode && typeof peerNode._ownUserEnabledSync === 'function' && !peerNode._ownUserEnabledSync())
|
|
373
|
+
throw new Error('Пользователь отключён администратором');
|
|
374
|
+
}
|
|
375
|
+
}
|
|
367
376
|
if (thread.kind !== 'dm' && !isTwinBot && !isSysSession(params)) {
|
|
368
377
|
const canSee = await storage.canSee?.(storage, params).catch(() => false);
|
|
369
378
|
const roles = await storage.roles?.(params).catch(() => []) || [];
|
|
@@ -566,12 +575,16 @@ export async function visibleContacts(storage, params = {}) {
|
|
|
566
575
|
const userMap = new Map();
|
|
567
576
|
for (const u of allUserItems) {
|
|
568
577
|
await u.init?.catch?.(() => {});
|
|
578
|
+
const enabled = typeof u._ownUserEnabledSync === 'function'
|
|
579
|
+
? u._ownUserEnabledSync()
|
|
580
|
+
: (u.DATA?.enabled !== false && u.DATA?.blocked !== true);
|
|
569
581
|
userMap.set(u.id, {
|
|
570
582
|
id: u.id,
|
|
571
583
|
path: u.path || `/USERS/${u.id}`,
|
|
572
584
|
label: u.DATA?.label || u.label || u.id,
|
|
573
585
|
icon: u.DATA?.icon || u.icon || '',
|
|
574
586
|
online: Boolean(u.online),
|
|
587
|
+
enabled,
|
|
575
588
|
self: u.id === uid,
|
|
576
589
|
external: false,
|
|
577
590
|
});
|
|
@@ -675,6 +688,8 @@ export async function visibleContacts(storage, params = {}) {
|
|
|
675
688
|
if (id === uid) continue;
|
|
676
689
|
const entry = userMap.get(id);
|
|
677
690
|
if (!entry) continue;
|
|
691
|
+
if (!isWorkBoss && entry.enabled === false)
|
|
692
|
+
continue;
|
|
678
693
|
out.push({
|
|
679
694
|
...entry,
|
|
680
695
|
external: externalOnlyIds.has(id),
|
|
@@ -1011,6 +1011,11 @@ export const classSecurityMethods = {
|
|
|
1011
1011
|
return all.filter(u => {
|
|
1012
1012
|
if (!u?.id || seen.has(u.id))
|
|
1013
1013
|
return false;
|
|
1014
|
+
const enabled = typeof u._ownUserEnabledSync === 'function'
|
|
1015
|
+
? u._ownUserEnabledSync()
|
|
1016
|
+
: (u.DATA?.enabled !== false && u.DATA?.blocked !== true);
|
|
1017
|
+
if (!enabled)
|
|
1018
|
+
return false;
|
|
1014
1019
|
seen.add(u.id);
|
|
1015
1020
|
return true;
|
|
1016
1021
|
});
|
package/sources/server/user.js
CHANGED
|
@@ -169,6 +169,8 @@ export class $user extends $class {
|
|
|
169
169
|
return true;
|
|
170
170
|
if (globalThis.WORK && await this._isWorkBoss(params))
|
|
171
171
|
return true;
|
|
172
|
+
if (!this._ownUserEnabledSync())
|
|
173
|
+
return false;
|
|
172
174
|
const { visibleContacts } = await import('./chat-threads.js');
|
|
173
175
|
const contacts = await visibleContacts(this, params);
|
|
174
176
|
return contacts.some(c => c.id === this.id);
|