odant-work 1.0.106 → 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 +10 -5
- package/$server/$folder/handlers/pages/form/$handler/class.js +256 -101
- package/$server/$folder/lib/explorer/explorer.js +10 -1
- package/$server/$folder/lib/icon/icon.js +6 -2
- package/$server/$folder/lib/prompt-bar/prompt-bar.js +1 -1
- package/$server/$folder/lib/tree/tree.js +15 -10
- package/package.json +1 -1
- package/sources/client.js +56 -2
- package/sources/host/auth-methods.js +25 -14
- package/sources/host/http-server.js +1 -0
- package/sources/host/websocket.js +14 -11
- package/sources/modules/call/call.js +5 -1
- package/sources/modules/user-profile/user-profile.js +9 -1
- package/sources/server/access/gateway.js +2 -6
- package/sources/server/chat-threads.js +15 -0
- package/sources/server/class/feed.js +1 -1
- package/sources/server/class/security.js +5 -0
- package/sources/server/logs.js +17 -10
- package/sources/server/server.js +17 -6
- package/sources/server/user.js +10 -1
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/profile/$handler/class.js +0 -30
|
@@ -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>
|
|
@@ -2082,9 +2082,14 @@ ODA({
|
|
|
2082
2082
|
if (!Array.isArray(rows)) rows = [];
|
|
2083
2083
|
const isDialogMetaRow = r => {
|
|
2084
2084
|
const p = String(r?.path || '').trim().replace(/\\/g, '/');
|
|
2085
|
-
if (
|
|
2086
|
-
|
|
2087
|
-
|
|
2085
|
+
if (p) {
|
|
2086
|
+
if (/(?:^|\/)(?:class\.js|readme\.md)$/i.test(p)) return true;
|
|
2087
|
+
if (/\/history\/\d{4}-\d{2}-\d{2}\/\d+\.[^/]+\.js$/i.test(p)) return true;
|
|
2088
|
+
if (/\/#(?:secret|system)\//i.test(p) && !/\.task$/i.test(p)) return true;
|
|
2089
|
+
}
|
|
2090
|
+
if (!String(r?.content || '').trim() && Array.isArray(r?.includes) && r.includes.length) {
|
|
2091
|
+
if (r.includes.every(inc => /(?:^|\/)(?:class\.js|readme\.md)$/i.test(String(inc || '').trim().replace(/\\/g, '/')))) return true;
|
|
2092
|
+
}
|
|
2088
2093
|
return false;
|
|
2089
2094
|
};
|
|
2090
2095
|
const hasVisibleRowPayload = r => {
|
|
@@ -939,7 +939,7 @@ ODA({is: 'work-form',
|
|
|
939
939
|
<div ~if="!isTaskForm" flex></div>
|
|
940
940
|
<oda-button ~if="showConsultantBtn" id="consultantBtn" shadow icon="bootstrap:robot" @tap="askConsultant" title="Спросить ИИ-консультанта по текущей форме" :icon-size info class="consultant-btn"
|
|
941
941
|
:style="'border-radius: 50%; flex-shrink: 0; margin-right: ' + (ODA.states?.mobileMode ? '0px' : '4px') + ';'"></oda-button>
|
|
942
|
-
<oda-button ~if="
|
|
942
|
+
<oda-button ~if="showCallBtn" shadow icon="communication:call" @tap="call" title="Позвонить" :icon-size success class="call-btn"
|
|
943
943
|
:style="'border-radius: 50%; flex-shrink: 0; margin-right: ' + (ODA.states?.mobileMode ? '0px' : '24px') + ';'"></oda-button>
|
|
944
944
|
<slot name="top-panel"></slot>
|
|
945
945
|
<div ~if="!isTaskForm || visibleFormViews.length > 1 || allowSave" class="view-selector" no-flex horizontal
|
|
@@ -1037,16 +1037,25 @@ ODA({is: 'work-form',
|
|
|
1037
1037
|
</div>
|
|
1038
1038
|
`,
|
|
1039
1039
|
async call(e) {
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1040
|
+
const cur = this.currentItem || await this.$item;
|
|
1041
|
+
if (cur?.DATA?.isUser && WORK?.uid && cur.id && cur.id !== WORK.uid) {
|
|
1042
|
+
WORK.top.RTCCaller.startCall(cur, [cur.id]);
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
const candidates = Array.isArray(this._callCandidates) && this._callCandidates.length
|
|
1046
|
+
? this._callCandidates
|
|
1047
|
+
: await this._resolveCallCandidates(cur);
|
|
1048
|
+
if (!candidates.length)
|
|
1049
|
+
return;
|
|
1050
|
+
const el = ODA.createComponent('call-users-list', { users: candidates });
|
|
1051
|
+
if (candidates.length === 1) {
|
|
1052
|
+
el.selectedUsers = [candidates[0]];
|
|
1044
1053
|
}
|
|
1045
1054
|
const updateEnable = () => {
|
|
1046
|
-
const
|
|
1047
|
-
if (el.domParent) {
|
|
1048
|
-
if (
|
|
1049
|
-
el.domParent.OK.label =
|
|
1055
|
+
const count = el.selectedUsers.length;
|
|
1056
|
+
if (el.domParent?.OK) {
|
|
1057
|
+
if (count > 0) {
|
|
1058
|
+
el.domParent.OK.label = `Позвонить (${count})`;
|
|
1050
1059
|
el.domParent.OK.icon = 'communication:call';
|
|
1051
1060
|
}
|
|
1052
1061
|
else {
|
|
@@ -1057,26 +1066,29 @@ ODA({is: 'work-form',
|
|
|
1057
1066
|
};
|
|
1058
1067
|
el.addEventListener('changed', updateEnable);
|
|
1059
1068
|
try {
|
|
1060
|
-
this.async(() => { updateEnable() },
|
|
1069
|
+
this.async(() => { updateEnable(); }, 50);
|
|
1061
1070
|
const res = await WORK.showDialog(el, {
|
|
1062
|
-
|
|
1063
|
-
|
|
1071
|
+
allowClose: true,
|
|
1072
|
+
TITLE: { label: 'Позвонить', icon: 'communication:call' },
|
|
1073
|
+
OK: { label: 'Позвонить', icon: 'communication:call' },
|
|
1074
|
+
CANCEL: { label: 'Отмена', icon: 'icons:close' },
|
|
1064
1075
|
});
|
|
1065
1076
|
if (res === 'ok') {
|
|
1066
1077
|
const receivers = el.selectedUsers;
|
|
1067
1078
|
if (receivers.length > 0) {
|
|
1068
|
-
WORK.top.RTCCaller.startCall(
|
|
1079
|
+
WORK.top.RTCCaller.startCall(cur, receivers.map(u => u.id));
|
|
1069
1080
|
}
|
|
1070
1081
|
else {
|
|
1071
|
-
WORK.top.RTCCaller.startRecord(
|
|
1082
|
+
WORK.top.RTCCaller.startRecord(cur);
|
|
1072
1083
|
}
|
|
1073
1084
|
}
|
|
1074
1085
|
}
|
|
1075
1086
|
catch (err) {
|
|
1076
|
-
|
|
1087
|
+
if (!(err instanceof WORK.CancelError))
|
|
1088
|
+
console.log(err);
|
|
1077
1089
|
}
|
|
1078
1090
|
finally {
|
|
1079
|
-
el.removeEventListener('
|
|
1091
|
+
el.removeEventListener('changed', updateEnable);
|
|
1080
1092
|
}
|
|
1081
1093
|
},
|
|
1082
1094
|
allowZoom: true,
|
|
@@ -1572,13 +1584,22 @@ ODA({is: 'work-form',
|
|
|
1572
1584
|
return this.loadFormViews($item, role);
|
|
1573
1585
|
},
|
|
1574
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
|
+
},
|
|
1575
1593
|
get visibleFormViews() {
|
|
1576
1594
|
const views = this.formViews;
|
|
1577
1595
|
if (!Array.isArray(views))
|
|
1578
1596
|
return [];
|
|
1597
|
+
if (this._isForeignUserItem(this.currentItem)) {
|
|
1598
|
+
return views.filter(v => v?.id === 'chat');
|
|
1599
|
+
}
|
|
1579
1600
|
const hideSystemForUnassigned = Boolean(
|
|
1580
1601
|
this._myScope?.isUnassigned
|
|
1581
|
-
&& this.currentItem?.DATA?.isUser
|
|
1602
|
+
&& (this.currentItem?.DATA?.isUser || this.currentItem?.isUser)
|
|
1582
1603
|
&& !this.currentItem?.DATA?.usersContainer
|
|
1583
1604
|
);
|
|
1584
1605
|
return views.filter(v => {
|
|
@@ -1620,6 +1641,11 @@ ODA({is: 'work-form',
|
|
|
1620
1641
|
let views = $item === this.currentItem ? await this.formViews : await this.loadFormViews($item, role);
|
|
1621
1642
|
if ((!Array.isArray(views) || !views.length) && $item)
|
|
1622
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
|
+
}
|
|
1623
1649
|
if (name) {
|
|
1624
1650
|
const parts = String(name).split('/').filter(Boolean);
|
|
1625
1651
|
const first = parts[0];
|
|
@@ -1704,12 +1730,13 @@ ODA({is: 'work-form',
|
|
|
1704
1730
|
this._appliedRoleItem = n;
|
|
1705
1731
|
this._appliedRole = n.role || '';
|
|
1706
1732
|
this._rootHasChildClasses = await this._detectHasChildClasses(n);
|
|
1707
|
-
if (globalThis.WORK?.uid && !globalThis.WORK?.DEV_MODE && n?.DATA?.isUser && !n?.DATA?.usersContainer) {
|
|
1733
|
+
if (globalThis.WORK?.uid && !globalThis.WORK?.DEV_MODE && (n?.DATA?.isUser || n?.isUser) && !n?.DATA?.usersContainer) {
|
|
1708
1734
|
this._myScope = await globalThis.WORK.fetch('/', 'my_scope').catch(() => null);
|
|
1709
1735
|
}
|
|
1710
1736
|
else {
|
|
1711
1737
|
this._myScope = null;
|
|
1712
1738
|
}
|
|
1739
|
+
this._callCandidates = await this._resolveCallCandidates(n);
|
|
1713
1740
|
}
|
|
1714
1741
|
finally {
|
|
1715
1742
|
this._initializingItem = false;
|
|
@@ -1758,6 +1785,37 @@ ODA({is: 'work-form',
|
|
|
1758
1785
|
get isEmbeddedNoTree() {
|
|
1759
1786
|
return typeof location !== 'undefined' && new URLSearchParams(location.search).get('noTree') === '1';
|
|
1760
1787
|
},
|
|
1788
|
+
_callCandidates: [],
|
|
1789
|
+
get showCallBtn() {
|
|
1790
|
+
return Boolean(!this.isTaskForm && Array.isArray(this._callCandidates) && this._callCandidates.length > 0);
|
|
1791
|
+
},
|
|
1792
|
+
async _resolveCallCandidates(n) {
|
|
1793
|
+
if (!n || n.DATA?.usersContainer || n.DATA?.container || n.DATA?.objects)
|
|
1794
|
+
return [];
|
|
1795
|
+
if (n.DATA?.isUser || n.isUser) {
|
|
1796
|
+
if (n.DATA?.enabled === false || n.DATA?.blocked === true)
|
|
1797
|
+
return [];
|
|
1798
|
+
return (WORK?.uid && n.id && n.id !== WORK.uid) ? [n] : [];
|
|
1799
|
+
}
|
|
1800
|
+
if (!n.DATA?.isStructure)
|
|
1801
|
+
return [];
|
|
1802
|
+
try {
|
|
1803
|
+
const raw = typeof n.fetch === 'function' ? await n.fetch('assignedUsers').catch(() => []) : [];
|
|
1804
|
+
const seen = new Set();
|
|
1805
|
+
const out = [];
|
|
1806
|
+
for (const u of (Array.isArray(raw) ? raw : [])) {
|
|
1807
|
+
const id = u?.id;
|
|
1808
|
+
if (!id || id === WORK?.uid || seen.has(id))
|
|
1809
|
+
continue;
|
|
1810
|
+
seen.add(id);
|
|
1811
|
+
out.push(u);
|
|
1812
|
+
}
|
|
1813
|
+
return out;
|
|
1814
|
+
}
|
|
1815
|
+
catch {
|
|
1816
|
+
return [];
|
|
1817
|
+
}
|
|
1818
|
+
},
|
|
1761
1819
|
get showConsultantBtn() {
|
|
1762
1820
|
if (!this.currentItem || this.isTaskForm)
|
|
1763
1821
|
return false;
|
|
@@ -2786,107 +2844,204 @@ ODA({
|
|
|
2786
2844
|
is: 'call-users-list',
|
|
2787
2845
|
template: /*html*/`
|
|
2788
2846
|
<style>
|
|
2789
|
-
:host{
|
|
2847
|
+
:host {
|
|
2790
2848
|
@apply --vertical;
|
|
2849
|
+
width: min(420px, 92vw);
|
|
2850
|
+
max-height: min(460px, 70vh);
|
|
2791
2851
|
overflow: hidden;
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2852
|
+
background: var(--content-background, #ffffff);
|
|
2853
|
+
color: var(--content-color, #0f172a);
|
|
2854
|
+
box-sizing: border-box;
|
|
2855
|
+
}
|
|
2856
|
+
.search-wrap {
|
|
2857
|
+
display: flex;
|
|
2858
|
+
align-items: center;
|
|
2859
|
+
gap: 8px;
|
|
2860
|
+
margin: 10px 12px 6px;
|
|
2861
|
+
padding: 6px 10px;
|
|
2862
|
+
border-radius: 10px;
|
|
2863
|
+
border: 1px solid var(--border-color, #cbd5e1);
|
|
2864
|
+
background: var(--subtle-background, #f8fafc);
|
|
2865
|
+
flex-shrink: 0;
|
|
2866
|
+
}
|
|
2867
|
+
.search-wrap input {
|
|
2868
|
+
flex: 1 1 auto;
|
|
2869
|
+
min-width: 0;
|
|
2870
|
+
border: none;
|
|
2871
|
+
outline: none;
|
|
2872
|
+
background: transparent;
|
|
2873
|
+
color: inherit;
|
|
2874
|
+
font: inherit;
|
|
2875
|
+
font-size: 13.5px;
|
|
2876
|
+
}
|
|
2877
|
+
.bar-meta {
|
|
2878
|
+
display: flex;
|
|
2879
|
+
align-items: center;
|
|
2880
|
+
justify-content: space-between;
|
|
2881
|
+
padding: 2px 14px 6px;
|
|
2882
|
+
font-size: 12px;
|
|
2883
|
+
color: var(--muted-color, #64748b);
|
|
2884
|
+
flex-shrink: 0;
|
|
2885
|
+
}
|
|
2886
|
+
.toggle-all {
|
|
2887
|
+
border: none;
|
|
2888
|
+
background: transparent;
|
|
2889
|
+
color: var(--accent-color, #2563eb);
|
|
2890
|
+
font: inherit;
|
|
2891
|
+
font-size: 12px;
|
|
2892
|
+
font-weight: 600;
|
|
2893
|
+
cursor: pointer;
|
|
2894
|
+
padding: 2px 4px;
|
|
2895
|
+
border-radius: 6px;
|
|
2896
|
+
}
|
|
2897
|
+
.toggle-all:hover {
|
|
2898
|
+
background: color-mix(in oklch, var(--accent-color, #2563eb) 10%, transparent);
|
|
2899
|
+
}
|
|
2900
|
+
.users-box {
|
|
2901
|
+
@apply --vertical;
|
|
2902
|
+
flex: 1 1 auto;
|
|
2903
|
+
min-height: 120px;
|
|
2904
|
+
overflow-y: auto;
|
|
2905
|
+
gap: 4px;
|
|
2906
|
+
padding: 4px 12px 12px;
|
|
2907
|
+
box-sizing: border-box;
|
|
2908
|
+
}
|
|
2909
|
+
.user-row {
|
|
2910
|
+
display: flex;
|
|
2911
|
+
align-items: center;
|
|
2912
|
+
gap: 10px;
|
|
2913
|
+
padding: 8px 10px;
|
|
2914
|
+
border-radius: 10px;
|
|
2915
|
+
border: 1px solid transparent;
|
|
2916
|
+
cursor: pointer;
|
|
2917
|
+
user-select: none;
|
|
2918
|
+
transition: background-color 0.15s ease, border-color 0.15s ease;
|
|
2919
|
+
}
|
|
2920
|
+
.user-row:hover {
|
|
2921
|
+
background: var(--subtle-background, rgba(148, 163, 184, 0.12));
|
|
2922
|
+
}
|
|
2923
|
+
.user-row[selected] {
|
|
2924
|
+
background: color-mix(in oklch, var(--accent-color, #2563eb) 10%, transparent);
|
|
2925
|
+
border-color: color-mix(in oklch, var(--accent-color, #2563eb) 40%, transparent);
|
|
2926
|
+
}
|
|
2927
|
+
.avatar-wrap {
|
|
2928
|
+
position: relative;
|
|
2929
|
+
flex-shrink: 0;
|
|
2930
|
+
width: 36px;
|
|
2931
|
+
height: 36px;
|
|
2932
|
+
display: flex;
|
|
2933
|
+
align-items: center;
|
|
2934
|
+
justify-content: center;
|
|
2935
|
+
}
|
|
2936
|
+
.online-dot {
|
|
2937
|
+
position: absolute;
|
|
2938
|
+
right: -1px;
|
|
2939
|
+
bottom: -1px;
|
|
2940
|
+
width: 10px;
|
|
2941
|
+
height: 10px;
|
|
2942
|
+
border-radius: 50%;
|
|
2943
|
+
background: #22c55e;
|
|
2944
|
+
border: 2px solid var(--content-background, #ffffff);
|
|
2945
|
+
box-sizing: border-box;
|
|
2946
|
+
}
|
|
2947
|
+
.user-info {
|
|
2948
|
+
flex: 1 1 auto;
|
|
2949
|
+
min-width: 0;
|
|
2950
|
+
display: flex;
|
|
2951
|
+
flex-direction: column;
|
|
2952
|
+
gap: 1px;
|
|
2953
|
+
}
|
|
2954
|
+
.user-name {
|
|
2955
|
+
font-size: 13.5px;
|
|
2956
|
+
font-weight: 600;
|
|
2957
|
+
white-space: nowrap;
|
|
2958
|
+
overflow: hidden;
|
|
2959
|
+
text-overflow: ellipsis;
|
|
2960
|
+
}
|
|
2961
|
+
.user-sub {
|
|
2962
|
+
font-size: 11.5px;
|
|
2963
|
+
color: var(--muted-color, #64748b);
|
|
2964
|
+
white-space: nowrap;
|
|
2965
|
+
overflow: hidden;
|
|
2966
|
+
text-overflow: ellipsis;
|
|
2967
|
+
}
|
|
2968
|
+
.check-ic {
|
|
2969
|
+
flex-shrink: 0;
|
|
2970
|
+
color: var(--muted-color, #94a3b8);
|
|
2971
|
+
}
|
|
2972
|
+
.user-row[selected] .check-ic {
|
|
2973
|
+
color: var(--accent-color, #2563eb);
|
|
2974
|
+
}
|
|
2975
|
+
.empty-msg {
|
|
2976
|
+
padding: 28px 12px;
|
|
2977
|
+
text-align: center;
|
|
2978
|
+
font-size: 13px;
|
|
2979
|
+
color: var(--muted-color, #64748b);
|
|
2846
2980
|
}
|
|
2847
2981
|
</style>
|
|
2848
|
-
<div
|
|
2849
|
-
<
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
<
|
|
2982
|
+
<div class="wrap" style="display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden;">
|
|
2983
|
+
<div ~if="users?.length" class="search-wrap">
|
|
2984
|
+
<oda-icon icon="carbon:search" :icon-size="15" style="opacity: 0.6;"></oda-icon>
|
|
2985
|
+
<input type="search" ::value="filterVal" placeholder="Поиск сотрудника…">
|
|
2986
|
+
</div>
|
|
2987
|
+
<div ~if="users?.length > 1" class="bar-meta">
|
|
2988
|
+
<span>Выбрано: {{selectedUsers.length}} из {{users.length}}</span>
|
|
2989
|
+
<button type="button" class="toggle-all" @tap="toggleAll()">
|
|
2990
|
+
{{selectedUsers.length === users.length ? 'Снять выбор' : 'Выбрать всех'}}
|
|
2991
|
+
</button>
|
|
2992
|
+
</div>
|
|
2993
|
+
<div ~if="users?.length" class="users-box">
|
|
2994
|
+
<div class="user-row" ~for="filteredUsers" @tap="select_user($for.item)" :selected="isSelected($for.item)">
|
|
2995
|
+
<div class="avatar-wrap">
|
|
2996
|
+
<oda-icon round :icon="$for.item.icon || 'icons:account-circle'" :icon-size="36" :style="'background:' + ($for.item.iconColor || 'transparent') + ';color:white;fill:white;'"></oda-icon>
|
|
2997
|
+
<span ~if="$for.item.online" class="online-dot" title="В сети"></span>
|
|
2998
|
+
</div>
|
|
2999
|
+
<div class="user-info">
|
|
3000
|
+
<span class="user-name">{{$for.item.label || $for.item.DATA?.label || $for.item.id}}</span>
|
|
3001
|
+
<span ~if="$for.item.email || $for.item.DATA?.email" class="user-sub">{{$for.item.email || $for.item.DATA?.email}}</span>
|
|
3002
|
+
</div>
|
|
3003
|
+
<oda-icon class="check-ic" :icon="isSelected($for.item) ? 'icons:check-box' : 'icons:check-box-outline-blank'" :icon-size="20"></oda-icon>
|
|
3004
|
+
</div>
|
|
3005
|
+
<div ~if="filteredUsers.length === 0" class="empty-msg">Никого не найдено</div>
|
|
2855
3006
|
</div>
|
|
2856
|
-
<
|
|
3007
|
+
<div ~if="!users" class="empty-msg">Загрузка списка…</div>
|
|
3008
|
+
<div ~if="users?.length === 0" class="empty-msg">Нет доступных собеседников</div>
|
|
2857
3009
|
</div>
|
|
2858
|
-
<h1 center ~if="!users">Загрузка...</h1>
|
|
2859
|
-
<h1 center ~if="users?.length === 0">пользователи не найдены</h1>
|
|
2860
3010
|
`,
|
|
2861
|
-
|
|
2862
|
-
return (async () => {
|
|
2863
|
-
const $users = await WORK.get_item('/USERS');
|
|
2864
|
-
const users = await $users.items;
|
|
2865
|
-
return (users || []).filter(u => u.id !== WORK.uid);
|
|
2866
|
-
})();
|
|
2867
|
-
},
|
|
3011
|
+
users: [],
|
|
2868
3012
|
filterVal: '',
|
|
2869
3013
|
get filteredUsers() {
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
3014
|
+
const list = Array.isArray(this.users) ? this.users : [];
|
|
3015
|
+
const q = String(this.filterVal || '').trim().toLowerCase();
|
|
3016
|
+
if (!q)
|
|
3017
|
+
return list;
|
|
3018
|
+
return list.filter(u => {
|
|
3019
|
+
const lbl = String(u?.label || u?.DATA?.label || '').toLowerCase();
|
|
3020
|
+
const eml = String(u?.email || u?.DATA?.email || '').toLowerCase();
|
|
3021
|
+
const id = String(u?.id || '').toLowerCase();
|
|
3022
|
+
return lbl.includes(q) || eml.includes(q) || id.includes(q);
|
|
3023
|
+
});
|
|
2874
3024
|
},
|
|
2875
3025
|
selectedUsers: [],
|
|
2876
3026
|
getIndex($user) {
|
|
2877
|
-
return this.selectedUsers.findIndex(u => u.id === $user.id)
|
|
3027
|
+
return this.selectedUsers.findIndex(u => u.id === $user.id);
|
|
2878
3028
|
},
|
|
2879
3029
|
isSelected($user) {
|
|
2880
3030
|
return this.getIndex($user) > -1;
|
|
2881
3031
|
},
|
|
2882
3032
|
select_user($user) {
|
|
2883
3033
|
const idx = this.getIndex($user);
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
else
|
|
2888
|
-
|
|
2889
|
-
|
|
3034
|
+
const next = [...this.selectedUsers];
|
|
3035
|
+
if (idx > -1)
|
|
3036
|
+
next.splice(idx, 1);
|
|
3037
|
+
else
|
|
3038
|
+
next.push($user);
|
|
3039
|
+
this.selectedUsers = next;
|
|
3040
|
+
this.fire('changed');
|
|
3041
|
+
},
|
|
3042
|
+
toggleAll() {
|
|
3043
|
+
const list = Array.isArray(this.users) ? this.users : [];
|
|
3044
|
+
this.selectedUsers = this.selectedUsers.length === list.length ? [] : [...list];
|
|
2890
3045
|
this.fire('changed');
|
|
2891
3046
|
}
|
|
2892
3047
|
});
|
|
@@ -829,7 +829,16 @@ export default {
|
|
|
829
829
|
WORK.authEvents?.addEventListener('auth', () => {
|
|
830
830
|
this._resolvedUserIcon = '';
|
|
831
831
|
this.user_icon = undefined;
|
|
832
|
-
if (WORK.uid &&
|
|
832
|
+
if (!WORK.uid && !WORK.DEV_MODE) {
|
|
833
|
+
this.focusedPage = '';
|
|
834
|
+
this.pages = [];
|
|
835
|
+
this.bookmarks = [];
|
|
836
|
+
this._autoOpenedLogin = true;
|
|
837
|
+
this.visibleMode = 'user';
|
|
838
|
+
if (this.left_drawer)
|
|
839
|
+
this.left_drawer.closed = true;
|
|
840
|
+
}
|
|
841
|
+
else if (WORK.uid && this._autoOpenedLogin && this.visibleMode === 'user') {
|
|
833
842
|
this._autoOpenedLogin = false;
|
|
834
843
|
this.visibleMode = 'main';
|
|
835
844
|
if (this.left_drawer)
|
|
@@ -46,8 +46,12 @@ export default {
|
|
|
46
46
|
$def: false,
|
|
47
47
|
$attr: true,
|
|
48
48
|
get() {
|
|
49
|
-
if (this.isUser)
|
|
50
|
-
|
|
49
|
+
if (this.isUser) {
|
|
50
|
+
this.$item?.__version;
|
|
51
|
+
if (this.$item?.DATA?.enabled === false || this.$item?.DATA?.blocked === true)
|
|
52
|
+
return false;
|
|
53
|
+
return Boolean(this.$item?.DATA?.online ?? this.$item?.online);
|
|
54
|
+
}
|
|
51
55
|
return false;
|
|
52
56
|
}
|
|
53
57
|
},
|
|
@@ -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>
|
|
@@ -697,7 +697,6 @@ ODA({is: 'oda-tree-node',
|
|
|
697
697
|
:host {
|
|
698
698
|
@apply --vertical;
|
|
699
699
|
overflow: visible;
|
|
700
|
-
padding: 4px;
|
|
701
700
|
min-width: 0;
|
|
702
701
|
}
|
|
703
702
|
.node {
|
|
@@ -705,20 +704,20 @@ ODA({is: 'oda-tree-node',
|
|
|
705
704
|
@apply --no-flex;
|
|
706
705
|
align-items: center;
|
|
707
706
|
overflow: hidden;
|
|
708
|
-
height:
|
|
709
|
-
min-height:
|
|
710
|
-
padding: 0
|
|
707
|
+
height: 32px;
|
|
708
|
+
min-height: 32px;
|
|
709
|
+
padding: 0 4px;
|
|
711
710
|
box-sizing: border-box;
|
|
712
711
|
background: var(--content-background);
|
|
713
712
|
color: var(--content-color);
|
|
714
713
|
}
|
|
715
714
|
.node.large-icon-node {
|
|
716
|
-
height:
|
|
717
|
-
min-height:
|
|
715
|
+
height: 64px;
|
|
716
|
+
min-height: 64px;
|
|
718
717
|
}
|
|
719
718
|
.node.medium-icon-node {
|
|
720
|
-
height:
|
|
721
|
-
min-height:
|
|
719
|
+
height: 42px;
|
|
720
|
+
min-height: 42px;
|
|
722
721
|
}
|
|
723
722
|
.node.structure-only-node {
|
|
724
723
|
height: 36px;
|
|
@@ -742,6 +741,7 @@ ODA({is: 'oda-tree-node',
|
|
|
742
741
|
}
|
|
743
742
|
.node.module-blocked item-node {
|
|
744
743
|
opacity: .5;
|
|
744
|
+
filter: grayscale(1);
|
|
745
745
|
}
|
|
746
746
|
.sub-nodes {
|
|
747
747
|
@apply --vertical;
|
|
@@ -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
|
}, '');
|
|
@@ -403,6 +403,20 @@ WORK.onAuthChanged = function (payload = {}) {
|
|
|
403
403
|
} catch {}
|
|
404
404
|
return;
|
|
405
405
|
}
|
|
406
|
+
if (payload.reason === 'disabled') {
|
|
407
|
+
WORK.clearSessionCache?.();
|
|
408
|
+
WORK.uid = '';
|
|
409
|
+
WORK.USER = undefined;
|
|
410
|
+
WORK._accountDisabled = true;
|
|
411
|
+
WORK._loginError = new Error('Учётная запись отключена администратором');
|
|
412
|
+
WORK._loginPromise = null;
|
|
413
|
+
WORK.syncAuthUI();
|
|
414
|
+
try {
|
|
415
|
+
WORK.authEvents?.dispatchEvent(new CustomEvent('auth', { detail: { uid: '', reason: 'disabled' } }));
|
|
416
|
+
WORK.authEvents?.dispatchEvent(new CustomEvent('login-state', { detail: { pending: false, error: WORK._loginError, uid: '' } }));
|
|
417
|
+
} catch {}
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
406
420
|
if (payload.reason === 'logout' && !newUid && !credUid) {
|
|
407
421
|
WORK.uid = '';
|
|
408
422
|
WORK.USER = undefined;
|
|
@@ -483,10 +497,20 @@ WORK.login = async function(force = false){
|
|
|
483
497
|
const prevUid = WORK.uid || '';
|
|
484
498
|
const authChanged = !WORK._authNotifiedOnce || prevUid !== uid;
|
|
485
499
|
WORK.uid = uid;
|
|
500
|
+
WORK._accountDisabled = false;
|
|
486
501
|
WORK._loginError = null;
|
|
487
502
|
WORK._anonExitSynced = false;
|
|
488
503
|
if (authChanged || !WORK.USER)
|
|
489
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
|
+
}
|
|
490
514
|
await WORK.loadUserSettings?.();
|
|
491
515
|
WORK.refreshChatUnread?.();
|
|
492
516
|
if (authChanged) {
|
|
@@ -517,7 +541,20 @@ WORK.login = async function(force = false){
|
|
|
517
541
|
}
|
|
518
542
|
}
|
|
519
543
|
catch (err) {
|
|
520
|
-
|
|
544
|
+
const errText = String(err?.message || err || '');
|
|
545
|
+
if (/отключена администратором|account_disabled/i.test(errText)) {
|
|
546
|
+
WORK._accountDisabled = true;
|
|
547
|
+
WORK.uid = '';
|
|
548
|
+
WORK.USER = undefined;
|
|
549
|
+
WORK._loginError = new Error('Учётная запись отключена администратором');
|
|
550
|
+
WORK.syncAuthUI();
|
|
551
|
+
try {
|
|
552
|
+
WORK.authEvents?.dispatchEvent(new CustomEvent('auth', { detail: { uid: '', reason: 'disabled' } }));
|
|
553
|
+
} catch {}
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
WORK._loginError = err;
|
|
557
|
+
}
|
|
521
558
|
if (WORK._loginPromise === run)
|
|
522
559
|
WORK._loginPromise = null;
|
|
523
560
|
throw err;
|
|
@@ -911,6 +948,23 @@ class WebSocketEvents {
|
|
|
911
948
|
// версия — до fire: слушатели changed делают load(), а его URL (и дедуп WORK.fetch) включает версию;
|
|
912
949
|
// старый порядок склеивал reload с висящим прежним запросом и отдавал устаревший JSON
|
|
913
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
|
+
}
|
|
914
968
|
// роли пользователей и флаги безопасности (roleIds, hasSecurity, icon, label) приходят в info:
|
|
915
969
|
// подтянуть свежие данные и уведомить дерево
|
|
916
970
|
if (item.DATA?.roleIds && !(item instanceof CORE.$user) && !WORK._roleRefresh.has(item)) {
|
|
@@ -4,6 +4,7 @@ import { DEV_MODE, HOST, CHALLENGE_TTL_MS } from './config.js';
|
|
|
4
4
|
import { getMailer } from './mail.js';
|
|
5
5
|
import * as CORE from '../server/index.js';
|
|
6
6
|
import { $server } from '../server/server.js';
|
|
7
|
+
import { notifyUserOnline } from './websocket.js';
|
|
7
8
|
import { audit } from '../server/access/audit.js';
|
|
8
9
|
import { inspectInvite, consumeInvite } from '../server/access/invites.js';
|
|
9
10
|
import { assertWorkplaceAvailableForLogin, sendLoginCodeViaLicenseHub } from '../modules/license/index.js';
|
|
@@ -352,11 +353,13 @@ export const authMethods = {
|
|
|
352
353
|
if (!challengeId || String(challengeId).length > 64)
|
|
353
354
|
throw new Error("challengeId required");
|
|
354
355
|
let users = await WORK.$users;
|
|
355
|
-
let
|
|
356
|
-
if (
|
|
356
|
+
let accountNode = await users.get_item('//' + uid);
|
|
357
|
+
if (!accountNode)
|
|
357
358
|
throw new Error("User not registered");
|
|
358
|
-
|
|
359
|
-
await
|
|
359
|
+
accountNode.reset();
|
|
360
|
+
await accountNode.init;
|
|
361
|
+
if (typeof accountNode._ownUserEnabledSync === 'function' && !accountNode._ownUserEnabledSync())
|
|
362
|
+
throw new Error('Учётная запись отключена администратором');
|
|
360
363
|
// До проверки подписи — только ожидание входа; личность сессии не меняется.
|
|
361
364
|
// Ожидание хранится по challengeId (случайный UUID клиента), а не в сессии: параллельные запросы
|
|
362
365
|
// страницы после перезапуска могут получить разные cookie — вход от этого не рвётся.
|
|
@@ -367,11 +370,11 @@ export const authMethods = {
|
|
|
367
370
|
const key = String(challengeId);
|
|
368
371
|
if (pendingLogins.size >= 10_000)
|
|
369
372
|
throw new Error("Слишком много незавершённых входов, повторите позже");
|
|
370
|
-
const perUid = [...pendingLogins.values()].filter(c => c.uid ===
|
|
373
|
+
const perUid = [...pendingLogins.values()].filter(c => c.uid === accountNode.id).length;
|
|
371
374
|
if (perUid >= 16)
|
|
372
375
|
throw new Error("Слишком много незавершённых входов");
|
|
373
376
|
const challenge = crypto.randomUUID();
|
|
374
|
-
pendingLogins.set(key, { value: challenge, uid:
|
|
377
|
+
pendingLogins.set(key, { value: challenge, uid: accountNode.id, expiresAt: now + CHALLENGE_TTL_MS });
|
|
375
378
|
return challenge;
|
|
376
379
|
},
|
|
377
380
|
|
|
@@ -382,11 +385,17 @@ export const authMethods = {
|
|
|
382
385
|
throw new Error("uid required");
|
|
383
386
|
const challengeKey = challengeId != null ? String(challengeId) : '';
|
|
384
387
|
if (session.uid === uid) {
|
|
388
|
+
const accountNode = await (await WORK.$users).get_item('//' + uid).catch(() => null);
|
|
389
|
+
if (!accountNode || (typeof accountNode._ownUserEnabledSync === 'function' && !accountNode._ownUserEnabledSync())) {
|
|
390
|
+
WORK.constructor.clearAllSessionsForUid?.(uid);
|
|
391
|
+
throw new Error('Учётная запись отключена администратором');
|
|
392
|
+
}
|
|
385
393
|
if (challengeKey) {
|
|
386
394
|
const entry = pendingLogins.get(challengeKey);
|
|
387
395
|
if (entry?.uid === uid)
|
|
388
396
|
pendingLogins.delete(challengeKey);
|
|
389
397
|
}
|
|
398
|
+
notifyUserOnline(session, accountNode);
|
|
390
399
|
}
|
|
391
400
|
else {
|
|
392
401
|
let signature = params.post?.signature;
|
|
@@ -399,11 +408,11 @@ export const authMethods = {
|
|
|
399
408
|
throw new Error("login session break. Challenge expired.");
|
|
400
409
|
if (challengeEntry.uid !== uid)
|
|
401
410
|
throw new Error("login session break. Challenge issued for another user.");
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
411
|
+
const accountNode = await (await WORK.$users).get_item('//' + uid);
|
|
412
|
+
if (!accountNode)
|
|
404
413
|
throw new Error("User not registered");
|
|
405
|
-
await
|
|
406
|
-
let publicKey =
|
|
414
|
+
await accountNode.init;
|
|
415
|
+
let publicKey = accountNode.DATA?.keys?.[time];
|
|
407
416
|
if (!publicKey) throw new Error("login session break. Need publicKey.");
|
|
408
417
|
let PK = await crypto.subtle.importKey("spki", Buffer.from(publicKey, "base64"), { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }, true, ["verify"]);
|
|
409
418
|
const isValid = await crypto.subtle.verify(
|
|
@@ -423,11 +432,10 @@ export const authMethods = {
|
|
|
423
432
|
currentSsid: session.ssid,
|
|
424
433
|
isAdmin,
|
|
425
434
|
});
|
|
426
|
-
session.credentials =
|
|
427
|
-
$server.signIn(session,
|
|
435
|
+
session.credentials = accountNode.DATA;
|
|
436
|
+
$server.signIn(session, accountNode);
|
|
428
437
|
audit('login', { params });
|
|
429
|
-
|
|
430
|
-
$user.reset();
|
|
438
|
+
notifyUserOnline(session, accountNode);
|
|
431
439
|
$server.broadcastAuthChangedToSession(session, { uid, reason: 'login' });
|
|
432
440
|
}
|
|
433
441
|
const invTok = String(params.post?.inviteToken || params.inviteToken || '').trim();
|
|
@@ -487,6 +495,9 @@ export const authMethods = {
|
|
|
487
495
|
}
|
|
488
496
|
const affected = Object.values($server.sessions).filter(s => s.uid === uid);
|
|
489
497
|
this.constructor.clearAllSessionsForUid(uid);
|
|
498
|
+
const exitNode = await (await WORK.$users).get_item('//' + uid).catch(() => null);
|
|
499
|
+
if (exitNode)
|
|
500
|
+
notifyUserOnline(null, exitNode);
|
|
490
501
|
for (const [id, c] of pendingLogins)
|
|
491
502
|
if (c?.uid === uid)
|
|
492
503
|
pendingLogins.delete(id);
|
|
@@ -351,6 +351,7 @@ export function createRequestHandler() {
|
|
|
351
351
|
else {
|
|
352
352
|
session = $server.get_session(cookies.ssid);
|
|
353
353
|
session.ip = request.socket?.remoteAddress;
|
|
354
|
+
WORK.constructor.enforceSessionEnabled?.(session);
|
|
354
355
|
}
|
|
355
356
|
const url = new URL(`https://${request.headers.host || HOST}` + request.url);
|
|
356
357
|
let path = decodeURIComponent(url.pathname);
|
|
@@ -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; // анонимная сессия — без присутствия
|
|
@@ -75,12 +75,13 @@ export function broadcastChatEvent(uids, payload) {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
function notifyUserOnline(session) {
|
|
79
|
-
|
|
78
|
+
export function notifyUserOnline(session, userOverride = null) {
|
|
79
|
+
const user = userOverride || session?.$user;
|
|
80
|
+
if (!user)
|
|
80
81
|
return;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
broadcastUserPath(
|
|
82
|
+
user.online = undefined;
|
|
83
|
+
user.reset?.();
|
|
84
|
+
broadcastUserPath(user);
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
export function isTaskVisibleToUser(uid, taskPath) {
|
|
@@ -159,7 +160,8 @@ export function onWebSocketConnect(ws, request) {
|
|
|
159
160
|
let wsid = $server.genGUID();
|
|
160
161
|
session.sockets[wsid] = { ws, events: [], visibleTasks: new Set() };
|
|
161
162
|
ws.send(JSON.stringify({ type: 'connect', wsid }));
|
|
162
|
-
|
|
163
|
+
if (session.uid)
|
|
164
|
+
notifyUserOnline(session);
|
|
163
165
|
ws.on('message', async (message) => {
|
|
164
166
|
try {
|
|
165
167
|
let str = new TextDecoder('utf-8').decode(message);
|
|
@@ -204,10 +206,11 @@ export function onWebSocketConnect(ws, request) {
|
|
|
204
206
|
}
|
|
205
207
|
});
|
|
206
208
|
ws.on('close', () => {
|
|
209
|
+
const hadUser = session.$user;
|
|
207
210
|
session.sockets[wsid] = undefined;
|
|
208
211
|
delete session.sockets[wsid];
|
|
209
|
-
if (!Object.keys(session.sockets).length)
|
|
210
|
-
notifyUserOnline(session);
|
|
212
|
+
if (!Object.keys(session.sockets).length && hadUser)
|
|
213
|
+
notifyUserOnline(session, hadUser);
|
|
211
214
|
});
|
|
212
215
|
// F24: слишком большое сообщение (и прочие ошибки сокета) — не роняют процесс
|
|
213
216
|
ws.on('error', e => log.debug('ws.error', e));
|
|
@@ -384,9 +384,13 @@ export class RTCCaller extends EventTarget {
|
|
|
384
384
|
|
|
385
385
|
static async sendMessage(callContext, signalMessage) {
|
|
386
386
|
console.log('sendMessage', signalMessage);
|
|
387
|
+
let target = callContext;
|
|
388
|
+
if (target?.DATA?.isUser && WORK?.uid && target.id !== WORK.uid) {
|
|
389
|
+
target = WORK.USER || await WORK.get_$user?.(WORK.uid).catch(() => null) || target;
|
|
390
|
+
}
|
|
387
391
|
let file = new File([JSON.stringify(signalMessage)], 'phone.call', { type: "application/json" });
|
|
388
392
|
let params = { receivers: signalMessage.receivers };
|
|
389
|
-
await
|
|
393
|
+
await target.save_file(file, params);
|
|
390
394
|
}
|
|
391
395
|
|
|
392
396
|
static currentAnswerDialog = null;
|
|
@@ -99,7 +99,8 @@ ODA({ is: 'user-profile', imports: 'oda//otp.js',
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
const errMsg = String(this.error?.message || this.error || '');
|
|
102
|
-
const
|
|
102
|
+
const isDisabledAccount = /отключена администратором|account_disabled/i.test(errMsg) || Boolean(WORK?._accountDisabled);
|
|
103
|
+
const keyRejected = !isDisabledAccount && /user not registered|need publickey|login failed|challenge issued for another user/i.test(errMsg);
|
|
103
104
|
if(!this.isRegistered || !this.hasKey || keyRejected)
|
|
104
105
|
return {
|
|
105
106
|
name: 'unregistered',
|
|
@@ -115,6 +116,13 @@ ODA({ is: 'user-profile', imports: 'oda//otp.js',
|
|
|
115
116
|
legend: 'Выполняется вход в систему…',
|
|
116
117
|
class: 'info-invert'
|
|
117
118
|
}
|
|
119
|
+
if (isDisabledAccount)
|
|
120
|
+
return {
|
|
121
|
+
name: 'need-login',
|
|
122
|
+
label: 'Повторить вход',
|
|
123
|
+
legend: 'Учётная запись отключена администратором. После повторного включения нажмите «Повторить вход».',
|
|
124
|
+
class: 'error-invert'
|
|
125
|
+
}
|
|
118
126
|
return {
|
|
119
127
|
name: 'need-login',
|
|
120
128
|
label: 'Войти',
|
|
@@ -205,17 +205,13 @@ export function isSameOriginRequest(request) {
|
|
|
205
205
|
const normHost = stripDefaultPort(rawHost);
|
|
206
206
|
const normFwd = stripDefaultPort(fwdHost);
|
|
207
207
|
const isProxied = isLoopbackRemote(request) || Boolean(h['x-forwarded-proto'] && h['x-work-wsid'] !== undefined);
|
|
208
|
+
const isSameSiteWithWsid = Boolean(site === 'same-origin' && h['x-work-wsid'] !== undefined);
|
|
208
209
|
if (h.origin) {
|
|
209
210
|
try {
|
|
210
211
|
const originHost = stripDefaultPort(new URL(h.origin).host);
|
|
211
212
|
const matchesHost = Boolean(normHost && originHost === normHost);
|
|
212
213
|
const matchesFwd = Boolean(isProxied && normFwd && originHost === normFwd);
|
|
213
|
-
|
|
214
|
-
isLoopbackRemote(request)
|
|
215
|
-
&& site === 'same-origin'
|
|
216
|
-
&& h['x-work-wsid'] !== undefined
|
|
217
|
-
);
|
|
218
|
-
if (!matchesHost && !matchesFwd && !matchesLoopbackSameSite)
|
|
214
|
+
if (!matchesHost && !matchesFwd && !isSameSiteWithWsid)
|
|
219
215
|
return false;
|
|
220
216
|
}
|
|
221
217
|
catch { return false; }
|
|
@@ -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),
|
|
@@ -412,7 +412,7 @@ export const classFeedMethods = {
|
|
|
412
412
|
switch (params.mode || 'folder') {
|
|
413
413
|
case 'dates': {
|
|
414
414
|
const nonEmpty = params.nonEmpty === true || params.nonEmpty === '1' || params.nonEmpty === 'true';
|
|
415
|
-
return LOGS.datesList(this, { nonEmpty, ownOnly });
|
|
415
|
+
return LOGS.datesList(this, { nonEmpty, ownOnly, feedMode: params.feedMode || '' });
|
|
416
416
|
}
|
|
417
417
|
case 'bodies':
|
|
418
418
|
return bodies();
|
|
@@ -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/logs.js
CHANGED
|
@@ -127,13 +127,19 @@ export function logExt(row) {
|
|
|
127
127
|
|
|
128
128
|
export function isSystemMetaLogRow(row) {
|
|
129
129
|
const p = String(row?.path || '').trim().replace(/\\/g, '/');
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
if (p) {
|
|
131
|
+
if (/(?:^|\/)(?:class\.js|readme\.md)$/i.test(p))
|
|
132
|
+
return true;
|
|
133
|
+
if (/\/history\/\d{4}-\d{2}-\d{2}\/\d+\.[^/]+\.js$/i.test(p))
|
|
134
|
+
return true;
|
|
135
|
+
// Снимки метафайлов внутри $.../#... (кроме пользовательских документов и задач .task)
|
|
136
|
+
if (/\/#(?:secret|system)\//i.test(p) && !/\.task$/i.test(p))
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
if (!String(row?.content || '').trim() && Array.isArray(row?.includes) && row.includes.length) {
|
|
140
|
+
if (row.includes.every(inc => /(?:^|\/)(?:class\.js|readme\.md)$/i.test(String(inc || '').trim().replace(/\\/g, '/'))))
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
137
143
|
return false;
|
|
138
144
|
}
|
|
139
145
|
|
|
@@ -197,8 +203,9 @@ function isVisibleChatRootRow(row, ownOnly = null) {
|
|
|
197
203
|
* Даты, за которые есть логи (по убыванию).
|
|
198
204
|
* По умолчанию сегодня всегда в списке; при `nonEmpty: true` — только дни, где есть хотя бы одна видимая корневая запись (без `mainContext`).
|
|
199
205
|
*/
|
|
200
|
-
export async function datesList(storage, { nonEmpty = false, ownOnly = null } = {}) {
|
|
206
|
+
export async function datesList(storage, { nonEmpty = false, ownOnly = null, feedMode = '' } = {}) {
|
|
201
207
|
const dateSet = new Set(nonEmpty ? [] : [today()]);
|
|
208
|
+
const skipSys = feedMode === 'dialog';
|
|
202
209
|
try {
|
|
203
210
|
const db = await dbForStorage(storage);
|
|
204
211
|
const fp = feedPathOf(storage);
|
|
@@ -209,7 +216,7 @@ export async function datesList(storage, { nonEmpty = false, ownOnly = null } =
|
|
|
209
216
|
continue;
|
|
210
217
|
try {
|
|
211
218
|
const row = typeof r.body === 'string' ? JSON.parse(r.body) : r.body;
|
|
212
|
-
if (isVisibleChatRootRow(row, ownOnly))
|
|
219
|
+
if (isVisibleChatRootRow(row, ownOnly) && (!skipSys || !isSystemMetaLogRow(row)))
|
|
213
220
|
dateSet.add(r.day);
|
|
214
221
|
}
|
|
215
222
|
catch { /* skip broken json */ }
|
|
@@ -240,7 +247,7 @@ export async function datesList(storage, { nonEmpty = false, ownOnly = null } =
|
|
|
240
247
|
for (const fname of fs.readdirSync(dayPath).filter(n => n.endsWith('.logs'))) {
|
|
241
248
|
try {
|
|
242
249
|
const row = JSON.parse(fs.readFileSync(path.join(dayPath, fname), 'utf-8'));
|
|
243
|
-
if (isVisibleChatRootRow(row, ownOnly)) {
|
|
250
|
+
if (isVisibleChatRootRow(row, ownOnly) && (!skipSys || !isSystemMetaLogRow(row))) {
|
|
244
251
|
dateSet.add(entry.name);
|
|
245
252
|
break;
|
|
246
253
|
}
|
package/sources/server/server.js
CHANGED
|
@@ -420,8 +420,8 @@ export class $server extends $class {
|
|
|
420
420
|
* Вход в сессию после успешной проверки (подпись ключа / регистрация):
|
|
421
421
|
* субъект сессии + новый ssid (старый, известный до входа, больше не действует).
|
|
422
422
|
*/
|
|
423
|
-
static signIn(session,
|
|
424
|
-
if (
|
|
423
|
+
static signIn(session, account) {
|
|
424
|
+
if (account && typeof account._ownUserEnabledSync === 'function' && !account._ownUserEnabledSync())
|
|
425
425
|
throw new Error('Учётная запись отключена администратором');
|
|
426
426
|
const old = session.ssid;
|
|
427
427
|
const id = this.newSessionId();
|
|
@@ -429,13 +429,24 @@ export class $server extends $class {
|
|
|
429
429
|
delete this.sessions[old];
|
|
430
430
|
session.ssid = id;
|
|
431
431
|
this.sessions[id] = session;
|
|
432
|
-
session.uid =
|
|
433
|
-
session.id =
|
|
434
|
-
session.$user =
|
|
435
|
-
session.principal = Object.freeze({ kind: 'user', id:
|
|
432
|
+
session.uid = account.id;
|
|
433
|
+
session.id = account.id;
|
|
434
|
+
session.$user = account;
|
|
435
|
+
session.principal = Object.freeze({ kind: 'user', id: account.id });
|
|
436
|
+
session.isAccountEnabled = () => account._ownUserEnabledSync();
|
|
436
437
|
return session;
|
|
437
438
|
}
|
|
438
439
|
|
|
440
|
+
static enforceSessionEnabled(session) {
|
|
441
|
+
if (!session?.uid || typeof session.isAccountEnabled !== 'function' || session.isAccountEnabled())
|
|
442
|
+
return true;
|
|
443
|
+
for (const sock of Object.values(session.sockets || {})) {
|
|
444
|
+
try { sock?.ws?.close?.(4403, 'account_disabled'); } catch { /* ignore */ }
|
|
445
|
+
}
|
|
446
|
+
this.clearAllSessionsForUid(session.uid);
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
|
|
439
450
|
static clearSessionAuth(session) {
|
|
440
451
|
if (!session)
|
|
441
452
|
return;
|
package/sources/server/user.js
CHANGED
|
@@ -25,7 +25,11 @@ export class $user extends $class {
|
|
|
25
25
|
get $public() {
|
|
26
26
|
return {
|
|
27
27
|
get online() {
|
|
28
|
-
|
|
28
|
+
if (!this._ownUserEnabledSync())
|
|
29
|
+
return false;
|
|
30
|
+
return Object.values(globalThis.$server?.sessions || {}).some(
|
|
31
|
+
s => s?.uid === this.id && Object.keys(s.sockets || {}).length > 0
|
|
32
|
+
);
|
|
29
33
|
},
|
|
30
34
|
get enabled() {
|
|
31
35
|
return this._ownUserEnabledSync();
|
|
@@ -33,6 +37,9 @@ export class $user extends $class {
|
|
|
33
37
|
get usersContainer() {
|
|
34
38
|
return this.DATA?.usersContainer === true ? true : undefined;
|
|
35
39
|
},
|
|
40
|
+
get isUser() {
|
|
41
|
+
return this.DATA?.usersContainer === true ? undefined : true;
|
|
42
|
+
},
|
|
36
43
|
icon: {
|
|
37
44
|
get() {
|
|
38
45
|
let icon = this.DATA?.icon;
|
|
@@ -162,6 +169,8 @@ export class $user extends $class {
|
|
|
162
169
|
return true;
|
|
163
170
|
if (globalThis.WORK && await this._isWorkBoss(params))
|
|
164
171
|
return true;
|
|
172
|
+
if (!this._ownUserEnabledSync())
|
|
173
|
+
return false;
|
|
165
174
|
const { visibleContacts } = await import('./chat-threads.js');
|
|
166
175
|
const contacts = await visibleContacts(this, params);
|
|
167
176
|
return contacts.some(c => c.id === this.id);
|
package/$server/$folder/$class/$structure/$user/handlers/pages/form/profile/$handler/class.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import '/sources/modules/user-profile/user-profile.js';
|
|
2
|
-
export default {
|
|
3
|
-
label: 'Профиль',
|
|
4
|
-
description: 'Личные данные и контактная информация пользователя',
|
|
5
|
-
icon: 'icons:account-circle',
|
|
6
|
-
order: 15,
|
|
7
|
-
async allowUse($context, params) {
|
|
8
|
-
if (!$context?.id || $context?.DATA?.usersContainer)
|
|
9
|
-
return false;
|
|
10
|
-
const uid = $context?.constructor?.resolveUid?.(params) || params?.session?.uid || '';
|
|
11
|
-
if (!uid || $context.id === uid)
|
|
12
|
-
return false;
|
|
13
|
-
if (globalThis.WORK?.DEV_MODE)
|
|
14
|
-
return false;
|
|
15
|
-
const isBoss = await globalThis.WORK?._isWorkBoss?.(params).catch(() => false);
|
|
16
|
-
return !isBoss;
|
|
17
|
-
},
|
|
18
|
-
component: {
|
|
19
|
-
template: /* html */`
|
|
20
|
-
<style>
|
|
21
|
-
:host {
|
|
22
|
-
@apply --vertical;
|
|
23
|
-
@apply --flex;
|
|
24
|
-
overflow: hidden;
|
|
25
|
-
}
|
|
26
|
-
</style>
|
|
27
|
-
<user-profile :$item flex></user-profile>
|
|
28
|
-
`
|
|
29
|
-
}
|
|
30
|
-
};
|