odant-work 1.0.107 → 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/chat/$handler/class.js +2 -2
- package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +25 -2
- package/$server/$folder/handlers/pages/form/$handler/class.js +92 -34
- package/$server/$folder/lib/consultant/consultant.js +58 -6
- package/$server/$folder/lib/icon/icon.js +2 -1
- package/$server/$folder/lib/invite/invite.js +370 -0
- package/$server/$folder/lib/node-explorer/node-explorer.js +0 -3
- 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 +63 -5
- package/sources/host/auth-methods.js +398 -27
- package/sources/host/sms.js +351 -0
- package/sources/host/websocket.js +3 -3
- 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/chat-threads.js +15 -0
- package/sources/server/class/security.js +5 -0
- package/sources/server/server.js +31 -0
- package/sources/server/user.js +2 -0
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
|
}, '');
|
|
@@ -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,10 +506,20 @@ 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)
|
|
504
513
|
await WORK.syncAuthUI();
|
|
514
|
+
const ownTreeUser = (WORK.USER?.short && CORE.$item.ITEMS[WORK.USER.short])
|
|
515
|
+
|| Object.values(CORE.$item.ITEMS).find(i => i?.id === uid && i?.DATA?.isUser);
|
|
516
|
+
if (ownTreeUser && WORK.USER?.DATA) {
|
|
517
|
+
Object.assign(ownTreeUser.DATA ??= {}, { online: Boolean(WORK.USER.DATA.online ?? true) });
|
|
518
|
+
Reactor.invalidate(ownTreeUser, 'DATA');
|
|
519
|
+
Reactor.invalidate(ownTreeUser, 'online');
|
|
520
|
+
ownTreeUser.increaseVersion?.();
|
|
521
|
+
ownTreeUser.fire?.('changed', { path: ownTreeUser.short, initiator: uid, online: true });
|
|
522
|
+
}
|
|
505
523
|
await WORK.loadUserSettings?.();
|
|
506
524
|
WORK.refreshChatUnread?.();
|
|
507
525
|
if (authChanged) {
|
|
@@ -535,6 +553,7 @@ WORK.login = async function(force = false){
|
|
|
535
553
|
const errText = String(err?.message || err || '');
|
|
536
554
|
if (/отключена администратором|account_disabled/i.test(errText)) {
|
|
537
555
|
WORK._accountDisabled = true;
|
|
556
|
+
WORK._disabledUid = nextUid;
|
|
538
557
|
WORK.uid = '';
|
|
539
558
|
WORK.USER = undefined;
|
|
540
559
|
WORK._loginError = new Error('Учётная запись отключена администратором');
|
|
@@ -771,6 +790,23 @@ WORK.arrayBufferToBase64 = function(buffer) {
|
|
|
771
790
|
|
|
772
791
|
|
|
773
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
|
+
|
|
774
810
|
class WebSocketEvents {
|
|
775
811
|
id = '';
|
|
776
812
|
constructor() {
|
|
@@ -778,7 +814,7 @@ class WebSocketEvents {
|
|
|
778
814
|
let ws = window.location.protocol === 'http:'?'ws://':'wss://'
|
|
779
815
|
this.socket = new WebSocket(ws + window.location.host + '/ws');
|
|
780
816
|
this.socket.onopen = this.onopen.bind(this.socket);
|
|
781
|
-
this.socket.onclose = this.onclose;
|
|
817
|
+
this.socket.onclose = this.onclose.bind(this.socket);
|
|
782
818
|
this.socket.onerror = this.onerror.bind(this.socket);
|
|
783
819
|
this.socket.onmessage = this.onmessage;
|
|
784
820
|
|
|
@@ -789,12 +825,18 @@ class WebSocketEvents {
|
|
|
789
825
|
}
|
|
790
826
|
onopen(e) {
|
|
791
827
|
WORK._ws = this;
|
|
792
|
-
|
|
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]));
|
|
793
834
|
for (const tp of WORK._visibleTasks || []) {
|
|
794
835
|
try { this.send(JSON.stringify({ type: 'task.presence', path: tp, visible: true })); } catch {}
|
|
795
836
|
}
|
|
796
837
|
WORK.connected = true;
|
|
797
|
-
WORK.
|
|
838
|
+
if (!WORK._accountDisabled)
|
|
839
|
+
WORK.login().catch(() => {});
|
|
798
840
|
}
|
|
799
841
|
onclose(e) {
|
|
800
842
|
if (WORK._ws === this)
|
|
@@ -802,7 +844,6 @@ class WebSocketEvents {
|
|
|
802
844
|
WORK.connected = false;
|
|
803
845
|
WORK.wsid = '';
|
|
804
846
|
WORK._loginPromise = null;
|
|
805
|
-
delete this;
|
|
806
847
|
setTimeout(() => {
|
|
807
848
|
new WebSocketEvents();
|
|
808
849
|
}, 3000);
|
|
@@ -939,6 +980,23 @@ class WebSocketEvents {
|
|
|
939
980
|
// версия — до fire: слушатели changed делают load(), а его URL (и дедуп WORK.fetch) включает версию;
|
|
940
981
|
// старый порядок склеивал reload с висящим прежним запросом и отдавал устаревший JSON
|
|
941
982
|
item.increaseVersion();
|
|
983
|
+
if (item.DATA?.isUser && !item.DATA?.usersContainer) {
|
|
984
|
+
if (typeof data.online === 'boolean') {
|
|
985
|
+
(item.DATA ??= {}).online = data.online;
|
|
986
|
+
Reactor.invalidate(item, 'DATA');
|
|
987
|
+
Reactor.invalidate(item, 'online');
|
|
988
|
+
item.increaseVersion();
|
|
989
|
+
}
|
|
990
|
+
else if (!WORK._roleRefresh.has(item)) {
|
|
991
|
+
WORK._roleRefresh.add(item);
|
|
992
|
+
item.fetch('info').then(() => {
|
|
993
|
+
Reactor.invalidate(item, 'DATA');
|
|
994
|
+
Reactor.invalidate(item, 'online');
|
|
995
|
+
item.increaseVersion();
|
|
996
|
+
item.fire('changed', data);
|
|
997
|
+
}).catch(() => { }).finally(() => WORK._roleRefresh.delete(item));
|
|
998
|
+
}
|
|
999
|
+
}
|
|
942
1000
|
// роли пользователей и флаги безопасности (roleIds, hasSecurity, icon, label) приходят в info:
|
|
943
1001
|
// подтянуть свежие данные и уведомить дерево
|
|
944
1002
|
if (item.DATA?.roleIds && !(item instanceof CORE.$user) && !WORK._roleRefresh.has(item)) {
|