@easemob-community/uikit-sdk-websdk5 1.6.1 → 1.6.2
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/dist/adapter/internal-stores/group.d.ts.map +1 -1
- package/dist/domain/__tests__/group-members.test.d.ts +2 -0
- package/dist/domain/__tests__/group-members.test.d.ts.map +1 -0
- package/dist/domain/group-domain.d.ts +1 -0
- package/dist/domain/group-domain.d.ts.map +1 -1
- package/dist/easemob-uikit-sdk-websdk5.js +640 -628
- package/dist/easemob-uikit-sdk-websdk5.umd.cjs +1 -1
- package/dist/event/types.d.ts +1 -0
- package/dist/event/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChatClient as it, isSDKError as Ve, ChatManager as qe, ChatRoomManager as at, UserInfoManager as We, ContactManager as ct, GroupManager as ut, PresenceManager as dt, PushManager as lt } from "easemob-websdk";
|
|
2
|
-
import { log as Ce, customEventPreviewMap as gt, mergeMessagePreviewLabels as Je, MESSAGE_TYPE as
|
|
2
|
+
import { log as Ce, GROUP_MEMBER_ROLE as L, customEventPreviewMap as gt, mergeMessagePreviewLabels as Je, MESSAGE_TYPE as C, resolveMultiBodyPreview as $e, isTextBody as ft, isImageBody as mt, MESSAGE_EXT_KEY as Qe, isVoiceBody as ze, isVideoBody as pt, isFileBody as ht, isLocationBody as vt, isCustomBody as It, isCmdBody as Mt, isCombineBody as Ye, CONVERSATION_TYPE as M, normalizeUserId as E, MESSAGE_STATUS as O, isMultiBody as yt, createLogger as T, toMessageRecord as we, formatConversationPreview as Xe, PRESENCE_STATUS as X, isKickErrorCode as bt, resolveLastMessageText as Ct, isStreamActive as wt, toConversationRecord as _e, NOTICE_EVENT_TYPE as A, SDK_CONTRACT_VERSION as St, normalizeLoginUserId as At } from "@easemob-community/uikit-sdk-contract";
|
|
3
3
|
import { normalizeUserId as rs } from "@easemob-community/uikit-sdk-contract";
|
|
4
4
|
import { markRaw as Ne, computed as me, reactive as Gt } from "vue";
|
|
5
5
|
let ce = null;
|
|
@@ -138,12 +138,12 @@ class _t {
|
|
|
138
138
|
"5.2.0",
|
|
139
139
|
n,
|
|
140
140
|
o,
|
|
141
|
-
"1.6.
|
|
141
|
+
"1.6.2"
|
|
142
142
|
) : Ce(
|
|
143
143
|
"%c[Easemob] SDK version: %s, Adapter version: %s",
|
|
144
144
|
"color: green; font-weight: bold;",
|
|
145
145
|
"5.2.0",
|
|
146
|
-
"1.6.
|
|
146
|
+
"1.6.2"
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
149
|
get chatManager() {
|
|
@@ -246,19 +246,19 @@ function Ot(s) {
|
|
|
246
246
|
e = r, o();
|
|
247
247
|
},
|
|
248
248
|
addContact(r) {
|
|
249
|
-
var c,
|
|
250
|
-
const i = e.findIndex((
|
|
251
|
-
i >= 0 ? e[i] = { ...e[i], ...r } : e.push(r), o(), (
|
|
249
|
+
var c, d;
|
|
250
|
+
const i = e.findIndex((g) => g.userId === r.userId);
|
|
251
|
+
i >= 0 ? e[i] = { ...e[i], ...r } : e.push(r), o(), (d = (c = s()) == null ? void 0 : c.onContactUpdated) == null || d.call(c, r);
|
|
252
252
|
},
|
|
253
253
|
removeContact(r) {
|
|
254
|
-
var c,
|
|
255
|
-
const i = e.find((
|
|
256
|
-
e = e.filter((
|
|
254
|
+
var c, d;
|
|
255
|
+
const i = e.find((g) => g.userId === r);
|
|
256
|
+
e = e.filter((g) => g.userId !== r), i && (o(), (d = (c = s()) == null ? void 0 : c.onContactUpdated) == null || d.call(c, i));
|
|
257
257
|
},
|
|
258
258
|
updateRemark(r, i) {
|
|
259
|
-
var
|
|
259
|
+
var d, g;
|
|
260
260
|
const c = e.findIndex((m) => m.userId === r);
|
|
261
|
-
c < 0 || (e[c] = { ...e[c], remark: i, name: i || e[c].name }, o(), (
|
|
261
|
+
c < 0 || (e[c] = { ...e[c], remark: i, name: i || e[c].name }, o(), (g = (d = s()) == null ? void 0 : d.onContactUpdated) == null || g.call(d, e[c]));
|
|
262
262
|
},
|
|
263
263
|
setBlocklist(r) {
|
|
264
264
|
},
|
|
@@ -270,7 +270,7 @@ function Ot(s) {
|
|
|
270
270
|
t = t.filter((i) => i.id !== r), a();
|
|
271
271
|
},
|
|
272
272
|
updateInviteStatus(r, i) {
|
|
273
|
-
const c = t.findIndex((
|
|
273
|
+
const c = t.findIndex((d) => d.id === r);
|
|
274
274
|
c < 0 || (t[c] = { ...t[c], status: i }, a());
|
|
275
275
|
},
|
|
276
276
|
getContact(r) {
|
|
@@ -316,9 +316,9 @@ function xt(s) {
|
|
|
316
316
|
e = e.filter((c) => c.id !== a), (i = (r = s()) == null ? void 0 : r.onConversationDeleted) == null || i.call(r, a);
|
|
317
317
|
},
|
|
318
318
|
update(a, r) {
|
|
319
|
-
var c,
|
|
320
|
-
const i = e.findIndex((
|
|
321
|
-
i < 0 || (e[i] = { ...e[i], ...r }, o(), (
|
|
319
|
+
var c, d;
|
|
320
|
+
const i = e.findIndex((g) => g.id === a);
|
|
321
|
+
i < 0 || (e[i] = { ...e[i], ...r }, o(), (d = (c = s()) == null ? void 0 : c.onConversationUpdated) == null || d.call(c, { id: a, conversation: r }));
|
|
322
322
|
},
|
|
323
323
|
setConversationList(a) {
|
|
324
324
|
this.setList(a);
|
|
@@ -351,142 +351,153 @@ function xt(s) {
|
|
|
351
351
|
}
|
|
352
352
|
function Pt(s) {
|
|
353
353
|
let e = [];
|
|
354
|
-
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(),
|
|
354
|
+
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Set(), g = !1;
|
|
355
355
|
function m() {
|
|
356
|
-
var
|
|
357
|
-
(
|
|
356
|
+
var u, l;
|
|
357
|
+
(l = (u = s()) == null ? void 0 : u.onGroupChange) == null || l.call(u, e);
|
|
358
|
+
}
|
|
359
|
+
function p(u, l) {
|
|
360
|
+
const f = new Map(u.map((h) => [h.userId, h.role]));
|
|
361
|
+
return l.map((h) => {
|
|
362
|
+
const v = f.get(h.userId);
|
|
363
|
+
return v === L.ADMIN && h.role === L.MEMBER ? { ...h, role: v } : h;
|
|
364
|
+
});
|
|
358
365
|
}
|
|
359
366
|
return {
|
|
360
367
|
get groupList() {
|
|
361
368
|
return e;
|
|
362
369
|
},
|
|
363
370
|
get loaded() {
|
|
364
|
-
return
|
|
365
|
-
},
|
|
366
|
-
setList(g) {
|
|
367
|
-
e = g, m();
|
|
368
|
-
},
|
|
369
|
-
addGroup(g) {
|
|
370
|
-
var l, p;
|
|
371
|
-
const d = e.findIndex((h) => h.groupId === g.groupId);
|
|
372
|
-
d >= 0 ? e[d] = { ...e[d], ...g } : e.push(g), m(), (p = (l = s()) == null ? void 0 : l.onGroupUpdated) == null || p.call(l, g);
|
|
373
|
-
},
|
|
374
|
-
removeGroup(g) {
|
|
375
|
-
var l, p;
|
|
376
|
-
const d = e.find((h) => h.groupId === g);
|
|
377
|
-
e = e.filter((h) => h.groupId !== g), d && (m(), (p = (l = s()) == null ? void 0 : l.onGroupUpdated) == null || p.call(l, d));
|
|
378
|
-
},
|
|
379
|
-
updateGroup(g, d) {
|
|
380
|
-
var p, h;
|
|
381
|
-
const l = e.findIndex((v) => v.groupId === g);
|
|
382
|
-
l < 0 || (e[l] = { ...e[l], ...d }, m(), (h = (p = s()) == null ? void 0 : p.onGroupUpdated) == null || h.call(p, e[l]));
|
|
383
|
-
},
|
|
384
|
-
setGroupMembers(g, d) {
|
|
385
|
-
var l, p;
|
|
386
|
-
t.set(g, d), (p = (l = s()) == null ? void 0 : l.onGroupMembersChanged) == null || p.call(l, { groupId: g, members: d });
|
|
387
|
-
},
|
|
388
|
-
appendGroupMembers(g, d) {
|
|
389
|
-
var v, S;
|
|
390
|
-
const l = t.get(g) ?? [], p = new Map(l.map((C) => [C.userId, C]));
|
|
391
|
-
for (const C of d)
|
|
392
|
-
p.set(C.userId, C);
|
|
393
|
-
const h = Array.from(p.values());
|
|
394
|
-
t.set(g, h), (S = (v = s()) == null ? void 0 : v.onGroupMembersChanged) == null || S.call(v, { groupId: g, members: h });
|
|
395
|
-
},
|
|
396
|
-
removeGroupMembers(g, d) {
|
|
397
|
-
var h, v;
|
|
398
|
-
const l = new Set(d), p = (t.get(g) ?? []).filter((S) => !l.has(S.userId));
|
|
399
|
-
t.set(g, p), (v = (h = s()) == null ? void 0 : h.onGroupMembersChanged) == null || v.call(h, { groupId: g, members: p });
|
|
400
|
-
},
|
|
401
|
-
updateGroupMemberRole(g, d, l) {
|
|
402
|
-
var v, S;
|
|
403
|
-
const p = t.get(g) ?? [], h = p.findIndex((C) => C.userId === d);
|
|
404
|
-
h < 0 || (p[h] = { ...p[h], role: l }, t.set(g, p), (S = (v = s()) == null ? void 0 : v.onGroupMembersChanged) == null || S.call(v, { groupId: g, members: p }));
|
|
405
|
-
},
|
|
406
|
-
setGroupAnnouncement(g, d) {
|
|
407
|
-
var l, p;
|
|
408
|
-
n.set(g, d), (p = (l = s()) == null ? void 0 : l.onGroupAnnouncementChanged) == null || p.call(l, { groupId: g, announcement: d });
|
|
409
|
-
},
|
|
410
|
-
isGroupAdminSynced(g) {
|
|
411
|
-
return u.has(g);
|
|
412
|
-
},
|
|
413
|
-
markGroupAdminSynced(g) {
|
|
414
|
-
u.add(g);
|
|
415
|
-
},
|
|
416
|
-
setGroupMuteList(g, d) {
|
|
417
|
-
o.set(g, d);
|
|
418
|
-
},
|
|
419
|
-
addGroupMuteMembers(g, d) {
|
|
420
|
-
const l = o.get(g) ?? [], p = Array.isArray(d) && d.length > 0 && typeof d[0] == "string" ? d : d.map((h) => h.userId);
|
|
421
|
-
for (const h of p)
|
|
422
|
-
l.some((v) => v.userId === h) || l.push({ userId: h });
|
|
423
|
-
o.set(g, l);
|
|
424
|
-
},
|
|
425
|
-
removeGroupMuteMembers(g, d) {
|
|
426
|
-
const l = new Set(d);
|
|
427
|
-
o.set(g, (o.get(g) ?? []).filter((p) => !l.has(p.userId)));
|
|
428
|
-
},
|
|
429
|
-
setGroupBlocklist(g, d) {
|
|
430
|
-
a.set(g, d);
|
|
431
|
-
},
|
|
432
|
-
addGroupBlocklistMembers(g, d) {
|
|
433
|
-
const l = a.get(g) ?? [];
|
|
434
|
-
for (const p of d)
|
|
435
|
-
l.some((h) => h.userId === p) || l.push({ userId: p });
|
|
436
|
-
a.set(g, l);
|
|
437
|
-
},
|
|
438
|
-
removeGroupBlocklistMembers(g, d) {
|
|
439
|
-
const l = new Set(d);
|
|
440
|
-
a.set(g, (a.get(g) ?? []).filter((p) => !l.has(p.userId)));
|
|
441
|
-
},
|
|
442
|
-
setGroupAllowlist(g, d) {
|
|
443
|
-
r.set(g, d);
|
|
444
|
-
},
|
|
445
|
-
addGroupAllowlistMembers(g, d) {
|
|
446
|
-
const l = r.get(g) ?? [];
|
|
447
|
-
for (const p of d)
|
|
448
|
-
l.some((h) => h.userId === p) || l.push({ userId: p });
|
|
449
|
-
r.set(g, l);
|
|
450
|
-
},
|
|
451
|
-
removeGroupAllowlistMembers(g, d) {
|
|
452
|
-
const l = new Set(d);
|
|
453
|
-
r.set(g, (r.get(g) ?? []).filter((p) => !l.has(p.userId)));
|
|
454
|
-
},
|
|
455
|
-
setGroupList(g) {
|
|
456
|
-
this.setList(g);
|
|
457
|
-
},
|
|
458
|
-
getGroupById(g) {
|
|
459
|
-
return e.find((d) => d.groupId === g);
|
|
460
|
-
},
|
|
461
|
-
incrementMemberCount(g, d) {
|
|
462
|
-
const l = this.getGroupById(g);
|
|
463
|
-
l && this.updateGroup(g, { memberCount: (l.memberCount ?? 0) + d });
|
|
371
|
+
return g;
|
|
464
372
|
},
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
l && this.updateGroup(g, { memberCount: Math.max(0, (l.memberCount ?? 0) - d) });
|
|
373
|
+
setList(u) {
|
|
374
|
+
e = u, m();
|
|
468
375
|
},
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
l.
|
|
376
|
+
addGroup(u) {
|
|
377
|
+
var f, h;
|
|
378
|
+
const l = e.findIndex((v) => v.groupId === u.groupId);
|
|
379
|
+
l >= 0 ? e[l] = { ...e[l], ...u } : e.push(u), m(), (h = (f = s()) == null ? void 0 : f.onGroupUpdated) == null || h.call(f, u);
|
|
472
380
|
},
|
|
473
|
-
|
|
474
|
-
|
|
381
|
+
removeGroup(u) {
|
|
382
|
+
var f, h;
|
|
383
|
+
const l = e.find((v) => v.groupId === u);
|
|
384
|
+
e = e.filter((v) => v.groupId !== u), l && (m(), (h = (f = s()) == null ? void 0 : f.onGroupUpdated) == null || h.call(f, l));
|
|
475
385
|
},
|
|
476
|
-
|
|
477
|
-
|
|
386
|
+
updateGroup(u, l) {
|
|
387
|
+
var h, v;
|
|
388
|
+
const f = e.findIndex((b) => b.groupId === u);
|
|
389
|
+
f < 0 || (e[f] = { ...e[f], ...l }, m(), (v = (h = s()) == null ? void 0 : h.onGroupUpdated) == null || v.call(h, e[f]));
|
|
478
390
|
},
|
|
479
|
-
|
|
480
|
-
|
|
391
|
+
setGroupMembers(u, l) {
|
|
392
|
+
var h, v;
|
|
393
|
+
const f = p(t.get(u) ?? [], l);
|
|
394
|
+
t.set(u, f), (v = (h = s()) == null ? void 0 : h.onGroupMembersChanged) == null || v.call(h, { groupId: u, members: f });
|
|
481
395
|
},
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
396
|
+
getGroupMembers(u) {
|
|
397
|
+
return t.get(u) ?? [];
|
|
398
|
+
},
|
|
399
|
+
appendGroupMembers(u, l) {
|
|
400
|
+
var b, w;
|
|
401
|
+
const f = t.get(u) ?? [], h = new Map(f.map((I) => [I.userId, I]));
|
|
402
|
+
for (const I of p(f, l))
|
|
403
|
+
h.set(I.userId, I);
|
|
404
|
+
const v = Array.from(h.values());
|
|
405
|
+
t.set(u, v), (w = (b = s()) == null ? void 0 : b.onGroupMembersChanged) == null || w.call(b, { groupId: u, members: v });
|
|
406
|
+
},
|
|
407
|
+
removeGroupMembers(u, l) {
|
|
408
|
+
var v, b;
|
|
409
|
+
const f = new Set(l), h = (t.get(u) ?? []).filter((w) => !f.has(w.userId));
|
|
410
|
+
t.set(u, h), (b = (v = s()) == null ? void 0 : v.onGroupMembersChanged) == null || b.call(v, { groupId: u, members: h });
|
|
411
|
+
},
|
|
412
|
+
updateGroupMemberRole(u, l, f) {
|
|
413
|
+
var b, w;
|
|
414
|
+
const h = t.get(u) ?? [], v = h.findIndex((I) => I.userId === l);
|
|
415
|
+
v < 0 || (h[v] = { ...h[v], role: f }, t.set(u, h), (w = (b = s()) == null ? void 0 : b.onGroupMembersChanged) == null || w.call(b, { groupId: u, members: h }));
|
|
416
|
+
},
|
|
417
|
+
setGroupAnnouncement(u, l) {
|
|
418
|
+
var f, h;
|
|
419
|
+
n.set(u, l), (h = (f = s()) == null ? void 0 : f.onGroupAnnouncementChanged) == null || h.call(f, { groupId: u, announcement: l });
|
|
420
|
+
},
|
|
421
|
+
isGroupAdminSynced(u) {
|
|
422
|
+
return d.has(u);
|
|
423
|
+
},
|
|
424
|
+
markGroupAdminSynced(u) {
|
|
425
|
+
d.add(u);
|
|
426
|
+
},
|
|
427
|
+
setGroupMuteList(u, l) {
|
|
428
|
+
o.set(u, l);
|
|
429
|
+
},
|
|
430
|
+
addGroupMuteMembers(u, l) {
|
|
431
|
+
const f = o.get(u) ?? [], h = Array.isArray(l) && l.length > 0 && typeof l[0] == "string" ? l : l.map((v) => v.userId);
|
|
432
|
+
for (const v of h)
|
|
433
|
+
f.some((b) => b.userId === v) || f.push({ userId: v });
|
|
434
|
+
o.set(u, f);
|
|
435
|
+
},
|
|
436
|
+
removeGroupMuteMembers(u, l) {
|
|
437
|
+
const f = new Set(l);
|
|
438
|
+
o.set(u, (o.get(u) ?? []).filter((h) => !f.has(h.userId)));
|
|
439
|
+
},
|
|
440
|
+
setGroupBlocklist(u, l) {
|
|
441
|
+
a.set(u, l);
|
|
442
|
+
},
|
|
443
|
+
addGroupBlocklistMembers(u, l) {
|
|
444
|
+
const f = a.get(u) ?? [];
|
|
445
|
+
for (const h of l)
|
|
446
|
+
f.some((v) => v.userId === h) || f.push({ userId: h });
|
|
447
|
+
a.set(u, f);
|
|
448
|
+
},
|
|
449
|
+
removeGroupBlocklistMembers(u, l) {
|
|
450
|
+
const f = new Set(l);
|
|
451
|
+
a.set(u, (a.get(u) ?? []).filter((h) => !f.has(h.userId)));
|
|
452
|
+
},
|
|
453
|
+
setGroupAllowlist(u, l) {
|
|
454
|
+
r.set(u, l);
|
|
455
|
+
},
|
|
456
|
+
addGroupAllowlistMembers(u, l) {
|
|
457
|
+
const f = r.get(u) ?? [];
|
|
458
|
+
for (const h of l)
|
|
459
|
+
f.some((v) => v.userId === h) || f.push({ userId: h });
|
|
460
|
+
r.set(u, f);
|
|
461
|
+
},
|
|
462
|
+
removeGroupAllowlistMembers(u, l) {
|
|
463
|
+
const f = new Set(l);
|
|
464
|
+
r.set(u, (r.get(u) ?? []).filter((h) => !f.has(h.userId)));
|
|
465
|
+
},
|
|
466
|
+
setGroupList(u) {
|
|
467
|
+
this.setList(u);
|
|
468
|
+
},
|
|
469
|
+
getGroupById(u) {
|
|
470
|
+
return e.find((l) => l.groupId === u);
|
|
471
|
+
},
|
|
472
|
+
incrementMemberCount(u, l) {
|
|
473
|
+
const f = this.getGroupById(u);
|
|
474
|
+
f && this.updateGroup(u, { memberCount: (f.memberCount ?? 0) + l });
|
|
475
|
+
},
|
|
476
|
+
decrementMemberCount(u, l) {
|
|
477
|
+
const f = this.getGroupById(u);
|
|
478
|
+
f && this.updateGroup(u, { memberCount: Math.max(0, (f.memberCount ?? 0) - l) });
|
|
479
|
+
},
|
|
480
|
+
addGroupSharedFile(u, l) {
|
|
481
|
+
const f = i.get(u) ?? [];
|
|
482
|
+
f.push(l), i.set(u, f);
|
|
483
|
+
},
|
|
484
|
+
removeGroupSharedFile(u, l) {
|
|
485
|
+
i.set(u, (i.get(u) ?? []).filter((f) => f.fileId !== l));
|
|
486
|
+
},
|
|
487
|
+
getGroupJoinRequests(u) {
|
|
488
|
+
return c.get(u) ?? [];
|
|
489
|
+
},
|
|
490
|
+
setGroupJoinRequests(u, l) {
|
|
491
|
+
c.set(u, l);
|
|
492
|
+
},
|
|
493
|
+
updateGroupJoinRequest(u, l, f) {
|
|
494
|
+
const v = (c.get(u) ?? []).find(
|
|
495
|
+
(b) => {
|
|
496
|
+
var w;
|
|
497
|
+
return b.applicantId === l || ((w = b.applicant) == null ? void 0 : w.userId) === l;
|
|
487
498
|
}
|
|
488
499
|
);
|
|
489
|
-
|
|
500
|
+
v && (v.status = f);
|
|
490
501
|
}
|
|
491
502
|
};
|
|
492
503
|
}
|
|
@@ -497,183 +508,183 @@ function Bt(s) {
|
|
|
497
508
|
return e.get(i) ?? [];
|
|
498
509
|
}
|
|
499
510
|
function a(i) {
|
|
500
|
-
for (const [c,
|
|
501
|
-
const
|
|
502
|
-
if (
|
|
503
|
-
return { list:
|
|
511
|
+
for (const [c, d] of e) {
|
|
512
|
+
const g = d.findIndex((m) => m.msgServerId === i || m.msgLocalId === i);
|
|
513
|
+
if (g >= 0)
|
|
514
|
+
return { list: d, index: g, conversationId: c };
|
|
504
515
|
}
|
|
505
516
|
return null;
|
|
506
517
|
}
|
|
507
518
|
function r(i) {
|
|
508
|
-
const c = i,
|
|
519
|
+
const c = i, d = e.get(c.conversationId) ?? [], g = d.findIndex(
|
|
509
520
|
(m) => m.msgServerId && m.msgServerId === c.msgServerId
|
|
510
521
|
);
|
|
511
|
-
|
|
522
|
+
g >= 0 ? d[g] = c : d.push(c), d.sort((m, p) => (m.timestamp ?? 0) - (p.timestamp ?? 0)), e.set(c.conversationId, d);
|
|
512
523
|
}
|
|
513
524
|
return {
|
|
514
525
|
getMessages: o,
|
|
515
526
|
addMessage(i) {
|
|
516
|
-
var c,
|
|
517
|
-
r(i), (
|
|
527
|
+
var c, d;
|
|
528
|
+
r(i), (d = (c = s()) == null ? void 0 : c.onMessage) == null || d.call(c, i);
|
|
518
529
|
},
|
|
519
530
|
addSendingMessage(i, c) {
|
|
520
531
|
t.set(i, c);
|
|
521
532
|
},
|
|
522
533
|
replaceWithSent(i, c) {
|
|
523
|
-
var
|
|
524
|
-
t.delete(i), r(c), (
|
|
534
|
+
var d, g;
|
|
535
|
+
t.delete(i), r(c), (g = (d = s()) == null ? void 0 : d.onMessage) == null || g.call(d, c);
|
|
525
536
|
},
|
|
526
537
|
updateUploadProgress(i, c) {
|
|
527
|
-
const
|
|
528
|
-
if (!
|
|
538
|
+
const d = t.get(i);
|
|
539
|
+
if (!d)
|
|
529
540
|
return;
|
|
530
|
-
const
|
|
531
|
-
if (
|
|
532
|
-
const m = { ...
|
|
533
|
-
|
|
541
|
+
const g = a(d.msgLocalId || d.msgServerId || "");
|
|
542
|
+
if (g) {
|
|
543
|
+
const m = { ...g.list[g.index], progress: c };
|
|
544
|
+
g.list[g.index] = m;
|
|
534
545
|
}
|
|
535
546
|
},
|
|
536
547
|
markFailed(i, c) {
|
|
537
|
-
const
|
|
548
|
+
const d = t.get(i);
|
|
538
549
|
t.delete(i);
|
|
539
|
-
const
|
|
540
|
-
if (!
|
|
550
|
+
const g = (d == null ? void 0 : d.msgLocalId) || (d == null ? void 0 : d.msgServerId);
|
|
551
|
+
if (!g)
|
|
541
552
|
return;
|
|
542
|
-
const m = a(
|
|
553
|
+
const m = a(g);
|
|
543
554
|
if (m) {
|
|
544
|
-
const
|
|
545
|
-
m.list[m.index] =
|
|
555
|
+
const p = { ...m.list[m.index], status: "failed", failReason: c };
|
|
556
|
+
m.list[m.index] = p;
|
|
546
557
|
}
|
|
547
558
|
},
|
|
548
559
|
prependMessages(i, c) {
|
|
549
|
-
const
|
|
550
|
-
for (const
|
|
551
|
-
const
|
|
552
|
-
|
|
560
|
+
const d = e.get(i) ?? [], g = /* @__PURE__ */ new Map();
|
|
561
|
+
for (const p of c) {
|
|
562
|
+
const u = p;
|
|
563
|
+
u.msgServerId && g.set(u.msgServerId, u);
|
|
553
564
|
}
|
|
554
|
-
for (const
|
|
555
|
-
|
|
556
|
-
const m = Array.from(
|
|
557
|
-
(
|
|
565
|
+
for (const p of d)
|
|
566
|
+
p.msgServerId && !g.has(p.msgServerId) && g.set(p.msgServerId, p);
|
|
567
|
+
const m = Array.from(g.values()).sort(
|
|
568
|
+
(p, u) => (p.timestamp ?? 0) - (u.timestamp ?? 0)
|
|
558
569
|
);
|
|
559
570
|
e.set(i, m);
|
|
560
571
|
},
|
|
561
572
|
updateStatusByServerId(i, c) {
|
|
562
|
-
var
|
|
563
|
-
const
|
|
564
|
-
|
|
573
|
+
var g, m;
|
|
574
|
+
const d = a(i);
|
|
575
|
+
d && (d.list[d.index] = { ...d.list[d.index], status: c }, (m = (g = s()) == null ? void 0 : g.onMessageStatusChanged) == null || m.call(g, { messageId: i, status: c }));
|
|
565
576
|
},
|
|
566
577
|
recallMessage(i, c) {
|
|
567
|
-
var m,
|
|
568
|
-
const
|
|
569
|
-
if (!
|
|
578
|
+
var m, p;
|
|
579
|
+
const d = a(i);
|
|
580
|
+
if (!d)
|
|
570
581
|
return;
|
|
571
|
-
const
|
|
572
|
-
|
|
582
|
+
const g = d.list[d.index];
|
|
583
|
+
g.recalled = !0, g.recalledBy = c, (p = (m = s()) == null ? void 0 : m.onMessagesRecalled) == null || p.call(m, {
|
|
573
584
|
messageId: i,
|
|
574
|
-
conversationId:
|
|
575
|
-
conversationType:
|
|
585
|
+
conversationId: d.conversationId,
|
|
586
|
+
conversationType: g.conversationType,
|
|
576
587
|
operatorId: c
|
|
577
588
|
});
|
|
578
589
|
},
|
|
579
590
|
updateMessage(i, c) {
|
|
580
|
-
var m,
|
|
581
|
-
const
|
|
582
|
-
if (!
|
|
591
|
+
var m, p;
|
|
592
|
+
const d = a(i);
|
|
593
|
+
if (!d)
|
|
583
594
|
return;
|
|
584
|
-
const
|
|
585
|
-
|
|
595
|
+
const g = c;
|
|
596
|
+
d.list[d.index] = g, g.modified && ((p = (m = s()) == null ? void 0 : m.onMessageUpdated) == null || p.call(m, g));
|
|
586
597
|
},
|
|
587
598
|
setPinnedMessages(i, c) {
|
|
588
599
|
},
|
|
589
600
|
setTranslation(i, c) {
|
|
590
|
-
const
|
|
591
|
-
if (!
|
|
601
|
+
const d = a(i);
|
|
602
|
+
if (!d)
|
|
592
603
|
return;
|
|
593
|
-
const
|
|
594
|
-
|
|
604
|
+
const g = d.list[d.index];
|
|
605
|
+
g.translation = c, g.showTranslation = !0;
|
|
595
606
|
},
|
|
596
607
|
setTranslating(i, c) {
|
|
597
|
-
const
|
|
598
|
-
|
|
608
|
+
const d = a(i);
|
|
609
|
+
d && (d.list[d.index] = { ...d.list[d.index], translating: c });
|
|
599
610
|
},
|
|
600
611
|
setVoiceText(i, c) {
|
|
601
|
-
const
|
|
602
|
-
if (!
|
|
612
|
+
const d = a(i);
|
|
613
|
+
if (!d)
|
|
603
614
|
return;
|
|
604
|
-
const
|
|
605
|
-
|
|
615
|
+
const g = d.list[d.index];
|
|
616
|
+
g.voiceText = c, g.showVoiceText = !0;
|
|
606
617
|
},
|
|
607
618
|
setVoiceTranscribing(i, c) {
|
|
608
|
-
const
|
|
609
|
-
|
|
619
|
+
const d = a(i);
|
|
620
|
+
d && (d.list[d.index] = { ...d.list[d.index], voiceTranscribing: c });
|
|
610
621
|
},
|
|
611
622
|
clearConversationMessages(i) {
|
|
612
623
|
e.delete(i);
|
|
613
624
|
},
|
|
614
625
|
updateMessageById(i, c) {
|
|
615
|
-
var
|
|
616
|
-
const
|
|
617
|
-
if (!
|
|
626
|
+
var p, u, l, f;
|
|
627
|
+
const d = a(i);
|
|
628
|
+
if (!d)
|
|
618
629
|
return;
|
|
619
|
-
const
|
|
620
|
-
|
|
630
|
+
const g = d.list[d.index], m = { ...g, ...c };
|
|
631
|
+
d.list[d.index] = m, (c.modified || c.modifiedInfo) && ((u = (p = s()) == null ? void 0 : p.onMessageUpdated) == null || u.call(p, m)), c.status && c.status !== g.status && ((f = (l = s()) == null ? void 0 : l.onMessageStatusChanged) == null || f.call(l, {
|
|
621
632
|
messageId: i,
|
|
622
633
|
status: c.status
|
|
623
634
|
}));
|
|
624
635
|
},
|
|
625
636
|
replaceMessageById(i, c) {
|
|
626
|
-
var m,
|
|
627
|
-
const
|
|
628
|
-
if (!
|
|
637
|
+
var m, p;
|
|
638
|
+
const d = a(i);
|
|
639
|
+
if (!d)
|
|
629
640
|
return;
|
|
630
|
-
const
|
|
631
|
-
|
|
641
|
+
const g = c;
|
|
642
|
+
d.list[d.index] = g, (p = (m = s()) == null ? void 0 : m.onMessageUpdated) == null || p.call(m, g);
|
|
632
643
|
},
|
|
633
644
|
addAtMeMessage(i, c) {
|
|
634
|
-
var
|
|
635
|
-
(
|
|
645
|
+
var d, g;
|
|
646
|
+
(g = (d = s()) == null ? void 0 : d.onAtMe) == null || g.call(d, { conversationId: i, messageId: c });
|
|
636
647
|
},
|
|
637
648
|
updateMessageStatus(i, c) {
|
|
638
|
-
var
|
|
639
|
-
const
|
|
640
|
-
|
|
649
|
+
var g, m;
|
|
650
|
+
const d = a(i);
|
|
651
|
+
d && (d.list[d.index] = { ...d.list[d.index], status: c }, (m = (g = s()) == null ? void 0 : g.onMessageStatusChanged) == null || m.call(g, { messageId: i, status: c }));
|
|
641
652
|
},
|
|
642
653
|
setMessagePinned(i, c) {
|
|
643
|
-
const
|
|
644
|
-
if (!
|
|
654
|
+
const d = a(i);
|
|
655
|
+
if (!d)
|
|
645
656
|
return;
|
|
646
|
-
const
|
|
647
|
-
|
|
657
|
+
const g = d.list[d.index];
|
|
658
|
+
g.pinned = !0, g.pinTime = c.pinTime, g.pinOperatorId = c.operatorId;
|
|
648
659
|
},
|
|
649
660
|
setMessageUnpinned(i) {
|
|
650
661
|
const c = a(i);
|
|
651
662
|
if (!c)
|
|
652
663
|
return;
|
|
653
|
-
const
|
|
654
|
-
|
|
664
|
+
const d = c.list[c.index];
|
|
665
|
+
d.pinned = !1;
|
|
655
666
|
},
|
|
656
667
|
deleteMessages(i) {
|
|
657
|
-
var
|
|
658
|
-
const c = new Set(i),
|
|
659
|
-
for (const [
|
|
668
|
+
var g, m;
|
|
669
|
+
const c = new Set(i), d = /* @__PURE__ */ new Map();
|
|
670
|
+
for (const [p, u] of e) {
|
|
660
671
|
const l = [];
|
|
661
|
-
for (const
|
|
662
|
-
const h =
|
|
672
|
+
for (const f of u) {
|
|
673
|
+
const h = f.msgServerId || f.msgLocalId;
|
|
663
674
|
if (h && c.has(h)) {
|
|
664
|
-
const v =
|
|
665
|
-
v.push(h),
|
|
675
|
+
const v = d.get(p) ?? [];
|
|
676
|
+
v.push(h), d.set(p, v);
|
|
666
677
|
} else
|
|
667
|
-
l.push(
|
|
678
|
+
l.push(f);
|
|
668
679
|
}
|
|
669
|
-
e.set(
|
|
680
|
+
e.set(p, l);
|
|
670
681
|
}
|
|
671
|
-
for (const [
|
|
672
|
-
(m = (
|
|
682
|
+
for (const [p, u] of d)
|
|
683
|
+
(m = (g = s()) == null ? void 0 : g.onMessagesDeleted) == null || m.call(g, { messageIds: u, conversationId: p });
|
|
673
684
|
},
|
|
674
685
|
setSyncingMessages(i) {
|
|
675
|
-
var c,
|
|
676
|
-
n !== i && (n = i, (
|
|
686
|
+
var c, d;
|
|
687
|
+
n !== i && (n = i, (d = (c = s()) == null ? void 0 : c.onSyncStatus) == null || d.call(c, {
|
|
677
688
|
type: "message",
|
|
678
689
|
status: i ? "syncing" : "success"
|
|
679
690
|
}));
|
|
@@ -702,8 +713,8 @@ function Ht(s) {
|
|
|
702
713
|
let a = !1;
|
|
703
714
|
const r = /* @__PURE__ */ new Map();
|
|
704
715
|
function i() {
|
|
705
|
-
var c,
|
|
706
|
-
(
|
|
716
|
+
var c, d;
|
|
717
|
+
(d = (c = s()) == null ? void 0 : c.onUserInfoChanged) == null || d.call(c, Array.from(e.values()));
|
|
707
718
|
}
|
|
708
719
|
return {
|
|
709
720
|
getUserInfo(c) {
|
|
@@ -713,48 +724,48 @@ function Ht(s) {
|
|
|
713
724
|
e.set(c.userId, c), i();
|
|
714
725
|
},
|
|
715
726
|
setUserInfos(c) {
|
|
716
|
-
for (const
|
|
717
|
-
e.set(
|
|
727
|
+
for (const d of c)
|
|
728
|
+
e.set(d.userId, d);
|
|
718
729
|
i();
|
|
719
730
|
},
|
|
720
|
-
areAttributesFetched(c,
|
|
721
|
-
const
|
|
722
|
-
return
|
|
731
|
+
areAttributesFetched(c, d) {
|
|
732
|
+
const g = r.get(c);
|
|
733
|
+
return g ? d.every((m) => g.has(m)) : !1;
|
|
723
734
|
},
|
|
724
|
-
markFetchedAttributes(c,
|
|
725
|
-
for (const
|
|
726
|
-
const m = r.get(
|
|
727
|
-
for (const
|
|
728
|
-
m.add(
|
|
729
|
-
r.set(
|
|
735
|
+
markFetchedAttributes(c, d) {
|
|
736
|
+
for (const g of c) {
|
|
737
|
+
const m = r.get(g) ?? /* @__PURE__ */ new Set();
|
|
738
|
+
for (const p of d)
|
|
739
|
+
m.add(p);
|
|
740
|
+
r.set(g, m);
|
|
730
741
|
}
|
|
731
742
|
},
|
|
732
743
|
markLoading(c) {
|
|
733
|
-
for (const
|
|
734
|
-
t.add(
|
|
744
|
+
for (const d of c)
|
|
745
|
+
t.add(d);
|
|
735
746
|
},
|
|
736
747
|
markLoaded(c) {
|
|
737
|
-
for (const
|
|
738
|
-
t.delete(
|
|
748
|
+
for (const d of c)
|
|
749
|
+
t.delete(d);
|
|
739
750
|
},
|
|
740
751
|
markFetchFailed(c) {
|
|
741
|
-
for (const
|
|
742
|
-
n.add(
|
|
752
|
+
for (const d of c)
|
|
753
|
+
n.add(d);
|
|
743
754
|
},
|
|
744
755
|
isFetchFailed(c) {
|
|
745
756
|
return n.has(c);
|
|
746
757
|
},
|
|
747
758
|
markSubscribed(c) {
|
|
748
|
-
for (const
|
|
749
|
-
o.add(
|
|
759
|
+
for (const d of c)
|
|
760
|
+
o.add(d);
|
|
750
761
|
},
|
|
751
762
|
markUnsubscribed(c) {
|
|
752
|
-
for (const
|
|
753
|
-
o.delete(
|
|
763
|
+
for (const d of c)
|
|
764
|
+
o.delete(d);
|
|
754
765
|
},
|
|
755
766
|
markSubscribeFailed(c) {
|
|
756
|
-
for (const
|
|
757
|
-
n.add(
|
|
767
|
+
for (const d of c)
|
|
768
|
+
n.add(d);
|
|
758
769
|
},
|
|
759
770
|
isSubscribeFailed(c) {
|
|
760
771
|
return n.has(c);
|
|
@@ -922,7 +933,7 @@ function $t(s) {
|
|
|
922
933
|
// 契约的 needReadReceipt 未透传:domain sendLocation 无此参数(SDK 不支持位置消息回执)
|
|
923
934
|
sendLocation: (n, o, a, r, i, c) => e.sendLocation(n, o, a, r, i, c),
|
|
924
935
|
sendCustom: (n, o, a, r, i) => {
|
|
925
|
-
const c = r ? Object.fromEntries(Object.entries(r).map(([
|
|
936
|
+
const c = r ? Object.fromEntries(Object.entries(r).map(([d, g]) => [d, String(g)])) : void 0;
|
|
926
937
|
return e.sendCustom(n, o, a, c, i);
|
|
927
938
|
},
|
|
928
939
|
sendCmd: (n, o, a, r) => e.sendCmd(n, o, a, r),
|
|
@@ -1038,7 +1049,7 @@ function xe(s, e) {
|
|
|
1038
1049
|
to: s.to || "",
|
|
1039
1050
|
sender: s.sender || { userId: t },
|
|
1040
1051
|
conversationId: s.conversationId || (e == null ? void 0 : e.conversationId) || "",
|
|
1041
|
-
conversationType: s.conversationType || (e == null ? void 0 : e.conversationType) ||
|
|
1052
|
+
conversationType: s.conversationType || (e == null ? void 0 : e.conversationType) || M.SINGLECHAT,
|
|
1042
1053
|
type: s.type || "unknown",
|
|
1043
1054
|
sendStatus: s.sendStatus ?? O.SENT,
|
|
1044
1055
|
ext: s.ext ?? {},
|
|
@@ -1057,7 +1068,7 @@ function zn(s, e, t) {
|
|
|
1057
1068
|
if (n !== void 0)
|
|
1058
1069
|
return n;
|
|
1059
1070
|
const o = Je({ ...Ue, ...e }), { body: a } = s;
|
|
1060
|
-
return s.type ===
|
|
1071
|
+
return s.type === C.MULTI_BODY ? $e(Oe(s), o) : ft(a) ? a.content || "" : mt(a) ? ((r = s.ext) == null ? void 0 : r[Qe.IS_STICKER]) === !0 ? o.sticker : o.image : ze(a) ? o.voice : pt(a) ? o.video : ht(a) ? a.filename || o.file : vt(a) ? o.location : It(a) ? o.custom[a.event || ""] || o.customFallback : Mt(a) ? "[命令]" : Ye(a) ? a.summary || o.combine : "";
|
|
1061
1072
|
}
|
|
1062
1073
|
function Xt(s, e, t, n) {
|
|
1063
1074
|
var i;
|
|
@@ -1068,27 +1079,27 @@ function Xt(s, e, t, n) {
|
|
|
1068
1079
|
return o;
|
|
1069
1080
|
const a = Je({ ...Ue, ...e }), r = Array.isArray(s.body) ? {} : s.body || {};
|
|
1070
1081
|
switch (s.type) {
|
|
1071
|
-
case
|
|
1082
|
+
case C.MULTI_BODY:
|
|
1072
1083
|
return $e(xe(s, n), a);
|
|
1073
|
-
case
|
|
1084
|
+
case C.TEXT:
|
|
1074
1085
|
return r.content || r.summary || "";
|
|
1075
|
-
case
|
|
1086
|
+
case C.IMAGE:
|
|
1076
1087
|
return ((i = s.ext) == null ? void 0 : i[Qe.IS_STICKER]) === !0 ? a.sticker : a.image;
|
|
1077
|
-
case
|
|
1088
|
+
case C.VOICE:
|
|
1078
1089
|
return a.voice;
|
|
1079
|
-
case
|
|
1090
|
+
case C.VIDEO:
|
|
1080
1091
|
return a.video;
|
|
1081
|
-
case
|
|
1092
|
+
case C.FILE:
|
|
1082
1093
|
return r.filename || a.file;
|
|
1083
|
-
case
|
|
1094
|
+
case C.LOCATION:
|
|
1084
1095
|
return a.location;
|
|
1085
|
-
case
|
|
1096
|
+
case C.CUSTOM: {
|
|
1086
1097
|
const c = ke(r);
|
|
1087
1098
|
return a.custom[c] || a.customFallback;
|
|
1088
1099
|
}
|
|
1089
|
-
case
|
|
1100
|
+
case C.CMD:
|
|
1090
1101
|
return "[命令]";
|
|
1091
|
-
case
|
|
1102
|
+
case C.COMBINE:
|
|
1092
1103
|
return r.summary || a.combine;
|
|
1093
1104
|
default: {
|
|
1094
1105
|
const c = ke(r);
|
|
@@ -1100,7 +1111,7 @@ function Yn(s, e, t) {
|
|
|
1100
1111
|
return s.conversationId === e && s.conversationType === t;
|
|
1101
1112
|
}
|
|
1102
1113
|
function Xn(s, e) {
|
|
1103
|
-
return s.conversationType ===
|
|
1114
|
+
return s.conversationType === M.GROUPCHAT || E(s.from) === E(e) ? s.to : s.from;
|
|
1104
1115
|
}
|
|
1105
1116
|
function U(s) {
|
|
1106
1117
|
return Ve(s) ? s.toJSON() : s;
|
|
@@ -1212,7 +1223,7 @@ function Zn(s, e, t) {
|
|
|
1212
1223
|
const o = tn(s), a = nn(o);
|
|
1213
1224
|
return a !== "error.unknown" ? t(a) || t(e) || o : t(n || e) || o || "";
|
|
1214
1225
|
}
|
|
1215
|
-
const he = T("Combine"), ve = T("History"),
|
|
1226
|
+
const he = T("Combine"), ve = T("History"), k = T("MessageDomain"), sn = 150;
|
|
1216
1227
|
function rn(s) {
|
|
1217
1228
|
return new Promise((e) => {
|
|
1218
1229
|
if (typeof document > "u" || typeof URL.createObjectURL != "function") {
|
|
@@ -1240,7 +1251,7 @@ function an(s) {
|
|
|
1240
1251
|
}
|
|
1241
1252
|
}
|
|
1242
1253
|
function se(s) {
|
|
1243
|
-
Promise.resolve().then(s).catch((e) =>
|
|
1254
|
+
Promise.resolve().then(s).catch((e) => k.warn("persistence 钩子执行失败(已忽略):", e));
|
|
1244
1255
|
}
|
|
1245
1256
|
function cn(s, e) {
|
|
1246
1257
|
const t = E(s.from) === E(e);
|
|
@@ -1253,31 +1264,31 @@ function cn(s, e) {
|
|
|
1253
1264
|
}
|
|
1254
1265
|
function un(s, e) {
|
|
1255
1266
|
switch (e.type) {
|
|
1256
|
-
case
|
|
1267
|
+
case C.TEXT: {
|
|
1257
1268
|
const { type: t, ...n } = e;
|
|
1258
1269
|
return s.createTextMessageBody(n);
|
|
1259
1270
|
}
|
|
1260
|
-
case
|
|
1271
|
+
case C.IMAGE: {
|
|
1261
1272
|
const { type: t, ...n } = e;
|
|
1262
1273
|
return s.createImageMessageBody(n);
|
|
1263
1274
|
}
|
|
1264
|
-
case
|
|
1275
|
+
case C.FILE: {
|
|
1265
1276
|
const { type: t, ...n } = e;
|
|
1266
1277
|
return s.createFileMessageBody(n);
|
|
1267
1278
|
}
|
|
1268
|
-
case
|
|
1279
|
+
case C.VOICE: {
|
|
1269
1280
|
const { type: t, ...n } = e;
|
|
1270
1281
|
return s.createVoiceMessageBody(n);
|
|
1271
1282
|
}
|
|
1272
|
-
case
|
|
1283
|
+
case C.VIDEO: {
|
|
1273
1284
|
const { type: t, ...n } = e;
|
|
1274
1285
|
return s.createVideoMessageBody(n);
|
|
1275
1286
|
}
|
|
1276
|
-
case
|
|
1287
|
+
case C.LOCATION: {
|
|
1277
1288
|
const { type: t, ...n } = e;
|
|
1278
1289
|
return s.createLocationMessageBody(n);
|
|
1279
1290
|
}
|
|
1280
|
-
case
|
|
1291
|
+
case C.CUSTOM: {
|
|
1281
1292
|
const { type: t, ...n } = e;
|
|
1282
1293
|
return s.createCustomMessageBody(n);
|
|
1283
1294
|
}
|
|
@@ -1375,7 +1386,7 @@ class dn {
|
|
|
1375
1386
|
return this._send(a);
|
|
1376
1387
|
}
|
|
1377
1388
|
async sendCombine(e, t, n, o, a, r, i) {
|
|
1378
|
-
const c = performance.now(),
|
|
1389
|
+
const c = performance.now(), d = this.client.chatManager.createCombineMessage({
|
|
1379
1390
|
conversationId: e,
|
|
1380
1391
|
conversationType: t,
|
|
1381
1392
|
title: n,
|
|
@@ -1387,7 +1398,7 @@ class dn {
|
|
|
1387
1398
|
return he.info("createCombineMessage done", {
|
|
1388
1399
|
items: r.length,
|
|
1389
1400
|
elapsedMs: Math.round(performance.now() - c)
|
|
1390
|
-
}), this._send(
|
|
1401
|
+
}), this._send(d);
|
|
1391
1402
|
}
|
|
1392
1403
|
async sendMultiBody(e, t, n, o, a) {
|
|
1393
1404
|
const r = n.map((c) => un(this.client.chatManager, c)), i = this.client.chatManager.createMultiBodyMessage({
|
|
@@ -1415,7 +1426,7 @@ class dn {
|
|
|
1415
1426
|
this.failedMultiBodyMessages.clear();
|
|
1416
1427
|
}
|
|
1417
1428
|
async downloadMultiBodyAttachments(e) {
|
|
1418
|
-
if (e.type !==
|
|
1429
|
+
if (e.type !== C.MULTI_BODY)
|
|
1419
1430
|
throw new Error("MULTI_BODY_ATTACHMENT_UNSUPPORTED");
|
|
1420
1431
|
const t = await this.client.chatManager.downloadAttachment({ message: e });
|
|
1421
1432
|
return Array.isArray(t) ? t : [t];
|
|
@@ -1423,10 +1434,10 @@ class dn {
|
|
|
1423
1434
|
/** 通用发送流程 */
|
|
1424
1435
|
async _send(e) {
|
|
1425
1436
|
var i;
|
|
1426
|
-
const t = e.msgLocalId, n = e.type ===
|
|
1427
|
-
if (e.type ===
|
|
1437
|
+
const t = e.msgLocalId, n = e.type === C.COMBINE;
|
|
1438
|
+
if (e.type === C.CMD)
|
|
1428
1439
|
return this.client.chatManager.sendMessage(e);
|
|
1429
|
-
e.requireGroupAck &&
|
|
1440
|
+
e.requireGroupAck && k.info("[GroupAck] 发送消息携带 needReadReceipt", {
|
|
1430
1441
|
conversationId: e.conversationId,
|
|
1431
1442
|
conversationType: e.conversationType,
|
|
1432
1443
|
msgLocalId: e.msgLocalId
|
|
@@ -1437,38 +1448,38 @@ class dn {
|
|
|
1437
1448
|
const c = await this.client.chatManager.sendMessage(e, {
|
|
1438
1449
|
onFileUploadProgress: (m) => {
|
|
1439
1450
|
o += 1;
|
|
1440
|
-
const
|
|
1441
|
-
|
|
1451
|
+
const p = m.percent ?? 0, u = performance.now();
|
|
1452
|
+
p < 100 && u - a < sn || (a = u, this.store.updateUploadProgress(t, p));
|
|
1442
1453
|
}
|
|
1443
1454
|
});
|
|
1444
1455
|
n && he.info("sendMessage done", {
|
|
1445
1456
|
elapsedMs: Math.round(performance.now() - r),
|
|
1446
1457
|
progressEvents: o
|
|
1447
1458
|
});
|
|
1448
|
-
const
|
|
1449
|
-
this.store.replaceWithSent(t,
|
|
1450
|
-
const
|
|
1451
|
-
return
|
|
1459
|
+
const d = P(c, this.currentUserId);
|
|
1460
|
+
this.store.replaceWithSent(t, d);
|
|
1461
|
+
const g = (i = this.options.persistence) == null ? void 0 : i.saveMessage;
|
|
1462
|
+
return g && se(() => g(we(c))), c;
|
|
1452
1463
|
} catch (c) {
|
|
1453
1464
|
n && he.warn("sendMessage failed", {
|
|
1454
1465
|
elapsedMs: Math.round(performance.now() - r),
|
|
1455
1466
|
progressEvents: o,
|
|
1456
1467
|
error: c instanceof Error ? c.message : String(c)
|
|
1457
1468
|
});
|
|
1458
|
-
const
|
|
1459
|
-
throw this.store.markFailed(t,
|
|
1469
|
+
const d = c instanceof Error ? c.message : String(c);
|
|
1470
|
+
throw this.store.markFailed(t, d), c;
|
|
1460
1471
|
}
|
|
1461
1472
|
}
|
|
1462
1473
|
// ===== 历史消息 =====
|
|
1463
1474
|
async fetchHistory(e, t, n, o = 20) {
|
|
1464
|
-
var
|
|
1465
|
-
const a = (
|
|
1475
|
+
var g, m;
|
|
1476
|
+
const a = (g = this.options.messageRepository) == null ? void 0 : g.loadMessages;
|
|
1466
1477
|
if (a) {
|
|
1467
|
-
const
|
|
1468
|
-
return this.store.prependMessages(e,
|
|
1469
|
-
list:
|
|
1470
|
-
cursor:
|
|
1471
|
-
hasMore:
|
|
1478
|
+
const p = await a(e, t, n, o), u = p.list.filter((l) => l.type !== C.CMD).map((l) => cn(l, this.currentUserId));
|
|
1479
|
+
return this.store.prependMessages(e, u), t === M.GROUPCHAT && this.fillGroupReadCounts(u, e), {
|
|
1480
|
+
list: u,
|
|
1481
|
+
cursor: p.cursor,
|
|
1482
|
+
hasMore: p.hasMore
|
|
1472
1483
|
};
|
|
1473
1484
|
}
|
|
1474
1485
|
const r = await this.client.chatManager.getHistoryMessages({
|
|
@@ -1486,12 +1497,12 @@ class dn {
|
|
|
1486
1497
|
count: r.items.length,
|
|
1487
1498
|
cursorReturned: r.cursor,
|
|
1488
1499
|
hasMore: r.hasMore,
|
|
1489
|
-
items: r.items.map((
|
|
1500
|
+
items: r.items.map((p) => `${p.msgServerId || p.msgLocalId}|${p.type}|${p.from}->${p.to}|${p.timestamp}`)
|
|
1490
1501
|
});
|
|
1491
|
-
const i = r.items.filter((
|
|
1502
|
+
const i = r.items.filter((p) => p.type !== C.CMD), c = i.map((p) => P(p, this.currentUserId));
|
|
1492
1503
|
this.store.prependMessages(e, c);
|
|
1493
|
-
const
|
|
1494
|
-
return
|
|
1504
|
+
const d = (m = this.options.persistence) == null ? void 0 : m.saveMessages;
|
|
1505
|
+
return d && i.length > 0 && se(() => d(i.map((p) => we(p)))), t === M.GROUPCHAT && this.fillGroupReadCounts(c, e), {
|
|
1495
1506
|
list: c,
|
|
1496
1507
|
cursor: r.cursor,
|
|
1497
1508
|
hasMore: r.hasMore
|
|
@@ -1524,10 +1535,10 @@ class dn {
|
|
|
1524
1535
|
messageIds: i
|
|
1525
1536
|
});
|
|
1526
1537
|
ve.info("fillGroupReadCounts result", { groupId: t, batch: i, receipts: c });
|
|
1527
|
-
for (const
|
|
1528
|
-
|
|
1538
|
+
for (const d of c)
|
|
1539
|
+
d.count > 0 && this.store.updateMessageById(d.messageId, { groupReadCount: d.count });
|
|
1529
1540
|
} catch (c) {
|
|
1530
|
-
|
|
1541
|
+
k.warn("[MessageDomain.fillGroupReadCounts] failed:", i, U(c));
|
|
1531
1542
|
}
|
|
1532
1543
|
}
|
|
1533
1544
|
}
|
|
@@ -1585,7 +1596,7 @@ class dn {
|
|
|
1585
1596
|
async sendPendingReadReceipts(e, t) {
|
|
1586
1597
|
const o = this.store.getMessages(e).filter((a) => !a.isSelf && !j.has(a.msgServerId)).map((a) => a.msgServerId).filter((a) => !!a);
|
|
1587
1598
|
if (o.length !== 0) {
|
|
1588
|
-
|
|
1599
|
+
k.info("[MessageDomain.sendPendingReadReceipts] 补发已读回执", { conversationId: e, conversationType: t, pendingCount: o.length, messageIds: o.slice(0, 5) });
|
|
1589
1600
|
for (const a of o)
|
|
1590
1601
|
j.add(a);
|
|
1591
1602
|
try {
|
|
@@ -1593,7 +1604,7 @@ class dn {
|
|
|
1593
1604
|
} catch (a) {
|
|
1594
1605
|
for (const r of o)
|
|
1595
1606
|
j.delete(r);
|
|
1596
|
-
|
|
1607
|
+
k.warn("[MessageDomain.sendPendingReadReceipts] failed:", e, U(a));
|
|
1597
1608
|
}
|
|
1598
1609
|
}
|
|
1599
1610
|
}
|
|
@@ -1621,18 +1632,18 @@ class dn {
|
|
|
1621
1632
|
targetLanguages: t
|
|
1622
1633
|
});
|
|
1623
1634
|
} catch (n) {
|
|
1624
|
-
throw
|
|
1635
|
+
throw k.error("[MessageDomain.translateMessage] raw SDK error:", U(n)), n;
|
|
1625
1636
|
}
|
|
1626
1637
|
}
|
|
1627
1638
|
/** 语音消息转文字 */
|
|
1628
1639
|
async transcribeVoiceMessage(e, t) {
|
|
1629
1640
|
if (!ze(e.body))
|
|
1630
|
-
throw
|
|
1641
|
+
throw k.warn("[MessageDomain.transcribeVoiceMessage] not a voice message:", e), new Error("not a voice message");
|
|
1631
1642
|
const n = {
|
|
1632
1643
|
...e.body,
|
|
1633
|
-
type:
|
|
1644
|
+
type: C.VOICE
|
|
1634
1645
|
};
|
|
1635
|
-
return
|
|
1646
|
+
return k.info("voiceMessageToText raw input:", { message: e, body: n, voiceParams: t }), await this.client.chatManager.voiceMessageToText(n, t);
|
|
1636
1647
|
}
|
|
1637
1648
|
/** 下载并解析合并消息 */
|
|
1638
1649
|
async downloadAndParseCombineMessage(e) {
|
|
@@ -1656,15 +1667,15 @@ class dn {
|
|
|
1656
1667
|
}
|
|
1657
1668
|
/** 发送单条消息已读回执 */
|
|
1658
1669
|
async markRead(e, t, n) {
|
|
1659
|
-
|
|
1670
|
+
k.info("[MessageDomain.markRead] 发送单条已读回执", { conversationId: e, conversationType: t, messageId: n });
|
|
1660
1671
|
try {
|
|
1661
1672
|
await this.client.chatManager.sendMessageReadReceipts({
|
|
1662
1673
|
conversationId: e,
|
|
1663
1674
|
conversationType: t,
|
|
1664
1675
|
messageIds: [n]
|
|
1665
|
-
}),
|
|
1676
|
+
}), k.info("[MessageDomain.markRead] 已读回执发送成功", { conversationId: e, conversationType: t, messageId: n });
|
|
1666
1677
|
} catch (o) {
|
|
1667
|
-
throw
|
|
1678
|
+
throw k.warn("[MessageDomain.markRead] 已读回执发送失败", { conversationId: e, conversationType: t, messageId: n, error: U(o) }), o;
|
|
1668
1679
|
}
|
|
1669
1680
|
}
|
|
1670
1681
|
/** 获取群消息已读详情(自动翻页聚合全部已读成员) */
|
|
@@ -1695,7 +1706,7 @@ class dn {
|
|
|
1695
1706
|
conversationType: t,
|
|
1696
1707
|
messageId: n,
|
|
1697
1708
|
message: {
|
|
1698
|
-
type:
|
|
1709
|
+
type: C.TEXT,
|
|
1699
1710
|
body: { content: o },
|
|
1700
1711
|
ext: {}
|
|
1701
1712
|
}
|
|
@@ -1703,16 +1714,16 @@ class dn {
|
|
|
1703
1714
|
}
|
|
1704
1715
|
}
|
|
1705
1716
|
function ln(s, e) {
|
|
1706
|
-
var
|
|
1717
|
+
var d, g, m, p, u, l;
|
|
1707
1718
|
const t = Xt(s.lastMessage, void 0, e == null ? void 0 : e.lastMessageTextResolver, {
|
|
1708
1719
|
conversationId: s.conversationId,
|
|
1709
1720
|
conversationType: s.conversationType
|
|
1710
|
-
}), n = E(((
|
|
1721
|
+
}), n = E(((d = s.lastMessage) == null ? void 0 : d.from) || ""), o = E(((m = (g = s.lastMessage) == null ? void 0 : g.sender) == null ? void 0 : m.userId) || ""), a = o || n, r = a ? (p = e == null ? void 0 : e.resolveSenderName) == null ? void 0 : p.call(e, a) : void 0, i = ((l = (u = s.lastMessage) == null ? void 0 : u.sender) == null ? void 0 : l.nickname) || r || o || n || "", c = Xe(s.conversationType, i, t);
|
|
1711
1722
|
return {
|
|
1712
1723
|
id: s.conversationId,
|
|
1713
1724
|
name: s.conversationName || s.conversationId,
|
|
1714
1725
|
avatar: s.conversationAvatar,
|
|
1715
|
-
type: s.conversationType ===
|
|
1726
|
+
type: s.conversationType === M.GROUPCHAT ? M.GROUPCHAT : M.SINGLECHAT,
|
|
1716
1727
|
unreadCount: s.unreadCount || 0,
|
|
1717
1728
|
lastMessageText: c,
|
|
1718
1729
|
// 保留群聊最后一条消息发送者 userId,供会话列表项在资料异步就绪后重新解析昵称
|
|
@@ -1737,7 +1748,7 @@ function fn(s, e) {
|
|
|
1737
1748
|
const t = {}, n = [];
|
|
1738
1749
|
for (const a of s) {
|
|
1739
1750
|
const r = String(((o = a.lastMessage) == null ? void 0 : o.type) ?? "(null)");
|
|
1740
|
-
t[r] = (t[r] ?? 0) + 1, (r ===
|
|
1751
|
+
t[r] = (t[r] ?? 0) + 1, (r === C.COMBINE || r === "unknown") && n.push({
|
|
1741
1752
|
conversationId: a.conversationId,
|
|
1742
1753
|
lastMessage: a.lastMessage
|
|
1743
1754
|
});
|
|
@@ -1794,17 +1805,17 @@ class pn {
|
|
|
1794
1805
|
const o = [];
|
|
1795
1806
|
let a;
|
|
1796
1807
|
do {
|
|
1797
|
-
const
|
|
1798
|
-
o.push(...
|
|
1808
|
+
const d = await t(a, 50);
|
|
1809
|
+
o.push(...d.list), a = d.hasMore ? d.cursor : void 0;
|
|
1799
1810
|
} while (a);
|
|
1800
|
-
const r = this.store.conversationList ?? [], i = new Map(r.map((
|
|
1801
|
-
for (const
|
|
1802
|
-
const
|
|
1803
|
-
c.set(
|
|
1804
|
-
...
|
|
1805
|
-
name: (!
|
|
1806
|
-
avatar:
|
|
1807
|
-
} :
|
|
1811
|
+
const r = this.store.conversationList ?? [], i = new Map(r.map((d) => [d.id, d])), c = /* @__PURE__ */ new Map();
|
|
1812
|
+
for (const d of o) {
|
|
1813
|
+
const g = i.get(d.id);
|
|
1814
|
+
c.set(d.id, g ? {
|
|
1815
|
+
...d,
|
|
1816
|
+
name: (!d.name || d.name === d.id) && g.name && g.name !== g.id ? g.name : d.name,
|
|
1817
|
+
avatar: d.avatar || g.avatar
|
|
1818
|
+
} : d);
|
|
1808
1819
|
}
|
|
1809
1820
|
this.store.setList(gn(Array.from(c.values())));
|
|
1810
1821
|
return;
|
|
@@ -2117,7 +2128,7 @@ class yn {
|
|
|
2117
2128
|
groupId: n.groupId,
|
|
2118
2129
|
groupName: e.name,
|
|
2119
2130
|
description: e.description,
|
|
2120
|
-
role:
|
|
2131
|
+
role: L.OWNER,
|
|
2121
2132
|
memberCount: (((a = e.memberIds) == null ? void 0 : a.length) ?? 0) + 1,
|
|
2122
2133
|
maxUsers: e.maxMembers,
|
|
2123
2134
|
public: e.public ?? !1,
|
|
@@ -2157,7 +2168,8 @@ class yn {
|
|
|
2157
2168
|
} catch {
|
|
2158
2169
|
}
|
|
2159
2170
|
}
|
|
2160
|
-
|
|
2171
|
+
const r = new Map(this.store.getGroupMembers(e).map((c) => [c.userId, c]));
|
|
2172
|
+
return { list: a.map((c) => r.get(c.userId) ?? c), cursor: o.cursor, hasMore: o.hasMore ?? !1 };
|
|
2161
2173
|
}
|
|
2162
2174
|
/** 拉取并合并群管理员到成员缓存 */
|
|
2163
2175
|
async syncGroupAdmins(e) {
|
|
@@ -2168,14 +2180,14 @@ class yn {
|
|
|
2168
2180
|
if ((a = (o = this.store).isGroupAdminSynced) != null && a.call(o, e))
|
|
2169
2181
|
return;
|
|
2170
2182
|
const n = (async () => {
|
|
2171
|
-
var c,
|
|
2183
|
+
var c, d;
|
|
2172
2184
|
const r = await this.client.groupManager.getGroup(e).getAdmins(), i = Z(
|
|
2173
|
-
(r || []).map((
|
|
2185
|
+
(r || []).map((g) => ({ user: g, role: L.ADMIN }))
|
|
2174
2186
|
);
|
|
2175
2187
|
this.store.appendGroupMembers(e, i);
|
|
2176
|
-
for (const
|
|
2177
|
-
this.store.updateGroupMemberRole(e,
|
|
2178
|
-
(
|
|
2188
|
+
for (const g of i)
|
|
2189
|
+
this.store.updateGroupMemberRole(e, g.userId, L.ADMIN);
|
|
2190
|
+
(d = (c = this.store).markGroupAdminSynced) == null || d.call(c, e);
|
|
2179
2191
|
})();
|
|
2180
2192
|
Me.set(e, n);
|
|
2181
2193
|
try {
|
|
@@ -2218,11 +2230,11 @@ class yn {
|
|
|
2218
2230
|
}
|
|
2219
2231
|
/** 设置群管理员 */
|
|
2220
2232
|
async addGroupAdmin(e, t) {
|
|
2221
|
-
await this.client.groupManager.addGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t,
|
|
2233
|
+
await this.client.groupManager.addGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t, L.ADMIN);
|
|
2222
2234
|
}
|
|
2223
2235
|
/** 取消群管理员 */
|
|
2224
2236
|
async removeGroupAdmin(e, t) {
|
|
2225
|
-
await this.client.groupManager.removeGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t,
|
|
2237
|
+
await this.client.groupManager.removeGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t, L.MEMBER);
|
|
2226
2238
|
}
|
|
2227
2239
|
/** 接受群邀请 */
|
|
2228
2240
|
async acceptGroupInvitation(e) {
|
|
@@ -2634,34 +2646,34 @@ class Cn {
|
|
|
2634
2646
|
});
|
|
2635
2647
|
}
|
|
2636
2648
|
}
|
|
2637
|
-
const
|
|
2649
|
+
const N = T("UIKit:ConnEvents");
|
|
2638
2650
|
function wn(s, e = {}) {
|
|
2639
2651
|
return {
|
|
2640
2652
|
onConnecting: () => {
|
|
2641
|
-
|
|
2653
|
+
N.info("onConnecting"), s.client.setConnecting(!0);
|
|
2642
2654
|
},
|
|
2643
2655
|
onConnected: () => {
|
|
2644
|
-
|
|
2656
|
+
N.info("onConnected"), s.client.setConnected(!0), s.client.setConnecting(!1), s.client.setHasConnectedOnce(!0);
|
|
2645
2657
|
},
|
|
2646
2658
|
onDisconnected: (t) => {
|
|
2647
|
-
|
|
2659
|
+
N.info("onDisconnected", t ? { reason: t.reason, errorCode: t.errorCode } : void 0), s.client.setConnected(!1), s.client.setConnecting(!1), bt(t == null ? void 0 : t.errorCode) && s.client.setKicked(t.errorCode);
|
|
2648
2660
|
},
|
|
2649
2661
|
onReconnectFailed: () => {
|
|
2650
|
-
|
|
2662
|
+
N.info("onReconnectFailed"), s.client.setConnecting(!1), N.error("Auto-reconnect failed after max retries");
|
|
2651
2663
|
},
|
|
2652
2664
|
onTokenWillExpire: () => {
|
|
2653
2665
|
var t;
|
|
2654
|
-
|
|
2666
|
+
N.info("onTokenWillExpire"), N.warn("Token will expire"), (t = e.onTokenWillExpire) == null || t.call(e);
|
|
2655
2667
|
},
|
|
2656
2668
|
onTokenExpired: () => {
|
|
2657
2669
|
var t;
|
|
2658
|
-
|
|
2670
|
+
N.info("onTokenExpired"), N.error("Token expired"), (t = e.onTokenExpired) == null || t.call(e);
|
|
2659
2671
|
},
|
|
2660
2672
|
onOfflineMessageSyncStart: () => {
|
|
2661
|
-
|
|
2673
|
+
N.info("onOfflineMessageSyncStart"), s.conversation.conversationsLoaded || s.message.setSyncingMessages(!0);
|
|
2662
2674
|
},
|
|
2663
2675
|
onOfflineMessageSyncFinish: () => {
|
|
2664
|
-
|
|
2676
|
+
N.info("onOfflineMessageSyncFinish"), s.message.setSyncingMessages(!1);
|
|
2665
2677
|
}
|
|
2666
2678
|
};
|
|
2667
2679
|
}
|
|
@@ -2758,7 +2770,7 @@ function ot(s, e) {
|
|
|
2758
2770
|
return a != null && a.nickname ? a.nickname : a != null && a.remark ? a.remark : t;
|
|
2759
2771
|
}
|
|
2760
2772
|
function Rn(s, e) {
|
|
2761
|
-
var
|
|
2773
|
+
var u;
|
|
2762
2774
|
const { useNotification: t, emitNotificationDelivered: n } = B(), { state: o, notify: a, notifyBrowser: r } = t();
|
|
2763
2775
|
if (!o.value.enabled || E(e.from) === E(s.client.currentUser) || e.conversationId === s.conversation.currentConversationId)
|
|
2764
2776
|
return;
|
|
@@ -2768,37 +2780,37 @@ function Rn(s, e) {
|
|
|
2768
2780
|
const c = typeof document > "u" || document.visibilityState === "hidden";
|
|
2769
2781
|
if (o.value.triggerMode === "background" && !c)
|
|
2770
2782
|
return;
|
|
2771
|
-
const
|
|
2783
|
+
const d = P(e, s.client.currentUser), g = ot(s, d), m = d.conversationType === M.GROUPCHAT, p = {
|
|
2772
2784
|
// 群聊标题为群名(正文含 "发送者: 内容" 前缀),单聊标题为发送者名
|
|
2773
|
-
title: m && (i == null ? void 0 : i.name) ||
|
|
2774
|
-
body: Ct(
|
|
2785
|
+
title: m && (i == null ? void 0 : i.name) || g,
|
|
2786
|
+
body: Ct(d, void 0, g, void 0, Ue),
|
|
2775
2787
|
// 群聊用群头像,单聊用发送者头像
|
|
2776
|
-
avatar: m ? i == null ? void 0 : i.avatar : (
|
|
2777
|
-
timestamp:
|
|
2788
|
+
avatar: m ? i == null ? void 0 : i.avatar : (u = s.userInfo.getUserInfo(e.from)) == null ? void 0 : u.avatarUrl,
|
|
2789
|
+
timestamp: d.timestamp || Date.now(),
|
|
2778
2790
|
conversationId: e.conversationId,
|
|
2779
|
-
conversationType:
|
|
2791
|
+
conversationType: d.conversationType
|
|
2780
2792
|
};
|
|
2781
|
-
c && o.value.browserEnabled ? r(
|
|
2782
|
-
l ? n(
|
|
2783
|
-
}) : o.value.inAppEnabled && (a(
|
|
2793
|
+
c && o.value.browserEnabled ? r(p).then((l) => {
|
|
2794
|
+
l ? n(p, "browser") : o.value.inAppEnabled && (a(p), n(p, "in-app"));
|
|
2795
|
+
}) : o.value.inAppEnabled && (a(p), n(p, "in-app"));
|
|
2784
2796
|
}
|
|
2785
2797
|
function Fe(s, e, t) {
|
|
2786
|
-
const { t: n, useNotification: o, emitNotificationDelivered: a, resolveNoticeUserName: r } = B(), { state: i, notify: c, notifyBrowser:
|
|
2798
|
+
const { t: n, useNotification: o, emitNotificationDelivered: a, resolveNoticeUserName: r } = B(), { state: i, notify: c, notifyBrowser: d } = o();
|
|
2787
2799
|
if (!i.value.enabled)
|
|
2788
2800
|
return;
|
|
2789
|
-
const
|
|
2790
|
-
title: r(
|
|
2801
|
+
const g = s.userInfo.getUserInfo(e), m = {
|
|
2802
|
+
title: r(g) || e,
|
|
2791
2803
|
body: n(t === "declined" ? "contact.inviteDeclinedByPeer" : "chat.notice.contactDeleted"),
|
|
2792
|
-
avatar:
|
|
2804
|
+
avatar: g == null ? void 0 : g.avatarUrl,
|
|
2793
2805
|
timestamp: Date.now(),
|
|
2794
2806
|
conversationId: e,
|
|
2795
|
-
conversationType:
|
|
2807
|
+
conversationType: M.SINGLECHAT
|
|
2796
2808
|
};
|
|
2797
|
-
(typeof document > "u" || document.visibilityState === "hidden") && i.value.browserEnabled ?
|
|
2798
|
-
|
|
2809
|
+
(typeof document > "u" || document.visibilityState === "hidden") && i.value.browserEnabled ? d(m).then((u) => {
|
|
2810
|
+
u ? a(m, "browser") : i.value.inAppEnabled && (c(m), a(m, "in-app"));
|
|
2799
2811
|
}) : i.value.inAppEnabled && (c(m), a(m, "in-app"));
|
|
2800
2812
|
}
|
|
2801
|
-
const
|
|
2813
|
+
const y = T("UIKit:ChatEvents"), le = /* @__PURE__ */ new Set(), Te = /* @__PURE__ */ new Set(), $ = /* @__PURE__ */ new Map();
|
|
2802
2814
|
let ge = !1;
|
|
2803
2815
|
function Un() {
|
|
2804
2816
|
le.clear(), Te.clear(), $.clear(), ge = !1;
|
|
@@ -2812,18 +2824,18 @@ function Ln(s, e, t, n) {
|
|
|
2812
2824
|
const r = Array.from($.entries());
|
|
2813
2825
|
$.clear();
|
|
2814
2826
|
for (const [i, c] of r) {
|
|
2815
|
-
const [
|
|
2827
|
+
const [d, g] = i.split(":");
|
|
2816
2828
|
for (let m = 0; m < c.length; m += 50) {
|
|
2817
|
-
const
|
|
2818
|
-
|
|
2829
|
+
const p = c.slice(m, m + 50);
|
|
2830
|
+
y.info("[queueMessageReadReceipt] 批量发送已读回执", { conversationType: d, conversationId: g, batchSize: p.length, messageIds: p });
|
|
2819
2831
|
try {
|
|
2820
2832
|
await s.chatManager.sendMessageReadReceipts({
|
|
2821
|
-
conversationId:
|
|
2822
|
-
conversationType:
|
|
2823
|
-
messageIds:
|
|
2824
|
-
}), an(
|
|
2825
|
-
} catch (
|
|
2826
|
-
|
|
2833
|
+
conversationId: g,
|
|
2834
|
+
conversationType: d,
|
|
2835
|
+
messageIds: p
|
|
2836
|
+
}), an(p), y.info("[queueMessageReadReceipt] 已读回执发送成功", { conversationType: d, conversationId: g, messageIds: p });
|
|
2837
|
+
} catch (u) {
|
|
2838
|
+
y.warn("[queueMessageReadReceipt] sendMessageReadReceipts failed:", { conversationType: d, conversationId: g, messageIds: p, err: u });
|
|
2827
2839
|
}
|
|
2828
2840
|
}
|
|
2829
2841
|
}
|
|
@@ -2849,17 +2861,17 @@ async function Dn(s, e) {
|
|
|
2849
2861
|
});
|
|
2850
2862
|
}
|
|
2851
2863
|
} catch (o) {
|
|
2852
|
-
|
|
2864
|
+
y.warn("patch conversation mute states failed:", o);
|
|
2853
2865
|
}
|
|
2854
2866
|
}
|
|
2855
2867
|
async function oe(s, e) {
|
|
2856
2868
|
const t = new Map(s.group.groupList.map((o) => [o.groupId, o.groupName])), n = [];
|
|
2857
2869
|
for (const o of s.conversation.conversationList)
|
|
2858
2870
|
if ((!o.name || o.name === o.id) && !Te.has(o.id)) {
|
|
2859
|
-
if (o.type ===
|
|
2871
|
+
if (o.type === M.GROUPCHAT) {
|
|
2860
2872
|
const r = t.get(o.id);
|
|
2861
2873
|
r && r !== o.id ? s.conversation.updateConversation(o.id, { name: r }) : le.has(o.id) || n.push(o.id);
|
|
2862
|
-
} else if (o.type ===
|
|
2874
|
+
} else if (o.type === M.SINGLECHAT) {
|
|
2863
2875
|
const r = s.contact.getContact(o.id), i = s.userInfo.getUserInfo(o.id), c = (r == null ? void 0 : r.remark) || (r == null ? void 0 : r.name) || (i == null ? void 0 : i.nickname);
|
|
2864
2876
|
c && s.conversation.updateConversation(o.id, { name: c });
|
|
2865
2877
|
}
|
|
@@ -2872,7 +2884,7 @@ async function oe(s, e) {
|
|
|
2872
2884
|
for (const r of a)
|
|
2873
2885
|
s.group.updateGroup(r.groupId, r), r.groupName && r.groupName !== r.groupId && s.conversation.updateConversation(r.groupId, { name: r.groupName });
|
|
2874
2886
|
} catch (o) {
|
|
2875
|
-
|
|
2887
|
+
y.warn("fetch missing group names failed:", o);
|
|
2876
2888
|
} finally {
|
|
2877
2889
|
for (const o of n) le.delete(o);
|
|
2878
2890
|
}
|
|
@@ -2887,28 +2899,28 @@ function _n(s, e, t, n) {
|
|
|
2887
2899
|
const r = o[a], i = s.conversation.conversationList.find((m) => m.id === e);
|
|
2888
2900
|
if (!i || i.lastMessageTime && r.timestamp < i.lastMessageTime - 1e3)
|
|
2889
2901
|
return;
|
|
2890
|
-
const
|
|
2902
|
+
const d = t === M.GROUPCHAT ? ot(s, r) : void 0, { t: g } = B();
|
|
2891
2903
|
s.conversation.updateConversation(e, {
|
|
2892
2904
|
lastMessageText: Xe(
|
|
2893
2905
|
t,
|
|
2894
|
-
|
|
2895
|
-
|
|
2906
|
+
d,
|
|
2907
|
+
g("message.recalledPreview")
|
|
2896
2908
|
)
|
|
2897
2909
|
});
|
|
2898
2910
|
}
|
|
2899
2911
|
function x(s) {
|
|
2900
|
-
Promise.resolve().then(s).catch((e) =>
|
|
2912
|
+
Promise.resolve().then(s).catch((e) => y.warn("persistence 钩子执行失败(已忽略):", e));
|
|
2901
2913
|
}
|
|
2902
2914
|
function He(s, e) {
|
|
2903
2915
|
const t = s.conversation.conversationList, n = new Set(e.map((r) => r.id)), o = e.map((r) => {
|
|
2904
|
-
const i = t.find((
|
|
2916
|
+
const i = t.find((g) => g.id === r.id);
|
|
2905
2917
|
if (!i)
|
|
2906
2918
|
return r;
|
|
2907
|
-
const c = (!r.name || r.name === r.id) && i.name && i.name !== i.id,
|
|
2919
|
+
const c = (!r.name || r.name === r.id) && i.name && i.name !== i.id, d = !r.avatar && i.avatar;
|
|
2908
2920
|
return {
|
|
2909
2921
|
...r,
|
|
2910
2922
|
name: c ? i.name : r.name,
|
|
2911
|
-
avatar:
|
|
2923
|
+
avatar: d ? i.avatar : r.avatar,
|
|
2912
2924
|
// SDK 快照不携带的本地字段保留(草稿)
|
|
2913
2925
|
draft: r.draft ?? i.draft,
|
|
2914
2926
|
draftTime: r.draftTime ?? i.draftTime,
|
|
@@ -2921,22 +2933,22 @@ function He(s, e) {
|
|
|
2921
2933
|
return [...o, ...a];
|
|
2922
2934
|
}
|
|
2923
2935
|
function Nn(s, e, t, n, o) {
|
|
2924
|
-
var
|
|
2925
|
-
const a = (
|
|
2936
|
+
var p;
|
|
2937
|
+
const a = (u) => Tn(e, u), {
|
|
2926
2938
|
saveMessage: r,
|
|
2927
2939
|
updateMessageStatus: i,
|
|
2928
2940
|
markMessageRecalled: c,
|
|
2929
|
-
updateMessageContent:
|
|
2930
|
-
deleteMessages:
|
|
2931
|
-
} = (n == null ? void 0 : n.message) ?? {}, m = (
|
|
2941
|
+
updateMessageContent: d,
|
|
2942
|
+
deleteMessages: g
|
|
2943
|
+
} = (n == null ? void 0 : n.message) ?? {}, m = (p = n == null ? void 0 : n.conversation) == null ? void 0 : p.saveConversations;
|
|
2932
2944
|
return {
|
|
2933
|
-
onSyncDataStart: (
|
|
2934
|
-
|
|
2945
|
+
onSyncDataStart: (u) => {
|
|
2946
|
+
y.info("onSyncDataStart", { dataType: u.dataType }), be(u.dataType, { status: "syncing" }), u.dataType === "conversation" && e.conversation.setSyncingConversations(!0);
|
|
2935
2947
|
},
|
|
2936
|
-
onSyncDataFinished: (
|
|
2937
|
-
if (
|
|
2938
|
-
const l =
|
|
2939
|
-
be(
|
|
2948
|
+
onSyncDataFinished: (u) => {
|
|
2949
|
+
if (y.info("onSyncDataFinished", { dataType: u.dataType, status: u.status }), u.status === "failed") {
|
|
2950
|
+
const l = u.error;
|
|
2951
|
+
be(u.dataType, {
|
|
2940
2952
|
status: "failed",
|
|
2941
2953
|
finishedAt: Date.now(),
|
|
2942
2954
|
error: {
|
|
@@ -2944,95 +2956,95 @@ function Nn(s, e, t, n, o) {
|
|
|
2944
2956
|
retryable: l == null ? void 0 : l.retryable,
|
|
2945
2957
|
message: l == null ? void 0 : l.message
|
|
2946
2958
|
}
|
|
2947
|
-
}),
|
|
2948
|
-
dataType:
|
|
2959
|
+
}), y.warn("[ChatEvents] 数据同步失败", {
|
|
2960
|
+
dataType: u.dataType,
|
|
2949
2961
|
stage: l == null ? void 0 : l.stage,
|
|
2950
2962
|
retryable: l == null ? void 0 : l.retryable,
|
|
2951
2963
|
message: l == null ? void 0 : l.message
|
|
2952
|
-
}),
|
|
2953
|
-
|
|
2964
|
+
}), u.dataType === "conversation" && (e.conversation.setSyncingConversations(!1), l != null && l.retryable && s.chatManager.refreshSessionList().catch((f) => {
|
|
2965
|
+
y.warn("[ChatEvents] conversation 同步失败重试未成功:", U(f));
|
|
2954
2966
|
}));
|
|
2955
2967
|
return;
|
|
2956
2968
|
}
|
|
2957
|
-
switch (be(
|
|
2969
|
+
switch (be(u.dataType, { status: "success", finishedAt: Date.now() }), u.dataType) {
|
|
2958
2970
|
case "conversation":
|
|
2959
2971
|
e.conversation.setSyncingConversations(!1);
|
|
2960
2972
|
{
|
|
2961
2973
|
const l = s.chatManager.getConversationList().filter((v) => v.conversationType !== "chatRoom");
|
|
2962
|
-
|
|
2963
|
-
const
|
|
2964
|
-
e.conversation.setConversationList(h),
|
|
2974
|
+
y.info("getConversationList raw (onSyncDataFinished)", l);
|
|
2975
|
+
const f = te(l, { resolveSenderName: a, lastMessageTextResolver: o }), h = He(e, f);
|
|
2976
|
+
e.conversation.setConversationList(h), y.info("conversation 同步回填", { count: h.length }), m && x(() => m(h.map(_e)));
|
|
2965
2977
|
}
|
|
2966
2978
|
e.conversation.setConversationsLoaded(!0), oe(e, s), Dn(e, s);
|
|
2967
2979
|
break;
|
|
2968
2980
|
case "contact":
|
|
2969
2981
|
if (!e.contact.loaded || e.contact.contactList.length === 0) {
|
|
2970
2982
|
const l = s.contactManager.getContacts();
|
|
2971
|
-
e.contact.setContactList(Ge(l)),
|
|
2983
|
+
e.contact.setContactList(Ge(l)), y.info("contact 同步回填", { count: l.length });
|
|
2972
2984
|
} else
|
|
2973
|
-
|
|
2985
|
+
y.info("contact 同步回填跳过(列表已由业务方填充)", { count: e.contact.contactList.length });
|
|
2974
2986
|
oe(e, s);
|
|
2975
2987
|
break;
|
|
2976
2988
|
case "group":
|
|
2977
2989
|
if (!e.group.loaded || e.group.groupList.length === 0) {
|
|
2978
2990
|
const l = s.groupManager.getJoinedGroupList();
|
|
2979
|
-
e.group.setGroupList(fe(l)),
|
|
2991
|
+
e.group.setGroupList(fe(l)), y.info("group 同步回填", { count: l.length });
|
|
2980
2992
|
} else
|
|
2981
|
-
|
|
2993
|
+
y.info("group 同步回填跳过(列表已由业务方填充)", { count: e.group.groupList.length });
|
|
2982
2994
|
oe(e, s);
|
|
2983
2995
|
break;
|
|
2984
2996
|
}
|
|
2985
2997
|
},
|
|
2986
|
-
onConversationListUpdate: (
|
|
2987
|
-
var
|
|
2988
|
-
const l =
|
|
2989
|
-
|
|
2998
|
+
onConversationListUpdate: (u) => {
|
|
2999
|
+
var w;
|
|
3000
|
+
const l = u.items.filter((I) => I.conversationType !== "chatRoom");
|
|
3001
|
+
y.info("onConversationListUpdate", { count: l.length, reset: u.patch.reset, removed: u.patch.removed.length }), y.info("getConversationList raw (onConversationListUpdate)", l);
|
|
2990
3002
|
{
|
|
2991
|
-
const
|
|
3003
|
+
const I = {}, G = [];
|
|
2992
3004
|
for (const q of l) {
|
|
2993
|
-
const R = String(((
|
|
2994
|
-
|
|
3005
|
+
const R = String(((w = q.lastMessage) == null ? void 0 : w.type) ?? "(null)");
|
|
3006
|
+
I[R] = (I[R] ?? 0) + 1, (R === C.COMBINE || R === "unknown") && G.push({ conversationId: q.conversationId, lastMessage: q.lastMessage });
|
|
2995
3007
|
}
|
|
2996
|
-
G.length > 0 &&
|
|
3008
|
+
G.length > 0 && y.info("raw snippets (onConversationListUpdate)", { typeCount: I, suspects: G });
|
|
2997
3009
|
}
|
|
2998
|
-
const
|
|
2999
|
-
if (
|
|
3000
|
-
e.conversation.setConversationList(
|
|
3010
|
+
const f = te(l, { resolveSenderName: a, lastMessageTextResolver: o }), h = He(e, f), v = new Set(u.patch.removed.map((I) => I.conversationId)), b = v.size > 0 ? h.filter((I) => !v.has(I.id)) : h;
|
|
3011
|
+
if (u.patch.reset || u.patch.removed.length > 0)
|
|
3012
|
+
e.conversation.setConversationList(b);
|
|
3001
3013
|
else
|
|
3002
|
-
for (const
|
|
3003
|
-
const G = e.conversation.conversationList.find((q) => q.id ===
|
|
3004
|
-
G ? G !==
|
|
3014
|
+
for (const I of b) {
|
|
3015
|
+
const G = e.conversation.conversationList.find((q) => q.id === I.id);
|
|
3016
|
+
G ? G !== I && e.conversation.updateConversation(I.id, I) : e.conversation.addConversation(I);
|
|
3005
3017
|
}
|
|
3006
|
-
m && x(() => m(
|
|
3018
|
+
m && x(() => m(b.map(_e))), oe(e, s);
|
|
3007
3019
|
},
|
|
3008
|
-
onMessage: (
|
|
3009
|
-
var
|
|
3010
|
-
if (
|
|
3020
|
+
onMessage: (u) => {
|
|
3021
|
+
var b, w, I;
|
|
3022
|
+
if (u.conversationType === "chatRoom")
|
|
3011
3023
|
return;
|
|
3012
|
-
if (
|
|
3013
|
-
const G =
|
|
3014
|
-
|
|
3015
|
-
conversationId:
|
|
3016
|
-
from:
|
|
3024
|
+
if (u.type === C.CMD) {
|
|
3025
|
+
const G = u.body.action;
|
|
3026
|
+
y.info("[CMD received]", {
|
|
3027
|
+
conversationId: u.conversationId,
|
|
3028
|
+
from: u.from,
|
|
3017
3029
|
action: G,
|
|
3018
|
-
ext:
|
|
3019
|
-
}), G === "TypingBegin" && (t == null ? void 0 : t.enableTyping) !== !1 &&
|
|
3030
|
+
ext: u.ext
|
|
3031
|
+
}), G === "TypingBegin" && (t == null ? void 0 : t.enableTyping) !== !1 && u.conversationType === M.SINGLECHAT && E(u.from) !== E(e.client.currentUser) && e.conversation.setTyping(u.conversationId, u.from);
|
|
3020
3032
|
return;
|
|
3021
3033
|
}
|
|
3022
|
-
|
|
3023
|
-
const l = P(
|
|
3024
|
-
|
|
3034
|
+
y.info("onMessage", { conversationId: u.conversationId, from: u.from, type: u.type });
|
|
3035
|
+
const l = P(u, e.client.currentUser), f = e.message.getMessages(u.conversationId).find((G) => G.msgServerId === u.msgServerId);
|
|
3036
|
+
f != null && f.stream && wt(f.stream.status) ? e.message.replaceMessageById(u.msgServerId, l) : e.message.addMessage(l), l.type === C.VOICE && !l.isSelf && ((w = (b = e.message).markVoiceUnplayed) == null || w.call(b, l.msgServerId || l.msgLocalId)), r && x(() => r(we(u)));
|
|
3025
3037
|
const h = e.conversation.currentConversationId, v = typeof document > "u" || document.visibilityState === "visible";
|
|
3026
|
-
if (h &&
|
|
3027
|
-
conversationId:
|
|
3028
|
-
conversationType:
|
|
3038
|
+
if (h && u.conversationId === h && E(u.from) !== E(e.client.currentUser) && v && (s.chatManager.clearConversationUnreadMessageCount({
|
|
3039
|
+
conversationId: u.conversationId,
|
|
3040
|
+
conversationType: u.conversationType
|
|
3029
3041
|
}).catch((G) => {
|
|
3030
|
-
|
|
3031
|
-
}), (t == null ? void 0 : t.enableReadReceipt) !== !1 && (
|
|
3032
|
-
const G = (
|
|
3033
|
-
Array.isArray(G) && G.includes(e.client.currentUser) && (e.conversation.setAtMe(
|
|
3042
|
+
y.warn("[UIKit] auto clearConversationUnreadMessageCount failed:", U(G));
|
|
3043
|
+
}), (t == null ? void 0 : t.enableReadReceipt) !== !1 && (u.conversationType === M.SINGLECHAT || u.conversationType === M.GROUPCHAT) && Ln(s, u.conversationType, u.conversationId, u.msgServerId)), (t == null ? void 0 : t.enableAtMe) !== !1 && u.conversationType === M.GROUPCHAT && E(u.from) !== E(e.client.currentUser)) {
|
|
3044
|
+
const G = (I = u.ext) == null ? void 0 : I.em_at_list;
|
|
3045
|
+
Array.isArray(G) && G.includes(e.client.currentUser) && (e.conversation.setAtMe(u.conversationId, !0), e.message.addAtMeMessage(u.conversationId, l.msgServerId || l.msgLocalId));
|
|
3034
3046
|
}
|
|
3035
|
-
Rn(e,
|
|
3047
|
+
Rn(e, u);
|
|
3036
3048
|
},
|
|
3037
3049
|
/**
|
|
3038
3050
|
* 流式消息(边生成边下发,典型 AI 对话)分片合并。
|
|
@@ -3042,134 +3054,134 @@ function Nn(s, e, t, n, o) {
|
|
|
3042
3054
|
* - `stream` 状态整体挂载到消息上,供渲染层展示传输中光标 / 终态收敛 / 异常提示,
|
|
3043
3055
|
* 也供插件插槽按 `customType` 接管(markdown 等富类型)。
|
|
3044
3056
|
*/
|
|
3045
|
-
onStreamMessage: (
|
|
3046
|
-
if (
|
|
3057
|
+
onStreamMessage: (u) => {
|
|
3058
|
+
if (u.conversationType === "chatRoom")
|
|
3047
3059
|
return;
|
|
3048
|
-
const l =
|
|
3060
|
+
const l = u.stream;
|
|
3049
3061
|
if (!l)
|
|
3050
3062
|
return;
|
|
3051
|
-
|
|
3052
|
-
conversationId:
|
|
3053
|
-
from:
|
|
3054
|
-
msgServerId:
|
|
3063
|
+
y.info("onStreamMessage", {
|
|
3064
|
+
conversationId: u.conversationId,
|
|
3065
|
+
from: u.from,
|
|
3066
|
+
msgServerId: u.msgServerId,
|
|
3055
3067
|
seq: l.seq,
|
|
3056
3068
|
status: l.status,
|
|
3057
3069
|
customType: l.customType
|
|
3058
3070
|
});
|
|
3059
|
-
const
|
|
3060
|
-
if (!
|
|
3071
|
+
const f = u.msgServerId || u.msgLocalId;
|
|
3072
|
+
if (!f)
|
|
3061
3073
|
return;
|
|
3062
|
-
if (!e.message.getMessages(
|
|
3063
|
-
(v) => v.msgServerId ===
|
|
3074
|
+
if (!e.message.getMessages(u.conversationId).some(
|
|
3075
|
+
(v) => v.msgServerId === u.msgServerId || u.msgLocalId !== void 0 && v.msgLocalId === u.msgLocalId
|
|
3064
3076
|
)) {
|
|
3065
|
-
e.message.addMessage(P(
|
|
3077
|
+
e.message.addMessage(P(u, e.client.currentUser));
|
|
3066
3078
|
return;
|
|
3067
3079
|
}
|
|
3068
|
-
e.message.updateMessageById(
|
|
3069
|
-
body: { ...
|
|
3080
|
+
e.message.updateMessageById(f, {
|
|
3081
|
+
body: { ...u.body, content: l.fullText },
|
|
3070
3082
|
stream: { ...l }
|
|
3071
3083
|
});
|
|
3072
3084
|
},
|
|
3073
|
-
onMessageRecalled: (
|
|
3074
|
-
|
|
3085
|
+
onMessageRecalled: (u) => {
|
|
3086
|
+
u.conversationType !== "chatRoom" && (y.info("onMessageRecalled", { messageId: u.messageId }), e.message.recallMessage(u.messageId, e.client.currentUser), c && x(() => c(u.messageId, e.client.currentUser)), _n(
|
|
3075
3087
|
e,
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3088
|
+
u.conversationId,
|
|
3089
|
+
u.conversationType,
|
|
3090
|
+
u.messageId
|
|
3079
3091
|
));
|
|
3080
3092
|
},
|
|
3081
|
-
onMessageDelivered: (
|
|
3082
|
-
|
|
3093
|
+
onMessageDelivered: (u) => {
|
|
3094
|
+
y.info("onMessageDelivered", { messageId: u.messageId }), e.message.updateMessageStatus(u.messageId, O.DELIVERED), i && x(() => i(u.messageId, O.DELIVERED));
|
|
3083
3095
|
},
|
|
3084
|
-
onMessageReadReceipts: (
|
|
3085
|
-
for (const l of
|
|
3086
|
-
if (l.conversationType ===
|
|
3087
|
-
|
|
3096
|
+
onMessageReadReceipts: (u) => {
|
|
3097
|
+
for (const l of u)
|
|
3098
|
+
if (l.conversationType === M.GROUPCHAT) {
|
|
3099
|
+
y.info("onMessageReadReceipts(group)", {
|
|
3088
3100
|
conversationId: l.conversationId,
|
|
3089
|
-
details: l.receiptDetails.map((
|
|
3101
|
+
details: l.receiptDetails.map((f) => ({ messageId: f.messageId, count: f.count }))
|
|
3090
3102
|
});
|
|
3091
|
-
for (const
|
|
3092
|
-
e.message.updateMessageById(
|
|
3103
|
+
for (const f of l.receiptDetails)
|
|
3104
|
+
e.message.updateMessageById(f.messageId, { groupReadCount: f.count });
|
|
3093
3105
|
} else {
|
|
3094
|
-
|
|
3106
|
+
y.info("onMessageReadReceipts(single)", {
|
|
3095
3107
|
conversationId: l.conversationId,
|
|
3096
3108
|
total: l.messageIds.length,
|
|
3097
3109
|
messageIds: l.messageIds.slice(0, 5)
|
|
3098
3110
|
});
|
|
3099
|
-
for (const
|
|
3100
|
-
e.message.updateMessageStatus(
|
|
3111
|
+
for (const f of l.messageIds)
|
|
3112
|
+
e.message.updateMessageStatus(f, O.READ), i && x(() => i(f, O.READ));
|
|
3101
3113
|
}
|
|
3102
3114
|
},
|
|
3103
|
-
onMessageUpdated: (
|
|
3104
|
-
|
|
3105
|
-
body:
|
|
3106
|
-
ext:
|
|
3107
|
-
modifiedInfo:
|
|
3115
|
+
onMessageUpdated: (u) => {
|
|
3116
|
+
u.conversationType !== "chatRoom" && (y.info("onMessageUpdated", { messageId: u.messageId }), e.message.updateMessageById(u.messageId, {
|
|
3117
|
+
body: u.message.body,
|
|
3118
|
+
ext: u.message.ext,
|
|
3119
|
+
modifiedInfo: u.message.modifiedInfo,
|
|
3108
3120
|
modified: !0
|
|
3109
|
-
}),
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3121
|
+
}), d && x(() => d(
|
|
3122
|
+
u.messageId,
|
|
3123
|
+
u.message.body,
|
|
3124
|
+
u.message.ext,
|
|
3125
|
+
u.message.modifiedInfo
|
|
3114
3126
|
)));
|
|
3115
3127
|
},
|
|
3116
|
-
onPinnedMessageChanged: async (
|
|
3117
|
-
if (
|
|
3118
|
-
operatorId:
|
|
3119
|
-
pinTime:
|
|
3120
|
-
}) :
|
|
3128
|
+
onPinnedMessageChanged: async (u) => {
|
|
3129
|
+
if (u.conversationType !== "chatRoom" && (y.info("onPinnedMessageChanged", { conversationId: u.conversationId, operation: u.operation }), !!u.messageId && (u.operation === "pin" ? e.message.setMessagePinned(u.messageId, {
|
|
3130
|
+
operatorId: u.operatorId || "",
|
|
3131
|
+
pinTime: u.pinTime || Date.now()
|
|
3132
|
+
}) : u.operation === "unpin" && e.message.setMessageUnpinned(u.messageId), u.conversationId && u.conversationType)))
|
|
3121
3133
|
try {
|
|
3122
|
-
const
|
|
3123
|
-
conversationId:
|
|
3124
|
-
conversationType:
|
|
3134
|
+
const f = (await s.chatManager.getPinnedMessageList({
|
|
3135
|
+
conversationId: u.conversationId,
|
|
3136
|
+
conversationType: u.conversationType
|
|
3125
3137
|
})).items.map((h) => P(h.message, e.client.currentUser));
|
|
3126
|
-
e.message.setPinnedMessages(
|
|
3138
|
+
e.message.setPinnedMessages(u.conversationId, f);
|
|
3127
3139
|
} catch (l) {
|
|
3128
|
-
|
|
3140
|
+
y.warn("refresh pinned messages failed:", l);
|
|
3129
3141
|
}
|
|
3130
3142
|
},
|
|
3131
|
-
onMultiDeviceConversation: (
|
|
3132
|
-
if (
|
|
3143
|
+
onMultiDeviceConversation: (u) => {
|
|
3144
|
+
if (y.info("onMultiDeviceConversation", { operation: u.operation }), u.operation === "ALL_CONVERSATIONS_UNREAD_MESSAGE_COUNT_CLEARED") {
|
|
3133
3145
|
for (const h of e.conversation.conversationList)
|
|
3134
3146
|
e.conversation.updateUnreadCount(h.id, 0);
|
|
3135
3147
|
return;
|
|
3136
3148
|
}
|
|
3137
|
-
const { operation: l, conversationId:
|
|
3149
|
+
const { operation: l, conversationId: f } = u;
|
|
3138
3150
|
switch (l) {
|
|
3139
3151
|
case "CONVERSATION_DELETED":
|
|
3140
|
-
e.conversation.deleteConversation(
|
|
3152
|
+
e.conversation.deleteConversation(f);
|
|
3141
3153
|
break;
|
|
3142
3154
|
case "CONVERSATION_PINNED":
|
|
3143
|
-
e.conversation.updateConversation(
|
|
3155
|
+
e.conversation.updateConversation(f, { isPinned: !0 });
|
|
3144
3156
|
break;
|
|
3145
3157
|
case "CONVERSATION_UNPINNED":
|
|
3146
|
-
e.conversation.updateConversation(
|
|
3158
|
+
e.conversation.updateConversation(f, { isPinned: !1 });
|
|
3147
3159
|
break;
|
|
3148
3160
|
case "CONVERSATION_UNREAD_MESSAGE_COUNT_CLEARED":
|
|
3149
|
-
e.conversation.updateUnreadCount(
|
|
3161
|
+
e.conversation.updateUnreadCount(f, 0);
|
|
3150
3162
|
break;
|
|
3151
3163
|
case "CONVERSATION_MARK":
|
|
3152
|
-
|
|
3164
|
+
u.mark !== void 0 && e.conversation.updateConversation(f, { marks: [u.mark] });
|
|
3153
3165
|
break;
|
|
3154
3166
|
case "CONVERSATION_MUTE_INFO_CHANGED":
|
|
3155
|
-
|
|
3156
|
-
isMuted:
|
|
3157
|
-
remindType:
|
|
3167
|
+
u.remindType && e.conversation.updateConversation(f, {
|
|
3168
|
+
isMuted: u.remindType === "NONE",
|
|
3169
|
+
remindType: u.remindType
|
|
3158
3170
|
});
|
|
3159
3171
|
break;
|
|
3160
3172
|
default:
|
|
3161
|
-
|
|
3173
|
+
y.warn("onMultiDeviceConversation unhandled:", u);
|
|
3162
3174
|
}
|
|
3163
3175
|
},
|
|
3164
|
-
onMultiDeviceMessageRemoved: (
|
|
3165
|
-
|
|
3166
|
-
const { operation: l, conversationId:
|
|
3167
|
-
if (!(!
|
|
3176
|
+
onMultiDeviceMessageRemoved: (u) => {
|
|
3177
|
+
y.info("onMultiDeviceMessageRemoved", { conversationId: u.conversationId, operation: u.operation, messageIds: u.messageIds });
|
|
3178
|
+
const { operation: l, conversationId: f, messageIds: h, beforeTimestamp: v } = u;
|
|
3179
|
+
if (!(!f || l !== "MESSAGE_REMOVED")) {
|
|
3168
3180
|
if (h && h.length > 0)
|
|
3169
|
-
e.message.deleteMessages([...h]),
|
|
3181
|
+
e.message.deleteMessages([...h]), g && x(() => g([...h]));
|
|
3170
3182
|
else if (v) {
|
|
3171
|
-
const
|
|
3172
|
-
|
|
3183
|
+
const w = e.message.getMessages(f).filter((I) => I.timestamp && I.timestamp < v).map((I) => I.msgServerId || I.msgLocalId).filter((I) => !!I);
|
|
3184
|
+
w.length > 0 && (e.message.deleteMessages(w), g && x(() => g(w)));
|
|
3173
3185
|
}
|
|
3174
3186
|
}
|
|
3175
3187
|
}
|
|
@@ -3213,7 +3225,7 @@ function kn(s) {
|
|
|
3213
3225
|
onContactDeleted: (n) => {
|
|
3214
3226
|
J.info("onContactDeleted", { from: n.from });
|
|
3215
3227
|
const o = n.from;
|
|
3216
|
-
o && (s.contact.removeContact(o), s.contact.removeInvite(o), t(s, o,
|
|
3228
|
+
o && (s.contact.removeContact(o), s.contact.removeInvite(o), t(s, o, M.SINGLECHAT, {
|
|
3217
3229
|
eventType: A.CONTACT_DELETED,
|
|
3218
3230
|
params: {},
|
|
3219
3231
|
defaultText: e("chat.notice.contactDeleted")
|
|
@@ -3222,7 +3234,7 @@ function kn(s) {
|
|
|
3222
3234
|
onContactAdded: (n) => {
|
|
3223
3235
|
J.info("onContactAdded", { from: n.from });
|
|
3224
3236
|
const o = n.from;
|
|
3225
|
-
o && (s.contact.addContact({ userId: o, name: o }), s.contact.removeInvite(o), t(s, o,
|
|
3237
|
+
o && (s.contact.addContact({ userId: o, name: o }), s.contact.removeInvite(o), t(s, o, M.SINGLECHAT, {
|
|
3226
3238
|
eventType: A.CONTACT_ADDED,
|
|
3227
3239
|
params: {},
|
|
3228
3240
|
defaultText: e("chat.notice.contactAdded")
|
|
@@ -3240,7 +3252,7 @@ function kn(s) {
|
|
|
3240
3252
|
}
|
|
3241
3253
|
};
|
|
3242
3254
|
}
|
|
3243
|
-
const
|
|
3255
|
+
const S = T("UIKit:GroupEvents");
|
|
3244
3256
|
function je(s, e = "pending") {
|
|
3245
3257
|
const t = s.groupId, n = "inviter" in s ? s.inviter : void 0, o = "groupName" in s ? s.groupName : void 0;
|
|
3246
3258
|
return {
|
|
@@ -3261,10 +3273,10 @@ function ie(s, e, t, n) {
|
|
|
3261
3273
|
return "";
|
|
3262
3274
|
const r = s[0];
|
|
3263
3275
|
if (s.length === 1) {
|
|
3264
|
-
const
|
|
3265
|
-
return o(t).replace("{name}",
|
|
3276
|
+
const d = r.userId === e ? o("chat.notice.you") : a(r);
|
|
3277
|
+
return o(t).replace("{name}", d);
|
|
3266
3278
|
}
|
|
3267
|
-
const i = s.find((
|
|
3279
|
+
const i = s.find((d) => d.userId !== e), c = a(i || r);
|
|
3268
3280
|
return o(n).replace("{name}", c).replace("{count}", String(s.length));
|
|
3269
3281
|
}
|
|
3270
3282
|
function ae(s, e) {
|
|
@@ -3282,106 +3294,106 @@ function On(s) {
|
|
|
3282
3294
|
}
|
|
3283
3295
|
return {
|
|
3284
3296
|
onInvitationReceived: (r) => {
|
|
3285
|
-
|
|
3297
|
+
S.info("onInvitationReceived raw payload", r);
|
|
3286
3298
|
const i = je(r, a(r.groupId) ? "accepted" : "pending");
|
|
3287
3299
|
s.contact.addInvite(i);
|
|
3288
3300
|
},
|
|
3289
3301
|
onInvitationAccepted: (r) => {
|
|
3290
|
-
|
|
3302
|
+
S.info("onInvitationAccepted raw payload", r), s.contact.updateInviteStatus(r.groupId, "accepted");
|
|
3291
3303
|
},
|
|
3292
3304
|
onInvitationDeclined: (r) => {
|
|
3293
|
-
|
|
3305
|
+
S.info("onInvitationDeclined raw payload", r), s.contact.updateInviteStatus(r.groupId, "declined");
|
|
3294
3306
|
},
|
|
3295
3307
|
onAutoAcceptInvitationFromGroup: (r) => {
|
|
3296
|
-
|
|
3308
|
+
S.info("onAutoAcceptInvitationFromGroup raw payload", r), s.contact.addInvite(je(r, "accepted"));
|
|
3297
3309
|
},
|
|
3298
3310
|
onMembersJoined: (r) => {
|
|
3299
|
-
|
|
3311
|
+
S.info("onMembersJoined raw payload", r);
|
|
3300
3312
|
const i = r.members || [], c = s.client.currentUser;
|
|
3301
3313
|
i.some((m) => m.userId === c) && (s.contact.getInvite(r.groupId) && s.contact.updateInviteStatus(r.groupId, "accepted"), s.group.getGroupById(r.groupId) || s.group.addGroup({ groupId: r.groupId, groupName: r.groupName })), s.group.incrementMemberCount(r.groupId, i.length);
|
|
3302
|
-
const
|
|
3314
|
+
const g = ie(
|
|
3303
3315
|
i,
|
|
3304
3316
|
c || "",
|
|
3305
3317
|
"chat.notice.memberJoined",
|
|
3306
3318
|
"chat.notice.memberJoinedMultiple"
|
|
3307
3319
|
);
|
|
3308
|
-
t(s, r.groupId,
|
|
3320
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
3309
3321
|
eventType: A.MEMBER_JOINED,
|
|
3310
3322
|
params: ae(i, c || ""),
|
|
3311
|
-
defaultText:
|
|
3323
|
+
defaultText: g
|
|
3312
3324
|
});
|
|
3313
3325
|
},
|
|
3314
3326
|
onMembersExited: (r) => {
|
|
3315
3327
|
const i = r.members || [];
|
|
3316
|
-
|
|
3328
|
+
S.info("onMembersExited raw payload", r), s.group.decrementMemberCount(r.groupId, i.length);
|
|
3317
3329
|
const c = ie(
|
|
3318
3330
|
i,
|
|
3319
3331
|
s.client.currentUser || "",
|
|
3320
3332
|
"chat.notice.memberExited",
|
|
3321
3333
|
"chat.notice.memberExitedMultiple"
|
|
3322
3334
|
);
|
|
3323
|
-
t(s, r.groupId,
|
|
3335
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
3324
3336
|
eventType: A.MEMBER_EXITED,
|
|
3325
3337
|
params: ae(i, s.client.currentUser || ""),
|
|
3326
3338
|
defaultText: c
|
|
3327
3339
|
});
|
|
3328
3340
|
},
|
|
3329
3341
|
onGroupInfoChanged: (r) => {
|
|
3330
|
-
|
|
3331
|
-
const i = r.groupInfo ?? r, c = i.name ?? i.groupName,
|
|
3342
|
+
S.info("onGroupInfoChanged raw payload", r);
|
|
3343
|
+
const i = r.groupInfo ?? r, c = i.name ?? i.groupName, d = s.group.getGroupById(r.groupId), g = Le({
|
|
3332
3344
|
...i,
|
|
3333
3345
|
groupId: r.groupId,
|
|
3334
3346
|
name: c,
|
|
3335
3347
|
avatarUrl: i.avatarUrl ?? i.avatar
|
|
3336
|
-
}),
|
|
3337
|
-
s.group.updateGroup(r.groupId,
|
|
3348
|
+
}), p = !!r.groupInfo ? g : Object.fromEntries(Object.entries(g).filter(([, u]) => u !== void 0));
|
|
3349
|
+
s.group.updateGroup(r.groupId, p), c && (d != null && d.groupName) && c !== d.groupName && (t(s, r.groupId, M.GROUPCHAT, {
|
|
3338
3350
|
eventType: A.GROUP_NAME_CHANGED,
|
|
3339
3351
|
params: { name: c },
|
|
3340
3352
|
defaultText: e("chat.notice.groupNameChanged").replace("{name}", c)
|
|
3341
3353
|
}), s.conversation.updateConversation(r.groupId, { name: c }));
|
|
3342
3354
|
},
|
|
3343
3355
|
onOwnerChanged: (r) => {
|
|
3344
|
-
var l,
|
|
3345
|
-
|
|
3346
|
-
const i = (l = s.group.getGroupById(r.groupId)) == null ? void 0 : l.owner, c = (h = (
|
|
3347
|
-
m && (m ===
|
|
3348
|
-
const
|
|
3349
|
-
t(s, r.groupId,
|
|
3356
|
+
var l, f, h, v, b, w;
|
|
3357
|
+
S.info("onOwnerChanged raw payload", r);
|
|
3358
|
+
const i = (l = s.group.getGroupById(r.groupId)) == null ? void 0 : l.owner, c = (h = (f = s.group).getPendingOwnerTransfer) == null ? void 0 : h.call(f, r.groupId), d = c || ((v = r.newOwner) == null ? void 0 : v.userId) || "", g = { owner: d }, m = s.client.currentUser || "";
|
|
3359
|
+
m && (m === d ? g.role = L.OWNER : m === i && (g.role = L.MEMBER)), s.group.updateGroup(r.groupId, g), d && s.group.updateGroupMemberRole(r.groupId, d, L.OWNER), i && i !== d && s.group.updateGroupMemberRole(r.groupId, i, L.MEMBER), c && ((w = (b = s.group).clearPendingOwnerTransfer) == null || w.call(b, r.groupId));
|
|
3360
|
+
const p = d === m ? e("chat.notice.you") : o(r.newOwner), u = e("chat.notice.ownerChanged").replace("{name}", p);
|
|
3361
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
3350
3362
|
eventType: A.OWNER_CHANGED,
|
|
3351
|
-
params: { name:
|
|
3352
|
-
defaultText:
|
|
3363
|
+
params: { name: p, ownerId: d },
|
|
3364
|
+
defaultText: u
|
|
3353
3365
|
});
|
|
3354
3366
|
},
|
|
3355
3367
|
onAdminAdded: (r) => {
|
|
3356
3368
|
var m;
|
|
3357
|
-
|
|
3369
|
+
S.info("onAdminAdded raw payload", r);
|
|
3358
3370
|
const i = (m = r.administrator) == null ? void 0 : m.userId;
|
|
3359
|
-
i && s.group.updateGroupMemberRole(r.groupId, i,
|
|
3360
|
-
const c = s.client.currentUser || "",
|
|
3361
|
-
t(s, r.groupId,
|
|
3371
|
+
i && s.group.updateGroupMemberRole(r.groupId, i, L.ADMIN);
|
|
3372
|
+
const c = s.client.currentUser || "", d = i === c ? e("chat.notice.you") : o(r.administrator), g = e("chat.notice.adminAdded").replace("{name}", d);
|
|
3373
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
3362
3374
|
eventType: A.ADMIN_ADDED,
|
|
3363
|
-
params: { name:
|
|
3364
|
-
defaultText:
|
|
3375
|
+
params: { name: d, userId: i || "" },
|
|
3376
|
+
defaultText: g
|
|
3365
3377
|
});
|
|
3366
3378
|
},
|
|
3367
3379
|
onAdminRemoved: (r) => {
|
|
3368
3380
|
var m;
|
|
3369
|
-
|
|
3381
|
+
S.info("onAdminRemoved raw payload", r);
|
|
3370
3382
|
const i = (m = r.administrator) == null ? void 0 : m.userId;
|
|
3371
|
-
i && s.group.updateGroupMemberRole(r.groupId, i,
|
|
3372
|
-
const c = s.client.currentUser || "",
|
|
3373
|
-
t(s, r.groupId,
|
|
3383
|
+
i && s.group.updateGroupMemberRole(r.groupId, i, L.MEMBER);
|
|
3384
|
+
const c = s.client.currentUser || "", d = i === c ? e("chat.notice.you") : o(r.administrator), g = e("chat.notice.adminRemoved").replace("{name}", d);
|
|
3385
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
3374
3386
|
eventType: A.ADMIN_REMOVED,
|
|
3375
|
-
params: { name:
|
|
3376
|
-
defaultText:
|
|
3387
|
+
params: { name: d, userId: i || "" },
|
|
3388
|
+
defaultText: g
|
|
3377
3389
|
});
|
|
3378
3390
|
},
|
|
3379
3391
|
onUserRemoved: (r) => {
|
|
3380
|
-
|
|
3392
|
+
S.info("onUserRemoved raw payload", r);
|
|
3381
3393
|
const i = e("chat.notice.you");
|
|
3382
3394
|
s.group.removeGroup(r.groupId), s.conversation.deleteConversation(r.groupId), s.message.clearConversationMessages(r.groupId);
|
|
3383
3395
|
const c = e("chat.notice.userRemoved").replace("{name}", i);
|
|
3384
|
-
t(s, r.groupId,
|
|
3396
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
3385
3397
|
eventType: A.USER_REMOVED,
|
|
3386
3398
|
params: { name: i },
|
|
3387
3399
|
defaultText: c
|
|
@@ -3389,56 +3401,56 @@ function On(s) {
|
|
|
3389
3401
|
},
|
|
3390
3402
|
onGroupDestroyed: (r) => {
|
|
3391
3403
|
var i;
|
|
3392
|
-
|
|
3404
|
+
S.info("onGroupDestroyed raw payload", r), s.group.removeGroup(r.groupId), (((i = s.client.client) == null ? void 0 : i.deleteConversationOnGroupDestroyed) ?? !0) && (s.conversation.deleteConversation(r.groupId), s.message.clearConversationMessages(r.groupId)), t(s, r.groupId, M.GROUPCHAT, {
|
|
3393
3405
|
eventType: A.GROUP_DESTROYED,
|
|
3394
3406
|
params: {},
|
|
3395
3407
|
defaultText: e("chat.notice.groupDestroyed")
|
|
3396
3408
|
});
|
|
3397
3409
|
},
|
|
3398
3410
|
onAnnouncementChanged: (r) => {
|
|
3399
|
-
|
|
3411
|
+
S.info("onAnnouncementChanged raw payload", r), s.group.updateGroup(r.groupId, { announcement: r.announcement }), s.group.setGroupAnnouncement(r.groupId, r.announcement), t(s, r.groupId, M.GROUPCHAT, {
|
|
3400
3412
|
eventType: A.ANNOUNCEMENT_CHANGED,
|
|
3401
3413
|
params: { announcement: r.announcement || "" },
|
|
3402
3414
|
defaultText: n(r.announcement)
|
|
3403
3415
|
});
|
|
3404
3416
|
},
|
|
3405
3417
|
onMuteListAdded: (r) => {
|
|
3406
|
-
|
|
3407
|
-
const i = (r.mutes || []).map((
|
|
3408
|
-
userId:
|
|
3418
|
+
S.info("onMuteListAdded raw payload", r);
|
|
3419
|
+
const i = (r.mutes || []).map((g) => ({
|
|
3420
|
+
userId: g.userId,
|
|
3409
3421
|
muteExpire: r.muteExpire
|
|
3410
3422
|
}));
|
|
3411
3423
|
s.group.addGroupMuteMembers(r.groupId, i);
|
|
3412
|
-
const c = (r.mutes || []).map((
|
|
3413
|
-
t(s, r.groupId,
|
|
3424
|
+
const c = (r.mutes || []).map((g) => g.nickname || g.userId || ""), d = c.map((g) => e("group.mutelist.muteNotice").replace("{name}", g)).join("、");
|
|
3425
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
3414
3426
|
eventType: A.MUTE_ADDED,
|
|
3415
3427
|
params: { names: c.join("、"), count: c.length },
|
|
3416
|
-
defaultText:
|
|
3428
|
+
defaultText: d
|
|
3417
3429
|
});
|
|
3418
3430
|
},
|
|
3419
3431
|
onMuteListRemoved: (r) => {
|
|
3420
|
-
|
|
3421
|
-
const i = (r.mutes || []).map((
|
|
3432
|
+
S.info("onMuteListRemoved raw payload", r);
|
|
3433
|
+
const i = (r.mutes || []).map((g) => g.userId);
|
|
3422
3434
|
s.group.removeGroupMuteMembers(r.groupId, i);
|
|
3423
|
-
const c = (r.mutes || []).map((
|
|
3424
|
-
t(s, r.groupId,
|
|
3435
|
+
const c = (r.mutes || []).map((g) => g.nickname || g.userId || ""), d = c.map((g) => e("group.mutelist.unmuteNotice").replace("{name}", g)).join("、");
|
|
3436
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
3425
3437
|
eventType: A.MUTE_REMOVED,
|
|
3426
3438
|
params: { names: c.join("、"), count: c.length },
|
|
3427
|
-
defaultText:
|
|
3439
|
+
defaultText: d
|
|
3428
3440
|
});
|
|
3429
3441
|
},
|
|
3430
3442
|
onAllMemberMuteStateChanged: (r) => {
|
|
3431
|
-
|
|
3443
|
+
S.info("onAllMemberMuteStateChanged raw payload", r), s.group.updateGroup(r.groupId, { mute: r.isMuted });
|
|
3432
3444
|
const i = e(r.isMuted ? "group.mutelist.muteAllNotice" : "group.mutelist.unmuteAllNotice");
|
|
3433
|
-
t(s, r.groupId,
|
|
3445
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
3434
3446
|
eventType: A.ALL_MEMBER_MUTE_CHANGED,
|
|
3435
3447
|
params: { muted: r.isMuted },
|
|
3436
3448
|
defaultText: i
|
|
3437
3449
|
});
|
|
3438
3450
|
},
|
|
3439
3451
|
onAllowListAdded: (r) => {
|
|
3440
|
-
|
|
3441
|
-
const i = (r.allowlist || []).map((
|
|
3452
|
+
S.info("onAllowListAdded raw payload", r);
|
|
3453
|
+
const i = (r.allowlist || []).map((d) => d.userId);
|
|
3442
3454
|
s.group.addGroupAllowlistMembers(r.groupId, i);
|
|
3443
3455
|
const c = ie(
|
|
3444
3456
|
r.allowlist || [],
|
|
@@ -3446,15 +3458,15 @@ function On(s) {
|
|
|
3446
3458
|
"chat.notice.allowlistAdded",
|
|
3447
3459
|
"chat.notice.allowlistAddedMultiple"
|
|
3448
3460
|
);
|
|
3449
|
-
t(s, r.groupId,
|
|
3461
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
3450
3462
|
eventType: A.ALLOWLIST_ADDED,
|
|
3451
3463
|
params: ae(r.allowlist || [], s.client.currentUser || ""),
|
|
3452
3464
|
defaultText: c
|
|
3453
3465
|
});
|
|
3454
3466
|
},
|
|
3455
3467
|
onAllowListRemoved: (r) => {
|
|
3456
|
-
|
|
3457
|
-
const i = (r.allowlist || []).map((
|
|
3468
|
+
S.info("onAllowListRemoved raw payload", r);
|
|
3469
|
+
const i = (r.allowlist || []).map((d) => d.userId);
|
|
3458
3470
|
s.group.removeGroupAllowlistMembers(r.groupId, i);
|
|
3459
3471
|
const c = ie(
|
|
3460
3472
|
r.allowlist || [],
|
|
@@ -3462,36 +3474,36 @@ function On(s) {
|
|
|
3462
3474
|
"chat.notice.allowlistRemoved",
|
|
3463
3475
|
"chat.notice.allowlistRemovedMultiple"
|
|
3464
3476
|
);
|
|
3465
|
-
t(s, r.groupId,
|
|
3477
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
3466
3478
|
eventType: A.ALLOWLIST_REMOVED,
|
|
3467
3479
|
params: ae(r.allowlist || [], s.client.currentUser || ""),
|
|
3468
3480
|
defaultText: c
|
|
3469
3481
|
});
|
|
3470
3482
|
},
|
|
3471
3483
|
onGroupDisabledChanged: (r) => {
|
|
3472
|
-
|
|
3484
|
+
S.info("onGroupDisabledChanged raw payload", r), s.group.updateGroup(r.groupId, { disabled: r.disabled }), t(s, r.groupId, M.GROUPCHAT, {
|
|
3473
3485
|
eventType: A.GROUP_DISABLED_CHANGED,
|
|
3474
3486
|
params: { disabled: r.disabled },
|
|
3475
3487
|
defaultText: e(r.disabled ? "chat.notice.groupDisabled" : "chat.notice.groupEnabled")
|
|
3476
3488
|
});
|
|
3477
3489
|
},
|
|
3478
3490
|
onSharedFileAdded: (r) => {
|
|
3479
|
-
if (
|
|
3491
|
+
if (S.info("onSharedFileAdded raw payload", r), r.sharedFile) {
|
|
3480
3492
|
s.group.addGroupSharedFile(r.groupId, r.sharedFile);
|
|
3481
|
-
const i = r.sharedFile.fileOwner, c = (i == null ? void 0 : i.userId) === s.client.currentUser ? e("chat.notice.you") : o(i),
|
|
3482
|
-
t(s, r.groupId,
|
|
3493
|
+
const i = r.sharedFile.fileOwner, c = (i == null ? void 0 : i.userId) === s.client.currentUser ? e("chat.notice.you") : o(i), d = e("chat.notice.sharedFileAdded").replace("{name}", c || (i == null ? void 0 : i.userId) || "").replace("{fileName}", r.sharedFile.fileName);
|
|
3494
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
3483
3495
|
eventType: A.SHARED_FILE_ADDED,
|
|
3484
3496
|
params: { name: c || (i == null ? void 0 : i.userId) || "", fileName: r.sharedFile.fileName },
|
|
3485
|
-
defaultText:
|
|
3497
|
+
defaultText: d
|
|
3486
3498
|
});
|
|
3487
3499
|
}
|
|
3488
3500
|
},
|
|
3489
3501
|
onSharedFileDeleted: (r) => {
|
|
3490
|
-
|
|
3502
|
+
S.info("onSharedFileDeleted raw payload", r), s.group.removeGroupSharedFile(r.groupId, r.fileId);
|
|
3491
3503
|
},
|
|
3492
3504
|
onRequestToJoinReceived: (r) => {
|
|
3493
3505
|
var c;
|
|
3494
|
-
|
|
3506
|
+
S.info("onRequestToJoinReceived raw payload", r);
|
|
3495
3507
|
const i = s.group.getGroupJoinRequests(r.groupId);
|
|
3496
3508
|
s.group.setGroupJoinRequests(r.groupId, [
|
|
3497
3509
|
...i,
|
|
@@ -3508,16 +3520,16 @@ function On(s) {
|
|
|
3508
3520
|
]);
|
|
3509
3521
|
},
|
|
3510
3522
|
onRequestToJoinAccepted: (r) => {
|
|
3511
|
-
|
|
3512
|
-
const i = s.client.currentUser, c = s.group.getGroupJoinRequests(r.groupId).filter((
|
|
3513
|
-
var
|
|
3514
|
-
return !(
|
|
3523
|
+
S.info("onRequestToJoinAccepted raw payload", r);
|
|
3524
|
+
const i = s.client.currentUser, c = s.group.getGroupJoinRequests(r.groupId).filter((d) => {
|
|
3525
|
+
var g;
|
|
3526
|
+
return !(d.status === "pending" && (d.applicantId === i || ((g = d.applicant) == null ? void 0 : g.userId) === i));
|
|
3515
3527
|
});
|
|
3516
3528
|
s.group.setGroupJoinRequests(r.groupId, c);
|
|
3517
3529
|
},
|
|
3518
3530
|
onRequestToJoinDeclined: (r) => {
|
|
3519
3531
|
var i;
|
|
3520
|
-
|
|
3532
|
+
S.info("onRequestToJoinDeclined raw payload", r), s.group.updateGroupJoinRequest(
|
|
3521
3533
|
r.groupId,
|
|
3522
3534
|
((i = r.applicant) == null ? void 0 : i.userId) || "",
|
|
3523
3535
|
"declined"
|
|
@@ -3545,12 +3557,12 @@ function Pn(s) {
|
|
|
3545
3557
|
};
|
|
3546
3558
|
}
|
|
3547
3559
|
function Bn(s, e, t = {}, n, o, a) {
|
|
3548
|
-
const r = wn(e, t), i = Nn(s, e, n, o, a), c = kn(e),
|
|
3549
|
-
return s.addEventHandler("uikit-conn", r), s.chatManager.addEventHandler("uikit-chat", i), s.contactManager.addEventHandler("uikit-contact", c), s.groupManager.addEventHandler("uikit-group",
|
|
3560
|
+
const r = wn(e, t), i = Nn(s, e, n, o, a), c = kn(e), d = On(e), g = Pn(e);
|
|
3561
|
+
return s.addEventHandler("uikit-conn", r), s.chatManager.addEventHandler("uikit-chat", i), s.contactManager.addEventHandler("uikit-contact", c), s.groupManager.addEventHandler("uikit-group", d), s.presenceManager.addEventHandler("uikit-presence", g), () => {
|
|
3550
3562
|
s.removeEventHandler("uikit-conn"), s.chatManager.removeEventHandler("uikit-chat"), s.contactManager.removeEventHandler("uikit-contact"), s.groupManager.removeEventHandler("uikit-group"), s.presenceManager.removeEventHandler("uikit-presence"), Un(), An();
|
|
3551
3563
|
};
|
|
3552
3564
|
}
|
|
3553
|
-
const
|
|
3565
|
+
const _ = T("UIKit:Websdk5Adapter"), Fn = [
|
|
3554
3566
|
qe,
|
|
3555
3567
|
ct,
|
|
3556
3568
|
ut,
|
|
@@ -3602,61 +3614,61 @@ class ts {
|
|
|
3602
3614
|
eventDeps: r,
|
|
3603
3615
|
onUserInfoSubscriptionPermissionError: i,
|
|
3604
3616
|
registerImEvents: c,
|
|
3605
|
-
managerPreset:
|
|
3606
|
-
repositories:
|
|
3617
|
+
managerPreset: d,
|
|
3618
|
+
repositories: g,
|
|
3607
3619
|
persistence: m,
|
|
3608
|
-
lastMessageTextResolver:
|
|
3609
|
-
...
|
|
3610
|
-
} = t, l = e.repositories ??
|
|
3611
|
-
this._persistence =
|
|
3612
|
-
const { appKey: h, appId: v, ...
|
|
3613
|
-
let
|
|
3620
|
+
lastMessageTextResolver: p,
|
|
3621
|
+
...u
|
|
3622
|
+
} = t, l = e.repositories ?? g, f = e.persistence ?? m;
|
|
3623
|
+
this._persistence = f, this._lastMessageTextResolver = p, this._loginTimeoutMs = e.loginTimeoutMs;
|
|
3624
|
+
const { appKey: h, appId: v, ...b } = u;
|
|
3625
|
+
let w;
|
|
3614
3626
|
if (e.appKey)
|
|
3615
|
-
|
|
3627
|
+
w = { appKey: e.appKey };
|
|
3616
3628
|
else if (e.appId)
|
|
3617
|
-
|
|
3629
|
+
w = { appId: e.appId };
|
|
3618
3630
|
else if (this.injectedClient)
|
|
3619
|
-
|
|
3631
|
+
w = { appKey: "" };
|
|
3620
3632
|
else
|
|
3621
3633
|
throw new Error("[Websdk5Adapter] 缺少应用身份:SdkConfig.appKey 与 SdkConfig.appId 必须提供其一");
|
|
3622
3634
|
this._client = this.injectedClient ?? Nt({
|
|
3623
3635
|
debug: e.debug,
|
|
3624
|
-
managers:
|
|
3625
|
-
...
|
|
3626
|
-
...
|
|
3636
|
+
managers: u.managers ?? (d === "chatroom" ? Hn : Fn),
|
|
3637
|
+
...b,
|
|
3638
|
+
...w
|
|
3627
3639
|
}), r && rt(r), this._features = n ?? jt(), this._registerImEvents = c !== !1;
|
|
3628
|
-
const
|
|
3629
|
-
if (
|
|
3640
|
+
const I = a ? Object.keys(a) : [];
|
|
3641
|
+
if (_.info("[Websdk5Adapter] init 开始", {
|
|
3630
3642
|
mode: this.injectedClient ? "injected-client" : "builtin",
|
|
3631
|
-
managerPreset:
|
|
3643
|
+
managerPreset: d ?? "im",
|
|
3632
3644
|
registerImEvents: this._registerImEvents,
|
|
3633
|
-
injectedStores:
|
|
3634
|
-
}),
|
|
3645
|
+
injectedStores: I
|
|
3646
|
+
}), I.length < 7) {
|
|
3635
3647
|
const W = ["client", "message", "conversation", "contact", "group", "presence", "userInfo"];
|
|
3636
|
-
|
|
3648
|
+
_.debug(
|
|
3637
3649
|
"[Websdk5Adapter] 以下 store 域未注入,回落 adapter 内置 store:",
|
|
3638
|
-
W.filter((
|
|
3650
|
+
W.filter((D) => !I.includes(D))
|
|
3639
3651
|
);
|
|
3640
3652
|
}
|
|
3641
3653
|
const R = { ...Kt(this, () => this._getFanout()), ...a };
|
|
3642
3654
|
this._stores = R, this._domains = {
|
|
3643
3655
|
message: new dn(this._client, R.message, {
|
|
3644
3656
|
messageRepository: l == null ? void 0 : l.message,
|
|
3645
|
-
persistence:
|
|
3657
|
+
persistence: f == null ? void 0 : f.message
|
|
3646
3658
|
}),
|
|
3647
3659
|
conversation: new pn(this._client, R.conversation, {
|
|
3648
|
-
sendPendingReadReceipts: (W,
|
|
3660
|
+
sendPendingReadReceipts: (W, D) => {
|
|
3649
3661
|
var Y, De;
|
|
3650
|
-
((Y = this._features) == null ? void 0 : Y.enableReadReceipt) !== !1 && ((De = this._domains) == null || De.message.sendPendingReadReceipts(W,
|
|
3662
|
+
((Y = this._features) == null ? void 0 : Y.enableReadReceipt) !== !1 && ((De = this._domains) == null || De.message.sendPendingReadReceipts(W, D));
|
|
3651
3663
|
},
|
|
3652
3664
|
resolveSenderName: (W) => {
|
|
3653
3665
|
var Y;
|
|
3654
|
-
const
|
|
3655
|
-
return
|
|
3666
|
+
const D = R.contact.getContact(W);
|
|
3667
|
+
return D != null && D.remark || D != null && D.name ? D.remark || D.name : (Y = R.userInfo.getUserInfo(W)) == null ? void 0 : Y.nickname;
|
|
3656
3668
|
},
|
|
3657
3669
|
lastMessageTextResolver: this._lastMessageTextResolver,
|
|
3658
3670
|
conversationRepository: l == null ? void 0 : l.conversation,
|
|
3659
|
-
persistence:
|
|
3671
|
+
persistence: f == null ? void 0 : f.conversation
|
|
3660
3672
|
}),
|
|
3661
3673
|
contact: new In(this._client, R.contact, {
|
|
3662
3674
|
contactRepository: l == null ? void 0 : l.contact
|
|
@@ -3671,29 +3683,29 @@ class ts {
|
|
|
3671
3683
|
this._client,
|
|
3672
3684
|
R.userInfo,
|
|
3673
3685
|
(l == null ? void 0 : l.userInfo) ?? Vt(o) ?? {},
|
|
3674
|
-
i ?? (() =>
|
|
3675
|
-
), this._userInfoDomain.listen(), this._setupEventHandlers(),
|
|
3686
|
+
i ?? (() => _.warn("[Websdk5Adapter] 用户资料订阅无权限,已自动熔断"))
|
|
3687
|
+
), this._userInfoDomain.listen(), this._setupEventHandlers(), _.info("[Websdk5Adapter] init 完成");
|
|
3676
3688
|
}
|
|
3677
3689
|
async login(e, t) {
|
|
3678
|
-
var o, a, r, i, c,
|
|
3690
|
+
var o, a, r, i, c, d, g;
|
|
3679
3691
|
if (!this._client)
|
|
3680
3692
|
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3681
|
-
this._eventsRegistered || (
|
|
3693
|
+
this._eventsRegistered || (_.debug("[Websdk5Adapter] 登出后重新登录,恢复事件处理器与用户资料监听"), (o = this._userInfoDomain) == null || o.listen(), this._setupEventHandlers());
|
|
3682
3694
|
const n = At(e);
|
|
3683
|
-
n !== e &&
|
|
3695
|
+
n !== e && _.warn("[Websdk5Adapter] 检测到登录 userId 包含大写字母,已强制转换为纯小写后继续登录", {
|
|
3684
3696
|
originalUserId: e,
|
|
3685
3697
|
normalizedUserId: n
|
|
3686
|
-
}),
|
|
3698
|
+
}), _.info("[Websdk5Adapter] login 开始", { user: n }), (i = (a = this._stores) == null ? void 0 : (r = a.client).setCurrentUser) == null || i.call(r, n);
|
|
3687
3699
|
try {
|
|
3688
3700
|
await this._client.login(n, t, this._loginTimeoutMs);
|
|
3689
3701
|
} catch (m) {
|
|
3690
|
-
throw (
|
|
3702
|
+
throw (g = (c = this._stores) == null ? void 0 : (d = c.client).setCurrentUser) == null || g.call(d, ""), _.error("[Websdk5Adapter] login 失败:", U(m)), m;
|
|
3691
3703
|
}
|
|
3692
|
-
|
|
3704
|
+
_.info("[Websdk5Adapter] login 成功", { user: n });
|
|
3693
3705
|
}
|
|
3694
3706
|
async logout() {
|
|
3695
3707
|
var e, t, n, o, a;
|
|
3696
|
-
|
|
3708
|
+
_.info("[Websdk5Adapter] logout"), await ((e = this._client) == null ? void 0 : e.logout()), (t = this._domains) == null || t.message.clearMultiBodyRetryCache(), (n = this._disposeEventHandlers) == null || n.call(this), this._disposeEventHandlers = void 0, (o = this._disposeSyncListener) == null || o.call(this), this._disposeSyncListener = void 0, (a = this._userInfoDomain) == null || a.dispose(), this._eventsRegistered = !1;
|
|
3697
3709
|
}
|
|
3698
3710
|
/** 订阅中立事件,返回取消订阅函数(支持多方订阅,内部扇出派发) */
|
|
3699
3711
|
subscribe(e) {
|
|
@@ -3720,7 +3732,7 @@ class ts {
|
|
|
3720
3732
|
var e, t;
|
|
3721
3733
|
if (!(!this._client || !this._stores)) {
|
|
3722
3734
|
if (!this._registerImEvents) {
|
|
3723
|
-
|
|
3735
|
+
_.debug("[Websdk5Adapter] IM 事件套件已关闭(registerImEvents=false),场景事件由业务经 onAdapterReady 自行注册");
|
|
3724
3736
|
return;
|
|
3725
3737
|
}
|
|
3726
3738
|
En(), (e = this._disposeSyncListener) == null || e.call(this), this._disposeSyncListener = Sn((n) => {
|
|
@@ -3742,7 +3754,7 @@ class ts {
|
|
|
3742
3754
|
this._features,
|
|
3743
3755
|
this._persistence,
|
|
3744
3756
|
this._lastMessageTextResolver
|
|
3745
|
-
), this._eventsRegistered = !0,
|
|
3757
|
+
), this._eventsRegistered = !0, _.debug("[Websdk5Adapter] SDK 事件处理器已注册");
|
|
3746
3758
|
}
|
|
3747
3759
|
}
|
|
3748
3760
|
get message() {
|