@onyx-p/imlib-web 1.5.3 → 1.5.5
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/index.esm.js +219 -141
- package/index.umd.js +220 -140
- package/package.json +1 -1
- package/types/index.d.ts +6 -0
- package/types/model/messages/otherMediaMessages.d.ts +12 -0
package/index.esm.js
CHANGED
@@ -18826,136 +18826,6 @@ const MessageTypes = {
|
|
18826
18826
|
TRANSFER: 0x10001030
|
18827
18827
|
};
|
18828
18828
|
|
18829
|
-
const STATUSMESSAGE_ALIVE_TIMEMS = 6000;
|
18830
|
-
function parse(orginalMsgs, callback) {
|
18831
|
-
const msgs = new Map();
|
18832
|
-
Object.keys(orginalMsgs).forEach(dialogId => {
|
18833
|
-
const arr = orginalMsgs[dialogId].dialogMessage?.filter(m => !m.sharingGroupFlag);
|
18834
|
-
if (arr?.length) {
|
18835
|
-
msgs.set(dialogId, arr);
|
18836
|
-
}
|
18837
|
-
});
|
18838
|
-
if (!msgs.size) {
|
18839
|
-
callback(true, new Map());
|
18840
|
-
return;
|
18841
|
-
}
|
18842
|
-
const remainDialogIds = new Set([...msgs.keys()]);
|
18843
|
-
DialogSecretKey$1.getDialogAesKeyListInBatches([...msgs.keys()], (remote, aesKeys) => {
|
18844
|
-
if (aesKeys.size) {
|
18845
|
-
const dialogIds = [...aesKeys.keys()];
|
18846
|
-
for (const k of dialogIds) {
|
18847
|
-
remainDialogIds.delete(k);
|
18848
|
-
}
|
18849
|
-
callback(!remainDialogIds.size, parseDialogsMessages(dialogIds, msgs, aesKeys));
|
18850
|
-
}
|
18851
|
-
if (remainDialogIds.size && remote) {
|
18852
|
-
callback(true, new Map());
|
18853
|
-
}
|
18854
|
-
});
|
18855
|
-
}
|
18856
|
-
const parseDialogsMessages = (dialogIdList, msgs, aesKeys) => {
|
18857
|
-
const retVal = new Map();
|
18858
|
-
dialogIdList.forEach(dialogId => {
|
18859
|
-
const arr = parseSingleDialogMessages(dialogId, msgs.get(dialogId), aesKeys.get(dialogId));
|
18860
|
-
if (arr.length) {
|
18861
|
-
retVal.set(dialogId, arr);
|
18862
|
-
}
|
18863
|
-
});
|
18864
|
-
return retVal;
|
18865
|
-
};
|
18866
|
-
const parseSingleDialogMessages = (dialogId, originalMessageList, aesKey) => {
|
18867
|
-
const conversation = splitFullDialog(dialogId);
|
18868
|
-
if (!conversation) {
|
18869
|
-
return [];
|
18870
|
-
}
|
18871
|
-
const recallMessageUIds = new Set();
|
18872
|
-
let contentList = [];
|
18873
|
-
originalMessageList.forEach(item => {
|
18874
|
-
const dialogMessage = item;
|
18875
|
-
let mediaConstructor = dialogMessage.mediaConstructor;
|
18876
|
-
let mediaAttributeJson = decodeMessageContent(dialogMessage, aesKey);
|
18877
|
-
if (!mediaAttributeJson) return;
|
18878
|
-
if (mediaConstructor === 0x60010012 || mediaConstructor === 0x60020021) {
|
18879
|
-
const {
|
18880
|
-
msgId,
|
18881
|
-
sendTime
|
18882
|
-
} = mediaAttributeJson;
|
18883
|
-
const recallContent = {
|
18884
|
-
msgId: msgId
|
18885
|
-
};
|
18886
|
-
mediaConstructor = MessageTypes.RECALL;
|
18887
|
-
mediaAttributeJson = recallContent;
|
18888
|
-
recallMessageUIds.add(msgId);
|
18889
|
-
}
|
18890
|
-
const messageInstance = decodeMessage(mediaConstructor, mediaAttributeJson);
|
18891
|
-
if (isDef(messageInstance)) {
|
18892
|
-
const receivedMessage = {
|
18893
|
-
...conversation,
|
18894
|
-
senderUserId: dialogMessage.srcId.toString(),
|
18895
|
-
messageDirection: dialogMessage.isOut ? MessageDirection.SEND : MessageDirection.RECEIVE,
|
18896
|
-
isCounted: messageInstance.isCounted,
|
18897
|
-
isMentioned: dialogMessage.atFlag,
|
18898
|
-
content: messageInstance.content,
|
18899
|
-
messageType: messageInstance.messageType,
|
18900
|
-
isOffLineMessage: false,
|
18901
|
-
isPersited: messageInstance.isPersited,
|
18902
|
-
messageId: Long.isLong(dialogMessage.localId) ? dialogMessage.localId.toString() : undefined,
|
18903
|
-
messageUId: dialogMessage.msgId.toString(),
|
18904
|
-
sentTime: dialogMessage.seqno.toString(),
|
18905
|
-
sentStatus: SentStatus.SENT,
|
18906
|
-
receivedTime: getServerTime$1().toString(),
|
18907
|
-
isStatusMessage: messageInstance.isStatusMessage,
|
18908
|
-
receivedStatus: ReceivedStatus.READ,
|
18909
|
-
disableNotification: false
|
18910
|
-
};
|
18911
|
-
if (receivedMessage.isStatusMessage && Long.fromNumber(getServerTime$1()).subtract(receivedMessage.sentTime).greaterThan(STATUSMESSAGE_ALIVE_TIMEMS)) {
|
18912
|
-
return;
|
18913
|
-
}
|
18914
|
-
contentList.push(receivedMessage);
|
18915
|
-
}
|
18916
|
-
});
|
18917
|
-
if (recallMessageUIds.size) {
|
18918
|
-
contentList = contentList.filter(e => !recallMessageUIds.has(e.messageUId));
|
18919
|
-
}
|
18920
|
-
return contentList;
|
18921
|
-
};
|
18922
|
-
const decodeMessageContent = (dialogMessage, aesKey) => {
|
18923
|
-
try {
|
18924
|
-
let mediaAttribute;
|
18925
|
-
if (dialogMessage.mediaAttribute?.length) {
|
18926
|
-
mediaAttribute = aes256Decrypt(dialogMessage.mediaAttribute, aesKey);
|
18927
|
-
} else {
|
18928
|
-
mediaAttribute = dialogMessage.msgPreContent ?? '';
|
18929
|
-
}
|
18930
|
-
let msgPostContent;
|
18931
|
-
if (dialogMessage.msgPostContent?.length) {
|
18932
|
-
msgPostContent = aes256Decrypt(dialogMessage.msgPostContent, aesKey);
|
18933
|
-
}
|
18934
|
-
if (dialogMessage.mediaConstructor === 0x60010012 || dialogMessage.mediaConstructor === 0x60020021) {
|
18935
|
-
mediaAttribute = transMsgIdNum64ToString(mediaAttribute);
|
18936
|
-
}
|
18937
|
-
let mediaAttributeJson = {};
|
18938
|
-
if (mediaAttribute?.length) {
|
18939
|
-
mediaAttributeJson = JSON.parse(mediaAttribute);
|
18940
|
-
}
|
18941
|
-
if (dialogMessage.mediaConstructor == MessageTypes.TEXT && msgPostContent) {
|
18942
|
-
mediaAttributeJson.content = msgPostContent;
|
18943
|
-
}
|
18944
|
-
return mediaAttributeJson;
|
18945
|
-
} catch (error) {
|
18946
|
-
logger.error('decode message content fail -> uid:', dialogMessage.msgId.toString());
|
18947
|
-
return null;
|
18948
|
-
}
|
18949
|
-
};
|
18950
|
-
const transMsgIdNum64ToString = jsonString => {
|
18951
|
-
const reg = /("msgId")\s*:\s*(\d+)/g;
|
18952
|
-
return jsonString.replace(reg, (r1, r2, r3) => `${r2}:"${r3}"`);
|
18953
|
-
};
|
18954
|
-
var ServerMessageParser = {
|
18955
|
-
parse,
|
18956
|
-
parseSingleDialogMessages
|
18957
|
-
};
|
18958
|
-
|
18959
18829
|
function deepClone(obj) {
|
18960
18830
|
if (!isDef(obj)) {
|
18961
18831
|
return obj;
|
@@ -19564,6 +19434,31 @@ class ConversationManager {
|
|
19564
19434
|
});
|
19565
19435
|
return totalUnreadCount;
|
19566
19436
|
}
|
19437
|
+
getConversationState(conOpt) {
|
19438
|
+
let val = this.get(conOpt);
|
19439
|
+
if (val) {
|
19440
|
+
let {
|
19441
|
+
unreadMessageCount,
|
19442
|
+
unreadMentionedCount,
|
19443
|
+
notificationLevel,
|
19444
|
+
notificationStatus,
|
19445
|
+
isTop,
|
19446
|
+
dialogTitle,
|
19447
|
+
smallAvatarUrl
|
19448
|
+
} = val;
|
19449
|
+
return {
|
19450
|
+
...conOpt,
|
19451
|
+
unreadCount: unreadMessageCount,
|
19452
|
+
unreadMentionedCount: unreadMentionedCount ?? 0,
|
19453
|
+
notificationLevel,
|
19454
|
+
notificationStatus,
|
19455
|
+
isTop,
|
19456
|
+
dialogTitle,
|
19457
|
+
smallAvatarUrl
|
19458
|
+
};
|
19459
|
+
}
|
19460
|
+
return null;
|
19461
|
+
}
|
19567
19462
|
getAllConversationState() {
|
19568
19463
|
const localConversations = this.store.getAll();
|
19569
19464
|
return localConversations.map(({
|
@@ -19629,6 +19524,9 @@ const nullConversationManager = {
|
|
19629
19524
|
getAllUnreadMentionedCount: function () {
|
19630
19525
|
return 0;
|
19631
19526
|
},
|
19527
|
+
getConversationState(conOpt) {
|
19528
|
+
return null;
|
19529
|
+
},
|
19632
19530
|
getAllConversationState: function () {
|
19633
19531
|
return [];
|
19634
19532
|
},
|
@@ -19649,6 +19547,172 @@ var ConversationManager$1 = {
|
|
19649
19547
|
}
|
19650
19548
|
};
|
19651
19549
|
|
19550
|
+
const STATUSMESSAGE_ALIVE_TIMEMS = 6000;
|
19551
|
+
function parse(orginalMsgs, callback) {
|
19552
|
+
const msgs = new Map();
|
19553
|
+
Object.keys(orginalMsgs).forEach(dialogId => {
|
19554
|
+
const arr = orginalMsgs[dialogId].dialogMessage?.filter(m => !m.sharingGroupFlag);
|
19555
|
+
if (arr?.length) {
|
19556
|
+
msgs.set(dialogId, arr);
|
19557
|
+
}
|
19558
|
+
});
|
19559
|
+
if (!msgs.size) {
|
19560
|
+
callback(true, new Map());
|
19561
|
+
return;
|
19562
|
+
}
|
19563
|
+
const remainDialogIds = new Set([...msgs.keys()]);
|
19564
|
+
DialogSecretKey$1.getDialogAesKeyListInBatches([...msgs.keys()], (remote, aesKeys) => {
|
19565
|
+
if (aesKeys.size) {
|
19566
|
+
const dialogIds = [...aesKeys.keys()];
|
19567
|
+
for (const k of dialogIds) {
|
19568
|
+
remainDialogIds.delete(k);
|
19569
|
+
}
|
19570
|
+
callback(!remainDialogIds.size, parseDialogsMessages(dialogIds, msgs, aesKeys));
|
19571
|
+
}
|
19572
|
+
if (remainDialogIds.size && remote) {
|
19573
|
+
callback(true, new Map());
|
19574
|
+
}
|
19575
|
+
});
|
19576
|
+
}
|
19577
|
+
const parseDialogsMessages = (dialogIdList, msgs, aesKeys) => {
|
19578
|
+
const retVal = new Map();
|
19579
|
+
dialogIdList.forEach(dialogId => {
|
19580
|
+
const arr = parseSingleDialogMessages(dialogId, msgs.get(dialogId), aesKeys.get(dialogId));
|
19581
|
+
if (arr.length) {
|
19582
|
+
retVal.set(dialogId, arr);
|
19583
|
+
}
|
19584
|
+
});
|
19585
|
+
return retVal;
|
19586
|
+
};
|
19587
|
+
const parseSingleDialogMessages = (dialogId, originalMessageList, aesKey) => {
|
19588
|
+
const conversation = splitFullDialog(dialogId);
|
19589
|
+
if (!conversation) {
|
19590
|
+
return [];
|
19591
|
+
}
|
19592
|
+
const localConversation = ConversationManager$1.get().get(conversation);
|
19593
|
+
const recallMessageUIds = new Set();
|
19594
|
+
let contentList = [];
|
19595
|
+
originalMessageList.forEach(item => {
|
19596
|
+
const dialogMessage = item;
|
19597
|
+
let mediaConstructor = dialogMessage.mediaConstructor;
|
19598
|
+
let mediaAttributeJson = decodeMessageContent(dialogMessage, aesKey);
|
19599
|
+
if (!mediaAttributeJson) return;
|
19600
|
+
if (mediaConstructor === 0x60010012 || mediaConstructor === 0x60020021) {
|
19601
|
+
const {
|
19602
|
+
msgId,
|
19603
|
+
sendTime
|
19604
|
+
} = mediaAttributeJson;
|
19605
|
+
const recallContent = {
|
19606
|
+
msgId: msgId
|
19607
|
+
};
|
19608
|
+
mediaConstructor = MessageTypes.RECALL;
|
19609
|
+
mediaAttributeJson = recallContent;
|
19610
|
+
recallMessageUIds.add(msgId);
|
19611
|
+
}
|
19612
|
+
const messageInstance = decodeMessage(mediaConstructor, mediaAttributeJson);
|
19613
|
+
if (isDef(messageInstance)) {
|
19614
|
+
const receivedMessage = {
|
19615
|
+
...conversation,
|
19616
|
+
senderUserId: dialogMessage.srcId.toString(),
|
19617
|
+
messageDirection: dialogMessage.isOut ? MessageDirection.SEND : MessageDirection.RECEIVE,
|
19618
|
+
isCounted: messageInstance.isCounted,
|
19619
|
+
isMentioned: dialogMessage.atFlag,
|
19620
|
+
content: messageInstance.content,
|
19621
|
+
messageType: messageInstance.messageType,
|
19622
|
+
isOffLineMessage: false,
|
19623
|
+
isPersited: messageInstance.isPersited,
|
19624
|
+
messageId: Long.isLong(dialogMessage.localId) ? dialogMessage.localId.toString() : undefined,
|
19625
|
+
messageUId: dialogMessage.msgId.toString(),
|
19626
|
+
sentTime: dialogMessage.seqno.toString(),
|
19627
|
+
sentStatus: SentStatus.SENT,
|
19628
|
+
receivedTime: getServerTime$1().toString(),
|
19629
|
+
isStatusMessage: messageInstance.isStatusMessage,
|
19630
|
+
receivedStatus: ReceivedStatus.READ,
|
19631
|
+
disableNotification: localConversation?.notificationStatus === NotificationStatus.OPEN || dialogMessage.srcId.toString() == accountStore.uid
|
19632
|
+
};
|
19633
|
+
if (receivedMessage.isStatusMessage && Long.fromNumber(getServerTime$1()).subtract(receivedMessage.sentTime).greaterThan(STATUSMESSAGE_ALIVE_TIMEMS)) {
|
19634
|
+
return;
|
19635
|
+
}
|
19636
|
+
contentList.push(receivedMessage);
|
19637
|
+
}
|
19638
|
+
});
|
19639
|
+
if (recallMessageUIds.size) {
|
19640
|
+
contentList = contentList.filter(e => !recallMessageUIds.has(e.messageUId));
|
19641
|
+
}
|
19642
|
+
return contentList;
|
19643
|
+
};
|
19644
|
+
const decodeMessageContent = (dialogMessage, aesKey) => {
|
19645
|
+
try {
|
19646
|
+
let mediaAttribute;
|
19647
|
+
if (dialogMessage.mediaAttribute?.length) {
|
19648
|
+
mediaAttribute = aes256Decrypt(dialogMessage.mediaAttribute, aesKey);
|
19649
|
+
} else {
|
19650
|
+
mediaAttribute = dialogMessage.msgPreContent ?? '';
|
19651
|
+
}
|
19652
|
+
let msgPostContent;
|
19653
|
+
if (dialogMessage.msgPostContent?.length) {
|
19654
|
+
msgPostContent = aes256Decrypt(dialogMessage.msgPostContent, aesKey);
|
19655
|
+
}
|
19656
|
+
if (dialogMessage.mediaConstructor === 0x60010012 || dialogMessage.mediaConstructor === 0x60020021) {
|
19657
|
+
mediaAttribute = transMsgIdNum64ToString(mediaAttribute);
|
19658
|
+
}
|
19659
|
+
return parseMediaAttributeJson(dialogMessage.mediaConstructor, mediaAttribute, msgPostContent);
|
19660
|
+
} catch (error) {
|
19661
|
+
logger.error('decode message content fail -> uid:', dialogMessage.msgId.toString());
|
19662
|
+
return null;
|
19663
|
+
}
|
19664
|
+
};
|
19665
|
+
const parseMediaAttributeJson = (mediaConstructor, mediaAttribute, msgPostContent) => {
|
19666
|
+
let mediaAttributeJson = {};
|
19667
|
+
if (mediaAttribute?.length) {
|
19668
|
+
mediaAttributeJson = JSON.parse(mediaAttribute);
|
19669
|
+
}
|
19670
|
+
if (mediaConstructor == MessageTypes.TEXT && msgPostContent) {
|
19671
|
+
mediaAttributeJson.content = msgPostContent;
|
19672
|
+
}
|
19673
|
+
return mediaAttributeJson;
|
19674
|
+
};
|
19675
|
+
const parseChatRecordMsgDetails$1 = (conversationOpt, msgDetails) => {
|
19676
|
+
let contentList = [];
|
19677
|
+
msgDetails.forEach(item => {
|
19678
|
+
const mediaAttributeJson = parseMediaAttributeJson(item.mediaConstructor, item.mediaAttribute, item.msgPostContent);
|
19679
|
+
if (!mediaAttributeJson) return;
|
19680
|
+
const messageInstance = decodeMessage(item.mediaConstructor, mediaAttributeJson);
|
19681
|
+
if (isDef(messageInstance)) {
|
19682
|
+
const receivedMessage = {
|
19683
|
+
...conversationOpt,
|
19684
|
+
senderUserId: item.srcId.toString(),
|
19685
|
+
messageDirection: item.srcId == accountStore.uid ? MessageDirection.SEND : MessageDirection.RECEIVE,
|
19686
|
+
isCounted: messageInstance.isCounted,
|
19687
|
+
isMentioned: false,
|
19688
|
+
content: messageInstance.content,
|
19689
|
+
messageType: messageInstance.messageType,
|
19690
|
+
isOffLineMessage: false,
|
19691
|
+
isPersited: messageInstance.isPersited,
|
19692
|
+
messageId: item.msgId + '',
|
19693
|
+
messageUId: item.msgId + '',
|
19694
|
+
sentTime: item.msgSendTime + '',
|
19695
|
+
sentStatus: SentStatus.SENT,
|
19696
|
+
receivedTime: item.msgSendTime + '',
|
19697
|
+
isStatusMessage: messageInstance.isStatusMessage,
|
19698
|
+
receivedStatus: ReceivedStatus.READ,
|
19699
|
+
disableNotification: false
|
19700
|
+
};
|
19701
|
+
contentList.push(receivedMessage);
|
19702
|
+
}
|
19703
|
+
});
|
19704
|
+
return contentList;
|
19705
|
+
};
|
19706
|
+
const transMsgIdNum64ToString = jsonString => {
|
19707
|
+
const reg = /("msgId")\s*:\s*(\d+)/g;
|
19708
|
+
return jsonString.replace(reg, (r1, r2, r3) => `${r2}:"${r3}"`);
|
19709
|
+
};
|
19710
|
+
var serverMessageParser = {
|
19711
|
+
parse,
|
19712
|
+
parseSingleDialogMessages,
|
19713
|
+
parseChatRecordMsgDetails: parseChatRecordMsgDetails$1
|
19714
|
+
};
|
19715
|
+
|
19652
19716
|
class MessageLoader {
|
19653
19717
|
watcher;
|
19654
19718
|
pullingMsg = false;
|
@@ -19741,9 +19805,8 @@ class MessageLoader {
|
|
19741
19805
|
};
|
19742
19806
|
});
|
19743
19807
|
await ConversationManager$1.get().loadConvsationsIfNotExist(cons);
|
19744
|
-
|
19808
|
+
serverMessageParser.parse(msg, (done, outputMsgs) => {
|
19745
19809
|
const messages = [];
|
19746
|
-
const conversations = [];
|
19747
19810
|
const isOffLineMessage = !this.pullOfflineFinished;
|
19748
19811
|
outputMsgs.forEach((l, dialogId) => {
|
19749
19812
|
const messageList = [];
|
@@ -19760,16 +19823,12 @@ class MessageLoader {
|
|
19760
19823
|
});
|
19761
19824
|
messages.push(...messageList);
|
19762
19825
|
if (this.isExistPersistedMessage(messageList)) {
|
19763
|
-
|
19764
|
-
conOpt && conversations.push(conOpt);
|
19826
|
+
splitFullDialog(dialogId);
|
19765
19827
|
}
|
19766
19828
|
});
|
19767
19829
|
if (messages.length) {
|
19768
19830
|
this.watcher.batchMessage?.(messages);
|
19769
19831
|
}
|
19770
|
-
if (conversations.length) {
|
19771
|
-
ConversationManager$1.get().loadConvsationsIfNotExist(conversations);
|
19772
|
-
}
|
19773
19832
|
if (done) {
|
19774
19833
|
if (seqno.ge(this.serverMsgSeqno)) {
|
19775
19834
|
this.serverMsgSeqno = seqno;
|
@@ -26607,7 +26666,7 @@ const transSentAttrs2IReceivedMessage = (message, options, sentStatus = SentStat
|
|
26607
26666
|
receivedTime: '0',
|
26608
26667
|
isStatusMessage: message.isStatusMessage,
|
26609
26668
|
receivedStatus: ReceivedStatus.UNREAD,
|
26610
|
-
disableNotification:
|
26669
|
+
disableNotification: true
|
26611
26670
|
});
|
26612
26671
|
|
26613
26672
|
let UniqueLocalId = 0;
|
@@ -27379,7 +27438,7 @@ class IMClient extends EventEmitter {
|
|
27379
27438
|
});
|
27380
27439
|
return;
|
27381
27440
|
}
|
27382
|
-
|
27441
|
+
serverMessageParser.parse({
|
27383
27442
|
[dialogId]: data.msg ?? {}
|
27384
27443
|
}, (_, outputMsgs) => {
|
27385
27444
|
const messageList = outputMsgs.get(dialogId) ?? [];
|
@@ -27493,6 +27552,9 @@ class IMClient extends EventEmitter {
|
|
27493
27552
|
const totalUnreadCount = ConversationManager$1.get().getAllUnreadMentionedCount();
|
27494
27553
|
return totalUnreadCount;
|
27495
27554
|
}
|
27555
|
+
getConversationState(conOpt) {
|
27556
|
+
return ConversationManager$1.get().getConversationState(conOpt);
|
27557
|
+
}
|
27496
27558
|
getAllConversationState() {
|
27497
27559
|
return ConversationManager$1.get().getAllConversationState();
|
27498
27560
|
}
|
@@ -27564,7 +27626,7 @@ class IMClient extends EventEmitter {
|
|
27564
27626
|
return;
|
27565
27627
|
}
|
27566
27628
|
if (isDef(msg)) {
|
27567
|
-
const latestMessage =
|
27629
|
+
const latestMessage = serverMessageParser.parseSingleDialogMessages(dialogId.toString(), [msg], aesKey)[0];
|
27568
27630
|
conversationObj.latestMessage = latestMessage;
|
27569
27631
|
}
|
27570
27632
|
return conversationObj;
|
@@ -28547,6 +28609,19 @@ const getAllUnreadMentionedCount = () => {
|
|
28547
28609
|
data: count
|
28548
28610
|
});
|
28549
28611
|
};
|
28612
|
+
const getConversationState = options => {
|
28613
|
+
logger.debug('getConversationState');
|
28614
|
+
const state = imClient.getConversationState(options);
|
28615
|
+
if (state) {
|
28616
|
+
return Promise.resolve({
|
28617
|
+
code: ErrorCode.SUCCESS,
|
28618
|
+
data: state
|
28619
|
+
});
|
28620
|
+
}
|
28621
|
+
return Promise.resolve({
|
28622
|
+
code: ErrorCode.UNKNOWN
|
28623
|
+
});
|
28624
|
+
};
|
28550
28625
|
const getAllConversationState = () => {
|
28551
28626
|
logger.debug('getAllConversationState');
|
28552
28627
|
const states = imClient.getAllConversationState();
|
@@ -28816,6 +28891,9 @@ const clearHistoryMessages = async (conversation, timestamp) => {
|
|
28816
28891
|
code: ErrorCode.SUCCESS
|
28817
28892
|
};
|
28818
28893
|
};
|
28894
|
+
const parseChatRecordMsgDetails = (conversation, detailItems) => {
|
28895
|
+
return serverMessageParser.parseChatRecordMsgDetails(conversation, detailItems);
|
28896
|
+
};
|
28819
28897
|
const mockLogin = config => {
|
28820
28898
|
return login(config);
|
28821
28899
|
};
|
@@ -28830,4 +28908,4 @@ const _logSendError = (conversation, errorCode) => {
|
|
28830
28908
|
}
|
28831
28909
|
};
|
28832
28910
|
|
28833
|
-
export { ConnectionStatus, ConversationType, ErrorCode, ErrorDesc, Events, FileMessage, GIFMessage, VoiceMessage as HQVoiceMessage, ImageMessage, LogLevel, MentionedType, MessageDirection, MessageTypes, NotificationLevel, NotificationStatus, ReceivedStatus, SentStatus, TextMessage, VideoMessage, addEventListener, clearAllMessagesUnreadStatus, clearHistoryMessages, clearMessagesUnreadStatus, clearTextMessageDraft, connect, deleteMessages, disconnect, getAllConversationState, getAllUnreadMentionedCount, getBlockedConversationList, getConnectionStatus, getConversation, getConversationList, getConversationNotificationLevel, getConversationNotificationStatus, getHistoryMessages, getRemoteHistoryMessages, getServerTime, getTextMessageDraft, getTopConversationList, getTotalUnreadCount, getUnreadCount, getUnreadMentionedCount, init, logOut, mockLogin, onceEventListener, recallMessage, registerMessageType, removeConversation, removeEventListener, request, saveTextMessageDraft, sendFileMessage, sendGIFMessage, sendHQVoiceMessage, sendImageMessage, sendMessage, sendSightMessage, sendTextMessage, setConversationNotificationStatus, setConversationToTop, setUserLogged };
|
28911
|
+
export { ConnectionStatus, ConversationType, ErrorCode, ErrorDesc, Events, FileMessage, GIFMessage, VoiceMessage as HQVoiceMessage, ImageMessage, LogLevel, MentionedType, MessageDirection, MessageTypes, NotificationLevel, NotificationStatus, ReceivedStatus, SentStatus, TextMessage, VideoMessage, addEventListener, clearAllMessagesUnreadStatus, clearHistoryMessages, clearMessagesUnreadStatus, clearTextMessageDraft, connect, deleteMessages, disconnect, getAllConversationState, getAllUnreadMentionedCount, getBlockedConversationList, getConnectionStatus, getConversation, getConversationList, getConversationNotificationLevel, getConversationNotificationStatus, getConversationState, getHistoryMessages, getRemoteHistoryMessages, getServerTime, getTextMessageDraft, getTopConversationList, getTotalUnreadCount, getUnreadCount, getUnreadMentionedCount, init, logOut, mockLogin, onceEventListener, parseChatRecordMsgDetails, recallMessage, registerMessageType, removeConversation, removeEventListener, request, saveTextMessageDraft, sendFileMessage, sendGIFMessage, sendHQVoiceMessage, sendImageMessage, sendMessage, sendSightMessage, sendTextMessage, setConversationNotificationStatus, setConversationToTop, setUserLogged };
|
package/index.umd.js
CHANGED
@@ -18832,136 +18832,6 @@
|
|
18832
18832
|
TRANSFER: 0x10001030
|
18833
18833
|
};
|
18834
18834
|
|
18835
|
-
const STATUSMESSAGE_ALIVE_TIMEMS = 6000;
|
18836
|
-
function parse(orginalMsgs, callback) {
|
18837
|
-
const msgs = new Map();
|
18838
|
-
Object.keys(orginalMsgs).forEach(dialogId => {
|
18839
|
-
const arr = orginalMsgs[dialogId].dialogMessage?.filter(m => !m.sharingGroupFlag);
|
18840
|
-
if (arr?.length) {
|
18841
|
-
msgs.set(dialogId, arr);
|
18842
|
-
}
|
18843
|
-
});
|
18844
|
-
if (!msgs.size) {
|
18845
|
-
callback(true, new Map());
|
18846
|
-
return;
|
18847
|
-
}
|
18848
|
-
const remainDialogIds = new Set([...msgs.keys()]);
|
18849
|
-
DialogSecretKey$1.getDialogAesKeyListInBatches([...msgs.keys()], (remote, aesKeys) => {
|
18850
|
-
if (aesKeys.size) {
|
18851
|
-
const dialogIds = [...aesKeys.keys()];
|
18852
|
-
for (const k of dialogIds) {
|
18853
|
-
remainDialogIds.delete(k);
|
18854
|
-
}
|
18855
|
-
callback(!remainDialogIds.size, parseDialogsMessages(dialogIds, msgs, aesKeys));
|
18856
|
-
}
|
18857
|
-
if (remainDialogIds.size && remote) {
|
18858
|
-
callback(true, new Map());
|
18859
|
-
}
|
18860
|
-
});
|
18861
|
-
}
|
18862
|
-
const parseDialogsMessages = (dialogIdList, msgs, aesKeys) => {
|
18863
|
-
const retVal = new Map();
|
18864
|
-
dialogIdList.forEach(dialogId => {
|
18865
|
-
const arr = parseSingleDialogMessages(dialogId, msgs.get(dialogId), aesKeys.get(dialogId));
|
18866
|
-
if (arr.length) {
|
18867
|
-
retVal.set(dialogId, arr);
|
18868
|
-
}
|
18869
|
-
});
|
18870
|
-
return retVal;
|
18871
|
-
};
|
18872
|
-
const parseSingleDialogMessages = (dialogId, originalMessageList, aesKey) => {
|
18873
|
-
const conversation = splitFullDialog(dialogId);
|
18874
|
-
if (!conversation) {
|
18875
|
-
return [];
|
18876
|
-
}
|
18877
|
-
const recallMessageUIds = new Set();
|
18878
|
-
let contentList = [];
|
18879
|
-
originalMessageList.forEach(item => {
|
18880
|
-
const dialogMessage = item;
|
18881
|
-
let mediaConstructor = dialogMessage.mediaConstructor;
|
18882
|
-
let mediaAttributeJson = decodeMessageContent(dialogMessage, aesKey);
|
18883
|
-
if (!mediaAttributeJson) return;
|
18884
|
-
if (mediaConstructor === 0x60010012 || mediaConstructor === 0x60020021) {
|
18885
|
-
const {
|
18886
|
-
msgId,
|
18887
|
-
sendTime
|
18888
|
-
} = mediaAttributeJson;
|
18889
|
-
const recallContent = {
|
18890
|
-
msgId: msgId
|
18891
|
-
};
|
18892
|
-
mediaConstructor = MessageTypes.RECALL;
|
18893
|
-
mediaAttributeJson = recallContent;
|
18894
|
-
recallMessageUIds.add(msgId);
|
18895
|
-
}
|
18896
|
-
const messageInstance = decodeMessage(mediaConstructor, mediaAttributeJson);
|
18897
|
-
if (isDef(messageInstance)) {
|
18898
|
-
const receivedMessage = {
|
18899
|
-
...conversation,
|
18900
|
-
senderUserId: dialogMessage.srcId.toString(),
|
18901
|
-
messageDirection: dialogMessage.isOut ? exports.MessageDirection.SEND : exports.MessageDirection.RECEIVE,
|
18902
|
-
isCounted: messageInstance.isCounted,
|
18903
|
-
isMentioned: dialogMessage.atFlag,
|
18904
|
-
content: messageInstance.content,
|
18905
|
-
messageType: messageInstance.messageType,
|
18906
|
-
isOffLineMessage: false,
|
18907
|
-
isPersited: messageInstance.isPersited,
|
18908
|
-
messageId: Long.isLong(dialogMessage.localId) ? dialogMessage.localId.toString() : undefined,
|
18909
|
-
messageUId: dialogMessage.msgId.toString(),
|
18910
|
-
sentTime: dialogMessage.seqno.toString(),
|
18911
|
-
sentStatus: exports.SentStatus.SENT,
|
18912
|
-
receivedTime: getServerTime$1().toString(),
|
18913
|
-
isStatusMessage: messageInstance.isStatusMessage,
|
18914
|
-
receivedStatus: exports.ReceivedStatus.READ,
|
18915
|
-
disableNotification: false
|
18916
|
-
};
|
18917
|
-
if (receivedMessage.isStatusMessage && Long.fromNumber(getServerTime$1()).subtract(receivedMessage.sentTime).greaterThan(STATUSMESSAGE_ALIVE_TIMEMS)) {
|
18918
|
-
return;
|
18919
|
-
}
|
18920
|
-
contentList.push(receivedMessage);
|
18921
|
-
}
|
18922
|
-
});
|
18923
|
-
if (recallMessageUIds.size) {
|
18924
|
-
contentList = contentList.filter(e => !recallMessageUIds.has(e.messageUId));
|
18925
|
-
}
|
18926
|
-
return contentList;
|
18927
|
-
};
|
18928
|
-
const decodeMessageContent = (dialogMessage, aesKey) => {
|
18929
|
-
try {
|
18930
|
-
let mediaAttribute;
|
18931
|
-
if (dialogMessage.mediaAttribute?.length) {
|
18932
|
-
mediaAttribute = aes256Decrypt(dialogMessage.mediaAttribute, aesKey);
|
18933
|
-
} else {
|
18934
|
-
mediaAttribute = dialogMessage.msgPreContent ?? '';
|
18935
|
-
}
|
18936
|
-
let msgPostContent;
|
18937
|
-
if (dialogMessage.msgPostContent?.length) {
|
18938
|
-
msgPostContent = aes256Decrypt(dialogMessage.msgPostContent, aesKey);
|
18939
|
-
}
|
18940
|
-
if (dialogMessage.mediaConstructor === 0x60010012 || dialogMessage.mediaConstructor === 0x60020021) {
|
18941
|
-
mediaAttribute = transMsgIdNum64ToString(mediaAttribute);
|
18942
|
-
}
|
18943
|
-
let mediaAttributeJson = {};
|
18944
|
-
if (mediaAttribute?.length) {
|
18945
|
-
mediaAttributeJson = JSON.parse(mediaAttribute);
|
18946
|
-
}
|
18947
|
-
if (dialogMessage.mediaConstructor == MessageTypes.TEXT && msgPostContent) {
|
18948
|
-
mediaAttributeJson.content = msgPostContent;
|
18949
|
-
}
|
18950
|
-
return mediaAttributeJson;
|
18951
|
-
} catch (error) {
|
18952
|
-
logger.error('decode message content fail -> uid:', dialogMessage.msgId.toString());
|
18953
|
-
return null;
|
18954
|
-
}
|
18955
|
-
};
|
18956
|
-
const transMsgIdNum64ToString = jsonString => {
|
18957
|
-
const reg = /("msgId")\s*:\s*(\d+)/g;
|
18958
|
-
return jsonString.replace(reg, (r1, r2, r3) => `${r2}:"${r3}"`);
|
18959
|
-
};
|
18960
|
-
var ServerMessageParser = {
|
18961
|
-
parse,
|
18962
|
-
parseSingleDialogMessages
|
18963
|
-
};
|
18964
|
-
|
18965
18835
|
function deepClone(obj) {
|
18966
18836
|
if (!isDef(obj)) {
|
18967
18837
|
return obj;
|
@@ -19570,6 +19440,31 @@
|
|
19570
19440
|
});
|
19571
19441
|
return totalUnreadCount;
|
19572
19442
|
}
|
19443
|
+
getConversationState(conOpt) {
|
19444
|
+
let val = this.get(conOpt);
|
19445
|
+
if (val) {
|
19446
|
+
let {
|
19447
|
+
unreadMessageCount,
|
19448
|
+
unreadMentionedCount,
|
19449
|
+
notificationLevel,
|
19450
|
+
notificationStatus,
|
19451
|
+
isTop,
|
19452
|
+
dialogTitle,
|
19453
|
+
smallAvatarUrl
|
19454
|
+
} = val;
|
19455
|
+
return {
|
19456
|
+
...conOpt,
|
19457
|
+
unreadCount: unreadMessageCount,
|
19458
|
+
unreadMentionedCount: unreadMentionedCount ?? 0,
|
19459
|
+
notificationLevel,
|
19460
|
+
notificationStatus,
|
19461
|
+
isTop,
|
19462
|
+
dialogTitle,
|
19463
|
+
smallAvatarUrl
|
19464
|
+
};
|
19465
|
+
}
|
19466
|
+
return null;
|
19467
|
+
}
|
19573
19468
|
getAllConversationState() {
|
19574
19469
|
const localConversations = this.store.getAll();
|
19575
19470
|
return localConversations.map(({
|
@@ -19635,6 +19530,9 @@
|
|
19635
19530
|
getAllUnreadMentionedCount: function () {
|
19636
19531
|
return 0;
|
19637
19532
|
},
|
19533
|
+
getConversationState(conOpt) {
|
19534
|
+
return null;
|
19535
|
+
},
|
19638
19536
|
getAllConversationState: function () {
|
19639
19537
|
return [];
|
19640
19538
|
},
|
@@ -19655,6 +19553,172 @@
|
|
19655
19553
|
}
|
19656
19554
|
};
|
19657
19555
|
|
19556
|
+
const STATUSMESSAGE_ALIVE_TIMEMS = 6000;
|
19557
|
+
function parse(orginalMsgs, callback) {
|
19558
|
+
const msgs = new Map();
|
19559
|
+
Object.keys(orginalMsgs).forEach(dialogId => {
|
19560
|
+
const arr = orginalMsgs[dialogId].dialogMessage?.filter(m => !m.sharingGroupFlag);
|
19561
|
+
if (arr?.length) {
|
19562
|
+
msgs.set(dialogId, arr);
|
19563
|
+
}
|
19564
|
+
});
|
19565
|
+
if (!msgs.size) {
|
19566
|
+
callback(true, new Map());
|
19567
|
+
return;
|
19568
|
+
}
|
19569
|
+
const remainDialogIds = new Set([...msgs.keys()]);
|
19570
|
+
DialogSecretKey$1.getDialogAesKeyListInBatches([...msgs.keys()], (remote, aesKeys) => {
|
19571
|
+
if (aesKeys.size) {
|
19572
|
+
const dialogIds = [...aesKeys.keys()];
|
19573
|
+
for (const k of dialogIds) {
|
19574
|
+
remainDialogIds.delete(k);
|
19575
|
+
}
|
19576
|
+
callback(!remainDialogIds.size, parseDialogsMessages(dialogIds, msgs, aesKeys));
|
19577
|
+
}
|
19578
|
+
if (remainDialogIds.size && remote) {
|
19579
|
+
callback(true, new Map());
|
19580
|
+
}
|
19581
|
+
});
|
19582
|
+
}
|
19583
|
+
const parseDialogsMessages = (dialogIdList, msgs, aesKeys) => {
|
19584
|
+
const retVal = new Map();
|
19585
|
+
dialogIdList.forEach(dialogId => {
|
19586
|
+
const arr = parseSingleDialogMessages(dialogId, msgs.get(dialogId), aesKeys.get(dialogId));
|
19587
|
+
if (arr.length) {
|
19588
|
+
retVal.set(dialogId, arr);
|
19589
|
+
}
|
19590
|
+
});
|
19591
|
+
return retVal;
|
19592
|
+
};
|
19593
|
+
const parseSingleDialogMessages = (dialogId, originalMessageList, aesKey) => {
|
19594
|
+
const conversation = splitFullDialog(dialogId);
|
19595
|
+
if (!conversation) {
|
19596
|
+
return [];
|
19597
|
+
}
|
19598
|
+
const localConversation = ConversationManager$1.get().get(conversation);
|
19599
|
+
const recallMessageUIds = new Set();
|
19600
|
+
let contentList = [];
|
19601
|
+
originalMessageList.forEach(item => {
|
19602
|
+
const dialogMessage = item;
|
19603
|
+
let mediaConstructor = dialogMessage.mediaConstructor;
|
19604
|
+
let mediaAttributeJson = decodeMessageContent(dialogMessage, aesKey);
|
19605
|
+
if (!mediaAttributeJson) return;
|
19606
|
+
if (mediaConstructor === 0x60010012 || mediaConstructor === 0x60020021) {
|
19607
|
+
const {
|
19608
|
+
msgId,
|
19609
|
+
sendTime
|
19610
|
+
} = mediaAttributeJson;
|
19611
|
+
const recallContent = {
|
19612
|
+
msgId: msgId
|
19613
|
+
};
|
19614
|
+
mediaConstructor = MessageTypes.RECALL;
|
19615
|
+
mediaAttributeJson = recallContent;
|
19616
|
+
recallMessageUIds.add(msgId);
|
19617
|
+
}
|
19618
|
+
const messageInstance = decodeMessage(mediaConstructor, mediaAttributeJson);
|
19619
|
+
if (isDef(messageInstance)) {
|
19620
|
+
const receivedMessage = {
|
19621
|
+
...conversation,
|
19622
|
+
senderUserId: dialogMessage.srcId.toString(),
|
19623
|
+
messageDirection: dialogMessage.isOut ? exports.MessageDirection.SEND : exports.MessageDirection.RECEIVE,
|
19624
|
+
isCounted: messageInstance.isCounted,
|
19625
|
+
isMentioned: dialogMessage.atFlag,
|
19626
|
+
content: messageInstance.content,
|
19627
|
+
messageType: messageInstance.messageType,
|
19628
|
+
isOffLineMessage: false,
|
19629
|
+
isPersited: messageInstance.isPersited,
|
19630
|
+
messageId: Long.isLong(dialogMessage.localId) ? dialogMessage.localId.toString() : undefined,
|
19631
|
+
messageUId: dialogMessage.msgId.toString(),
|
19632
|
+
sentTime: dialogMessage.seqno.toString(),
|
19633
|
+
sentStatus: exports.SentStatus.SENT,
|
19634
|
+
receivedTime: getServerTime$1().toString(),
|
19635
|
+
isStatusMessage: messageInstance.isStatusMessage,
|
19636
|
+
receivedStatus: exports.ReceivedStatus.READ,
|
19637
|
+
disableNotification: localConversation?.notificationStatus === exports.NotificationStatus.OPEN || dialogMessage.srcId.toString() == accountStore.uid
|
19638
|
+
};
|
19639
|
+
if (receivedMessage.isStatusMessage && Long.fromNumber(getServerTime$1()).subtract(receivedMessage.sentTime).greaterThan(STATUSMESSAGE_ALIVE_TIMEMS)) {
|
19640
|
+
return;
|
19641
|
+
}
|
19642
|
+
contentList.push(receivedMessage);
|
19643
|
+
}
|
19644
|
+
});
|
19645
|
+
if (recallMessageUIds.size) {
|
19646
|
+
contentList = contentList.filter(e => !recallMessageUIds.has(e.messageUId));
|
19647
|
+
}
|
19648
|
+
return contentList;
|
19649
|
+
};
|
19650
|
+
const decodeMessageContent = (dialogMessage, aesKey) => {
|
19651
|
+
try {
|
19652
|
+
let mediaAttribute;
|
19653
|
+
if (dialogMessage.mediaAttribute?.length) {
|
19654
|
+
mediaAttribute = aes256Decrypt(dialogMessage.mediaAttribute, aesKey);
|
19655
|
+
} else {
|
19656
|
+
mediaAttribute = dialogMessage.msgPreContent ?? '';
|
19657
|
+
}
|
19658
|
+
let msgPostContent;
|
19659
|
+
if (dialogMessage.msgPostContent?.length) {
|
19660
|
+
msgPostContent = aes256Decrypt(dialogMessage.msgPostContent, aesKey);
|
19661
|
+
}
|
19662
|
+
if (dialogMessage.mediaConstructor === 0x60010012 || dialogMessage.mediaConstructor === 0x60020021) {
|
19663
|
+
mediaAttribute = transMsgIdNum64ToString(mediaAttribute);
|
19664
|
+
}
|
19665
|
+
return parseMediaAttributeJson(dialogMessage.mediaConstructor, mediaAttribute, msgPostContent);
|
19666
|
+
} catch (error) {
|
19667
|
+
logger.error('decode message content fail -> uid:', dialogMessage.msgId.toString());
|
19668
|
+
return null;
|
19669
|
+
}
|
19670
|
+
};
|
19671
|
+
const parseMediaAttributeJson = (mediaConstructor, mediaAttribute, msgPostContent) => {
|
19672
|
+
let mediaAttributeJson = {};
|
19673
|
+
if (mediaAttribute?.length) {
|
19674
|
+
mediaAttributeJson = JSON.parse(mediaAttribute);
|
19675
|
+
}
|
19676
|
+
if (mediaConstructor == MessageTypes.TEXT && msgPostContent) {
|
19677
|
+
mediaAttributeJson.content = msgPostContent;
|
19678
|
+
}
|
19679
|
+
return mediaAttributeJson;
|
19680
|
+
};
|
19681
|
+
const parseChatRecordMsgDetails$1 = (conversationOpt, msgDetails) => {
|
19682
|
+
let contentList = [];
|
19683
|
+
msgDetails.forEach(item => {
|
19684
|
+
const mediaAttributeJson = parseMediaAttributeJson(item.mediaConstructor, item.mediaAttribute, item.msgPostContent);
|
19685
|
+
if (!mediaAttributeJson) return;
|
19686
|
+
const messageInstance = decodeMessage(item.mediaConstructor, mediaAttributeJson);
|
19687
|
+
if (isDef(messageInstance)) {
|
19688
|
+
const receivedMessage = {
|
19689
|
+
...conversationOpt,
|
19690
|
+
senderUserId: item.srcId.toString(),
|
19691
|
+
messageDirection: item.srcId == accountStore.uid ? exports.MessageDirection.SEND : exports.MessageDirection.RECEIVE,
|
19692
|
+
isCounted: messageInstance.isCounted,
|
19693
|
+
isMentioned: false,
|
19694
|
+
content: messageInstance.content,
|
19695
|
+
messageType: messageInstance.messageType,
|
19696
|
+
isOffLineMessage: false,
|
19697
|
+
isPersited: messageInstance.isPersited,
|
19698
|
+
messageId: item.msgId + '',
|
19699
|
+
messageUId: item.msgId + '',
|
19700
|
+
sentTime: item.msgSendTime + '',
|
19701
|
+
sentStatus: exports.SentStatus.SENT,
|
19702
|
+
receivedTime: item.msgSendTime + '',
|
19703
|
+
isStatusMessage: messageInstance.isStatusMessage,
|
19704
|
+
receivedStatus: exports.ReceivedStatus.READ,
|
19705
|
+
disableNotification: false
|
19706
|
+
};
|
19707
|
+
contentList.push(receivedMessage);
|
19708
|
+
}
|
19709
|
+
});
|
19710
|
+
return contentList;
|
19711
|
+
};
|
19712
|
+
const transMsgIdNum64ToString = jsonString => {
|
19713
|
+
const reg = /("msgId")\s*:\s*(\d+)/g;
|
19714
|
+
return jsonString.replace(reg, (r1, r2, r3) => `${r2}:"${r3}"`);
|
19715
|
+
};
|
19716
|
+
var serverMessageParser = {
|
19717
|
+
parse,
|
19718
|
+
parseSingleDialogMessages,
|
19719
|
+
parseChatRecordMsgDetails: parseChatRecordMsgDetails$1
|
19720
|
+
};
|
19721
|
+
|
19658
19722
|
class MessageLoader {
|
19659
19723
|
watcher;
|
19660
19724
|
pullingMsg = false;
|
@@ -19747,9 +19811,8 @@
|
|
19747
19811
|
};
|
19748
19812
|
});
|
19749
19813
|
await ConversationManager$1.get().loadConvsationsIfNotExist(cons);
|
19750
|
-
|
19814
|
+
serverMessageParser.parse(msg, (done, outputMsgs) => {
|
19751
19815
|
const messages = [];
|
19752
|
-
const conversations = [];
|
19753
19816
|
const isOffLineMessage = !this.pullOfflineFinished;
|
19754
19817
|
outputMsgs.forEach((l, dialogId) => {
|
19755
19818
|
const messageList = [];
|
@@ -19766,16 +19829,12 @@
|
|
19766
19829
|
});
|
19767
19830
|
messages.push(...messageList);
|
19768
19831
|
if (this.isExistPersistedMessage(messageList)) {
|
19769
|
-
|
19770
|
-
conOpt && conversations.push(conOpt);
|
19832
|
+
splitFullDialog(dialogId);
|
19771
19833
|
}
|
19772
19834
|
});
|
19773
19835
|
if (messages.length) {
|
19774
19836
|
this.watcher.batchMessage?.(messages);
|
19775
19837
|
}
|
19776
|
-
if (conversations.length) {
|
19777
|
-
ConversationManager$1.get().loadConvsationsIfNotExist(conversations);
|
19778
|
-
}
|
19779
19838
|
if (done) {
|
19780
19839
|
if (seqno.ge(this.serverMsgSeqno)) {
|
19781
19840
|
this.serverMsgSeqno = seqno;
|
@@ -26613,7 +26672,7 @@
|
|
26613
26672
|
receivedTime: '0',
|
26614
26673
|
isStatusMessage: message.isStatusMessage,
|
26615
26674
|
receivedStatus: exports.ReceivedStatus.UNREAD,
|
26616
|
-
disableNotification:
|
26675
|
+
disableNotification: true
|
26617
26676
|
});
|
26618
26677
|
|
26619
26678
|
let UniqueLocalId = 0;
|
@@ -27385,7 +27444,7 @@
|
|
27385
27444
|
});
|
27386
27445
|
return;
|
27387
27446
|
}
|
27388
|
-
|
27447
|
+
serverMessageParser.parse({
|
27389
27448
|
[dialogId]: data.msg ?? {}
|
27390
27449
|
}, (_, outputMsgs) => {
|
27391
27450
|
const messageList = outputMsgs.get(dialogId) ?? [];
|
@@ -27499,6 +27558,9 @@
|
|
27499
27558
|
const totalUnreadCount = ConversationManager$1.get().getAllUnreadMentionedCount();
|
27500
27559
|
return totalUnreadCount;
|
27501
27560
|
}
|
27561
|
+
getConversationState(conOpt) {
|
27562
|
+
return ConversationManager$1.get().getConversationState(conOpt);
|
27563
|
+
}
|
27502
27564
|
getAllConversationState() {
|
27503
27565
|
return ConversationManager$1.get().getAllConversationState();
|
27504
27566
|
}
|
@@ -27570,7 +27632,7 @@
|
|
27570
27632
|
return;
|
27571
27633
|
}
|
27572
27634
|
if (isDef(msg)) {
|
27573
|
-
const latestMessage =
|
27635
|
+
const latestMessage = serverMessageParser.parseSingleDialogMessages(dialogId.toString(), [msg], aesKey)[0];
|
27574
27636
|
conversationObj.latestMessage = latestMessage;
|
27575
27637
|
}
|
27576
27638
|
return conversationObj;
|
@@ -28553,6 +28615,19 @@
|
|
28553
28615
|
data: count
|
28554
28616
|
});
|
28555
28617
|
};
|
28618
|
+
const getConversationState = options => {
|
28619
|
+
logger.debug('getConversationState');
|
28620
|
+
const state = imClient.getConversationState(options);
|
28621
|
+
if (state) {
|
28622
|
+
return Promise.resolve({
|
28623
|
+
code: exports.ErrorCode.SUCCESS,
|
28624
|
+
data: state
|
28625
|
+
});
|
28626
|
+
}
|
28627
|
+
return Promise.resolve({
|
28628
|
+
code: exports.ErrorCode.UNKNOWN
|
28629
|
+
});
|
28630
|
+
};
|
28556
28631
|
const getAllConversationState = () => {
|
28557
28632
|
logger.debug('getAllConversationState');
|
28558
28633
|
const states = imClient.getAllConversationState();
|
@@ -28822,6 +28897,9 @@
|
|
28822
28897
|
code: exports.ErrorCode.SUCCESS
|
28823
28898
|
};
|
28824
28899
|
};
|
28900
|
+
const parseChatRecordMsgDetails = (conversation, detailItems) => {
|
28901
|
+
return serverMessageParser.parseChatRecordMsgDetails(conversation, detailItems);
|
28902
|
+
};
|
28825
28903
|
const mockLogin = config => {
|
28826
28904
|
return login(config);
|
28827
28905
|
};
|
@@ -28860,6 +28938,7 @@
|
|
28860
28938
|
exports.getConversationList = getConversationList;
|
28861
28939
|
exports.getConversationNotificationLevel = getConversationNotificationLevel;
|
28862
28940
|
exports.getConversationNotificationStatus = getConversationNotificationStatus;
|
28941
|
+
exports.getConversationState = getConversationState;
|
28863
28942
|
exports.getHistoryMessages = getHistoryMessages;
|
28864
28943
|
exports.getRemoteHistoryMessages = getRemoteHistoryMessages;
|
28865
28944
|
exports.getServerTime = getServerTime;
|
@@ -28872,6 +28951,7 @@
|
|
28872
28951
|
exports.logOut = logOut;
|
28873
28952
|
exports.mockLogin = mockLogin;
|
28874
28953
|
exports.onceEventListener = onceEventListener;
|
28954
|
+
exports.parseChatRecordMsgDetails = parseChatRecordMsgDetails;
|
28875
28955
|
exports.recallMessage = recallMessage;
|
28876
28956
|
exports.registerMessageType = registerMessageType;
|
28877
28957
|
exports.removeConversation = removeConversation;
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
@@ -6,6 +6,7 @@ import IReceivedMessage from './model/iReceivedMessage';
|
|
6
6
|
import IReceivedConversation from './model/iReceivedConversation';
|
7
7
|
import { CommonReqResult, PBCodec } from './net/connection/webSocketServer';
|
8
8
|
import { BaseResp } from './net/pbs/rpc.base';
|
9
|
+
import { IChatRecordMsgDetail } from './model/messages/otherMediaMessages';
|
9
10
|
export { TextMessage, ImageMessage, HQVoiceMessage, GIFMessage, FileMessage, VideoMessage } from './model/messages';
|
10
11
|
export type { ITextMessageBody, IImageMessageBody, IGIFMessageBody, IFileMessageBody, IHQVoiceMessageBody, IRecallCommandMessageBody, IVideoMessageBody, ILocationMessageBody, IChatRecordMessageBody, IContactMessageBody, IInvitationMessageBody, IRedEnvelopeMessageBody, ITransferMessageBody } from './model/messages';
|
11
12
|
export { MessageTypes } from './constants/messageTypes';
|
@@ -97,6 +98,10 @@ export declare const getUnreadMentionedCount: (options: IConversationOption) =>
|
|
97
98
|
* 获取所有群会话 @ 消息未读数
|
98
99
|
*/
|
99
100
|
export declare const getAllUnreadMentionedCount: () => IPromiseResult<number>;
|
101
|
+
/**
|
102
|
+
* 获取本地单个会话的状态
|
103
|
+
*/
|
104
|
+
export declare const getConversationState: (options: IConversationOption) => IPromiseResult<IConversationState>;
|
100
105
|
/**
|
101
106
|
* 获取本地全部会话的状态
|
102
107
|
* @description
|
@@ -222,6 +227,7 @@ export declare const deleteMessages: (conversation: IConversationOption, message
|
|
222
227
|
* @param timestamp 清除时间点, 该时间之前的消息将被清除
|
223
228
|
*/
|
224
229
|
export declare const clearHistoryMessages: (conversation: IConversationOption, timestamp: number) => IPromiseResult<void>;
|
230
|
+
export declare const parseChatRecordMsgDetails: (conversation: IConversationOption, detailItems: IChatRecordMsgDetail[]) => IReceivedMessage[];
|
225
231
|
export declare const mockLogin: (config: {
|
226
232
|
langCode: string;
|
227
233
|
phone: string;
|
@@ -18,6 +18,18 @@ export interface IChatRecordMessageBody {
|
|
18
18
|
}>;
|
19
19
|
encryptKey?: string;
|
20
20
|
}
|
21
|
+
export interface IChatRecordMsgDetail {
|
22
|
+
senderNickname: string;
|
23
|
+
senderAvatar?: string;
|
24
|
+
msgId: string;
|
25
|
+
srcId: string;
|
26
|
+
destId: string;
|
27
|
+
msgPreContent?: string;
|
28
|
+
msgPostContent?: string;
|
29
|
+
mediaConstructor: number;
|
30
|
+
mediaAttribute?: string;
|
31
|
+
msgSendTime: string;
|
32
|
+
}
|
21
33
|
export interface IContactMessageBody {
|
22
34
|
uid: string;
|
23
35
|
nickname: string;
|