@easemob-community/uikit-sdk-websdk5 1.6.1 → 1.7.0
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/conversation-adapter.d.ts.map +1 -1
- package/dist/adapter/internal-stores/group.d.ts.map +1 -1
- package/dist/adapter/internal-stores/user-info.d.ts.map +1 -1
- package/dist/adapter/repositories/user-info.d.ts.map +1 -1
- package/dist/adapter/user-info-cache.d.ts +10 -0
- package/dist/adapter/user-info-cache.d.ts.map +1 -0
- package/dist/adapter/user-info-cache.test.d.ts +2 -0
- package/dist/adapter/user-info-cache.test.d.ts.map +1 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.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/__tests__/presence-batching.test.d.ts +2 -0
- package/dist/domain/__tests__/presence-batching.test.d.ts.map +1 -0
- package/dist/domain/conversation-domain.d.ts +2 -0
- package/dist/domain/conversation-domain.d.ts.map +1 -1
- package/dist/domain/group-domain.d.ts +1 -0
- package/dist/domain/group-domain.d.ts.map +1 -1
- package/dist/domain/presence-domain.d.ts +12 -3
- package/dist/domain/presence-domain.d.ts.map +1 -1
- package/dist/domain/user-info-domain.d.ts +10 -7
- package/dist/domain/user-info-domain.d.ts.map +1 -1
- package/dist/easemob-uikit-sdk-websdk5.js +1287 -995
- package/dist/easemob-uikit-sdk-websdk5.umd.cjs +1 -1
- package/dist/event/__tests__/conversation-mute.test.d.ts +2 -0
- package/dist/event/__tests__/conversation-mute.test.d.ts.map +1 -0
- package/dist/event/chat-events.d.ts.map +1 -1
- package/dist/event/connection-events.d.ts +3 -0
- package/dist/event/connection-events.d.ts.map +1 -1
- package/dist/event/conversation-mute.d.ts +56 -0
- package/dist/event/conversation-mute.d.ts.map +1 -0
- package/dist/event/types.d.ts +2 -0
- package/dist/event/types.d.ts.map +1 -1
- package/dist/utils/__tests__/conversation-log.test.d.ts +2 -0
- package/dist/utils/__tests__/conversation-log.test.d.ts.map +1 -0
- package/dist/utils/conversation-log.d.ts +15 -0
- package/dist/utils/conversation-log.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { ChatClient as
|
|
2
|
-
import { log as
|
|
3
|
-
import { normalizeUserId as
|
|
4
|
-
import { markRaw as
|
|
5
|
-
let
|
|
6
|
-
function
|
|
7
|
-
|
|
1
|
+
import { ChatClient as It, isSDKError as et, ChatManager as tt, ChatRoomManager as Mt, UserInfoManager as nt, ContactManager as yt, GroupManager as Ct, PresenceManager as bt, PushManager as wt } from "easemob-websdk";
|
|
2
|
+
import { log as Le, GROUP_MEMBER_ROLE as R, customEventPreviewMap as St, mergeMessagePreviewLabels as st, MESSAGE_TYPE as b, resolveMultiBodyPreview as rt, isTextBody as At, isImageBody as Et, MESSAGE_EXT_KEY as ot, isVoiceBody as it, isVideoBody as Gt, isFileBody as Tt, isLocationBody as Ut, isCustomBody as Rt, isCmdBody as Lt, isCombineBody as at, CONVERSATION_TYPE as I, normalizeUserId as G, MESSAGE_STATUS as k, isMultiBody as _t, createLogger as T, toMessageRecord as _e, formatConversationPreview as ct, PRESENCE_STATUS as ee, isKickErrorCode as Dt, resolveLastMessageText as Nt, isStreamActive as kt, toConversationRecord as Ke, NOTICE_EVENT_TYPE as E, SDK_CONTRACT_VERSION as Ot, normalizeLoginUserId as xt } from "@easemob-community/uikit-sdk-contract";
|
|
3
|
+
import { normalizeUserId as Es } from "@easemob-community/uikit-sdk-contract";
|
|
4
|
+
import { markRaw as qe, computed as Me, reactive as Pt } from "vue";
|
|
5
|
+
let de = null;
|
|
6
|
+
function gs(s) {
|
|
7
|
+
de = s;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
9
|
+
function Bt(s) {
|
|
10
|
+
de == null || de(s);
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const ut = "uikit-sdk-log-capture", Ft = /^%c\[Chat\]\[(DEBUG|WARN|ERROR)\]\[[^\]]*\]/, dt = {
|
|
13
13
|
DEBUG: "debug",
|
|
14
14
|
WARN: "warn",
|
|
15
15
|
ERROR: "error"
|
|
16
16
|
};
|
|
17
|
-
let
|
|
18
|
-
function
|
|
19
|
-
|
|
17
|
+
let z = !1, j = null, W = null, le = null, De = !1, q = null, fe = null;
|
|
18
|
+
function Ht(s) {
|
|
19
|
+
fe = s;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
level:
|
|
21
|
+
function ne(s, e, t) {
|
|
22
|
+
z && Bt({
|
|
23
|
+
level: dt[s],
|
|
24
24
|
source: "sdk",
|
|
25
25
|
message: typeof e == "string" ? e : String(e),
|
|
26
26
|
args: t
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
const n =
|
|
29
|
+
function ye(s, e, t) {
|
|
30
|
+
const n = W ?? console.log, o = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
31
31
|
n.call(
|
|
32
32
|
console,
|
|
33
33
|
`%c[Chat][${s}][${o}]`,
|
|
@@ -36,72 +36,72 @@ function pe(s, e, t) {
|
|
|
36
36
|
...t
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
39
|
+
function Kt() {
|
|
40
|
+
W || (W = console.log, console.log = (...s) => {
|
|
41
41
|
try {
|
|
42
42
|
const e = s[0];
|
|
43
43
|
if (typeof e == "string") {
|
|
44
|
-
const t = e.match(
|
|
45
|
-
t &&
|
|
44
|
+
const t = e.match(Ft);
|
|
45
|
+
t && ne(t[1], s[2], s.slice(3));
|
|
46
46
|
}
|
|
47
47
|
} catch {
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
W.apply(console, s);
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
52
|
+
function qt() {
|
|
53
|
+
W && (console.log = W, W = null);
|
|
54
54
|
}
|
|
55
|
-
async function
|
|
55
|
+
async function ms() {
|
|
56
56
|
var s;
|
|
57
|
-
if (!
|
|
58
|
-
|
|
57
|
+
if (!z) {
|
|
58
|
+
z = !0;
|
|
59
59
|
try {
|
|
60
60
|
const e = await import("easemob-websdk");
|
|
61
|
-
typeof e.setLogLevel == "function" && (e.setLogLevel("DEBUG"),
|
|
61
|
+
typeof e.setLogLevel == "function" && (e.setLogLevel("DEBUG"), De = !0);
|
|
62
62
|
const t = e.LogEventName ? (s = e.ChatClient) == null ? void 0 : s.instance : null;
|
|
63
|
-
t && typeof t.addEventHandler == "function" ? (t.addEventHandler(
|
|
63
|
+
t && typeof t.addEventHandler == "function" ? (t.addEventHandler(ut, {
|
|
64
64
|
onLog: (n) => {
|
|
65
65
|
const o = n;
|
|
66
|
-
o && typeof o.level == "string" && o.level in
|
|
66
|
+
o && typeof o.level == "string" && o.level in dt && ne(o.level, o.message, [...o.args ?? []]);
|
|
67
67
|
}
|
|
68
|
-
}),
|
|
68
|
+
}), q = t, j = "onlog") : typeof e.setLogger == "function" ? (le = typeof e.getLogger == "function" ? e.getLogger() : null, e.setLogger({
|
|
69
69
|
debug: (n, ...o) => {
|
|
70
|
-
|
|
70
|
+
ne("DEBUG", n, o), ye("DEBUG", n, o);
|
|
71
71
|
},
|
|
72
72
|
warn: (n, ...o) => {
|
|
73
|
-
|
|
73
|
+
ne("WARN", n, o), ye("WARN", n, o);
|
|
74
74
|
},
|
|
75
75
|
error: (n, ...o) => {
|
|
76
|
-
|
|
76
|
+
ne("ERROR", n, o), ye("ERROR", n, o);
|
|
77
77
|
}
|
|
78
|
-
}),
|
|
78
|
+
}), j = "inject") : (Kt(), j = "console");
|
|
79
79
|
} catch (e) {
|
|
80
|
-
|
|
80
|
+
z = !1, console.warn("[UIKit:SdkLogCapture] failed to enable SDK log capture", e);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
async function
|
|
84
|
+
async function ps() {
|
|
85
85
|
var s;
|
|
86
|
-
if (
|
|
87
|
-
|
|
86
|
+
if (z) {
|
|
87
|
+
z = !1;
|
|
88
88
|
try {
|
|
89
|
-
|
|
89
|
+
j === "console" && qt(), j === "onlog" && ((s = q == null ? void 0 : q.removeEventHandler) == null || s.call(q, ut));
|
|
90
90
|
const e = await import("easemob-websdk");
|
|
91
|
-
|
|
91
|
+
j === "inject" && typeof e.setLogger == "function" && le && e.setLogger(le), De && !(fe != null && fe()) && typeof e.setLogLevel == "function" && e.setLogLevel("WARN");
|
|
92
92
|
} catch {
|
|
93
93
|
} finally {
|
|
94
|
-
|
|
94
|
+
j = null, q = null, le = null, De = !1;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
let
|
|
99
|
-
function
|
|
100
|
-
return
|
|
98
|
+
let Pe = !1;
|
|
99
|
+
function hs() {
|
|
100
|
+
return Pe;
|
|
101
101
|
}
|
|
102
|
-
let
|
|
103
|
-
function
|
|
104
|
-
const e =
|
|
102
|
+
let lt = null;
|
|
103
|
+
function jt(s) {
|
|
104
|
+
const e = lt;
|
|
105
105
|
if (!e)
|
|
106
106
|
return s;
|
|
107
107
|
if (s.appKey !== e.appKey || s.appId !== e.appId)
|
|
@@ -111,13 +111,13 @@ function Dt(s) {
|
|
|
111
111
|
const { managers: t, ...n } = s, o = [];
|
|
112
112
|
for (const a of Object.keys(n))
|
|
113
113
|
JSON.stringify(n[a]) !== JSON.stringify(e[a]) && o.push(a);
|
|
114
|
-
return o.length > 0 &&
|
|
114
|
+
return o.length > 0 && Le(
|
|
115
115
|
"[UIKit] SDK 已初始化,本次 init 配置以首次初始化为准(忽略字段:%s)。",
|
|
116
116
|
o.join(", ")
|
|
117
117
|
), { ...e, managers: t };
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
class
|
|
119
|
+
Ht(() => Pe);
|
|
120
|
+
class Vt {
|
|
121
121
|
constructor(e) {
|
|
122
122
|
var i;
|
|
123
123
|
const { debug: t, clientName: n = "UIKit", clientVersion: o, ...a } = e;
|
|
@@ -125,25 +125,25 @@ class _t {
|
|
|
125
125
|
throw new Error(
|
|
126
126
|
"[UIKit] ClientConfig.managers 未注入:SDK manager 列表由 adapter 负责传入"
|
|
127
127
|
);
|
|
128
|
-
const r =
|
|
128
|
+
const r = jt({
|
|
129
129
|
...a,
|
|
130
130
|
enableUserInfoSync: a.enableUserInfoSync ?? !0,
|
|
131
131
|
managers: a.managers
|
|
132
132
|
});
|
|
133
|
-
this._deleteConversationOnGroupDestroyed = r.deleteConversationOnGroupDestroyed ?? !0, this._client =
|
|
133
|
+
this._deleteConversationOnGroupDestroyed = r.deleteConversationOnGroupDestroyed ?? !0, this._client = It.init(r), lt = r, t && (Pe = !0, import("easemob-websdk").then(({ setLogLevel: c }) => {
|
|
134
134
|
c("DEBUG");
|
|
135
|
-
})), o ?
|
|
135
|
+
})), o ? Le(
|
|
136
136
|
"%c[Easemob] SDK version: %s, %s version: %s, Adapter version: %s",
|
|
137
137
|
"color: green; font-weight: bold;",
|
|
138
|
-
"5.2.
|
|
138
|
+
"5.2.1",
|
|
139
139
|
n,
|
|
140
140
|
o,
|
|
141
|
-
"1.
|
|
142
|
-
) :
|
|
141
|
+
"1.7.0"
|
|
142
|
+
) : Le(
|
|
143
143
|
"%c[Easemob] SDK version: %s, Adapter version: %s",
|
|
144
144
|
"color: green; font-weight: bold;",
|
|
145
|
-
"5.2.
|
|
146
|
-
"1.
|
|
145
|
+
"5.2.1",
|
|
146
|
+
"1.7.0"
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
149
|
get chatManager() {
|
|
@@ -179,6 +179,12 @@ class _t {
|
|
|
179
179
|
get currentUserId() {
|
|
180
180
|
return this._client.getCurrentUserId();
|
|
181
181
|
}
|
|
182
|
+
/** SDK internal 缓存入口的安全委托,由 adapter 内结构类型消费。 */
|
|
183
|
+
getCacheManager() {
|
|
184
|
+
var t;
|
|
185
|
+
const e = this._client;
|
|
186
|
+
return ((t = e.getCacheManager) == null ? void 0 : t.call(e)) ?? null;
|
|
187
|
+
}
|
|
182
188
|
addEventHandler(e, t) {
|
|
183
189
|
this._client.addEventHandler(e, t);
|
|
184
190
|
}
|
|
@@ -192,10 +198,10 @@ class _t {
|
|
|
192
198
|
return this._client.logout();
|
|
193
199
|
}
|
|
194
200
|
}
|
|
195
|
-
function
|
|
196
|
-
return new
|
|
201
|
+
function Wt(s) {
|
|
202
|
+
return new Vt(s);
|
|
197
203
|
}
|
|
198
|
-
function
|
|
204
|
+
function Jt(s, e) {
|
|
199
205
|
let t = !1, n = !1, o = !1;
|
|
200
206
|
function a() {
|
|
201
207
|
return n ? "connecting" : t ? "connected" : o ? "reconnectFailed" : "disconnected";
|
|
@@ -225,7 +231,7 @@ function kt(s, e) {
|
|
|
225
231
|
}
|
|
226
232
|
};
|
|
227
233
|
}
|
|
228
|
-
function
|
|
234
|
+
function $t(s) {
|
|
229
235
|
let e = [], t = [];
|
|
230
236
|
function o() {
|
|
231
237
|
var r, i;
|
|
@@ -247,18 +253,18 @@ function Ot(s) {
|
|
|
247
253
|
},
|
|
248
254
|
addContact(r) {
|
|
249
255
|
var c, u;
|
|
250
|
-
const i = e.findIndex((
|
|
256
|
+
const i = e.findIndex((l) => l.userId === r.userId);
|
|
251
257
|
i >= 0 ? e[i] = { ...e[i], ...r } : e.push(r), o(), (u = (c = s()) == null ? void 0 : c.onContactUpdated) == null || u.call(c, r);
|
|
252
258
|
},
|
|
253
259
|
removeContact(r) {
|
|
254
260
|
var c, u;
|
|
255
|
-
const i = e.find((
|
|
256
|
-
e = e.filter((
|
|
261
|
+
const i = e.find((l) => l.userId === r);
|
|
262
|
+
e = e.filter((l) => l.userId !== r), i && (o(), (u = (c = s()) == null ? void 0 : c.onContactUpdated) == null || u.call(c, i));
|
|
257
263
|
},
|
|
258
264
|
updateRemark(r, i) {
|
|
259
|
-
var u,
|
|
260
|
-
const c = e.findIndex((
|
|
261
|
-
c < 0 || (e[c] = { ...e[c], remark: i, name: i || e[c].name }, o(), (
|
|
265
|
+
var u, l;
|
|
266
|
+
const c = e.findIndex((g) => g.userId === r);
|
|
267
|
+
c < 0 || (e[c] = { ...e[c], remark: i, name: i || e[c].name }, o(), (l = (u = s()) == null ? void 0 : u.onContactUpdated) == null || l.call(u, e[c]));
|
|
262
268
|
},
|
|
263
269
|
setBlocklist(r) {
|
|
264
270
|
},
|
|
@@ -287,7 +293,7 @@ function Ot(s) {
|
|
|
287
293
|
}
|
|
288
294
|
};
|
|
289
295
|
}
|
|
290
|
-
function
|
|
296
|
+
function Qt(s) {
|
|
291
297
|
let e = [], t = null, n = !1;
|
|
292
298
|
function o() {
|
|
293
299
|
var a, r;
|
|
@@ -317,7 +323,7 @@ function xt(s) {
|
|
|
317
323
|
},
|
|
318
324
|
update(a, r) {
|
|
319
325
|
var c, u;
|
|
320
|
-
const i = e.findIndex((
|
|
326
|
+
const i = e.findIndex((l) => l.id === a);
|
|
321
327
|
i < 0 || (e[i] = { ...e[i], ...r }, o(), (u = (c = s()) == null ? void 0 : c.onConversationUpdated) == null || u.call(c, { id: a, conversation: r }));
|
|
322
328
|
},
|
|
323
329
|
setConversationList(a) {
|
|
@@ -349,148 +355,159 @@ function xt(s) {
|
|
|
349
355
|
}
|
|
350
356
|
};
|
|
351
357
|
}
|
|
352
|
-
function
|
|
358
|
+
function zt(s) {
|
|
353
359
|
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(), u = /* @__PURE__ */ new Set(),
|
|
355
|
-
function
|
|
356
|
-
var
|
|
357
|
-
(
|
|
360
|
+
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(), u = /* @__PURE__ */ new Set(), l = !1;
|
|
361
|
+
function g() {
|
|
362
|
+
var d, f;
|
|
363
|
+
(f = (d = s()) == null ? void 0 : d.onGroupChange) == null || f.call(d, e);
|
|
364
|
+
}
|
|
365
|
+
function p(d, f) {
|
|
366
|
+
const m = new Map(d.map((h) => [h.userId, h.role]));
|
|
367
|
+
return f.map((h) => {
|
|
368
|
+
const v = m.get(h.userId);
|
|
369
|
+
return v === R.ADMIN && h.role === R.MEMBER ? { ...h, role: v } : h;
|
|
370
|
+
});
|
|
358
371
|
}
|
|
359
372
|
return {
|
|
360
373
|
get groupList() {
|
|
361
374
|
return e;
|
|
362
375
|
},
|
|
363
376
|
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)));
|
|
377
|
+
return l;
|
|
441
378
|
},
|
|
442
|
-
|
|
443
|
-
|
|
379
|
+
setList(d) {
|
|
380
|
+
e = d, g();
|
|
444
381
|
},
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
r.set(g, l);
|
|
382
|
+
addGroup(d) {
|
|
383
|
+
var m, h;
|
|
384
|
+
const f = e.findIndex((v) => v.groupId === d.groupId);
|
|
385
|
+
f >= 0 ? e[f] = { ...e[f], ...d } : e.push(d), g(), (h = (m = s()) == null ? void 0 : m.onGroupUpdated) == null || h.call(m, d);
|
|
450
386
|
},
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
387
|
+
removeGroup(d) {
|
|
388
|
+
var m, h;
|
|
389
|
+
const f = e.find((v) => v.groupId === d);
|
|
390
|
+
e = e.filter((v) => v.groupId !== d), f && (g(), (h = (m = s()) == null ? void 0 : m.onGroupUpdated) == null || h.call(m, f));
|
|
454
391
|
},
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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 });
|
|
464
|
-
},
|
|
465
|
-
decrementMemberCount(g, d) {
|
|
466
|
-
const l = this.getGroupById(g);
|
|
467
|
-
l && this.updateGroup(g, { memberCount: Math.max(0, (l.memberCount ?? 0) - d) });
|
|
468
|
-
},
|
|
469
|
-
addGroupSharedFile(g, d) {
|
|
470
|
-
const l = i.get(g) ?? [];
|
|
471
|
-
l.push(d), i.set(g, l);
|
|
472
|
-
},
|
|
473
|
-
removeGroupSharedFile(g, d) {
|
|
474
|
-
i.set(g, (i.get(g) ?? []).filter((l) => l.fileId !== d));
|
|
475
|
-
},
|
|
476
|
-
getGroupJoinRequests(g) {
|
|
477
|
-
return c.get(g) ?? [];
|
|
392
|
+
updateGroup(d, f) {
|
|
393
|
+
var h, v;
|
|
394
|
+
const m = e.findIndex((C) => C.groupId === d);
|
|
395
|
+
m < 0 || (e[m] = { ...e[m], ...f }, g(), (v = (h = s()) == null ? void 0 : h.onGroupUpdated) == null || v.call(h, e[m]));
|
|
478
396
|
},
|
|
479
|
-
|
|
480
|
-
|
|
397
|
+
setGroupMembers(d, f) {
|
|
398
|
+
var h, v;
|
|
399
|
+
const m = p(t.get(d) ?? [], f);
|
|
400
|
+
t.set(d, m), (v = (h = s()) == null ? void 0 : h.onGroupMembersChanged) == null || v.call(h, { groupId: d, members: m });
|
|
481
401
|
},
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
402
|
+
getGroupMembers(d) {
|
|
403
|
+
return t.get(d) ?? [];
|
|
404
|
+
},
|
|
405
|
+
appendGroupMembers(d, f) {
|
|
406
|
+
var C, w;
|
|
407
|
+
const m = t.get(d) ?? [], h = new Map(m.map((M) => [M.userId, M]));
|
|
408
|
+
for (const M of p(m, f))
|
|
409
|
+
h.set(M.userId, M);
|
|
410
|
+
const v = Array.from(h.values());
|
|
411
|
+
t.set(d, v), (w = (C = s()) == null ? void 0 : C.onGroupMembersChanged) == null || w.call(C, { groupId: d, members: v });
|
|
412
|
+
},
|
|
413
|
+
removeGroupMembers(d, f) {
|
|
414
|
+
var v, C;
|
|
415
|
+
const m = new Set(f), h = (t.get(d) ?? []).filter((w) => !m.has(w.userId));
|
|
416
|
+
t.set(d, h), (C = (v = s()) == null ? void 0 : v.onGroupMembersChanged) == null || C.call(v, { groupId: d, members: h });
|
|
417
|
+
},
|
|
418
|
+
updateGroupMemberRole(d, f, m) {
|
|
419
|
+
var C, w;
|
|
420
|
+
const h = t.get(d) ?? [], v = h.findIndex((M) => M.userId === f);
|
|
421
|
+
v < 0 || (h[v] = { ...h[v], role: m }, t.set(d, h), (w = (C = s()) == null ? void 0 : C.onGroupMembersChanged) == null || w.call(C, { groupId: d, members: h }));
|
|
422
|
+
},
|
|
423
|
+
setGroupAnnouncement(d, f) {
|
|
424
|
+
var m, h;
|
|
425
|
+
n.set(d, f), (h = (m = s()) == null ? void 0 : m.onGroupAnnouncementChanged) == null || h.call(m, { groupId: d, announcement: f });
|
|
426
|
+
},
|
|
427
|
+
isGroupAdminSynced(d) {
|
|
428
|
+
return u.has(d);
|
|
429
|
+
},
|
|
430
|
+
markGroupAdminSynced(d) {
|
|
431
|
+
u.add(d);
|
|
432
|
+
},
|
|
433
|
+
setGroupMuteList(d, f) {
|
|
434
|
+
o.set(d, f);
|
|
435
|
+
},
|
|
436
|
+
addGroupMuteMembers(d, f) {
|
|
437
|
+
const m = o.get(d) ?? [], h = Array.isArray(f) && f.length > 0 && typeof f[0] == "string" ? f : f.map((v) => v.userId);
|
|
438
|
+
for (const v of h)
|
|
439
|
+
m.some((C) => C.userId === v) || m.push({ userId: v });
|
|
440
|
+
o.set(d, m);
|
|
441
|
+
},
|
|
442
|
+
removeGroupMuteMembers(d, f) {
|
|
443
|
+
const m = new Set(f);
|
|
444
|
+
o.set(d, (o.get(d) ?? []).filter((h) => !m.has(h.userId)));
|
|
445
|
+
},
|
|
446
|
+
setGroupBlocklist(d, f) {
|
|
447
|
+
a.set(d, f);
|
|
448
|
+
},
|
|
449
|
+
addGroupBlocklistMembers(d, f) {
|
|
450
|
+
const m = a.get(d) ?? [];
|
|
451
|
+
for (const h of f)
|
|
452
|
+
m.some((v) => v.userId === h) || m.push({ userId: h });
|
|
453
|
+
a.set(d, m);
|
|
454
|
+
},
|
|
455
|
+
removeGroupBlocklistMembers(d, f) {
|
|
456
|
+
const m = new Set(f);
|
|
457
|
+
a.set(d, (a.get(d) ?? []).filter((h) => !m.has(h.userId)));
|
|
458
|
+
},
|
|
459
|
+
setGroupAllowlist(d, f) {
|
|
460
|
+
r.set(d, f);
|
|
461
|
+
},
|
|
462
|
+
addGroupAllowlistMembers(d, f) {
|
|
463
|
+
const m = r.get(d) ?? [];
|
|
464
|
+
for (const h of f)
|
|
465
|
+
m.some((v) => v.userId === h) || m.push({ userId: h });
|
|
466
|
+
r.set(d, m);
|
|
467
|
+
},
|
|
468
|
+
removeGroupAllowlistMembers(d, f) {
|
|
469
|
+
const m = new Set(f);
|
|
470
|
+
r.set(d, (r.get(d) ?? []).filter((h) => !m.has(h.userId)));
|
|
471
|
+
},
|
|
472
|
+
setGroupList(d) {
|
|
473
|
+
this.setList(d);
|
|
474
|
+
},
|
|
475
|
+
getGroupById(d) {
|
|
476
|
+
return e.find((f) => f.groupId === d);
|
|
477
|
+
},
|
|
478
|
+
incrementMemberCount(d, f) {
|
|
479
|
+
const m = this.getGroupById(d);
|
|
480
|
+
m && this.updateGroup(d, { memberCount: (m.memberCount ?? 0) + f });
|
|
481
|
+
},
|
|
482
|
+
decrementMemberCount(d, f) {
|
|
483
|
+
const m = this.getGroupById(d);
|
|
484
|
+
m && this.updateGroup(d, { memberCount: Math.max(0, (m.memberCount ?? 0) - f) });
|
|
485
|
+
},
|
|
486
|
+
addGroupSharedFile(d, f) {
|
|
487
|
+
const m = i.get(d) ?? [];
|
|
488
|
+
m.push(f), i.set(d, m);
|
|
489
|
+
},
|
|
490
|
+
removeGroupSharedFile(d, f) {
|
|
491
|
+
i.set(d, (i.get(d) ?? []).filter((m) => m.fileId !== f));
|
|
492
|
+
},
|
|
493
|
+
getGroupJoinRequests(d) {
|
|
494
|
+
return c.get(d) ?? [];
|
|
495
|
+
},
|
|
496
|
+
setGroupJoinRequests(d, f) {
|
|
497
|
+
c.set(d, f);
|
|
498
|
+
},
|
|
499
|
+
updateGroupJoinRequest(d, f, m) {
|
|
500
|
+
const v = (c.get(d) ?? []).find(
|
|
501
|
+
(C) => {
|
|
502
|
+
var w;
|
|
503
|
+
return C.applicantId === f || ((w = C.applicant) == null ? void 0 : w.userId) === f;
|
|
487
504
|
}
|
|
488
505
|
);
|
|
489
|
-
|
|
506
|
+
v && (v.status = m);
|
|
490
507
|
}
|
|
491
508
|
};
|
|
492
509
|
}
|
|
493
|
-
function
|
|
510
|
+
function Yt(s) {
|
|
494
511
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
495
512
|
let n = !1;
|
|
496
513
|
function o(i) {
|
|
@@ -498,17 +515,17 @@ function Bt(s) {
|
|
|
498
515
|
}
|
|
499
516
|
function a(i) {
|
|
500
517
|
for (const [c, u] of e) {
|
|
501
|
-
const
|
|
502
|
-
if (
|
|
503
|
-
return { list: u, index:
|
|
518
|
+
const l = u.findIndex((g) => g.msgServerId === i || g.msgLocalId === i);
|
|
519
|
+
if (l >= 0)
|
|
520
|
+
return { list: u, index: l, conversationId: c };
|
|
504
521
|
}
|
|
505
522
|
return null;
|
|
506
523
|
}
|
|
507
524
|
function r(i) {
|
|
508
|
-
const c = i, u = e.get(c.conversationId) ?? [],
|
|
509
|
-
(
|
|
525
|
+
const c = i, u = e.get(c.conversationId) ?? [], l = u.findIndex(
|
|
526
|
+
(g) => g.msgServerId && g.msgServerId === c.msgServerId
|
|
510
527
|
);
|
|
511
|
-
|
|
528
|
+
l >= 0 ? u[l] = c : u.push(c), u.sort((g, p) => (g.timestamp ?? 0) - (p.timestamp ?? 0)), e.set(c.conversationId, u);
|
|
512
529
|
}
|
|
513
530
|
return {
|
|
514
531
|
getMessages: o,
|
|
@@ -520,69 +537,69 @@ function Bt(s) {
|
|
|
520
537
|
t.set(i, c);
|
|
521
538
|
},
|
|
522
539
|
replaceWithSent(i, c) {
|
|
523
|
-
var u,
|
|
524
|
-
t.delete(i), r(c), (
|
|
540
|
+
var u, l;
|
|
541
|
+
t.delete(i), r(c), (l = (u = s()) == null ? void 0 : u.onMessage) == null || l.call(u, c);
|
|
525
542
|
},
|
|
526
543
|
updateUploadProgress(i, c) {
|
|
527
544
|
const u = t.get(i);
|
|
528
545
|
if (!u)
|
|
529
546
|
return;
|
|
530
|
-
const
|
|
531
|
-
if (
|
|
532
|
-
const
|
|
533
|
-
|
|
547
|
+
const l = a(u.msgLocalId || u.msgServerId || "");
|
|
548
|
+
if (l) {
|
|
549
|
+
const g = { ...l.list[l.index], progress: c };
|
|
550
|
+
l.list[l.index] = g;
|
|
534
551
|
}
|
|
535
552
|
},
|
|
536
553
|
markFailed(i, c) {
|
|
537
554
|
const u = t.get(i);
|
|
538
555
|
t.delete(i);
|
|
539
|
-
const
|
|
540
|
-
if (!
|
|
556
|
+
const l = (u == null ? void 0 : u.msgLocalId) || (u == null ? void 0 : u.msgServerId);
|
|
557
|
+
if (!l)
|
|
541
558
|
return;
|
|
542
|
-
const
|
|
543
|
-
if (
|
|
544
|
-
const
|
|
545
|
-
|
|
559
|
+
const g = a(l);
|
|
560
|
+
if (g) {
|
|
561
|
+
const p = { ...g.list[g.index], status: "failed", failReason: c };
|
|
562
|
+
g.list[g.index] = p;
|
|
546
563
|
}
|
|
547
564
|
},
|
|
548
565
|
prependMessages(i, c) {
|
|
549
|
-
const u = e.get(i) ?? [],
|
|
550
|
-
for (const
|
|
551
|
-
const d =
|
|
552
|
-
d.msgServerId &&
|
|
566
|
+
const u = e.get(i) ?? [], l = /* @__PURE__ */ new Map();
|
|
567
|
+
for (const p of c) {
|
|
568
|
+
const d = p;
|
|
569
|
+
d.msgServerId && l.set(d.msgServerId, d);
|
|
553
570
|
}
|
|
554
|
-
for (const
|
|
555
|
-
|
|
556
|
-
const
|
|
557
|
-
(
|
|
571
|
+
for (const p of u)
|
|
572
|
+
p.msgServerId && !l.has(p.msgServerId) && l.set(p.msgServerId, p);
|
|
573
|
+
const g = Array.from(l.values()).sort(
|
|
574
|
+
(p, d) => (p.timestamp ?? 0) - (d.timestamp ?? 0)
|
|
558
575
|
);
|
|
559
|
-
e.set(i,
|
|
576
|
+
e.set(i, g);
|
|
560
577
|
},
|
|
561
578
|
updateStatusByServerId(i, c) {
|
|
562
|
-
var
|
|
579
|
+
var l, g;
|
|
563
580
|
const u = a(i);
|
|
564
|
-
u && (u.list[u.index] = { ...u.list[u.index], status: c }, (
|
|
581
|
+
u && (u.list[u.index] = { ...u.list[u.index], status: c }, (g = (l = s()) == null ? void 0 : l.onMessageStatusChanged) == null || g.call(l, { messageId: i, status: c }));
|
|
565
582
|
},
|
|
566
583
|
recallMessage(i, c) {
|
|
567
|
-
var
|
|
584
|
+
var g, p;
|
|
568
585
|
const u = a(i);
|
|
569
586
|
if (!u)
|
|
570
587
|
return;
|
|
571
|
-
const
|
|
572
|
-
|
|
588
|
+
const l = u.list[u.index];
|
|
589
|
+
l.recalled = !0, l.recalledBy = c, (p = (g = s()) == null ? void 0 : g.onMessagesRecalled) == null || p.call(g, {
|
|
573
590
|
messageId: i,
|
|
574
591
|
conversationId: u.conversationId,
|
|
575
|
-
conversationType:
|
|
592
|
+
conversationType: l.conversationType,
|
|
576
593
|
operatorId: c
|
|
577
594
|
});
|
|
578
595
|
},
|
|
579
596
|
updateMessage(i, c) {
|
|
580
|
-
var
|
|
597
|
+
var g, p;
|
|
581
598
|
const u = a(i);
|
|
582
599
|
if (!u)
|
|
583
600
|
return;
|
|
584
|
-
const
|
|
585
|
-
u.list[u.index] =
|
|
601
|
+
const l = c;
|
|
602
|
+
u.list[u.index] = l, l.modified && ((p = (g = s()) == null ? void 0 : g.onMessageUpdated) == null || p.call(g, l));
|
|
586
603
|
},
|
|
587
604
|
setPinnedMessages(i, c) {
|
|
588
605
|
},
|
|
@@ -590,8 +607,8 @@ function Bt(s) {
|
|
|
590
607
|
const u = a(i);
|
|
591
608
|
if (!u)
|
|
592
609
|
return;
|
|
593
|
-
const
|
|
594
|
-
|
|
610
|
+
const l = u.list[u.index];
|
|
611
|
+
l.translation = c, l.showTranslation = !0;
|
|
595
612
|
},
|
|
596
613
|
setTranslating(i, c) {
|
|
597
614
|
const u = a(i);
|
|
@@ -601,8 +618,8 @@ function Bt(s) {
|
|
|
601
618
|
const u = a(i);
|
|
602
619
|
if (!u)
|
|
603
620
|
return;
|
|
604
|
-
const
|
|
605
|
-
|
|
621
|
+
const l = u.list[u.index];
|
|
622
|
+
l.voiceText = c, l.showVoiceText = !0;
|
|
606
623
|
},
|
|
607
624
|
setVoiceTranscribing(i, c) {
|
|
608
625
|
const u = a(i);
|
|
@@ -612,39 +629,39 @@ function Bt(s) {
|
|
|
612
629
|
e.delete(i);
|
|
613
630
|
},
|
|
614
631
|
updateMessageById(i, c) {
|
|
615
|
-
var
|
|
632
|
+
var p, d, f, m;
|
|
616
633
|
const u = a(i);
|
|
617
634
|
if (!u)
|
|
618
635
|
return;
|
|
619
|
-
const
|
|
620
|
-
u.list[u.index] =
|
|
636
|
+
const l = u.list[u.index], g = { ...l, ...c };
|
|
637
|
+
u.list[u.index] = g, (c.modified || c.modifiedInfo) && ((d = (p = s()) == null ? void 0 : p.onMessageUpdated) == null || d.call(p, g)), c.status && c.status !== l.status && ((m = (f = s()) == null ? void 0 : f.onMessageStatusChanged) == null || m.call(f, {
|
|
621
638
|
messageId: i,
|
|
622
639
|
status: c.status
|
|
623
640
|
}));
|
|
624
641
|
},
|
|
625
642
|
replaceMessageById(i, c) {
|
|
626
|
-
var
|
|
643
|
+
var g, p;
|
|
627
644
|
const u = a(i);
|
|
628
645
|
if (!u)
|
|
629
646
|
return;
|
|
630
|
-
const
|
|
631
|
-
u.list[u.index] =
|
|
647
|
+
const l = c;
|
|
648
|
+
u.list[u.index] = l, (p = (g = s()) == null ? void 0 : g.onMessageUpdated) == null || p.call(g, l);
|
|
632
649
|
},
|
|
633
650
|
addAtMeMessage(i, c) {
|
|
634
|
-
var u,
|
|
635
|
-
(
|
|
651
|
+
var u, l;
|
|
652
|
+
(l = (u = s()) == null ? void 0 : u.onAtMe) == null || l.call(u, { conversationId: i, messageId: c });
|
|
636
653
|
},
|
|
637
654
|
updateMessageStatus(i, c) {
|
|
638
|
-
var
|
|
655
|
+
var l, g;
|
|
639
656
|
const u = a(i);
|
|
640
|
-
u && (u.list[u.index] = { ...u.list[u.index], status: c }, (
|
|
657
|
+
u && (u.list[u.index] = { ...u.list[u.index], status: c }, (g = (l = s()) == null ? void 0 : l.onMessageStatusChanged) == null || g.call(l, { messageId: i, status: c }));
|
|
641
658
|
},
|
|
642
659
|
setMessagePinned(i, c) {
|
|
643
660
|
const u = a(i);
|
|
644
661
|
if (!u)
|
|
645
662
|
return;
|
|
646
|
-
const
|
|
647
|
-
|
|
663
|
+
const l = u.list[u.index];
|
|
664
|
+
l.pinned = !0, l.pinTime = c.pinTime, l.pinOperatorId = c.operatorId;
|
|
648
665
|
},
|
|
649
666
|
setMessageUnpinned(i) {
|
|
650
667
|
const c = a(i);
|
|
@@ -654,22 +671,22 @@ function Bt(s) {
|
|
|
654
671
|
u.pinned = !1;
|
|
655
672
|
},
|
|
656
673
|
deleteMessages(i) {
|
|
657
|
-
var
|
|
674
|
+
var l, g;
|
|
658
675
|
const c = new Set(i), u = /* @__PURE__ */ new Map();
|
|
659
|
-
for (const [
|
|
660
|
-
const
|
|
661
|
-
for (const
|
|
662
|
-
const h =
|
|
676
|
+
for (const [p, d] of e) {
|
|
677
|
+
const f = [];
|
|
678
|
+
for (const m of d) {
|
|
679
|
+
const h = m.msgServerId || m.msgLocalId;
|
|
663
680
|
if (h && c.has(h)) {
|
|
664
|
-
const v = u.get(
|
|
665
|
-
v.push(h), u.set(
|
|
681
|
+
const v = u.get(p) ?? [];
|
|
682
|
+
v.push(h), u.set(p, v);
|
|
666
683
|
} else
|
|
667
|
-
|
|
684
|
+
f.push(m);
|
|
668
685
|
}
|
|
669
|
-
e.set(
|
|
686
|
+
e.set(p, f);
|
|
670
687
|
}
|
|
671
|
-
for (const [
|
|
672
|
-
(
|
|
688
|
+
for (const [p, d] of u)
|
|
689
|
+
(g = (l = s()) == null ? void 0 : l.onMessagesDeleted) == null || g.call(l, { messageIds: d, conversationId: p });
|
|
673
690
|
},
|
|
674
691
|
setSyncingMessages(i) {
|
|
675
692
|
var c, u;
|
|
@@ -680,7 +697,7 @@ function Bt(s) {
|
|
|
680
697
|
}
|
|
681
698
|
};
|
|
682
699
|
}
|
|
683
|
-
function
|
|
700
|
+
function Xt(s) {
|
|
684
701
|
let e = [];
|
|
685
702
|
const t = /* @__PURE__ */ new Set();
|
|
686
703
|
return {
|
|
@@ -697,7 +714,7 @@ function Ft(s) {
|
|
|
697
714
|
}
|
|
698
715
|
};
|
|
699
716
|
}
|
|
700
|
-
function
|
|
717
|
+
function Zt(s) {
|
|
701
718
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
|
|
702
719
|
let a = !1;
|
|
703
720
|
const r = /* @__PURE__ */ new Map();
|
|
@@ -718,15 +735,15 @@ function Ht(s) {
|
|
|
718
735
|
i();
|
|
719
736
|
},
|
|
720
737
|
areAttributesFetched(c, u) {
|
|
721
|
-
const
|
|
722
|
-
return
|
|
738
|
+
const l = r.get(c);
|
|
739
|
+
return l ? u.every((g) => l.has(g)) : !1;
|
|
723
740
|
},
|
|
724
741
|
markFetchedAttributes(c, u) {
|
|
725
|
-
for (const
|
|
726
|
-
const
|
|
727
|
-
for (const
|
|
728
|
-
|
|
729
|
-
r.set(
|
|
742
|
+
for (const l of c) {
|
|
743
|
+
const g = r.get(l) ?? /* @__PURE__ */ new Set();
|
|
744
|
+
for (const p of u)
|
|
745
|
+
g.add(p);
|
|
746
|
+
r.set(l, g);
|
|
730
747
|
}
|
|
731
748
|
},
|
|
732
749
|
markLoading(c) {
|
|
@@ -744,6 +761,14 @@ function Ht(s) {
|
|
|
744
761
|
isFetchFailed(c) {
|
|
745
762
|
return n.has(c);
|
|
746
763
|
},
|
|
764
|
+
clearFetchFailed(c) {
|
|
765
|
+
if (!c) {
|
|
766
|
+
n.clear();
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
for (const u of c)
|
|
770
|
+
n.delete(u);
|
|
771
|
+
},
|
|
747
772
|
markSubscribed(c) {
|
|
748
773
|
for (const u of c)
|
|
749
774
|
o.add(u);
|
|
@@ -773,18 +798,18 @@ function Ht(s) {
|
|
|
773
798
|
}
|
|
774
799
|
};
|
|
775
800
|
}
|
|
776
|
-
function
|
|
801
|
+
function en(s, e) {
|
|
777
802
|
return {
|
|
778
|
-
client:
|
|
779
|
-
message:
|
|
780
|
-
conversation:
|
|
781
|
-
contact:
|
|
782
|
-
group:
|
|
783
|
-
presence:
|
|
784
|
-
userInfo:
|
|
803
|
+
client: Jt(s, e),
|
|
804
|
+
message: Yt(e),
|
|
805
|
+
conversation: Qt(e),
|
|
806
|
+
contact: $t(e),
|
|
807
|
+
group: zt(e),
|
|
808
|
+
presence: Xt(e),
|
|
809
|
+
userInfo: Zt(e)
|
|
785
810
|
};
|
|
786
811
|
}
|
|
787
|
-
function
|
|
812
|
+
function tn() {
|
|
788
813
|
return {
|
|
789
814
|
enableContact: !0,
|
|
790
815
|
enableBlocklist: !0,
|
|
@@ -803,11 +828,11 @@ function jt() {
|
|
|
803
828
|
filterBlockedContacts: !0
|
|
804
829
|
};
|
|
805
830
|
}
|
|
806
|
-
function
|
|
831
|
+
function nn(s) {
|
|
807
832
|
if (s != null && s.fetchUserInfos)
|
|
808
833
|
return { fetchUserInfos: s.fetchUserInfos };
|
|
809
834
|
}
|
|
810
|
-
function
|
|
835
|
+
function sn(s) {
|
|
811
836
|
const e = s;
|
|
812
837
|
return {
|
|
813
838
|
// 经 domain.fetchContacts 读取:注入 contact.fetchContacts 时由 domain 委托覆盖
|
|
@@ -830,13 +855,13 @@ function qt(s) {
|
|
|
830
855
|
}
|
|
831
856
|
};
|
|
832
857
|
}
|
|
833
|
-
function
|
|
858
|
+
function rn(s) {
|
|
834
859
|
const e = s;
|
|
835
860
|
return {
|
|
836
861
|
fetchConversations: async () => ({ list: e.syncLocal(), cursor: void 0, hasMore: !1 })
|
|
837
862
|
};
|
|
838
863
|
}
|
|
839
|
-
function
|
|
864
|
+
function on(s) {
|
|
840
865
|
const e = s;
|
|
841
866
|
return {
|
|
842
867
|
// 经 domain.fetchGroups 读取:注入 group.fetchGroups 时由 domain 委托覆盖
|
|
@@ -903,7 +928,7 @@ function Jt(s) {
|
|
|
903
928
|
}
|
|
904
929
|
};
|
|
905
930
|
}
|
|
906
|
-
function
|
|
931
|
+
function an(s) {
|
|
907
932
|
const e = s.message, t = s.conversation;
|
|
908
933
|
return {
|
|
909
934
|
loadMessages: async (n, o, a, r) => {
|
|
@@ -922,7 +947,7 @@ function $t(s) {
|
|
|
922
947
|
// 契约的 needReadReceipt 未透传:domain sendLocation 无此参数(SDK 不支持位置消息回执)
|
|
923
948
|
sendLocation: (n, o, a, r, i, c) => e.sendLocation(n, o, a, r, i, c),
|
|
924
949
|
sendCustom: (n, o, a, r, i) => {
|
|
925
|
-
const c = r ? Object.fromEntries(Object.entries(r).map(([u,
|
|
950
|
+
const c = r ? Object.fromEntries(Object.entries(r).map(([u, l]) => [u, String(l)])) : void 0;
|
|
926
951
|
return e.sendCustom(n, o, a, c, i);
|
|
927
952
|
},
|
|
928
953
|
sendCmd: (n, o, a, r) => e.sendCmd(n, o, a, r),
|
|
@@ -942,7 +967,7 @@ function $t(s) {
|
|
|
942
967
|
}
|
|
943
968
|
};
|
|
944
969
|
}
|
|
945
|
-
function
|
|
970
|
+
function cn(s) {
|
|
946
971
|
const e = s;
|
|
947
972
|
return {
|
|
948
973
|
subscribe: async (t, n) => {
|
|
@@ -957,8 +982,9 @@ function Qt(s) {
|
|
|
957
982
|
}
|
|
958
983
|
};
|
|
959
984
|
}
|
|
960
|
-
function
|
|
985
|
+
function un(s) {
|
|
961
986
|
return {
|
|
987
|
+
readCachedUserInfos: (e) => s.readCachedUserInfos(e),
|
|
962
988
|
fetchUserInfos: async (e, t) => s.fetchUserInfos(e, t),
|
|
963
989
|
updateOwnInfo: async (e) => {
|
|
964
990
|
await s.updateOwnInfo(e);
|
|
@@ -975,7 +1001,41 @@ function zt(s) {
|
|
|
975
1001
|
getSubscribedUsers: async () => s.getSubscribedUsers()
|
|
976
1002
|
};
|
|
977
1003
|
}
|
|
978
|
-
|
|
1004
|
+
function dn(s) {
|
|
1005
|
+
return Object.fromEntries(
|
|
1006
|
+
Object.entries({
|
|
1007
|
+
userId: s.userId,
|
|
1008
|
+
nickname: s.nickname,
|
|
1009
|
+
avatarUrl: s.avatarUrl,
|
|
1010
|
+
mail: s.mail,
|
|
1011
|
+
phone: s.phone,
|
|
1012
|
+
gender: s.gender,
|
|
1013
|
+
sign: s.sign,
|
|
1014
|
+
birth: s.birth,
|
|
1015
|
+
ext: s.ext
|
|
1016
|
+
}).filter(([, e]) => e !== void 0)
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
function ln(s, e) {
|
|
1020
|
+
var t, n;
|
|
1021
|
+
try {
|
|
1022
|
+
const o = s.getCacheManager();
|
|
1023
|
+
if (!o)
|
|
1024
|
+
return [];
|
|
1025
|
+
const a = [], r = /* @__PURE__ */ new Map();
|
|
1026
|
+
for (const c of e) {
|
|
1027
|
+
const u = (t = o.getRuntimeUserInfo) == null ? void 0 : t.call(o, c, !1);
|
|
1028
|
+
u ? r.set(c, { ...u, userId: c }) : a.push(c);
|
|
1029
|
+
}
|
|
1030
|
+
const i = new Map(
|
|
1031
|
+
(((n = o.getUserInfoSummaries) == null ? void 0 : n.call(o, a, !1)) ?? []).map((c) => [c.userId, c])
|
|
1032
|
+
);
|
|
1033
|
+
return e.map((c) => r.get(c) ?? i.get(c)).filter((c) => !!c).map(dn);
|
|
1034
|
+
} catch {
|
|
1035
|
+
return [];
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
const fn = T("UIKit:MessageAdapter"), Be = {
|
|
979
1039
|
image: "[图片]",
|
|
980
1040
|
sticker: "[表情]",
|
|
981
1041
|
voice: "[语音]",
|
|
@@ -985,11 +1045,11 @@ const Yt = T("UIKit:MessageAdapter"), Ue = {
|
|
|
985
1045
|
combine: "[聊天记录]",
|
|
986
1046
|
multiBody: "[复合消息]",
|
|
987
1047
|
multiBodyMore: "...",
|
|
988
|
-
custom:
|
|
1048
|
+
custom: St,
|
|
989
1049
|
customFallback: "[自定义]",
|
|
990
1050
|
unknown: ""
|
|
991
1051
|
};
|
|
992
|
-
function
|
|
1052
|
+
function je(s) {
|
|
993
1053
|
if (s.event && typeof s.event == "string")
|
|
994
1054
|
return s.event;
|
|
995
1055
|
const e = s.params;
|
|
@@ -1000,35 +1060,35 @@ function ke(s) {
|
|
|
1000
1060
|
}
|
|
1001
1061
|
return "";
|
|
1002
1062
|
}
|
|
1003
|
-
function
|
|
1004
|
-
e ||
|
|
1063
|
+
function H(s, e) {
|
|
1064
|
+
e || fn.warn("[toUiMessage] currentUserId is empty, isSelf may be inaccurate", {
|
|
1005
1065
|
from: s.from,
|
|
1006
1066
|
conversationId: s.conversationId,
|
|
1007
1067
|
type: s.type
|
|
1008
1068
|
});
|
|
1009
|
-
const t =
|
|
1069
|
+
const t = G(s.from) === G(e), n = {
|
|
1010
1070
|
...s,
|
|
1011
1071
|
isSelf: t,
|
|
1012
1072
|
localId: s.msgLocalId,
|
|
1013
|
-
status: t && s.isPeerRead === !0 ?
|
|
1073
|
+
status: t && s.isPeerRead === !0 ? k.READ : s.sendStatus ?? k.SENT
|
|
1014
1074
|
};
|
|
1015
|
-
return
|
|
1075
|
+
return at(n.body) && n.body.messageList ? n.body = {
|
|
1016
1076
|
...n.body,
|
|
1017
|
-
messageList:
|
|
1018
|
-
} :
|
|
1077
|
+
messageList: qe([...n.body.messageList])
|
|
1078
|
+
} : _t(n.body) && (n.body = qe([...n.body])), n;
|
|
1019
1079
|
}
|
|
1020
|
-
function
|
|
1021
|
-
return s.map((t) =>
|
|
1080
|
+
function vs(s, e) {
|
|
1081
|
+
return s.map((t) => H(t, e));
|
|
1022
1082
|
}
|
|
1023
|
-
function
|
|
1083
|
+
function Ve(s) {
|
|
1024
1084
|
return {
|
|
1025
1085
|
...s,
|
|
1026
1086
|
isSelf: !1,
|
|
1027
1087
|
localId: s.msgLocalId,
|
|
1028
|
-
status: s.sendStatus ??
|
|
1088
|
+
status: s.sendStatus ?? k.SENT
|
|
1029
1089
|
};
|
|
1030
1090
|
}
|
|
1031
|
-
function
|
|
1091
|
+
function We(s, e) {
|
|
1032
1092
|
const t = s.from || "";
|
|
1033
1093
|
return {
|
|
1034
1094
|
...s,
|
|
@@ -1040,40 +1100,40 @@ function xe(s, e) {
|
|
|
1040
1100
|
conversationId: s.conversationId || (e == null ? void 0 : e.conversationId) || "",
|
|
1041
1101
|
conversationType: s.conversationType || (e == null ? void 0 : e.conversationType) || I.SINGLECHAT,
|
|
1042
1102
|
type: s.type || "unknown",
|
|
1043
|
-
sendStatus: s.sendStatus ??
|
|
1103
|
+
sendStatus: s.sendStatus ?? k.SENT,
|
|
1044
1104
|
ext: s.ext ?? {},
|
|
1045
1105
|
timestamp: s.timestamp ?? 0,
|
|
1046
1106
|
body: s.body || {},
|
|
1047
1107
|
isSelf: !1,
|
|
1048
1108
|
localId: s.msgLocalId || s.msgServerId,
|
|
1049
|
-
status: s.sendStatus ??
|
|
1109
|
+
status: s.sendStatus ?? k.SENT
|
|
1050
1110
|
};
|
|
1051
1111
|
}
|
|
1052
|
-
function
|
|
1112
|
+
function Is(s, e, t) {
|
|
1053
1113
|
var r;
|
|
1054
1114
|
if (!s)
|
|
1055
1115
|
return "";
|
|
1056
|
-
const n = t == null ? void 0 : t(
|
|
1116
|
+
const n = t == null ? void 0 : t(Ve(s));
|
|
1057
1117
|
if (n !== void 0)
|
|
1058
1118
|
return n;
|
|
1059
|
-
const o =
|
|
1060
|
-
return s.type === b.MULTI_BODY ?
|
|
1119
|
+
const o = st({ ...Be, ...e }), { body: a } = s;
|
|
1120
|
+
return s.type === b.MULTI_BODY ? rt(Ve(s), o) : At(a) ? a.content || "" : Et(a) ? ((r = s.ext) == null ? void 0 : r[ot.IS_STICKER]) === !0 ? o.sticker : o.image : it(a) ? o.voice : Gt(a) ? o.video : Tt(a) ? a.filename || o.file : Ut(a) ? o.location : Rt(a) ? o.custom[a.event || ""] || o.customFallback : Lt(a) ? "[命令]" : at(a) ? a.summary || o.combine : "";
|
|
1061
1121
|
}
|
|
1062
|
-
function
|
|
1122
|
+
function gn(s, e, t, n) {
|
|
1063
1123
|
var i;
|
|
1064
1124
|
if (!s)
|
|
1065
1125
|
return "";
|
|
1066
|
-
const o = t == null ? void 0 : t(
|
|
1126
|
+
const o = t == null ? void 0 : t(We(s, n));
|
|
1067
1127
|
if (o !== void 0)
|
|
1068
1128
|
return o;
|
|
1069
|
-
const a =
|
|
1129
|
+
const a = st({ ...Be, ...e }), r = Array.isArray(s.body) ? {} : s.body || {};
|
|
1070
1130
|
switch (s.type) {
|
|
1071
1131
|
case b.MULTI_BODY:
|
|
1072
|
-
return
|
|
1132
|
+
return rt(We(s, n), a);
|
|
1073
1133
|
case b.TEXT:
|
|
1074
1134
|
return r.content || r.summary || "";
|
|
1075
1135
|
case b.IMAGE:
|
|
1076
|
-
return ((i = s.ext) == null ? void 0 : i[
|
|
1136
|
+
return ((i = s.ext) == null ? void 0 : i[ot.IS_STICKER]) === !0 ? a.sticker : a.image;
|
|
1077
1137
|
case b.VOICE:
|
|
1078
1138
|
return a.voice;
|
|
1079
1139
|
case b.VIDEO:
|
|
@@ -1083,7 +1143,7 @@ function Xt(s, e, t, n) {
|
|
|
1083
1143
|
case b.LOCATION:
|
|
1084
1144
|
return a.location;
|
|
1085
1145
|
case b.CUSTOM: {
|
|
1086
|
-
const c =
|
|
1146
|
+
const c = je(r);
|
|
1087
1147
|
return a.custom[c] || a.customFallback;
|
|
1088
1148
|
}
|
|
1089
1149
|
case b.CMD:
|
|
@@ -1091,21 +1151,21 @@ function Xt(s, e, t, n) {
|
|
|
1091
1151
|
case b.COMBINE:
|
|
1092
1152
|
return r.summary || a.combine;
|
|
1093
1153
|
default: {
|
|
1094
|
-
const c =
|
|
1154
|
+
const c = je(r);
|
|
1095
1155
|
return c ? a.custom[c] || a.customFallback : r.content || r.summary || r.msg || "";
|
|
1096
1156
|
}
|
|
1097
1157
|
}
|
|
1098
1158
|
}
|
|
1099
|
-
function
|
|
1159
|
+
function Ms(s, e, t) {
|
|
1100
1160
|
return s.conversationId === e && s.conversationType === t;
|
|
1101
1161
|
}
|
|
1102
|
-
function
|
|
1103
|
-
return s.conversationType === I.GROUPCHAT ||
|
|
1162
|
+
function ys(s, e) {
|
|
1163
|
+
return s.conversationType === I.GROUPCHAT || G(s.from) === G(e) ? s.to : s.from;
|
|
1104
1164
|
}
|
|
1105
|
-
function
|
|
1106
|
-
return
|
|
1165
|
+
function L(s) {
|
|
1166
|
+
return et(s) ? s.toJSON() : s;
|
|
1107
1167
|
}
|
|
1108
|
-
const
|
|
1168
|
+
const mn = {
|
|
1109
1169
|
// 连接 / 网络
|
|
1110
1170
|
1: "error.unknown",
|
|
1111
1171
|
2: "error.network",
|
|
@@ -1192,28 +1252,28 @@ const Zt = {
|
|
|
1192
1252
|
1600: "error.userInfoSubscriptionLimitExceeded",
|
|
1193
1253
|
1601: "error.userInfoSubscriptionTargetLimitExceeded"
|
|
1194
1254
|
};
|
|
1195
|
-
function
|
|
1196
|
-
return
|
|
1255
|
+
function pn(s) {
|
|
1256
|
+
return et(s) ? mn[s.code] ?? null : null;
|
|
1197
1257
|
}
|
|
1198
|
-
function
|
|
1258
|
+
function hn(s) {
|
|
1199
1259
|
return s instanceof Error ? s.message : typeof s == "string" ? s : s && typeof s == "object" && "reason" in s && typeof s.reason == "string" ? s.reason : String(s);
|
|
1200
1260
|
}
|
|
1201
|
-
function
|
|
1261
|
+
function vn(s) {
|
|
1202
1262
|
const e = s.toLowerCase();
|
|
1203
1263
|
return e.includes("not connected") || e.includes("disconnected") || e.includes("connection is closed") || e.includes("chatclient is not connected") ? "error.notConnected" : e.includes("network") || e.includes("net::err") || e.includes("failed to fetch") || e.includes("network request failed") ? "error.network" : e.includes("timeout") || e.includes("timed out") ? "error.timeout" : "error.unknown";
|
|
1204
1264
|
}
|
|
1205
|
-
function
|
|
1206
|
-
const n =
|
|
1265
|
+
function Cs(s, e, t) {
|
|
1266
|
+
const n = pn(s);
|
|
1207
1267
|
if (n) {
|
|
1208
1268
|
const r = t(n);
|
|
1209
1269
|
if (r && r !== n)
|
|
1210
1270
|
return r;
|
|
1211
1271
|
}
|
|
1212
|
-
const o =
|
|
1272
|
+
const o = hn(s), a = vn(o);
|
|
1213
1273
|
return a !== "error.unknown" ? t(a) || t(e) || o : t(n || e) || o || "";
|
|
1214
1274
|
}
|
|
1215
|
-
const
|
|
1216
|
-
function
|
|
1275
|
+
const Ce = T("Combine"), be = T("History"), N = T("MessageDomain"), In = 150;
|
|
1276
|
+
function Mn(s) {
|
|
1217
1277
|
return new Promise((e) => {
|
|
1218
1278
|
if (typeof document > "u" || typeof URL.createObjectURL != "function") {
|
|
1219
1279
|
e(void 0);
|
|
@@ -1231,27 +1291,27 @@ function rn(s) {
|
|
|
1231
1291
|
}), n.addEventListener("error", () => a(void 0)), setTimeout(() => a(void 0), 5e3);
|
|
1232
1292
|
});
|
|
1233
1293
|
}
|
|
1234
|
-
const
|
|
1235
|
-
function
|
|
1294
|
+
const V = /* @__PURE__ */ new Set(), yn = 5e3;
|
|
1295
|
+
function Cn(s) {
|
|
1236
1296
|
for (const e of s)
|
|
1237
|
-
if (
|
|
1238
|
-
const t =
|
|
1239
|
-
t !== void 0 &&
|
|
1297
|
+
if (V.add(e), V.size > yn) {
|
|
1298
|
+
const t = V.values().next().value;
|
|
1299
|
+
t !== void 0 && V.delete(t);
|
|
1240
1300
|
}
|
|
1241
1301
|
}
|
|
1242
|
-
function
|
|
1302
|
+
function oe(s) {
|
|
1243
1303
|
Promise.resolve().then(s).catch((e) => N.warn("persistence 钩子执行失败(已忽略):", e));
|
|
1244
1304
|
}
|
|
1245
|
-
function
|
|
1246
|
-
const t =
|
|
1305
|
+
function bn(s, e) {
|
|
1306
|
+
const t = G(s.from) === G(e);
|
|
1247
1307
|
return {
|
|
1248
1308
|
...s,
|
|
1249
1309
|
isSelf: t,
|
|
1250
1310
|
localId: s.msgLocalId,
|
|
1251
|
-
status: t && s.isPeerRead === !0 ?
|
|
1311
|
+
status: t && s.isPeerRead === !0 ? k.READ : s.sendStatus ?? k.SENT
|
|
1252
1312
|
};
|
|
1253
1313
|
}
|
|
1254
|
-
function
|
|
1314
|
+
function wn(s, e) {
|
|
1255
1315
|
switch (e.type) {
|
|
1256
1316
|
case b.TEXT: {
|
|
1257
1317
|
const { type: t, ...n } = e;
|
|
@@ -1283,7 +1343,7 @@ function un(s, e) {
|
|
|
1283
1343
|
}
|
|
1284
1344
|
}
|
|
1285
1345
|
}
|
|
1286
|
-
class
|
|
1346
|
+
class Sn {
|
|
1287
1347
|
constructor(e, t, n = {}) {
|
|
1288
1348
|
this.client = e, this.store = t, this.options = n, this.failedMultiBodyMessages = /* @__PURE__ */ new Map();
|
|
1289
1349
|
}
|
|
@@ -1331,7 +1391,7 @@ class dn {
|
|
|
1331
1391
|
return this._send(i);
|
|
1332
1392
|
}
|
|
1333
1393
|
async sendVideo(e, t, n, o, a, r) {
|
|
1334
|
-
const i = typeof n == "string" ? void 0 : await
|
|
1394
|
+
const i = typeof n == "string" ? void 0 : await Mn(n), c = this.client.chatManager.createVideoMessage({
|
|
1335
1395
|
conversationId: e,
|
|
1336
1396
|
conversationType: t,
|
|
1337
1397
|
duration: o,
|
|
@@ -1384,13 +1444,13 @@ class dn {
|
|
|
1384
1444
|
messageList: r,
|
|
1385
1445
|
ext: i
|
|
1386
1446
|
});
|
|
1387
|
-
return
|
|
1447
|
+
return Ce.info("createCombineMessage done", {
|
|
1388
1448
|
items: r.length,
|
|
1389
1449
|
elapsedMs: Math.round(performance.now() - c)
|
|
1390
1450
|
}), this._send(u);
|
|
1391
1451
|
}
|
|
1392
1452
|
async sendMultiBody(e, t, n, o, a) {
|
|
1393
|
-
const r = n.map((c) =>
|
|
1453
|
+
const r = n.map((c) => wn(this.client.chatManager, c)), i = this.client.chatManager.createMultiBodyMessage({
|
|
1394
1454
|
conversationId: e,
|
|
1395
1455
|
conversationType: t,
|
|
1396
1456
|
bodies: r,
|
|
@@ -1435,22 +1495,22 @@ class dn {
|
|
|
1435
1495
|
const r = performance.now();
|
|
1436
1496
|
try {
|
|
1437
1497
|
const c = await this.client.chatManager.sendMessage(e, {
|
|
1438
|
-
onFileUploadProgress: (
|
|
1498
|
+
onFileUploadProgress: (g) => {
|
|
1439
1499
|
o += 1;
|
|
1440
|
-
const
|
|
1441
|
-
|
|
1500
|
+
const p = g.percent ?? 0, d = performance.now();
|
|
1501
|
+
p < 100 && d - a < In || (a = d, this.store.updateUploadProgress(t, p));
|
|
1442
1502
|
}
|
|
1443
1503
|
});
|
|
1444
|
-
n &&
|
|
1504
|
+
n && Ce.info("sendMessage done", {
|
|
1445
1505
|
elapsedMs: Math.round(performance.now() - r),
|
|
1446
1506
|
progressEvents: o
|
|
1447
1507
|
});
|
|
1448
|
-
const u =
|
|
1508
|
+
const u = H(c, this.currentUserId);
|
|
1449
1509
|
this.store.replaceWithSent(t, u);
|
|
1450
|
-
const
|
|
1451
|
-
return
|
|
1510
|
+
const l = (i = this.options.persistence) == null ? void 0 : i.saveMessage;
|
|
1511
|
+
return l && oe(() => l(_e(c))), c;
|
|
1452
1512
|
} catch (c) {
|
|
1453
|
-
n &&
|
|
1513
|
+
n && Ce.warn("sendMessage failed", {
|
|
1454
1514
|
elapsedMs: Math.round(performance.now() - r),
|
|
1455
1515
|
progressEvents: o,
|
|
1456
1516
|
error: c instanceof Error ? c.message : String(c)
|
|
@@ -1461,14 +1521,14 @@ class dn {
|
|
|
1461
1521
|
}
|
|
1462
1522
|
// ===== 历史消息 =====
|
|
1463
1523
|
async fetchHistory(e, t, n, o = 20) {
|
|
1464
|
-
var
|
|
1465
|
-
const a = (
|
|
1524
|
+
var l, g;
|
|
1525
|
+
const a = (l = this.options.messageRepository) == null ? void 0 : l.loadMessages;
|
|
1466
1526
|
if (a) {
|
|
1467
|
-
const
|
|
1527
|
+
const p = await a(e, t, n, o), d = p.list.filter((f) => f.type !== b.CMD).map((f) => bn(f, this.currentUserId));
|
|
1468
1528
|
return this.store.prependMessages(e, d), t === I.GROUPCHAT && this.fillGroupReadCounts(d, e), {
|
|
1469
1529
|
list: d,
|
|
1470
|
-
cursor:
|
|
1471
|
-
hasMore:
|
|
1530
|
+
cursor: p.cursor,
|
|
1531
|
+
hasMore: p.hasMore
|
|
1472
1532
|
};
|
|
1473
1533
|
}
|
|
1474
1534
|
const r = await this.client.chatManager.getHistoryMessages({
|
|
@@ -1478,7 +1538,7 @@ class dn {
|
|
|
1478
1538
|
cursor: n,
|
|
1479
1539
|
searchDirection: "up"
|
|
1480
1540
|
});
|
|
1481
|
-
|
|
1541
|
+
be.info("fetchHistory response", {
|
|
1482
1542
|
conversationId: e,
|
|
1483
1543
|
conversationType: t,
|
|
1484
1544
|
cursor: n,
|
|
@@ -1486,12 +1546,12 @@ class dn {
|
|
|
1486
1546
|
count: r.items.length,
|
|
1487
1547
|
cursorReturned: r.cursor,
|
|
1488
1548
|
hasMore: r.hasMore,
|
|
1489
|
-
items: r.items.map((
|
|
1549
|
+
items: r.items.map((p) => `${p.msgServerId || p.msgLocalId}|${p.type}|${p.from}->${p.to}|${p.timestamp}`)
|
|
1490
1550
|
});
|
|
1491
|
-
const i = r.items.filter((
|
|
1551
|
+
const i = r.items.filter((p) => p.type !== b.CMD), c = i.map((p) => H(p, this.currentUserId));
|
|
1492
1552
|
this.store.prependMessages(e, c);
|
|
1493
|
-
const u = (
|
|
1494
|
-
return u && i.length > 0 &&
|
|
1553
|
+
const u = (g = this.options.persistence) == null ? void 0 : g.saveMessages;
|
|
1554
|
+
return u && i.length > 0 && oe(() => u(i.map((p) => _e(p)))), t === I.GROUPCHAT && this.fillGroupReadCounts(c, e), {
|
|
1495
1555
|
list: c,
|
|
1496
1556
|
cursor: r.cursor,
|
|
1497
1557
|
hasMore: r.hasMore
|
|
@@ -1508,7 +1568,7 @@ class dn {
|
|
|
1508
1568
|
*/
|
|
1509
1569
|
async fillGroupReadCounts(e, t) {
|
|
1510
1570
|
const n = e.filter((r) => r.isSelf && !(r.groupReadCount ?? 0)), o = n.map((r) => r.msgServerId).filter((r) => !!r);
|
|
1511
|
-
if (
|
|
1571
|
+
if (be.info("fillGroupReadCounts scan", {
|
|
1512
1572
|
groupId: t,
|
|
1513
1573
|
total: e.length,
|
|
1514
1574
|
selfMissingCount: n.length,
|
|
@@ -1523,11 +1583,11 @@ class dn {
|
|
|
1523
1583
|
groupId: t,
|
|
1524
1584
|
messageIds: i
|
|
1525
1585
|
});
|
|
1526
|
-
|
|
1586
|
+
be.info("fillGroupReadCounts result", { groupId: t, batch: i, receipts: c });
|
|
1527
1587
|
for (const u of c)
|
|
1528
1588
|
u.count > 0 && this.store.updateMessageById(u.messageId, { groupReadCount: u.count });
|
|
1529
1589
|
} catch (c) {
|
|
1530
|
-
N.warn("[MessageDomain.fillGroupReadCounts] failed:", i,
|
|
1590
|
+
N.warn("[MessageDomain.fillGroupReadCounts] failed:", i, L(c));
|
|
1531
1591
|
}
|
|
1532
1592
|
}
|
|
1533
1593
|
}
|
|
@@ -1540,7 +1600,7 @@ class dn {
|
|
|
1540
1600
|
messageId: n
|
|
1541
1601
|
});
|
|
1542
1602
|
const o = (a = this.options.persistence) == null ? void 0 : a.markMessageRecalled;
|
|
1543
|
-
o &&
|
|
1603
|
+
o && oe(() => o(n, this.currentUserId));
|
|
1544
1604
|
}
|
|
1545
1605
|
/**
|
|
1546
1606
|
* 删除消息:移除当前用户的服务端漫游历史(SDK5 `removeHistoryMessages`)。
|
|
@@ -1557,7 +1617,7 @@ class dn {
|
|
|
1557
1617
|
messageIds: n
|
|
1558
1618
|
});
|
|
1559
1619
|
const o = (a = this.options.persistence) == null ? void 0 : a.deleteMessages;
|
|
1560
|
-
o &&
|
|
1620
|
+
o && oe(() => o([...n]));
|
|
1561
1621
|
}
|
|
1562
1622
|
/** 批量发送消息已读回执(统一 API,支持单聊/群聊) */
|
|
1563
1623
|
async markMessagesRead(e, t, n) {
|
|
@@ -1583,17 +1643,17 @@ class dn {
|
|
|
1583
1643
|
* 失败仅 warn 不阻塞进入会话(先标记后发送,失败回滚以便下次重试)。
|
|
1584
1644
|
*/
|
|
1585
1645
|
async sendPendingReadReceipts(e, t) {
|
|
1586
|
-
const o = this.store.getMessages(e).filter((a) => !a.isSelf && !
|
|
1646
|
+
const o = this.store.getMessages(e).filter((a) => !a.isSelf && !V.has(a.msgServerId)).map((a) => a.msgServerId).filter((a) => !!a);
|
|
1587
1647
|
if (o.length !== 0) {
|
|
1588
1648
|
N.info("[MessageDomain.sendPendingReadReceipts] 补发已读回执", { conversationId: e, conversationType: t, pendingCount: o.length, messageIds: o.slice(0, 5) });
|
|
1589
1649
|
for (const a of o)
|
|
1590
|
-
|
|
1650
|
+
V.add(a);
|
|
1591
1651
|
try {
|
|
1592
1652
|
await this.markMessagesRead(e, t, o);
|
|
1593
1653
|
} catch (a) {
|
|
1594
1654
|
for (const r of o)
|
|
1595
|
-
|
|
1596
|
-
N.warn("[MessageDomain.sendPendingReadReceipts] failed:", e,
|
|
1655
|
+
V.delete(r);
|
|
1656
|
+
N.warn("[MessageDomain.sendPendingReadReceipts] failed:", e, L(a));
|
|
1597
1657
|
}
|
|
1598
1658
|
}
|
|
1599
1659
|
}
|
|
@@ -1610,7 +1670,7 @@ class dn {
|
|
|
1610
1670
|
const o = (await this.client.chatManager.getPinnedMessageList({
|
|
1611
1671
|
conversationId: e,
|
|
1612
1672
|
conversationType: t
|
|
1613
|
-
})).items.map((a) =>
|
|
1673
|
+
})).items.map((a) => H(a.message, this.currentUserId));
|
|
1614
1674
|
return this.store.setPinnedMessages(e, o), o;
|
|
1615
1675
|
}
|
|
1616
1676
|
/** 翻译文本消息 */
|
|
@@ -1621,12 +1681,12 @@ class dn {
|
|
|
1621
1681
|
targetLanguages: t
|
|
1622
1682
|
});
|
|
1623
1683
|
} catch (n) {
|
|
1624
|
-
throw N.error("[MessageDomain.translateMessage] raw SDK error:",
|
|
1684
|
+
throw N.error("[MessageDomain.translateMessage] raw SDK error:", L(n)), n;
|
|
1625
1685
|
}
|
|
1626
1686
|
}
|
|
1627
1687
|
/** 语音消息转文字 */
|
|
1628
1688
|
async transcribeVoiceMessage(e, t) {
|
|
1629
|
-
if (!
|
|
1689
|
+
if (!it(e.body))
|
|
1630
1690
|
throw N.warn("[MessageDomain.transcribeVoiceMessage] not a voice message:", e), new Error("not a voice message");
|
|
1631
1691
|
const n = {
|
|
1632
1692
|
...e.body,
|
|
@@ -1664,7 +1724,7 @@ class dn {
|
|
|
1664
1724
|
messageIds: [n]
|
|
1665
1725
|
}), N.info("[MessageDomain.markRead] 已读回执发送成功", { conversationId: e, conversationType: t, messageId: n });
|
|
1666
1726
|
} catch (o) {
|
|
1667
|
-
throw N.warn("[MessageDomain.markRead] 已读回执发送失败", { conversationId: e, conversationType: t, messageId: n, error:
|
|
1727
|
+
throw N.warn("[MessageDomain.markRead] 已读回执发送失败", { conversationId: e, conversationType: t, messageId: n, error: L(o) }), o;
|
|
1668
1728
|
}
|
|
1669
1729
|
}
|
|
1670
1730
|
/** 获取群消息已读详情(自动翻页聚合全部已读成员) */
|
|
@@ -1702,12 +1762,12 @@ class dn {
|
|
|
1702
1762
|
});
|
|
1703
1763
|
}
|
|
1704
1764
|
}
|
|
1705
|
-
function
|
|
1706
|
-
var u,
|
|
1707
|
-
const t =
|
|
1765
|
+
function An(s, e) {
|
|
1766
|
+
var u, l, g, p, d, f;
|
|
1767
|
+
const t = gn(s.lastMessage, void 0, e == null ? void 0 : e.lastMessageTextResolver, {
|
|
1708
1768
|
conversationId: s.conversationId,
|
|
1709
1769
|
conversationType: s.conversationType
|
|
1710
|
-
}), n =
|
|
1770
|
+
}), n = G(((u = s.lastMessage) == null ? void 0 : u.from) || ""), o = G(((g = (l = s.lastMessage) == null ? void 0 : l.sender) == null ? void 0 : g.userId) || ""), a = o || n, r = a ? (p = e == null ? void 0 : e.resolveSenderName) == null ? void 0 : p.call(e, a) : void 0, i = ((f = (d = s.lastMessage) == null ? void 0 : d.sender) == null ? void 0 : f.nickname) || r || o || n || "", c = ct(s.conversationType, i, t);
|
|
1711
1771
|
return {
|
|
1712
1772
|
id: s.conversationId,
|
|
1713
1773
|
name: s.conversationName || s.conversationId,
|
|
@@ -1717,6 +1777,7 @@ function ln(s, e) {
|
|
|
1717
1777
|
lastMessageText: c,
|
|
1718
1778
|
// 保留群聊最后一条消息发送者 userId,供会话列表项在资料异步就绪后重新解析昵称
|
|
1719
1779
|
lastMessageFrom: a || void 0,
|
|
1780
|
+
lastMessageSenderName: i || void 0,
|
|
1720
1781
|
lastMessageTime: s.lastMessageAt,
|
|
1721
1782
|
isPinned: s.isPinned ?? !1,
|
|
1722
1783
|
pinnedTime: s.pinnedTimestamp,
|
|
@@ -1725,14 +1786,26 @@ function ln(s, e) {
|
|
|
1725
1786
|
remindType: s.remindType
|
|
1726
1787
|
};
|
|
1727
1788
|
}
|
|
1728
|
-
function
|
|
1729
|
-
return s.map((t) =>
|
|
1789
|
+
function se(s, e) {
|
|
1790
|
+
return s.map((t) => An(t, e));
|
|
1791
|
+
}
|
|
1792
|
+
const En = 20, Je = 3;
|
|
1793
|
+
function ve(s, e, t) {
|
|
1794
|
+
if (t.length <= En) {
|
|
1795
|
+
s.info(`getConversationList raw (${e})`, t);
|
|
1796
|
+
return;
|
|
1797
|
+
}
|
|
1798
|
+
s.info(`getConversationList raw (${e})`, {
|
|
1799
|
+
count: t.length,
|
|
1800
|
+
sampleSize: Je,
|
|
1801
|
+
sample: t.slice(0, Je)
|
|
1802
|
+
});
|
|
1730
1803
|
}
|
|
1731
|
-
const
|
|
1732
|
-
function
|
|
1804
|
+
const Ne = T("Conversation");
|
|
1805
|
+
function Gn(s) {
|
|
1733
1806
|
return [...s].sort((e, t) => e.isPinned !== t.isPinned ? e.isPinned ? -1 : 1 : e.isPinned ? (t.pinnedTime ?? 0) - (e.pinnedTime ?? 0) : (t.lastMessageTime ?? 0) - (e.lastMessageTime ?? 0));
|
|
1734
1807
|
}
|
|
1735
|
-
function
|
|
1808
|
+
function Tn(s, e) {
|
|
1736
1809
|
var o;
|
|
1737
1810
|
const t = {}, n = [];
|
|
1738
1811
|
for (const a of s) {
|
|
@@ -1742,10 +1815,10 @@ function fn(s, e) {
|
|
|
1742
1815
|
lastMessage: a.lastMessage
|
|
1743
1816
|
});
|
|
1744
1817
|
}
|
|
1745
|
-
n.length > 0 &&
|
|
1818
|
+
n.length > 0 && Ne.info(`raw snippets (${e})`, { typeCount: t, suspects: n });
|
|
1746
1819
|
}
|
|
1747
|
-
const
|
|
1748
|
-
class
|
|
1820
|
+
const Un = 1e3;
|
|
1821
|
+
class Rn {
|
|
1749
1822
|
constructor(e, t, n = {}) {
|
|
1750
1823
|
this.client = e, this.store = t, this.hooks = n, this.channelAckSentAt = /* @__PURE__ */ new Map();
|
|
1751
1824
|
}
|
|
@@ -1760,20 +1833,26 @@ class pn {
|
|
|
1760
1833
|
}
|
|
1761
1834
|
/** 从本地缓存读取会话列表 */
|
|
1762
1835
|
syncLocal() {
|
|
1836
|
+
var o, a;
|
|
1763
1837
|
const e = this.client.chatManager.getConversationList();
|
|
1764
|
-
|
|
1765
|
-
const t =
|
|
1838
|
+
ve(Ne, "syncLocal", e), Tn(e, "syncLocal");
|
|
1839
|
+
const t = Array.from(new Set(e.filter((r) => r.conversationType === I.GROUPCHAT).map((r) => {
|
|
1840
|
+
var i, c, u;
|
|
1841
|
+
return G(((c = (i = r.lastMessage) == null ? void 0 : i.sender) == null ? void 0 : c.userId) || ((u = r.lastMessage) == null ? void 0 : u.from) || "");
|
|
1842
|
+
}).filter(Boolean)));
|
|
1843
|
+
(a = (o = this.hooks).prefillUserInfo) == null || a.call(o, t);
|
|
1844
|
+
const n = se(e, {
|
|
1766
1845
|
resolveSenderName: this.hooks.resolveSenderName,
|
|
1767
1846
|
lastMessageTextResolver: this.hooks.lastMessageTextResolver
|
|
1768
1847
|
});
|
|
1769
|
-
return this.store.setList(
|
|
1848
|
+
return this.store.setList(n), n;
|
|
1770
1849
|
}
|
|
1771
1850
|
/** 仅按原始快照重算现有会话摘要,保留本地字段和本地独有会话 */
|
|
1772
1851
|
refreshPreviews() {
|
|
1773
1852
|
const e = this.store.conversationList ?? [];
|
|
1774
1853
|
if (e.length === 0)
|
|
1775
1854
|
return;
|
|
1776
|
-
const t = this.client.chatManager.getConversationList(), n =
|
|
1855
|
+
const t = this.client.chatManager.getConversationList(), n = se(t, {
|
|
1777
1856
|
resolveSenderName: this.hooks.resolveSenderName,
|
|
1778
1857
|
lastMessageTextResolver: this.hooks.lastMessageTextResolver
|
|
1779
1858
|
}), o = new Map(n.map((a) => [a.id, a.lastMessageText]));
|
|
@@ -1799,14 +1878,14 @@ class pn {
|
|
|
1799
1878
|
} while (a);
|
|
1800
1879
|
const r = this.store.conversationList ?? [], i = new Map(r.map((u) => [u.id, u])), c = /* @__PURE__ */ new Map();
|
|
1801
1880
|
for (const u of o) {
|
|
1802
|
-
const
|
|
1803
|
-
c.set(u.id,
|
|
1881
|
+
const l = i.get(u.id);
|
|
1882
|
+
c.set(u.id, l ? {
|
|
1804
1883
|
...u,
|
|
1805
|
-
name: (!u.name || u.name === u.id) &&
|
|
1806
|
-
avatar: u.avatar ||
|
|
1884
|
+
name: (!u.name || u.name === u.id) && l.name && l.name !== l.id ? l.name : u.name,
|
|
1885
|
+
avatar: u.avatar || l.avatar
|
|
1807
1886
|
} : u);
|
|
1808
1887
|
}
|
|
1809
|
-
this.store.setList(
|
|
1888
|
+
this.store.setList(Gn(Array.from(c.values())));
|
|
1810
1889
|
return;
|
|
1811
1890
|
}
|
|
1812
1891
|
await this.client.chatManager.refreshSessionList({ includeEmpty: e });
|
|
@@ -1897,20 +1976,20 @@ class pn {
|
|
|
1897
1976
|
if (n !== void 0 && n <= 0)
|
|
1898
1977
|
return;
|
|
1899
1978
|
const o = Date.now(), a = this.channelAckSentAt.get(e) || 0;
|
|
1900
|
-
o - a <
|
|
1979
|
+
o - a < Un || (this.channelAckSentAt.set(e, o), await this.markRead(e, t));
|
|
1901
1980
|
}
|
|
1902
1981
|
/** 加载更多会话:SDK5 当前无分页游标,直接返回本地列表 */
|
|
1903
1982
|
async loadMore(e) {
|
|
1904
1983
|
const t = this.client.chatManager.getConversationList();
|
|
1905
|
-
|
|
1906
|
-
const n =
|
|
1984
|
+
ve(Ne, "loadMore", t);
|
|
1985
|
+
const n = se(t, {
|
|
1907
1986
|
resolveSenderName: this.hooks.resolveSenderName,
|
|
1908
1987
|
lastMessageTextResolver: this.hooks.lastMessageTextResolver
|
|
1909
1988
|
});
|
|
1910
1989
|
this.store.setList(n);
|
|
1911
1990
|
}
|
|
1912
1991
|
}
|
|
1913
|
-
function
|
|
1992
|
+
function Ln(s) {
|
|
1914
1993
|
if ("userId" in s && s.userId !== void 0) {
|
|
1915
1994
|
const t = s;
|
|
1916
1995
|
return {
|
|
@@ -1930,10 +2009,10 @@ function hn(s) {
|
|
|
1930
2009
|
birth: e.birth,
|
|
1931
2010
|
phone: e.phone,
|
|
1932
2011
|
mail: e.mail,
|
|
1933
|
-
ext:
|
|
2012
|
+
ext: _n(e.ext)
|
|
1934
2013
|
};
|
|
1935
2014
|
}
|
|
1936
|
-
function
|
|
2015
|
+
function _n(s) {
|
|
1937
2016
|
if (s)
|
|
1938
2017
|
try {
|
|
1939
2018
|
const e = JSON.parse(s);
|
|
@@ -1942,16 +2021,16 @@ function vn(s) {
|
|
|
1942
2021
|
return;
|
|
1943
2022
|
}
|
|
1944
2023
|
}
|
|
1945
|
-
function
|
|
1946
|
-
return s.map((e) =>
|
|
2024
|
+
function ke(s) {
|
|
2025
|
+
return s.map((e) => Ln(e));
|
|
1947
2026
|
}
|
|
1948
|
-
class
|
|
2027
|
+
class Dn {
|
|
1949
2028
|
constructor(e, t, n = {}) {
|
|
1950
2029
|
this.client = e, this.store = t, this.options = n;
|
|
1951
2030
|
}
|
|
1952
2031
|
/** 获取当前内存中的联系人列表 */
|
|
1953
2032
|
syncLocal() {
|
|
1954
|
-
const e = this.client.contactManager.getContacts(), t =
|
|
2033
|
+
const e = this.client.contactManager.getContacts(), t = ke(e);
|
|
1955
2034
|
return this.store.setList(t), t;
|
|
1956
2035
|
}
|
|
1957
2036
|
/**
|
|
@@ -2007,7 +2086,7 @@ class In {
|
|
|
2007
2086
|
const a = await e();
|
|
2008
2087
|
return this.store.setBlocklist(a), a;
|
|
2009
2088
|
}
|
|
2010
|
-
const t = await this.client.contactManager.getBlocklist(), n =
|
|
2089
|
+
const t = await this.client.contactManager.getBlocklist(), n = ke(t);
|
|
2011
2090
|
return this.store.setBlocklist(n), n;
|
|
2012
2091
|
}
|
|
2013
2092
|
/** 批量加入黑名单 */
|
|
@@ -2019,7 +2098,7 @@ class In {
|
|
|
2019
2098
|
await this.client.contactManager.removeUserFromBlocklist({ userIds: e });
|
|
2020
2099
|
}
|
|
2021
2100
|
}
|
|
2022
|
-
function
|
|
2101
|
+
function Fe(s) {
|
|
2023
2102
|
const e = {
|
|
2024
2103
|
groupId: s.groupId,
|
|
2025
2104
|
groupName: s.name,
|
|
@@ -2033,10 +2112,10 @@ function Le(s) {
|
|
|
2033
2112
|
};
|
|
2034
2113
|
return s.role && (e.role = s.role), "avatarUrl" in s && (e.avatar = s.avatarUrl), "muteAllMembers" in s && (e.mute = s.muteAllMembers), "ownerId" in s && (e.owner = s.ownerId), "owner" in s && s.owner && (e.owner = s.owner.userId), "createdAt" in s && (e.created = s.createdAt), "messageBlocked" in s && (e.shieldgroup = s.messageBlocked), "ext" in s && (e.ext = s.ext), "inviteNeedConfirm" in s && (e.inviteNeedConfirm = s.inviteNeedConfirm), "joinedAt" in s && (e.joinedAt = s.joinedAt), e;
|
|
2035
2114
|
}
|
|
2036
|
-
function
|
|
2037
|
-
return s.map((e) =>
|
|
2115
|
+
function Ie(s) {
|
|
2116
|
+
return s.map((e) => Fe(e));
|
|
2038
2117
|
}
|
|
2039
|
-
function
|
|
2118
|
+
function Nn(s) {
|
|
2040
2119
|
const e = s.user, t = {
|
|
2041
2120
|
userId: e.userId,
|
|
2042
2121
|
nickname: e.nickname,
|
|
@@ -2045,17 +2124,17 @@ function Mn(s) {
|
|
|
2045
2124
|
};
|
|
2046
2125
|
return "joinedAt" in s && (t.joinedAt = s.joinedAt), "muteExpire" in s && s.muteExpire !== void 0 && (t.muteExpire = s.muteExpire), "muteDuration" in s && s.muteDuration !== void 0 && (t.muteDuration = s.muteDuration), t;
|
|
2047
2126
|
}
|
|
2048
|
-
function
|
|
2049
|
-
return s.map((e) =>
|
|
2127
|
+
function te(s) {
|
|
2128
|
+
return s.map((e) => Nn(e));
|
|
2050
2129
|
}
|
|
2051
|
-
const
|
|
2052
|
-
class
|
|
2130
|
+
const ie = T("UIKit:GroupDomain"), we = /* @__PURE__ */ new Map(), Se = /* @__PURE__ */ new Map(), Ae = /* @__PURE__ */ new Map();
|
|
2131
|
+
class kn {
|
|
2053
2132
|
constructor(e, t, n = {}) {
|
|
2054
2133
|
this.client = e, this.store = t, this.options = n;
|
|
2055
2134
|
}
|
|
2056
2135
|
/** 获取已加入群组本地列表 */
|
|
2057
2136
|
syncLocal() {
|
|
2058
|
-
const e = this.client.groupManager.getJoinedGroupList(), t =
|
|
2137
|
+
const e = this.client.groupManager.getJoinedGroupList(), t = Ie(e);
|
|
2059
2138
|
return this.store.setList(t), t;
|
|
2060
2139
|
}
|
|
2061
2140
|
/**
|
|
@@ -2078,23 +2157,23 @@ class yn {
|
|
|
2078
2157
|
}
|
|
2079
2158
|
/** 获取单个群详情 */
|
|
2080
2159
|
async fetchGroupInfo(e) {
|
|
2081
|
-
const t =
|
|
2160
|
+
const t = we.get(e);
|
|
2082
2161
|
if (t)
|
|
2083
2162
|
return t;
|
|
2084
2163
|
const n = (async () => {
|
|
2085
|
-
const o = await this.client.groupManager.getGroupInfo({ groupId: e }), a =
|
|
2164
|
+
const o = await this.client.groupManager.getGroupInfo({ groupId: e }), a = Fe(o);
|
|
2086
2165
|
return this.store.updateGroup(e, a), a;
|
|
2087
2166
|
})();
|
|
2088
|
-
|
|
2167
|
+
we.set(e, n);
|
|
2089
2168
|
try {
|
|
2090
2169
|
return await n;
|
|
2091
2170
|
} finally {
|
|
2092
|
-
|
|
2171
|
+
we.delete(e);
|
|
2093
2172
|
}
|
|
2094
2173
|
}
|
|
2095
2174
|
/** 批量获取群详情 */
|
|
2096
2175
|
async fetchGroupInfoList(e) {
|
|
2097
|
-
const t = await this.client.groupManager.getGroupInfoList({ groupIds: e }), n =
|
|
2176
|
+
const t = await this.client.groupManager.getGroupInfoList({ groupIds: e }), n = Ie(t);
|
|
2098
2177
|
return n.forEach((o) => this.store.updateGroup(o.groupId, o)), n;
|
|
2099
2178
|
}
|
|
2100
2179
|
/** 创建群组(注入 createGroup 时整体委托业务接管:不调 SDK、不写本地缓存,权威数据由业务源负责) */
|
|
@@ -2117,7 +2196,7 @@ class yn {
|
|
|
2117
2196
|
groupId: n.groupId,
|
|
2118
2197
|
groupName: e.name,
|
|
2119
2198
|
description: e.description,
|
|
2120
|
-
role:
|
|
2199
|
+
role: R.OWNER,
|
|
2121
2200
|
memberCount: (((a = e.memberIds) == null ? void 0 : a.length) ?? 0) + 1,
|
|
2122
2201
|
maxUsers: e.maxMembers,
|
|
2123
2202
|
public: e.public ?? !1,
|
|
@@ -2147,7 +2226,7 @@ class yn {
|
|
|
2147
2226
|
}
|
|
2148
2227
|
/** 拉取群成员列表 */
|
|
2149
2228
|
async fetchGroupMembers(e, t, n = 20) {
|
|
2150
|
-
const o = await this.client.groupManager.getGroupMemberList({ groupId: e, cursor: t, pageSize: n }), a =
|
|
2229
|
+
const o = await this.client.groupManager.getGroupMemberList({ groupId: e, cursor: t, pageSize: n }), a = te(o.items);
|
|
2151
2230
|
if (t)
|
|
2152
2231
|
this.store.appendGroupMembers(e, a);
|
|
2153
2232
|
else {
|
|
@@ -2157,47 +2236,48 @@ class yn {
|
|
|
2157
2236
|
} catch {
|
|
2158
2237
|
}
|
|
2159
2238
|
}
|
|
2160
|
-
|
|
2239
|
+
const r = new Map(this.store.getGroupMembers(e).map((c) => [c.userId, c]));
|
|
2240
|
+
return { list: a.map((c) => r.get(c.userId) ?? c), cursor: o.cursor, hasMore: o.hasMore ?? !1 };
|
|
2161
2241
|
}
|
|
2162
2242
|
/** 拉取并合并群管理员到成员缓存 */
|
|
2163
2243
|
async syncGroupAdmins(e) {
|
|
2164
2244
|
var o, a;
|
|
2165
|
-
const t =
|
|
2245
|
+
const t = Se.get(e);
|
|
2166
2246
|
if (t)
|
|
2167
2247
|
return t;
|
|
2168
2248
|
if ((a = (o = this.store).isGroupAdminSynced) != null && a.call(o, e))
|
|
2169
2249
|
return;
|
|
2170
2250
|
const n = (async () => {
|
|
2171
2251
|
var c, u;
|
|
2172
|
-
const r = await this.client.groupManager.getGroup(e).getAdmins(), i =
|
|
2173
|
-
(r || []).map((
|
|
2252
|
+
const r = await this.client.groupManager.getGroup(e).getAdmins(), i = te(
|
|
2253
|
+
(r || []).map((l) => ({ user: l, role: R.ADMIN }))
|
|
2174
2254
|
);
|
|
2175
2255
|
this.store.appendGroupMembers(e, i);
|
|
2176
|
-
for (const
|
|
2177
|
-
this.store.updateGroupMemberRole(e,
|
|
2256
|
+
for (const l of i)
|
|
2257
|
+
this.store.updateGroupMemberRole(e, l.userId, R.ADMIN);
|
|
2178
2258
|
(u = (c = this.store).markGroupAdminSynced) == null || u.call(c, e);
|
|
2179
2259
|
})();
|
|
2180
|
-
|
|
2260
|
+
Se.set(e, n);
|
|
2181
2261
|
try {
|
|
2182
2262
|
return await n;
|
|
2183
2263
|
} finally {
|
|
2184
|
-
|
|
2264
|
+
Se.delete(e);
|
|
2185
2265
|
}
|
|
2186
2266
|
}
|
|
2187
2267
|
/** 拉取群公告 */
|
|
2188
2268
|
async fetchGroupAnnouncement(e) {
|
|
2189
|
-
const t =
|
|
2269
|
+
const t = Ae.get(e);
|
|
2190
2270
|
if (t)
|
|
2191
2271
|
return t;
|
|
2192
2272
|
const n = (async () => {
|
|
2193
2273
|
const a = (await this.client.groupManager.getGroupAnnouncement({ groupId: e })).announcement ?? "";
|
|
2194
2274
|
return this.store.setGroupAnnouncement(e, a), a;
|
|
2195
2275
|
})();
|
|
2196
|
-
|
|
2276
|
+
Ae.set(e, n);
|
|
2197
2277
|
try {
|
|
2198
2278
|
return await n;
|
|
2199
2279
|
} finally {
|
|
2200
|
-
|
|
2280
|
+
Ae.delete(e);
|
|
2201
2281
|
}
|
|
2202
2282
|
}
|
|
2203
2283
|
/** 更新群公告 */
|
|
@@ -2218,11 +2298,11 @@ class yn {
|
|
|
2218
2298
|
}
|
|
2219
2299
|
/** 设置群管理员 */
|
|
2220
2300
|
async addGroupAdmin(e, t) {
|
|
2221
|
-
await this.client.groupManager.addGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t,
|
|
2301
|
+
await this.client.groupManager.addGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t, R.ADMIN);
|
|
2222
2302
|
}
|
|
2223
2303
|
/** 取消群管理员 */
|
|
2224
2304
|
async removeGroupAdmin(e, t) {
|
|
2225
|
-
await this.client.groupManager.removeGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t,
|
|
2305
|
+
await this.client.groupManager.removeGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t, R.MEMBER);
|
|
2226
2306
|
}
|
|
2227
2307
|
/** 接受群邀请 */
|
|
2228
2308
|
async acceptGroupInvitation(e) {
|
|
@@ -2253,25 +2333,25 @@ class yn {
|
|
|
2253
2333
|
* @param muteDuration 禁言时长,单位为毫秒;传 -1 表示永久禁言(SDK 5.0.0+ 语义)。
|
|
2254
2334
|
*/
|
|
2255
2335
|
async muteGroupMembers(e, t, n) {
|
|
2256
|
-
|
|
2336
|
+
ie.info("muteGroupMembers request raw", { groupId: e, userIds: t, muteDuration: n });
|
|
2257
2337
|
const o = await this.client.groupManager.getGroup(e).muteMembers({ userIds: t, muteDuration: n });
|
|
2258
|
-
|
|
2338
|
+
ie.info("muteGroupMembers response raw", o), this.store.addGroupMuteMembers(e, t);
|
|
2259
2339
|
}
|
|
2260
2340
|
/** 解除指定成员禁言 */
|
|
2261
2341
|
async unmuteGroupMembers(e, t) {
|
|
2262
|
-
|
|
2342
|
+
ie.info("unmuteGroupMembers request raw", { groupId: e, userIds: t });
|
|
2263
2343
|
const n = await this.client.groupManager.getGroup(e).unmuteMembers({ userIds: t });
|
|
2264
|
-
|
|
2344
|
+
ie.info("unmuteGroupMembers response raw", n), this.store.removeGroupMuteMembers(e, t);
|
|
2265
2345
|
}
|
|
2266
2346
|
/** 获取群禁言列表 */
|
|
2267
2347
|
async getGroupMuteList(e, t, n) {
|
|
2268
2348
|
const o = await this.client.groupManager.getGroup(e).getMuteList({ pageNum: t, pageSize: n }), a = Array.isArray(o) ? o : (o == null ? void 0 : o.data) ?? [];
|
|
2269
|
-
return this.store.setGroupMuteList(e,
|
|
2349
|
+
return this.store.setGroupMuteList(e, te(a)), o;
|
|
2270
2350
|
}
|
|
2271
2351
|
/** 获取群黑名单 */
|
|
2272
2352
|
async getGroupBlocklist(e, t, n) {
|
|
2273
2353
|
const o = await this.client.groupManager.getGroup(e).getBlocklist({ pageNum: t, pageSize: n }), a = Array.isArray(o) ? o : (o == null ? void 0 : o.data) ?? [];
|
|
2274
|
-
return this.store.setGroupBlocklist(e,
|
|
2354
|
+
return this.store.setGroupBlocklist(e, te(a)), o;
|
|
2275
2355
|
}
|
|
2276
2356
|
/** 将成员加入群黑名单 */
|
|
2277
2357
|
async blockGroupMembers(e, t) {
|
|
@@ -2284,7 +2364,7 @@ class yn {
|
|
|
2284
2364
|
/** 获取群白名单 */
|
|
2285
2365
|
async getGroupAllowlist(e) {
|
|
2286
2366
|
const t = await this.client.groupManager.getGroup(e).getAllowlist(), n = Array.isArray(t) ? t : (t == null ? void 0 : t.data) ?? [];
|
|
2287
|
-
return this.store.setGroupAllowlist(e,
|
|
2367
|
+
return this.store.setGroupAllowlist(e, te(n)), t;
|
|
2288
2368
|
}
|
|
2289
2369
|
/** 将成员加入群白名单 */
|
|
2290
2370
|
async addUsersToGroupAllowlist(e, t) {
|
|
@@ -2349,75 +2429,162 @@ class yn {
|
|
|
2349
2429
|
await this.client.groupManager.rejectInvitation({ groupId: e });
|
|
2350
2430
|
}
|
|
2351
2431
|
}
|
|
2352
|
-
|
|
2432
|
+
const Ee = T("UIKit:PresenceDomain"), Ge = 100;
|
|
2433
|
+
function Te(s, e) {
|
|
2434
|
+
const t = [];
|
|
2435
|
+
for (let n = 0; n < s.length; n += e)
|
|
2436
|
+
t.push(s.slice(n, n + e));
|
|
2437
|
+
return t;
|
|
2438
|
+
}
|
|
2439
|
+
function ft(s, e) {
|
|
2353
2440
|
if (!s)
|
|
2354
2441
|
return "offline";
|
|
2355
2442
|
if (!e)
|
|
2356
2443
|
return "online";
|
|
2357
|
-
const t = e.toLowerCase(), n =
|
|
2444
|
+
const t = e.toLowerCase(), n = ee.ONLINE.toLowerCase(), o = ee.AWAY.toLowerCase(), a = ee.BUSY.toLowerCase(), r = ee.DO_NOT_DISTURB.toLowerCase(), i = ee.OFFLINE.toLowerCase();
|
|
2358
2445
|
return t === n ? "online" : t === o ? "away" : t === a ? "busy" : t === r ? "doNotDisturb" : t === i ? "offline" : "custom";
|
|
2359
2446
|
}
|
|
2360
|
-
function
|
|
2447
|
+
function $e(s) {
|
|
2361
2448
|
const e = s.publisher || "";
|
|
2362
2449
|
if (!e)
|
|
2363
2450
|
return null;
|
|
2364
2451
|
const t = s.statusList || {}, n = Object.values(t).some((a) => Number(a) === 1), o = s.ext || "";
|
|
2365
2452
|
return {
|
|
2366
2453
|
userId: e,
|
|
2367
|
-
status:
|
|
2454
|
+
status: ft(n, o),
|
|
2368
2455
|
ext: o,
|
|
2369
2456
|
lastTime: s.latestTime || Date.now()
|
|
2370
2457
|
};
|
|
2371
2458
|
}
|
|
2372
|
-
class
|
|
2459
|
+
class On {
|
|
2373
2460
|
constructor(e, t, n = {}) {
|
|
2374
2461
|
this.client = e, this.store = t, this.options = n;
|
|
2375
2462
|
}
|
|
2376
|
-
/**
|
|
2463
|
+
/** 订阅用户在线状态(>100 人自动分片;任一分片失败会在其余分片完成后抛出首个错误) */
|
|
2377
2464
|
async subscribe(e, t = 7 * 24 * 60 * 60) {
|
|
2378
|
-
var
|
|
2379
|
-
const n = (
|
|
2465
|
+
var c;
|
|
2466
|
+
const n = (c = this.options.presenceRepository) == null ? void 0 : c.subscribe;
|
|
2380
2467
|
if (n)
|
|
2381
2468
|
return await n(e, t), [];
|
|
2382
2469
|
if (!this.client.isConnected)
|
|
2383
2470
|
return [];
|
|
2384
|
-
const o =
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
const
|
|
2390
|
-
|
|
2471
|
+
const o = Array.from(new Set(e.filter(Boolean)));
|
|
2472
|
+
if (o.length === 0)
|
|
2473
|
+
return [];
|
|
2474
|
+
const a = [];
|
|
2475
|
+
let r;
|
|
2476
|
+
const i = Te(o, Ge);
|
|
2477
|
+
for (const u of i)
|
|
2478
|
+
try {
|
|
2479
|
+
const l = await this.client.presenceManager.subscribePresence({
|
|
2480
|
+
userIds: u,
|
|
2481
|
+
expiry: t
|
|
2482
|
+
});
|
|
2483
|
+
this.store.setSubscribed(u);
|
|
2484
|
+
const g = l.map($e).filter((p) => p !== null);
|
|
2485
|
+
this.store.updateBatch(g), a.push(...g);
|
|
2486
|
+
} catch (l) {
|
|
2487
|
+
r === void 0 && (r = l, Ee.warn("[PresenceDomain] subscribePresence chunk failed:", {
|
|
2488
|
+
chunkSize: u.length,
|
|
2489
|
+
chunks: i.length
|
|
2490
|
+
}));
|
|
2491
|
+
}
|
|
2492
|
+
if (r !== void 0)
|
|
2493
|
+
throw r;
|
|
2494
|
+
return a;
|
|
2391
2495
|
}
|
|
2392
|
-
/**
|
|
2496
|
+
/** 取消订阅(>100 人分片;清理语义,分片失败仅告警不抛出,避免调用方 void 时产生未处理拒绝) */
|
|
2393
2497
|
async unsubscribe(e) {
|
|
2394
|
-
var
|
|
2395
|
-
const t = (
|
|
2498
|
+
var o;
|
|
2499
|
+
const t = (o = this.options.presenceRepository) == null ? void 0 : o.unsubscribe;
|
|
2396
2500
|
if (t) {
|
|
2397
2501
|
await t(e);
|
|
2398
2502
|
return;
|
|
2399
2503
|
}
|
|
2400
|
-
this.client.isConnected
|
|
2504
|
+
if (!this.client.isConnected)
|
|
2505
|
+
return;
|
|
2506
|
+
const n = Array.from(new Set(e.filter(Boolean)));
|
|
2507
|
+
for (const a of Te(n, Ge))
|
|
2508
|
+
try {
|
|
2509
|
+
await this.client.presenceManager.unsubscribePresence({ userIds: a });
|
|
2510
|
+
} catch (r) {
|
|
2511
|
+
Ee.warn("[PresenceDomain] unsubscribePresence chunk failed:", {
|
|
2512
|
+
chunkSize: a.length,
|
|
2513
|
+
err: r
|
|
2514
|
+
});
|
|
2515
|
+
}
|
|
2401
2516
|
}
|
|
2402
|
-
/**
|
|
2517
|
+
/** 主动查询在线状态(>100 人分片;任一分片失败会在其余分片完成后抛出首个错误) */
|
|
2403
2518
|
async fetchStatus(e) {
|
|
2404
|
-
var
|
|
2405
|
-
const t = (
|
|
2519
|
+
var i;
|
|
2520
|
+
const t = (i = this.options.presenceRepository) == null ? void 0 : i.fetchStatus;
|
|
2406
2521
|
if (t) {
|
|
2407
|
-
const
|
|
2408
|
-
return this.store.updateBatch(
|
|
2522
|
+
const c = await t(e);
|
|
2523
|
+
return this.store.updateBatch(c), c;
|
|
2409
2524
|
}
|
|
2410
2525
|
if (!this.client.isConnected)
|
|
2411
2526
|
return [];
|
|
2412
|
-
const
|
|
2413
|
-
|
|
2527
|
+
const n = Array.from(new Set(e.filter(Boolean)));
|
|
2528
|
+
if (n.length === 0)
|
|
2529
|
+
return [];
|
|
2530
|
+
const o = [];
|
|
2531
|
+
let a;
|
|
2532
|
+
const r = Te(n, Ge);
|
|
2533
|
+
for (const c of r)
|
|
2534
|
+
try {
|
|
2535
|
+
const l = (await this.client.presenceManager.getPresenceStatus({ userIds: c })).map($e).filter((g) => g !== null);
|
|
2536
|
+
this.store.updateBatch(l), o.push(...l);
|
|
2537
|
+
} catch (u) {
|
|
2538
|
+
a === void 0 && (a = u, Ee.warn("[PresenceDomain] getPresenceStatus chunk failed:", {
|
|
2539
|
+
chunkSize: c.length,
|
|
2540
|
+
chunks: r.length
|
|
2541
|
+
}));
|
|
2542
|
+
}
|
|
2543
|
+
if (a !== void 0)
|
|
2544
|
+
throw a;
|
|
2545
|
+
return o;
|
|
2414
2546
|
}
|
|
2415
2547
|
/** 发布自定义在线状态 */
|
|
2416
2548
|
async publish(e) {
|
|
2417
2549
|
this.client.isConnected && await this.client.presenceManager.publishPresence({ customStatus: e });
|
|
2418
2550
|
}
|
|
2419
2551
|
}
|
|
2420
|
-
const
|
|
2552
|
+
const P = T("UIKit:UserInfoDomain"), F = 100, xn = 300;
|
|
2553
|
+
function Pn(s) {
|
|
2554
|
+
var a;
|
|
2555
|
+
const e = s, t = ((a = e == null ? void 0 : e.details) == null ? void 0 : a.httpStatus) ?? (e == null ? void 0 : e.httpStatus);
|
|
2556
|
+
if (t === 429 || t !== void 0 && t >= 500)
|
|
2557
|
+
return !0;
|
|
2558
|
+
if (t !== void 0)
|
|
2559
|
+
return !1;
|
|
2560
|
+
const n = Number(e == null ? void 0 : e.code);
|
|
2561
|
+
if ([2, 301, 302, 303, 304].includes(n))
|
|
2562
|
+
return !0;
|
|
2563
|
+
if ((e == null ? void 0 : e.code) !== void 0)
|
|
2564
|
+
return !1;
|
|
2565
|
+
const o = s instanceof Error ? s.message : String(s ?? "");
|
|
2566
|
+
return /network|failed to fetch|timeout|timed out/i.test(o);
|
|
2567
|
+
}
|
|
2568
|
+
function Bn(s) {
|
|
2569
|
+
var t, n, o;
|
|
2570
|
+
const e = s;
|
|
2571
|
+
return {
|
|
2572
|
+
code: e == null ? void 0 : e.code,
|
|
2573
|
+
httpStatus: ((t = e == null ? void 0 : e.details) == null ? void 0 : t.httpStatus) ?? (e == null ? void 0 : e.httpStatus),
|
|
2574
|
+
reason: ((n = e == null ? void 0 : e.details) == null ? void 0 : n.reasonKey) ?? ((o = e == null ? void 0 : e.details) == null ? void 0 : o.reason) ?? (e == null ? void 0 : e.reason),
|
|
2575
|
+
message: e == null ? void 0 : e.message
|
|
2576
|
+
};
|
|
2577
|
+
}
|
|
2578
|
+
async function Fn(s) {
|
|
2579
|
+
try {
|
|
2580
|
+
return await s();
|
|
2581
|
+
} catch (e) {
|
|
2582
|
+
if (!Pn(e))
|
|
2583
|
+
throw e;
|
|
2584
|
+
return await new Promise((t) => setTimeout(t, xn)), s();
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
const Ue = [
|
|
2421
2588
|
"nickname",
|
|
2422
2589
|
"avatarUrl",
|
|
2423
2590
|
"mail",
|
|
@@ -2427,10 +2594,29 @@ const F = T("UIKit:UserInfoDomain"), Be = [
|
|
|
2427
2594
|
"birth",
|
|
2428
2595
|
"ext"
|
|
2429
2596
|
];
|
|
2430
|
-
class
|
|
2597
|
+
class Hn {
|
|
2431
2598
|
constructor(e, t, n = {}, o) {
|
|
2432
2599
|
this.client = e, this.store = t, this.userInfoRepository = n, this.onSubscriptionPermissionError = o, this.handlerId = "uikit-user-info", this.subscribeQueue = [], this.subscribeFlushPromise = null, this.fetchQueue = [], this.fetchFlushPromise = null, this.hasLoggedPermissionError = !1;
|
|
2433
2600
|
}
|
|
2601
|
+
readCachedUserInfos(e) {
|
|
2602
|
+
var t, n;
|
|
2603
|
+
try {
|
|
2604
|
+
return ((n = (t = this.userInfoRepository).readCachedUserInfos) == null ? void 0 : n.call(t, Array.from(new Set(e.filter(Boolean))))) ?? [];
|
|
2605
|
+
} catch {
|
|
2606
|
+
return [];
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
prefillUserInfos(e) {
|
|
2610
|
+
const t = this.readCachedUserInfos(e);
|
|
2611
|
+
if (t.length === 0)
|
|
2612
|
+
return [];
|
|
2613
|
+
this.store.setUserInfos(t);
|
|
2614
|
+
for (const n of t) {
|
|
2615
|
+
const o = Ue.filter((a) => n[a] !== void 0);
|
|
2616
|
+
o.length > 0 && this.store.markFetchedAttributes([n.userId], o);
|
|
2617
|
+
}
|
|
2618
|
+
return t;
|
|
2619
|
+
}
|
|
2434
2620
|
/**
|
|
2435
2621
|
* 启动用户资料变更事件监听。应在 SDK 初始化完成后调用。
|
|
2436
2622
|
*/
|
|
@@ -2439,19 +2625,17 @@ class Cn {
|
|
|
2439
2625
|
}
|
|
2440
2626
|
/**
|
|
2441
2627
|
* 批量获取用户资料;已缓存(且请求属性已覆盖)或正在加载中的 userId 会被跳过。
|
|
2442
|
-
*
|
|
2443
|
-
* flush 时合并所有调用的 userIds(去重)与 attributes
|
|
2628
|
+
* 同一事件循环内的多次调用会先微任务合批,再按 100 人顺序分片(与 subscribe 合批同构):
|
|
2629
|
+
* flush 时合并所有调用的 userIds(去重)与 attributes(并集),
|
|
2444
2630
|
* 每个原始调用各自 resolve 回「自己请求的 userIds 对应的 UserInfo[]」(从 store 缓存读回)。
|
|
2445
2631
|
* @param userIds 目标用户 ID 列表
|
|
2446
2632
|
* @param attributes 需要查询的属性,默认全量 8 个属性
|
|
2447
2633
|
*/
|
|
2448
|
-
async fetchUserInfos(e, t =
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
this.fetchQueue.push({ userIds: n, attributes: t, resolve: o }), this.scheduleFetchFlush();
|
|
2454
|
-
});
|
|
2634
|
+
async fetchUserInfos(e, t = Ue, n) {
|
|
2635
|
+
const o = Array.from(new Set(e.filter(Boolean)));
|
|
2636
|
+
return o.length === 0 ? [] : this.client.isConnected ? new Promise((a) => {
|
|
2637
|
+
this.fetchQueue.push({ userIds: o, attributes: t, options: n, resolve: a }), this.scheduleFetchFlush();
|
|
2638
|
+
}) : (this.store.markFetchFailed(o), []);
|
|
2455
2639
|
}
|
|
2456
2640
|
scheduleFetchFlush() {
|
|
2457
2641
|
this.fetchFlushPromise || (this.fetchFlushPromise = Promise.resolve().then(() => this.flushFetchQueue()));
|
|
@@ -2460,31 +2644,61 @@ class Cn {
|
|
|
2460
2644
|
const e = this.fetchQueue;
|
|
2461
2645
|
this.fetchQueue = [];
|
|
2462
2646
|
try {
|
|
2463
|
-
const t = e.
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2647
|
+
const t = Array.from(new Set(e.flatMap((l) => l.userIds.filter(
|
|
2648
|
+
(g) => !this.store.areAttributesFetched(g, l.attributes) && !this.store.isLoading(g) && !this.store.isFetchFailed(g)
|
|
2649
|
+
)))), n = this.prefillUserInfos(t).length, o = e.map((l) => ({
|
|
2650
|
+
...l,
|
|
2651
|
+
missingIds: l.userIds.filter(
|
|
2652
|
+
(g) => !this.store.areAttributesFetched(g, l.attributes) && !this.store.isLoading(g) && !this.store.isFetchFailed(g)
|
|
2467
2653
|
)
|
|
2468
|
-
})),
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2654
|
+
})), a = Array.from(new Set(o.flatMap((l) => l.missingIds))), r = Array.from(new Set(e.flatMap((l) => l.attributes))), i = Array.from(new Set(e.map((l) => {
|
|
2655
|
+
var g;
|
|
2656
|
+
return ((g = l.options) == null ? void 0 : g.source) ?? "unknown";
|
|
2657
|
+
}))), c = i.join(",");
|
|
2658
|
+
let u = 0;
|
|
2659
|
+
if (a.length > 0)
|
|
2660
|
+
for (let l = 0; l < a.length; l += F)
|
|
2661
|
+
await this.fetchChunk(
|
|
2662
|
+
a.slice(l, l + F),
|
|
2663
|
+
r,
|
|
2664
|
+
{ source: c },
|
|
2665
|
+
() => {
|
|
2666
|
+
u += 1;
|
|
2667
|
+
}
|
|
2668
|
+
);
|
|
2669
|
+
P.info("[UserInfoDomain] fetch", {
|
|
2670
|
+
sources: i,
|
|
2671
|
+
prefilled: n,
|
|
2672
|
+
requested: new Set(e.flatMap((l) => l.userIds)).size,
|
|
2673
|
+
missing: a.length,
|
|
2674
|
+
chunks: Math.ceil(a.length / F),
|
|
2675
|
+
failedChunks: u
|
|
2676
|
+
});
|
|
2677
|
+
for (const l of o)
|
|
2678
|
+
l.resolve(
|
|
2679
|
+
l.userIds.map((g) => this.store.getUserInfo(g)).filter((g) => !!g)
|
|
2483
2680
|
);
|
|
2484
2681
|
} finally {
|
|
2485
2682
|
this.fetchFlushPromise = null, this.fetchQueue.length > 0 && this.scheduleFetchFlush();
|
|
2486
2683
|
}
|
|
2487
2684
|
}
|
|
2685
|
+
async fetchChunk(e, t, n, o) {
|
|
2686
|
+
this.store.markLoading(e);
|
|
2687
|
+
try {
|
|
2688
|
+
const a = await Fn(() => this.userInfoRepository.fetchUserInfos ? this.fetchFromRepository(e) : this.fetchFromSdk(e, t)), r = new Set(a.map((u) => u.userId).filter(Boolean)), i = e.filter((u) => !r.has(u));
|
|
2689
|
+
i.length > 0 && this.store.markFetchFailed(i), this.store.setUserInfos(a);
|
|
2690
|
+
const c = e.filter((u) => r.has(u));
|
|
2691
|
+
return c.length > 0 && this.store.markFetchedAttributes(c, t), a;
|
|
2692
|
+
} catch (a) {
|
|
2693
|
+
return o == null || o(), P.warn("[UserInfoDomain] chunk failed", {
|
|
2694
|
+
source: (n == null ? void 0 : n.source) ?? "unknown",
|
|
2695
|
+
chunkSize: e.length,
|
|
2696
|
+
...Bn(a)
|
|
2697
|
+
}), this.store.markFetchFailed(e), [];
|
|
2698
|
+
} finally {
|
|
2699
|
+
this.store.markLoaded(e);
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2488
2702
|
async fetchFromSdk(e, t) {
|
|
2489
2703
|
const n = await this.client.userInfoManager.getUserInfoByAttribute({
|
|
2490
2704
|
userIds: e,
|
|
@@ -2507,25 +2721,41 @@ class Cn {
|
|
|
2507
2721
|
}
|
|
2508
2722
|
/**
|
|
2509
2723
|
* 批量订阅陌生人资料变更通知。
|
|
2510
|
-
*
|
|
2724
|
+
* 同一事件循环内的多次调用先合批,再按 100 人顺序分片;
|
|
2511
2725
|
* 若服务端返回无权限,则自动熔断后续订阅并缓存失败用户,避免重复请求与控制台警告刷屏。
|
|
2512
2726
|
*/
|
|
2513
|
-
async subscribeUserInfos(e) {
|
|
2727
|
+
async subscribeUserInfos(e, t) {
|
|
2514
2728
|
if (!this.client.isConnected || this.store.isSubscriptionDisabled())
|
|
2515
2729
|
return;
|
|
2516
|
-
const
|
|
2517
|
-
(
|
|
2730
|
+
const n = Array.from(new Set(e.filter(Boolean))).filter(
|
|
2731
|
+
(o) => !this.store.isSubscribed(o) && !this.store.isSubscribeFailed(o)
|
|
2518
2732
|
);
|
|
2519
|
-
if (
|
|
2520
|
-
return this.subscribeQueue.push(
|
|
2733
|
+
if (n.length !== 0)
|
|
2734
|
+
return this.subscribeQueue.push({ userIds: n, options: t }), this.subscribeFlushPromise ? this.subscribeFlushPromise : (this.subscribeFlushPromise = Promise.resolve().then(() => this.flushSubscribeQueue()), this.subscribeFlushPromise);
|
|
2521
2735
|
}
|
|
2522
2736
|
async flushSubscribeQueue() {
|
|
2523
|
-
const e =
|
|
2737
|
+
const e = this.subscribeQueue;
|
|
2524
2738
|
this.subscribeQueue = [];
|
|
2739
|
+
const t = Array.from(new Set(e.flatMap((o) => o.userIds))), n = Array.from(new Set(e.map((o) => {
|
|
2740
|
+
var a;
|
|
2741
|
+
return ((a = o.options) == null ? void 0 : a.source) ?? "unknown";
|
|
2742
|
+
})));
|
|
2743
|
+
P.info("[UserInfoDomain] subscribe", {
|
|
2744
|
+
sources: n,
|
|
2745
|
+
requested: t.length,
|
|
2746
|
+
chunks: Math.ceil(t.length / F)
|
|
2747
|
+
});
|
|
2525
2748
|
try {
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2749
|
+
for (let o = 0; o < t.length; o += F) {
|
|
2750
|
+
const a = t.slice(o, o + F);
|
|
2751
|
+
try {
|
|
2752
|
+
await this.client.userInfoManager.subscribeUsersInfo({ userIds: a }), this.store.markSubscribed(a);
|
|
2753
|
+
} catch (r) {
|
|
2754
|
+
const i = this.isPermissionError(r);
|
|
2755
|
+
if (this.handleSubscribeError(r, a), i)
|
|
2756
|
+
break;
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2529
2759
|
} finally {
|
|
2530
2760
|
this.subscribeFlushPromise = null, this.subscribeQueue.length > 0 && (this.subscribeFlushPromise = Promise.resolve().then(() => this.flushSubscribeQueue()));
|
|
2531
2761
|
}
|
|
@@ -2533,30 +2763,28 @@ class Cn {
|
|
|
2533
2763
|
handleSubscribeError(e, t) {
|
|
2534
2764
|
var n;
|
|
2535
2765
|
if (this.isPermissionError(e)) {
|
|
2536
|
-
this.store.markSubscribeFailed(t), this.store.disableSubscription(), this.hasLoggedPermissionError || (this.hasLoggedPermissionError = !0,
|
|
2766
|
+
this.store.markSubscribeFailed(t), this.store.disableSubscription(), this.hasLoggedPermissionError || (this.hasLoggedPermissionError = !0, P.warn(
|
|
2537
2767
|
"[UserInfoDomain] 用户资料订阅无权限或服务未开通,已自动关闭订阅。后续陌生人资料变更将不会实时推送,拉取到的资料仍可正常展示。",
|
|
2538
|
-
|
|
2768
|
+
L(e)
|
|
2539
2769
|
), (n = this.onSubscriptionPermissionError) == null || n.call(this));
|
|
2540
2770
|
return;
|
|
2541
2771
|
}
|
|
2542
|
-
this.store.markSubscribeFailed(t),
|
|
2772
|
+
this.store.markSubscribeFailed(t), P.warn("[UserInfoDomain] subscribeUserInfos failed:", L(e));
|
|
2543
2773
|
}
|
|
2544
2774
|
isPermissionError(e) {
|
|
2545
2775
|
var n, o;
|
|
2546
2776
|
if (!e || typeof e != "object")
|
|
2547
2777
|
return !1;
|
|
2548
2778
|
const t = e;
|
|
2549
|
-
return t.code === 210 || ((n = t.details) == null ? void 0 : n.httpStatus) === 403 || ((o = t.details) == null ? void 0 : o.reason) === "service_forbidden";
|
|
2779
|
+
return t.code === 210 || t.code === 1600 || ((n = t.details) == null ? void 0 : n.httpStatus) === 403 || ((o = t.details) == null ? void 0 : o.reason) === "service_forbidden";
|
|
2550
2780
|
}
|
|
2551
2781
|
/**
|
|
2552
2782
|
* 获取当前登录用户自己的资料(默认全量属性,保证签名等登录后回显)。
|
|
2553
2783
|
*/
|
|
2554
|
-
async fetchOwnInfo(e =
|
|
2555
|
-
const
|
|
2556
|
-
if (
|
|
2557
|
-
return;
|
|
2558
|
-
const [n] = await this.fetchUserInfos([t], e);
|
|
2559
|
-
return n;
|
|
2784
|
+
async fetchOwnInfo(e = Ue, t) {
|
|
2785
|
+
const n = this.client.currentUserId;
|
|
2786
|
+
if (n)
|
|
2787
|
+
return this.client.isConnected ? (!this.store.isLoading(n) && !this.store.isFetchFailed(n) && this.prefillUserInfos([n]), this.store.areAttributesFetched(n, e) || this.store.isLoading(n) || this.store.isFetchFailed(n) ? this.store.getUserInfo(n) : (await this.fetchChunk([n], e, t), this.store.getUserInfo(n))) : (this.store.markFetchFailed([n]), this.store.getUserInfo(n));
|
|
2560
2788
|
}
|
|
2561
2789
|
/**
|
|
2562
2790
|
* 更新当前登录用户资料。
|
|
@@ -2567,7 +2795,7 @@ class Cn {
|
|
|
2567
2795
|
const t = await this.client.userInfoManager.updateOwnInfo(e);
|
|
2568
2796
|
return this.store.setUserInfo(t), t;
|
|
2569
2797
|
} catch (t) {
|
|
2570
|
-
|
|
2798
|
+
P.warn("[UserInfoDomain] updateOwnInfo failed:", L(t));
|
|
2571
2799
|
return;
|
|
2572
2800
|
}
|
|
2573
2801
|
}
|
|
@@ -2580,7 +2808,7 @@ class Cn {
|
|
|
2580
2808
|
const n = await this.client.userInfoManager.updateOwnInfoByAttribute(e, t);
|
|
2581
2809
|
return this.store.setUserInfo(n), n;
|
|
2582
2810
|
} catch (n) {
|
|
2583
|
-
|
|
2811
|
+
P.warn("[UserInfoDomain] updateOwnInfoByAttribute failed:", L(n));
|
|
2584
2812
|
return;
|
|
2585
2813
|
}
|
|
2586
2814
|
}
|
|
@@ -2592,10 +2820,13 @@ class Cn {
|
|
|
2592
2820
|
return;
|
|
2593
2821
|
const t = Array.from(new Set(e.filter(Boolean)));
|
|
2594
2822
|
if (t.length !== 0)
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2823
|
+
for (let n = 0; n < t.length; n += F) {
|
|
2824
|
+
const o = t.slice(n, n + F);
|
|
2825
|
+
try {
|
|
2826
|
+
await this.client.userInfoManager.unsubscribeUsersInfo({ userIds: o }), this.store.markUnsubscribed(o);
|
|
2827
|
+
} catch (a) {
|
|
2828
|
+
P.warn("[UserInfoDomain] unsubscribeUsersInfo failed:", L(a));
|
|
2829
|
+
}
|
|
2599
2830
|
}
|
|
2600
2831
|
}
|
|
2601
2832
|
/**
|
|
@@ -2607,7 +2838,7 @@ class Cn {
|
|
|
2607
2838
|
try {
|
|
2608
2839
|
return await this.client.userInfoManager.getSubscribedUsers();
|
|
2609
2840
|
} catch (e) {
|
|
2610
|
-
return
|
|
2841
|
+
return P.warn("[UserInfoDomain] getSubscribedUsers failed:", L(e)), [];
|
|
2611
2842
|
}
|
|
2612
2843
|
}
|
|
2613
2844
|
/**
|
|
@@ -2634,87 +2865,88 @@ class Cn {
|
|
|
2634
2865
|
});
|
|
2635
2866
|
}
|
|
2636
2867
|
}
|
|
2637
|
-
const
|
|
2638
|
-
function
|
|
2868
|
+
const D = T("UIKit:ConnEvents");
|
|
2869
|
+
function Kn(s, e = {}) {
|
|
2639
2870
|
return {
|
|
2640
2871
|
onConnecting: () => {
|
|
2641
|
-
|
|
2872
|
+
D.info("onConnecting"), s.client.setConnecting(!0);
|
|
2642
2873
|
},
|
|
2643
2874
|
onConnected: () => {
|
|
2644
|
-
|
|
2875
|
+
var t, n;
|
|
2876
|
+
D.info("onConnected"), s.client.setConnected(!0), s.client.setConnecting(!1), s.client.setHasConnectedOnce(!0), (n = (t = s.userInfo) == null ? void 0 : t.clearFetchFailed) == null || n.call(t);
|
|
2645
2877
|
},
|
|
2646
2878
|
onDisconnected: (t) => {
|
|
2647
|
-
|
|
2879
|
+
D.info("onDisconnected", t ? { reason: t.reason, errorCode: t.errorCode } : void 0), s.client.setConnected(!1), s.client.setConnecting(!1), Dt(t == null ? void 0 : t.errorCode) && s.client.setKicked(t.errorCode);
|
|
2648
2880
|
},
|
|
2649
2881
|
onReconnectFailed: () => {
|
|
2650
|
-
|
|
2882
|
+
D.info("onReconnectFailed"), s.client.setConnecting(!1), D.error("Auto-reconnect failed after max retries");
|
|
2651
2883
|
},
|
|
2652
2884
|
onTokenWillExpire: () => {
|
|
2653
2885
|
var t;
|
|
2654
|
-
|
|
2886
|
+
D.info("onTokenWillExpire"), D.warn("Token will expire"), (t = e.onTokenWillExpire) == null || t.call(e);
|
|
2655
2887
|
},
|
|
2656
2888
|
onTokenExpired: () => {
|
|
2657
2889
|
var t;
|
|
2658
|
-
|
|
2890
|
+
D.info("onTokenExpired"), D.error("Token expired"), (t = e.onTokenExpired) == null || t.call(e);
|
|
2659
2891
|
},
|
|
2660
2892
|
onOfflineMessageSyncStart: () => {
|
|
2661
|
-
|
|
2893
|
+
D.info("onOfflineMessageSyncStart"), s.conversation.conversationsLoaded || s.message.setSyncingMessages(!0);
|
|
2662
2894
|
},
|
|
2663
2895
|
onOfflineMessageSyncFinish: () => {
|
|
2664
|
-
|
|
2896
|
+
D.info("onOfflineMessageSyncFinish"), s.message.setSyncingMessages(!1);
|
|
2665
2897
|
}
|
|
2666
2898
|
};
|
|
2667
2899
|
}
|
|
2668
|
-
const
|
|
2900
|
+
const gt = T("UIKit:SyncStatus"), Y = Pt({
|
|
2669
2901
|
conversation: { status: "idle" },
|
|
2670
2902
|
contact: { status: "idle" },
|
|
2671
2903
|
group: { status: "idle" }
|
|
2672
2904
|
});
|
|
2673
|
-
let
|
|
2674
|
-
function
|
|
2675
|
-
return
|
|
2676
|
-
|
|
2905
|
+
let re = null;
|
|
2906
|
+
function qn(s) {
|
|
2907
|
+
return re = s, () => {
|
|
2908
|
+
re = null;
|
|
2677
2909
|
};
|
|
2678
2910
|
}
|
|
2679
|
-
function
|
|
2680
|
-
const t =
|
|
2681
|
-
t.status = e.status, e.finishedAt !== void 0 && (t.finishedAt = e.finishedAt), e.error !== void 0 && (t.error = e.error),
|
|
2911
|
+
function Re(s, e) {
|
|
2912
|
+
const t = Y[s];
|
|
2913
|
+
t.status = e.status, e.finishedAt !== void 0 && (t.finishedAt = e.finishedAt), e.error !== void 0 && (t.error = e.error), gt.info(`sync ${s} -> ${e.status}`, e.error ? { stage: e.error.stage, retryable: e.error.retryable, message: e.error.message } : void 0), re == null || re({
|
|
2682
2914
|
type: s,
|
|
2683
2915
|
status: e.status === "idle" ? "syncing" : e.status,
|
|
2684
2916
|
error: e.error
|
|
2685
2917
|
});
|
|
2686
2918
|
}
|
|
2687
|
-
function
|
|
2688
|
-
const s = Object.keys(
|
|
2919
|
+
function jn() {
|
|
2920
|
+
const s = Object.keys(Y);
|
|
2689
2921
|
for (const e of s)
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
}
|
|
2693
|
-
function
|
|
2694
|
-
const s =
|
|
2695
|
-
() => Object.values(
|
|
2696
|
-
), t =
|
|
2697
|
-
() => Object.values(
|
|
2922
|
+
Y[e] = { status: "idle" };
|
|
2923
|
+
gt.info("sync status reset(事件反注册/登出)");
|
|
2924
|
+
}
|
|
2925
|
+
function bs() {
|
|
2926
|
+
const s = Me(() => ({ ...Y })), e = Me(
|
|
2927
|
+
() => Object.values(Y).some((n) => n.status === "syncing")
|
|
2928
|
+
), t = Me(
|
|
2929
|
+
() => Object.values(Y).every((n) => n.status === "success" || n.status === "failed")
|
|
2698
2930
|
);
|
|
2699
2931
|
return { status: s, isSyncing: e, allFinished: t };
|
|
2700
2932
|
}
|
|
2701
|
-
let
|
|
2702
|
-
function
|
|
2703
|
-
|
|
2933
|
+
let Oe = null;
|
|
2934
|
+
function mt(s) {
|
|
2935
|
+
Oe = s;
|
|
2704
2936
|
}
|
|
2705
|
-
function
|
|
2706
|
-
if (!
|
|
2937
|
+
function K() {
|
|
2938
|
+
if (!Oe)
|
|
2707
2939
|
throw new Error(
|
|
2708
2940
|
"[UIKit] 事件层依赖未注入:请在调用 registerEventHandlers 前先执行 setEventHandlerDeps()"
|
|
2709
2941
|
);
|
|
2710
|
-
return
|
|
2942
|
+
return Oe;
|
|
2711
2943
|
}
|
|
2712
|
-
const
|
|
2713
|
-
function
|
|
2944
|
+
const Vn = T("UIKit:Websdk5Adapter");
|
|
2945
|
+
function Wn() {
|
|
2714
2946
|
try {
|
|
2715
|
-
|
|
2947
|
+
K();
|
|
2716
2948
|
} catch {
|
|
2717
|
-
|
|
2949
|
+
Vn.warn("[Websdk5Adapter] 事件层依赖未注入,使用最小兜底实现"), mt({
|
|
2718
2950
|
t: (s) => s,
|
|
2719
2951
|
insertChatNotice: () => {
|
|
2720
2952
|
},
|
|
@@ -2738,7 +2970,7 @@ function En() {
|
|
|
2738
2970
|
});
|
|
2739
2971
|
}
|
|
2740
2972
|
}
|
|
2741
|
-
function
|
|
2973
|
+
function Jn(s, e) {
|
|
2742
2974
|
const t = s.contact.getContact(e);
|
|
2743
2975
|
if (t != null && t.remark)
|
|
2744
2976
|
return t.remark;
|
|
@@ -2746,7 +2978,7 @@ function Tn(s, e) {
|
|
|
2746
2978
|
if (n != null && n.nickname)
|
|
2747
2979
|
return n.nickname;
|
|
2748
2980
|
}
|
|
2749
|
-
function
|
|
2981
|
+
function pt(s, e) {
|
|
2750
2982
|
var r;
|
|
2751
2983
|
const t = e.from || "", n = s.contact.getContact(t);
|
|
2752
2984
|
if (n != null && n.remark)
|
|
@@ -2757,108 +2989,155 @@ function ot(s, e) {
|
|
|
2757
2989
|
const a = (r = e.ext) == null ? void 0 : r.ease_chat_uikit_user_info;
|
|
2758
2990
|
return a != null && a.nickname ? a.nickname : a != null && a.remark ? a.remark : t;
|
|
2759
2991
|
}
|
|
2760
|
-
function
|
|
2992
|
+
function $n(s, e) {
|
|
2761
2993
|
var d;
|
|
2762
|
-
const { useNotification: t, emitNotificationDelivered: n } =
|
|
2763
|
-
if (!o.value.enabled ||
|
|
2994
|
+
const { useNotification: t, emitNotificationDelivered: n } = K(), { state: o, notify: a, notifyBrowser: r } = t();
|
|
2995
|
+
if (!o.value.enabled || G(e.from) === G(s.client.currentUser) || e.conversationId === s.conversation.currentConversationId)
|
|
2764
2996
|
return;
|
|
2765
|
-
const i = s.conversation.conversationList.find((
|
|
2997
|
+
const i = s.conversation.conversationList.find((f) => f.id === e.conversationId);
|
|
2766
2998
|
if (i != null && i.isMuted)
|
|
2767
2999
|
return;
|
|
2768
3000
|
const c = typeof document > "u" || document.visibilityState === "hidden";
|
|
2769
3001
|
if (o.value.triggerMode === "background" && !c)
|
|
2770
3002
|
return;
|
|
2771
|
-
const u =
|
|
3003
|
+
const u = H(e, s.client.currentUser), l = pt(s, u), g = u.conversationType === I.GROUPCHAT, p = {
|
|
2772
3004
|
// 群聊标题为群名(正文含 "发送者: 内容" 前缀),单聊标题为发送者名
|
|
2773
|
-
title:
|
|
2774
|
-
body:
|
|
3005
|
+
title: g && (i == null ? void 0 : i.name) || l,
|
|
3006
|
+
body: Nt(u, void 0, l, void 0, Be),
|
|
2775
3007
|
// 群聊用群头像,单聊用发送者头像
|
|
2776
|
-
avatar:
|
|
3008
|
+
avatar: g ? i == null ? void 0 : i.avatar : (d = s.userInfo.getUserInfo(e.from)) == null ? void 0 : d.avatarUrl,
|
|
2777
3009
|
timestamp: u.timestamp || Date.now(),
|
|
2778
3010
|
conversationId: e.conversationId,
|
|
2779
3011
|
conversationType: u.conversationType
|
|
2780
3012
|
};
|
|
2781
|
-
c && o.value.browserEnabled ? r(
|
|
2782
|
-
|
|
2783
|
-
}) : o.value.inAppEnabled && (a(
|
|
3013
|
+
c && o.value.browserEnabled ? r(p).then((f) => {
|
|
3014
|
+
f ? n(p, "browser") : o.value.inAppEnabled && (a(p), n(p, "in-app"));
|
|
3015
|
+
}) : o.value.inAppEnabled && (a(p), n(p, "in-app"));
|
|
2784
3016
|
}
|
|
2785
|
-
function
|
|
2786
|
-
const { t: n, useNotification: o, emitNotificationDelivered: a, resolveNoticeUserName: r } =
|
|
3017
|
+
function Qe(s, e, t) {
|
|
3018
|
+
const { t: n, useNotification: o, emitNotificationDelivered: a, resolveNoticeUserName: r } = K(), { state: i, notify: c, notifyBrowser: u } = o();
|
|
2787
3019
|
if (!i.value.enabled)
|
|
2788
3020
|
return;
|
|
2789
|
-
const
|
|
2790
|
-
title: r(
|
|
3021
|
+
const l = s.userInfo.getUserInfo(e), g = {
|
|
3022
|
+
title: r(l) || e,
|
|
2791
3023
|
body: n(t === "declined" ? "contact.inviteDeclinedByPeer" : "chat.notice.contactDeleted"),
|
|
2792
|
-
avatar:
|
|
3024
|
+
avatar: l == null ? void 0 : l.avatarUrl,
|
|
2793
3025
|
timestamp: Date.now(),
|
|
2794
3026
|
conversationId: e,
|
|
2795
3027
|
conversationType: I.SINGLECHAT
|
|
2796
3028
|
};
|
|
2797
|
-
(typeof document > "u" || document.visibilityState === "hidden") && i.value.browserEnabled ? u(
|
|
2798
|
-
d ? a(
|
|
2799
|
-
}) : i.value.inAppEnabled && (c(
|
|
3029
|
+
(typeof document > "u" || document.visibilityState === "hidden") && i.value.browserEnabled ? u(g).then((d) => {
|
|
3030
|
+
d ? a(g, "browser") : i.value.inAppEnabled && (c(g), a(g, "in-app"));
|
|
3031
|
+
}) : i.value.inAppEnabled && (c(g), a(g, "in-app"));
|
|
3032
|
+
}
|
|
3033
|
+
const Qn = 20, zn = 2;
|
|
3034
|
+
function ze(s) {
|
|
3035
|
+
return `${s.conversationType}:${s.conversationId}`;
|
|
2800
3036
|
}
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
3037
|
+
async function Yn(s) {
|
|
3038
|
+
const e = s.batchSize ?? Qn, t = Math.max(1, s.concurrency ?? zn), n = s.targets.filter((c) => !s.queried.has(ze(c)));
|
|
3039
|
+
if (n.length === 0 || e <= 0)
|
|
3040
|
+
return { queriedCount: 0, batchCount: 0, failedBatchCount: 0 };
|
|
3041
|
+
const o = [];
|
|
3042
|
+
for (let c = 0; c < n.length; c += e)
|
|
3043
|
+
o.push(n.slice(c, c + e));
|
|
3044
|
+
let a = 0, r = 0;
|
|
3045
|
+
async function i() {
|
|
3046
|
+
var c;
|
|
3047
|
+
for (; a < o.length; ) {
|
|
3048
|
+
const u = o[a];
|
|
3049
|
+
a += 1;
|
|
3050
|
+
try {
|
|
3051
|
+
const l = await s.query(u);
|
|
3052
|
+
for (const g of l)
|
|
3053
|
+
s.apply(g);
|
|
3054
|
+
for (const g of u)
|
|
3055
|
+
s.queried.add(ze(g));
|
|
3056
|
+
} catch (l) {
|
|
3057
|
+
r += 1, (c = s.onError) == null || c.call(s, l, u);
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
return await Promise.all(Array.from({ length: Math.min(t, o.length) }, () => i())), { queriedCount: n.length, batchCount: o.length, failedBatchCount: r };
|
|
2805
3062
|
}
|
|
2806
|
-
|
|
3063
|
+
const y = T("UIKit:ChatEvents"), ge = /* @__PURE__ */ new Set(), xe = /* @__PURE__ */ new Set(), ht = /* @__PURE__ */ new Set();
|
|
3064
|
+
let me = !1, pe = !1;
|
|
3065
|
+
const Q = /* @__PURE__ */ new Map();
|
|
3066
|
+
let he = !1;
|
|
3067
|
+
function Xn() {
|
|
3068
|
+
ge.clear(), xe.clear(), ht.clear(), me = !1, pe = !1, Q.clear(), he = !1;
|
|
3069
|
+
}
|
|
3070
|
+
function Zn(s, e, t, n) {
|
|
2807
3071
|
if (!n)
|
|
2808
3072
|
return;
|
|
2809
|
-
const o = `${e}:${t}`, a =
|
|
2810
|
-
a.push(n),
|
|
2811
|
-
for (
|
|
2812
|
-
const r = Array.from(
|
|
2813
|
-
|
|
3073
|
+
const o = `${e}:${t}`, a = Q.get(o) || [];
|
|
3074
|
+
a.push(n), Q.set(o, a), !he && (he = !0, Promise.resolve().then(async () => {
|
|
3075
|
+
for (he = !1; Q.size > 0; ) {
|
|
3076
|
+
const r = Array.from(Q.entries());
|
|
3077
|
+
Q.clear();
|
|
2814
3078
|
for (const [i, c] of r) {
|
|
2815
|
-
const [u,
|
|
2816
|
-
for (let
|
|
2817
|
-
const
|
|
2818
|
-
|
|
3079
|
+
const [u, l] = i.split(":");
|
|
3080
|
+
for (let g = 0; g < c.length; g += 50) {
|
|
3081
|
+
const p = c.slice(g, g + 50);
|
|
3082
|
+
y.info("[queueMessageReadReceipt] 批量发送已读回执", { conversationType: u, conversationId: l, batchSize: p.length, messageIds: p });
|
|
2819
3083
|
try {
|
|
2820
3084
|
await s.chatManager.sendMessageReadReceipts({
|
|
2821
|
-
conversationId:
|
|
3085
|
+
conversationId: l,
|
|
2822
3086
|
conversationType: u,
|
|
2823
|
-
messageIds:
|
|
2824
|
-
}),
|
|
3087
|
+
messageIds: p
|
|
3088
|
+
}), Cn(p), y.info("[queueMessageReadReceipt] 已读回执发送成功", { conversationType: u, conversationId: l, messageIds: p });
|
|
2825
3089
|
} catch (d) {
|
|
2826
|
-
|
|
3090
|
+
y.warn("[queueMessageReadReceipt] sendMessageReadReceipts failed:", { conversationType: u, conversationId: l, messageIds: p, err: d });
|
|
2827
3091
|
}
|
|
2828
3092
|
}
|
|
2829
3093
|
}
|
|
2830
3094
|
}
|
|
2831
3095
|
}));
|
|
2832
3096
|
}
|
|
2833
|
-
async function
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
}
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
3097
|
+
async function es(s, e) {
|
|
3098
|
+
if (me) {
|
|
3099
|
+
pe = !0;
|
|
3100
|
+
return;
|
|
3101
|
+
}
|
|
3102
|
+
me = !0;
|
|
3103
|
+
try {
|
|
3104
|
+
do {
|
|
3105
|
+
pe = !1;
|
|
3106
|
+
const t = Date.now(), n = [];
|
|
3107
|
+
for (const i of s.conversation.conversationList)
|
|
3108
|
+
i.type === I.SINGLECHAT ? n.push({ conversationId: i.id, conversationType: I.SINGLECHAT }) : i.type === I.GROUPCHAT && n.push({ conversationId: i.id, conversationType: I.GROUPCHAT });
|
|
3109
|
+
const { queriedCount: o, batchCount: a, failedBatchCount: r } = await Yn({
|
|
3110
|
+
targets: n,
|
|
3111
|
+
queried: ht,
|
|
3112
|
+
query: async (i) => (await e.pushManager.getConversationSilentModes({ conversationList: i })).conversations,
|
|
3113
|
+
apply: (i) => {
|
|
3114
|
+
const c = i.rule.remindType === "NONE" || i.rule.expireTimestamp !== void 0 && i.rule.expireTimestamp > Date.now(), u = s.conversation.conversationList.find((l) => l.id === i.conversationId);
|
|
3115
|
+
u && u.isMuted !== c && s.conversation.updateConversation(i.conversationId, {
|
|
3116
|
+
isMuted: c,
|
|
3117
|
+
remindType: i.rule.remindType ?? (c ? "NONE" : "DEFAULT")
|
|
2849
3118
|
});
|
|
2850
|
-
}
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
3119
|
+
},
|
|
3120
|
+
onError: (i) => y.warn("patch conversation mute states failed:", i)
|
|
3121
|
+
});
|
|
3122
|
+
a > 0 && y.info("patch conversation mute states", {
|
|
3123
|
+
conversations: n.length,
|
|
3124
|
+
queried: o,
|
|
3125
|
+
batches: a,
|
|
3126
|
+
failedBatches: r,
|
|
3127
|
+
durationMs: Date.now() - t
|
|
3128
|
+
});
|
|
3129
|
+
} while (pe);
|
|
3130
|
+
} finally {
|
|
3131
|
+
me = !1;
|
|
3132
|
+
}
|
|
2854
3133
|
}
|
|
2855
|
-
async function
|
|
3134
|
+
async function ae(s, e) {
|
|
2856
3135
|
const t = new Map(s.group.groupList.map((o) => [o.groupId, o.groupName])), n = [];
|
|
2857
3136
|
for (const o of s.conversation.conversationList)
|
|
2858
|
-
if ((!o.name || o.name === o.id) && !
|
|
3137
|
+
if ((!o.name || o.name === o.id) && !xe.has(o.id)) {
|
|
2859
3138
|
if (o.type === I.GROUPCHAT) {
|
|
2860
3139
|
const r = t.get(o.id);
|
|
2861
|
-
r && r !== o.id ? s.conversation.updateConversation(o.id, { name: r }) :
|
|
3140
|
+
r && r !== o.id ? s.conversation.updateConversation(o.id, { name: r }) : ge.has(o.id) || n.push(o.id);
|
|
2862
3141
|
} else if (o.type === I.SINGLECHAT) {
|
|
2863
3142
|
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
3143
|
c && s.conversation.updateConversation(o.id, { name: c });
|
|
@@ -2866,42 +3145,43 @@ async function oe(s, e) {
|
|
|
2866
3145
|
}
|
|
2867
3146
|
if (n.length !== 0) {
|
|
2868
3147
|
for (const o of n)
|
|
2869
|
-
|
|
3148
|
+
ge.add(o), xe.add(o);
|
|
2870
3149
|
try {
|
|
2871
|
-
const o = await e.groupManager.getGroupInfoList({ groupIds: n }), a =
|
|
3150
|
+
const o = await e.groupManager.getGroupInfoList({ groupIds: n }), a = Ie(o);
|
|
2872
3151
|
for (const r of a)
|
|
2873
3152
|
s.group.updateGroup(r.groupId, r), r.groupName && r.groupName !== r.groupId && s.conversation.updateConversation(r.groupId, { name: r.groupName });
|
|
2874
3153
|
} catch (o) {
|
|
2875
|
-
|
|
3154
|
+
y.warn("fetch missing group names failed:", o);
|
|
2876
3155
|
} finally {
|
|
2877
|
-
for (const o of n)
|
|
3156
|
+
for (const o of n) ge.delete(o);
|
|
2878
3157
|
}
|
|
2879
3158
|
}
|
|
2880
3159
|
}
|
|
2881
|
-
function
|
|
3160
|
+
function ts(s, e, t, n) {
|
|
2882
3161
|
const o = s.message.getMessages(e), a = o.findIndex(
|
|
2883
|
-
(
|
|
3162
|
+
(p) => p.msgServerId === n || p.msgLocalId === n
|
|
2884
3163
|
);
|
|
2885
3164
|
if (a === -1 || a !== o.length - 1)
|
|
2886
3165
|
return;
|
|
2887
|
-
const r = o[a], i = s.conversation.conversationList.find((
|
|
3166
|
+
const r = o[a], i = s.conversation.conversationList.find((p) => p.id === e);
|
|
2888
3167
|
if (!i || i.lastMessageTime && r.timestamp < i.lastMessageTime - 1e3)
|
|
2889
3168
|
return;
|
|
2890
|
-
const u = t === I.GROUPCHAT ?
|
|
3169
|
+
const u = t === I.GROUPCHAT ? G(r.from || "") : "", l = u ? pt(s, { ...r, from: u }) : void 0, { t: g } = K();
|
|
2891
3170
|
s.conversation.updateConversation(e, {
|
|
2892
|
-
lastMessageText:
|
|
3171
|
+
lastMessageText: ct(
|
|
2893
3172
|
t,
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
)
|
|
3173
|
+
l,
|
|
3174
|
+
g("message.recalledPreview")
|
|
3175
|
+
),
|
|
3176
|
+
...u ? { lastMessageFrom: u, lastMessageSenderName: l } : {}
|
|
2897
3177
|
});
|
|
2898
3178
|
}
|
|
2899
|
-
function
|
|
2900
|
-
Promise.resolve().then(s).catch((e) =>
|
|
3179
|
+
function B(s) {
|
|
3180
|
+
Promise.resolve().then(s).catch((e) => y.warn("persistence 钩子执行失败(已忽略):", e));
|
|
2901
3181
|
}
|
|
2902
|
-
function
|
|
3182
|
+
function Ye(s, e) {
|
|
2903
3183
|
const t = s.conversation.conversationList, n = new Set(e.map((r) => r.id)), o = e.map((r) => {
|
|
2904
|
-
const i = t.find((
|
|
3184
|
+
const i = t.find((l) => l.id === r.id);
|
|
2905
3185
|
if (!i)
|
|
2906
3186
|
return r;
|
|
2907
3187
|
const c = (!r.name || r.name === r.id) && i.name && i.name !== i.id, u = !r.avatar && i.avatar;
|
|
@@ -2920,119 +3200,119 @@ function He(s, e) {
|
|
|
2920
3200
|
}), a = t.filter((r) => !n.has(r.id)).sort((r, i) => (i.lastMessageTime ?? 0) - (r.lastMessageTime ?? 0));
|
|
2921
3201
|
return [...o, ...a];
|
|
2922
3202
|
}
|
|
2923
|
-
function
|
|
2924
|
-
var
|
|
2925
|
-
const a = (d) =>
|
|
3203
|
+
function ns(s, e, t, n, o) {
|
|
3204
|
+
var p;
|
|
3205
|
+
const a = (d) => Jn(e, d), {
|
|
2926
3206
|
saveMessage: r,
|
|
2927
3207
|
updateMessageStatus: i,
|
|
2928
3208
|
markMessageRecalled: c,
|
|
2929
3209
|
updateMessageContent: u,
|
|
2930
|
-
deleteMessages:
|
|
2931
|
-
} = (n == null ? void 0 : n.message) ?? {},
|
|
3210
|
+
deleteMessages: l
|
|
3211
|
+
} = (n == null ? void 0 : n.message) ?? {}, g = (p = n == null ? void 0 : n.conversation) == null ? void 0 : p.saveConversations;
|
|
2932
3212
|
return {
|
|
2933
3213
|
onSyncDataStart: (d) => {
|
|
2934
|
-
|
|
3214
|
+
y.info("onSyncDataStart", { dataType: d.dataType }), Re(d.dataType, { status: "syncing" }), d.dataType === "conversation" && e.conversation.setSyncingConversations(!0);
|
|
2935
3215
|
},
|
|
2936
3216
|
onSyncDataFinished: (d) => {
|
|
2937
|
-
if (
|
|
2938
|
-
const
|
|
2939
|
-
|
|
3217
|
+
if (y.info("onSyncDataFinished", { dataType: d.dataType, status: d.status }), d.status === "failed") {
|
|
3218
|
+
const f = d.error;
|
|
3219
|
+
Re(d.dataType, {
|
|
2940
3220
|
status: "failed",
|
|
2941
3221
|
finishedAt: Date.now(),
|
|
2942
3222
|
error: {
|
|
2943
|
-
stage:
|
|
2944
|
-
retryable:
|
|
2945
|
-
message:
|
|
3223
|
+
stage: f == null ? void 0 : f.stage,
|
|
3224
|
+
retryable: f == null ? void 0 : f.retryable,
|
|
3225
|
+
message: f == null ? void 0 : f.message
|
|
2946
3226
|
}
|
|
2947
|
-
}),
|
|
3227
|
+
}), y.warn("[ChatEvents] 数据同步失败", {
|
|
2948
3228
|
dataType: d.dataType,
|
|
2949
|
-
stage:
|
|
2950
|
-
retryable:
|
|
2951
|
-
message:
|
|
2952
|
-
}), d.dataType === "conversation" && (e.conversation.setSyncingConversations(!1),
|
|
2953
|
-
|
|
3229
|
+
stage: f == null ? void 0 : f.stage,
|
|
3230
|
+
retryable: f == null ? void 0 : f.retryable,
|
|
3231
|
+
message: f == null ? void 0 : f.message
|
|
3232
|
+
}), d.dataType === "conversation" && (e.conversation.setSyncingConversations(!1), f != null && f.retryable && s.chatManager.refreshSessionList().catch((m) => {
|
|
3233
|
+
y.warn("[ChatEvents] conversation 同步失败重试未成功:", L(m));
|
|
2954
3234
|
}));
|
|
2955
3235
|
return;
|
|
2956
3236
|
}
|
|
2957
|
-
switch (
|
|
3237
|
+
switch (Re(d.dataType, { status: "success", finishedAt: Date.now() }), d.dataType) {
|
|
2958
3238
|
case "conversation":
|
|
2959
3239
|
e.conversation.setSyncingConversations(!1);
|
|
2960
3240
|
{
|
|
2961
|
-
const
|
|
2962
|
-
|
|
2963
|
-
const
|
|
2964
|
-
e.conversation.setConversationList(h),
|
|
3241
|
+
const f = s.chatManager.getConversationList().filter((v) => v.conversationType !== "chatRoom");
|
|
3242
|
+
ve(y, "onSyncDataFinished", f);
|
|
3243
|
+
const m = se(f, { resolveSenderName: a, lastMessageTextResolver: o }), h = Ye(e, m);
|
|
3244
|
+
e.conversation.setConversationList(h), y.info("conversation 同步回填", { count: h.length }), g && B(() => g(h.map(Ke)));
|
|
2965
3245
|
}
|
|
2966
|
-
e.conversation.setConversationsLoaded(!0),
|
|
3246
|
+
e.conversation.setConversationsLoaded(!0), ae(e, s), es(e, s);
|
|
2967
3247
|
break;
|
|
2968
3248
|
case "contact":
|
|
2969
3249
|
if (!e.contact.loaded || e.contact.contactList.length === 0) {
|
|
2970
|
-
const
|
|
2971
|
-
e.contact.setContactList(
|
|
3250
|
+
const f = s.contactManager.getContacts();
|
|
3251
|
+
e.contact.setContactList(ke(f)), y.info("contact 同步回填", { count: f.length });
|
|
2972
3252
|
} else
|
|
2973
|
-
|
|
2974
|
-
|
|
3253
|
+
y.info("contact 同步回填跳过(列表已由业务方填充)", { count: e.contact.contactList.length });
|
|
3254
|
+
ae(e, s);
|
|
2975
3255
|
break;
|
|
2976
3256
|
case "group":
|
|
2977
3257
|
if (!e.group.loaded || e.group.groupList.length === 0) {
|
|
2978
|
-
const
|
|
2979
|
-
e.group.setGroupList(
|
|
3258
|
+
const f = s.groupManager.getJoinedGroupList();
|
|
3259
|
+
e.group.setGroupList(Ie(f)), y.info("group 同步回填", { count: f.length });
|
|
2980
3260
|
} else
|
|
2981
|
-
|
|
2982
|
-
|
|
3261
|
+
y.info("group 同步回填跳过(列表已由业务方填充)", { count: e.group.groupList.length });
|
|
3262
|
+
ae(e, s);
|
|
2983
3263
|
break;
|
|
2984
3264
|
}
|
|
2985
3265
|
},
|
|
2986
3266
|
onConversationListUpdate: (d) => {
|
|
2987
|
-
var
|
|
2988
|
-
const
|
|
2989
|
-
|
|
3267
|
+
var w;
|
|
3268
|
+
const f = d.items.filter((M) => M.conversationType !== "chatRoom");
|
|
3269
|
+
y.info("onConversationListUpdate", { count: f.length, reset: d.patch.reset, removed: d.patch.removed.length }), ve(y, "onConversationListUpdate", f);
|
|
2990
3270
|
{
|
|
2991
|
-
const
|
|
2992
|
-
for (const
|
|
2993
|
-
const
|
|
2994
|
-
|
|
3271
|
+
const M = {}, A = [];
|
|
3272
|
+
for (const J of f) {
|
|
3273
|
+
const X = String(((w = J.lastMessage) == null ? void 0 : w.type) ?? "(null)");
|
|
3274
|
+
M[X] = (M[X] ?? 0) + 1, (X === b.COMBINE || X === "unknown") && A.push({ conversationId: J.conversationId, lastMessage: J.lastMessage });
|
|
2995
3275
|
}
|
|
2996
|
-
|
|
3276
|
+
A.length > 0 && y.info("raw snippets (onConversationListUpdate)", { typeCount: M, suspects: A });
|
|
2997
3277
|
}
|
|
2998
|
-
const
|
|
3278
|
+
const m = se(f, { resolveSenderName: a, lastMessageTextResolver: o }), h = Ye(e, m), v = new Set(d.patch.removed.map((M) => M.conversationId)), C = v.size > 0 ? h.filter((M) => !v.has(M.id)) : h;
|
|
2999
3279
|
if (d.patch.reset || d.patch.removed.length > 0)
|
|
3000
|
-
e.conversation.setConversationList(
|
|
3280
|
+
e.conversation.setConversationList(C);
|
|
3001
3281
|
else
|
|
3002
|
-
for (const
|
|
3003
|
-
const
|
|
3004
|
-
|
|
3282
|
+
for (const M of C) {
|
|
3283
|
+
const A = e.conversation.conversationList.find((J) => J.id === M.id);
|
|
3284
|
+
A ? A !== M && e.conversation.updateConversation(M.id, M) : e.conversation.addConversation(M);
|
|
3005
3285
|
}
|
|
3006
|
-
|
|
3286
|
+
g && B(() => g(C.map(Ke))), ae(e, s);
|
|
3007
3287
|
},
|
|
3008
3288
|
onMessage: (d) => {
|
|
3009
|
-
var
|
|
3289
|
+
var C, w, M;
|
|
3010
3290
|
if (d.conversationType === "chatRoom")
|
|
3011
3291
|
return;
|
|
3012
3292
|
if (d.type === b.CMD) {
|
|
3013
|
-
const
|
|
3014
|
-
|
|
3293
|
+
const A = d.body.action;
|
|
3294
|
+
y.info("[CMD received]", {
|
|
3015
3295
|
conversationId: d.conversationId,
|
|
3016
3296
|
from: d.from,
|
|
3017
|
-
action:
|
|
3297
|
+
action: A,
|
|
3018
3298
|
ext: d.ext
|
|
3019
|
-
}),
|
|
3299
|
+
}), A === "TypingBegin" && (t == null ? void 0 : t.enableTyping) !== !1 && d.conversationType === I.SINGLECHAT && G(d.from) !== G(e.client.currentUser) && e.conversation.setTyping(d.conversationId, d.from);
|
|
3020
3300
|
return;
|
|
3021
3301
|
}
|
|
3022
|
-
|
|
3023
|
-
const
|
|
3024
|
-
|
|
3302
|
+
y.info("onMessage", { conversationId: d.conversationId, from: d.from, type: d.type });
|
|
3303
|
+
const f = H(d, e.client.currentUser), m = e.message.getMessages(d.conversationId).find((A) => A.msgServerId === d.msgServerId);
|
|
3304
|
+
m != null && m.stream && kt(m.stream.status) ? e.message.replaceMessageById(d.msgServerId, f) : e.message.addMessage(f), f.type === b.VOICE && !f.isSelf && ((w = (C = e.message).markVoiceUnplayed) == null || w.call(C, f.msgServerId || f.msgLocalId)), r && B(() => r(_e(d)));
|
|
3025
3305
|
const h = e.conversation.currentConversationId, v = typeof document > "u" || document.visibilityState === "visible";
|
|
3026
|
-
if (h && d.conversationId === h &&
|
|
3306
|
+
if (h && d.conversationId === h && G(d.from) !== G(e.client.currentUser) && v && (s.chatManager.clearConversationUnreadMessageCount({
|
|
3027
3307
|
conversationId: d.conversationId,
|
|
3028
3308
|
conversationType: d.conversationType
|
|
3029
|
-
}).catch((
|
|
3030
|
-
|
|
3031
|
-
}), (t == null ? void 0 : t.enableReadReceipt) !== !1 && (d.conversationType === I.SINGLECHAT || d.conversationType === I.GROUPCHAT) &&
|
|
3032
|
-
const
|
|
3033
|
-
Array.isArray(
|
|
3309
|
+
}).catch((A) => {
|
|
3310
|
+
y.warn("[UIKit] auto clearConversationUnreadMessageCount failed:", L(A));
|
|
3311
|
+
}), (t == null ? void 0 : t.enableReadReceipt) !== !1 && (d.conversationType === I.SINGLECHAT || d.conversationType === I.GROUPCHAT) && Zn(s, d.conversationType, d.conversationId, d.msgServerId)), (t == null ? void 0 : t.enableAtMe) !== !1 && d.conversationType === I.GROUPCHAT && G(d.from) !== G(e.client.currentUser)) {
|
|
3312
|
+
const A = (M = d.ext) == null ? void 0 : M.em_at_list;
|
|
3313
|
+
Array.isArray(A) && A.includes(e.client.currentUser) && (e.conversation.setAtMe(d.conversationId, !0), e.message.addAtMeMessage(d.conversationId, f.msgServerId || f.msgLocalId));
|
|
3034
3314
|
}
|
|
3035
|
-
|
|
3315
|
+
$n(e, d);
|
|
3036
3316
|
},
|
|
3037
3317
|
/**
|
|
3038
3318
|
* 流式消息(边生成边下发,典型 AI 对话)分片合并。
|
|
@@ -3045,33 +3325,33 @@ function Nn(s, e, t, n, o) {
|
|
|
3045
3325
|
onStreamMessage: (d) => {
|
|
3046
3326
|
if (d.conversationType === "chatRoom")
|
|
3047
3327
|
return;
|
|
3048
|
-
const
|
|
3049
|
-
if (!
|
|
3328
|
+
const f = d.stream;
|
|
3329
|
+
if (!f)
|
|
3050
3330
|
return;
|
|
3051
|
-
|
|
3331
|
+
y.info("onStreamMessage", {
|
|
3052
3332
|
conversationId: d.conversationId,
|
|
3053
3333
|
from: d.from,
|
|
3054
3334
|
msgServerId: d.msgServerId,
|
|
3055
|
-
seq:
|
|
3056
|
-
status:
|
|
3057
|
-
customType:
|
|
3335
|
+
seq: f.seq,
|
|
3336
|
+
status: f.status,
|
|
3337
|
+
customType: f.customType
|
|
3058
3338
|
});
|
|
3059
|
-
const
|
|
3060
|
-
if (!
|
|
3339
|
+
const m = d.msgServerId || d.msgLocalId;
|
|
3340
|
+
if (!m)
|
|
3061
3341
|
return;
|
|
3062
3342
|
if (!e.message.getMessages(d.conversationId).some(
|
|
3063
3343
|
(v) => v.msgServerId === d.msgServerId || d.msgLocalId !== void 0 && v.msgLocalId === d.msgLocalId
|
|
3064
3344
|
)) {
|
|
3065
|
-
e.message.addMessage(
|
|
3345
|
+
e.message.addMessage(H(d, e.client.currentUser));
|
|
3066
3346
|
return;
|
|
3067
3347
|
}
|
|
3068
|
-
e.message.updateMessageById(
|
|
3069
|
-
body: { ...d.body, content:
|
|
3070
|
-
stream: { ...
|
|
3348
|
+
e.message.updateMessageById(m, {
|
|
3349
|
+
body: { ...d.body, content: f.fullText },
|
|
3350
|
+
stream: { ...f }
|
|
3071
3351
|
});
|
|
3072
3352
|
},
|
|
3073
3353
|
onMessageRecalled: (d) => {
|
|
3074
|
-
d.conversationType !== "chatRoom" && (
|
|
3354
|
+
d.conversationType !== "chatRoom" && (y.info("onMessageRecalled", { messageId: d.messageId }), e.message.recallMessage(d.messageId, e.client.currentUser), c && B(() => c(d.messageId, e.client.currentUser)), ts(
|
|
3075
3355
|
e,
|
|
3076
3356
|
d.conversationId,
|
|
3077
3357
|
d.conversationType,
|
|
@@ -3079,34 +3359,34 @@ function Nn(s, e, t, n, o) {
|
|
|
3079
3359
|
));
|
|
3080
3360
|
},
|
|
3081
3361
|
onMessageDelivered: (d) => {
|
|
3082
|
-
|
|
3362
|
+
y.info("onMessageDelivered", { messageId: d.messageId }), e.message.updateMessageStatus(d.messageId, k.DELIVERED), i && B(() => i(d.messageId, k.DELIVERED));
|
|
3083
3363
|
},
|
|
3084
3364
|
onMessageReadReceipts: (d) => {
|
|
3085
|
-
for (const
|
|
3086
|
-
if (
|
|
3087
|
-
|
|
3088
|
-
conversationId:
|
|
3089
|
-
details:
|
|
3365
|
+
for (const f of d)
|
|
3366
|
+
if (f.conversationType === I.GROUPCHAT) {
|
|
3367
|
+
y.info("onMessageReadReceipts(group)", {
|
|
3368
|
+
conversationId: f.conversationId,
|
|
3369
|
+
details: f.receiptDetails.map((m) => ({ messageId: m.messageId, count: m.count }))
|
|
3090
3370
|
});
|
|
3091
|
-
for (const
|
|
3092
|
-
e.message.updateMessageById(
|
|
3371
|
+
for (const m of f.receiptDetails)
|
|
3372
|
+
e.message.updateMessageById(m.messageId, { groupReadCount: m.count });
|
|
3093
3373
|
} else {
|
|
3094
|
-
|
|
3095
|
-
conversationId:
|
|
3096
|
-
total:
|
|
3097
|
-
messageIds:
|
|
3374
|
+
y.info("onMessageReadReceipts(single)", {
|
|
3375
|
+
conversationId: f.conversationId,
|
|
3376
|
+
total: f.messageIds.length,
|
|
3377
|
+
messageIds: f.messageIds.slice(0, 5)
|
|
3098
3378
|
});
|
|
3099
|
-
for (const
|
|
3100
|
-
e.message.updateMessageStatus(
|
|
3379
|
+
for (const m of f.messageIds)
|
|
3380
|
+
e.message.updateMessageStatus(m, k.READ), i && B(() => i(m, k.READ));
|
|
3101
3381
|
}
|
|
3102
3382
|
},
|
|
3103
3383
|
onMessageUpdated: (d) => {
|
|
3104
|
-
d.conversationType !== "chatRoom" && (
|
|
3384
|
+
d.conversationType !== "chatRoom" && (y.info("onMessageUpdated", { messageId: d.messageId }), e.message.updateMessageById(d.messageId, {
|
|
3105
3385
|
body: d.message.body,
|
|
3106
3386
|
ext: d.message.ext,
|
|
3107
3387
|
modifiedInfo: d.message.modifiedInfo,
|
|
3108
3388
|
modified: !0
|
|
3109
|
-
}), u &&
|
|
3389
|
+
}), u && B(() => u(
|
|
3110
3390
|
d.messageId,
|
|
3111
3391
|
d.message.body,
|
|
3112
3392
|
d.message.ext,
|
|
@@ -3114,69 +3394,69 @@ function Nn(s, e, t, n, o) {
|
|
|
3114
3394
|
)));
|
|
3115
3395
|
},
|
|
3116
3396
|
onPinnedMessageChanged: async (d) => {
|
|
3117
|
-
if (d.conversationType !== "chatRoom" && (
|
|
3397
|
+
if (d.conversationType !== "chatRoom" && (y.info("onPinnedMessageChanged", { conversationId: d.conversationId, operation: d.operation }), !!d.messageId && (d.operation === "pin" ? e.message.setMessagePinned(d.messageId, {
|
|
3118
3398
|
operatorId: d.operatorId || "",
|
|
3119
3399
|
pinTime: d.pinTime || Date.now()
|
|
3120
3400
|
}) : d.operation === "unpin" && e.message.setMessageUnpinned(d.messageId), d.conversationId && d.conversationType)))
|
|
3121
3401
|
try {
|
|
3122
|
-
const
|
|
3402
|
+
const m = (await s.chatManager.getPinnedMessageList({
|
|
3123
3403
|
conversationId: d.conversationId,
|
|
3124
3404
|
conversationType: d.conversationType
|
|
3125
|
-
})).items.map((h) =>
|
|
3126
|
-
e.message.setPinnedMessages(d.conversationId,
|
|
3127
|
-
} catch (
|
|
3128
|
-
|
|
3405
|
+
})).items.map((h) => H(h.message, e.client.currentUser));
|
|
3406
|
+
e.message.setPinnedMessages(d.conversationId, m);
|
|
3407
|
+
} catch (f) {
|
|
3408
|
+
y.warn("refresh pinned messages failed:", f);
|
|
3129
3409
|
}
|
|
3130
3410
|
},
|
|
3131
3411
|
onMultiDeviceConversation: (d) => {
|
|
3132
|
-
if (
|
|
3412
|
+
if (y.info("onMultiDeviceConversation", { operation: d.operation }), d.operation === "ALL_CONVERSATIONS_UNREAD_MESSAGE_COUNT_CLEARED") {
|
|
3133
3413
|
for (const h of e.conversation.conversationList)
|
|
3134
3414
|
e.conversation.updateUnreadCount(h.id, 0);
|
|
3135
3415
|
return;
|
|
3136
3416
|
}
|
|
3137
|
-
const { operation:
|
|
3138
|
-
switch (
|
|
3417
|
+
const { operation: f, conversationId: m } = d;
|
|
3418
|
+
switch (f) {
|
|
3139
3419
|
case "CONVERSATION_DELETED":
|
|
3140
|
-
e.conversation.deleteConversation(
|
|
3420
|
+
e.conversation.deleteConversation(m);
|
|
3141
3421
|
break;
|
|
3142
3422
|
case "CONVERSATION_PINNED":
|
|
3143
|
-
e.conversation.updateConversation(
|
|
3423
|
+
e.conversation.updateConversation(m, { isPinned: !0 });
|
|
3144
3424
|
break;
|
|
3145
3425
|
case "CONVERSATION_UNPINNED":
|
|
3146
|
-
e.conversation.updateConversation(
|
|
3426
|
+
e.conversation.updateConversation(m, { isPinned: !1 });
|
|
3147
3427
|
break;
|
|
3148
3428
|
case "CONVERSATION_UNREAD_MESSAGE_COUNT_CLEARED":
|
|
3149
|
-
e.conversation.updateUnreadCount(
|
|
3429
|
+
e.conversation.updateUnreadCount(m, 0);
|
|
3150
3430
|
break;
|
|
3151
3431
|
case "CONVERSATION_MARK":
|
|
3152
|
-
d.mark !== void 0 && e.conversation.updateConversation(
|
|
3432
|
+
d.mark !== void 0 && e.conversation.updateConversation(m, { marks: [d.mark] });
|
|
3153
3433
|
break;
|
|
3154
3434
|
case "CONVERSATION_MUTE_INFO_CHANGED":
|
|
3155
|
-
d.remindType && e.conversation.updateConversation(
|
|
3435
|
+
d.remindType && e.conversation.updateConversation(m, {
|
|
3156
3436
|
isMuted: d.remindType === "NONE",
|
|
3157
3437
|
remindType: d.remindType
|
|
3158
3438
|
});
|
|
3159
3439
|
break;
|
|
3160
3440
|
default:
|
|
3161
|
-
|
|
3441
|
+
y.warn("onMultiDeviceConversation unhandled:", d);
|
|
3162
3442
|
}
|
|
3163
3443
|
},
|
|
3164
3444
|
onMultiDeviceMessageRemoved: (d) => {
|
|
3165
|
-
|
|
3166
|
-
const { operation:
|
|
3167
|
-
if (!(!
|
|
3445
|
+
y.info("onMultiDeviceMessageRemoved", { conversationId: d.conversationId, operation: d.operation, messageIds: d.messageIds });
|
|
3446
|
+
const { operation: f, conversationId: m, messageIds: h, beforeTimestamp: v } = d;
|
|
3447
|
+
if (!(!m || f !== "MESSAGE_REMOVED")) {
|
|
3168
3448
|
if (h && h.length > 0)
|
|
3169
|
-
e.message.deleteMessages([...h]),
|
|
3449
|
+
e.message.deleteMessages([...h]), l && B(() => l([...h]));
|
|
3170
3450
|
else if (v) {
|
|
3171
|
-
const
|
|
3172
|
-
|
|
3451
|
+
const w = e.message.getMessages(m).filter((M) => M.timestamp && M.timestamp < v).map((M) => M.msgServerId || M.msgLocalId).filter((M) => !!M);
|
|
3452
|
+
w.length > 0 && (e.message.deleteMessages(w), l && B(() => l(w)));
|
|
3173
3453
|
}
|
|
3174
3454
|
}
|
|
3175
3455
|
}
|
|
3176
3456
|
};
|
|
3177
3457
|
}
|
|
3178
|
-
const
|
|
3179
|
-
function
|
|
3458
|
+
const $ = T("UIKit:ContactEvents");
|
|
3459
|
+
function Xe(s, e = "pending") {
|
|
3180
3460
|
const t = s.userInfo, n = s.from;
|
|
3181
3461
|
return {
|
|
3182
3462
|
id: n,
|
|
@@ -3190,47 +3470,47 @@ function Ke(s, e = "pending") {
|
|
|
3190
3470
|
timestamp: Date.now()
|
|
3191
3471
|
};
|
|
3192
3472
|
}
|
|
3193
|
-
function
|
|
3194
|
-
const { t: e, insertChatNotice: t } =
|
|
3473
|
+
function ss(s) {
|
|
3474
|
+
const { t: e, insertChatNotice: t } = K();
|
|
3195
3475
|
return {
|
|
3196
3476
|
onContactInvited: (n) => {
|
|
3197
|
-
|
|
3477
|
+
$.info("onContactInvited", { from: n.from });
|
|
3198
3478
|
const o = n.from, a = o ? s.contact.getContact(o) : void 0;
|
|
3199
|
-
s.contact.addInvite(
|
|
3479
|
+
s.contact.addInvite(Xe(n, a ? "accepted" : "pending"));
|
|
3200
3480
|
},
|
|
3201
3481
|
onContactAgreed: (n) => {
|
|
3202
|
-
|
|
3482
|
+
$.info("onContactAgreed", { from: n.from });
|
|
3203
3483
|
const o = n.from;
|
|
3204
3484
|
if (!o)
|
|
3205
3485
|
return;
|
|
3206
3486
|
s.contact.getInvite(o) && s.contact.updateInviteStatus(o, "accepted"), s.contact.addContact({ userId: o, name: o });
|
|
3207
3487
|
},
|
|
3208
3488
|
onContactRefuse: (n) => {
|
|
3209
|
-
|
|
3489
|
+
$.info("onContactRefuse", { from: n.from });
|
|
3210
3490
|
const o = n.from;
|
|
3211
|
-
o && (s.contact.getInvite(o) ? s.contact.updateInviteStatus(o, "declined") : s.contact.addInvite({ ...
|
|
3491
|
+
o && (s.contact.getInvite(o) ? s.contact.updateInviteStatus(o, "declined") : s.contact.addInvite({ ...Xe(n, "declined"), outgoing: !0, unread: !0 }), Qe(s, o, "declined"));
|
|
3212
3492
|
},
|
|
3213
3493
|
onContactDeleted: (n) => {
|
|
3214
|
-
|
|
3494
|
+
$.info("onContactDeleted", { from: n.from });
|
|
3215
3495
|
const o = n.from;
|
|
3216
3496
|
o && (s.contact.removeContact(o), s.contact.removeInvite(o), t(s, o, I.SINGLECHAT, {
|
|
3217
|
-
eventType:
|
|
3497
|
+
eventType: E.CONTACT_DELETED,
|
|
3218
3498
|
params: {},
|
|
3219
3499
|
defaultText: e("chat.notice.contactDeleted")
|
|
3220
|
-
}),
|
|
3500
|
+
}), Qe(s, o, "deleted"));
|
|
3221
3501
|
},
|
|
3222
3502
|
onContactAdded: (n) => {
|
|
3223
|
-
|
|
3503
|
+
$.info("onContactAdded", { from: n.from });
|
|
3224
3504
|
const o = n.from;
|
|
3225
3505
|
o && (s.contact.addContact({ userId: o, name: o }), s.contact.removeInvite(o), t(s, o, I.SINGLECHAT, {
|
|
3226
|
-
eventType:
|
|
3506
|
+
eventType: E.CONTACT_ADDED,
|
|
3227
3507
|
params: {},
|
|
3228
3508
|
defaultText: e("chat.notice.contactAdded")
|
|
3229
3509
|
}));
|
|
3230
3510
|
},
|
|
3231
3511
|
onContactInfoUpdated: (n) => {
|
|
3232
3512
|
var a, r;
|
|
3233
|
-
|
|
3513
|
+
$.info("onContactInfoUpdated", { userId: (a = n.contact) == null ? void 0 : a.userId });
|
|
3234
3514
|
const o = n.contact;
|
|
3235
3515
|
if (o != null && o.userId && o.remark !== void 0) {
|
|
3236
3516
|
s.contact.updateContactRemark(o.userId, o.remark);
|
|
@@ -3240,8 +3520,8 @@ function kn(s) {
|
|
|
3240
3520
|
}
|
|
3241
3521
|
};
|
|
3242
3522
|
}
|
|
3243
|
-
const
|
|
3244
|
-
function
|
|
3523
|
+
const S = T("UIKit:GroupEvents");
|
|
3524
|
+
function Ze(s, e = "pending") {
|
|
3245
3525
|
const t = s.groupId, n = "inviter" in s ? s.inviter : void 0, o = "groupName" in s ? s.groupName : void 0;
|
|
3246
3526
|
return {
|
|
3247
3527
|
id: t,
|
|
@@ -3255,8 +3535,8 @@ function je(s, e = "pending") {
|
|
|
3255
3535
|
timestamp: Date.now()
|
|
3256
3536
|
};
|
|
3257
3537
|
}
|
|
3258
|
-
function
|
|
3259
|
-
const { t: o, resolveNoticeUserName: a } =
|
|
3538
|
+
function ce(s, e, t, n) {
|
|
3539
|
+
const { t: o, resolveNoticeUserName: a } = K();
|
|
3260
3540
|
if (s.length === 0)
|
|
3261
3541
|
return "";
|
|
3262
3542
|
const r = s[0];
|
|
@@ -3267,231 +3547,231 @@ function ie(s, e, t, n) {
|
|
|
3267
3547
|
const i = s.find((u) => u.userId !== e), c = a(i || r);
|
|
3268
3548
|
return o(n).replace("{name}", c).replace("{count}", String(s.length));
|
|
3269
3549
|
}
|
|
3270
|
-
function
|
|
3271
|
-
const { t, resolveNoticeUserName: n } =
|
|
3550
|
+
function ue(s, e) {
|
|
3551
|
+
const { t, resolveNoticeUserName: n } = K(), o = s.find((r) => r.userId !== e) ?? s[0];
|
|
3272
3552
|
return {
|
|
3273
3553
|
name: (o == null ? void 0 : o.userId) === e ? t("chat.notice.you") : n(o),
|
|
3274
3554
|
count: s.length,
|
|
3275
3555
|
userIds: s.map((r) => r.userId).join(",")
|
|
3276
3556
|
};
|
|
3277
3557
|
}
|
|
3278
|
-
function
|
|
3279
|
-
const { t: e, insertChatNotice: t, buildAnnouncementNoticeText: n, resolveNoticeUserName: o } =
|
|
3558
|
+
function rs(s) {
|
|
3559
|
+
const { t: e, insertChatNotice: t, buildAnnouncementNoticeText: n, resolveNoticeUserName: o } = K();
|
|
3280
3560
|
function a(r) {
|
|
3281
3561
|
return s.group.groupList.some((i) => i.groupId === r);
|
|
3282
3562
|
}
|
|
3283
3563
|
return {
|
|
3284
3564
|
onInvitationReceived: (r) => {
|
|
3285
|
-
|
|
3286
|
-
const i =
|
|
3565
|
+
S.info("onInvitationReceived raw payload", r);
|
|
3566
|
+
const i = Ze(r, a(r.groupId) ? "accepted" : "pending");
|
|
3287
3567
|
s.contact.addInvite(i);
|
|
3288
3568
|
},
|
|
3289
3569
|
onInvitationAccepted: (r) => {
|
|
3290
|
-
|
|
3570
|
+
S.info("onInvitationAccepted raw payload", r), s.contact.updateInviteStatus(r.groupId, "accepted");
|
|
3291
3571
|
},
|
|
3292
3572
|
onInvitationDeclined: (r) => {
|
|
3293
|
-
|
|
3573
|
+
S.info("onInvitationDeclined raw payload", r), s.contact.updateInviteStatus(r.groupId, "declined");
|
|
3294
3574
|
},
|
|
3295
3575
|
onAutoAcceptInvitationFromGroup: (r) => {
|
|
3296
|
-
|
|
3576
|
+
S.info("onAutoAcceptInvitationFromGroup raw payload", r), s.contact.addInvite(Ze(r, "accepted"));
|
|
3297
3577
|
},
|
|
3298
3578
|
onMembersJoined: (r) => {
|
|
3299
|
-
|
|
3579
|
+
S.info("onMembersJoined raw payload", r);
|
|
3300
3580
|
const i = r.members || [], c = s.client.currentUser;
|
|
3301
|
-
i.some((
|
|
3302
|
-
const
|
|
3581
|
+
i.some((g) => g.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);
|
|
3582
|
+
const l = ce(
|
|
3303
3583
|
i,
|
|
3304
3584
|
c || "",
|
|
3305
3585
|
"chat.notice.memberJoined",
|
|
3306
3586
|
"chat.notice.memberJoinedMultiple"
|
|
3307
3587
|
);
|
|
3308
3588
|
t(s, r.groupId, I.GROUPCHAT, {
|
|
3309
|
-
eventType:
|
|
3310
|
-
params:
|
|
3311
|
-
defaultText:
|
|
3589
|
+
eventType: E.MEMBER_JOINED,
|
|
3590
|
+
params: ue(i, c || ""),
|
|
3591
|
+
defaultText: l
|
|
3312
3592
|
});
|
|
3313
3593
|
},
|
|
3314
3594
|
onMembersExited: (r) => {
|
|
3315
3595
|
const i = r.members || [];
|
|
3316
|
-
|
|
3317
|
-
const c =
|
|
3596
|
+
S.info("onMembersExited raw payload", r), s.group.decrementMemberCount(r.groupId, i.length);
|
|
3597
|
+
const c = ce(
|
|
3318
3598
|
i,
|
|
3319
3599
|
s.client.currentUser || "",
|
|
3320
3600
|
"chat.notice.memberExited",
|
|
3321
3601
|
"chat.notice.memberExitedMultiple"
|
|
3322
3602
|
);
|
|
3323
3603
|
t(s, r.groupId, I.GROUPCHAT, {
|
|
3324
|
-
eventType:
|
|
3325
|
-
params:
|
|
3604
|
+
eventType: E.MEMBER_EXITED,
|
|
3605
|
+
params: ue(i, s.client.currentUser || ""),
|
|
3326
3606
|
defaultText: c
|
|
3327
3607
|
});
|
|
3328
3608
|
},
|
|
3329
3609
|
onGroupInfoChanged: (r) => {
|
|
3330
|
-
|
|
3331
|
-
const i = r.groupInfo ?? r, c = i.name ?? i.groupName, u = s.group.getGroupById(r.groupId),
|
|
3610
|
+
S.info("onGroupInfoChanged raw payload", r);
|
|
3611
|
+
const i = r.groupInfo ?? r, c = i.name ?? i.groupName, u = s.group.getGroupById(r.groupId), l = Fe({
|
|
3332
3612
|
...i,
|
|
3333
3613
|
groupId: r.groupId,
|
|
3334
3614
|
name: c,
|
|
3335
3615
|
avatarUrl: i.avatarUrl ?? i.avatar
|
|
3336
|
-
}),
|
|
3337
|
-
s.group.updateGroup(r.groupId,
|
|
3338
|
-
eventType:
|
|
3616
|
+
}), p = !!r.groupInfo ? l : Object.fromEntries(Object.entries(l).filter(([, d]) => d !== void 0));
|
|
3617
|
+
s.group.updateGroup(r.groupId, p), c && (u != null && u.groupName) && c !== u.groupName && (t(s, r.groupId, I.GROUPCHAT, {
|
|
3618
|
+
eventType: E.GROUP_NAME_CHANGED,
|
|
3339
3619
|
params: { name: c },
|
|
3340
3620
|
defaultText: e("chat.notice.groupNameChanged").replace("{name}", c)
|
|
3341
3621
|
}), s.conversation.updateConversation(r.groupId, { name: c }));
|
|
3342
3622
|
},
|
|
3343
3623
|
onOwnerChanged: (r) => {
|
|
3344
|
-
var
|
|
3345
|
-
|
|
3346
|
-
const i = (
|
|
3347
|
-
|
|
3348
|
-
const
|
|
3624
|
+
var f, m, h, v, C, w;
|
|
3625
|
+
S.info("onOwnerChanged raw payload", r);
|
|
3626
|
+
const i = (f = s.group.getGroupById(r.groupId)) == null ? void 0 : f.owner, c = (h = (m = s.group).getPendingOwnerTransfer) == null ? void 0 : h.call(m, r.groupId), u = c || ((v = r.newOwner) == null ? void 0 : v.userId) || "", l = { owner: u }, g = s.client.currentUser || "";
|
|
3627
|
+
g && (g === u ? l.role = R.OWNER : g === i && (l.role = R.MEMBER)), s.group.updateGroup(r.groupId, l), u && s.group.updateGroupMemberRole(r.groupId, u, R.OWNER), i && i !== u && s.group.updateGroupMemberRole(r.groupId, i, R.MEMBER), c && ((w = (C = s.group).clearPendingOwnerTransfer) == null || w.call(C, r.groupId));
|
|
3628
|
+
const p = u === g ? e("chat.notice.you") : o(r.newOwner), d = e("chat.notice.ownerChanged").replace("{name}", p);
|
|
3349
3629
|
t(s, r.groupId, I.GROUPCHAT, {
|
|
3350
|
-
eventType:
|
|
3351
|
-
params: { name:
|
|
3630
|
+
eventType: E.OWNER_CHANGED,
|
|
3631
|
+
params: { name: p, ownerId: u },
|
|
3352
3632
|
defaultText: d
|
|
3353
3633
|
});
|
|
3354
3634
|
},
|
|
3355
3635
|
onAdminAdded: (r) => {
|
|
3356
|
-
var
|
|
3357
|
-
|
|
3358
|
-
const i = (
|
|
3359
|
-
i && s.group.updateGroupMemberRole(r.groupId, i,
|
|
3360
|
-
const c = s.client.currentUser || "", u = i === c ? e("chat.notice.you") : o(r.administrator),
|
|
3636
|
+
var g;
|
|
3637
|
+
S.info("onAdminAdded raw payload", r);
|
|
3638
|
+
const i = (g = r.administrator) == null ? void 0 : g.userId;
|
|
3639
|
+
i && s.group.updateGroupMemberRole(r.groupId, i, R.ADMIN);
|
|
3640
|
+
const c = s.client.currentUser || "", u = i === c ? e("chat.notice.you") : o(r.administrator), l = e("chat.notice.adminAdded").replace("{name}", u);
|
|
3361
3641
|
t(s, r.groupId, I.GROUPCHAT, {
|
|
3362
|
-
eventType:
|
|
3642
|
+
eventType: E.ADMIN_ADDED,
|
|
3363
3643
|
params: { name: u, userId: i || "" },
|
|
3364
|
-
defaultText:
|
|
3644
|
+
defaultText: l
|
|
3365
3645
|
});
|
|
3366
3646
|
},
|
|
3367
3647
|
onAdminRemoved: (r) => {
|
|
3368
|
-
var
|
|
3369
|
-
|
|
3370
|
-
const i = (
|
|
3371
|
-
i && s.group.updateGroupMemberRole(r.groupId, i,
|
|
3372
|
-
const c = s.client.currentUser || "", u = i === c ? e("chat.notice.you") : o(r.administrator),
|
|
3648
|
+
var g;
|
|
3649
|
+
S.info("onAdminRemoved raw payload", r);
|
|
3650
|
+
const i = (g = r.administrator) == null ? void 0 : g.userId;
|
|
3651
|
+
i && s.group.updateGroupMemberRole(r.groupId, i, R.MEMBER);
|
|
3652
|
+
const c = s.client.currentUser || "", u = i === c ? e("chat.notice.you") : o(r.administrator), l = e("chat.notice.adminRemoved").replace("{name}", u);
|
|
3373
3653
|
t(s, r.groupId, I.GROUPCHAT, {
|
|
3374
|
-
eventType:
|
|
3654
|
+
eventType: E.ADMIN_REMOVED,
|
|
3375
3655
|
params: { name: u, userId: i || "" },
|
|
3376
|
-
defaultText:
|
|
3656
|
+
defaultText: l
|
|
3377
3657
|
});
|
|
3378
3658
|
},
|
|
3379
3659
|
onUserRemoved: (r) => {
|
|
3380
|
-
|
|
3660
|
+
S.info("onUserRemoved raw payload", r);
|
|
3381
3661
|
const i = e("chat.notice.you");
|
|
3382
3662
|
s.group.removeGroup(r.groupId), s.conversation.deleteConversation(r.groupId), s.message.clearConversationMessages(r.groupId);
|
|
3383
3663
|
const c = e("chat.notice.userRemoved").replace("{name}", i);
|
|
3384
3664
|
t(s, r.groupId, I.GROUPCHAT, {
|
|
3385
|
-
eventType:
|
|
3665
|
+
eventType: E.USER_REMOVED,
|
|
3386
3666
|
params: { name: i },
|
|
3387
3667
|
defaultText: c
|
|
3388
3668
|
});
|
|
3389
3669
|
},
|
|
3390
3670
|
onGroupDestroyed: (r) => {
|
|
3391
3671
|
var i;
|
|
3392
|
-
|
|
3393
|
-
eventType:
|
|
3672
|
+
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, I.GROUPCHAT, {
|
|
3673
|
+
eventType: E.GROUP_DESTROYED,
|
|
3394
3674
|
params: {},
|
|
3395
3675
|
defaultText: e("chat.notice.groupDestroyed")
|
|
3396
3676
|
});
|
|
3397
3677
|
},
|
|
3398
3678
|
onAnnouncementChanged: (r) => {
|
|
3399
|
-
|
|
3400
|
-
eventType:
|
|
3679
|
+
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, I.GROUPCHAT, {
|
|
3680
|
+
eventType: E.ANNOUNCEMENT_CHANGED,
|
|
3401
3681
|
params: { announcement: r.announcement || "" },
|
|
3402
3682
|
defaultText: n(r.announcement)
|
|
3403
3683
|
});
|
|
3404
3684
|
},
|
|
3405
3685
|
onMuteListAdded: (r) => {
|
|
3406
|
-
|
|
3407
|
-
const i = (r.mutes || []).map((
|
|
3408
|
-
userId:
|
|
3686
|
+
S.info("onMuteListAdded raw payload", r);
|
|
3687
|
+
const i = (r.mutes || []).map((l) => ({
|
|
3688
|
+
userId: l.userId,
|
|
3409
3689
|
muteExpire: r.muteExpire
|
|
3410
3690
|
}));
|
|
3411
3691
|
s.group.addGroupMuteMembers(r.groupId, i);
|
|
3412
|
-
const c = (r.mutes || []).map((
|
|
3692
|
+
const c = (r.mutes || []).map((l) => l.nickname || l.userId || ""), u = c.map((l) => e("group.mutelist.muteNotice").replace("{name}", l)).join("、");
|
|
3413
3693
|
t(s, r.groupId, I.GROUPCHAT, {
|
|
3414
|
-
eventType:
|
|
3694
|
+
eventType: E.MUTE_ADDED,
|
|
3415
3695
|
params: { names: c.join("、"), count: c.length },
|
|
3416
3696
|
defaultText: u
|
|
3417
3697
|
});
|
|
3418
3698
|
},
|
|
3419
3699
|
onMuteListRemoved: (r) => {
|
|
3420
|
-
|
|
3421
|
-
const i = (r.mutes || []).map((
|
|
3700
|
+
S.info("onMuteListRemoved raw payload", r);
|
|
3701
|
+
const i = (r.mutes || []).map((l) => l.userId);
|
|
3422
3702
|
s.group.removeGroupMuteMembers(r.groupId, i);
|
|
3423
|
-
const c = (r.mutes || []).map((
|
|
3703
|
+
const c = (r.mutes || []).map((l) => l.nickname || l.userId || ""), u = c.map((l) => e("group.mutelist.unmuteNotice").replace("{name}", l)).join("、");
|
|
3424
3704
|
t(s, r.groupId, I.GROUPCHAT, {
|
|
3425
|
-
eventType:
|
|
3705
|
+
eventType: E.MUTE_REMOVED,
|
|
3426
3706
|
params: { names: c.join("、"), count: c.length },
|
|
3427
3707
|
defaultText: u
|
|
3428
3708
|
});
|
|
3429
3709
|
},
|
|
3430
3710
|
onAllMemberMuteStateChanged: (r) => {
|
|
3431
|
-
|
|
3711
|
+
S.info("onAllMemberMuteStateChanged raw payload", r), s.group.updateGroup(r.groupId, { mute: r.isMuted });
|
|
3432
3712
|
const i = e(r.isMuted ? "group.mutelist.muteAllNotice" : "group.mutelist.unmuteAllNotice");
|
|
3433
3713
|
t(s, r.groupId, I.GROUPCHAT, {
|
|
3434
|
-
eventType:
|
|
3714
|
+
eventType: E.ALL_MEMBER_MUTE_CHANGED,
|
|
3435
3715
|
params: { muted: r.isMuted },
|
|
3436
3716
|
defaultText: i
|
|
3437
3717
|
});
|
|
3438
3718
|
},
|
|
3439
3719
|
onAllowListAdded: (r) => {
|
|
3440
|
-
|
|
3720
|
+
S.info("onAllowListAdded raw payload", r);
|
|
3441
3721
|
const i = (r.allowlist || []).map((u) => u.userId);
|
|
3442
3722
|
s.group.addGroupAllowlistMembers(r.groupId, i);
|
|
3443
|
-
const c =
|
|
3723
|
+
const c = ce(
|
|
3444
3724
|
r.allowlist || [],
|
|
3445
3725
|
s.client.currentUser || "",
|
|
3446
3726
|
"chat.notice.allowlistAdded",
|
|
3447
3727
|
"chat.notice.allowlistAddedMultiple"
|
|
3448
3728
|
);
|
|
3449
3729
|
t(s, r.groupId, I.GROUPCHAT, {
|
|
3450
|
-
eventType:
|
|
3451
|
-
params:
|
|
3730
|
+
eventType: E.ALLOWLIST_ADDED,
|
|
3731
|
+
params: ue(r.allowlist || [], s.client.currentUser || ""),
|
|
3452
3732
|
defaultText: c
|
|
3453
3733
|
});
|
|
3454
3734
|
},
|
|
3455
3735
|
onAllowListRemoved: (r) => {
|
|
3456
|
-
|
|
3736
|
+
S.info("onAllowListRemoved raw payload", r);
|
|
3457
3737
|
const i = (r.allowlist || []).map((u) => u.userId);
|
|
3458
3738
|
s.group.removeGroupAllowlistMembers(r.groupId, i);
|
|
3459
|
-
const c =
|
|
3739
|
+
const c = ce(
|
|
3460
3740
|
r.allowlist || [],
|
|
3461
3741
|
s.client.currentUser || "",
|
|
3462
3742
|
"chat.notice.allowlistRemoved",
|
|
3463
3743
|
"chat.notice.allowlistRemovedMultiple"
|
|
3464
3744
|
);
|
|
3465
3745
|
t(s, r.groupId, I.GROUPCHAT, {
|
|
3466
|
-
eventType:
|
|
3467
|
-
params:
|
|
3746
|
+
eventType: E.ALLOWLIST_REMOVED,
|
|
3747
|
+
params: ue(r.allowlist || [], s.client.currentUser || ""),
|
|
3468
3748
|
defaultText: c
|
|
3469
3749
|
});
|
|
3470
3750
|
},
|
|
3471
3751
|
onGroupDisabledChanged: (r) => {
|
|
3472
|
-
|
|
3473
|
-
eventType:
|
|
3752
|
+
S.info("onGroupDisabledChanged raw payload", r), s.group.updateGroup(r.groupId, { disabled: r.disabled }), t(s, r.groupId, I.GROUPCHAT, {
|
|
3753
|
+
eventType: E.GROUP_DISABLED_CHANGED,
|
|
3474
3754
|
params: { disabled: r.disabled },
|
|
3475
3755
|
defaultText: e(r.disabled ? "chat.notice.groupDisabled" : "chat.notice.groupEnabled")
|
|
3476
3756
|
});
|
|
3477
3757
|
},
|
|
3478
3758
|
onSharedFileAdded: (r) => {
|
|
3479
|
-
if (
|
|
3759
|
+
if (S.info("onSharedFileAdded raw payload", r), r.sharedFile) {
|
|
3480
3760
|
s.group.addGroupSharedFile(r.groupId, r.sharedFile);
|
|
3481
3761
|
const i = r.sharedFile.fileOwner, c = (i == null ? void 0 : i.userId) === s.client.currentUser ? e("chat.notice.you") : o(i), u = e("chat.notice.sharedFileAdded").replace("{name}", c || (i == null ? void 0 : i.userId) || "").replace("{fileName}", r.sharedFile.fileName);
|
|
3482
3762
|
t(s, r.groupId, I.GROUPCHAT, {
|
|
3483
|
-
eventType:
|
|
3763
|
+
eventType: E.SHARED_FILE_ADDED,
|
|
3484
3764
|
params: { name: c || (i == null ? void 0 : i.userId) || "", fileName: r.sharedFile.fileName },
|
|
3485
3765
|
defaultText: u
|
|
3486
3766
|
});
|
|
3487
3767
|
}
|
|
3488
3768
|
},
|
|
3489
3769
|
onSharedFileDeleted: (r) => {
|
|
3490
|
-
|
|
3770
|
+
S.info("onSharedFileDeleted raw payload", r), s.group.removeGroupSharedFile(r.groupId, r.fileId);
|
|
3491
3771
|
},
|
|
3492
3772
|
onRequestToJoinReceived: (r) => {
|
|
3493
3773
|
var c;
|
|
3494
|
-
|
|
3774
|
+
S.info("onRequestToJoinReceived raw payload", r);
|
|
3495
3775
|
const i = s.group.getGroupJoinRequests(r.groupId);
|
|
3496
3776
|
s.group.setGroupJoinRequests(r.groupId, [
|
|
3497
3777
|
...i,
|
|
@@ -3508,16 +3788,16 @@ function On(s) {
|
|
|
3508
3788
|
]);
|
|
3509
3789
|
},
|
|
3510
3790
|
onRequestToJoinAccepted: (r) => {
|
|
3511
|
-
|
|
3791
|
+
S.info("onRequestToJoinAccepted raw payload", r);
|
|
3512
3792
|
const i = s.client.currentUser, c = s.group.getGroupJoinRequests(r.groupId).filter((u) => {
|
|
3513
|
-
var
|
|
3514
|
-
return !(u.status === "pending" && (u.applicantId === i || ((
|
|
3793
|
+
var l;
|
|
3794
|
+
return !(u.status === "pending" && (u.applicantId === i || ((l = u.applicant) == null ? void 0 : l.userId) === i));
|
|
3515
3795
|
});
|
|
3516
3796
|
s.group.setGroupJoinRequests(r.groupId, c);
|
|
3517
3797
|
},
|
|
3518
3798
|
onRequestToJoinDeclined: (r) => {
|
|
3519
3799
|
var i;
|
|
3520
|
-
|
|
3800
|
+
S.info("onRequestToJoinDeclined raw payload", r), s.group.updateGroupJoinRequest(
|
|
3521
3801
|
r.groupId,
|
|
3522
3802
|
((i = r.applicant) == null ? void 0 : i.userId) || "",
|
|
3523
3803
|
"declined"
|
|
@@ -3525,17 +3805,17 @@ function On(s) {
|
|
|
3525
3805
|
}
|
|
3526
3806
|
};
|
|
3527
3807
|
}
|
|
3528
|
-
const
|
|
3529
|
-
function
|
|
3808
|
+
const os = T("UIKit:PresenceEvents");
|
|
3809
|
+
function is(s) {
|
|
3530
3810
|
return {
|
|
3531
3811
|
onPresenceStatusChange: (e) => {
|
|
3532
|
-
if (
|
|
3812
|
+
if (os.info("onPresenceStatusChange", { count: Array.isArray(e) ? e.length : 0 }), !Array.isArray(e))
|
|
3533
3813
|
return;
|
|
3534
3814
|
const t = e.map((n) => {
|
|
3535
3815
|
const o = n.userId || "", r = (Array.isArray(n.statusDetails) ? n.statusDetails : []).some((c) => Number(c == null ? void 0 : c.status) === 1), i = n.ext || "";
|
|
3536
3816
|
return {
|
|
3537
3817
|
userId: o,
|
|
3538
|
-
status:
|
|
3818
|
+
status: ft(r, i),
|
|
3539
3819
|
ext: i,
|
|
3540
3820
|
lastTime: n.lastTime || Date.now()
|
|
3541
3821
|
};
|
|
@@ -3544,25 +3824,25 @@ function Pn(s) {
|
|
|
3544
3824
|
}
|
|
3545
3825
|
};
|
|
3546
3826
|
}
|
|
3547
|
-
function
|
|
3548
|
-
const r =
|
|
3549
|
-
return s.addEventHandler("uikit-conn", r), s.chatManager.addEventHandler("uikit-chat", i), s.contactManager.addEventHandler("uikit-contact", c), s.groupManager.addEventHandler("uikit-group", u), s.presenceManager.addEventHandler("uikit-presence",
|
|
3550
|
-
s.removeEventHandler("uikit-conn"), s.chatManager.removeEventHandler("uikit-chat"), s.contactManager.removeEventHandler("uikit-contact"), s.groupManager.removeEventHandler("uikit-group"), s.presenceManager.removeEventHandler("uikit-presence"),
|
|
3827
|
+
function as(s, e, t = {}, n, o, a) {
|
|
3828
|
+
const r = Kn(e, t), i = ns(s, e, n, o, a), c = ss(e), u = rs(e), l = is(e);
|
|
3829
|
+
return s.addEventHandler("uikit-conn", r), s.chatManager.addEventHandler("uikit-chat", i), s.contactManager.addEventHandler("uikit-contact", c), s.groupManager.addEventHandler("uikit-group", u), s.presenceManager.addEventHandler("uikit-presence", l), () => {
|
|
3830
|
+
s.removeEventHandler("uikit-conn"), s.chatManager.removeEventHandler("uikit-chat"), s.contactManager.removeEventHandler("uikit-contact"), s.groupManager.removeEventHandler("uikit-group"), s.presenceManager.removeEventHandler("uikit-presence"), Xn(), jn();
|
|
3551
3831
|
};
|
|
3552
3832
|
}
|
|
3553
|
-
const
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
],
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3833
|
+
const _ = T("UIKit:Websdk5Adapter"), cs = [
|
|
3834
|
+
tt,
|
|
3835
|
+
yt,
|
|
3836
|
+
Ct,
|
|
3837
|
+
bt,
|
|
3838
|
+
wt,
|
|
3839
|
+
nt
|
|
3840
|
+
], us = [
|
|
3841
|
+
tt,
|
|
3842
|
+
Mt,
|
|
3843
|
+
nt
|
|
3564
3844
|
];
|
|
3565
|
-
class
|
|
3845
|
+
class ws {
|
|
3566
3846
|
constructor(e) {
|
|
3567
3847
|
this.injectedClient = e, this.capabilities = {
|
|
3568
3848
|
combineMessage: !0,
|
|
@@ -3571,7 +3851,7 @@ class ts {
|
|
|
3571
3851
|
streamingMessage: !0,
|
|
3572
3852
|
groupReadReceipt: !0,
|
|
3573
3853
|
// 本 adapter 遵循的契约版本(协商机制见 contract capabilities.ts)
|
|
3574
|
-
contractVersion:
|
|
3854
|
+
contractVersion: Ot
|
|
3575
3855
|
}, this._client = null, this._handlersSet = /* @__PURE__ */ new Set(), this._eventsRegistered = !1, this._registerImEvents = !0;
|
|
3576
3856
|
}
|
|
3577
3857
|
/** 原生 SDK 客户端实例(UIKitClient 包装,可选) */
|
|
@@ -3603,97 +3883,108 @@ class ts {
|
|
|
3603
3883
|
onUserInfoSubscriptionPermissionError: i,
|
|
3604
3884
|
registerImEvents: c,
|
|
3605
3885
|
managerPreset: u,
|
|
3606
|
-
repositories:
|
|
3607
|
-
persistence:
|
|
3608
|
-
lastMessageTextResolver:
|
|
3886
|
+
repositories: l,
|
|
3887
|
+
persistence: g,
|
|
3888
|
+
lastMessageTextResolver: p,
|
|
3609
3889
|
...d
|
|
3610
|
-
} = t,
|
|
3611
|
-
this._persistence =
|
|
3612
|
-
const { appKey: h, appId: v, ...
|
|
3613
|
-
let
|
|
3890
|
+
} = t, f = e.repositories ?? l, m = e.persistence ?? g;
|
|
3891
|
+
this._persistence = m, this._lastMessageTextResolver = p, this._loginTimeoutMs = e.loginTimeoutMs;
|
|
3892
|
+
const { appKey: h, appId: v, ...C } = d;
|
|
3893
|
+
let w;
|
|
3614
3894
|
if (e.appKey)
|
|
3615
|
-
|
|
3895
|
+
w = { appKey: e.appKey };
|
|
3616
3896
|
else if (e.appId)
|
|
3617
|
-
|
|
3897
|
+
w = { appId: e.appId };
|
|
3618
3898
|
else if (this.injectedClient)
|
|
3619
|
-
|
|
3899
|
+
w = { appKey: "" };
|
|
3620
3900
|
else
|
|
3621
3901
|
throw new Error("[Websdk5Adapter] 缺少应用身份:SdkConfig.appKey 与 SdkConfig.appId 必须提供其一");
|
|
3622
|
-
|
|
3902
|
+
const M = (n == null ? void 0 : n.enableUserInfo) === !1 ? !1 : C.enableUserInfoSync ?? !0;
|
|
3903
|
+
this._client = this.injectedClient ?? Wt({
|
|
3623
3904
|
debug: e.debug,
|
|
3624
|
-
managers: d.managers ?? (u === "chatroom" ?
|
|
3625
|
-
...
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3905
|
+
managers: d.managers ?? (u === "chatroom" ? us : cs),
|
|
3906
|
+
...C,
|
|
3907
|
+
enableUserInfoSync: M,
|
|
3908
|
+
...w
|
|
3909
|
+
}), r && mt(r), this._features = n ?? tn(), this._registerImEvents = c !== !1;
|
|
3910
|
+
const A = a ? Object.keys(a) : [];
|
|
3911
|
+
if (_.info("[Websdk5Adapter] init 开始", {
|
|
3630
3912
|
mode: this.injectedClient ? "injected-client" : "builtin",
|
|
3631
3913
|
managerPreset: u ?? "im",
|
|
3632
3914
|
registerImEvents: this._registerImEvents,
|
|
3633
|
-
injectedStores:
|
|
3634
|
-
}),
|
|
3635
|
-
const
|
|
3636
|
-
|
|
3915
|
+
injectedStores: A
|
|
3916
|
+
}), A.length < 7) {
|
|
3917
|
+
const O = ["client", "message", "conversation", "contact", "group", "presence", "userInfo"];
|
|
3918
|
+
_.debug(
|
|
3637
3919
|
"[Websdk5Adapter] 以下 store 域未注入,回落 adapter 内置 store:",
|
|
3638
|
-
|
|
3920
|
+
O.filter((U) => !A.includes(U))
|
|
3639
3921
|
);
|
|
3640
3922
|
}
|
|
3641
|
-
const
|
|
3642
|
-
this._stores =
|
|
3643
|
-
message: new
|
|
3644
|
-
messageRepository:
|
|
3645
|
-
persistence:
|
|
3923
|
+
const x = { ...en(this, () => this._getFanout()), ...a };
|
|
3924
|
+
this._stores = x, this._domains = {
|
|
3925
|
+
message: new Sn(this._client, x.message, {
|
|
3926
|
+
messageRepository: f == null ? void 0 : f.message,
|
|
3927
|
+
persistence: m == null ? void 0 : m.message
|
|
3646
3928
|
}),
|
|
3647
|
-
conversation: new
|
|
3648
|
-
sendPendingReadReceipts: (
|
|
3649
|
-
var
|
|
3650
|
-
((
|
|
3929
|
+
conversation: new Rn(this._client, x.conversation, {
|
|
3930
|
+
sendPendingReadReceipts: (O, U) => {
|
|
3931
|
+
var Z, He;
|
|
3932
|
+
((Z = this._features) == null ? void 0 : Z.enableReadReceipt) !== !1 && ((He = this._domains) == null || He.message.sendPendingReadReceipts(O, U));
|
|
3933
|
+
},
|
|
3934
|
+
resolveSenderName: (O) => {
|
|
3935
|
+
var Z;
|
|
3936
|
+
const U = x.contact.getContact(O);
|
|
3937
|
+
return U != null && U.remark || U != null && U.name ? U.remark || U.name : (Z = x.userInfo.getUserInfo(O)) == null ? void 0 : Z.nickname;
|
|
3651
3938
|
},
|
|
3652
|
-
|
|
3653
|
-
var
|
|
3654
|
-
|
|
3655
|
-
return L != null && L.remark || L != null && L.name ? L.remark || L.name : (Y = R.userInfo.getUserInfo(W)) == null ? void 0 : Y.nickname;
|
|
3939
|
+
prefillUserInfo: (O) => {
|
|
3940
|
+
var U;
|
|
3941
|
+
return (U = this._userInfoDomain) == null ? void 0 : U.prefillUserInfos(O);
|
|
3656
3942
|
},
|
|
3657
3943
|
lastMessageTextResolver: this._lastMessageTextResolver,
|
|
3658
|
-
conversationRepository:
|
|
3659
|
-
persistence:
|
|
3944
|
+
conversationRepository: f == null ? void 0 : f.conversation,
|
|
3945
|
+
persistence: m == null ? void 0 : m.conversation
|
|
3660
3946
|
}),
|
|
3661
|
-
contact: new
|
|
3662
|
-
contactRepository:
|
|
3947
|
+
contact: new Dn(this._client, x.contact, {
|
|
3948
|
+
contactRepository: f == null ? void 0 : f.contact
|
|
3663
3949
|
}),
|
|
3664
|
-
group: new
|
|
3665
|
-
groupRepository:
|
|
3950
|
+
group: new kn(this._client, x.group, {
|
|
3951
|
+
groupRepository: f == null ? void 0 : f.group
|
|
3666
3952
|
}),
|
|
3667
|
-
presence: new
|
|
3668
|
-
presenceRepository:
|
|
3953
|
+
presence: new On(this._client, x.presence, {
|
|
3954
|
+
presenceRepository: f == null ? void 0 : f.presence
|
|
3669
3955
|
})
|
|
3670
|
-
}
|
|
3956
|
+
};
|
|
3957
|
+
const vt = (f == null ? void 0 : f.userInfo) ?? nn(o) ?? {};
|
|
3958
|
+
this._userInfoDomain = new Hn(
|
|
3671
3959
|
this._client,
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3960
|
+
x.userInfo,
|
|
3961
|
+
{
|
|
3962
|
+
readCachedUserInfos: (O) => ln(this._client, O),
|
|
3963
|
+
...vt
|
|
3964
|
+
},
|
|
3965
|
+
i ?? (() => _.warn("[Websdk5Adapter] 用户资料订阅无权限,已自动熔断"))
|
|
3966
|
+
), this._userInfoDomain.listen(), this._setupEventHandlers(), _.info("[Websdk5Adapter] init 完成");
|
|
3676
3967
|
}
|
|
3677
3968
|
async login(e, t) {
|
|
3678
|
-
var o, a, r, i, c, u,
|
|
3969
|
+
var o, a, r, i, c, u, l;
|
|
3679
3970
|
if (!this._client)
|
|
3680
3971
|
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3681
|
-
this._eventsRegistered || (
|
|
3682
|
-
const n =
|
|
3683
|
-
n !== e &&
|
|
3972
|
+
this._eventsRegistered || (_.debug("[Websdk5Adapter] 登出后重新登录,恢复事件处理器与用户资料监听"), (o = this._userInfoDomain) == null || o.listen(), this._setupEventHandlers());
|
|
3973
|
+
const n = xt(e);
|
|
3974
|
+
n !== e && _.warn("[Websdk5Adapter] 检测到登录 userId 包含大写字母,已强制转换为纯小写后继续登录", {
|
|
3684
3975
|
originalUserId: e,
|
|
3685
3976
|
normalizedUserId: n
|
|
3686
|
-
}),
|
|
3977
|
+
}), _.info("[Websdk5Adapter] login 开始", { user: n }), (i = (a = this._stores) == null ? void 0 : (r = a.client).setCurrentUser) == null || i.call(r, n);
|
|
3687
3978
|
try {
|
|
3688
3979
|
await this._client.login(n, t, this._loginTimeoutMs);
|
|
3689
|
-
} catch (
|
|
3690
|
-
throw (
|
|
3980
|
+
} catch (g) {
|
|
3981
|
+
throw (l = (c = this._stores) == null ? void 0 : (u = c.client).setCurrentUser) == null || l.call(u, ""), _.error("[Websdk5Adapter] login 失败:", L(g)), g;
|
|
3691
3982
|
}
|
|
3692
|
-
|
|
3983
|
+
_.info("[Websdk5Adapter] login 成功", { user: n });
|
|
3693
3984
|
}
|
|
3694
3985
|
async logout() {
|
|
3695
3986
|
var e, t, n, o, a;
|
|
3696
|
-
|
|
3987
|
+
_.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
3988
|
}
|
|
3698
3989
|
/** 订阅中立事件,返回取消订阅函数(支持多方订阅,内部扇出派发) */
|
|
3699
3990
|
subscribe(e) {
|
|
@@ -3720,13 +4011,13 @@ class ts {
|
|
|
3720
4011
|
var e, t;
|
|
3721
4012
|
if (!(!this._client || !this._stores)) {
|
|
3722
4013
|
if (!this._registerImEvents) {
|
|
3723
|
-
|
|
4014
|
+
_.debug("[Websdk5Adapter] IM 事件套件已关闭(registerImEvents=false),场景事件由业务经 onAdapterReady 自行注册");
|
|
3724
4015
|
return;
|
|
3725
4016
|
}
|
|
3726
|
-
|
|
4017
|
+
Wn(), (e = this._disposeSyncListener) == null || e.call(this), this._disposeSyncListener = qn((n) => {
|
|
3727
4018
|
var o, a;
|
|
3728
4019
|
(a = (o = this._getFanout()).onSyncStatus) == null || a.call(o, n);
|
|
3729
|
-
}), (t = this._disposeEventHandlers) == null || t.call(this), this._disposeEventHandlers =
|
|
4020
|
+
}), (t = this._disposeEventHandlers) == null || t.call(this), this._disposeEventHandlers = as(
|
|
3730
4021
|
this._client,
|
|
3731
4022
|
this._stores,
|
|
3732
4023
|
{
|
|
@@ -3742,95 +4033,96 @@ class ts {
|
|
|
3742
4033
|
this._features,
|
|
3743
4034
|
this._persistence,
|
|
3744
4035
|
this._lastMessageTextResolver
|
|
3745
|
-
), this._eventsRegistered = !0,
|
|
4036
|
+
), this._eventsRegistered = !0, _.debug("[Websdk5Adapter] SDK 事件处理器已注册");
|
|
3746
4037
|
}
|
|
3747
4038
|
}
|
|
3748
4039
|
get message() {
|
|
3749
4040
|
if (!this._domains)
|
|
3750
4041
|
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3751
|
-
return
|
|
4042
|
+
return an({ message: this._domains.message, conversation: this._domains.conversation });
|
|
3752
4043
|
}
|
|
3753
4044
|
get conversation() {
|
|
3754
4045
|
if (!this._domains)
|
|
3755
4046
|
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3756
|
-
return
|
|
4047
|
+
return rn(this._domains.conversation);
|
|
3757
4048
|
}
|
|
3758
4049
|
get contact() {
|
|
3759
4050
|
if (!this._domains)
|
|
3760
4051
|
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3761
|
-
return
|
|
4052
|
+
return sn(this._domains.contact);
|
|
3762
4053
|
}
|
|
3763
4054
|
get group() {
|
|
3764
4055
|
if (!this._domains)
|
|
3765
4056
|
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3766
|
-
return
|
|
4057
|
+
return on(this._domains.group);
|
|
3767
4058
|
}
|
|
3768
4059
|
get presence() {
|
|
3769
4060
|
if (!this._domains)
|
|
3770
4061
|
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3771
|
-
return
|
|
4062
|
+
return cn(this._domains.presence);
|
|
3772
4063
|
}
|
|
3773
4064
|
get userInfo() {
|
|
3774
4065
|
if (!this._userInfoDomain)
|
|
3775
4066
|
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3776
|
-
return
|
|
4067
|
+
return un(this._userInfoDomain);
|
|
3777
4068
|
}
|
|
3778
4069
|
}
|
|
3779
4070
|
export {
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
Hn as
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
4071
|
+
Ue as ALL_USER_INFO_ATTRIBUTES,
|
|
4072
|
+
Dn as ContactDomain,
|
|
4073
|
+
Rn as ConversationDomain,
|
|
4074
|
+
kn as GroupDomain,
|
|
4075
|
+
Sn as MessageDomain,
|
|
4076
|
+
Ge as PRESENCE_REQUEST_BATCH_SIZE,
|
|
4077
|
+
On as PresenceDomain,
|
|
4078
|
+
Vt as UIKitClient,
|
|
4079
|
+
Hn as UserInfoDomain,
|
|
4080
|
+
us as WEBSDK5_CHATROOM_MANAGERS,
|
|
4081
|
+
cs as WEBSDK5_MANAGERS,
|
|
4082
|
+
ws as Websdk5Adapter,
|
|
4083
|
+
ns as createChatHandlers,
|
|
4084
|
+
Wt as createClient,
|
|
4085
|
+
Kn as createConnectionHandlers,
|
|
4086
|
+
ss as createContactHandlers,
|
|
4087
|
+
rs as createGroupHandlers,
|
|
4088
|
+
is as createPresenceHandlers,
|
|
4089
|
+
Be as defaultAdapterPreviewLabels,
|
|
4090
|
+
ps as disableSdkLogCapture,
|
|
4091
|
+
ms as enableSdkLogCapture,
|
|
4092
|
+
Is as extractLastMessageText,
|
|
4093
|
+
hn as extractSdkErrorReason,
|
|
4094
|
+
gn as extractSnippetText,
|
|
4095
|
+
L as formatSdkError,
|
|
4096
|
+
Ms as isMessageInConversation,
|
|
4097
|
+
hs as isSdkDebugEnabled,
|
|
4098
|
+
Cn as markReadReceiptSent,
|
|
4099
|
+
Es as normalizeUserId,
|
|
4100
|
+
Qe as notifyContactEvent,
|
|
4101
|
+
$n as notifyOnNewMessage,
|
|
4102
|
+
ft as parsePresenceStatus,
|
|
4103
|
+
as as registerEventHandlers,
|
|
4104
|
+
Xn as resetChatEventState,
|
|
4105
|
+
jn as resetSyncStatus,
|
|
4106
|
+
ys as resolvePeerUserId,
|
|
4107
|
+
pn as resolveSdkErrorCodeI18nKey,
|
|
4108
|
+
vn as resolveSdkErrorI18nKey,
|
|
4109
|
+
Cs as resolveSdkErrorMessage,
|
|
4110
|
+
pt as resolveSenderDisplayName,
|
|
4111
|
+
Jn as resolveUserDisplayName,
|
|
4112
|
+
mt as setEventHandlerDeps,
|
|
4113
|
+
Ht as setSdkDebugGuard,
|
|
4114
|
+
gs as setSdkLogAppender,
|
|
4115
|
+
Re as setSyncStatus,
|
|
4116
|
+
qn as setSyncStatusListener,
|
|
4117
|
+
Ln as toUiContact,
|
|
4118
|
+
ke as toUiContacts,
|
|
4119
|
+
An as toUiConversation,
|
|
4120
|
+
se as toUiConversations,
|
|
4121
|
+
Fe as toUiGroup,
|
|
4122
|
+
Nn as toUiGroupMember,
|
|
4123
|
+
te as toUiGroupMembers,
|
|
4124
|
+
Ie as toUiGroups,
|
|
4125
|
+
H as toUiMessage,
|
|
4126
|
+
vs as toUiMessages,
|
|
4127
|
+
bs as useSyncStatus
|
|
3836
4128
|
};
|