@easemob-community/uikit-sdk-websdk5 1.3.4 → 1.5.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.d.ts +2 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/client.d.ts +4 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/easemob-uikit-sdk-websdk5.js +629 -609
- package/dist/easemob-uikit-sdk-websdk5.umd.cjs +1 -1
- package/dist/utils/sdk-log-capture.d.ts.map +1 -1
- 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
|
-
|
|
8
|
-
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
const
|
|
1
|
+
import { ChatClient as et, isSDKError as Fe, ChatManager as Be, ChatRoomManager as tt, UserInfoManager as He, ContactManager as nt, GroupManager as st, PresenceManager as rt, PushManager as ot } from "easemob-websdk";
|
|
2
|
+
import { log as Ce, customEventPreviewMap as it, mergeMessagePreviewLabels as Ke, isTextBody as at, isImageBody as ct, isVoiceBody as je, isVideoBody as ut, isFileBody as dt, isLocationBody as lt, isCustomBody as gt, isCmdBody as pt, isCombineBody as Ve, MESSAGE_TYPE as S, CONVERSATION_TYPE as M, normalizeUserId as A, MESSAGE_STATUS as x, createLogger as T, toMessageRecord as we, formatConversationPreview as qe, GROUP_MEMBER_ROLE as N, PRESENCE_STATUS as Y, isKickErrorCode as ft, resolveLastMessageText as mt, isStreamActive as ht, toConversationRecord as Le, NOTICE_EVENT_TYPE as G, SDK_CONTRACT_VERSION as vt } from "@easemob-community/uikit-sdk-contract";
|
|
3
|
+
import { normalizeUserId as Kn } from "@easemob-community/uikit-sdk-contract";
|
|
4
|
+
import { markRaw as It, computed as pe, reactive as Mt } from "vue";
|
|
5
|
+
let ie = null;
|
|
6
|
+
function Tn(s) {
|
|
7
|
+
ie = s;
|
|
8
|
+
}
|
|
9
|
+
function bt(s) {
|
|
10
|
+
ie == null || ie(s);
|
|
11
|
+
}
|
|
12
|
+
const We = "uikit-sdk-log-capture", Ct = /^%c\[Chat\]\[(DEBUG|WARN|ERROR)\]\[[^\]]*\]/, Je = {
|
|
13
13
|
DEBUG: "debug",
|
|
14
14
|
WARN: "warn",
|
|
15
15
|
ERROR: "error"
|
|
16
16
|
};
|
|
17
|
-
let
|
|
18
|
-
function
|
|
19
|
-
|
|
17
|
+
let $ = !1, H = null, j = null, ae = null, ye = !1, B = null, ce = null;
|
|
18
|
+
function wt(s) {
|
|
19
|
+
ce = s;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
level:
|
|
21
|
+
function Z(s, e, t) {
|
|
22
|
+
$ && bt({
|
|
23
|
+
level: Je[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 fe(s, e, t) {
|
|
30
|
+
const n = j ?? console.log, o = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
31
31
|
n.call(
|
|
32
32
|
console,
|
|
33
33
|
`%c[Chat][${s}][${o}]`,
|
|
@@ -36,79 +36,88 @@ function de(s, e, t) {
|
|
|
36
36
|
...t
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
39
|
+
function yt() {
|
|
40
|
+
j || (j = 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(Ct);
|
|
45
|
+
t && Z(t[1], s[2], s.slice(3));
|
|
46
46
|
}
|
|
47
47
|
} catch {
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
j.apply(console, s);
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
52
|
+
function St() {
|
|
53
|
+
j && (console.log = j, j = null);
|
|
54
54
|
}
|
|
55
|
-
async function
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
async function Un() {
|
|
56
|
+
var s;
|
|
57
|
+
if (!$) {
|
|
58
|
+
$ = !0;
|
|
58
59
|
try {
|
|
59
|
-
const
|
|
60
|
-
typeof
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const e = await import("easemob-websdk");
|
|
61
|
+
typeof e.setLogLevel == "function" && (e.setLogLevel("DEBUG"), ye = !0);
|
|
62
|
+
const t = e.LogEventName ? (s = e.ChatClient) == null ? void 0 : s.instance : null;
|
|
63
|
+
t && typeof t.addEventHandler == "function" ? (t.addEventHandler(We, {
|
|
64
|
+
onLog: (n) => {
|
|
65
|
+
const o = n;
|
|
66
|
+
o && typeof o.level == "string" && o.level in Je && Z(o.level, o.message, [...o.args ?? []]);
|
|
67
|
+
}
|
|
68
|
+
}), B = t, H = "onlog") : typeof e.setLogger == "function" ? (ae = typeof e.getLogger == "function" ? e.getLogger() : null, e.setLogger({
|
|
69
|
+
debug: (n, ...o) => {
|
|
70
|
+
Z("DEBUG", n, o), fe("DEBUG", n, o);
|
|
63
71
|
},
|
|
64
|
-
warn: (
|
|
65
|
-
|
|
72
|
+
warn: (n, ...o) => {
|
|
73
|
+
Z("WARN", n, o), fe("WARN", n, o);
|
|
66
74
|
},
|
|
67
|
-
error: (
|
|
68
|
-
|
|
75
|
+
error: (n, ...o) => {
|
|
76
|
+
Z("ERROR", n, o), fe("ERROR", n, o);
|
|
69
77
|
}
|
|
70
|
-
}),
|
|
71
|
-
} catch (
|
|
72
|
-
|
|
78
|
+
}), H = "inject") : (yt(), H = "console");
|
|
79
|
+
} catch (e) {
|
|
80
|
+
$ = !1, console.warn("[UIKit:SdkLogCapture] failed to enable SDK log capture", e);
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
|
-
async function
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
async function Ln() {
|
|
85
|
+
var s;
|
|
86
|
+
if ($) {
|
|
87
|
+
$ = !1;
|
|
79
88
|
try {
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
89
|
+
H === "console" && St(), H === "onlog" && ((s = B == null ? void 0 : B.removeEventHandler) == null || s.call(B, We));
|
|
90
|
+
const e = await import("easemob-websdk");
|
|
91
|
+
H === "inject" && typeof e.setLogger == "function" && ae && e.setLogger(ae), ye && !(ce != null && ce()) && typeof e.setLogLevel == "function" && e.setLogLevel("WARN");
|
|
83
92
|
} catch {
|
|
84
93
|
} finally {
|
|
85
|
-
|
|
94
|
+
H = null, B = null, ae = null, ye = !1;
|
|
86
95
|
}
|
|
87
96
|
}
|
|
88
97
|
}
|
|
89
|
-
let
|
|
90
|
-
function
|
|
91
|
-
return
|
|
98
|
+
let Re = !1;
|
|
99
|
+
function Dn() {
|
|
100
|
+
return Re;
|
|
92
101
|
}
|
|
93
|
-
let
|
|
94
|
-
function
|
|
95
|
-
const e =
|
|
102
|
+
let $e = null;
|
|
103
|
+
function Gt(s) {
|
|
104
|
+
const e = $e;
|
|
96
105
|
if (!e)
|
|
97
106
|
return s;
|
|
98
|
-
if (s.appKey !== e.appKey)
|
|
107
|
+
if (s.appKey !== e.appKey || s.appId !== e.appId)
|
|
99
108
|
throw new Error(
|
|
100
|
-
`[UIKit] ClientConfig
|
|
109
|
+
`[UIKit] ClientConfig 应用身份(appKey=${s.appKey ?? "-"} / appId=${s.appId ?? "-"})与已初始化的 SDK 单例(appKey=${e.appKey ?? "-"} / appId=${e.appId ?? "-"})不一致:同一应用内多个 UIKit 场景包必须使用同一个 appKey/appId(SDK 连接与事件总线是全局单例)。`
|
|
101
110
|
);
|
|
102
111
|
const { managers: t, ...n } = s, o = [];
|
|
103
112
|
for (const a of Object.keys(n))
|
|
104
113
|
JSON.stringify(n[a]) !== JSON.stringify(e[a]) && o.push(a);
|
|
105
|
-
return o.length > 0 &&
|
|
114
|
+
return o.length > 0 && Ce(
|
|
106
115
|
"[UIKit] SDK 已初始化,本次 init 配置以首次初始化为准(忽略字段:%s)。",
|
|
107
116
|
o.join(", ")
|
|
108
117
|
), { ...e, managers: t };
|
|
109
118
|
}
|
|
110
|
-
|
|
111
|
-
class
|
|
119
|
+
wt(() => Re);
|
|
120
|
+
class At {
|
|
112
121
|
constructor(e) {
|
|
113
122
|
var i;
|
|
114
123
|
const { debug: t, clientName: n = "UIKit", clientVersion: o, ...a } = e;
|
|
@@ -116,25 +125,25 @@ class bt {
|
|
|
116
125
|
throw new Error(
|
|
117
126
|
"[UIKit] ClientConfig.managers 未注入:SDK manager 列表由 adapter 负责传入"
|
|
118
127
|
);
|
|
119
|
-
const r =
|
|
128
|
+
const r = Gt({
|
|
120
129
|
...a,
|
|
121
130
|
enableUserInfoSync: a.enableUserInfoSync ?? !0,
|
|
122
131
|
managers: a.managers
|
|
123
132
|
});
|
|
124
|
-
this._deleteConversationOnGroupDestroyed = r.deleteConversationOnGroupDestroyed ?? !0, this._client =
|
|
133
|
+
this._deleteConversationOnGroupDestroyed = r.deleteConversationOnGroupDestroyed ?? !0, this._client = et.init(r), $e = r, t && (Re = !0, import("easemob-websdk").then(({ setLogLevel: u }) => {
|
|
125
134
|
u("DEBUG");
|
|
126
|
-
})), o ?
|
|
135
|
+
})), o ? Ce(
|
|
127
136
|
"%c[Easemob] SDK version: %s, %s version: %s, Adapter version: %s",
|
|
128
137
|
"color: green; font-weight: bold;",
|
|
129
|
-
"5.
|
|
138
|
+
"5.1.2",
|
|
130
139
|
n,
|
|
131
140
|
o,
|
|
132
|
-
"1.
|
|
133
|
-
) :
|
|
141
|
+
"1.5.0"
|
|
142
|
+
) : Ce(
|
|
134
143
|
"%c[Easemob] SDK version: %s, Adapter version: %s",
|
|
135
144
|
"color: green; font-weight: bold;",
|
|
136
|
-
"5.
|
|
137
|
-
"1.
|
|
145
|
+
"5.1.2",
|
|
146
|
+
"1.5.0"
|
|
138
147
|
);
|
|
139
148
|
}
|
|
140
149
|
get chatManager() {
|
|
@@ -176,17 +185,17 @@ class bt {
|
|
|
176
185
|
removeEventHandler(e) {
|
|
177
186
|
this._client.removeEventHandler(e);
|
|
178
187
|
}
|
|
179
|
-
async login(e, t) {
|
|
180
|
-
return this._client.login({ userId: e, token: t });
|
|
188
|
+
async login(e, t, n) {
|
|
189
|
+
return this._client.login({ userId: e, token: t, ...n !== void 0 ? { timeoutMs: n } : {} });
|
|
181
190
|
}
|
|
182
191
|
async logout() {
|
|
183
192
|
return this._client.logout();
|
|
184
193
|
}
|
|
185
194
|
}
|
|
186
|
-
function
|
|
187
|
-
return new
|
|
195
|
+
function Et(s) {
|
|
196
|
+
return new At(s);
|
|
188
197
|
}
|
|
189
|
-
const
|
|
198
|
+
const Rt = T("UIKit:MessageAdapter"), Te = {
|
|
190
199
|
image: "[图片]",
|
|
191
200
|
sticker: "[表情]",
|
|
192
201
|
voice: "[语音]",
|
|
@@ -194,11 +203,11 @@ const Ct = R("UIKit:MessageAdapter"), Ge = {
|
|
|
194
203
|
file: "[文件]",
|
|
195
204
|
location: "[位置]",
|
|
196
205
|
combine: "[聊天记录]",
|
|
197
|
-
custom:
|
|
206
|
+
custom: it,
|
|
198
207
|
customFallback: "[自定义]",
|
|
199
208
|
unknown: ""
|
|
200
209
|
};
|
|
201
|
-
function
|
|
210
|
+
function De(s) {
|
|
202
211
|
if (s.event && typeof s.event == "string")
|
|
203
212
|
return s.event;
|
|
204
213
|
const e = s.params;
|
|
@@ -209,8 +218,8 @@ function Ee(s) {
|
|
|
209
218
|
}
|
|
210
219
|
return "";
|
|
211
220
|
}
|
|
212
|
-
function
|
|
213
|
-
e ||
|
|
221
|
+
function O(s, e) {
|
|
222
|
+
e || Rt.warn("[toUiMessage] currentUserId is empty, isSelf may be inaccurate", {
|
|
214
223
|
from: s.from,
|
|
215
224
|
conversationId: s.conversationId,
|
|
216
225
|
type: s.type
|
|
@@ -219,26 +228,26 @@ function x(s, e) {
|
|
|
219
228
|
...s,
|
|
220
229
|
isSelf: t,
|
|
221
230
|
localId: s.msgLocalId,
|
|
222
|
-
status: t && s.isPeerRead === !0 ?
|
|
231
|
+
status: t && s.isPeerRead === !0 ? x.READ : s.sendStatus ?? x.SENT
|
|
223
232
|
};
|
|
224
|
-
return
|
|
233
|
+
return Ve(n.body) && n.body.messageList && (n.body = {
|
|
225
234
|
...n.body,
|
|
226
|
-
messageList:
|
|
235
|
+
messageList: It([...n.body.messageList])
|
|
227
236
|
}), n;
|
|
228
237
|
}
|
|
229
|
-
function
|
|
230
|
-
return s.map((t) =>
|
|
238
|
+
function _n(s, e) {
|
|
239
|
+
return s.map((t) => O(t, e));
|
|
231
240
|
}
|
|
232
|
-
function
|
|
241
|
+
function Nn(s, e) {
|
|
233
242
|
if (!s)
|
|
234
243
|
return "";
|
|
235
|
-
const t =
|
|
236
|
-
return
|
|
244
|
+
const t = Ke({ ...Te, ...e }), { body: n } = s;
|
|
245
|
+
return at(n) ? n.content || "" : ct(n) ? t.image : je(n) ? t.voice : ut(n) ? t.video : dt(n) ? n.filename || t.file : lt(n) ? t.location : gt(n) ? t.custom[n.event || ""] || t.customFallback : pt(n) ? "[命令]" : Ve(n) ? n.summary || t.combine : "";
|
|
237
246
|
}
|
|
238
|
-
function
|
|
247
|
+
function Tt(s, e) {
|
|
239
248
|
if (!s)
|
|
240
249
|
return "";
|
|
241
|
-
const t =
|
|
250
|
+
const t = Ke({ ...Te, ...e }), n = s.body || {};
|
|
242
251
|
switch (s.type) {
|
|
243
252
|
case S.TEXT:
|
|
244
253
|
return n.content || n.summary || "";
|
|
@@ -253,7 +262,7 @@ function yt(s, e) {
|
|
|
253
262
|
case S.LOCATION:
|
|
254
263
|
return t.location;
|
|
255
264
|
case S.CUSTOM: {
|
|
256
|
-
const o =
|
|
265
|
+
const o = De(n);
|
|
257
266
|
return t.custom[o] || t.customFallback;
|
|
258
267
|
}
|
|
259
268
|
case S.CMD:
|
|
@@ -261,21 +270,21 @@ function yt(s, e) {
|
|
|
261
270
|
case S.COMBINE:
|
|
262
271
|
return n.summary || t.combine;
|
|
263
272
|
default: {
|
|
264
|
-
const o =
|
|
273
|
+
const o = De(n);
|
|
265
274
|
return o ? t.custom[o] || t.customFallback : n.content || n.summary || n.msg || "";
|
|
266
275
|
}
|
|
267
276
|
}
|
|
268
277
|
}
|
|
269
|
-
function
|
|
278
|
+
function kn(s, e, t) {
|
|
270
279
|
return s.conversationId === e && s.conversationType === t;
|
|
271
280
|
}
|
|
272
|
-
function
|
|
281
|
+
function xn(s, e) {
|
|
273
282
|
return s.conversationType === M.GROUPCHAT || A(s.from) === A(e) ? s.to : s.from;
|
|
274
283
|
}
|
|
275
|
-
function
|
|
276
|
-
return
|
|
284
|
+
function R(s) {
|
|
285
|
+
return Fe(s) ? s.toJSON() : s;
|
|
277
286
|
}
|
|
278
|
-
const
|
|
287
|
+
const Ut = {
|
|
279
288
|
// 连接 / 网络
|
|
280
289
|
1: "error.unknown",
|
|
281
290
|
2: "error.network",
|
|
@@ -362,28 +371,28 @@ const St = {
|
|
|
362
371
|
1600: "error.userInfoSubscriptionLimitExceeded",
|
|
363
372
|
1601: "error.userInfoSubscriptionTargetLimitExceeded"
|
|
364
373
|
};
|
|
365
|
-
function
|
|
366
|
-
return
|
|
374
|
+
function Lt(s) {
|
|
375
|
+
return Fe(s) ? Ut[s.code] ?? null : null;
|
|
367
376
|
}
|
|
368
|
-
function
|
|
377
|
+
function Dt(s) {
|
|
369
378
|
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);
|
|
370
379
|
}
|
|
371
|
-
function
|
|
380
|
+
function _t(s) {
|
|
372
381
|
const e = s.toLowerCase();
|
|
373
382
|
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";
|
|
374
383
|
}
|
|
375
|
-
function
|
|
376
|
-
const n =
|
|
384
|
+
function On(s, e, t) {
|
|
385
|
+
const n = Lt(s);
|
|
377
386
|
if (n) {
|
|
378
387
|
const r = t(n);
|
|
379
388
|
if (r && r !== n)
|
|
380
389
|
return r;
|
|
381
390
|
}
|
|
382
|
-
const o =
|
|
391
|
+
const o = Dt(s), a = _t(o);
|
|
383
392
|
return a !== "error.unknown" ? t(a) || t(e) || o : t(n || e) || o || "";
|
|
384
393
|
}
|
|
385
|
-
const
|
|
386
|
-
function
|
|
394
|
+
const me = T("Combine"), he = T("History"), _ = T("MessageDomain"), Nt = 150;
|
|
395
|
+
function kt(s) {
|
|
387
396
|
return new Promise((e) => {
|
|
388
397
|
if (typeof document > "u" || typeof URL.createObjectURL != "function") {
|
|
389
398
|
e(void 0);
|
|
@@ -401,27 +410,27 @@ function Tt(s) {
|
|
|
401
410
|
}), n.addEventListener("error", () => a(void 0)), setTimeout(() => a(void 0), 5e3);
|
|
402
411
|
});
|
|
403
412
|
}
|
|
404
|
-
const
|
|
405
|
-
function
|
|
413
|
+
const K = /* @__PURE__ */ new Set(), xt = 5e3;
|
|
414
|
+
function Ot(s) {
|
|
406
415
|
for (const e of s)
|
|
407
|
-
if (
|
|
408
|
-
const t =
|
|
409
|
-
t !== void 0 &&
|
|
416
|
+
if (K.add(e), K.size > xt) {
|
|
417
|
+
const t = K.values().next().value;
|
|
418
|
+
t !== void 0 && K.delete(t);
|
|
410
419
|
}
|
|
411
420
|
}
|
|
412
|
-
function
|
|
413
|
-
Promise.resolve().then(s).catch((e) =>
|
|
421
|
+
function te(s) {
|
|
422
|
+
Promise.resolve().then(s).catch((e) => _.warn("persistence 钩子执行失败(已忽略):", e));
|
|
414
423
|
}
|
|
415
|
-
function
|
|
424
|
+
function Pt(s, e) {
|
|
416
425
|
const t = A(s.from) === A(e);
|
|
417
426
|
return {
|
|
418
427
|
...s,
|
|
419
428
|
isSelf: t,
|
|
420
429
|
localId: s.msgLocalId,
|
|
421
|
-
status: t && s.isPeerRead === !0 ?
|
|
430
|
+
status: t && s.isPeerRead === !0 ? x.READ : s.sendStatus ?? x.SENT
|
|
422
431
|
};
|
|
423
432
|
}
|
|
424
|
-
class
|
|
433
|
+
class Ft {
|
|
425
434
|
constructor(e, t, n = {}) {
|
|
426
435
|
this.client = e, this.store = t, this.options = n;
|
|
427
436
|
}
|
|
@@ -469,7 +478,7 @@ class _t {
|
|
|
469
478
|
return this._send(i);
|
|
470
479
|
}
|
|
471
480
|
async sendVideo(e, t, n, o, a, r) {
|
|
472
|
-
const i = typeof n == "string" ? void 0 : await
|
|
481
|
+
const i = typeof n == "string" ? void 0 : await kt(n), u = this.client.chatManager.createVideoMessage({
|
|
473
482
|
conversationId: e,
|
|
474
483
|
conversationType: t,
|
|
475
484
|
duration: o,
|
|
@@ -522,7 +531,7 @@ class _t {
|
|
|
522
531
|
messageList: r,
|
|
523
532
|
ext: i
|
|
524
533
|
});
|
|
525
|
-
return
|
|
534
|
+
return me.info("createCombineMessage done", {
|
|
526
535
|
items: r.length,
|
|
527
536
|
elapsedMs: Math.round(performance.now() - u)
|
|
528
537
|
}), this._send(d);
|
|
@@ -533,7 +542,7 @@ class _t {
|
|
|
533
542
|
const t = e.msgLocalId, n = e.type === S.COMBINE;
|
|
534
543
|
if (e.type === S.CMD)
|
|
535
544
|
return this.client.chatManager.sendMessage(e);
|
|
536
|
-
e.requireGroupAck &&
|
|
545
|
+
e.requireGroupAck && _.info("[GroupAck] 发送消息携带 needReadReceipt", {
|
|
537
546
|
conversationId: e.conversationId,
|
|
538
547
|
conversationType: e.conversationType,
|
|
539
548
|
msgLocalId: e.msgLocalId
|
|
@@ -545,19 +554,19 @@ class _t {
|
|
|
545
554
|
onFileUploadProgress: (f) => {
|
|
546
555
|
o += 1;
|
|
547
556
|
const c = f.percent ?? 0, l = performance.now();
|
|
548
|
-
c < 100 && l - a <
|
|
557
|
+
c < 100 && l - a < Nt || (a = l, this.store.updateUploadProgress(t, c));
|
|
549
558
|
}
|
|
550
559
|
});
|
|
551
|
-
n &&
|
|
560
|
+
n && me.info("sendMessage done", {
|
|
552
561
|
elapsedMs: Math.round(performance.now() - r),
|
|
553
562
|
progressEvents: o
|
|
554
563
|
});
|
|
555
|
-
const d =
|
|
564
|
+
const d = O(u, this.currentUserId);
|
|
556
565
|
this.store.replaceWithSent(t, d);
|
|
557
566
|
const g = (i = this.options.persistence) == null ? void 0 : i.saveMessage;
|
|
558
|
-
return g &&
|
|
567
|
+
return g && te(() => g(we(u))), u;
|
|
559
568
|
} catch (u) {
|
|
560
|
-
n &&
|
|
569
|
+
n && me.warn("sendMessage failed", {
|
|
561
570
|
elapsedMs: Math.round(performance.now() - r),
|
|
562
571
|
progressEvents: o,
|
|
563
572
|
error: u instanceof Error ? u.message : String(u)
|
|
@@ -571,7 +580,7 @@ class _t {
|
|
|
571
580
|
var g, f;
|
|
572
581
|
const a = (g = this.options.messageRepository) == null ? void 0 : g.loadMessages;
|
|
573
582
|
if (a) {
|
|
574
|
-
const c = await a(e, t, n, o), l = c.list.filter((
|
|
583
|
+
const c = await a(e, t, n, o), l = c.list.filter((p) => p.type !== S.CMD).map((p) => Pt(p, this.currentUserId));
|
|
575
584
|
return this.store.prependMessages(e, l), t === M.GROUPCHAT && this.fillGroupReadCounts(l, e), {
|
|
576
585
|
list: l,
|
|
577
586
|
cursor: c.cursor,
|
|
@@ -585,7 +594,7 @@ class _t {
|
|
|
585
594
|
cursor: n,
|
|
586
595
|
searchDirection: "up"
|
|
587
596
|
});
|
|
588
|
-
|
|
597
|
+
he.info("fetchHistory response", {
|
|
589
598
|
conversationId: e,
|
|
590
599
|
conversationType: t,
|
|
591
600
|
cursor: n,
|
|
@@ -595,10 +604,10 @@ class _t {
|
|
|
595
604
|
hasMore: r.hasMore,
|
|
596
605
|
items: r.items.map((c) => `${c.msgServerId || c.msgLocalId}|${c.type}|${c.from}->${c.to}|${c.timestamp}`)
|
|
597
606
|
});
|
|
598
|
-
const i = r.items.filter((c) => c.type !== S.CMD), u = i.map((c) =>
|
|
607
|
+
const i = r.items.filter((c) => c.type !== S.CMD), u = i.map((c) => O(c, this.currentUserId));
|
|
599
608
|
this.store.prependMessages(e, u);
|
|
600
609
|
const d = (f = this.options.persistence) == null ? void 0 : f.saveMessages;
|
|
601
|
-
return d && i.length > 0 &&
|
|
610
|
+
return d && i.length > 0 && te(() => d(i.map((c) => we(c)))), t === M.GROUPCHAT && this.fillGroupReadCounts(u, e), {
|
|
602
611
|
list: u,
|
|
603
612
|
cursor: r.cursor,
|
|
604
613
|
hasMore: r.hasMore
|
|
@@ -615,7 +624,7 @@ class _t {
|
|
|
615
624
|
*/
|
|
616
625
|
async fillGroupReadCounts(e, t) {
|
|
617
626
|
const n = e.filter((r) => r.isSelf && !(r.groupReadCount ?? 0)), o = n.map((r) => r.msgServerId).filter((r) => !!r);
|
|
618
|
-
if (
|
|
627
|
+
if (he.info("fillGroupReadCounts scan", {
|
|
619
628
|
groupId: t,
|
|
620
629
|
total: e.length,
|
|
621
630
|
selfMissingCount: n.length,
|
|
@@ -630,11 +639,11 @@ class _t {
|
|
|
630
639
|
groupId: t,
|
|
631
640
|
messageIds: i
|
|
632
641
|
});
|
|
633
|
-
|
|
642
|
+
he.info("fillGroupReadCounts result", { groupId: t, batch: i, receipts: u });
|
|
634
643
|
for (const d of u)
|
|
635
644
|
d.count > 0 && this.store.updateMessageById(d.messageId, { groupReadCount: d.count });
|
|
636
645
|
} catch (u) {
|
|
637
|
-
|
|
646
|
+
_.warn("[MessageDomain.fillGroupReadCounts] failed:", i, R(u));
|
|
638
647
|
}
|
|
639
648
|
}
|
|
640
649
|
}
|
|
@@ -647,7 +656,7 @@ class _t {
|
|
|
647
656
|
messageId: n
|
|
648
657
|
});
|
|
649
658
|
const o = (a = this.options.persistence) == null ? void 0 : a.markMessageRecalled;
|
|
650
|
-
o &&
|
|
659
|
+
o && te(() => o(n, this.currentUserId));
|
|
651
660
|
}
|
|
652
661
|
/**
|
|
653
662
|
* 删除消息:移除当前用户的服务端漫游历史(SDK5 `removeHistoryMessages`)。
|
|
@@ -664,7 +673,7 @@ class _t {
|
|
|
664
673
|
messageIds: n
|
|
665
674
|
});
|
|
666
675
|
const o = (a = this.options.persistence) == null ? void 0 : a.deleteMessages;
|
|
667
|
-
o &&
|
|
676
|
+
o && te(() => o([...n]));
|
|
668
677
|
}
|
|
669
678
|
/** 批量发送消息已读回执(统一 API,支持单聊/群聊) */
|
|
670
679
|
async markMessagesRead(e, t, n) {
|
|
@@ -690,17 +699,17 @@ class _t {
|
|
|
690
699
|
* 失败仅 warn 不阻塞进入会话(先标记后发送,失败回滚以便下次重试)。
|
|
691
700
|
*/
|
|
692
701
|
async sendPendingReadReceipts(e, t) {
|
|
693
|
-
const o = this.store.getMessages(e).filter((a) => !a.isSelf && !
|
|
702
|
+
const o = this.store.getMessages(e).filter((a) => !a.isSelf && !K.has(a.msgServerId)).map((a) => a.msgServerId).filter((a) => !!a);
|
|
694
703
|
if (o.length !== 0) {
|
|
695
|
-
|
|
704
|
+
_.info("[MessageDomain.sendPendingReadReceipts] 补发已读回执", { conversationId: e, conversationType: t, pendingCount: o.length, messageIds: o.slice(0, 5) });
|
|
696
705
|
for (const a of o)
|
|
697
|
-
|
|
706
|
+
K.add(a);
|
|
698
707
|
try {
|
|
699
708
|
await this.markMessagesRead(e, t, o);
|
|
700
709
|
} catch (a) {
|
|
701
710
|
for (const r of o)
|
|
702
|
-
|
|
703
|
-
|
|
711
|
+
K.delete(r);
|
|
712
|
+
_.warn("[MessageDomain.sendPendingReadReceipts] failed:", e, R(a));
|
|
704
713
|
}
|
|
705
714
|
}
|
|
706
715
|
}
|
|
@@ -717,7 +726,7 @@ class _t {
|
|
|
717
726
|
const o = (await this.client.chatManager.getPinnedMessageList({
|
|
718
727
|
conversationId: e,
|
|
719
728
|
conversationType: t
|
|
720
|
-
})).items.map((a) =>
|
|
729
|
+
})).items.map((a) => O(a.message, this.currentUserId));
|
|
721
730
|
return this.store.setPinnedMessages(e, o), o;
|
|
722
731
|
}
|
|
723
732
|
/** 翻译文本消息 */
|
|
@@ -728,18 +737,18 @@ class _t {
|
|
|
728
737
|
targetLanguages: t
|
|
729
738
|
});
|
|
730
739
|
} catch (n) {
|
|
731
|
-
throw
|
|
740
|
+
throw _.error("[MessageDomain.translateMessage] raw SDK error:", R(n)), n;
|
|
732
741
|
}
|
|
733
742
|
}
|
|
734
743
|
/** 语音消息转文字 */
|
|
735
744
|
async transcribeVoiceMessage(e, t) {
|
|
736
|
-
if (!
|
|
737
|
-
throw
|
|
745
|
+
if (!je(e.body))
|
|
746
|
+
throw _.warn("[MessageDomain.transcribeVoiceMessage] not a voice message:", e), new Error("not a voice message");
|
|
738
747
|
const n = {
|
|
739
748
|
...e.body,
|
|
740
749
|
type: S.VOICE
|
|
741
750
|
};
|
|
742
|
-
return
|
|
751
|
+
return _.info("voiceMessageToText raw input:", { message: e, body: n, voiceParams: t }), await this.client.chatManager.voiceMessageToText(n, t);
|
|
743
752
|
}
|
|
744
753
|
/** 下载并解析合并消息 */
|
|
745
754
|
async downloadAndParseCombineMessage(e) {
|
|
@@ -763,15 +772,15 @@ class _t {
|
|
|
763
772
|
}
|
|
764
773
|
/** 发送单条消息已读回执 */
|
|
765
774
|
async markRead(e, t, n) {
|
|
766
|
-
|
|
775
|
+
_.info("[MessageDomain.markRead] 发送单条已读回执", { conversationId: e, conversationType: t, messageId: n });
|
|
767
776
|
try {
|
|
768
777
|
await this.client.chatManager.sendMessageReadReceipts({
|
|
769
778
|
conversationId: e,
|
|
770
779
|
conversationType: t,
|
|
771
780
|
messageIds: [n]
|
|
772
|
-
}),
|
|
781
|
+
}), _.info("[MessageDomain.markRead] 已读回执发送成功", { conversationId: e, conversationType: t, messageId: n });
|
|
773
782
|
} catch (o) {
|
|
774
|
-
throw
|
|
783
|
+
throw _.warn("[MessageDomain.markRead] 已读回执发送失败", { conversationId: e, conversationType: t, messageId: n, error: R(o) }), o;
|
|
775
784
|
}
|
|
776
785
|
}
|
|
777
786
|
/** 获取群消息已读详情(自动翻页聚合全部已读成员) */
|
|
@@ -809,9 +818,9 @@ class _t {
|
|
|
809
818
|
});
|
|
810
819
|
}
|
|
811
820
|
}
|
|
812
|
-
function
|
|
813
|
-
var d, g, f, c, l,
|
|
814
|
-
const t =
|
|
821
|
+
function Bt(s, e) {
|
|
822
|
+
var d, g, f, c, l, p;
|
|
823
|
+
const t = Tt(s.lastMessage), n = A(((d = s.lastMessage) == null ? void 0 : d.from) || ""), o = A(((f = (g = s.lastMessage) == null ? void 0 : g.sender) == null ? void 0 : f.userId) || ""), a = o || n, r = a ? (c = e == null ? void 0 : e.resolveSenderName) == null ? void 0 : c.call(e, a) : void 0, i = ((p = (l = s.lastMessage) == null ? void 0 : l.sender) == null ? void 0 : p.nickname) || r || o || n || "", u = qe(s.conversationType, i, t);
|
|
815
824
|
return {
|
|
816
825
|
id: s.conversationId,
|
|
817
826
|
name: s.conversationName || s.conversationId,
|
|
@@ -829,14 +838,14 @@ function Nt(s, e) {
|
|
|
829
838
|
remindType: s.remindType
|
|
830
839
|
};
|
|
831
840
|
}
|
|
832
|
-
function
|
|
833
|
-
return s.map((t) =>
|
|
841
|
+
function le(s, e) {
|
|
842
|
+
return s.map((t) => Bt(t, e));
|
|
834
843
|
}
|
|
835
|
-
const
|
|
836
|
-
function
|
|
844
|
+
const Se = T("Conversation");
|
|
845
|
+
function Ht(s) {
|
|
837
846
|
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));
|
|
838
847
|
}
|
|
839
|
-
function
|
|
848
|
+
function Kt(s, e) {
|
|
840
849
|
var o;
|
|
841
850
|
const t = {}, n = [];
|
|
842
851
|
for (const a of s) {
|
|
@@ -846,10 +855,10 @@ function xt(s, e) {
|
|
|
846
855
|
lastMessage: a.lastMessage
|
|
847
856
|
});
|
|
848
857
|
}
|
|
849
|
-
n.length > 0 &&
|
|
858
|
+
n.length > 0 && Se.info(`raw snippets (${e})`, { typeCount: t, suspects: n });
|
|
850
859
|
}
|
|
851
|
-
const
|
|
852
|
-
class
|
|
860
|
+
const jt = 1e3;
|
|
861
|
+
class Vt {
|
|
853
862
|
constructor(e, t, n = {}) {
|
|
854
863
|
this.client = e, this.store = t, this.hooks = n, this.channelAckSentAt = /* @__PURE__ */ new Map();
|
|
855
864
|
}
|
|
@@ -865,8 +874,8 @@ class Pt {
|
|
|
865
874
|
/** 从本地缓存读取会话列表 */
|
|
866
875
|
syncLocal() {
|
|
867
876
|
const e = this.client.chatManager.getConversationList();
|
|
868
|
-
|
|
869
|
-
const t =
|
|
877
|
+
Se.info("getConversationList raw (syncLocal)", e), Kt(e, "syncLocal");
|
|
878
|
+
const t = le(e, { resolveSenderName: this.hooks.resolveSenderName });
|
|
870
879
|
return this.store.setList(t), t;
|
|
871
880
|
}
|
|
872
881
|
/**
|
|
@@ -893,7 +902,7 @@ class Pt {
|
|
|
893
902
|
avatar: d.avatar || g.avatar
|
|
894
903
|
} : d);
|
|
895
904
|
}
|
|
896
|
-
this.store.setList(
|
|
905
|
+
this.store.setList(Ht(Array.from(u.values())));
|
|
897
906
|
return;
|
|
898
907
|
}
|
|
899
908
|
await this.client.chatManager.refreshSessionList({ includeEmpty: e });
|
|
@@ -984,17 +993,17 @@ class Pt {
|
|
|
984
993
|
if (n !== void 0 && n <= 0)
|
|
985
994
|
return;
|
|
986
995
|
const o = Date.now(), a = this.channelAckSentAt.get(e) || 0;
|
|
987
|
-
o - a <
|
|
996
|
+
o - a < jt || (this.channelAckSentAt.set(e, o), await this.markRead(e, t));
|
|
988
997
|
}
|
|
989
998
|
/** 加载更多会话:SDK5 当前无分页游标,直接返回本地列表 */
|
|
990
999
|
async loadMore(e) {
|
|
991
1000
|
const t = this.client.chatManager.getConversationList();
|
|
992
|
-
|
|
993
|
-
const n =
|
|
1001
|
+
Se.info("getConversationList raw (loadMore)", t);
|
|
1002
|
+
const n = le(t, { resolveSenderName: this.hooks.resolveSenderName });
|
|
994
1003
|
this.store.setList(n);
|
|
995
1004
|
}
|
|
996
1005
|
}
|
|
997
|
-
function
|
|
1006
|
+
function qt(s) {
|
|
998
1007
|
if ("userId" in s && s.userId !== void 0) {
|
|
999
1008
|
const t = s;
|
|
1000
1009
|
return {
|
|
@@ -1014,10 +1023,10 @@ function Ft(s) {
|
|
|
1014
1023
|
birth: e.birth,
|
|
1015
1024
|
phone: e.phone,
|
|
1016
1025
|
mail: e.mail,
|
|
1017
|
-
ext:
|
|
1026
|
+
ext: Wt(e.ext)
|
|
1018
1027
|
};
|
|
1019
1028
|
}
|
|
1020
|
-
function
|
|
1029
|
+
function Wt(s) {
|
|
1021
1030
|
if (s)
|
|
1022
1031
|
try {
|
|
1023
1032
|
const e = JSON.parse(s);
|
|
@@ -1026,16 +1035,16 @@ function Bt(s) {
|
|
|
1026
1035
|
return;
|
|
1027
1036
|
}
|
|
1028
1037
|
}
|
|
1029
|
-
function
|
|
1030
|
-
return s.map((e) =>
|
|
1038
|
+
function Ge(s) {
|
|
1039
|
+
return s.map((e) => qt(e));
|
|
1031
1040
|
}
|
|
1032
|
-
class
|
|
1041
|
+
class Jt {
|
|
1033
1042
|
constructor(e, t, n = {}) {
|
|
1034
1043
|
this.client = e, this.store = t, this.options = n;
|
|
1035
1044
|
}
|
|
1036
1045
|
/** 获取当前内存中的联系人列表 */
|
|
1037
1046
|
syncLocal() {
|
|
1038
|
-
const e = this.client.contactManager.getContacts(), t =
|
|
1047
|
+
const e = this.client.contactManager.getContacts(), t = Ge(e);
|
|
1039
1048
|
return this.store.setList(t), t;
|
|
1040
1049
|
}
|
|
1041
1050
|
/**
|
|
@@ -1091,7 +1100,7 @@ class Ht {
|
|
|
1091
1100
|
const a = await e();
|
|
1092
1101
|
return this.store.setBlocklist(a), a;
|
|
1093
1102
|
}
|
|
1094
|
-
const t = await this.client.contactManager.getBlocklist(), n =
|
|
1103
|
+
const t = await this.client.contactManager.getBlocklist(), n = Ge(t);
|
|
1095
1104
|
return this.store.setBlocklist(n), n;
|
|
1096
1105
|
}
|
|
1097
1106
|
/** 批量加入黑名单 */
|
|
@@ -1103,7 +1112,7 @@ class Ht {
|
|
|
1103
1112
|
await this.client.contactManager.removeUserFromBlocklist({ userIds: e });
|
|
1104
1113
|
}
|
|
1105
1114
|
}
|
|
1106
|
-
function
|
|
1115
|
+
function Qe(s) {
|
|
1107
1116
|
const e = {
|
|
1108
1117
|
groupId: s.groupId,
|
|
1109
1118
|
groupName: s.name,
|
|
@@ -1117,10 +1126,10 @@ function Ke(s) {
|
|
|
1117
1126
|
};
|
|
1118
1127
|
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), e;
|
|
1119
1128
|
}
|
|
1120
|
-
function
|
|
1121
|
-
return s.map((e) =>
|
|
1129
|
+
function ge(s) {
|
|
1130
|
+
return s.map((e) => Qe(e));
|
|
1122
1131
|
}
|
|
1123
|
-
function
|
|
1132
|
+
function $t(s) {
|
|
1124
1133
|
const e = s.user, t = {
|
|
1125
1134
|
userId: e.userId,
|
|
1126
1135
|
nickname: e.nickname,
|
|
@@ -1129,17 +1138,17 @@ function Kt(s) {
|
|
|
1129
1138
|
};
|
|
1130
1139
|
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;
|
|
1131
1140
|
}
|
|
1132
|
-
function
|
|
1133
|
-
return s.map((e) =>
|
|
1141
|
+
function X(s) {
|
|
1142
|
+
return s.map((e) => $t(e));
|
|
1134
1143
|
}
|
|
1135
|
-
const
|
|
1136
|
-
class
|
|
1144
|
+
const ne = T("UIKit:GroupDomain"), ve = /* @__PURE__ */ new Map(), Ie = /* @__PURE__ */ new Map(), Me = /* @__PURE__ */ new Map();
|
|
1145
|
+
class Qt {
|
|
1137
1146
|
constructor(e, t, n = {}) {
|
|
1138
1147
|
this.client = e, this.store = t, this.options = n;
|
|
1139
1148
|
}
|
|
1140
1149
|
/** 获取已加入群组本地列表 */
|
|
1141
1150
|
syncLocal() {
|
|
1142
|
-
const e = this.client.groupManager.getJoinedGroupList(), t =
|
|
1151
|
+
const e = this.client.groupManager.getJoinedGroupList(), t = ge(e);
|
|
1143
1152
|
return this.store.setList(t), t;
|
|
1144
1153
|
}
|
|
1145
1154
|
/**
|
|
@@ -1162,23 +1171,23 @@ class jt {
|
|
|
1162
1171
|
}
|
|
1163
1172
|
/** 获取单个群详情 */
|
|
1164
1173
|
async fetchGroupInfo(e) {
|
|
1165
|
-
const t =
|
|
1174
|
+
const t = ve.get(e);
|
|
1166
1175
|
if (t)
|
|
1167
1176
|
return t;
|
|
1168
1177
|
const n = (async () => {
|
|
1169
|
-
const o = await this.client.groupManager.getGroupInfo({ groupId: e }), a =
|
|
1178
|
+
const o = await this.client.groupManager.getGroupInfo({ groupId: e }), a = Qe(o);
|
|
1170
1179
|
return this.store.updateGroup(e, a), a;
|
|
1171
1180
|
})();
|
|
1172
|
-
|
|
1181
|
+
ve.set(e, n);
|
|
1173
1182
|
try {
|
|
1174
1183
|
return await n;
|
|
1175
1184
|
} finally {
|
|
1176
|
-
|
|
1185
|
+
ve.delete(e);
|
|
1177
1186
|
}
|
|
1178
1187
|
}
|
|
1179
1188
|
/** 批量获取群详情 */
|
|
1180
1189
|
async fetchGroupInfoList(e) {
|
|
1181
|
-
const t = await this.client.groupManager.getGroupInfoList({ groupIds: e }), n =
|
|
1190
|
+
const t = await this.client.groupManager.getGroupInfoList({ groupIds: e }), n = ge(t);
|
|
1182
1191
|
return n.forEach((o) => this.store.updateGroup(o.groupId, o)), n;
|
|
1183
1192
|
}
|
|
1184
1193
|
/** 创建群组(注入 createGroup 时整体委托业务接管:不调 SDK、不写本地缓存,权威数据由业务源负责) */
|
|
@@ -1201,7 +1210,7 @@ class jt {
|
|
|
1201
1210
|
groupId: n.groupId,
|
|
1202
1211
|
groupName: e.name,
|
|
1203
1212
|
description: e.description,
|
|
1204
|
-
role:
|
|
1213
|
+
role: N.OWNER,
|
|
1205
1214
|
memberCount: (((a = e.memberIds) == null ? void 0 : a.length) ?? 0) + 1,
|
|
1206
1215
|
maxUsers: e.maxMembers,
|
|
1207
1216
|
public: e.public ?? !1,
|
|
@@ -1230,7 +1239,7 @@ class jt {
|
|
|
1230
1239
|
}
|
|
1231
1240
|
/** 拉取群成员列表 */
|
|
1232
1241
|
async fetchGroupMembers(e, t, n = 20) {
|
|
1233
|
-
const o = await this.client.groupManager.getGroupMemberList({ groupId: e, cursor: t, pageSize: n }), a =
|
|
1242
|
+
const o = await this.client.groupManager.getGroupMemberList({ groupId: e, cursor: t, pageSize: n }), a = X(o.items);
|
|
1234
1243
|
if (t)
|
|
1235
1244
|
this.store.appendGroupMembers(e, a);
|
|
1236
1245
|
else {
|
|
@@ -1245,42 +1254,42 @@ class jt {
|
|
|
1245
1254
|
/** 拉取并合并群管理员到成员缓存 */
|
|
1246
1255
|
async syncGroupAdmins(e) {
|
|
1247
1256
|
var o, a;
|
|
1248
|
-
const t =
|
|
1257
|
+
const t = Ie.get(e);
|
|
1249
1258
|
if (t)
|
|
1250
1259
|
return t;
|
|
1251
1260
|
if ((a = (o = this.store).isGroupAdminSynced) != null && a.call(o, e))
|
|
1252
1261
|
return;
|
|
1253
1262
|
const n = (async () => {
|
|
1254
1263
|
var u, d;
|
|
1255
|
-
const r = await this.client.groupManager.getGroup(e).getAdmins(), i =
|
|
1256
|
-
(r || []).map((g) => ({ user: g, role:
|
|
1264
|
+
const r = await this.client.groupManager.getGroup(e).getAdmins(), i = X(
|
|
1265
|
+
(r || []).map((g) => ({ user: g, role: N.ADMIN }))
|
|
1257
1266
|
);
|
|
1258
1267
|
this.store.appendGroupMembers(e, i);
|
|
1259
1268
|
for (const g of i)
|
|
1260
|
-
this.store.updateGroupMemberRole(e, g.userId,
|
|
1269
|
+
this.store.updateGroupMemberRole(e, g.userId, N.ADMIN);
|
|
1261
1270
|
(d = (u = this.store).markGroupAdminSynced) == null || d.call(u, e);
|
|
1262
1271
|
})();
|
|
1263
|
-
|
|
1272
|
+
Ie.set(e, n);
|
|
1264
1273
|
try {
|
|
1265
1274
|
return await n;
|
|
1266
1275
|
} finally {
|
|
1267
|
-
|
|
1276
|
+
Ie.delete(e);
|
|
1268
1277
|
}
|
|
1269
1278
|
}
|
|
1270
1279
|
/** 拉取群公告 */
|
|
1271
1280
|
async fetchGroupAnnouncement(e) {
|
|
1272
|
-
const t =
|
|
1281
|
+
const t = Me.get(e);
|
|
1273
1282
|
if (t)
|
|
1274
1283
|
return t;
|
|
1275
1284
|
const n = (async () => {
|
|
1276
1285
|
const a = (await this.client.groupManager.getGroupAnnouncement({ groupId: e })).announcement ?? "";
|
|
1277
1286
|
return this.store.setGroupAnnouncement(e, a), a;
|
|
1278
1287
|
})();
|
|
1279
|
-
|
|
1288
|
+
Me.set(e, n);
|
|
1280
1289
|
try {
|
|
1281
1290
|
return await n;
|
|
1282
1291
|
} finally {
|
|
1283
|
-
|
|
1292
|
+
Me.delete(e);
|
|
1284
1293
|
}
|
|
1285
1294
|
}
|
|
1286
1295
|
/** 更新群公告 */
|
|
@@ -1301,11 +1310,11 @@ class jt {
|
|
|
1301
1310
|
}
|
|
1302
1311
|
/** 设置群管理员 */
|
|
1303
1312
|
async addGroupAdmin(e, t) {
|
|
1304
|
-
await this.client.groupManager.addGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t,
|
|
1313
|
+
await this.client.groupManager.addGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t, N.ADMIN);
|
|
1305
1314
|
}
|
|
1306
1315
|
/** 取消群管理员 */
|
|
1307
1316
|
async removeGroupAdmin(e, t) {
|
|
1308
|
-
await this.client.groupManager.removeGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t,
|
|
1317
|
+
await this.client.groupManager.removeGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t, N.MEMBER);
|
|
1309
1318
|
}
|
|
1310
1319
|
/** 接受群邀请 */
|
|
1311
1320
|
async acceptGroupInvitation(e) {
|
|
@@ -1336,25 +1345,25 @@ class jt {
|
|
|
1336
1345
|
* @param muteDuration 禁言时长,单位为毫秒;传 -1 表示永久禁言(SDK 5.0.0+ 语义)。
|
|
1337
1346
|
*/
|
|
1338
1347
|
async muteGroupMembers(e, t, n) {
|
|
1339
|
-
|
|
1348
|
+
ne.info("muteGroupMembers request raw", { groupId: e, userIds: t, muteDuration: n });
|
|
1340
1349
|
const o = await this.client.groupManager.getGroup(e).muteMembers({ userIds: t, muteDuration: n });
|
|
1341
|
-
|
|
1350
|
+
ne.info("muteGroupMembers response raw", o), this.store.addGroupMuteMembers(e, t);
|
|
1342
1351
|
}
|
|
1343
1352
|
/** 解除指定成员禁言 */
|
|
1344
1353
|
async unmuteGroupMembers(e, t) {
|
|
1345
|
-
|
|
1354
|
+
ne.info("unmuteGroupMembers request raw", { groupId: e, userIds: t });
|
|
1346
1355
|
const n = await this.client.groupManager.getGroup(e).unmuteMembers({ userIds: t });
|
|
1347
|
-
|
|
1356
|
+
ne.info("unmuteGroupMembers response raw", n), this.store.removeGroupMuteMembers(e, t);
|
|
1348
1357
|
}
|
|
1349
1358
|
/** 获取群禁言列表 */
|
|
1350
1359
|
async getGroupMuteList(e, t, n) {
|
|
1351
1360
|
const o = await this.client.groupManager.getGroup(e).getMuteList({ pageNum: t, pageSize: n }), a = Array.isArray(o) ? o : (o == null ? void 0 : o.data) ?? [];
|
|
1352
|
-
return this.store.setGroupMuteList(e,
|
|
1361
|
+
return this.store.setGroupMuteList(e, X(a)), o;
|
|
1353
1362
|
}
|
|
1354
1363
|
/** 获取群黑名单 */
|
|
1355
1364
|
async getGroupBlocklist(e, t, n) {
|
|
1356
1365
|
const o = await this.client.groupManager.getGroup(e).getBlocklist({ pageNum: t, pageSize: n }), a = Array.isArray(o) ? o : (o == null ? void 0 : o.data) ?? [];
|
|
1357
|
-
return this.store.setGroupBlocklist(e,
|
|
1366
|
+
return this.store.setGroupBlocklist(e, X(a)), o;
|
|
1358
1367
|
}
|
|
1359
1368
|
/** 将成员加入群黑名单 */
|
|
1360
1369
|
async blockGroupMembers(e, t) {
|
|
@@ -1367,7 +1376,7 @@ class jt {
|
|
|
1367
1376
|
/** 获取群白名单 */
|
|
1368
1377
|
async getGroupAllowlist(e) {
|
|
1369
1378
|
const t = await this.client.groupManager.getGroup(e).getAllowlist(), n = Array.isArray(t) ? t : (t == null ? void 0 : t.data) ?? [];
|
|
1370
|
-
return this.store.setGroupAllowlist(e,
|
|
1379
|
+
return this.store.setGroupAllowlist(e, X(n)), t;
|
|
1371
1380
|
}
|
|
1372
1381
|
/** 将成员加入群白名单 */
|
|
1373
1382
|
async addUsersToGroupAllowlist(e, t) {
|
|
@@ -1432,27 +1441,27 @@ class jt {
|
|
|
1432
1441
|
await this.client.groupManager.rejectInvitation({ groupId: e });
|
|
1433
1442
|
}
|
|
1434
1443
|
}
|
|
1435
|
-
function
|
|
1444
|
+
function ze(s, e) {
|
|
1436
1445
|
if (!s)
|
|
1437
1446
|
return "offline";
|
|
1438
1447
|
if (!e)
|
|
1439
1448
|
return "online";
|
|
1440
|
-
const t = e.toLowerCase(), n =
|
|
1449
|
+
const t = e.toLowerCase(), n = Y.ONLINE.toLowerCase(), o = Y.AWAY.toLowerCase(), a = Y.BUSY.toLowerCase(), r = Y.DO_NOT_DISTURB.toLowerCase(), i = Y.OFFLINE.toLowerCase();
|
|
1441
1450
|
return t === n ? "online" : t === o ? "away" : t === a ? "busy" : t === r ? "doNotDisturb" : t === i ? "offline" : "custom";
|
|
1442
1451
|
}
|
|
1443
|
-
function
|
|
1452
|
+
function _e(s) {
|
|
1444
1453
|
const e = s.publisher || "";
|
|
1445
1454
|
if (!e)
|
|
1446
1455
|
return null;
|
|
1447
1456
|
const t = s.statusList || {}, n = Object.values(t).some((a) => Number(a) === 1), o = s.ext || "";
|
|
1448
1457
|
return {
|
|
1449
1458
|
userId: e,
|
|
1450
|
-
status:
|
|
1459
|
+
status: ze(n, o),
|
|
1451
1460
|
ext: o,
|
|
1452
1461
|
lastTime: s.latestTime || Date.now()
|
|
1453
1462
|
};
|
|
1454
1463
|
}
|
|
1455
|
-
class
|
|
1464
|
+
class zt {
|
|
1456
1465
|
constructor(e, t, n = {}) {
|
|
1457
1466
|
this.client = e, this.store = t, this.options = n;
|
|
1458
1467
|
}
|
|
@@ -1469,7 +1478,7 @@ class Vt {
|
|
|
1469
1478
|
expiry: t
|
|
1470
1479
|
});
|
|
1471
1480
|
this.store.setSubscribed(e);
|
|
1472
|
-
const a = o.map(
|
|
1481
|
+
const a = o.map(_e).filter((i) => i !== null);
|
|
1473
1482
|
return this.store.updateBatch(a), a;
|
|
1474
1483
|
}
|
|
1475
1484
|
/** 取消订阅 */
|
|
@@ -1492,7 +1501,7 @@ class Vt {
|
|
|
1492
1501
|
}
|
|
1493
1502
|
if (!this.client.isConnected)
|
|
1494
1503
|
return [];
|
|
1495
|
-
const o = (await this.client.presenceManager.getPresenceStatus({ userIds: e })).map(
|
|
1504
|
+
const o = (await this.client.presenceManager.getPresenceStatus({ userIds: e })).map(_e).filter((r) => r !== null);
|
|
1496
1505
|
return this.store.updateBatch(o), o;
|
|
1497
1506
|
}
|
|
1498
1507
|
/** 发布自定义在线状态 */
|
|
@@ -1500,7 +1509,7 @@ class Vt {
|
|
|
1500
1509
|
this.client.isConnected && await this.client.presenceManager.publishPresence({ customStatus: e });
|
|
1501
1510
|
}
|
|
1502
1511
|
}
|
|
1503
|
-
const F =
|
|
1512
|
+
const F = T("UIKit:UserInfoDomain"), Ne = [
|
|
1504
1513
|
"nickname",
|
|
1505
1514
|
"avatarUrl",
|
|
1506
1515
|
"mail",
|
|
@@ -1510,7 +1519,7 @@ const F = R("UIKit:UserInfoDomain"), Te = [
|
|
|
1510
1519
|
"birth",
|
|
1511
1520
|
"ext"
|
|
1512
1521
|
];
|
|
1513
|
-
class
|
|
1522
|
+
class Yt {
|
|
1514
1523
|
constructor(e, t, n = {}, o) {
|
|
1515
1524
|
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;
|
|
1516
1525
|
}
|
|
@@ -1528,7 +1537,7 @@ class qt {
|
|
|
1528
1537
|
* @param userIds 目标用户 ID 列表
|
|
1529
1538
|
* @param attributes 需要查询的属性,默认全量 8 个属性
|
|
1530
1539
|
*/
|
|
1531
|
-
async fetchUserInfos(e, t =
|
|
1540
|
+
async fetchUserInfos(e, t = Ne) {
|
|
1532
1541
|
if (!this.client.isConnected)
|
|
1533
1542
|
return [];
|
|
1534
1543
|
const n = Array.from(new Set(e.filter(Boolean)));
|
|
@@ -1555,7 +1564,7 @@ class qt {
|
|
|
1555
1564
|
const a = this.userInfoRepository.fetchUserInfos ? await this.fetchFromRepository(n) : await this.fetchFromSdk(n, o), r = new Set(a.map((u) => u.userId).filter(Boolean)), i = n.filter((u) => !r.has(u));
|
|
1556
1565
|
i.length > 0 && this.store.markFetchFailed(i), this.store.setUserInfos(a), this.store.markFetchedAttributes(n, o);
|
|
1557
1566
|
} catch (a) {
|
|
1558
|
-
F.warn("[UserInfoDomain] fetchUserInfos failed:",
|
|
1567
|
+
F.warn("[UserInfoDomain] fetchUserInfos failed:", R(a)), this.store.markFetchFailed(n);
|
|
1559
1568
|
} finally {
|
|
1560
1569
|
this.store.markLoaded(n);
|
|
1561
1570
|
}
|
|
@@ -1618,11 +1627,11 @@ class qt {
|
|
|
1618
1627
|
if (this.isPermissionError(e)) {
|
|
1619
1628
|
this.store.markSubscribeFailed(t), this.store.disableSubscription(), this.hasLoggedPermissionError || (this.hasLoggedPermissionError = !0, F.warn(
|
|
1620
1629
|
"[UserInfoDomain] 用户资料订阅无权限或服务未开通,已自动关闭订阅。后续陌生人资料变更将不会实时推送,拉取到的资料仍可正常展示。",
|
|
1621
|
-
|
|
1630
|
+
R(e)
|
|
1622
1631
|
), (n = this.onSubscriptionPermissionError) == null || n.call(this));
|
|
1623
1632
|
return;
|
|
1624
1633
|
}
|
|
1625
|
-
this.store.markSubscribeFailed(t), F.warn("[UserInfoDomain] subscribeUserInfos failed:",
|
|
1634
|
+
this.store.markSubscribeFailed(t), F.warn("[UserInfoDomain] subscribeUserInfos failed:", R(e));
|
|
1626
1635
|
}
|
|
1627
1636
|
isPermissionError(e) {
|
|
1628
1637
|
var n, o;
|
|
@@ -1634,7 +1643,7 @@ class qt {
|
|
|
1634
1643
|
/**
|
|
1635
1644
|
* 获取当前登录用户自己的资料(默认全量属性,保证签名等登录后回显)。
|
|
1636
1645
|
*/
|
|
1637
|
-
async fetchOwnInfo(e =
|
|
1646
|
+
async fetchOwnInfo(e = Ne) {
|
|
1638
1647
|
const t = this.client.currentUserId;
|
|
1639
1648
|
if (!t)
|
|
1640
1649
|
return;
|
|
@@ -1650,7 +1659,7 @@ class qt {
|
|
|
1650
1659
|
const t = await this.client.userInfoManager.updateOwnInfo(e);
|
|
1651
1660
|
return this.store.setUserInfo(t), t;
|
|
1652
1661
|
} catch (t) {
|
|
1653
|
-
F.warn("[UserInfoDomain] updateOwnInfo failed:",
|
|
1662
|
+
F.warn("[UserInfoDomain] updateOwnInfo failed:", R(t));
|
|
1654
1663
|
return;
|
|
1655
1664
|
}
|
|
1656
1665
|
}
|
|
@@ -1663,7 +1672,7 @@ class qt {
|
|
|
1663
1672
|
const n = await this.client.userInfoManager.updateOwnInfoByAttribute(e, t);
|
|
1664
1673
|
return this.store.setUserInfo(n), n;
|
|
1665
1674
|
} catch (n) {
|
|
1666
|
-
F.warn("[UserInfoDomain] updateOwnInfoByAttribute failed:",
|
|
1675
|
+
F.warn("[UserInfoDomain] updateOwnInfoByAttribute failed:", R(n));
|
|
1667
1676
|
return;
|
|
1668
1677
|
}
|
|
1669
1678
|
}
|
|
@@ -1678,7 +1687,7 @@ class qt {
|
|
|
1678
1687
|
try {
|
|
1679
1688
|
await this.client.userInfoManager.unsubscribeUsersInfo({ userIds: t }), this.store.markUnsubscribed(t);
|
|
1680
1689
|
} catch (n) {
|
|
1681
|
-
F.warn("[UserInfoDomain] unsubscribeUsersInfo failed:",
|
|
1690
|
+
F.warn("[UserInfoDomain] unsubscribeUsersInfo failed:", R(n));
|
|
1682
1691
|
}
|
|
1683
1692
|
}
|
|
1684
1693
|
/**
|
|
@@ -1690,7 +1699,7 @@ class qt {
|
|
|
1690
1699
|
try {
|
|
1691
1700
|
return await this.client.userInfoManager.getSubscribedUsers();
|
|
1692
1701
|
} catch (e) {
|
|
1693
|
-
return F.warn("[UserInfoDomain] getSubscribedUsers failed:",
|
|
1702
|
+
return F.warn("[UserInfoDomain] getSubscribedUsers failed:", R(e)), [];
|
|
1694
1703
|
}
|
|
1695
1704
|
}
|
|
1696
1705
|
/**
|
|
@@ -1717,82 +1726,82 @@ class qt {
|
|
|
1717
1726
|
});
|
|
1718
1727
|
}
|
|
1719
1728
|
}
|
|
1720
|
-
const
|
|
1721
|
-
function
|
|
1729
|
+
const D = T("UIKit:ConnEvents");
|
|
1730
|
+
function Xt(s, e = {}) {
|
|
1722
1731
|
return {
|
|
1723
1732
|
onConnecting: () => {
|
|
1724
|
-
|
|
1733
|
+
D.info("onConnecting"), s.client.setConnecting(!0);
|
|
1725
1734
|
},
|
|
1726
1735
|
onConnected: () => {
|
|
1727
|
-
|
|
1736
|
+
D.info("onConnected"), s.client.setConnected(!0), s.client.setConnecting(!1), s.client.setHasConnectedOnce(!0);
|
|
1728
1737
|
},
|
|
1729
1738
|
onDisconnected: (t) => {
|
|
1730
|
-
|
|
1739
|
+
D.info("onDisconnected", t ? { reason: t.reason, errorCode: t.errorCode } : void 0), s.client.setConnected(!1), s.client.setConnecting(!1), ft(t == null ? void 0 : t.errorCode) && s.client.setKicked(t.errorCode);
|
|
1731
1740
|
},
|
|
1732
1741
|
onReconnectFailed: () => {
|
|
1733
|
-
|
|
1742
|
+
D.info("onReconnectFailed"), s.client.setConnecting(!1), D.error("Auto-reconnect failed after max retries");
|
|
1734
1743
|
},
|
|
1735
1744
|
onTokenWillExpire: () => {
|
|
1736
1745
|
var t;
|
|
1737
|
-
|
|
1746
|
+
D.info("onTokenWillExpire"), D.warn("Token will expire"), (t = e.onTokenWillExpire) == null || t.call(e);
|
|
1738
1747
|
},
|
|
1739
1748
|
onTokenExpired: () => {
|
|
1740
1749
|
var t;
|
|
1741
|
-
|
|
1750
|
+
D.info("onTokenExpired"), D.error("Token expired"), (t = e.onTokenExpired) == null || t.call(e);
|
|
1742
1751
|
},
|
|
1743
1752
|
onOfflineMessageSyncStart: () => {
|
|
1744
|
-
|
|
1753
|
+
D.info("onOfflineMessageSyncStart"), s.conversation.conversationsLoaded || s.message.setSyncingMessages(!0);
|
|
1745
1754
|
},
|
|
1746
1755
|
onOfflineMessageSyncFinish: () => {
|
|
1747
|
-
|
|
1756
|
+
D.info("onOfflineMessageSyncFinish"), s.message.setSyncingMessages(!1);
|
|
1748
1757
|
}
|
|
1749
1758
|
};
|
|
1750
1759
|
}
|
|
1751
|
-
const
|
|
1760
|
+
const Ye = T("UIKit:SyncStatus"), Q = Mt({
|
|
1752
1761
|
conversation: { status: "idle" },
|
|
1753
1762
|
contact: { status: "idle" },
|
|
1754
1763
|
group: { status: "idle" }
|
|
1755
1764
|
});
|
|
1756
|
-
let
|
|
1757
|
-
function
|
|
1758
|
-
return
|
|
1759
|
-
|
|
1765
|
+
let ee = null;
|
|
1766
|
+
function Zt(s) {
|
|
1767
|
+
return ee = s, () => {
|
|
1768
|
+
ee = null;
|
|
1760
1769
|
};
|
|
1761
1770
|
}
|
|
1762
|
-
function
|
|
1763
|
-
const t =
|
|
1764
|
-
t.status = e.status, e.finishedAt !== void 0 && (t.finishedAt = e.finishedAt), e.error !== void 0 && (t.error = e.error),
|
|
1771
|
+
function be(s, e) {
|
|
1772
|
+
const t = Q[s];
|
|
1773
|
+
t.status = e.status, e.finishedAt !== void 0 && (t.finishedAt = e.finishedAt), e.error !== void 0 && (t.error = e.error), Ye.info(`sync ${s} -> ${e.status}`, e.error ? { stage: e.error.stage, retryable: e.error.retryable, message: e.error.message } : void 0), ee == null || ee({
|
|
1765
1774
|
type: s,
|
|
1766
1775
|
status: e.status === "idle" ? "syncing" : e.status,
|
|
1767
1776
|
error: e.error
|
|
1768
1777
|
});
|
|
1769
1778
|
}
|
|
1770
|
-
function
|
|
1771
|
-
const s = Object.keys(
|
|
1779
|
+
function en() {
|
|
1780
|
+
const s = Object.keys(Q);
|
|
1772
1781
|
for (const e of s)
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
}
|
|
1776
|
-
function
|
|
1777
|
-
const s =
|
|
1778
|
-
() => Object.values(
|
|
1779
|
-
), t =
|
|
1780
|
-
() => Object.values(
|
|
1782
|
+
Q[e] = { status: "idle" };
|
|
1783
|
+
Ye.info("sync status reset(事件反注册/登出)");
|
|
1784
|
+
}
|
|
1785
|
+
function Pn() {
|
|
1786
|
+
const s = pe(() => ({ ...Q })), e = pe(
|
|
1787
|
+
() => Object.values(Q).some((n) => n.status === "syncing")
|
|
1788
|
+
), t = pe(
|
|
1789
|
+
() => Object.values(Q).every((n) => n.status === "success" || n.status === "failed")
|
|
1781
1790
|
);
|
|
1782
1791
|
return { status: s, isSyncing: e, allFinished: t };
|
|
1783
1792
|
}
|
|
1784
|
-
let
|
|
1785
|
-
function
|
|
1786
|
-
|
|
1793
|
+
let Ae = null;
|
|
1794
|
+
function Xe(s) {
|
|
1795
|
+
Ae = s;
|
|
1787
1796
|
}
|
|
1788
|
-
function
|
|
1789
|
-
if (!
|
|
1797
|
+
function P() {
|
|
1798
|
+
if (!Ae)
|
|
1790
1799
|
throw new Error(
|
|
1791
1800
|
"[UIKit] 事件层依赖未注入:请在调用 registerEventHandlers 前先执行 setEventHandlerDeps()"
|
|
1792
1801
|
);
|
|
1793
|
-
return
|
|
1802
|
+
return Ae;
|
|
1794
1803
|
}
|
|
1795
|
-
function
|
|
1804
|
+
function tn(s, e) {
|
|
1796
1805
|
const t = s.contact.getContact(e);
|
|
1797
1806
|
if (t != null && t.remark)
|
|
1798
1807
|
return t.remark;
|
|
@@ -1800,7 +1809,7 @@ function $t(s, e) {
|
|
|
1800
1809
|
if (n != null && n.nickname)
|
|
1801
1810
|
return n.nickname;
|
|
1802
1811
|
}
|
|
1803
|
-
function
|
|
1812
|
+
function Ze(s, e) {
|
|
1804
1813
|
var r;
|
|
1805
1814
|
const t = e.from || "", n = s.contact.getContact(t);
|
|
1806
1815
|
if (n != null && n.remark)
|
|
@@ -1811,33 +1820,33 @@ function We(s, e) {
|
|
|
1811
1820
|
const a = (r = e.ext) == null ? void 0 : r.ease_chat_uikit_user_info;
|
|
1812
1821
|
return a != null && a.nickname ? a.nickname : a != null && a.remark ? a.remark : t;
|
|
1813
1822
|
}
|
|
1814
|
-
function
|
|
1823
|
+
function nn(s, e) {
|
|
1815
1824
|
var l;
|
|
1816
|
-
const { useNotification: t, emitNotificationDelivered: n } =
|
|
1825
|
+
const { useNotification: t, emitNotificationDelivered: n } = P(), { state: o, notify: a, notifyBrowser: r } = t();
|
|
1817
1826
|
if (!o.value.enabled || A(e.from) === A(s.client.currentUser) || e.conversationId === s.conversation.currentConversationId)
|
|
1818
1827
|
return;
|
|
1819
|
-
const i = s.conversation.conversationList.find((
|
|
1828
|
+
const i = s.conversation.conversationList.find((p) => p.id === e.conversationId);
|
|
1820
1829
|
if (i != null && i.isMuted)
|
|
1821
1830
|
return;
|
|
1822
1831
|
const u = typeof document > "u" || document.visibilityState === "hidden";
|
|
1823
1832
|
if (o.value.triggerMode === "background" && !u)
|
|
1824
1833
|
return;
|
|
1825
|
-
const d =
|
|
1834
|
+
const d = O(e, s.client.currentUser), g = Ze(s, d), f = d.conversationType === M.GROUPCHAT, c = {
|
|
1826
1835
|
// 群聊标题为群名(正文含 "发送者: 内容" 前缀),单聊标题为发送者名
|
|
1827
1836
|
title: f && (i == null ? void 0 : i.name) || g,
|
|
1828
|
-
body:
|
|
1837
|
+
body: mt(d, void 0, g, void 0, Te),
|
|
1829
1838
|
// 群聊用群头像,单聊用发送者头像
|
|
1830
1839
|
avatar: f ? i == null ? void 0 : i.avatar : (l = s.userInfo.getUserInfo(e.from)) == null ? void 0 : l.avatarUrl,
|
|
1831
1840
|
timestamp: d.timestamp || Date.now(),
|
|
1832
1841
|
conversationId: e.conversationId,
|
|
1833
1842
|
conversationType: d.conversationType
|
|
1834
1843
|
};
|
|
1835
|
-
u && o.value.browserEnabled ? r(c).then((
|
|
1836
|
-
|
|
1844
|
+
u && o.value.browserEnabled ? r(c).then((p) => {
|
|
1845
|
+
p ? n(c, "browser") : o.value.inAppEnabled && (a(c), n(c, "in-app"));
|
|
1837
1846
|
}) : o.value.inAppEnabled && (a(c), n(c, "in-app"));
|
|
1838
1847
|
}
|
|
1839
|
-
function
|
|
1840
|
-
const { t: n, useNotification: o, emitNotificationDelivered: a, resolveNoticeUserName: r } =
|
|
1848
|
+
function ke(s, e, t) {
|
|
1849
|
+
const { t: n, useNotification: o, emitNotificationDelivered: a, resolveNoticeUserName: r } = P(), { state: i, notify: u, notifyBrowser: d } = o();
|
|
1841
1850
|
if (!i.value.enabled)
|
|
1842
1851
|
return;
|
|
1843
1852
|
const g = s.userInfo.getUserInfo(e), f = {
|
|
@@ -1852,39 +1861,39 @@ function Ue(s, e, t) {
|
|
|
1852
1861
|
l ? a(f, "browser") : i.value.inAppEnabled && (u(f), a(f, "in-app"));
|
|
1853
1862
|
}) : i.value.inAppEnabled && (u(f), a(f, "in-app"));
|
|
1854
1863
|
}
|
|
1855
|
-
const
|
|
1856
|
-
let
|
|
1857
|
-
function
|
|
1858
|
-
|
|
1864
|
+
const b = T("UIKit:ChatEvents"), ue = /* @__PURE__ */ new Set(), Ee = /* @__PURE__ */ new Set(), J = /* @__PURE__ */ new Map();
|
|
1865
|
+
let de = !1;
|
|
1866
|
+
function sn() {
|
|
1867
|
+
ue.clear(), Ee.clear(), J.clear(), de = !1;
|
|
1859
1868
|
}
|
|
1860
|
-
function
|
|
1869
|
+
function rn(s, e, t, n) {
|
|
1861
1870
|
if (!n)
|
|
1862
1871
|
return;
|
|
1863
|
-
const o = `${e}:${t}`, a =
|
|
1864
|
-
a.push(n),
|
|
1865
|
-
for (
|
|
1866
|
-
const r = Array.from(
|
|
1867
|
-
|
|
1872
|
+
const o = `${e}:${t}`, a = J.get(o) || [];
|
|
1873
|
+
a.push(n), J.set(o, a), !de && (de = !0, Promise.resolve().then(async () => {
|
|
1874
|
+
for (de = !1; J.size > 0; ) {
|
|
1875
|
+
const r = Array.from(J.entries());
|
|
1876
|
+
J.clear();
|
|
1868
1877
|
for (const [i, u] of r) {
|
|
1869
1878
|
const [d, g] = i.split(":");
|
|
1870
1879
|
for (let f = 0; f < u.length; f += 50) {
|
|
1871
1880
|
const c = u.slice(f, f + 50);
|
|
1872
|
-
|
|
1881
|
+
b.info("[queueMessageReadReceipt] 批量发送已读回执", { conversationType: d, conversationId: g, batchSize: c.length, messageIds: c });
|
|
1873
1882
|
try {
|
|
1874
1883
|
await s.chatManager.sendMessageReadReceipts({
|
|
1875
1884
|
conversationId: g,
|
|
1876
1885
|
conversationType: d,
|
|
1877
1886
|
messageIds: c
|
|
1878
|
-
}),
|
|
1887
|
+
}), Ot(c), b.info("[queueMessageReadReceipt] 已读回执发送成功", { conversationType: d, conversationId: g, messageIds: c });
|
|
1879
1888
|
} catch (l) {
|
|
1880
|
-
|
|
1889
|
+
b.warn("[queueMessageReadReceipt] sendMessageReadReceipts failed:", { conversationType: d, conversationId: g, messageIds: c, err: l });
|
|
1881
1890
|
}
|
|
1882
1891
|
}
|
|
1883
1892
|
}
|
|
1884
1893
|
}
|
|
1885
1894
|
}));
|
|
1886
1895
|
}
|
|
1887
|
-
async function
|
|
1896
|
+
async function on(s, e) {
|
|
1888
1897
|
const t = s.conversation.conversationList.map((n) => ({
|
|
1889
1898
|
conversationId: n.id,
|
|
1890
1899
|
conversationType: n.type
|
|
@@ -1903,16 +1912,16 @@ async function Zt(s, e) {
|
|
|
1903
1912
|
});
|
|
1904
1913
|
}
|
|
1905
1914
|
} catch (o) {
|
|
1906
|
-
|
|
1915
|
+
b.warn("patch conversation mute states failed:", o);
|
|
1907
1916
|
}
|
|
1908
1917
|
}
|
|
1909
|
-
async function
|
|
1918
|
+
async function se(s, e) {
|
|
1910
1919
|
const t = new Map(s.group.groupList.map((o) => [o.groupId, o.groupName])), n = [];
|
|
1911
1920
|
for (const o of s.conversation.conversationList)
|
|
1912
|
-
if ((!o.name || o.name === o.id) && !
|
|
1921
|
+
if ((!o.name || o.name === o.id) && !Ee.has(o.id)) {
|
|
1913
1922
|
if (o.type === M.GROUPCHAT) {
|
|
1914
1923
|
const r = t.get(o.id);
|
|
1915
|
-
r && r !== o.id ? s.conversation.updateConversation(o.id, { name: r }) :
|
|
1924
|
+
r && r !== o.id ? s.conversation.updateConversation(o.id, { name: r }) : ue.has(o.id) || n.push(o.id);
|
|
1916
1925
|
} else if (o.type === M.SINGLECHAT) {
|
|
1917
1926
|
const r = s.contact.getContact(o.id), i = s.userInfo.getUserInfo(o.id), u = (r == null ? void 0 : r.remark) || (r == null ? void 0 : r.name) || (i == null ? void 0 : i.nickname);
|
|
1918
1927
|
u && s.conversation.updateConversation(o.id, { name: u });
|
|
@@ -1920,19 +1929,19 @@ async function X(s, e) {
|
|
|
1920
1929
|
}
|
|
1921
1930
|
if (n.length !== 0) {
|
|
1922
1931
|
for (const o of n)
|
|
1923
|
-
|
|
1932
|
+
ue.add(o), Ee.add(o);
|
|
1924
1933
|
try {
|
|
1925
|
-
const o = await e.groupManager.getGroupInfoList({ groupIds: n }), a =
|
|
1934
|
+
const o = await e.groupManager.getGroupInfoList({ groupIds: n }), a = ge(o);
|
|
1926
1935
|
for (const r of a)
|
|
1927
1936
|
s.group.updateGroup(r.groupId, r), r.groupName && r.groupName !== r.groupId && s.conversation.updateConversation(r.groupId, { name: r.groupName });
|
|
1928
1937
|
} catch (o) {
|
|
1929
|
-
|
|
1938
|
+
b.warn("fetch missing group names failed:", o);
|
|
1930
1939
|
} finally {
|
|
1931
|
-
for (const o of n)
|
|
1940
|
+
for (const o of n) ue.delete(o);
|
|
1932
1941
|
}
|
|
1933
1942
|
}
|
|
1934
1943
|
}
|
|
1935
|
-
function
|
|
1944
|
+
function an(s, e, t, n) {
|
|
1936
1945
|
const o = s.message.getMessages(e), a = o.findIndex(
|
|
1937
1946
|
(f) => f.msgServerId === n || f.msgLocalId === n
|
|
1938
1947
|
);
|
|
@@ -1941,19 +1950,19 @@ function en(s, e, t, n) {
|
|
|
1941
1950
|
const r = o[a], i = s.conversation.conversationList.find((f) => f.id === e);
|
|
1942
1951
|
if (!i || i.lastMessageTime && r.timestamp < i.lastMessageTime - 1e3)
|
|
1943
1952
|
return;
|
|
1944
|
-
const d = t === M.GROUPCHAT ?
|
|
1953
|
+
const d = t === M.GROUPCHAT ? Ze(s, r) : void 0, { t: g } = P();
|
|
1945
1954
|
s.conversation.updateConversation(e, {
|
|
1946
|
-
lastMessageText:
|
|
1955
|
+
lastMessageText: qe(
|
|
1947
1956
|
t,
|
|
1948
1957
|
d,
|
|
1949
1958
|
g("message.recalledPreview")
|
|
1950
1959
|
)
|
|
1951
1960
|
});
|
|
1952
1961
|
}
|
|
1953
|
-
function
|
|
1954
|
-
Promise.resolve().then(s).catch((e) =>
|
|
1962
|
+
function k(s) {
|
|
1963
|
+
Promise.resolve().then(s).catch((e) => b.warn("persistence 钩子执行失败(已忽略):", e));
|
|
1955
1964
|
}
|
|
1956
|
-
function
|
|
1965
|
+
function xe(s, e) {
|
|
1957
1966
|
const t = s.conversation.conversationList, n = new Set(e.map((r) => r.id)), o = e.map((r) => {
|
|
1958
1967
|
const i = t.find((g) => g.id === r.id);
|
|
1959
1968
|
if (!i)
|
|
@@ -1974,9 +1983,9 @@ function Le(s, e) {
|
|
|
1974
1983
|
}), a = t.filter((r) => !n.has(r.id)).sort((r, i) => (i.lastMessageTime ?? 0) - (r.lastMessageTime ?? 0));
|
|
1975
1984
|
return [...o, ...a];
|
|
1976
1985
|
}
|
|
1977
|
-
function
|
|
1986
|
+
function cn(s, e, t, n) {
|
|
1978
1987
|
var f;
|
|
1979
|
-
const o = (c) =>
|
|
1988
|
+
const o = (c) => tn(e, c), {
|
|
1980
1989
|
saveMessage: a,
|
|
1981
1990
|
updateMessageStatus: r,
|
|
1982
1991
|
markMessageRecalled: i,
|
|
@@ -1985,12 +1994,12 @@ function tn(s, e, t, n) {
|
|
|
1985
1994
|
} = (n == null ? void 0 : n.message) ?? {}, g = (f = n == null ? void 0 : n.conversation) == null ? void 0 : f.saveConversations;
|
|
1986
1995
|
return {
|
|
1987
1996
|
onSyncDataStart: (c) => {
|
|
1988
|
-
|
|
1997
|
+
b.info("onSyncDataStart", { dataType: c.dataType }), be(c.dataType, { status: "syncing" }), c.dataType === "conversation" && e.conversation.setSyncingConversations(!0);
|
|
1989
1998
|
},
|
|
1990
1999
|
onSyncDataFinished: (c) => {
|
|
1991
|
-
if (
|
|
2000
|
+
if (b.info("onSyncDataFinished", { dataType: c.dataType, status: c.status }), c.status === "failed") {
|
|
1992
2001
|
const l = c.error;
|
|
1993
|
-
|
|
2002
|
+
be(c.dataType, {
|
|
1994
2003
|
status: "failed",
|
|
1995
2004
|
finishedAt: Date.now(),
|
|
1996
2005
|
error: {
|
|
@@ -1998,95 +2007,95 @@ function tn(s, e, t, n) {
|
|
|
1998
2007
|
retryable: l == null ? void 0 : l.retryable,
|
|
1999
2008
|
message: l == null ? void 0 : l.message
|
|
2000
2009
|
}
|
|
2001
|
-
}),
|
|
2010
|
+
}), b.warn("[ChatEvents] 数据同步失败", {
|
|
2002
2011
|
dataType: c.dataType,
|
|
2003
2012
|
stage: l == null ? void 0 : l.stage,
|
|
2004
2013
|
retryable: l == null ? void 0 : l.retryable,
|
|
2005
2014
|
message: l == null ? void 0 : l.message
|
|
2006
|
-
}), c.dataType === "conversation" && (e.conversation.setSyncingConversations(!1), l != null && l.retryable && s.chatManager.refreshSessionList().catch((
|
|
2007
|
-
|
|
2015
|
+
}), c.dataType === "conversation" && (e.conversation.setSyncingConversations(!1), l != null && l.retryable && s.chatManager.refreshSessionList().catch((p) => {
|
|
2016
|
+
b.warn("[ChatEvents] conversation 同步失败重试未成功:", R(p));
|
|
2008
2017
|
}));
|
|
2009
2018
|
return;
|
|
2010
2019
|
}
|
|
2011
|
-
switch (
|
|
2020
|
+
switch (be(c.dataType, { status: "success", finishedAt: Date.now() }), c.dataType) {
|
|
2012
2021
|
case "conversation":
|
|
2013
2022
|
e.conversation.setSyncingConversations(!1);
|
|
2014
2023
|
{
|
|
2015
2024
|
const l = s.chatManager.getConversationList().filter((h) => h.conversationType !== "chatRoom");
|
|
2016
|
-
|
|
2017
|
-
const
|
|
2018
|
-
e.conversation.setConversationList(
|
|
2025
|
+
b.info("getConversationList raw (onSyncDataFinished)", l);
|
|
2026
|
+
const p = le(l, { resolveSenderName: o }), m = xe(e, p);
|
|
2027
|
+
e.conversation.setConversationList(m), b.info("conversation 同步回填", { count: m.length }), g && k(() => g(m.map(Le)));
|
|
2019
2028
|
}
|
|
2020
|
-
e.conversation.setConversationsLoaded(!0),
|
|
2029
|
+
e.conversation.setConversationsLoaded(!0), se(e, s), on(e, s);
|
|
2021
2030
|
break;
|
|
2022
2031
|
case "contact":
|
|
2023
2032
|
if (!e.contact.loaded || e.contact.contactList.length === 0) {
|
|
2024
2033
|
const l = s.contactManager.getContacts();
|
|
2025
|
-
e.contact.setContactList(
|
|
2034
|
+
e.contact.setContactList(Ge(l)), b.info("contact 同步回填", { count: l.length });
|
|
2026
2035
|
} else
|
|
2027
|
-
|
|
2028
|
-
|
|
2036
|
+
b.info("contact 同步回填跳过(列表已由业务方填充)", { count: e.contact.contactList.length });
|
|
2037
|
+
se(e, s);
|
|
2029
2038
|
break;
|
|
2030
2039
|
case "group":
|
|
2031
2040
|
if (!e.group.loaded || e.group.groupList.length === 0) {
|
|
2032
2041
|
const l = s.groupManager.getJoinedGroupList();
|
|
2033
|
-
e.group.setGroupList(
|
|
2042
|
+
e.group.setGroupList(ge(l)), b.info("group 同步回填", { count: l.length });
|
|
2034
2043
|
} else
|
|
2035
|
-
|
|
2036
|
-
|
|
2044
|
+
b.info("group 同步回填跳过(列表已由业务方填充)", { count: e.group.groupList.length });
|
|
2045
|
+
se(e, s);
|
|
2037
2046
|
break;
|
|
2038
2047
|
}
|
|
2039
2048
|
},
|
|
2040
2049
|
onConversationListUpdate: (c) => {
|
|
2041
|
-
var
|
|
2050
|
+
var C;
|
|
2042
2051
|
const l = c.items.filter((v) => v.conversationType !== "chatRoom");
|
|
2043
|
-
|
|
2052
|
+
b.info("onConversationListUpdate", { count: l.length, reset: c.patch.reset, removed: c.patch.removed.length }), b.info("getConversationList raw (onConversationListUpdate)", l);
|
|
2044
2053
|
{
|
|
2045
|
-
const v = {},
|
|
2046
|
-
for (const
|
|
2047
|
-
const
|
|
2048
|
-
v[
|
|
2054
|
+
const v = {}, w = [];
|
|
2055
|
+
for (const V of l) {
|
|
2056
|
+
const E = String(((C = V.lastMessage) == null ? void 0 : C.type) ?? "(null)");
|
|
2057
|
+
v[E] = (v[E] ?? 0) + 1, (E === S.COMBINE || E === "unknown") && w.push({ conversationId: V.conversationId, lastMessage: V.lastMessage });
|
|
2049
2058
|
}
|
|
2050
|
-
|
|
2059
|
+
w.length > 0 && b.info("raw snippets (onConversationListUpdate)", { typeCount: v, suspects: w });
|
|
2051
2060
|
}
|
|
2052
|
-
const
|
|
2061
|
+
const p = le(l, { resolveSenderName: o }), m = xe(e, p), h = new Set(c.patch.removed.map((v) => v.conversationId)), I = h.size > 0 ? m.filter((v) => !h.has(v.id)) : m;
|
|
2053
2062
|
if (c.patch.reset || c.patch.removed.length > 0)
|
|
2054
2063
|
e.conversation.setConversationList(I);
|
|
2055
2064
|
else
|
|
2056
2065
|
for (const v of I) {
|
|
2057
|
-
const
|
|
2058
|
-
|
|
2066
|
+
const w = e.conversation.conversationList.find((V) => V.id === v.id);
|
|
2067
|
+
w ? w !== v && e.conversation.updateConversation(v.id, v) : e.conversation.addConversation(v);
|
|
2059
2068
|
}
|
|
2060
|
-
g &&
|
|
2069
|
+
g && k(() => g(I.map(Le))), se(e, s);
|
|
2061
2070
|
},
|
|
2062
2071
|
onMessage: (c) => {
|
|
2063
|
-
var I,
|
|
2072
|
+
var I, C, v;
|
|
2064
2073
|
if (c.conversationType === "chatRoom")
|
|
2065
2074
|
return;
|
|
2066
2075
|
if (c.type === S.CMD) {
|
|
2067
|
-
const
|
|
2068
|
-
|
|
2076
|
+
const w = c.body.action;
|
|
2077
|
+
b.info("[CMD received]", {
|
|
2069
2078
|
conversationId: c.conversationId,
|
|
2070
2079
|
from: c.from,
|
|
2071
|
-
action:
|
|
2080
|
+
action: w,
|
|
2072
2081
|
ext: c.ext
|
|
2073
|
-
}),
|
|
2082
|
+
}), w === "TypingBegin" && (t == null ? void 0 : t.enableTyping) !== !1 && c.conversationType === M.SINGLECHAT && A(c.from) !== A(e.client.currentUser) && e.conversation.setTyping(c.conversationId, c.from);
|
|
2074
2083
|
return;
|
|
2075
2084
|
}
|
|
2076
|
-
|
|
2077
|
-
const l =
|
|
2078
|
-
|
|
2079
|
-
const
|
|
2080
|
-
if (
|
|
2085
|
+
b.info("onMessage", { conversationId: c.conversationId, from: c.from, type: c.type });
|
|
2086
|
+
const l = O(c, e.client.currentUser), p = e.message.getMessages(c.conversationId).find((w) => w.msgServerId === c.msgServerId);
|
|
2087
|
+
p != null && p.stream && ht(p.stream.status) ? e.message.replaceMessageById(c.msgServerId, l) : e.message.addMessage(l), l.type === S.VOICE && !l.isSelf && ((C = (I = e.message).markVoiceUnplayed) == null || C.call(I, l.msgServerId || l.msgLocalId)), a && k(() => a(we(c)));
|
|
2088
|
+
const m = e.conversation.currentConversationId, h = typeof document > "u" || document.visibilityState === "visible";
|
|
2089
|
+
if (m && c.conversationId === m && A(c.from) !== A(e.client.currentUser) && h && (s.chatManager.clearConversationUnreadMessageCount({
|
|
2081
2090
|
conversationId: c.conversationId,
|
|
2082
2091
|
conversationType: c.conversationType
|
|
2083
|
-
}).catch((
|
|
2084
|
-
|
|
2085
|
-
}), (t == null ? void 0 : t.enableReadReceipt) !== !1 && (c.conversationType === M.SINGLECHAT || c.conversationType === M.GROUPCHAT) &&
|
|
2086
|
-
const
|
|
2087
|
-
Array.isArray(
|
|
2092
|
+
}).catch((w) => {
|
|
2093
|
+
b.warn("[UIKit] auto clearConversationUnreadMessageCount failed:", R(w));
|
|
2094
|
+
}), (t == null ? void 0 : t.enableReadReceipt) !== !1 && (c.conversationType === M.SINGLECHAT || c.conversationType === M.GROUPCHAT) && rn(s, c.conversationType, c.conversationId, c.msgServerId)), (t == null ? void 0 : t.enableAtMe) !== !1 && c.conversationType === M.GROUPCHAT && A(c.from) !== A(e.client.currentUser)) {
|
|
2095
|
+
const w = (v = c.ext) == null ? void 0 : v.em_at_list;
|
|
2096
|
+
Array.isArray(w) && w.includes(e.client.currentUser) && (e.conversation.setAtMe(c.conversationId, !0), e.message.addAtMeMessage(c.conversationId, l.msgServerId || l.msgLocalId));
|
|
2088
2097
|
}
|
|
2089
|
-
|
|
2098
|
+
nn(e, c);
|
|
2090
2099
|
},
|
|
2091
2100
|
/**
|
|
2092
2101
|
* 流式消息(边生成边下发,典型 AI 对话)分片合并。
|
|
@@ -2102,7 +2111,7 @@ function tn(s, e, t, n) {
|
|
|
2102
2111
|
const l = c.stream;
|
|
2103
2112
|
if (!l)
|
|
2104
2113
|
return;
|
|
2105
|
-
|
|
2114
|
+
b.info("onStreamMessage", {
|
|
2106
2115
|
conversationId: c.conversationId,
|
|
2107
2116
|
from: c.from,
|
|
2108
2117
|
msgServerId: c.msgServerId,
|
|
@@ -2110,22 +2119,22 @@ function tn(s, e, t, n) {
|
|
|
2110
2119
|
status: l.status,
|
|
2111
2120
|
customType: l.customType
|
|
2112
2121
|
});
|
|
2113
|
-
const
|
|
2114
|
-
if (!
|
|
2122
|
+
const p = c.msgServerId || c.msgLocalId;
|
|
2123
|
+
if (!p)
|
|
2115
2124
|
return;
|
|
2116
2125
|
if (!e.message.getMessages(c.conversationId).some(
|
|
2117
2126
|
(h) => h.msgServerId === c.msgServerId || c.msgLocalId !== void 0 && h.msgLocalId === c.msgLocalId
|
|
2118
2127
|
)) {
|
|
2119
|
-
e.message.addMessage(
|
|
2128
|
+
e.message.addMessage(O(c, e.client.currentUser));
|
|
2120
2129
|
return;
|
|
2121
2130
|
}
|
|
2122
|
-
e.message.updateMessageById(
|
|
2131
|
+
e.message.updateMessageById(p, {
|
|
2123
2132
|
body: { ...c.body, content: l.fullText },
|
|
2124
2133
|
stream: { ...l }
|
|
2125
2134
|
});
|
|
2126
2135
|
},
|
|
2127
2136
|
onMessageRecalled: (c) => {
|
|
2128
|
-
c.conversationType !== "chatRoom" && (
|
|
2137
|
+
c.conversationType !== "chatRoom" && (b.info("onMessageRecalled", { messageId: c.messageId }), e.message.recallMessage(c.messageId, e.client.currentUser), i && k(() => i(c.messageId, e.client.currentUser)), an(
|
|
2129
2138
|
e,
|
|
2130
2139
|
c.conversationId,
|
|
2131
2140
|
c.conversationType,
|
|
@@ -2133,34 +2142,34 @@ function tn(s, e, t, n) {
|
|
|
2133
2142
|
));
|
|
2134
2143
|
},
|
|
2135
2144
|
onMessageDelivered: (c) => {
|
|
2136
|
-
|
|
2145
|
+
b.info("onMessageDelivered", { messageId: c.messageId }), e.message.updateMessageStatus(c.messageId, x.DELIVERED), r && k(() => r(c.messageId, x.DELIVERED));
|
|
2137
2146
|
},
|
|
2138
2147
|
onMessageReadReceipts: (c) => {
|
|
2139
2148
|
for (const l of c)
|
|
2140
2149
|
if (l.conversationType === M.GROUPCHAT) {
|
|
2141
|
-
|
|
2150
|
+
b.info("onMessageReadReceipts(group)", {
|
|
2142
2151
|
conversationId: l.conversationId,
|
|
2143
|
-
details: l.receiptDetails.map((
|
|
2152
|
+
details: l.receiptDetails.map((p) => ({ messageId: p.messageId, count: p.count }))
|
|
2144
2153
|
});
|
|
2145
|
-
for (const
|
|
2146
|
-
e.message.updateMessageById(
|
|
2154
|
+
for (const p of l.receiptDetails)
|
|
2155
|
+
e.message.updateMessageById(p.messageId, { groupReadCount: p.count });
|
|
2147
2156
|
} else {
|
|
2148
|
-
|
|
2157
|
+
b.info("onMessageReadReceipts(single)", {
|
|
2149
2158
|
conversationId: l.conversationId,
|
|
2150
2159
|
total: l.messageIds.length,
|
|
2151
2160
|
messageIds: l.messageIds.slice(0, 5)
|
|
2152
2161
|
});
|
|
2153
|
-
for (const
|
|
2154
|
-
e.message.updateMessageStatus(
|
|
2162
|
+
for (const p of l.messageIds)
|
|
2163
|
+
e.message.updateMessageStatus(p, x.READ), r && k(() => r(p, x.READ));
|
|
2155
2164
|
}
|
|
2156
2165
|
},
|
|
2157
2166
|
onMessageUpdated: (c) => {
|
|
2158
|
-
c.conversationType !== "chatRoom" && (
|
|
2167
|
+
c.conversationType !== "chatRoom" && (b.info("onMessageUpdated", { messageId: c.messageId }), e.message.updateMessageById(c.messageId, {
|
|
2159
2168
|
body: c.message.body,
|
|
2160
2169
|
ext: c.message.ext,
|
|
2161
2170
|
modifiedInfo: c.message.modifiedInfo,
|
|
2162
2171
|
modified: !0
|
|
2163
|
-
}), u &&
|
|
2172
|
+
}), u && k(() => u(
|
|
2164
2173
|
c.messageId,
|
|
2165
2174
|
c.message.body,
|
|
2166
2175
|
c.message.ext,
|
|
@@ -2168,69 +2177,69 @@ function tn(s, e, t, n) {
|
|
|
2168
2177
|
)));
|
|
2169
2178
|
},
|
|
2170
2179
|
onPinnedMessageChanged: async (c) => {
|
|
2171
|
-
if (c.conversationType !== "chatRoom" && (
|
|
2180
|
+
if (c.conversationType !== "chatRoom" && (b.info("onPinnedMessageChanged", { conversationId: c.conversationId, operation: c.operation }), !!c.messageId && (c.operation === "pin" ? e.message.setMessagePinned(c.messageId, {
|
|
2172
2181
|
operatorId: c.operatorId || "",
|
|
2173
2182
|
pinTime: c.pinTime || Date.now()
|
|
2174
2183
|
}) : c.operation === "unpin" && e.message.setMessageUnpinned(c.messageId), c.conversationId && c.conversationType)))
|
|
2175
2184
|
try {
|
|
2176
|
-
const
|
|
2185
|
+
const p = (await s.chatManager.getPinnedMessageList({
|
|
2177
2186
|
conversationId: c.conversationId,
|
|
2178
2187
|
conversationType: c.conversationType
|
|
2179
|
-
})).items.map((
|
|
2180
|
-
e.message.setPinnedMessages(c.conversationId,
|
|
2188
|
+
})).items.map((m) => O(m.message, e.client.currentUser));
|
|
2189
|
+
e.message.setPinnedMessages(c.conversationId, p);
|
|
2181
2190
|
} catch (l) {
|
|
2182
|
-
|
|
2191
|
+
b.warn("refresh pinned messages failed:", l);
|
|
2183
2192
|
}
|
|
2184
2193
|
},
|
|
2185
2194
|
onMultiDeviceConversation: (c) => {
|
|
2186
|
-
if (
|
|
2187
|
-
for (const
|
|
2188
|
-
e.conversation.updateUnreadCount(
|
|
2195
|
+
if (b.info("onMultiDeviceConversation", { operation: c.operation }), c.operation === "ALL_CONVERSATIONS_UNREAD_MESSAGE_COUNT_CLEARED") {
|
|
2196
|
+
for (const m of e.conversation.conversationList)
|
|
2197
|
+
e.conversation.updateUnreadCount(m.id, 0);
|
|
2189
2198
|
return;
|
|
2190
2199
|
}
|
|
2191
|
-
const { operation: l, conversationId:
|
|
2200
|
+
const { operation: l, conversationId: p } = c;
|
|
2192
2201
|
switch (l) {
|
|
2193
2202
|
case "CONVERSATION_DELETED":
|
|
2194
|
-
e.conversation.deleteConversation(
|
|
2203
|
+
e.conversation.deleteConversation(p);
|
|
2195
2204
|
break;
|
|
2196
2205
|
case "CONVERSATION_PINNED":
|
|
2197
|
-
e.conversation.updateConversation(
|
|
2206
|
+
e.conversation.updateConversation(p, { isPinned: !0 });
|
|
2198
2207
|
break;
|
|
2199
2208
|
case "CONVERSATION_UNPINNED":
|
|
2200
|
-
e.conversation.updateConversation(
|
|
2209
|
+
e.conversation.updateConversation(p, { isPinned: !1 });
|
|
2201
2210
|
break;
|
|
2202
2211
|
case "CONVERSATION_UNREAD_MESSAGE_COUNT_CLEARED":
|
|
2203
|
-
e.conversation.updateUnreadCount(
|
|
2212
|
+
e.conversation.updateUnreadCount(p, 0);
|
|
2204
2213
|
break;
|
|
2205
2214
|
case "CONVERSATION_MARK":
|
|
2206
|
-
c.mark !== void 0 && e.conversation.updateConversation(
|
|
2215
|
+
c.mark !== void 0 && e.conversation.updateConversation(p, { marks: [c.mark] });
|
|
2207
2216
|
break;
|
|
2208
2217
|
case "CONVERSATION_MUTE_INFO_CHANGED":
|
|
2209
|
-
c.remindType && e.conversation.updateConversation(
|
|
2218
|
+
c.remindType && e.conversation.updateConversation(p, {
|
|
2210
2219
|
isMuted: c.remindType === "NONE",
|
|
2211
2220
|
remindType: c.remindType
|
|
2212
2221
|
});
|
|
2213
2222
|
break;
|
|
2214
2223
|
default:
|
|
2215
|
-
|
|
2224
|
+
b.warn("onMultiDeviceConversation unhandled:", c);
|
|
2216
2225
|
}
|
|
2217
2226
|
},
|
|
2218
2227
|
onMultiDeviceMessageRemoved: (c) => {
|
|
2219
|
-
|
|
2220
|
-
const { operation: l, conversationId:
|
|
2221
|
-
if (!(!
|
|
2222
|
-
if (
|
|
2223
|
-
e.message.deleteMessages([...
|
|
2228
|
+
b.info("onMultiDeviceMessageRemoved", { conversationId: c.conversationId, operation: c.operation, messageIds: c.messageIds });
|
|
2229
|
+
const { operation: l, conversationId: p, messageIds: m, beforeTimestamp: h } = c;
|
|
2230
|
+
if (!(!p || l !== "MESSAGE_REMOVED")) {
|
|
2231
|
+
if (m && m.length > 0)
|
|
2232
|
+
e.message.deleteMessages([...m]), d && k(() => d([...m]));
|
|
2224
2233
|
else if (h) {
|
|
2225
|
-
const
|
|
2226
|
-
|
|
2234
|
+
const C = e.message.getMessages(p).filter((v) => v.timestamp && v.timestamp < h).map((v) => v.msgServerId || v.msgLocalId).filter((v) => !!v);
|
|
2235
|
+
C.length > 0 && (e.message.deleteMessages(C), d && k(() => d(C)));
|
|
2227
2236
|
}
|
|
2228
2237
|
}
|
|
2229
2238
|
}
|
|
2230
2239
|
};
|
|
2231
2240
|
}
|
|
2232
|
-
const
|
|
2233
|
-
function
|
|
2241
|
+
const W = T("UIKit:ContactEvents");
|
|
2242
|
+
function Oe(s, e = "pending") {
|
|
2234
2243
|
const t = s.userInfo, n = s.from;
|
|
2235
2244
|
return {
|
|
2236
2245
|
id: n,
|
|
@@ -2244,37 +2253,37 @@ function De(s, e = "pending") {
|
|
|
2244
2253
|
timestamp: Date.now()
|
|
2245
2254
|
};
|
|
2246
2255
|
}
|
|
2247
|
-
function
|
|
2248
|
-
const { t: e, insertChatNotice: t } =
|
|
2256
|
+
function un(s) {
|
|
2257
|
+
const { t: e, insertChatNotice: t } = P();
|
|
2249
2258
|
return {
|
|
2250
2259
|
onContactInvited: (n) => {
|
|
2251
|
-
|
|
2260
|
+
W.info("onContactInvited", { from: n.from });
|
|
2252
2261
|
const o = n.from, a = o ? s.contact.getContact(o) : void 0;
|
|
2253
|
-
s.contact.addInvite(
|
|
2262
|
+
s.contact.addInvite(Oe(n, a ? "accepted" : "pending"));
|
|
2254
2263
|
},
|
|
2255
2264
|
onContactAgreed: (n) => {
|
|
2256
|
-
|
|
2265
|
+
W.info("onContactAgreed", { from: n.from });
|
|
2257
2266
|
const o = n.from;
|
|
2258
2267
|
if (!o)
|
|
2259
2268
|
return;
|
|
2260
2269
|
s.contact.getInvite(o) && s.contact.updateInviteStatus(o, "accepted"), s.contact.addContact({ userId: o, name: o });
|
|
2261
2270
|
},
|
|
2262
2271
|
onContactRefuse: (n) => {
|
|
2263
|
-
|
|
2272
|
+
W.info("onContactRefuse", { from: n.from });
|
|
2264
2273
|
const o = n.from;
|
|
2265
|
-
o && (s.contact.getInvite(o) ? s.contact.updateInviteStatus(o, "declined") : s.contact.addInvite({ ...
|
|
2274
|
+
o && (s.contact.getInvite(o) ? s.contact.updateInviteStatus(o, "declined") : s.contact.addInvite({ ...Oe(n, "declined"), outgoing: !0, unread: !0 }), ke(s, o, "declined"));
|
|
2266
2275
|
},
|
|
2267
2276
|
onContactDeleted: (n) => {
|
|
2268
|
-
|
|
2277
|
+
W.info("onContactDeleted", { from: n.from });
|
|
2269
2278
|
const o = n.from;
|
|
2270
2279
|
o && (s.contact.removeContact(o), s.contact.removeInvite(o), t(s, o, M.SINGLECHAT, {
|
|
2271
2280
|
eventType: G.CONTACT_DELETED,
|
|
2272
2281
|
params: {},
|
|
2273
2282
|
defaultText: e("chat.notice.contactDeleted")
|
|
2274
|
-
}),
|
|
2283
|
+
}), ke(s, o, "deleted"));
|
|
2275
2284
|
},
|
|
2276
2285
|
onContactAdded: (n) => {
|
|
2277
|
-
|
|
2286
|
+
W.info("onContactAdded", { from: n.from });
|
|
2278
2287
|
const o = n.from;
|
|
2279
2288
|
o && (s.contact.addContact({ userId: o, name: o }), s.contact.removeInvite(o), t(s, o, M.SINGLECHAT, {
|
|
2280
2289
|
eventType: G.CONTACT_ADDED,
|
|
@@ -2284,7 +2293,7 @@ function nn(s) {
|
|
|
2284
2293
|
},
|
|
2285
2294
|
onContactInfoUpdated: (n) => {
|
|
2286
2295
|
var a, r;
|
|
2287
|
-
|
|
2296
|
+
W.info("onContactInfoUpdated", { userId: (a = n.contact) == null ? void 0 : a.userId });
|
|
2288
2297
|
const o = n.contact;
|
|
2289
2298
|
if (o != null && o.userId && o.remark !== void 0) {
|
|
2290
2299
|
s.contact.updateContactRemark(o.userId, o.remark);
|
|
@@ -2294,8 +2303,8 @@ function nn(s) {
|
|
|
2294
2303
|
}
|
|
2295
2304
|
};
|
|
2296
2305
|
}
|
|
2297
|
-
const y =
|
|
2298
|
-
function
|
|
2306
|
+
const y = T("UIKit:GroupEvents");
|
|
2307
|
+
function Pe(s, e = "pending") {
|
|
2299
2308
|
const t = s.groupId, n = "inviter" in s ? s.inviter : void 0, o = "groupName" in s ? s.groupName : void 0;
|
|
2300
2309
|
return {
|
|
2301
2310
|
id: t,
|
|
@@ -2309,8 +2318,8 @@ function _e(s, e = "pending") {
|
|
|
2309
2318
|
timestamp: Date.now()
|
|
2310
2319
|
};
|
|
2311
2320
|
}
|
|
2312
|
-
function
|
|
2313
|
-
const { t: o, resolveNoticeUserName: a } =
|
|
2321
|
+
function re(s, e, t, n) {
|
|
2322
|
+
const { t: o, resolveNoticeUserName: a } = P();
|
|
2314
2323
|
if (s.length === 0)
|
|
2315
2324
|
return "";
|
|
2316
2325
|
const r = s[0];
|
|
@@ -2321,23 +2330,23 @@ function Z(s, e, t, n) {
|
|
|
2321
2330
|
const i = s.find((d) => d.userId !== e), u = a(i || r);
|
|
2322
2331
|
return o(n).replace("{name}", u).replace("{count}", String(s.length));
|
|
2323
2332
|
}
|
|
2324
|
-
function
|
|
2325
|
-
const { t, resolveNoticeUserName: n } =
|
|
2333
|
+
function oe(s, e) {
|
|
2334
|
+
const { t, resolveNoticeUserName: n } = P(), o = s.find((r) => r.userId !== e) ?? s[0];
|
|
2326
2335
|
return {
|
|
2327
2336
|
name: (o == null ? void 0 : o.userId) === e ? t("chat.notice.you") : n(o),
|
|
2328
2337
|
count: s.length,
|
|
2329
2338
|
userIds: s.map((r) => r.userId).join(",")
|
|
2330
2339
|
};
|
|
2331
2340
|
}
|
|
2332
|
-
function
|
|
2333
|
-
const { t: e, insertChatNotice: t, buildAnnouncementNoticeText: n, resolveNoticeUserName: o } =
|
|
2341
|
+
function dn(s) {
|
|
2342
|
+
const { t: e, insertChatNotice: t, buildAnnouncementNoticeText: n, resolveNoticeUserName: o } = P();
|
|
2334
2343
|
function a(r) {
|
|
2335
2344
|
return s.group.groupList.some((i) => i.groupId === r);
|
|
2336
2345
|
}
|
|
2337
2346
|
return {
|
|
2338
2347
|
onInvitationReceived: (r) => {
|
|
2339
2348
|
y.info("onInvitationReceived raw payload", r);
|
|
2340
|
-
const i =
|
|
2349
|
+
const i = Pe(r, a(r.groupId) ? "accepted" : "pending");
|
|
2341
2350
|
s.contact.addInvite(i);
|
|
2342
2351
|
},
|
|
2343
2352
|
onInvitationAccepted: (r) => {
|
|
@@ -2347,13 +2356,13 @@ function sn(s) {
|
|
|
2347
2356
|
y.info("onInvitationDeclined raw payload", r), s.contact.updateInviteStatus(r.groupId, "declined");
|
|
2348
2357
|
},
|
|
2349
2358
|
onAutoAcceptInvitationFromGroup: (r) => {
|
|
2350
|
-
y.info("onAutoAcceptInvitationFromGroup raw payload", r), s.contact.addInvite(
|
|
2359
|
+
y.info("onAutoAcceptInvitationFromGroup raw payload", r), s.contact.addInvite(Pe(r, "accepted"));
|
|
2351
2360
|
},
|
|
2352
2361
|
onMembersJoined: (r) => {
|
|
2353
2362
|
y.info("onMembersJoined raw payload", r);
|
|
2354
2363
|
const i = r.members || [], u = s.client.currentUser;
|
|
2355
2364
|
i.some((f) => f.userId === u) && (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);
|
|
2356
|
-
const g =
|
|
2365
|
+
const g = re(
|
|
2357
2366
|
i,
|
|
2358
2367
|
u || "",
|
|
2359
2368
|
"chat.notice.memberJoined",
|
|
@@ -2361,14 +2370,14 @@ function sn(s) {
|
|
|
2361
2370
|
);
|
|
2362
2371
|
t(s, r.groupId, M.GROUPCHAT, {
|
|
2363
2372
|
eventType: G.MEMBER_JOINED,
|
|
2364
|
-
params:
|
|
2373
|
+
params: oe(i, u || ""),
|
|
2365
2374
|
defaultText: g
|
|
2366
2375
|
});
|
|
2367
2376
|
},
|
|
2368
2377
|
onMembersExited: (r) => {
|
|
2369
2378
|
const i = r.members || [];
|
|
2370
2379
|
y.info("onMembersExited raw payload", r), s.group.decrementMemberCount(r.groupId, i.length);
|
|
2371
|
-
const u =
|
|
2380
|
+
const u = re(
|
|
2372
2381
|
i,
|
|
2373
2382
|
s.client.currentUser || "",
|
|
2374
2383
|
"chat.notice.memberExited",
|
|
@@ -2376,7 +2385,7 @@ function sn(s) {
|
|
|
2376
2385
|
);
|
|
2377
2386
|
t(s, r.groupId, M.GROUPCHAT, {
|
|
2378
2387
|
eventType: G.MEMBER_EXITED,
|
|
2379
|
-
params:
|
|
2388
|
+
params: oe(i, s.client.currentUser || ""),
|
|
2380
2389
|
defaultText: u
|
|
2381
2390
|
});
|
|
2382
2391
|
},
|
|
@@ -2394,10 +2403,10 @@ function sn(s) {
|
|
|
2394
2403
|
}), s.conversation.updateConversation(r.groupId, { name: u }));
|
|
2395
2404
|
},
|
|
2396
2405
|
onOwnerChanged: (r) => {
|
|
2397
|
-
var
|
|
2406
|
+
var p, m, h, I, C, v;
|
|
2398
2407
|
y.info("onOwnerChanged raw payload", r);
|
|
2399
|
-
const i = (
|
|
2400
|
-
f && (f === d ? g.role =
|
|
2408
|
+
const i = (p = s.group.getGroupById(r.groupId)) == null ? void 0 : p.owner, u = (h = (m = s.group).getPendingOwnerTransfer) == null ? void 0 : h.call(m, r.groupId), d = u || ((I = r.newOwner) == null ? void 0 : I.userId) || "", g = { owner: d }, f = s.client.currentUser || "";
|
|
2409
|
+
f && (f === d ? g.role = N.OWNER : f === i && (g.role = N.MEMBER)), s.group.updateGroup(r.groupId, g), d && s.group.updateGroupMemberRole(r.groupId, d, N.OWNER), i && i !== d && s.group.updateGroupMemberRole(r.groupId, i, N.MEMBER), u && ((v = (C = s.group).clearPendingOwnerTransfer) == null || v.call(C, r.groupId));
|
|
2401
2410
|
const c = d === f ? e("chat.notice.you") : o(r.newOwner), l = e("chat.notice.ownerChanged").replace("{name}", c);
|
|
2402
2411
|
t(s, r.groupId, M.GROUPCHAT, {
|
|
2403
2412
|
eventType: G.OWNER_CHANGED,
|
|
@@ -2409,7 +2418,7 @@ function sn(s) {
|
|
|
2409
2418
|
var f;
|
|
2410
2419
|
y.info("onAdminAdded raw payload", r);
|
|
2411
2420
|
const i = (f = r.administrator) == null ? void 0 : f.userId;
|
|
2412
|
-
i && s.group.updateGroupMemberRole(r.groupId, i,
|
|
2421
|
+
i && s.group.updateGroupMemberRole(r.groupId, i, N.ADMIN);
|
|
2413
2422
|
const u = s.client.currentUser || "", d = i === u ? e("chat.notice.you") : o(r.administrator), g = e("chat.notice.adminAdded").replace("{name}", d);
|
|
2414
2423
|
t(s, r.groupId, M.GROUPCHAT, {
|
|
2415
2424
|
eventType: G.ADMIN_ADDED,
|
|
@@ -2421,7 +2430,7 @@ function sn(s) {
|
|
|
2421
2430
|
var f;
|
|
2422
2431
|
y.info("onAdminRemoved raw payload", r);
|
|
2423
2432
|
const i = (f = r.administrator) == null ? void 0 : f.userId;
|
|
2424
|
-
i && s.group.updateGroupMemberRole(r.groupId, i,
|
|
2433
|
+
i && s.group.updateGroupMemberRole(r.groupId, i, N.MEMBER);
|
|
2425
2434
|
const u = s.client.currentUser || "", d = i === u ? e("chat.notice.you") : o(r.administrator), g = e("chat.notice.adminRemoved").replace("{name}", d);
|
|
2426
2435
|
t(s, r.groupId, M.GROUPCHAT, {
|
|
2427
2436
|
eventType: G.ADMIN_REMOVED,
|
|
@@ -2493,7 +2502,7 @@ function sn(s) {
|
|
|
2493
2502
|
y.info("onAllowListAdded raw payload", r);
|
|
2494
2503
|
const i = (r.allowlist || []).map((d) => d.userId);
|
|
2495
2504
|
s.group.addGroupAllowlistMembers(r.groupId, i);
|
|
2496
|
-
const u =
|
|
2505
|
+
const u = re(
|
|
2497
2506
|
r.allowlist || [],
|
|
2498
2507
|
s.client.currentUser || "",
|
|
2499
2508
|
"chat.notice.allowlistAdded",
|
|
@@ -2501,7 +2510,7 @@ function sn(s) {
|
|
|
2501
2510
|
);
|
|
2502
2511
|
t(s, r.groupId, M.GROUPCHAT, {
|
|
2503
2512
|
eventType: G.ALLOWLIST_ADDED,
|
|
2504
|
-
params:
|
|
2513
|
+
params: oe(r.allowlist || [], s.client.currentUser || ""),
|
|
2505
2514
|
defaultText: u
|
|
2506
2515
|
});
|
|
2507
2516
|
},
|
|
@@ -2509,7 +2518,7 @@ function sn(s) {
|
|
|
2509
2518
|
y.info("onAllowListRemoved raw payload", r);
|
|
2510
2519
|
const i = (r.allowlist || []).map((d) => d.userId);
|
|
2511
2520
|
s.group.removeGroupAllowlistMembers(r.groupId, i);
|
|
2512
|
-
const u =
|
|
2521
|
+
const u = re(
|
|
2513
2522
|
r.allowlist || [],
|
|
2514
2523
|
s.client.currentUser || "",
|
|
2515
2524
|
"chat.notice.allowlistRemoved",
|
|
@@ -2517,7 +2526,7 @@ function sn(s) {
|
|
|
2517
2526
|
);
|
|
2518
2527
|
t(s, r.groupId, M.GROUPCHAT, {
|
|
2519
2528
|
eventType: G.ALLOWLIST_REMOVED,
|
|
2520
|
-
params:
|
|
2529
|
+
params: oe(r.allowlist || [], s.client.currentUser || ""),
|
|
2521
2530
|
defaultText: u
|
|
2522
2531
|
});
|
|
2523
2532
|
},
|
|
@@ -2578,17 +2587,17 @@ function sn(s) {
|
|
|
2578
2587
|
}
|
|
2579
2588
|
};
|
|
2580
2589
|
}
|
|
2581
|
-
const
|
|
2582
|
-
function
|
|
2590
|
+
const ln = T("UIKit:PresenceEvents");
|
|
2591
|
+
function gn(s) {
|
|
2583
2592
|
return {
|
|
2584
2593
|
onPresenceStatusChange: (e) => {
|
|
2585
|
-
if (
|
|
2594
|
+
if (ln.info("onPresenceStatusChange", { count: Array.isArray(e) ? e.length : 0 }), !Array.isArray(e))
|
|
2586
2595
|
return;
|
|
2587
2596
|
const t = e.map((n) => {
|
|
2588
2597
|
const o = n.userId || "", r = (Array.isArray(n.statusDetails) ? n.statusDetails : []).some((u) => Number(u == null ? void 0 : u.status) === 1), i = n.ext || "";
|
|
2589
2598
|
return {
|
|
2590
2599
|
userId: o,
|
|
2591
|
-
status:
|
|
2600
|
+
status: ze(r, i),
|
|
2592
2601
|
ext: i,
|
|
2593
2602
|
lastTime: n.lastTime || Date.now()
|
|
2594
2603
|
};
|
|
@@ -2597,25 +2606,25 @@ function on(s) {
|
|
|
2597
2606
|
}
|
|
2598
2607
|
};
|
|
2599
2608
|
}
|
|
2600
|
-
function
|
|
2601
|
-
const a =
|
|
2609
|
+
function pn(s, e, t = {}, n, o) {
|
|
2610
|
+
const a = Xt(e, t), r = cn(s, e, n, o), i = un(e), u = dn(e), d = gn(e);
|
|
2602
2611
|
return s.addEventHandler("uikit-conn", a), s.chatManager.addEventHandler("uikit-chat", r), s.contactManager.addEventHandler("uikit-contact", i), s.groupManager.addEventHandler("uikit-group", u), s.presenceManager.addEventHandler("uikit-presence", d), () => {
|
|
2603
|
-
s.removeEventHandler("uikit-conn"), s.chatManager.removeEventHandler("uikit-chat"), s.contactManager.removeEventHandler("uikit-contact"), s.groupManager.removeEventHandler("uikit-group"), s.presenceManager.removeEventHandler("uikit-presence"),
|
|
2612
|
+
s.removeEventHandler("uikit-conn"), s.chatManager.removeEventHandler("uikit-chat"), s.contactManager.removeEventHandler("uikit-contact"), s.groupManager.removeEventHandler("uikit-group"), s.presenceManager.removeEventHandler("uikit-presence"), sn(), en();
|
|
2604
2613
|
};
|
|
2605
2614
|
}
|
|
2606
|
-
const
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
],
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2615
|
+
const L = T("UIKit:Websdk5Adapter"), fn = [
|
|
2616
|
+
Be,
|
|
2617
|
+
nt,
|
|
2618
|
+
st,
|
|
2619
|
+
rt,
|
|
2620
|
+
ot,
|
|
2621
|
+
He
|
|
2622
|
+
], mn = [
|
|
2623
|
+
Be,
|
|
2624
|
+
tt,
|
|
2625
|
+
He
|
|
2617
2626
|
];
|
|
2618
|
-
function
|
|
2627
|
+
function hn() {
|
|
2619
2628
|
return {
|
|
2620
2629
|
enableContact: !0,
|
|
2621
2630
|
enableBlocklist: !0,
|
|
@@ -2634,15 +2643,15 @@ function dn() {
|
|
|
2634
2643
|
filterBlockedContacts: !0
|
|
2635
2644
|
};
|
|
2636
2645
|
}
|
|
2637
|
-
function
|
|
2646
|
+
function vn(s) {
|
|
2638
2647
|
if (s != null && s.fetchUserInfos)
|
|
2639
2648
|
return { fetchUserInfos: s.fetchUserInfos };
|
|
2640
2649
|
}
|
|
2641
|
-
function
|
|
2650
|
+
function In() {
|
|
2642
2651
|
try {
|
|
2643
|
-
|
|
2652
|
+
P();
|
|
2644
2653
|
} catch {
|
|
2645
|
-
|
|
2654
|
+
L.warn("[Websdk5Adapter] 事件层依赖未注入,使用最小兜底实现"), Xe({
|
|
2646
2655
|
t: (s) => s,
|
|
2647
2656
|
insertChatNotice: () => {
|
|
2648
2657
|
},
|
|
@@ -2666,7 +2675,7 @@ function gn() {
|
|
|
2666
2675
|
});
|
|
2667
2676
|
}
|
|
2668
2677
|
}
|
|
2669
|
-
function
|
|
2678
|
+
function Mn(s, e) {
|
|
2670
2679
|
let t = !1, n = !1, o = !1;
|
|
2671
2680
|
function a() {
|
|
2672
2681
|
return n ? "connecting" : t ? "connected" : o ? "reconnectFailed" : "disconnected";
|
|
@@ -2696,7 +2705,7 @@ function mn(s, e) {
|
|
|
2696
2705
|
}
|
|
2697
2706
|
};
|
|
2698
2707
|
}
|
|
2699
|
-
function
|
|
2708
|
+
function bn(s) {
|
|
2700
2709
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
2701
2710
|
let n = !1;
|
|
2702
2711
|
function o(i) {
|
|
@@ -2818,12 +2827,12 @@ function fn(s) {
|
|
|
2818
2827
|
e.delete(i);
|
|
2819
2828
|
},
|
|
2820
2829
|
updateMessageById(i, u) {
|
|
2821
|
-
var c, l,
|
|
2830
|
+
var c, l, p, m;
|
|
2822
2831
|
const d = a(i);
|
|
2823
2832
|
if (!d)
|
|
2824
2833
|
return;
|
|
2825
2834
|
const g = d.list[d.index], f = { ...g, ...u };
|
|
2826
|
-
d.list[d.index] = f, (u.modified || u.modifiedInfo) && ((l = (c = s()) == null ? void 0 : c.onMessageUpdated) == null || l.call(c, f)), u.status && u.status !== g.status && ((
|
|
2835
|
+
d.list[d.index] = f, (u.modified || u.modifiedInfo) && ((l = (c = s()) == null ? void 0 : c.onMessageUpdated) == null || l.call(c, f)), u.status && u.status !== g.status && ((m = (p = s()) == null ? void 0 : p.onMessageStatusChanged) == null || m.call(p, {
|
|
2827
2836
|
messageId: i,
|
|
2828
2837
|
status: u.status
|
|
2829
2838
|
}));
|
|
@@ -2863,16 +2872,16 @@ function fn(s) {
|
|
|
2863
2872
|
var g, f;
|
|
2864
2873
|
const u = new Set(i), d = /* @__PURE__ */ new Map();
|
|
2865
2874
|
for (const [c, l] of e) {
|
|
2866
|
-
const
|
|
2867
|
-
for (const
|
|
2868
|
-
const h =
|
|
2875
|
+
const p = [];
|
|
2876
|
+
for (const m of l) {
|
|
2877
|
+
const h = m.msgServerId || m.msgLocalId;
|
|
2869
2878
|
if (h && u.has(h)) {
|
|
2870
2879
|
const I = d.get(c) ?? [];
|
|
2871
2880
|
I.push(h), d.set(c, I);
|
|
2872
2881
|
} else
|
|
2873
|
-
|
|
2882
|
+
p.push(m);
|
|
2874
2883
|
}
|
|
2875
|
-
e.set(c,
|
|
2884
|
+
e.set(c, p);
|
|
2876
2885
|
}
|
|
2877
2886
|
for (const [c, l] of d)
|
|
2878
2887
|
(f = (g = s()) == null ? void 0 : g.onMessagesDeleted) == null || f.call(g, { messageIds: l, conversationId: c });
|
|
@@ -2886,7 +2895,7 @@ function fn(s) {
|
|
|
2886
2895
|
}
|
|
2887
2896
|
};
|
|
2888
2897
|
}
|
|
2889
|
-
function
|
|
2898
|
+
function Cn(s) {
|
|
2890
2899
|
let e = [], t = null, n = !1;
|
|
2891
2900
|
function o() {
|
|
2892
2901
|
var a, r;
|
|
@@ -2948,7 +2957,7 @@ function pn(s) {
|
|
|
2948
2957
|
}
|
|
2949
2958
|
};
|
|
2950
2959
|
}
|
|
2951
|
-
function
|
|
2960
|
+
function wn(s) {
|
|
2952
2961
|
let e = [], t = [];
|
|
2953
2962
|
function o() {
|
|
2954
2963
|
var r, i;
|
|
@@ -3010,7 +3019,7 @@ function hn(s) {
|
|
|
3010
3019
|
}
|
|
3011
3020
|
};
|
|
3012
3021
|
}
|
|
3013
|
-
function
|
|
3022
|
+
function yn(s) {
|
|
3014
3023
|
let e = [];
|
|
3015
3024
|
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(), u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Set(), g = !1;
|
|
3016
3025
|
function f() {
|
|
@@ -3028,45 +3037,45 @@ function vn(s) {
|
|
|
3028
3037
|
e = c, f();
|
|
3029
3038
|
},
|
|
3030
3039
|
addGroup(c) {
|
|
3031
|
-
var
|
|
3040
|
+
var p, m;
|
|
3032
3041
|
const l = e.findIndex((h) => h.groupId === c.groupId);
|
|
3033
|
-
l >= 0 ? e[l] = { ...e[l], ...c } : e.push(c), f(), (
|
|
3042
|
+
l >= 0 ? e[l] = { ...e[l], ...c } : e.push(c), f(), (m = (p = s()) == null ? void 0 : p.onGroupUpdated) == null || m.call(p, c);
|
|
3034
3043
|
},
|
|
3035
3044
|
removeGroup(c) {
|
|
3036
|
-
var
|
|
3045
|
+
var p, m;
|
|
3037
3046
|
const l = e.find((h) => h.groupId === c);
|
|
3038
|
-
e = e.filter((h) => h.groupId !== c), l && (f(), (
|
|
3047
|
+
e = e.filter((h) => h.groupId !== c), l && (f(), (m = (p = s()) == null ? void 0 : p.onGroupUpdated) == null || m.call(p, l));
|
|
3039
3048
|
},
|
|
3040
3049
|
updateGroup(c, l) {
|
|
3041
|
-
var
|
|
3042
|
-
const
|
|
3043
|
-
|
|
3050
|
+
var m, h;
|
|
3051
|
+
const p = e.findIndex((I) => I.groupId === c);
|
|
3052
|
+
p < 0 || (e[p] = { ...e[p], ...l }, f(), (h = (m = s()) == null ? void 0 : m.onGroupUpdated) == null || h.call(m, e[p]));
|
|
3044
3053
|
},
|
|
3045
3054
|
setGroupMembers(c, l) {
|
|
3046
|
-
var
|
|
3047
|
-
t.set(c, l), (
|
|
3055
|
+
var p, m;
|
|
3056
|
+
t.set(c, l), (m = (p = s()) == null ? void 0 : p.onGroupMembersChanged) == null || m.call(p, { groupId: c, members: l });
|
|
3048
3057
|
},
|
|
3049
3058
|
appendGroupMembers(c, l) {
|
|
3050
|
-
var I,
|
|
3051
|
-
const
|
|
3059
|
+
var I, C;
|
|
3060
|
+
const p = t.get(c) ?? [], m = new Map(p.map((v) => [v.userId, v]));
|
|
3052
3061
|
for (const v of l)
|
|
3053
|
-
|
|
3054
|
-
const h = Array.from(
|
|
3055
|
-
t.set(c, h), (
|
|
3062
|
+
m.set(v.userId, v);
|
|
3063
|
+
const h = Array.from(m.values());
|
|
3064
|
+
t.set(c, h), (C = (I = s()) == null ? void 0 : I.onGroupMembersChanged) == null || C.call(I, { groupId: c, members: h });
|
|
3056
3065
|
},
|
|
3057
3066
|
removeGroupMembers(c, l) {
|
|
3058
3067
|
var h, I;
|
|
3059
|
-
const
|
|
3060
|
-
t.set(c,
|
|
3068
|
+
const p = new Set(l), m = (t.get(c) ?? []).filter((C) => !p.has(C.userId));
|
|
3069
|
+
t.set(c, m), (I = (h = s()) == null ? void 0 : h.onGroupMembersChanged) == null || I.call(h, { groupId: c, members: m });
|
|
3061
3070
|
},
|
|
3062
|
-
updateGroupMemberRole(c, l,
|
|
3063
|
-
var I,
|
|
3064
|
-
const
|
|
3065
|
-
h < 0 || (
|
|
3071
|
+
updateGroupMemberRole(c, l, p) {
|
|
3072
|
+
var I, C;
|
|
3073
|
+
const m = t.get(c) ?? [], h = m.findIndex((v) => v.userId === l);
|
|
3074
|
+
h < 0 || (m[h] = { ...m[h], role: p }, t.set(c, m), (C = (I = s()) == null ? void 0 : I.onGroupMembersChanged) == null || C.call(I, { groupId: c, members: m }));
|
|
3066
3075
|
},
|
|
3067
3076
|
setGroupAnnouncement(c, l) {
|
|
3068
|
-
var
|
|
3069
|
-
n.set(c, l), (
|
|
3077
|
+
var p, m;
|
|
3078
|
+
n.set(c, l), (m = (p = s()) == null ? void 0 : p.onGroupAnnouncementChanged) == null || m.call(p, { groupId: c, announcement: l });
|
|
3070
3079
|
},
|
|
3071
3080
|
isGroupAdminSynced(c) {
|
|
3072
3081
|
return d.has(c);
|
|
@@ -3078,40 +3087,40 @@ function vn(s) {
|
|
|
3078
3087
|
o.set(c, l);
|
|
3079
3088
|
},
|
|
3080
3089
|
addGroupMuteMembers(c, l) {
|
|
3081
|
-
const
|
|
3082
|
-
for (const h of
|
|
3083
|
-
|
|
3084
|
-
o.set(c,
|
|
3090
|
+
const p = o.get(c) ?? [], m = Array.isArray(l) && l.length > 0 && typeof l[0] == "string" ? l : l.map((h) => h.userId);
|
|
3091
|
+
for (const h of m)
|
|
3092
|
+
p.some((I) => I.userId === h) || p.push({ userId: h });
|
|
3093
|
+
o.set(c, p);
|
|
3085
3094
|
},
|
|
3086
3095
|
removeGroupMuteMembers(c, l) {
|
|
3087
|
-
const
|
|
3088
|
-
o.set(c, (o.get(c) ?? []).filter((
|
|
3096
|
+
const p = new Set(l);
|
|
3097
|
+
o.set(c, (o.get(c) ?? []).filter((m) => !p.has(m.userId)));
|
|
3089
3098
|
},
|
|
3090
3099
|
setGroupBlocklist(c, l) {
|
|
3091
3100
|
a.set(c, l);
|
|
3092
3101
|
},
|
|
3093
3102
|
addGroupBlocklistMembers(c, l) {
|
|
3094
|
-
const
|
|
3095
|
-
for (const
|
|
3096
|
-
|
|
3097
|
-
a.set(c,
|
|
3103
|
+
const p = a.get(c) ?? [];
|
|
3104
|
+
for (const m of l)
|
|
3105
|
+
p.some((h) => h.userId === m) || p.push({ userId: m });
|
|
3106
|
+
a.set(c, p);
|
|
3098
3107
|
},
|
|
3099
3108
|
removeGroupBlocklistMembers(c, l) {
|
|
3100
|
-
const
|
|
3101
|
-
a.set(c, (a.get(c) ?? []).filter((
|
|
3109
|
+
const p = new Set(l);
|
|
3110
|
+
a.set(c, (a.get(c) ?? []).filter((m) => !p.has(m.userId)));
|
|
3102
3111
|
},
|
|
3103
3112
|
setGroupAllowlist(c, l) {
|
|
3104
3113
|
r.set(c, l);
|
|
3105
3114
|
},
|
|
3106
3115
|
addGroupAllowlistMembers(c, l) {
|
|
3107
|
-
const
|
|
3108
|
-
for (const
|
|
3109
|
-
|
|
3110
|
-
r.set(c,
|
|
3116
|
+
const p = r.get(c) ?? [];
|
|
3117
|
+
for (const m of l)
|
|
3118
|
+
p.some((h) => h.userId === m) || p.push({ userId: m });
|
|
3119
|
+
r.set(c, p);
|
|
3111
3120
|
},
|
|
3112
3121
|
removeGroupAllowlistMembers(c, l) {
|
|
3113
|
-
const
|
|
3114
|
-
r.set(c, (r.get(c) ?? []).filter((
|
|
3122
|
+
const p = new Set(l);
|
|
3123
|
+
r.set(c, (r.get(c) ?? []).filter((m) => !p.has(m.userId)));
|
|
3115
3124
|
},
|
|
3116
3125
|
setGroupList(c) {
|
|
3117
3126
|
this.setList(c);
|
|
@@ -3120,19 +3129,19 @@ function vn(s) {
|
|
|
3120
3129
|
return e.find((l) => l.groupId === c);
|
|
3121
3130
|
},
|
|
3122
3131
|
incrementMemberCount(c, l) {
|
|
3123
|
-
const
|
|
3124
|
-
|
|
3132
|
+
const p = this.getGroupById(c);
|
|
3133
|
+
p && this.updateGroup(c, { memberCount: (p.memberCount ?? 0) + l });
|
|
3125
3134
|
},
|
|
3126
3135
|
decrementMemberCount(c, l) {
|
|
3127
|
-
const
|
|
3128
|
-
|
|
3136
|
+
const p = this.getGroupById(c);
|
|
3137
|
+
p && this.updateGroup(c, { memberCount: Math.max(0, (p.memberCount ?? 0) - l) });
|
|
3129
3138
|
},
|
|
3130
3139
|
addGroupSharedFile(c, l) {
|
|
3131
|
-
const
|
|
3132
|
-
|
|
3140
|
+
const p = i.get(c) ?? [];
|
|
3141
|
+
p.push(l), i.set(c, p);
|
|
3133
3142
|
},
|
|
3134
3143
|
removeGroupSharedFile(c, l) {
|
|
3135
|
-
i.set(c, (i.get(c) ?? []).filter((
|
|
3144
|
+
i.set(c, (i.get(c) ?? []).filter((p) => p.fileId !== l));
|
|
3136
3145
|
},
|
|
3137
3146
|
getGroupJoinRequests(c) {
|
|
3138
3147
|
return u.get(c) ?? [];
|
|
@@ -3140,18 +3149,18 @@ function vn(s) {
|
|
|
3140
3149
|
setGroupJoinRequests(c, l) {
|
|
3141
3150
|
u.set(c, l);
|
|
3142
3151
|
},
|
|
3143
|
-
updateGroupJoinRequest(c, l,
|
|
3152
|
+
updateGroupJoinRequest(c, l, p) {
|
|
3144
3153
|
const h = (u.get(c) ?? []).find(
|
|
3145
3154
|
(I) => {
|
|
3146
|
-
var
|
|
3147
|
-
return I.applicantId === l || ((
|
|
3155
|
+
var C;
|
|
3156
|
+
return I.applicantId === l || ((C = I.applicant) == null ? void 0 : C.userId) === l;
|
|
3148
3157
|
}
|
|
3149
3158
|
);
|
|
3150
|
-
h && (h.status =
|
|
3159
|
+
h && (h.status = p);
|
|
3151
3160
|
}
|
|
3152
3161
|
};
|
|
3153
3162
|
}
|
|
3154
|
-
function
|
|
3163
|
+
function Sn(s) {
|
|
3155
3164
|
let e = [];
|
|
3156
3165
|
const t = /* @__PURE__ */ new Set();
|
|
3157
3166
|
return {
|
|
@@ -3168,7 +3177,7 @@ function In(s) {
|
|
|
3168
3177
|
}
|
|
3169
3178
|
};
|
|
3170
3179
|
}
|
|
3171
|
-
function
|
|
3180
|
+
function Gn(s) {
|
|
3172
3181
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
|
|
3173
3182
|
let a = !1;
|
|
3174
3183
|
const r = /* @__PURE__ */ new Map();
|
|
@@ -3244,7 +3253,7 @@ function Mn(s) {
|
|
|
3244
3253
|
}
|
|
3245
3254
|
};
|
|
3246
3255
|
}
|
|
3247
|
-
class
|
|
3256
|
+
class Fn {
|
|
3248
3257
|
constructor(e) {
|
|
3249
3258
|
this.injectedClient = e, this.capabilities = {
|
|
3250
3259
|
combineMessage: !0,
|
|
@@ -3252,7 +3261,7 @@ class _n {
|
|
|
3252
3261
|
streamingMessage: !0,
|
|
3253
3262
|
groupReadReceipt: !0,
|
|
3254
3263
|
// 本 adapter 遵循的契约版本(协商机制见 contract capabilities.ts)
|
|
3255
|
-
contractVersion:
|
|
3264
|
+
contractVersion: vt
|
|
3256
3265
|
}, this._client = null, this._handlersSet = /* @__PURE__ */ new Set(), this._eventsRegistered = !1, this._registerImEvents = !0;
|
|
3257
3266
|
}
|
|
3258
3267
|
/** 原生 SDK 客户端实例(UIKitClient 包装,可选) */
|
|
@@ -3287,84 +3296,95 @@ class _n {
|
|
|
3287
3296
|
repositories: g,
|
|
3288
3297
|
persistence: f,
|
|
3289
3298
|
...c
|
|
3290
|
-
} = t, l = e.repositories ?? g,
|
|
3291
|
-
this._persistence =
|
|
3292
|
-
|
|
3299
|
+
} = t, l = e.repositories ?? g, p = e.persistence ?? f;
|
|
3300
|
+
this._persistence = p, this._loginTimeoutMs = e.loginTimeoutMs;
|
|
3301
|
+
const { appKey: m, appId: h, ...I } = c;
|
|
3302
|
+
let C;
|
|
3303
|
+
if (e.appKey)
|
|
3304
|
+
C = { appKey: e.appKey };
|
|
3305
|
+
else if (e.appId)
|
|
3306
|
+
C = { appId: e.appId };
|
|
3307
|
+
else if (this.injectedClient)
|
|
3308
|
+
C = { appKey: "" };
|
|
3309
|
+
else
|
|
3310
|
+
throw new Error("[Websdk5Adapter] 缺少应用身份:SdkConfig.appKey 与 SdkConfig.appId 必须提供其一");
|
|
3311
|
+
this._client = this.injectedClient ?? Et({
|
|
3293
3312
|
debug: e.debug,
|
|
3294
|
-
managers: c.managers ?? (d === "chatroom" ?
|
|
3295
|
-
...
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3313
|
+
managers: c.managers ?? (d === "chatroom" ? mn : fn),
|
|
3314
|
+
...I,
|
|
3315
|
+
...C
|
|
3316
|
+
}), r && Xe(r), this._features = n ?? hn(), this._registerImEvents = u !== !1;
|
|
3317
|
+
const v = a ? Object.keys(a) : [];
|
|
3318
|
+
if (L.info("[Websdk5Adapter] init 开始", {
|
|
3299
3319
|
mode: this.injectedClient ? "injected-client" : "builtin",
|
|
3300
3320
|
managerPreset: d ?? "im",
|
|
3301
3321
|
registerImEvents: this._registerImEvents,
|
|
3302
|
-
injectedStores:
|
|
3303
|
-
}),
|
|
3304
|
-
const
|
|
3305
|
-
|
|
3322
|
+
injectedStores: v
|
|
3323
|
+
}), v.length < 7) {
|
|
3324
|
+
const q = ["client", "message", "conversation", "contact", "group", "presence", "userInfo"];
|
|
3325
|
+
L.debug(
|
|
3306
3326
|
"[Websdk5Adapter] 以下 store 域未注入,回落 adapter 内置 store:",
|
|
3307
|
-
|
|
3327
|
+
q.filter((U) => !v.includes(U))
|
|
3308
3328
|
);
|
|
3309
3329
|
}
|
|
3310
|
-
const
|
|
3311
|
-
client:
|
|
3312
|
-
message:
|
|
3313
|
-
conversation:
|
|
3314
|
-
contact:
|
|
3315
|
-
group:
|
|
3316
|
-
presence:
|
|
3317
|
-
userInfo:
|
|
3330
|
+
const w = () => this._getFanout(), E = { ...{
|
|
3331
|
+
client: Mn(this, w),
|
|
3332
|
+
message: bn(w),
|
|
3333
|
+
conversation: Cn(w),
|
|
3334
|
+
contact: wn(w),
|
|
3335
|
+
group: yn(w),
|
|
3336
|
+
presence: Sn(w),
|
|
3337
|
+
userInfo: Gn(w)
|
|
3318
3338
|
}, ...a };
|
|
3319
|
-
this._stores =
|
|
3320
|
-
message: new
|
|
3339
|
+
this._stores = E, this._domains = {
|
|
3340
|
+
message: new Ft(this._client, E.message, {
|
|
3321
3341
|
messageRepository: l == null ? void 0 : l.message,
|
|
3322
|
-
persistence:
|
|
3342
|
+
persistence: p == null ? void 0 : p.message
|
|
3323
3343
|
}),
|
|
3324
|
-
conversation: new
|
|
3325
|
-
sendPendingReadReceipts: (
|
|
3326
|
-
var
|
|
3327
|
-
((
|
|
3344
|
+
conversation: new Vt(this._client, E.conversation, {
|
|
3345
|
+
sendPendingReadReceipts: (q, U) => {
|
|
3346
|
+
var z, Ue;
|
|
3347
|
+
((z = this._features) == null ? void 0 : z.enableReadReceipt) !== !1 && ((Ue = this._domains) == null || Ue.message.sendPendingReadReceipts(q, U));
|
|
3328
3348
|
},
|
|
3329
|
-
resolveSenderName: (
|
|
3330
|
-
var
|
|
3331
|
-
const
|
|
3332
|
-
return
|
|
3349
|
+
resolveSenderName: (q) => {
|
|
3350
|
+
var z;
|
|
3351
|
+
const U = E.contact.getContact(q);
|
|
3352
|
+
return U != null && U.remark || U != null && U.name ? U.remark || U.name : (z = E.userInfo.getUserInfo(q)) == null ? void 0 : z.nickname;
|
|
3333
3353
|
},
|
|
3334
3354
|
conversationRepository: l == null ? void 0 : l.conversation,
|
|
3335
|
-
persistence:
|
|
3355
|
+
persistence: p == null ? void 0 : p.conversation
|
|
3336
3356
|
}),
|
|
3337
|
-
contact: new
|
|
3357
|
+
contact: new Jt(this._client, E.contact, {
|
|
3338
3358
|
contactRepository: l == null ? void 0 : l.contact
|
|
3339
3359
|
}),
|
|
3340
|
-
group: new
|
|
3360
|
+
group: new Qt(this._client, E.group, {
|
|
3341
3361
|
groupRepository: l == null ? void 0 : l.group
|
|
3342
3362
|
}),
|
|
3343
|
-
presence: new
|
|
3363
|
+
presence: new zt(this._client, E.presence, {
|
|
3344
3364
|
presenceRepository: l == null ? void 0 : l.presence
|
|
3345
3365
|
})
|
|
3346
|
-
}, this._userInfoDomain = new
|
|
3366
|
+
}, this._userInfoDomain = new Yt(
|
|
3347
3367
|
this._client,
|
|
3348
|
-
|
|
3349
|
-
(l == null ? void 0 : l.userInfo) ??
|
|
3350
|
-
i ?? (() =>
|
|
3351
|
-
), this._userInfoDomain.listen(), this._setupEventHandlers(),
|
|
3368
|
+
E.userInfo,
|
|
3369
|
+
(l == null ? void 0 : l.userInfo) ?? vn(o) ?? {},
|
|
3370
|
+
i ?? (() => L.warn("[Websdk5Adapter] 用户资料订阅无权限,已自动熔断"))
|
|
3371
|
+
), this._userInfoDomain.listen(), this._setupEventHandlers(), L.info("[Websdk5Adapter] init 完成");
|
|
3352
3372
|
}
|
|
3353
3373
|
async login(e, t) {
|
|
3354
3374
|
var n, o, a, r, i, u, d;
|
|
3355
3375
|
if (!this._client)
|
|
3356
3376
|
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3357
|
-
this._eventsRegistered || (
|
|
3377
|
+
this._eventsRegistered || (L.debug("[Websdk5Adapter] 登出后重新登录,恢复事件处理器与用户资料监听"), (n = this._userInfoDomain) == null || n.listen(), this._setupEventHandlers()), L.info("[Websdk5Adapter] login 开始", { user: e }), (r = (o = this._stores) == null ? void 0 : (a = o.client).setCurrentUser) == null || r.call(a, e);
|
|
3358
3378
|
try {
|
|
3359
|
-
await this._client.login(e, t);
|
|
3379
|
+
await this._client.login(e, t, this._loginTimeoutMs);
|
|
3360
3380
|
} catch (g) {
|
|
3361
|
-
throw (d = (i = this._stores) == null ? void 0 : (u = i.client).setCurrentUser) == null || d.call(u, ""),
|
|
3381
|
+
throw (d = (i = this._stores) == null ? void 0 : (u = i.client).setCurrentUser) == null || d.call(u, ""), L.error("[Websdk5Adapter] login 失败:", R(g)), g;
|
|
3362
3382
|
}
|
|
3363
|
-
|
|
3383
|
+
L.info("[Websdk5Adapter] login 成功", { user: e });
|
|
3364
3384
|
}
|
|
3365
3385
|
async logout() {
|
|
3366
3386
|
var e, t, n, o;
|
|
3367
|
-
|
|
3387
|
+
L.info("[Websdk5Adapter] logout"), await ((e = this._client) == null ? void 0 : e.logout()), (t = this._disposeEventHandlers) == null || t.call(this), this._disposeEventHandlers = void 0, (n = this._disposeSyncListener) == null || n.call(this), this._disposeSyncListener = void 0, (o = this._userInfoDomain) == null || o.dispose(), this._eventsRegistered = !1;
|
|
3368
3388
|
}
|
|
3369
3389
|
/** 订阅中立事件,返回取消订阅函数(支持多方订阅,内部扇出派发) */
|
|
3370
3390
|
subscribe(e) {
|
|
@@ -3391,13 +3411,13 @@ class _n {
|
|
|
3391
3411
|
var e, t;
|
|
3392
3412
|
if (!(!this._client || !this._stores)) {
|
|
3393
3413
|
if (!this._registerImEvents) {
|
|
3394
|
-
|
|
3414
|
+
L.debug("[Websdk5Adapter] IM 事件套件已关闭(registerImEvents=false),场景事件由业务经 onAdapterReady 自行注册");
|
|
3395
3415
|
return;
|
|
3396
3416
|
}
|
|
3397
|
-
|
|
3417
|
+
In(), (e = this._disposeSyncListener) == null || e.call(this), this._disposeSyncListener = Zt((n) => {
|
|
3398
3418
|
var o, a;
|
|
3399
3419
|
(a = (o = this._getFanout()).onSyncStatus) == null || a.call(o, n);
|
|
3400
|
-
}), (t = this._disposeEventHandlers) == null || t.call(this), this._disposeEventHandlers =
|
|
3420
|
+
}), (t = this._disposeEventHandlers) == null || t.call(this), this._disposeEventHandlers = pn(
|
|
3401
3421
|
this._client,
|
|
3402
3422
|
this._stores,
|
|
3403
3423
|
{
|
|
@@ -3412,7 +3432,7 @@ class _n {
|
|
|
3412
3432
|
},
|
|
3413
3433
|
this._features,
|
|
3414
3434
|
this._persistence
|
|
3415
|
-
), this._eventsRegistered = !0,
|
|
3435
|
+
), this._eventsRegistered = !0, L.debug("[Websdk5Adapter] SDK 事件处理器已注册");
|
|
3416
3436
|
}
|
|
3417
3437
|
}
|
|
3418
3438
|
get message() {
|
|
@@ -3598,60 +3618,60 @@ class _n {
|
|
|
3598
3618
|
}
|
|
3599
3619
|
}
|
|
3600
3620
|
export {
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3621
|
+
Ne as ALL_USER_INFO_ATTRIBUTES,
|
|
3622
|
+
Jt as ContactDomain,
|
|
3623
|
+
Vt as ConversationDomain,
|
|
3624
|
+
Qt as GroupDomain,
|
|
3625
|
+
Ft as MessageDomain,
|
|
3626
|
+
zt as PresenceDomain,
|
|
3627
|
+
At as UIKitClient,
|
|
3628
|
+
Yt as UserInfoDomain,
|
|
3629
|
+
mn as WEBSDK5_CHATROOM_MANAGERS,
|
|
3630
|
+
fn as WEBSDK5_MANAGERS,
|
|
3631
|
+
Fn as Websdk5Adapter,
|
|
3632
|
+
cn as createChatHandlers,
|
|
3633
|
+
Et as createClient,
|
|
3634
|
+
Xt as createConnectionHandlers,
|
|
3635
|
+
un as createContactHandlers,
|
|
3636
|
+
dn as createGroupHandlers,
|
|
3637
|
+
gn as createPresenceHandlers,
|
|
3638
|
+
Te as defaultAdapterPreviewLabels,
|
|
3639
|
+
Ln as disableSdkLogCapture,
|
|
3640
|
+
Un as enableSdkLogCapture,
|
|
3641
|
+
Nn as extractLastMessageText,
|
|
3642
|
+
Dt as extractSdkErrorReason,
|
|
3643
|
+
Tt as extractSnippetText,
|
|
3644
|
+
R as formatSdkError,
|
|
3645
|
+
kn as isMessageInConversation,
|
|
3646
|
+
Dn as isSdkDebugEnabled,
|
|
3647
|
+
Ot as markReadReceiptSent,
|
|
3648
|
+
Kn as normalizeUserId,
|
|
3649
|
+
ke as notifyContactEvent,
|
|
3650
|
+
nn as notifyOnNewMessage,
|
|
3651
|
+
ze as parsePresenceStatus,
|
|
3652
|
+
pn as registerEventHandlers,
|
|
3653
|
+
sn as resetChatEventState,
|
|
3654
|
+
en as resetSyncStatus,
|
|
3655
|
+
xn as resolvePeerUserId,
|
|
3656
|
+
Lt as resolveSdkErrorCodeI18nKey,
|
|
3657
|
+
_t as resolveSdkErrorI18nKey,
|
|
3658
|
+
On as resolveSdkErrorMessage,
|
|
3659
|
+
Ze as resolveSenderDisplayName,
|
|
3660
|
+
tn as resolveUserDisplayName,
|
|
3661
|
+
Xe as setEventHandlerDeps,
|
|
3662
|
+
wt as setSdkDebugGuard,
|
|
3663
|
+
Tn as setSdkLogAppender,
|
|
3664
|
+
be as setSyncStatus,
|
|
3665
|
+
Zt as setSyncStatusListener,
|
|
3666
|
+
qt as toUiContact,
|
|
3667
|
+
Ge as toUiContacts,
|
|
3668
|
+
Bt as toUiConversation,
|
|
3669
|
+
le as toUiConversations,
|
|
3670
|
+
Qe as toUiGroup,
|
|
3671
|
+
$t as toUiGroupMember,
|
|
3672
|
+
X as toUiGroupMembers,
|
|
3673
|
+
ge as toUiGroups,
|
|
3674
|
+
O as toUiMessage,
|
|
3675
|
+
_n as toUiMessages,
|
|
3676
|
+
Pn as useSyncStatus
|
|
3657
3677
|
};
|