@onyx-p/imlib-web 1.3.3 → 1.3.4
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 +92 -845
- package/index.umd.js +93 -849
- package/package.json +1 -1
- package/types/index.d.ts +2 -5
- package/types/model/baseMessage.d.ts +4 -2
- package/types/model/messages/fileMessage.d.ts +12 -13
- package/types/model/messages/gifMessage.d.ts +11 -12
- package/types/model/messages/imageMessage.d.ts +16 -16
- package/types/model/messages/recallCommandMessage.d.ts +5 -13
- package/types/model/messages/textMessage.d.ts +4 -8
- package/types/model/messages/voiceMessage.d.ts +9 -12
package/index.umd.js
CHANGED
@@ -13519,13 +13519,13 @@
|
|
13519
13519
|
return;
|
13520
13520
|
}
|
13521
13521
|
const messageSeq = Long.isLong(networkResponse.messageSeq) ? networkResponse.messageSeq.toNumber() : 0;
|
13522
|
-
logger.
|
13522
|
+
logger.info(`websocket recv ack -> messageSeq: ${messageSeq}`);
|
13523
13523
|
const resolve = this.responseCallbacks.get(messageSeq);
|
13524
13524
|
if (isDef(resolve)) {
|
13525
13525
|
resolve(networkResponse.body);
|
13526
13526
|
this.responseCallbacks.delete(messageSeq);
|
13527
13527
|
} else {
|
13528
|
-
logger.
|
13528
|
+
logger.info(`websocket recv -> cmd: 0x${networkResponse.cmdId.toString(16)}, messageSeq: ${messageSeq}`);
|
13529
13529
|
this.watcher?.message(networkResponse.cmdId, networkResponse.body);
|
13530
13530
|
}
|
13531
13531
|
}
|
@@ -18718,331 +18718,6 @@
|
|
18718
18718
|
}
|
18719
18719
|
};
|
18720
18720
|
|
18721
|
-
const MessageSerializers = new Map();
|
18722
|
-
function registerMessageSerializer(aSerializer) {
|
18723
|
-
MessageSerializers.set(aSerializer.getObjectId(), aSerializer.decode.bind(aSerializer));
|
18724
|
-
}
|
18725
|
-
function decodeMessage(objectId, messageData) {
|
18726
|
-
const decodeFunc = MessageSerializers.get(objectId);
|
18727
|
-
const messageObject = decodeFunc ? decodeFunc(messageData) : null;
|
18728
|
-
return messageObject;
|
18729
|
-
}
|
18730
|
-
|
18731
|
-
class BaseMessage {
|
18732
|
-
content;
|
18733
|
-
isPersited;
|
18734
|
-
isCounted;
|
18735
|
-
isStatusMessage;
|
18736
|
-
constructor(content, isPersited = true, isCounted = true, isStatusMessage = false) {
|
18737
|
-
this.content = content;
|
18738
|
-
if (isStatusMessage) {
|
18739
|
-
this.isPersited = false;
|
18740
|
-
this.isCounted = false;
|
18741
|
-
} else {
|
18742
|
-
this.isPersited = isPersited;
|
18743
|
-
this.isCounted = isCounted;
|
18744
|
-
}
|
18745
|
-
this.isStatusMessage = isStatusMessage;
|
18746
|
-
}
|
18747
|
-
get objectId() {
|
18748
|
-
return this.constructor.getObjectId();
|
18749
|
-
}
|
18750
|
-
static getObjectId() {
|
18751
|
-
throw new Error('Method not implemented.');
|
18752
|
-
}
|
18753
|
-
static decode(aDecoder) {
|
18754
|
-
throw new Error('Method not implemented.');
|
18755
|
-
}
|
18756
|
-
encode() {
|
18757
|
-
throw new Error('Method not implemented.');
|
18758
|
-
}
|
18759
|
-
}
|
18760
|
-
|
18761
|
-
const MessageObjectIds = {
|
18762
|
-
TEXT: 0x00000000,
|
18763
|
-
IMAGE: 0x10001000,
|
18764
|
-
GIF: 0x1000100b,
|
18765
|
-
FILE: 0x1000100a,
|
18766
|
-
AUDIO: 0x10001001,
|
18767
|
-
CUST_COMMAND: 0x1000101d,
|
18768
|
-
CUST_STORAGE: 0x1000102d,
|
18769
|
-
CUST_NORMAL: 0x1000103d,
|
18770
|
-
CUST_STATUS: 0x1000104d,
|
18771
|
-
RECALL: 0x6001001d,
|
18772
|
-
CMD: 0x1000105d
|
18773
|
-
};
|
18774
|
-
|
18775
|
-
class TextMessage extends BaseMessage {
|
18776
|
-
constructor(content) {
|
18777
|
-
super(content);
|
18778
|
-
}
|
18779
|
-
static getObjectId() {
|
18780
|
-
return MessageObjectIds.TEXT;
|
18781
|
-
}
|
18782
|
-
static decode(aDecoder) {
|
18783
|
-
const {
|
18784
|
-
user,
|
18785
|
-
extra,
|
18786
|
-
content
|
18787
|
-
} = aDecoder;
|
18788
|
-
return new TextMessage({
|
18789
|
-
user,
|
18790
|
-
extra,
|
18791
|
-
content
|
18792
|
-
});
|
18793
|
-
}
|
18794
|
-
encode() {
|
18795
|
-
const {
|
18796
|
-
user,
|
18797
|
-
extra,
|
18798
|
-
content
|
18799
|
-
} = this.content;
|
18800
|
-
return {
|
18801
|
-
user,
|
18802
|
-
extra,
|
18803
|
-
content
|
18804
|
-
};
|
18805
|
-
}
|
18806
|
-
}
|
18807
|
-
|
18808
|
-
class IMConfig {
|
18809
|
-
_token = '';
|
18810
|
-
_uploadUrl = '';
|
18811
|
-
_downloadUrl = '';
|
18812
|
-
_cert = '';
|
18813
|
-
set imInitToken(val) {
|
18814
|
-
this._token = val;
|
18815
|
-
}
|
18816
|
-
get imInitToken() {
|
18817
|
-
return this._token;
|
18818
|
-
}
|
18819
|
-
get fileUploadUrl() {
|
18820
|
-
return this._uploadUrl;
|
18821
|
-
}
|
18822
|
-
get cert() {
|
18823
|
-
return this._cert;
|
18824
|
-
}
|
18825
|
-
get fileDownloadUrl() {
|
18826
|
-
return this._downloadUrl;
|
18827
|
-
}
|
18828
|
-
setFileServerInfo(uploadUrl, downloadUrl, cert) {
|
18829
|
-
this._uploadUrl = uploadUrl;
|
18830
|
-
this._downloadUrl = downloadUrl;
|
18831
|
-
this._cert = cert;
|
18832
|
-
}
|
18833
|
-
getFileAbsoluteUri(u) {
|
18834
|
-
if (!notEmptyString(u)) {
|
18835
|
-
return u;
|
18836
|
-
}
|
18837
|
-
if (u.startsWith('http')) {
|
18838
|
-
return u;
|
18839
|
-
}
|
18840
|
-
return this.fileDownloadUrl + u;
|
18841
|
-
}
|
18842
|
-
try2ExtractFileRelativeUri(u) {
|
18843
|
-
if (!notEmptyString(u)) {
|
18844
|
-
return u;
|
18845
|
-
}
|
18846
|
-
if (!u.startsWith(this.fileDownloadUrl)) {
|
18847
|
-
return u;
|
18848
|
-
}
|
18849
|
-
return u.substring(this.fileDownloadUrl.length);
|
18850
|
-
}
|
18851
|
-
}
|
18852
|
-
var imConfig = new IMConfig();
|
18853
|
-
|
18854
|
-
class ImageMessage extends BaseMessage {
|
18855
|
-
constructor(content) {
|
18856
|
-
super(content);
|
18857
|
-
}
|
18858
|
-
static getObjectId() {
|
18859
|
-
return MessageObjectIds.IMAGE;
|
18860
|
-
}
|
18861
|
-
static decode(aDecoder) {
|
18862
|
-
const {
|
18863
|
-
user,
|
18864
|
-
extra,
|
18865
|
-
thumbnailObjectKey,
|
18866
|
-
originalObjectKey,
|
18867
|
-
width,
|
18868
|
-
height
|
18869
|
-
} = aDecoder;
|
18870
|
-
return new ImageMessage({
|
18871
|
-
user,
|
18872
|
-
extra,
|
18873
|
-
content: thumbnailObjectKey,
|
18874
|
-
imageUri: imConfig.getFileAbsoluteUri(originalObjectKey),
|
18875
|
-
width,
|
18876
|
-
height
|
18877
|
-
});
|
18878
|
-
}
|
18879
|
-
encode() {
|
18880
|
-
const {
|
18881
|
-
user,
|
18882
|
-
extra,
|
18883
|
-
content,
|
18884
|
-
imageUri,
|
18885
|
-
width,
|
18886
|
-
height
|
18887
|
-
} = this.content;
|
18888
|
-
return {
|
18889
|
-
user,
|
18890
|
-
extra,
|
18891
|
-
thumbnailObjectKey: content,
|
18892
|
-
originalObjectKey: imConfig.try2ExtractFileRelativeUri(imageUri),
|
18893
|
-
width: width && Math.floor(width),
|
18894
|
-
height: height && Math.floor(height)
|
18895
|
-
};
|
18896
|
-
}
|
18897
|
-
}
|
18898
|
-
|
18899
|
-
class GIFMessage extends BaseMessage {
|
18900
|
-
constructor(content) {
|
18901
|
-
super(content);
|
18902
|
-
}
|
18903
|
-
static getObjectId() {
|
18904
|
-
return MessageObjectIds.GIF;
|
18905
|
-
}
|
18906
|
-
static decode(aDecoder) {
|
18907
|
-
const {
|
18908
|
-
user,
|
18909
|
-
extra,
|
18910
|
-
size,
|
18911
|
-
originalObjectKey,
|
18912
|
-
width,
|
18913
|
-
height
|
18914
|
-
} = aDecoder;
|
18915
|
-
return new GIFMessage({
|
18916
|
-
user,
|
18917
|
-
extra,
|
18918
|
-
gifDataSize: size,
|
18919
|
-
remoteUrl: imConfig.getFileAbsoluteUri(originalObjectKey),
|
18920
|
-
width,
|
18921
|
-
height
|
18922
|
-
});
|
18923
|
-
}
|
18924
|
-
encode() {
|
18925
|
-
const {
|
18926
|
-
user,
|
18927
|
-
extra,
|
18928
|
-
gifDataSize,
|
18929
|
-
remoteUrl,
|
18930
|
-
width,
|
18931
|
-
height
|
18932
|
-
} = this.content;
|
18933
|
-
return {
|
18934
|
-
user,
|
18935
|
-
extra,
|
18936
|
-
size: gifDataSize,
|
18937
|
-
originalObjectKey: imConfig.try2ExtractFileRelativeUri(remoteUrl),
|
18938
|
-
width: width && Math.floor(width),
|
18939
|
-
height: height && Math.floor(height),
|
18940
|
-
extension: 'gif'
|
18941
|
-
};
|
18942
|
-
}
|
18943
|
-
}
|
18944
|
-
|
18945
|
-
class HQVoiceMessage extends BaseMessage {
|
18946
|
-
constructor(content) {
|
18947
|
-
super(content);
|
18948
|
-
}
|
18949
|
-
static getObjectId() {
|
18950
|
-
return MessageObjectIds.AUDIO;
|
18951
|
-
}
|
18952
|
-
static decode(aDecoder) {
|
18953
|
-
const {
|
18954
|
-
user,
|
18955
|
-
extra,
|
18956
|
-
length,
|
18957
|
-
audioObjectKey,
|
18958
|
-
extension
|
18959
|
-
} = aDecoder;
|
18960
|
-
return new HQVoiceMessage({
|
18961
|
-
user,
|
18962
|
-
extra,
|
18963
|
-
remoteUrl: imConfig.getFileAbsoluteUri(audioObjectKey),
|
18964
|
-
duration: length,
|
18965
|
-
type: extension
|
18966
|
-
});
|
18967
|
-
}
|
18968
|
-
encode() {
|
18969
|
-
const {
|
18970
|
-
user,
|
18971
|
-
extra,
|
18972
|
-
remoteUrl,
|
18973
|
-
duration,
|
18974
|
-
type
|
18975
|
-
} = this.content;
|
18976
|
-
return {
|
18977
|
-
user,
|
18978
|
-
extra,
|
18979
|
-
length: duration,
|
18980
|
-
audioObjectKey: imConfig.try2ExtractFileRelativeUri(remoteUrl),
|
18981
|
-
extension: type
|
18982
|
-
};
|
18983
|
-
}
|
18984
|
-
}
|
18985
|
-
|
18986
|
-
class FileMessage extends BaseMessage {
|
18987
|
-
constructor(content) {
|
18988
|
-
super(content);
|
18989
|
-
}
|
18990
|
-
static getObjectId() {
|
18991
|
-
return MessageObjectIds.FILE;
|
18992
|
-
}
|
18993
|
-
static decode(aDecoder) {
|
18994
|
-
const {
|
18995
|
-
user,
|
18996
|
-
extra,
|
18997
|
-
title,
|
18998
|
-
extension,
|
18999
|
-
size,
|
19000
|
-
originalObjectKey
|
19001
|
-
} = aDecoder;
|
19002
|
-
return new FileMessage({
|
19003
|
-
user,
|
19004
|
-
extra,
|
19005
|
-
name: title,
|
19006
|
-
size,
|
19007
|
-
type: extension,
|
19008
|
-
fileUrl: imConfig.getFileAbsoluteUri(originalObjectKey)
|
19009
|
-
});
|
19010
|
-
}
|
19011
|
-
encode() {
|
19012
|
-
const {
|
19013
|
-
user,
|
19014
|
-
extra,
|
19015
|
-
name,
|
19016
|
-
size,
|
19017
|
-
type,
|
19018
|
-
fileUrl
|
19019
|
-
} = this.content;
|
19020
|
-
return {
|
19021
|
-
user,
|
19022
|
-
extra,
|
19023
|
-
title: name,
|
19024
|
-
originalObjectKey: imConfig.try2ExtractFileRelativeUri(fileUrl),
|
19025
|
-
extension: type,
|
19026
|
-
size
|
19027
|
-
};
|
19028
|
-
}
|
19029
|
-
}
|
19030
|
-
|
19031
|
-
class RecallCommandMessage extends BaseMessage {
|
19032
|
-
constructor(content) {
|
19033
|
-
super(content, true, false, false);
|
19034
|
-
}
|
19035
|
-
static getObjectId() {
|
19036
|
-
return MessageObjectIds.RECALL;
|
19037
|
-
}
|
19038
|
-
static decode(aDecoder) {
|
19039
|
-
return new RecallCommandMessage(aDecoder);
|
19040
|
-
}
|
19041
|
-
encode() {
|
19042
|
-
return this.content;
|
19043
|
-
}
|
19044
|
-
}
|
19045
|
-
|
19046
18721
|
class DialogSecretKey {
|
19047
18722
|
aesKeyRecord = new Map();
|
19048
18723
|
async getDialogAesKey(dialogId) {
|
@@ -19192,6 +18867,27 @@
|
|
19192
18867
|
return new Uint8Array(array);
|
19193
18868
|
};
|
19194
18869
|
|
18870
|
+
const MessageSerializers = new Map();
|
18871
|
+
function decodeMessage(objectId, messageData) {
|
18872
|
+
const decodeFunc = MessageSerializers.get(objectId);
|
18873
|
+
const messageObject = decodeFunc ? decodeFunc(messageData) : null;
|
18874
|
+
return messageObject;
|
18875
|
+
}
|
18876
|
+
|
18877
|
+
const MessageTypes = {
|
18878
|
+
TEXT: 0x00000000,
|
18879
|
+
IMAGE: 0x10001000,
|
18880
|
+
GIF: 0x1000100b,
|
18881
|
+
FILE: 0x1000100a,
|
18882
|
+
AUDIO: 0x10001001,
|
18883
|
+
CUST_COMMAND: 0x1000101d,
|
18884
|
+
CUST_STORAGE: 0x1000102d,
|
18885
|
+
CUST_NORMAL: 0x1000103d,
|
18886
|
+
CUST_STATUS: 0x1000104d,
|
18887
|
+
RECALL: 0x6001001d,
|
18888
|
+
CMD: 0x1000105d
|
18889
|
+
};
|
18890
|
+
|
19195
18891
|
const STATUSMESSAGE_ALIVE_TIMEMS = 6000;
|
19196
18892
|
function parse(orginalMsgs, callback) {
|
19197
18893
|
const msgs = new Map();
|
@@ -19247,12 +18943,9 @@
|
|
19247
18943
|
sendTime
|
19248
18944
|
} = mediaAttributeJson;
|
19249
18945
|
const recallContent = {
|
19250
|
-
|
19251
|
-
messageUId: msgId,
|
19252
|
-
conversationType: conversation.conversationType,
|
19253
|
-
targetId: dialogMessage.isOut ? conversation.targetId : accountStore.uid
|
18946
|
+
msgId: msgId
|
19254
18947
|
};
|
19255
|
-
mediaConstructor =
|
18948
|
+
mediaConstructor = MessageTypes.RECALL;
|
19256
18949
|
mediaAttributeJson = recallContent;
|
19257
18950
|
recallMessageUIds.add(msgId);
|
19258
18951
|
}
|
@@ -19398,7 +19091,7 @@
|
|
19398
19091
|
messageDirection
|
19399
19092
|
} = message;
|
19400
19093
|
const isSelfSend = messageDirection === exports.MessageDirection.SEND;
|
19401
|
-
const isRecall = messageType ===
|
19094
|
+
const isRecall = messageType === MessageTypes.RECALL;
|
19402
19095
|
const hasContent = isObject(content);
|
19403
19096
|
const key = {
|
19404
19097
|
conversationType,
|
@@ -19432,7 +19125,7 @@
|
|
19432
19125
|
messageDirection,
|
19433
19126
|
content
|
19434
19127
|
} = message;
|
19435
|
-
if (messageDirection === exports.MessageDirection.SEND || !isMentioned && messageType !==
|
19128
|
+
if (messageDirection === exports.MessageDirection.SEND || !isMentioned && messageType !== MessageTypes.RECALL) {
|
19436
19129
|
return;
|
19437
19130
|
}
|
19438
19131
|
const key = this.getStoreKey({
|
@@ -19447,9 +19140,9 @@
|
|
19447
19140
|
localMentionedUIdList.push(messageUId.toString());
|
19448
19141
|
}
|
19449
19142
|
}
|
19450
|
-
if (messageType ===
|
19143
|
+
if (messageType === MessageTypes.RECALL && conversationType === exports.ConversationType.GROUP) {
|
19451
19144
|
const recallContent = content;
|
19452
|
-
const index = localMentionedUIdList.indexOf(recallContent.
|
19145
|
+
const index = localMentionedUIdList.indexOf(recallContent.msgId.toString());
|
19453
19146
|
if (index >= 0) {
|
19454
19147
|
localMentionedUIdList.splice(index, 1);
|
19455
19148
|
}
|
@@ -20075,7 +19768,7 @@
|
|
20075
19768
|
l.forEach(m => {
|
20076
19769
|
if (m.messageDirection === exports.MessageDirection.SEND && m.messageId && SentMessageStore.has(m.messageId)) {
|
20077
19770
|
SentMessageStore.remove(m.messageId);
|
20078
|
-
} else if (m.messageType ===
|
19771
|
+
} else if (m.messageType === MessageTypes.RECALL && RecallMessageStore.has(m.content.messageUId)) {
|
20079
19772
|
RecallMessageStore.remove(m.content.messageUId);
|
20080
19773
|
} else {
|
20081
19774
|
m.isOffLineMessage = isOffLineMessage;
|
@@ -20163,14 +19856,7 @@
|
|
20163
19856
|
}
|
20164
19857
|
return DEFAULT_SOCKET_URI;
|
20165
19858
|
}
|
20166
|
-
registerMessage() {
|
20167
|
-
registerMessageSerializer(TextMessage);
|
20168
|
-
registerMessageSerializer(ImageMessage);
|
20169
|
-
registerMessageSerializer(GIFMessage);
|
20170
|
-
registerMessageSerializer(HQVoiceMessage);
|
20171
|
-
registerMessageSerializer(RecallCommandMessage);
|
20172
|
-
registerMessageSerializer(FileMessage);
|
20173
|
-
}
|
19859
|
+
registerMessage() {}
|
20174
19860
|
async connect() {
|
20175
19861
|
if (this.connectionStatus === exports.ConnectionStatus.CONNECTED) {
|
20176
19862
|
return {
|
@@ -20280,6 +19966,7 @@
|
|
20280
19966
|
}, 2000);
|
20281
19967
|
}
|
20282
19968
|
messageListener(cmdId, body) {
|
19969
|
+
logger.info(`libLoader messageListener -> cmdId: ${cmdId}, body: ${body}`);
|
20283
19970
|
if (cmdId === CmdIds$1.NewMessagePush) {
|
20284
19971
|
const newMsgNotiResp = NewMessageNotificationResp.decode(body);
|
20285
19972
|
this.messageLoader?.syncMsg(newMsgNotiResp.seqno);
|
@@ -26850,6 +26537,56 @@
|
|
26850
26537
|
var protobufjsExports = requireProtobufjs();
|
26851
26538
|
var protobuf = /*@__PURE__*/getDefaultExportFromCjs(protobufjsExports);
|
26852
26539
|
|
26540
|
+
class BaseMessage {
|
26541
|
+
messageType;
|
26542
|
+
content;
|
26543
|
+
isPersited;
|
26544
|
+
isCounted;
|
26545
|
+
isStatusMessage;
|
26546
|
+
constructor(messageType, content, isPersited = true, isCounted = true, isStatusMessage = false) {
|
26547
|
+
this.messageType = messageType;
|
26548
|
+
this.content = content;
|
26549
|
+
if (isStatusMessage) {
|
26550
|
+
this.isPersited = false;
|
26551
|
+
this.isCounted = false;
|
26552
|
+
} else {
|
26553
|
+
this.isPersited = isPersited;
|
26554
|
+
this.isCounted = isCounted;
|
26555
|
+
}
|
26556
|
+
this.isStatusMessage = isStatusMessage;
|
26557
|
+
}
|
26558
|
+
get objectId() {
|
26559
|
+
return this.constructor.getObjectId();
|
26560
|
+
}
|
26561
|
+
static getObjectId() {
|
26562
|
+
throw new Error('Method not implemented.');
|
26563
|
+
}
|
26564
|
+
static decode(aDecoder) {
|
26565
|
+
throw new Error('Method not implemented.');
|
26566
|
+
}
|
26567
|
+
encode() {
|
26568
|
+
throw new Error('Method not implemented.');
|
26569
|
+
}
|
26570
|
+
}
|
26571
|
+
const registerMessageType$1 = (messageType, isPersited, isCounted, isStatusMessage) => {
|
26572
|
+
const defined = function (content) {
|
26573
|
+
return new BaseMessage(messageType, content, isPersited, isCounted, isStatusMessage);
|
26574
|
+
};
|
26575
|
+
return defined;
|
26576
|
+
};
|
26577
|
+
|
26578
|
+
const TextMessage = registerMessageType$1(MessageTypes.TEXT, true, true, false);
|
26579
|
+
|
26580
|
+
const ImageMessage = registerMessageType$1(MessageTypes.IMAGE, true, true, false);
|
26581
|
+
|
26582
|
+
const GIFMessage = registerMessageType$1(MessageTypes.GIF, true, true, false);
|
26583
|
+
|
26584
|
+
const VoiceMessage = registerMessageType$1(MessageTypes.AUDIO, true, true, false);
|
26585
|
+
|
26586
|
+
const FileMessage = registerMessageType$1(MessageTypes.FILE, true, true, false);
|
26587
|
+
|
26588
|
+
const RecallCommandMessage = registerMessageType$1(MessageTypes.RECALL, true, false, false);
|
26589
|
+
|
26853
26590
|
const transSentAttrs2IReceivedMessage = (message, options, sentStatus = exports.SentStatus.SENDING) => ({
|
26854
26591
|
conversationType: options.conversation.conversationType,
|
26855
26592
|
targetId: options.conversation.targetId,
|
@@ -26881,411 +26618,10 @@
|
|
26881
26618
|
return 230000000000000 + UniqueLocalId;
|
26882
26619
|
}
|
26883
26620
|
|
26884
|
-
const getBlobUrl = blob => {
|
26885
|
-
const URL = window.URL || window.webkitURL;
|
26886
|
-
return URL ? URL.createObjectURL(blob) : '';
|
26887
|
-
};
|
26888
|
-
const getBlobExtension = blob => {
|
26889
|
-
const name = blob.name;
|
26890
|
-
if (notEmptyString(name)) {
|
26891
|
-
return name.substring(name.lastIndexOf('.') + 1);
|
26892
|
-
}
|
26893
|
-
return blob.type.indexOf('/') > 0 ? blob.type.substring(blob.type.lastIndexOf('/') + 1) : '';
|
26894
|
-
};
|
26895
|
-
const blob2ArrayBuffer = blob => {
|
26896
|
-
if (isPromise(blob.arrayBuffer)) {
|
26897
|
-
return blob.arrayBuffer();
|
26898
|
-
}
|
26899
|
-
return new Promise((resolve, reject) => {
|
26900
|
-
const reader = new FileReader();
|
26901
|
-
reader.addEventListener('load', event => {
|
26902
|
-
if (event.target) {
|
26903
|
-
resolve(event.target.result);
|
26904
|
-
} else {
|
26905
|
-
reject('null');
|
26906
|
-
}
|
26907
|
-
});
|
26908
|
-
reader.addEventListener('error', error => reject(error));
|
26909
|
-
reader.readAsArrayBuffer(blob);
|
26910
|
-
});
|
26911
|
-
};
|
26912
|
-
const revokeBlobUrl = url => {
|
26913
|
-
const URL = window.URL || window.webkitURL;
|
26914
|
-
URL.revokeObjectURL(url);
|
26915
|
-
};
|
26916
|
-
const dataURL2Blob = url => {
|
26917
|
-
const type = url.match(/data:([^;]+)/)[1];
|
26918
|
-
const base64 = url.replace(/^[^,]+,/, '');
|
26919
|
-
const bstr = window.atob(base64);
|
26920
|
-
let n = bstr.length;
|
26921
|
-
const u8arr = new Uint8Array(bstr.length);
|
26922
|
-
while (n--) {
|
26923
|
-
u8arr[n] = bstr.charCodeAt(n);
|
26924
|
-
}
|
26925
|
-
return new Blob([u8arr], {
|
26926
|
-
type
|
26927
|
-
});
|
26928
|
-
};
|
26929
|
-
|
26930
|
-
const COMPRESS_LENGTH_MAX = 1680;
|
26931
|
-
const COMPRESS_LENGTH_MIN = 160;
|
26932
|
-
const getImageObj = link => {
|
26933
|
-
return new Promise((resolve, reject) => {
|
26934
|
-
const handle = image => {
|
26935
|
-
if (image.width !== 0 || image.height !== 0) {
|
26936
|
-
resolve(image);
|
26937
|
-
} else {
|
26938
|
-
reject();
|
26939
|
-
}
|
26940
|
-
};
|
26941
|
-
const image = new Image();
|
26942
|
-
image.addEventListener('load', event => handle(event.target));
|
26943
|
-
image.addEventListener('error', reject);
|
26944
|
-
image.src = link;
|
26945
|
-
if (image.complete) {
|
26946
|
-
handle(image);
|
26947
|
-
return;
|
26948
|
-
}
|
26949
|
-
const intervalId = setInterval(() => {
|
26950
|
-
if (image.complete) {
|
26951
|
-
handle(image);
|
26952
|
-
clearInterval(intervalId);
|
26953
|
-
}
|
26954
|
-
}, 40);
|
26955
|
-
});
|
26956
|
-
};
|
26957
|
-
const compress = (image, quality = 1, mineType = 'image/jpeg') => {
|
26958
|
-
quality = Math.min(1, quality);
|
26959
|
-
const width = image.width;
|
26960
|
-
const height = image.height;
|
26961
|
-
let compressWidth = width;
|
26962
|
-
let compressHeight = height;
|
26963
|
-
if (quality < 1) {
|
26964
|
-
const isheight = width < height;
|
26965
|
-
const zoom = isheight ? height / COMPRESS_LENGTH_MAX : width / COMPRESS_LENGTH_MAX;
|
26966
|
-
if (width > COMPRESS_LENGTH_MAX && height > COMPRESS_LENGTH_MAX) {
|
26967
|
-
if (isheight) {
|
26968
|
-
compressHeight = COMPRESS_LENGTH_MAX;
|
26969
|
-
compressWidth = compressWidth / zoom;
|
26970
|
-
} else {
|
26971
|
-
compressWidth = COMPRESS_LENGTH_MAX;
|
26972
|
-
compressHeight = compressHeight / zoom;
|
26973
|
-
}
|
26974
|
-
} else if (width > COMPRESS_LENGTH_MAX && height > COMPRESS_LENGTH_MIN) {
|
26975
|
-
compressWidth = COMPRESS_LENGTH_MAX;
|
26976
|
-
compressHeight = compressHeight / zoom;
|
26977
|
-
if (compressHeight < COMPRESS_LENGTH_MIN) {
|
26978
|
-
compressHeight = COMPRESS_LENGTH_MIN;
|
26979
|
-
compressWidth = width / (height / COMPRESS_LENGTH_MIN);
|
26980
|
-
}
|
26981
|
-
} else if (height > COMPRESS_LENGTH_MAX && width > COMPRESS_LENGTH_MIN) {
|
26982
|
-
compressHeight = COMPRESS_LENGTH_MAX;
|
26983
|
-
compressWidth = compressWidth / zoom;
|
26984
|
-
if (compressWidth < COMPRESS_LENGTH_MIN) {
|
26985
|
-
compressWidth = COMPRESS_LENGTH_MIN;
|
26986
|
-
compressHeight = height / (width / COMPRESS_LENGTH_MIN);
|
26987
|
-
}
|
26988
|
-
}
|
26989
|
-
}
|
26990
|
-
compressWidth = Math.floor(compressWidth);
|
26991
|
-
compressHeight = Math.floor(compressHeight);
|
26992
|
-
const canvas = document.createElement('canvas');
|
26993
|
-
canvas.width = compressWidth;
|
26994
|
-
canvas.height = compressHeight;
|
26995
|
-
const ctx = canvas.getContext('2d');
|
26996
|
-
ctx.fillStyle = '#FFF';
|
26997
|
-
ctx.fillRect(0, 0, compressWidth, compressHeight);
|
26998
|
-
ctx.drawImage(image, 0, 0, width, height, 0, 0, compressWidth, compressHeight);
|
26999
|
-
if (!mineType || mineType == 'image/png') {
|
27000
|
-
mineType = 'image/jpeg';
|
27001
|
-
}
|
27002
|
-
return {
|
27003
|
-
imageFile: dataURL2Blob(canvas.toDataURL(mineType, Math.min(0.92, quality))),
|
27004
|
-
compressWidth,
|
27005
|
-
compressHeight
|
27006
|
-
};
|
27007
|
-
};
|
27008
|
-
const getThumbnail = (img, thumbnailConfig) => {
|
27009
|
-
const canvas = document.createElement('canvas');
|
27010
|
-
const context = canvas.getContext('2d');
|
27011
|
-
const pos = calcPosition(img.width, img.height, thumbnailConfig);
|
27012
|
-
canvas.width = pos.w > thumbnailConfig.maxWidth ? thumbnailConfig.maxWidth : pos.w;
|
27013
|
-
canvas.height = pos.h > thumbnailConfig.maxHeight ? thumbnailConfig.maxHeight : pos.h;
|
27014
|
-
context?.drawImage(img, pos.x, pos.y, pos.w, pos.h);
|
27015
|
-
try {
|
27016
|
-
let base64 = canvas.toDataURL('image/jpeg', thumbnailConfig.quality);
|
27017
|
-
const reg = new RegExp('^data:image/[^;]+;base64,');
|
27018
|
-
base64 = base64.replace(reg, '');
|
27019
|
-
return base64;
|
27020
|
-
} catch (e) {
|
27021
|
-
throw new Error(e);
|
27022
|
-
}
|
27023
|
-
};
|
27024
|
-
function calcPosition(width, height, thumbnailConfig) {
|
27025
|
-
const isheight = width < height;
|
27026
|
-
const scale = isheight ? height / width : width / height;
|
27027
|
-
let zoom;
|
27028
|
-
let x = 0;
|
27029
|
-
let y = 0;
|
27030
|
-
let w;
|
27031
|
-
let h;
|
27032
|
-
const gtScale = function () {
|
27033
|
-
if (isheight) {
|
27034
|
-
zoom = width / 100;
|
27035
|
-
w = 100;
|
27036
|
-
h = height / zoom;
|
27037
|
-
y = (h - thumbnailConfig.maxHeight) / 2;
|
27038
|
-
} else {
|
27039
|
-
zoom = height / 100;
|
27040
|
-
h = 100;
|
27041
|
-
w = width / zoom;
|
27042
|
-
x = (w - thumbnailConfig.maxWidth) / 2;
|
27043
|
-
}
|
27044
|
-
return {
|
27045
|
-
w: w,
|
27046
|
-
h: h,
|
27047
|
-
x: -x,
|
27048
|
-
y: -y
|
27049
|
-
};
|
27050
|
-
};
|
27051
|
-
const ltScale = function () {
|
27052
|
-
if (isheight) {
|
27053
|
-
zoom = height / thumbnailConfig.maxHeight;
|
27054
|
-
h = thumbnailConfig.maxHeight;
|
27055
|
-
w = width / zoom;
|
27056
|
-
} else {
|
27057
|
-
zoom = width / thumbnailConfig.maxWidth;
|
27058
|
-
w = thumbnailConfig.maxWidth;
|
27059
|
-
h = height / zoom;
|
27060
|
-
}
|
27061
|
-
return {
|
27062
|
-
w: w,
|
27063
|
-
h: h,
|
27064
|
-
x: -x,
|
27065
|
-
y: -y
|
27066
|
-
};
|
27067
|
-
};
|
27068
|
-
return scale > thumbnailConfig.scale ? gtScale() : ltScale();
|
27069
|
-
}
|
27070
|
-
|
27071
|
-
class Img {
|
27072
|
-
async create(file) {
|
27073
|
-
try {
|
27074
|
-
const blobUrl = getBlobUrl(file);
|
27075
|
-
const image = await getImageObj(blobUrl);
|
27076
|
-
revokeBlobUrl(blobUrl);
|
27077
|
-
const {
|
27078
|
-
imageFile: sentImageFile,
|
27079
|
-
compressWidth,
|
27080
|
-
compressHeight
|
27081
|
-
} = compress(image, 0.85, file.type);
|
27082
|
-
const config = {
|
27083
|
-
maxHeight: 160,
|
27084
|
-
maxWidth: 160,
|
27085
|
-
quality: 0.6,
|
27086
|
-
scale: 2.4
|
27087
|
-
};
|
27088
|
-
const thumbnail = getThumbnail(image, config);
|
27089
|
-
return {
|
27090
|
-
success: true,
|
27091
|
-
message: new ImageMessage({
|
27092
|
-
content: thumbnail,
|
27093
|
-
imageUri: getBlobUrl(sentImageFile),
|
27094
|
-
width: compressWidth,
|
27095
|
-
height: compressHeight
|
27096
|
-
}),
|
27097
|
-
file: sentImageFile
|
27098
|
-
};
|
27099
|
-
} catch (error) {
|
27100
|
-
return {
|
27101
|
-
success: false
|
27102
|
-
};
|
27103
|
-
}
|
27104
|
-
}
|
27105
|
-
updateMessageRemoteUrlProperty(msg, remoteUrl) {
|
27106
|
-
msg.content.imageUri = remoteUrl;
|
27107
|
-
}
|
27108
|
-
}
|
27109
|
-
class GIF {
|
27110
|
-
async create(file) {
|
27111
|
-
if (file.size > 2 * 1024 * 1024) {
|
27112
|
-
return {
|
27113
|
-
success: false
|
27114
|
-
};
|
27115
|
-
}
|
27116
|
-
try {
|
27117
|
-
const blobUrl = getBlobUrl(file);
|
27118
|
-
const image = await getImageObj(blobUrl);
|
27119
|
-
return {
|
27120
|
-
success: true,
|
27121
|
-
message: new GIFMessage({
|
27122
|
-
gifDataSize: file.size,
|
27123
|
-
remoteUrl: blobUrl,
|
27124
|
-
width: image.width,
|
27125
|
-
height: image.height
|
27126
|
-
}),
|
27127
|
-
file: file
|
27128
|
-
};
|
27129
|
-
} catch {
|
27130
|
-
return {
|
27131
|
-
success: false
|
27132
|
-
};
|
27133
|
-
}
|
27134
|
-
}
|
27135
|
-
updateMessageRemoteUrlProperty(message, remoteUrl) {
|
27136
|
-
message.content.remoteUrl = remoteUrl;
|
27137
|
-
}
|
27138
|
-
}
|
27139
|
-
let audioCtx;
|
27140
|
-
class Audio {
|
27141
|
-
create(file) {
|
27142
|
-
return blob2ArrayBuffer(file).then(this.getAudioInfo).then(info => {
|
27143
|
-
return {
|
27144
|
-
success: true,
|
27145
|
-
message: new HQVoiceMessage({
|
27146
|
-
remoteUrl: '',
|
27147
|
-
duration: info.duration,
|
27148
|
-
type: getBlobExtension(file)
|
27149
|
-
}),
|
27150
|
-
file
|
27151
|
-
};
|
27152
|
-
}).catch(() => {
|
27153
|
-
return {
|
27154
|
-
success: false
|
27155
|
-
};
|
27156
|
-
});
|
27157
|
-
}
|
27158
|
-
updateMessageRemoteUrlProperty(message, remoteUrl) {
|
27159
|
-
message.content.remoteUrl = remoteUrl;
|
27160
|
-
}
|
27161
|
-
getAudioInfo(buffer) {
|
27162
|
-
const ctx = audioCtx || new AudioContext();
|
27163
|
-
audioCtx = ctx;
|
27164
|
-
return new Promise((resolve, reject) => {
|
27165
|
-
ctx.decodeAudioData(buffer, function (audioBuffer) {
|
27166
|
-
resolve({
|
27167
|
-
duration: audioBuffer.duration,
|
27168
|
-
length: audioBuffer.length
|
27169
|
-
});
|
27170
|
-
}, reject);
|
27171
|
-
});
|
27172
|
-
}
|
27173
|
-
}
|
27174
|
-
class File {
|
27175
|
-
async create(file) {
|
27176
|
-
if (file.size > 100 * 1024 * 1024) {
|
27177
|
-
return {
|
27178
|
-
success: false
|
27179
|
-
};
|
27180
|
-
}
|
27181
|
-
return {
|
27182
|
-
success: true,
|
27183
|
-
message: new FileMessage({
|
27184
|
-
fileUrl: '',
|
27185
|
-
name: file.name,
|
27186
|
-
type: getBlobExtension(file),
|
27187
|
-
size: file.size
|
27188
|
-
}),
|
27189
|
-
file
|
27190
|
-
};
|
27191
|
-
}
|
27192
|
-
updateMessageRemoteUrlProperty(message, remoteUrl) {
|
27193
|
-
message.content.fileUrl = remoteUrl;
|
27194
|
-
}
|
27195
|
-
}
|
27196
|
-
var FileType;
|
27197
|
-
(function (FileType) {
|
27198
|
-
FileType[FileType["IMAGE"] = 1] = "IMAGE";
|
27199
|
-
FileType[FileType["GIF"] = 2] = "GIF";
|
27200
|
-
FileType[FileType["AUDIO"] = 3] = "AUDIO";
|
27201
|
-
FileType[FileType["VIDEO"] = 4] = "VIDEO";
|
27202
|
-
FileType[FileType["FILE"] = 5] = "FILE";
|
27203
|
-
FileType[FileType["SIGHT"] = 6] = "SIGHT";
|
27204
|
-
})(FileType || (FileType = {}));
|
27205
|
-
const getMediaMessageCreator = fileType => {
|
27206
|
-
let creator;
|
27207
|
-
switch (fileType) {
|
27208
|
-
case FileType.IMAGE:
|
27209
|
-
creator = new Img();
|
27210
|
-
break;
|
27211
|
-
case FileType.AUDIO:
|
27212
|
-
creator = new Audio();
|
27213
|
-
break;
|
27214
|
-
case FileType.GIF:
|
27215
|
-
creator = new GIF();
|
27216
|
-
break;
|
27217
|
-
case FileType.FILE:
|
27218
|
-
creator = new File();
|
27219
|
-
break;
|
27220
|
-
}
|
27221
|
-
return creator;
|
27222
|
-
};
|
27223
|
-
|
27224
|
-
class Upload {
|
27225
|
-
options;
|
27226
|
-
xhr;
|
27227
|
-
constructor(options) {
|
27228
|
-
this.options = options;
|
27229
|
-
}
|
27230
|
-
upload(file, callback) {
|
27231
|
-
const xhr = new XMLHttpRequest();
|
27232
|
-
xhr.timeout = (30 + file.size / 1024 / 512) * 1000;
|
27233
|
-
xhr.upload.onprogress = event => {
|
27234
|
-
callback.onProgress?.(event.loaded, event.total);
|
27235
|
-
};
|
27236
|
-
xhr.onreadystatechange = () => {
|
27237
|
-
if (xhr.readyState === 4) {
|
27238
|
-
const responseText = xhr.responseText || '{}';
|
27239
|
-
const responseData = JSON.parse(responseText);
|
27240
|
-
if (xhr.status === 200 && responseData.code === 200) {
|
27241
|
-
let result = {
|
27242
|
-
url: responseData.url
|
27243
|
-
};
|
27244
|
-
if (this.options.transformer) {
|
27245
|
-
result = this.options.transformer(result);
|
27246
|
-
}
|
27247
|
-
callback.onCompleted?.(result);
|
27248
|
-
} else {
|
27249
|
-
callback.onError?.('upload fail');
|
27250
|
-
}
|
27251
|
-
}
|
27252
|
-
};
|
27253
|
-
xhr.open('POST', this.options.uploadUrl, true);
|
27254
|
-
xhr.setRequestHeader('device', '7');
|
27255
|
-
xhr.setRequestHeader('cert', this.options.cert ?? '');
|
27256
|
-
const type = getBlobExtension(file);
|
27257
|
-
const fileName = genUId() + (type.length ? `.${type}` : '');
|
27258
|
-
const formData = new FormData();
|
27259
|
-
formData.append('file', file);
|
27260
|
-
formData.append('name', 'file');
|
27261
|
-
formData.append('fileName', fileName);
|
27262
|
-
formData.append('token', this.options.token);
|
27263
|
-
xhr.send(formData);
|
27264
|
-
this.xhr = xhr;
|
27265
|
-
}
|
27266
|
-
cancel() {
|
27267
|
-
this.xhr?.abort();
|
27268
|
-
}
|
27269
|
-
}
|
27270
|
-
function genUId() {
|
27271
|
-
let date = new Date().getTime();
|
27272
|
-
const uuid = 'xxxxxx4xxxyxxxxxxx'.replace(/[xy]/g, function (c) {
|
27273
|
-
const r = (date + Math.random() * 16) % 16 | 0;
|
27274
|
-
date = Math.floor(date / 16);
|
27275
|
-
return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
|
27276
|
-
});
|
27277
|
-
return uuid;
|
27278
|
-
}
|
27279
|
-
|
27280
26621
|
const MAX_MESSAGE_CONTENT_BYTES = 80 * 1024;
|
27281
|
-
const MEDIA_MESSAGES = [MessageObjectIds.IMAGE, MessageObjectIds.AUDIO, MessageObjectIds.GIF, MessageObjectIds.FILE];
|
27282
26622
|
async function sendMessage$1(conversation, message, options) {
|
27283
26623
|
return internal_sendMessage(conversation, message, options);
|
27284
26624
|
}
|
27285
|
-
const sendImageMessage$1 = createSendFunction.bind(null, FileType.IMAGE);
|
27286
|
-
const sendGIFMessage$1 = createSendFunction.bind(null, FileType.GIF);
|
27287
|
-
const sendHQVoiceMessage$1 = createSendFunction.bind(null, FileType.AUDIO);
|
27288
|
-
const sendFileMessage$1 = createSendFunction.bind(null, FileType.FILE);
|
27289
26625
|
const sendRecallMessage = async (conversation, options) => {
|
27290
26626
|
const dialogId = getFullDialogId(conversation);
|
27291
26627
|
RecallMessageStore.addMessage(options.messageUId);
|
@@ -27296,9 +26632,7 @@
|
|
27296
26632
|
};
|
27297
26633
|
}
|
27298
26634
|
const recallCommandMessage = new RecallCommandMessage({
|
27299
|
-
|
27300
|
-
messageUId: options.messageUId,
|
27301
|
-
...conversation
|
26635
|
+
msgId: options.messageUId
|
27302
26636
|
});
|
27303
26637
|
const sentAttris = {
|
27304
26638
|
conversation,
|
@@ -27313,58 +26647,6 @@
|
|
27313
26647
|
data: receivedMessage
|
27314
26648
|
};
|
27315
26649
|
};
|
27316
|
-
async function createSendFunction(fileType, conversation, msgBody, hooks, sendOptions) {
|
27317
|
-
const mediaMessageCreator = getMediaMessageCreator(fileType);
|
27318
|
-
if (!mediaMessageCreator) return {
|
27319
|
-
code: exports.ErrorCode.NOT_SUPPORT
|
27320
|
-
};
|
27321
|
-
const {
|
27322
|
-
success,
|
27323
|
-
message: message1,
|
27324
|
-
file
|
27325
|
-
} = await mediaMessageCreator.create(msgBody.file);
|
27326
|
-
if (!success || !message1 || !file) {
|
27327
|
-
return {
|
27328
|
-
code: exports.ErrorCode.MEDIA_EXCEPTION
|
27329
|
-
};
|
27330
|
-
}
|
27331
|
-
message1.content.user = msgBody.user;
|
27332
|
-
message1.content.extra = msgBody.extra;
|
27333
|
-
return internal_sendMessage(conversation, message1, sendOptions, {
|
27334
|
-
file,
|
27335
|
-
task: (message2, toBeUploadedFile) => {
|
27336
|
-
return new Promise(resolve => {
|
27337
|
-
const uploader = new Upload({
|
27338
|
-
token: imConfig.imInitToken,
|
27339
|
-
uploadUrl: imConfig.fileUploadUrl,
|
27340
|
-
cert: imConfig.cert,
|
27341
|
-
transformer: result => ({
|
27342
|
-
...result,
|
27343
|
-
url: imConfig.getFileAbsoluteUri(result.url)
|
27344
|
-
})
|
27345
|
-
});
|
27346
|
-
uploader.upload(toBeUploadedFile, {
|
27347
|
-
onProgress: (loaded, total) => hooks?.onProgress?.(Math.floor(loaded / total * 100)),
|
27348
|
-
onError: () => {
|
27349
|
-
resolve({
|
27350
|
-
finished: false,
|
27351
|
-
message: message2
|
27352
|
-
});
|
27353
|
-
},
|
27354
|
-
onCompleted: result => {
|
27355
|
-
mediaMessageCreator.updateMessageRemoteUrlProperty(message2, result.url);
|
27356
|
-
resolve({
|
27357
|
-
finished: true,
|
27358
|
-
message: hooks?.onComplete?.({
|
27359
|
-
url: result.url
|
27360
|
-
}) ?? message2
|
27361
|
-
});
|
27362
|
-
}
|
27363
|
-
});
|
27364
|
-
});
|
27365
|
-
}
|
27366
|
-
});
|
27367
|
-
}
|
27368
26650
|
async function internal_sendMessage(conversation, message, options, uploadOptions) {
|
27369
26651
|
const checkResult = beforeSend(conversation, message, options);
|
27370
26652
|
if (checkResult.code !== exports.ErrorCode.SUCCESS || !checkResult.message || !checkResult.sentArgs) {
|
@@ -27436,7 +26718,7 @@
|
|
27436
26718
|
SentMessageStore.addMessage(sentArgs.messageId);
|
27437
26719
|
const baseParams = {
|
27438
26720
|
localId: sentArgs.messageId,
|
27439
|
-
mediaFlag:
|
26721
|
+
mediaFlag: false,
|
27440
26722
|
mediaConstructor: message.objectId,
|
27441
26723
|
mediaAttribute: '',
|
27442
26724
|
msgPreContent: '',
|
@@ -27566,6 +26848,7 @@
|
|
27566
26848
|
});
|
27567
26849
|
},
|
27568
26850
|
onPush: (cmdId, body) => {
|
26851
|
+
logger.info(`client onPush -> cmdId: ${cmdId}, body: ${body}`);
|
27569
26852
|
this.emit(exports.Events.PUSH, {
|
27570
26853
|
cmdId,
|
27571
26854
|
body
|
@@ -27592,10 +26875,6 @@
|
|
27592
26875
|
}
|
27593
26876
|
getServerTime = getServerTime$1;
|
27594
26877
|
sendMessage = sendMessage$1;
|
27595
|
-
sendImageMessage = sendImageMessage$1;
|
27596
|
-
sendGIFMessage = sendGIFMessage$1;
|
27597
|
-
sendHQVoiceMessage = sendHQVoiceMessage$1;
|
27598
|
-
sendFileMessage = sendFileMessage$1;
|
27599
26878
|
recallMsg = sendRecallMessage;
|
27600
26879
|
async getRemoteHistoryMessages(conversation, options) {
|
27601
26880
|
const dialogId = getFullDialogId(conversation);
|
@@ -28893,6 +28172,12 @@
|
|
28893
28172
|
const getTopConversationList = () => {
|
28894
28173
|
return imClient.getTopConversationList();
|
28895
28174
|
};
|
28175
|
+
const registerMessageType = (messageType, isPersited, isCounted, isStatusMessage) => {
|
28176
|
+
const defined = function (content) {
|
28177
|
+
return new BaseMessage(messageType, content, isPersited, isCounted, isStatusMessage);
|
28178
|
+
};
|
28179
|
+
return defined;
|
28180
|
+
};
|
28896
28181
|
const sendMessage = async (conversation, message, options) => {
|
28897
28182
|
if (message instanceof BaseMessage === false) {
|
28898
28183
|
logger.warn('send message fail -> message parameter is not an instance of BaseMessage');
|
@@ -28910,44 +28195,6 @@
|
|
28910
28195
|
const message = new TextMessage(messageBody);
|
28911
28196
|
return sendMessage(conversation, message, options);
|
28912
28197
|
};
|
28913
|
-
const sendImageMessage = async (conversation, msgBody, hooks, sendOptions) => {
|
28914
|
-
assert('conversation', conversation, AssertRules.CONVERSATION, true);
|
28915
|
-
assert('msgBody.file', msgBody.file, file => file instanceof Blob && file.type.startsWith('image/'), true);
|
28916
|
-
const paramsStr = 'conversationType:' + conversation.conversationType + ',targetId:' + conversation.targetId;
|
28917
|
-
logger.debug('send message ->' + paramsStr);
|
28918
|
-
_logSendBefore(conversation);
|
28919
|
-
const response = await imClient.sendImageMessage(conversation, msgBody, hooks, sendOptions);
|
28920
|
-
_logSendError(conversation, response.code);
|
28921
|
-
return response;
|
28922
|
-
};
|
28923
|
-
const sendGIFMessage = async (conversation, msgBody, hooks, sendOptions) => {
|
28924
|
-
assert('conversation', conversation, AssertRules.CONVERSATION, true);
|
28925
|
-
assert('msgBody.file', msgBody.file, file => file instanceof Blob && file.type.endsWith('image/gif'), true);
|
28926
|
-
const paramsStr = 'conversationType:' + conversation.conversationType + ',targetId:' + conversation.targetId;
|
28927
|
-
logger.debug('send message ->' + paramsStr);
|
28928
|
-
_logSendBefore(conversation);
|
28929
|
-
const response = await imClient.sendGIFMessage(conversation, msgBody, hooks, sendOptions);
|
28930
|
-
_logSendError(conversation, response.code);
|
28931
|
-
return response;
|
28932
|
-
};
|
28933
|
-
const sendHQVoiceMessage = async (conversation, msgBody, hooks, sendOptions) => {
|
28934
|
-
assert('conversation', conversation, AssertRules.CONVERSATION, true);
|
28935
|
-
assert('msgBody.file', msgBody.file, file => file instanceof Blob, true);
|
28936
|
-
_logSendBefore(conversation);
|
28937
|
-
const response = await imClient.sendHQVoiceMessage(conversation, msgBody, hooks, sendOptions);
|
28938
|
-
_logSendError(conversation, response.code);
|
28939
|
-
return response;
|
28940
|
-
};
|
28941
|
-
const sendFileMessage = async (conversation, msgBody, hooks, sendOptions) => {
|
28942
|
-
assert('conversation', conversation, AssertRules.CONVERSATION, true);
|
28943
|
-
assert('msgBody.file', msgBody.file, file => file instanceof Blob, true);
|
28944
|
-
const paramsStr = 'conversationType:' + conversation.conversationType + ',targetId:' + conversation.targetId;
|
28945
|
-
logger.debug('send message ->' + paramsStr);
|
28946
|
-
_logSendBefore(conversation);
|
28947
|
-
const response = await imClient.sendFileMessage(conversation, msgBody, hooks, sendOptions);
|
28948
|
-
_logSendError(conversation, response.code);
|
28949
|
-
return response;
|
28950
|
-
};
|
28951
28198
|
const recallMessage = async (conversation, options) => {
|
28952
28199
|
assert('options.messageUId', options.messageUId, AssertRules.STRING, true);
|
28953
28200
|
assert('options.sentTime', options.sentTime, AssertRules.NUMBER, true);
|
@@ -29050,7 +28297,7 @@
|
|
29050
28297
|
exports.ErrorDesc = ErrorDesc;
|
29051
28298
|
exports.FileMessage = FileMessage;
|
29052
28299
|
exports.GIFMessage = GIFMessage;
|
29053
|
-
exports.HQVoiceMessage =
|
28300
|
+
exports.HQVoiceMessage = VoiceMessage;
|
29054
28301
|
exports.ImageMessage = ImageMessage;
|
29055
28302
|
exports.TextMessage = TextMessage;
|
29056
28303
|
exports.addEventListener = addEventListener;
|
@@ -29082,14 +28329,11 @@
|
|
29082
28329
|
exports.mockLogin = mockLogin;
|
29083
28330
|
exports.onceEventListener = onceEventListener;
|
29084
28331
|
exports.recallMessage = recallMessage;
|
28332
|
+
exports.registerMessageType = registerMessageType;
|
29085
28333
|
exports.removeConversation = removeConversation;
|
29086
28334
|
exports.removeEventListener = removeEventListener;
|
29087
28335
|
exports.request = request;
|
29088
28336
|
exports.saveTextMessageDraft = saveTextMessageDraft;
|
29089
|
-
exports.sendFileMessage = sendFileMessage;
|
29090
|
-
exports.sendGIFMessage = sendGIFMessage;
|
29091
|
-
exports.sendHQVoiceMessage = sendHQVoiceMessage;
|
29092
|
-
exports.sendImageMessage = sendImageMessage;
|
29093
28337
|
exports.sendMessage = sendMessage;
|
29094
28338
|
exports.sendTextMessage = sendTextMessage;
|
29095
28339
|
exports.setConversationNotificationStatus = setConversationNotificationStatus;
|