odant-work 1.0.71 → 1.0.73
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/#system/package-manifest.json +30 -27
- package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/calendar.js +1004 -1011
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +51 -23
- package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/class.js +7 -90
- package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/email.js +913 -705
- package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/methods/refresh/$method/class.js +30 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/class.js +10 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/{system/$handler/tabs → search/$handler}/search.js +14 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/system.js +53 -30
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/staff.js +1 -1
- package/$server/$folder/$class/ai/skills/email-mailbox.md +10 -7
- package/$server/$folder/$class/ai/skills/meeting-minutes.md +1 -1
- package/$server/$folder/$file/$eml/triggers/on_save/$trigger/class.js +17 -1
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/voice-ui.js +5 -5
- package/$server/$folder/lib/calendar-form/calendar-form.js +482 -296
- package/$server/$folder/lib/tree/tree.js +1 -1
- package/oda/oda.js +8 -4
- package/package.json +1 -1
- package/sources/client.js +42 -6
- package/sources/host/email-utils.js +25 -1
- package/sources/modules/agent/index.js +3 -1
- package/sources/modules/agent/node-rules.js +60 -3
- package/sources/modules/agent/scheduler.js +7 -0
- package/sources/modules/agent/tools/calendar-mail.js +273 -0
- package/sources/server/access/gateway.js +3 -0
- package/sources/server/chat-threads.js +77 -23
- package/sources/server/class/feed.js +46 -0
- package/sources/server/class/mail-calendar.js +867 -0
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
* - kind = 'group' : тематическая группа людей; хранится в БД контекста создания.
|
|
9
9
|
*/
|
|
10
10
|
import crypto from 'node:crypto';
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
11
13
|
import * as LOGS from './logs.js';
|
|
12
14
|
import * as REFS from './access/refs.js';
|
|
13
15
|
import * as WORKPLACES from './access/workplaces.js';
|
|
14
|
-
import { dataDb, tx } from '../data/db.js';
|
|
16
|
+
import { baseDbFile, dataDb, tx } from '../data/db.js';
|
|
15
17
|
import { DEV_MODE } from '../host/config.js';
|
|
16
18
|
|
|
17
19
|
function notifyChatEvent(uids, payload) {
|
|
@@ -430,6 +432,15 @@ export async function markRead(storage, params = {}) {
|
|
|
430
432
|
if (!part)
|
|
431
433
|
return { ok: false, lastReadId: 0 };
|
|
432
434
|
|
|
435
|
+
const threadRow = db.prepare('SELECT kind, node_path FROM chat_threads WHERE id = ?').get(threadId);
|
|
436
|
+
const kind = threadRow?.kind || kindHint;
|
|
437
|
+
const nodePath = threadRow?.node_path || '';
|
|
438
|
+
let peerId = '';
|
|
439
|
+
if (kind === 'dm' && threadId.startsWith('dm:')) {
|
|
440
|
+
const parts = threadId.slice(3).split('|');
|
|
441
|
+
peerId = parts[0] === uid && parts[1] === uid ? uid : (parts[0] === uid ? parts[1] : parts[0]);
|
|
442
|
+
}
|
|
443
|
+
|
|
433
444
|
const maxRow = db.prepare('SELECT COALESCE(MAX(id), 0) AS max_id FROM chat_messages WHERE thread_id = ?').get(threadId);
|
|
434
445
|
const targetId = params.lastMessageId != null ? Math.min(Number(params.lastMessageId) || 0, Number(maxRow?.max_id) || 0) : (Number(maxRow?.max_id) || 0);
|
|
435
446
|
const nextRead = Math.max(Number(part.last_read_id) || 0, targetId);
|
|
@@ -437,42 +448,85 @@ export async function markRead(storage, params = {}) {
|
|
|
437
448
|
notifyChatEvent([uid], {
|
|
438
449
|
type: 'chat:read',
|
|
439
450
|
threadId,
|
|
451
|
+
kind,
|
|
452
|
+
nodePath,
|
|
453
|
+
peerId,
|
|
440
454
|
uid,
|
|
441
455
|
lastReadId: nextRead,
|
|
442
456
|
});
|
|
443
|
-
return { ok: true, lastReadId: nextRead };
|
|
457
|
+
return { ok: true, lastReadId: nextRead, threadId, kind, nodePath, peerId };
|
|
444
458
|
}
|
|
445
459
|
|
|
446
|
-
/** Сводка непрочитанного для текущего пользователя в БД данного
|
|
460
|
+
/** Сводка непрочитанного для текущего пользователя в БД данного узла/сервера (на $server — включая БД организаций и проектов). */
|
|
447
461
|
export async function unreadSummary(storage, params = {}) {
|
|
448
462
|
const uid = resolveActorUid(storage, params);
|
|
449
463
|
if (!uid)
|
|
450
464
|
return { total: 0, byThread: {}, byNode: {}, byPeer: {} };
|
|
451
|
-
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
465
|
+
|
|
466
|
+
const dbs = [];
|
|
467
|
+
const primaryDb = await dbForThreadStorage(storage, params.kind || '');
|
|
468
|
+
if (primaryDb)
|
|
469
|
+
dbs.push(primaryDb);
|
|
470
|
+
|
|
471
|
+
if (storage?.type === '$server' && !params.kind) {
|
|
472
|
+
const rootDir = rootDirOf();
|
|
473
|
+
for (const container of ['ORGANIZATIONS', 'PROJECTS']) {
|
|
474
|
+
const dir = path.join(rootDir, container);
|
|
475
|
+
if (!fs.existsSync(dir))
|
|
476
|
+
continue;
|
|
477
|
+
try {
|
|
478
|
+
for (const ent of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
479
|
+
if (!ent.isDirectory() || ent.name.startsWith('$'))
|
|
480
|
+
continue;
|
|
481
|
+
const basePath = `/${container}/${ent.name}`;
|
|
482
|
+
const dbFile = baseDbFile(rootDir, basePath);
|
|
483
|
+
if (!fs.existsSync(dbFile))
|
|
484
|
+
continue;
|
|
485
|
+
const baseDb = await dataDb(basePath, rootDir).catch(() => null);
|
|
486
|
+
if (baseDb && !dbs.includes(baseDb))
|
|
487
|
+
dbs.push(baseDb);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
catch { /* ignore unreadable directory */ }
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
459
494
|
const byThread = {};
|
|
460
495
|
const byNode = {};
|
|
461
496
|
const byPeer = {};
|
|
462
497
|
let total = 0;
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
498
|
+
const seenThreads = new Set();
|
|
499
|
+
for (const db of dbs) {
|
|
500
|
+
let rows = [];
|
|
501
|
+
try {
|
|
502
|
+
rows = db.prepare(`
|
|
503
|
+
SELECT t.id, t.kind, t.node_path,
|
|
504
|
+
(SELECT COUNT(*) FROM chat_messages m WHERE m.thread_id = t.id AND m.id > p.last_read_id AND m.sender != ?) AS unread
|
|
505
|
+
FROM chat_threads t
|
|
506
|
+
JOIN chat_participants p ON p.thread_id = t.id
|
|
507
|
+
WHERE p.uid = ?
|
|
508
|
+
`).all(uid, uid);
|
|
470
509
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
510
|
+
catch {
|
|
511
|
+
rows = [];
|
|
512
|
+
}
|
|
513
|
+
for (const r of rows) {
|
|
514
|
+
if (seenThreads.has(r.id))
|
|
515
|
+
continue;
|
|
516
|
+
seenThreads.add(r.id);
|
|
517
|
+
const cnt = Number(r.unread) || 0;
|
|
518
|
+
if (!cnt) continue;
|
|
519
|
+
total += cnt;
|
|
520
|
+
byThread[r.id] = cnt;
|
|
521
|
+
if (r.kind === 'twin' && r.node_path) {
|
|
522
|
+
byNode[r.node_path] = (byNode[r.node_path] || 0) + cnt;
|
|
523
|
+
}
|
|
524
|
+
else if (r.kind === 'dm') {
|
|
525
|
+
const parts = String(r.id).slice(3).split('|');
|
|
526
|
+
const peer = parts[0] === uid && parts[1] === uid ? uid : (parts[0] === uid ? parts[1] : parts[0]);
|
|
527
|
+
if (peer)
|
|
528
|
+
byPeer[peer] = (byPeer[peer] || 0) + cnt;
|
|
529
|
+
}
|
|
476
530
|
}
|
|
477
531
|
}
|
|
478
532
|
return { total, byThread, byNode, byPeer };
|
|
@@ -5,6 +5,7 @@ import * as fs from 'node:fs';
|
|
|
5
5
|
import { FS } from '../index.js';
|
|
6
6
|
import * as LOGS from '../logs.js';
|
|
7
7
|
import * as CHAT from '../chat-threads.js';
|
|
8
|
+
import * as MAILCAL from './mail-calendar.js';
|
|
8
9
|
import * as POLICY from '../access/policy.js';
|
|
9
10
|
import { DEV_MODE } from '../../host/config.js';
|
|
10
11
|
|
|
@@ -223,6 +224,51 @@ export const classFeedMethods = {
|
|
|
223
224
|
return saveNodeProactivity(this, params);
|
|
224
225
|
},
|
|
225
226
|
|
|
227
|
+
/** Публичный список настроенных почтовых ящиков узла (без паролей и секретов). */
|
|
228
|
+
async mail_accounts(params = {}) {
|
|
229
|
+
return MAILCAL.mailAccounts(this, params);
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
/** Список писем узла (.eml) с фильтрацией по папке, поиском и счётчиками непрочитанных. */
|
|
233
|
+
async mail_list(params = {}) {
|
|
234
|
+
return MAILCAL.mailList(this, params);
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
/** Прочитать полное письмо (.eml) с автопометкой прочитанности. */
|
|
238
|
+
async mail_read(params = {}) {
|
|
239
|
+
return MAILCAL.mailRead(this, params);
|
|
240
|
+
},
|
|
241
|
+
|
|
242
|
+
/** Сохранить/обновить черновик письма в папке drafts. */
|
|
243
|
+
async mail_draft_save(params = {}) {
|
|
244
|
+
return MAILCAL.mailDraftSave(this, params);
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
/** Отправить письмо через SMTP-конвейер узла. */
|
|
248
|
+
async mail_send(params = {}) {
|
|
249
|
+
return MAILCAL.mailSend(this, params);
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
/** Изменить состояние письма (read/unread, в корзину, восстановить, удалить). */
|
|
253
|
+
async mail_state(params = {}) {
|
|
254
|
+
return MAILCAL.mailState(this, params);
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
/** Запросить свежие входящие письма с IMAP-сервера узла. */
|
|
258
|
+
async mail_refresh(params = {}) {
|
|
259
|
+
return MAILCAL.mailRefresh(this, params);
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
/** События календаря узла (.ics), включая повторения, задачи и расписания ИИ. */
|
|
263
|
+
async calendar_list(params = {}) {
|
|
264
|
+
return MAILCAL.calendarList(this, params);
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
/** Сохранить, перенести или отменить событие календаря (.ics) + синхронизация участникам. */
|
|
268
|
+
async calendar_save(params = {}) {
|
|
269
|
+
return MAILCAL.calendarSave(this, params);
|
|
270
|
+
},
|
|
271
|
+
|
|
226
272
|
/** @deprecated используй append_log_includes({ entryPath, includePaths }) */
|
|
227
273
|
async appendLogIncludes(entryPath, includePaths = [], params = {}) {
|
|
228
274
|
if (entryPath && typeof entryPath === 'object' && entryPath.entryPath) {
|