odant-work 1.0.108 → 1.0.109
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/$server/handlers/pages/form/system/sms/$handler/class.js +293 -0
- package/$server/$folder/$class/$structure/handlers/methods/invite/$handler/class.js +31 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +25 -2
- package/$server/$folder/handlers/pages/form/$handler/class.js +79 -37
- package/$server/$folder/lib/consultant/consultant.js +58 -6
- package/$server/$folder/lib/invite/invite.js +370 -0
- package/$server/$folder/lib/node-explorer/node-explorer.js +0 -3
- package/package.json +1 -1
- package/sources/client.js +36 -4
- package/sources/host/auth-methods.js +398 -27
- package/sources/host/sms.js +351 -0
- package/sources/modules/license/index.js +9 -4
- package/sources/modules/user-profile/user-profile.js +337 -23
- package/sources/server/access/gateway.js +4 -1
- package/sources/server/access/invites.js +149 -8
- package/sources/server/server.js +31 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Диалог приглашения пользователя на рабочее место активной структуры ($structure) для BOSS.
|
|
3
|
+
* Используется как из метод-хендлера тулбара/контекстного меню ($structure/handlers/methods/invite),
|
|
4
|
+
* так и из вкладки «Система → Пользователи».
|
|
5
|
+
*/
|
|
6
|
+
function flattenRoles(roles = [], prefix = '', depth = 0, out = []) {
|
|
7
|
+
for (const r of (Array.isArray(roles) ? roles : [])) {
|
|
8
|
+
if (!r || !r.id)
|
|
9
|
+
continue;
|
|
10
|
+
const trail = prefix ? `${prefix}/${r.id}` : r.id;
|
|
11
|
+
out.push({
|
|
12
|
+
trail,
|
|
13
|
+
label: `${' '.repeat(depth)}${r.label || r.id}${r.external ? ' (клиент)' : ''}`,
|
|
14
|
+
});
|
|
15
|
+
if (Array.isArray(r.ROLES) && r.ROLES.length)
|
|
16
|
+
flattenRoles(r.ROLES, trail, depth + 1, out);
|
|
17
|
+
}
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof ODA === 'function' && !customElements.get('work-invite-dialog')) {
|
|
22
|
+
ODA({
|
|
23
|
+
is: 'work-invite-dialog',
|
|
24
|
+
imports: 'oda//button, oda//icon',
|
|
25
|
+
template: /* html */`
|
|
26
|
+
<style>
|
|
27
|
+
:host {
|
|
28
|
+
@apply --vertical;
|
|
29
|
+
width: min(500px, 94vw);
|
|
30
|
+
max-height: min(640px, 84vh);
|
|
31
|
+
padding: 16px 18px;
|
|
32
|
+
gap: 12px;
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
overflow-y: auto;
|
|
35
|
+
background: var(--content-background, #ffffff);
|
|
36
|
+
color: var(--content-color, #0f172a);
|
|
37
|
+
font-size: 13.5px;
|
|
38
|
+
}
|
|
39
|
+
.field {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
gap: 4px;
|
|
43
|
+
}
|
|
44
|
+
.field label {
|
|
45
|
+
font-size: 12px;
|
|
46
|
+
font-weight: 600;
|
|
47
|
+
color: var(--muted-color, #64748b);
|
|
48
|
+
}
|
|
49
|
+
.field input, .field select, .field textarea {
|
|
50
|
+
padding: 8px 10px;
|
|
51
|
+
border-radius: 8px;
|
|
52
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
53
|
+
background: var(--content-background, #fff);
|
|
54
|
+
color: var(--content-color, #0f172a);
|
|
55
|
+
font: inherit;
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
width: 100%;
|
|
58
|
+
}
|
|
59
|
+
.tabs {
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-wrap: wrap;
|
|
62
|
+
gap: 6px;
|
|
63
|
+
}
|
|
64
|
+
.tab-btn {
|
|
65
|
+
padding: 6px 10px;
|
|
66
|
+
border-radius: 8px;
|
|
67
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
68
|
+
background: var(--subtle-background, #f8fafc);
|
|
69
|
+
color: inherit;
|
|
70
|
+
font: inherit;
|
|
71
|
+
font-size: 12.5px;
|
|
72
|
+
font-weight: 600;
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
}
|
|
75
|
+
.tab-btn.active {
|
|
76
|
+
background: var(--accent-color, #2563eb);
|
|
77
|
+
color: #ffffff;
|
|
78
|
+
border-color: transparent;
|
|
79
|
+
}
|
|
80
|
+
.existing-box {
|
|
81
|
+
padding: 10px 12px;
|
|
82
|
+
border-radius: 10px;
|
|
83
|
+
border: 1px solid rgba(16, 185, 129, 0.4);
|
|
84
|
+
background: rgba(16, 185, 129, 0.08);
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
gap: 8px;
|
|
88
|
+
}
|
|
89
|
+
.result-box {
|
|
90
|
+
padding: 10px 12px;
|
|
91
|
+
border-radius: 10px;
|
|
92
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
93
|
+
background: var(--subtle-background, #f8fafc);
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
gap: 8px;
|
|
97
|
+
}
|
|
98
|
+
.url-line {
|
|
99
|
+
word-break: break-all;
|
|
100
|
+
font-family: monospace;
|
|
101
|
+
font-size: 12px;
|
|
102
|
+
padding: 6px 8px;
|
|
103
|
+
border-radius: 6px;
|
|
104
|
+
background: var(--content-background, #fff);
|
|
105
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
106
|
+
}
|
|
107
|
+
.row-btns {
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
gap: 8px;
|
|
111
|
+
flex-wrap: wrap;
|
|
112
|
+
}
|
|
113
|
+
.inv-list {
|
|
114
|
+
display: flex;
|
|
115
|
+
flex-direction: column;
|
|
116
|
+
gap: 6px;
|
|
117
|
+
border-top: 1px solid var(--subtle-border, #e2e8f0);
|
|
118
|
+
padding-top: 10px;
|
|
119
|
+
}
|
|
120
|
+
.inv-item {
|
|
121
|
+
display: flex;
|
|
122
|
+
align-items: center;
|
|
123
|
+
gap: 8px;
|
|
124
|
+
padding: 6px 8px;
|
|
125
|
+
border-radius: 8px;
|
|
126
|
+
border: 1px solid var(--subtle-border, #e2e8f0);
|
|
127
|
+
font-size: 12.5px;
|
|
128
|
+
}
|
|
129
|
+
.warn {
|
|
130
|
+
color: #b45309;
|
|
131
|
+
font-size: 12.5px;
|
|
132
|
+
}
|
|
133
|
+
.err {
|
|
134
|
+
color: #dc2626;
|
|
135
|
+
font-size: 12.5px;
|
|
136
|
+
}
|
|
137
|
+
.ok {
|
|
138
|
+
color: #059669;
|
|
139
|
+
font-size: 12.5px;
|
|
140
|
+
font-weight: 600;
|
|
141
|
+
}
|
|
142
|
+
</style>
|
|
143
|
+
|
|
144
|
+
<div class="field">
|
|
145
|
+
<label>Рабочее место в «{{$item?.DATA?.label || $item?.label || $item?.id}}»</label>
|
|
146
|
+
<select ::value="trail">
|
|
147
|
+
<option ~for="placeOptions" :value="$for.item.trail">{{$for.item.label}}</option>
|
|
148
|
+
</select>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<div class="field">
|
|
152
|
+
<label>Способ приглашения</label>
|
|
153
|
+
<div class="tabs">
|
|
154
|
+
<button type="button" class="tab-btn" ~class="{ active: channel === 'email' }" @tap="setChannel('email')">Email</button>
|
|
155
|
+
<button type="button" class="tab-btn" ~class="{ active: channel === 'phone' }" @tap="setChannel('phone')">Телефон</button>
|
|
156
|
+
<button type="button" class="tab-btn" ~class="{ active: channel === 'link' }" @tap="setChannel('link')">Ссылка</button>
|
|
157
|
+
<button type="button" class="tab-btn" ~class="{ active: channel === 'telegram' }" @tap="setChannel('telegram')">Telegram</button>
|
|
158
|
+
<button type="button" class="tab-btn" ~class="{ active: channel === 'max' }" @tap="setChannel('max')">MAX</button>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
<div class="field" ~if="channel !== 'link'">
|
|
163
|
+
<label>{{recipientLabel}}</label>
|
|
164
|
+
<input :type="channel === 'email' ? 'email' : (channel === 'phone' ? 'tel' : 'text')"
|
|
165
|
+
:placeholder="recipientPlaceholder"
|
|
166
|
+
::value="recipient"
|
|
167
|
+
@input="onRecipientInput">
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<div ~if="existingUser" class="existing-box">
|
|
171
|
+
<div>
|
|
172
|
+
Пользователь уже зарегистрирован на сервере: <b>{{existingUser.label}}</b>
|
|
173
|
+
<span ~if="existingUser.enabled === false" style="color:#dc2626;"> (отключён)</span>
|
|
174
|
+
</div>
|
|
175
|
+
<div class="row-btns" ~if="existingUser.enabled !== false">
|
|
176
|
+
<oda-button primary icon="icons:check" label="Назначить сразу" @tap="assignExisting" :disabled="busy || !trail"></oda-button>
|
|
177
|
+
<oda-button icon="icons:send" label="Отправить приглашение" @tap="createInvite" :disabled="busy || !trail"></oda-button>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<div class="field">
|
|
182
|
+
<label>Комментарий (необязательно)</label>
|
|
183
|
+
<input type="text" placeholder="Например: добро пожаловать в команду" ::value="note">
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<div class="row-btns" ~if="!existingUser">
|
|
187
|
+
<oda-button primary icon="icons:person-add" label="Создать и отправить приглашение" @tap="createInvite" :disabled="busy || !trail || (channel !== 'link' && !recipient.trim())"></oda-button>
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
<div ~if="statusOk" class="ok">{{statusOk}}</div>
|
|
191
|
+
<div ~if="errorMsg" class="err">{{errorMsg}}</div>
|
|
192
|
+
|
|
193
|
+
<div ~if="createdResult" class="result-box">
|
|
194
|
+
<div class="ok" ~if="createdResult.sent">Приглашение отправлено ({{createdResult.sentVia}}).</div>
|
|
195
|
+
<div class="warn" ~if="createdResult.warning">{{createdResult.warning}}</div>
|
|
196
|
+
<div class="url-line">{{createdResult.url}}</div>
|
|
197
|
+
<div class="row-btns">
|
|
198
|
+
<oda-button icon="icons:content-copy" label="Копировать ссылку" @tap="copyUrl(createdResult.url)"></oda-button>
|
|
199
|
+
<oda-button ~if="createdResult.shareUrl" icon="icons:share" label="Поделиться в Telegram" @tap="openShare(createdResult.shareUrl)"></oda-button>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<div class="inv-list" ~if="activeInvites.length">
|
|
204
|
+
<label style="font-size:12px;font-weight:600;color:var(--muted-color,#64748b);">Активные приглашения ({{activeInvites.length}})</label>
|
|
205
|
+
<div class="inv-item" ~for="activeInvites">
|
|
206
|
+
<div style="flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">
|
|
207
|
+
<b>{{$for.item.placeLabel}}</b> · {{$for.item.channel}}{{$for.item.recipient ? ': ' + $for.item.recipient : ''}}
|
|
208
|
+
</div>
|
|
209
|
+
<oda-button icon="icons:close" title="Отозвать приглашение" @tap="revokeInvite($for.item)" style="min-height:24px;"></oda-button>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
`,
|
|
213
|
+
$item: {
|
|
214
|
+
$def: null,
|
|
215
|
+
set(n) {
|
|
216
|
+
if (n) this.load();
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
placeOptions: [],
|
|
220
|
+
trail: '',
|
|
221
|
+
channel: 'email',
|
|
222
|
+
recipient: '',
|
|
223
|
+
note: '',
|
|
224
|
+
existingUser: null,
|
|
225
|
+
createdResult: null,
|
|
226
|
+
activeInvites: [],
|
|
227
|
+
busy: false,
|
|
228
|
+
statusOk: '',
|
|
229
|
+
errorMsg: '',
|
|
230
|
+
get recipientLabel() {
|
|
231
|
+
if (this.channel === 'email') return 'Email получателя';
|
|
232
|
+
if (this.channel === 'phone') return 'Номер телефона (+79991234567)';
|
|
233
|
+
if (this.channel === 'telegram') return 'Telegram Chat ID (или @username для ссылки)';
|
|
234
|
+
if (this.channel === 'max') return 'MAX Chat ID';
|
|
235
|
+
return 'Получатель';
|
|
236
|
+
},
|
|
237
|
+
get recipientPlaceholder() {
|
|
238
|
+
if (this.channel === 'email') return 'user@company.ru';
|
|
239
|
+
if (this.channel === 'phone') return '+79991234567';
|
|
240
|
+
if (this.channel === 'telegram') return '123456789';
|
|
241
|
+
if (this.channel === 'max') return 'chat_id';
|
|
242
|
+
return '';
|
|
243
|
+
},
|
|
244
|
+
attached() {
|
|
245
|
+
if (this.$item) this.load();
|
|
246
|
+
},
|
|
247
|
+
setChannel(ch) {
|
|
248
|
+
this.channel = ch;
|
|
249
|
+
this.existingUser = null;
|
|
250
|
+
this.createdResult = null;
|
|
251
|
+
this.errorMsg = '';
|
|
252
|
+
this.statusOk = '';
|
|
253
|
+
},
|
|
254
|
+
onRecipientInput() {
|
|
255
|
+
this.existingUser = null;
|
|
256
|
+
this.statusOk = '';
|
|
257
|
+
this.errorMsg = '';
|
|
258
|
+
clearTimeout(this._lookupTimer);
|
|
259
|
+
if (this.channel !== 'email' && this.channel !== 'phone')
|
|
260
|
+
return;
|
|
261
|
+
const val = String(this.recipient || '').trim();
|
|
262
|
+
if (!val)
|
|
263
|
+
return;
|
|
264
|
+
this._lookupTimer = setTimeout(() => this.lookupExisting(val), 350);
|
|
265
|
+
},
|
|
266
|
+
async lookupExisting(val) {
|
|
267
|
+
if (!this.$item || (this.channel !== 'email' && this.channel !== 'phone'))
|
|
268
|
+
return;
|
|
269
|
+
try {
|
|
270
|
+
const payload = this.channel === 'email' ? { email: val } : { phone: val };
|
|
271
|
+
const res = await this.$item.fetch('invite_lookup_user', {}, payload);
|
|
272
|
+
if (String(this.recipient || '').trim() !== val)
|
|
273
|
+
return;
|
|
274
|
+
this.existingUser = res?.exists ? res : null;
|
|
275
|
+
} catch { /* ignore */ }
|
|
276
|
+
},
|
|
277
|
+
async load() {
|
|
278
|
+
if (!this.$item) return;
|
|
279
|
+
try {
|
|
280
|
+
await this.$item.init?.catch?.(() => {});
|
|
281
|
+
const sec = this.$item.DATA?.['#security'] || {};
|
|
282
|
+
const opts = [];
|
|
283
|
+
if (this.$item.DATA?.allowRoles !== false) {
|
|
284
|
+
flattenRoles(sec.ROLES || [], '', 0, opts);
|
|
285
|
+
}
|
|
286
|
+
opts.push({ trail: 'BOSS', label: 'Руководитель (BOSS)' });
|
|
287
|
+
this.placeOptions = opts;
|
|
288
|
+
if (!this.trail || !opts.some(o => o.trail === this.trail))
|
|
289
|
+
this.trail = opts[0]?.trail || 'BOSS';
|
|
290
|
+
await this.reloadInvites();
|
|
291
|
+
} catch (err) {
|
|
292
|
+
this.errorMsg = err?.message || String(err);
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
async reloadInvites() {
|
|
296
|
+
if (!this.$item) return;
|
|
297
|
+
try {
|
|
298
|
+
const list = await this.$item.fetch('invite_list');
|
|
299
|
+
this.activeInvites = (Array.isArray(list) ? list : []).filter(i => i?.status === 'active');
|
|
300
|
+
} catch {
|
|
301
|
+
this.activeInvites = [];
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
async assignExisting() {
|
|
305
|
+
if (!this.$item || !this.existingUser?.uid || !this.trail || this.busy)
|
|
306
|
+
return;
|
|
307
|
+
this.busy = true;
|
|
308
|
+
this.errorMsg = '';
|
|
309
|
+
this.statusOk = '';
|
|
310
|
+
try {
|
|
311
|
+
const res = await this.$item.fetch('invite_assign_existing', {}, {
|
|
312
|
+
uid: this.existingUser.uid,
|
|
313
|
+
trail: this.trail,
|
|
314
|
+
});
|
|
315
|
+
this.statusOk = `Пользователь «${this.existingUser.label}» назначен на «${res?.placeLabel || this.trail}».`;
|
|
316
|
+
this.$item.reset?.();
|
|
317
|
+
this.fire('assigned', res);
|
|
318
|
+
} catch (err) {
|
|
319
|
+
this.errorMsg = err?.message || String(err);
|
|
320
|
+
} finally {
|
|
321
|
+
this.busy = false;
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
async createInvite() {
|
|
325
|
+
if (!this.$item || !this.trail || this.busy)
|
|
326
|
+
return;
|
|
327
|
+
this.busy = true;
|
|
328
|
+
this.errorMsg = '';
|
|
329
|
+
this.statusOk = '';
|
|
330
|
+
this.createdResult = null;
|
|
331
|
+
try {
|
|
332
|
+
const res = await this.$item.fetch('invite_create', {}, {
|
|
333
|
+
trail: this.trail,
|
|
334
|
+
channel: this.channel,
|
|
335
|
+
recipient: this.channel === 'link' ? '' : String(this.recipient || '').trim(),
|
|
336
|
+
note: String(this.note || '').trim(),
|
|
337
|
+
origin: location.origin,
|
|
338
|
+
});
|
|
339
|
+
this.createdResult = res;
|
|
340
|
+
await this.reloadInvites();
|
|
341
|
+
} catch (err) {
|
|
342
|
+
this.errorMsg = err?.message || String(err);
|
|
343
|
+
} finally {
|
|
344
|
+
this.busy = false;
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
async revokeInvite(inv) {
|
|
348
|
+
if (!this.$item || !inv?.id)
|
|
349
|
+
return;
|
|
350
|
+
try {
|
|
351
|
+
await this.$item.fetch('invite_revoke', {}, { id: inv.id });
|
|
352
|
+
await this.reloadInvites();
|
|
353
|
+
} catch (err) {
|
|
354
|
+
this.errorMsg = err?.message || String(err);
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
async copyUrl(url) {
|
|
358
|
+
if (!url) return;
|
|
359
|
+
try {
|
|
360
|
+
await navigator.clipboard.writeText(url);
|
|
361
|
+
this.statusOk = 'Ссылка скопирована в буфер обмена.';
|
|
362
|
+
} catch {
|
|
363
|
+
this.statusOk = 'Скопируйте ссылку из поля выше.';
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
openShare(url) {
|
|
367
|
+
if (url) window.open(url, '_blank', 'noopener');
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
@@ -6,15 +6,12 @@ export default {
|
|
|
6
6
|
justify-content: flex-start;
|
|
7
7
|
@apply --horizontal;
|
|
8
8
|
flex-wrap: wrap;
|
|
9
|
-
overflow: hidden;
|
|
10
|
-
|
|
11
9
|
}
|
|
12
10
|
item-node:not(:first-child){
|
|
13
11
|
max-width: 200px;
|
|
14
12
|
}
|
|
15
13
|
div {
|
|
16
14
|
opacity: .9;
|
|
17
|
-
overflow: hidden;
|
|
18
15
|
}
|
|
19
16
|
div:hover {
|
|
20
17
|
opacity: 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.109",
|
|
4
4
|
"description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "sources/work.js",
|
package/sources/client.js
CHANGED
|
@@ -279,6 +279,7 @@ WORK.__bind = function (data, path = '') {
|
|
|
279
279
|
let item = CORE.$item.ITEMS[key];
|
|
280
280
|
if (!item) {
|
|
281
281
|
item = CORE.$item.ITEMS[key] = Reactor.activate(new (CORE[data.type] || CORE.$class)(data));
|
|
282
|
+
WORK._subscribeWsPath?.(item.short || key);
|
|
282
283
|
} else {
|
|
283
284
|
Object.assign(item.DATA ??= {}, data);
|
|
284
285
|
delete item.body;
|
|
@@ -445,6 +446,13 @@ WORK.login = async function(force = false){
|
|
|
445
446
|
let secure = ODA.LocalStorage.create('work-secure');
|
|
446
447
|
let nextCreds = secure.getItem('credentials');
|
|
447
448
|
let nextUid = nextCreds?.uid || '';
|
|
449
|
+
if (!force && WORK._accountDisabled && WORK._disabledUid && WORK._disabledUid === nextUid) {
|
|
450
|
+
return Promise.reject(WORK._loginError || new Error('Учётная запись отключена администратором'));
|
|
451
|
+
}
|
|
452
|
+
if (force || (WORK._disabledUid && WORK._disabledUid !== nextUid)) {
|
|
453
|
+
WORK._accountDisabled = false;
|
|
454
|
+
WORK._disabledUid = '';
|
|
455
|
+
}
|
|
448
456
|
if (!force && window.top && window.top !== window) {
|
|
449
457
|
try {
|
|
450
458
|
if (window.top.WORK?._loginPromise && window.top.WORK?._loginTargetUid === nextUid) {
|
|
@@ -498,6 +506,7 @@ WORK.login = async function(force = false){
|
|
|
498
506
|
const authChanged = !WORK._authNotifiedOnce || prevUid !== uid;
|
|
499
507
|
WORK.uid = uid;
|
|
500
508
|
WORK._accountDisabled = false;
|
|
509
|
+
WORK._disabledUid = '';
|
|
501
510
|
WORK._loginError = null;
|
|
502
511
|
WORK._anonExitSynced = false;
|
|
503
512
|
if (authChanged || !WORK.USER)
|
|
@@ -544,6 +553,7 @@ WORK.login = async function(force = false){
|
|
|
544
553
|
const errText = String(err?.message || err || '');
|
|
545
554
|
if (/отключена администратором|account_disabled/i.test(errText)) {
|
|
546
555
|
WORK._accountDisabled = true;
|
|
556
|
+
WORK._disabledUid = nextUid;
|
|
547
557
|
WORK.uid = '';
|
|
548
558
|
WORK.USER = undefined;
|
|
549
559
|
WORK._loginError = new Error('Учётная запись отключена администратором');
|
|
@@ -780,6 +790,23 @@ WORK.arrayBufferToBase64 = function(buffer) {
|
|
|
780
790
|
|
|
781
791
|
|
|
782
792
|
|
|
793
|
+
WORK._pendingWsPaths = new Set();
|
|
794
|
+
WORK._subscribeWsPath = function (p) {
|
|
795
|
+
if (!p || typeof p !== 'string' || WORK._ws?.readyState !== 1)
|
|
796
|
+
return;
|
|
797
|
+
WORK._pendingWsPaths.add(p);
|
|
798
|
+
if (WORK._subWsTimer)
|
|
799
|
+
return;
|
|
800
|
+
WORK._subWsTimer = setTimeout(() => {
|
|
801
|
+
WORK._subWsTimer = null;
|
|
802
|
+
const list = [...WORK._pendingWsPaths];
|
|
803
|
+
WORK._pendingWsPaths.clear();
|
|
804
|
+
if (list.length && WORK._ws?.readyState === 1) {
|
|
805
|
+
try { WORK._ws.send(JSON.stringify(list)); } catch { /* ignore */ }
|
|
806
|
+
}
|
|
807
|
+
}, 30);
|
|
808
|
+
};
|
|
809
|
+
|
|
783
810
|
class WebSocketEvents {
|
|
784
811
|
id = '';
|
|
785
812
|
constructor() {
|
|
@@ -787,7 +814,7 @@ class WebSocketEvents {
|
|
|
787
814
|
let ws = window.location.protocol === 'http:'?'ws://':'wss://'
|
|
788
815
|
this.socket = new WebSocket(ws + window.location.host + '/ws');
|
|
789
816
|
this.socket.onopen = this.onopen.bind(this.socket);
|
|
790
|
-
this.socket.onclose = this.onclose;
|
|
817
|
+
this.socket.onclose = this.onclose.bind(this.socket);
|
|
791
818
|
this.socket.onerror = this.onerror.bind(this.socket);
|
|
792
819
|
this.socket.onmessage = this.onmessage;
|
|
793
820
|
|
|
@@ -798,12 +825,18 @@ class WebSocketEvents {
|
|
|
798
825
|
}
|
|
799
826
|
onopen(e) {
|
|
800
827
|
WORK._ws = this;
|
|
801
|
-
|
|
828
|
+
const keys = new Set();
|
|
829
|
+
for (const [k, it] of Object.entries(CORE.$item.ITEMS || {})) {
|
|
830
|
+
if (k) keys.add(k);
|
|
831
|
+
if (it?.short) keys.add(it.short);
|
|
832
|
+
}
|
|
833
|
+
this.send(JSON.stringify([...keys]));
|
|
802
834
|
for (const tp of WORK._visibleTasks || []) {
|
|
803
835
|
try { this.send(JSON.stringify({ type: 'task.presence', path: tp, visible: true })); } catch {}
|
|
804
836
|
}
|
|
805
837
|
WORK.connected = true;
|
|
806
|
-
WORK.
|
|
838
|
+
if (!WORK._accountDisabled)
|
|
839
|
+
WORK.login().catch(() => {});
|
|
807
840
|
}
|
|
808
841
|
onclose(e) {
|
|
809
842
|
if (WORK._ws === this)
|
|
@@ -811,7 +844,6 @@ class WebSocketEvents {
|
|
|
811
844
|
WORK.connected = false;
|
|
812
845
|
WORK.wsid = '';
|
|
813
846
|
WORK._loginPromise = null;
|
|
814
|
-
delete this;
|
|
815
847
|
setTimeout(() => {
|
|
816
848
|
new WebSocketEvents();
|
|
817
849
|
}, 3000);
|