@rongcloud/electron 5.4.4 → 5.5.0-enterprise-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding/electron-v11.1-darwin-x64.node +0 -0
- package/binding/electron-v11.1-linux-arm64.node +0 -0
- package/binding/electron-v11.1-linux-x64.node +0 -0
- package/binding/electron-v11.1-win32-ia32.node +0 -0
- package/binding/electron-v14.0-darwin-x64.node +0 -0
- package/binding/electron-v14.0-win32-ia32.node +0 -0
- package/binding/electron-v16.0-darwin-x64.node +0 -0
- package/binding/electron-v16.0-linux-arm64.node +0 -0
- package/binding/electron-v16.0-win32-ia32.node +0 -0
- package/index.d.ts +17 -193
- package/index.esm.js +1 -1
- package/index.js +1 -1
- package/package.json +2 -2
- package/binding/electron-v5.0-darwin-x64.node +0 -0
- package/binding/electron-v5.0-win32-ia32.node +0 -0
- package/binding/electron-v5.0-win32-x64.node +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConversationType, IChrmKVEntry, FileType,
|
|
1
|
+
import { ConversationType, IChrmKVEntry, FileType, IEngine, IExtraMethod, IAsyncRes, IReceivedConversation, IPromiseResult, IReceivedMessage, INaviInfo, ErrorCode, ISendMsgOptions, IRecallMsgOptions, MessageDirection, NotificationStatus, IInsertMsgOptions, IServerConversationStatus, ISetConversationStatusOptions, IServerUserSetting, IMessageReaderResponse, IChatroomInfo, IChrmKVEntries, IUploadAuth, UploadMethod, IRTCRoomBindOption, ITagParam, ITagInfo, IConversationOption, IReceivedConversationByTag, ITagStatus, IConversationTag, IBaseConversationInfo, LogLevel } from '@rongcloud/engine';
|
|
2
2
|
|
|
3
3
|
declare type IOnErrorCallBack = (code: number) => void;
|
|
4
4
|
interface ICppProtocol {
|
|
@@ -94,7 +94,8 @@ interface ICppProtocol {
|
|
|
94
94
|
canIncludeExpansion: boolean, // 是否支持消息扩展存储
|
|
95
95
|
expansionContent: string, // 扩展消息内容
|
|
96
96
|
enableVoipPush: boolean, // 开启 voip 推送 , 音视频 CAllLib SDK 发消息使用。IM 消息均为 false
|
|
97
|
-
tag
|
|
97
|
+
tag: string, // 会话组织标识
|
|
98
|
+
resendMessageId: number) => any;
|
|
98
99
|
/**
|
|
99
100
|
* 撤回消息
|
|
100
101
|
*/
|
|
@@ -398,152 +399,18 @@ interface ICppProtocol {
|
|
|
398
399
|
* 设置消息扩展字段
|
|
399
400
|
*/
|
|
400
401
|
setMessageExtension: (conversationType: ConversationType, targetId: string, messageUId: string, messageExtension: string, tag: string) => void;
|
|
401
|
-
/**
|
|
402
|
-
* 加入 RTC 房间
|
|
403
|
-
*/
|
|
404
|
-
joinRTCRoom: (roomId: string, roomType: number, liveType: number, joinType: RTCJoinType, onSuccess: (result: string, token: string, sessionId: string, roomInfo: string, kvEntries: [], offlineKickTime: number) => void, onError: IOnErrorCallBack, key?: string, value?: string, inner?: string, outer?: string) => void;
|
|
405
|
-
/**
|
|
406
|
-
* 退出 RTC 房间
|
|
407
|
-
*/
|
|
408
|
-
exitRTCRoom: (roomId: string, onSuccess: () => void, onError: IOnErrorCallBack) => void;
|
|
409
|
-
/**
|
|
410
|
-
* RTC Ping
|
|
411
|
-
*/
|
|
412
|
-
sendRTCPing: (roomId: string, onSuccess: () => void, onError: IOnErrorCallBack) => void;
|
|
413
|
-
/**
|
|
414
|
-
* 获取 RTC 房间信息
|
|
415
|
-
*/
|
|
416
|
-
getRTCResouce: (roomId: string, order: number, onSuccess: (result: string) => void, onError: IOnErrorCallBack) => void;
|
|
417
|
-
/**
|
|
418
|
-
* 获取 RTC 用户信息列表
|
|
419
|
-
*/
|
|
420
|
-
getRTCUsers: (roomId: string, order: number, onSuccess: (result: IRTCUsers) => void, onError: IOnErrorCallBack) => void;
|
|
421
|
-
/**
|
|
422
|
-
* 设置 RTC 数据
|
|
423
|
-
*/
|
|
424
|
-
setRTCInnerData: (roomId: string, apiType: RTCApiType, key: string, value: string, name: string, content: string, onSuccess: () => void, onError: IOnErrorCallBack) => void;
|
|
425
|
-
/**
|
|
426
|
-
* 设置 RTC 数据
|
|
427
|
-
*/
|
|
428
|
-
setRTCOuterData: (roomId: string, apiType: RTCApiType, key: string, value: string, name: string, content: string, onSuccess: () => void, onError: IOnErrorCallBack) => void;
|
|
429
|
-
/**
|
|
430
|
-
* 获取 RTC 数据
|
|
431
|
-
*/
|
|
432
|
-
getRTCInnerData: (roomId: string, apiType: RTCApiType, keys: string[], onSuccess: (data: string) => void, onError: IOnErrorCallBack) => void;
|
|
433
|
-
/**
|
|
434
|
-
* 获取 RTC 数据
|
|
435
|
-
*/
|
|
436
|
-
getRTCOuterData: (roomId: string, apiType: RTCApiType, keys: string[], onSuccess: (data: string) => void, onError: IOnErrorCallBack) => void;
|
|
437
|
-
/**
|
|
438
|
-
* 删除 RTC 数据
|
|
439
|
-
*/
|
|
440
|
-
deleteRTCInnerData: (roomId: string, apiType: RTCApiType, keys: string[], name: string, content: string, onSuccess: (data: unknown) => void, onError: IOnErrorCallBack) => void;
|
|
441
|
-
/**
|
|
442
|
-
* 删除 RTC 数据
|
|
443
|
-
*/
|
|
444
|
-
deleteRTCOuterData: (roomId: string, apiType: RTCApiType, keys: string[], name: string, content: string, onSuccess: (data: unknown) => void, onError: IOnErrorCallBack) => void;
|
|
445
|
-
/**
|
|
446
|
-
* 获取 RTC Token
|
|
447
|
-
*/
|
|
448
|
-
getRTCToken: (roomId: string, onSuccess: (token: string) => void, onError: IOnErrorCallBack) => void;
|
|
449
|
-
/**
|
|
450
|
-
* 日志上报
|
|
451
|
-
*/
|
|
452
|
-
setRTCUserState: (roomId: string, state: string, onSuccess: (token: string) => void, onError: IOnErrorCallBack) => void;
|
|
453
|
-
/**
|
|
454
|
-
* 全量 Uri
|
|
455
|
-
*/
|
|
456
|
-
setUserResource: (roomId: string, oldname: string, oldContent: string, newName: string, uris: string, mcuUris: string, onSuccess: () => void, onError: IOnErrorCallBack) => void;
|
|
457
|
-
/**
|
|
458
|
-
* 设置内置 cdn 数据
|
|
459
|
-
*/
|
|
460
|
-
setRTCCDNUris: (roomId: string, objectName: string, CDNUris: string, onSuccess: () => void) => void;
|
|
461
|
-
/**
|
|
462
|
-
* 发送 RTC 消息
|
|
463
|
-
*/
|
|
464
|
-
sendRTCMessage: (onSuccess: (message: string, code: number) => void, onError: (message: string, code: number) => void, conversationType: ConversationType, targetId: string, messageType: string, content: string, directionalUserIdList: string[], // 接收定向消息的用户 id 列表. 仅群组有效
|
|
465
|
-
disableNotification: boolean, // 禁用消息通知
|
|
466
|
-
disablePushTitle: boolean, // 移动端是否禁用自定义标题 // disablePushTitle
|
|
467
|
-
forceShowDetailContent: boolean, // 移动端是否强制显示详情 // forceShowDetailContent
|
|
468
|
-
pushContent: string, // Push 显示内容
|
|
469
|
-
pushData: string, // Push 通知时附加信息
|
|
470
|
-
notificationId: string, // 推送 ID // notificationId
|
|
471
|
-
pushTitle: string, // 自定义推送标题 // pushTitle
|
|
472
|
-
pushConfig: string, // 移动端 PUSH 配置
|
|
473
|
-
pushTemplateId: string, // PUSH 模板 ID
|
|
474
|
-
canIncludeExpansion: boolean, // 是否支持消息扩展存储
|
|
475
|
-
expansionContent: string, // 扩展消息内容
|
|
476
|
-
enableVoipPush: boolean, // 开启 voip 推送 , 音视频 CAllLib SDK 发消息使用。IM 消息均为 false
|
|
477
|
-
isStatusMsg: boolean) => void;
|
|
478
|
-
/**
|
|
479
|
-
* 直播观众加房间
|
|
480
|
-
*/
|
|
481
|
-
audienceJoinRoom: (roomId: string, liveType: number, onSuccess: (token: string, entries: string) => void, onError: IOnErrorCallBack) => void;
|
|
482
|
-
/**
|
|
483
|
-
* 直播观众退出房间
|
|
484
|
-
*/
|
|
485
|
-
audienceLeaveRoom: (roomId: string, onSuccess: (token: string) => void, onError: IOnErrorCallBack) => void;
|
|
486
|
-
/**
|
|
487
|
-
* 直播房间身份切换
|
|
488
|
-
*/
|
|
489
|
-
switchRole: (roomId: string, liveType: number, roleChangeType: number, key: string, value: string,
|
|
490
|
-
/**
|
|
491
|
-
* TODO 主播切观众仅返回 token 待验证
|
|
492
|
-
*/
|
|
493
|
-
onSuccess: (result: string, token: string, sessionId: string, roomInfo: string, entries: string, offlineKickTime: number) => void, onError: IOnErrorCallBack) => void;
|
|
494
|
-
/**
|
|
495
|
-
* 观众房间,资源通知监听
|
|
496
|
-
*/
|
|
497
|
-
setRTCRoomEventListener(callback: (kv: string) => void): void;
|
|
498
402
|
getConversationListByPage(conversationTypes: ConversationType[], timestamp: number, limit: number, channelId: string): string;
|
|
499
|
-
/**
|
|
500
|
-
* 查询加入房间用户的信息
|
|
501
|
-
*/
|
|
502
|
-
queryJoinedRoom: (onSuccess: (result: string) => void, onError: IOnErrorCallBack) => void;
|
|
503
|
-
/**
|
|
504
|
-
* 直播跨房间连麦 PK 邀请
|
|
505
|
-
*/
|
|
506
|
-
livePKInvitation: (roomId: string, // 当前房间 ID
|
|
507
|
-
invitedUserId: string, // 被邀请用户 ID
|
|
508
|
-
invitedRoomId: string, // 被邀请房间 ID
|
|
509
|
-
inviteInfo: string, // 本次邀请额外信息
|
|
510
|
-
inviteSessionId: string, // 本次邀请唯一 ID
|
|
511
|
-
inviteTimeout: number, // 本次邀请超时时间
|
|
512
|
-
onSuccess: (result: string) => void, onError: IOnErrorCallBack) => void;
|
|
513
|
-
/**
|
|
514
|
-
* 直播跨房间连麦 PK 取消邀请
|
|
515
|
-
*/
|
|
516
|
-
livePKCancel: (roomId: string, // 当前房间 ID
|
|
517
|
-
invitedUserId: string, // 被邀请用户 ID
|
|
518
|
-
invitedRoomId: string, // 被邀请房间 ID
|
|
519
|
-
inviteInfo: string, // 本次邀请额外信息
|
|
520
|
-
inviteSessionId: string, // 本次邀请唯一 ID
|
|
521
|
-
onSuccess: (result: string) => void, onError: IOnErrorCallBack) => void;
|
|
522
|
-
/**
|
|
523
|
-
* 直播跨房间连麦 PK 取消邀请
|
|
524
|
-
*/
|
|
525
|
-
livePKAnswer: (roomId: string, // 当前房间 ID
|
|
526
|
-
answerCode: number, // 是否同意 同意:1 不同意:0
|
|
527
|
-
inviteUserId: string, // 邀请者 ID
|
|
528
|
-
inviteRoomId: string, // 邀请者房间 ID
|
|
529
|
-
inviteSessionId: string, // 邀请的 SessionID
|
|
530
|
-
content: string, // 需要转发的信息
|
|
531
|
-
key: string, // 同意邀请时要设置的 key, 放在room级别的k和v,新加入房间的能拉取到
|
|
532
|
-
value: string, // 同意邀请时要设置的 value, 放在room级别的k和v,新加入房间的能拉取到
|
|
533
|
-
onSuccess: (result: string) => void, onError: IOnErrorCallBack) => void;
|
|
534
|
-
/**
|
|
535
|
-
* 直播跨房间连麦 PK 取消邀请
|
|
536
|
-
*/
|
|
537
|
-
livePKHangup: (roomId: string, // 当前房间 ID
|
|
538
|
-
endRoomId: string, // 需要结束的连麦房间 ID
|
|
539
|
-
sessionId: string, // 需要结束的连麦 SessionID
|
|
540
|
-
content: string, // 结束连麦的信息
|
|
541
|
-
keys: string[], // 需要删除连麦信息的 keys
|
|
542
|
-
onSuccess: (result: string) => void, onError: IOnErrorCallBack) => void;
|
|
543
403
|
/**
|
|
544
404
|
* 设置聊天室关联的rtc房间
|
|
545
405
|
*/
|
|
546
406
|
bindRTCRoomForChatroom: (chatRoomId: string, rtcRoomId: string, onSuccess: (result: string) => void, onError: IOnErrorCallBack) => void;
|
|
407
|
+
rtcSignaling(roomId: string, method: string, isQuery: boolean, sourceData: number[], success: (buffer: number[]) => void, error: (code: number) => void): void;
|
|
408
|
+
/**
|
|
409
|
+
* RTC Ping
|
|
410
|
+
*/
|
|
411
|
+
sendRTCHeartbeat(roomId: string[]): void;
|
|
412
|
+
setRTCHeartbeatListener(onReq: (roomId: string, seqId: string) => void, onRes: (roomId: string, code: number, seqId: string) => void): void;
|
|
413
|
+
setRTCRoomEventListener(callback: (buffer: number[]) => void): void;
|
|
547
414
|
/**
|
|
548
415
|
* 删库
|
|
549
416
|
*/
|
|
@@ -912,36 +779,14 @@ declare class RCCppService implements IEngine, IExtraMethod {
|
|
|
912
779
|
clearData(): IPromiseResult<boolean>;
|
|
913
780
|
getDeviceId(): string;
|
|
914
781
|
getVoIPKey(engineType: number, channelName: string): IPromiseResult<string>;
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
782
|
+
bindRTCRoomForChatroom(options: IRTCRoomBindOption): Promise<ErrorCode>;
|
|
783
|
+
rtcSignaling(roomId: string, method: string, isQuery: boolean, sourceData: ArrayBuffer): Promise<{
|
|
784
|
+
code: ErrorCode;
|
|
785
|
+
buffer?: ArrayBuffer;
|
|
786
|
+
}>;
|
|
787
|
+
private rtcHeartbeatResolves;
|
|
788
|
+
private _setRTCHeartbeatListener;
|
|
920
789
|
rtcPing(roomId: string, mode: number, broadcastType?: number): Promise<ErrorCode>;
|
|
921
|
-
getRTCRoomInfo(roomId: string): IPromiseResult<IRTCRoomInfo>;
|
|
922
|
-
getRTCUserInfoList(roomId: string): IPromiseResult<IRTCUsers>;
|
|
923
|
-
getRTCUserInfo(roomId: string): IPromiseResult<unknown>;
|
|
924
|
-
setRTCUserInfo(roomId: string, key: string, value: string): Promise<ErrorCode>;
|
|
925
|
-
removeRTCUserInfo(roomId: string, keys: string[]): Promise<ErrorCode>;
|
|
926
|
-
setRTCData(roomId: string, key: string, value: string, isInner: boolean, apiType: RTCApiType, message?: {
|
|
927
|
-
name: string;
|
|
928
|
-
content: string;
|
|
929
|
-
}): Promise<ErrorCode>;
|
|
930
|
-
setRTCTotalRes(roomId: string, message: {
|
|
931
|
-
name: string;
|
|
932
|
-
content: string;
|
|
933
|
-
}, valueInfo: string, messageType: string, mcuValInfo: string): Promise<ErrorCode>;
|
|
934
|
-
setRTCCDNUris(roomId: string, objectName: string, CDNUris: string): Promise<ErrorCode>;
|
|
935
|
-
getRTCData(roomId: string, keys: string[], isInner: boolean, apiType: RTCApiType): IPromiseResult<KVString>;
|
|
936
|
-
removeRTCData(roomId: string, keys: string[], isInner: boolean, apiType: RTCApiType, message?: {
|
|
937
|
-
name: string;
|
|
938
|
-
content: string;
|
|
939
|
-
}): Promise<ErrorCode>;
|
|
940
|
-
setRTCOutData(roomId: string, rtcData: unknown, type: number, message: unknown): Promise<ErrorCode>;
|
|
941
|
-
getRTCOutData(roomId: string, userIds: string[]): IPromiseResult<unknown>;
|
|
942
|
-
getRTCToken(roomId: string, _mode: number, _broadcastType?: number): IPromiseResult<IRtcTokenData>;
|
|
943
|
-
setRTCState(roomId: string, reportId: string): Promise<ErrorCode>;
|
|
944
|
-
getRTCUserList(roomId: string): IPromiseResult<IRTCUsers>;
|
|
945
790
|
createTag(tag: ITagParam): IPromiseResult<IAsyncRes>;
|
|
946
791
|
removeTag(tagId: string): IPromiseResult<IAsyncRes>;
|
|
947
792
|
updateTag(tag: ITagParam): IPromiseResult<IAsyncRes>;
|
|
@@ -953,31 +798,10 @@ declare class RCCppService implements IEngine, IExtraMethod {
|
|
|
953
798
|
getUnreadCountByTag(tagId: string, containMuted: boolean): IPromiseResult<number>;
|
|
954
799
|
setConversationStatusInTag(tagId: string, conversation: IConversationOption, status: ITagStatus): IPromiseResult<IAsyncRes>;
|
|
955
800
|
getTagsForConversation(conversation: IConversationOption): IPromiseResult<IConversationTag[]>;
|
|
956
|
-
/**
|
|
957
|
-
* 直播观众加房间
|
|
958
|
-
*/
|
|
959
|
-
joinLivingRoomAsAudience(roomId: string, mode: RTCMode, broadcastType?: number): Promise<IAsyncRes<{
|
|
960
|
-
token: string;
|
|
961
|
-
kvEntries: IServerRTCRoomEntry[];
|
|
962
|
-
}>>;
|
|
963
|
-
/**
|
|
964
|
-
* 直播观众退出房间
|
|
965
|
-
*/
|
|
966
|
-
quitLivingRoomAsAudience(roomId: string): Promise<ErrorCode>;
|
|
967
|
-
/**
|
|
968
|
-
* 直播房间身份切换
|
|
969
|
-
*/
|
|
970
|
-
switchLivingRoomRole(roomId: string, changeType: RTCIdentityChangeType, broadcastType?: number): Promise<IAsyncRes<IJoinRTCRoomData>>;
|
|
971
|
-
getRTCJoinedUserInfo(userId: string): Promise<IAsyncRes<IRTCJoinedInfo[]>>;
|
|
972
801
|
getBlockConversationList(): Promise<IAsyncRes<IBaseConversationInfo[]>>;
|
|
973
802
|
getTopConversationList(): Promise<IAsyncRes<IBaseConversationInfo[]>>;
|
|
974
803
|
getUnreadMentionedCount(conversation: IConversationOption): Promise<IAsyncRes<number>>;
|
|
975
804
|
getAllUnreadMentionedCount(): Promise<IAsyncRes<number>>;
|
|
976
|
-
requestRoomPK(options: IReqRoomPKOptions): Promise<ErrorCode>;
|
|
977
|
-
cancelRoomPK(options: ICancelRoomPKOptions): Promise<ErrorCode>;
|
|
978
|
-
responseRoomPK(options: IResRoomPKOptions): Promise<ErrorCode>;
|
|
979
|
-
endRoomPK(options: IEndRoomPKOptions): Promise<ErrorCode>;
|
|
980
|
-
bindRTCRoomForChatroom(options: IRTCRoomBindOption): Promise<ErrorCode>;
|
|
981
805
|
}
|
|
982
806
|
|
|
983
807
|
declare const _default: (options: {
|
package/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{platform as e,arch as t}from"os";import{resolve as n}from"path";import{Logger as o,ConnectionStatus as r,LogLevel as i,logger as s,ErrorCode as a,ConversationType as c,LogTagId as u,SEND_MESSAGE_TYPE_OPTION as p,isObject as l,isUndefined as d,pushJSONToConfigs as f,MessageDirection as C,NotificationStatus as g,MessageType as h,pushConfigsToJSON as _,MentionedType as v,ReceivedStatus as S,isArray as y,getUploadFileName as m,RTCJoinType as P,RTCApiType as E,LiveType as R}from"@rongcloud/engine";import{ipcMain as T,app as I}from"electron";import{existsSync as N,readFileSync as O,writeFileSync as U}from"fs";import{createHash as M}from"crypto";import{request as L}from"http";import{Agent as b,request as x}from"https";var w=process.versions.electron.replace(/\.\d+$/,""),D=n(__dirname,"binding","electron-v".concat(w,"-").concat(e(),"-").concat(t(),".node")),A=null;try{A=require(D)}catch(e){console.error("error ->",D,"\n",e)}var J=A,k=function(){return k=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},k.apply(this,arguments)};function B(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function H(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function F(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var j,K=new o("RCMain"),V=null,W=function(){var n,o=Date.now(),r=[t(),e(),process.pid,o,Math.floor(Math.random()*o)].join("__");return n=r,M("md5").update(n).digest("hex")},G=function(e){if(V)return V;var t=n(e,"deviceId");return K.debug("deviceIdPath -> ".concat(t)),N(t)?V=O(t).toString():(V=W(),K.debug("createDeviceId -> ".concat(V)),U(t,V),V)},q=function(){function e(e,t){this._timerId=0,this._heartbeatTimeoutId=0,this._isFirstPing=!0,this._lossCount=0,this._hasPingRes=e,this._reconnect=t}return e.init=function(t,n){return j?(j.stop(),j):j=new e(t,n)},e.prototype.start=function(e){var t=this,n=this,o=function(){var r=t._isFirstPing?0:15e3;n._timerId=setTimeout((function(){n._isFirstPing=!1,K.debug("current lossCount: "+n._lossCount),n._hasPingRes?(e(),n._hasPingRes=!1,o()):n._lossCount<4?(n._lossCount++,e(),o()):n._reconnect()}),r)};o()},e.prototype.stop=function(){this._lossCount=0,clearTimeout(this._timerId)},e.prototype.setHeartbeatRes=function(e){K.debug("receive ping"),this._hasPingRes=e,this._lossCount=0},e}(),Y=function(){function e(e){this._setTime=15962112e5,this._cppProto=e}return e.prototype._setToProtocol=function(e,t,n,o,r){var i=JSON.stringify(o);K.info("MsgExpansion._setToProtocol ===>",e,t,n,i,r),this._cppProto.setMessageExtension(e,t,n,i,r)},e.prototype.setLocalFromReceiveMsg=function(e){K.info("MsgExpansion.setLocalFromReceiveMsg ===>",e);var t=e.channelId,n=e.conversationType,o=e.targetId,r=e.messageUId,i=e.expansion,s=e.sentTime,a={};for(var c in i)a[c]={v:"",ts:0},a[c].v=i[c],a[c].ts=s;this._setToProtocol(n,o,r,a,t||"")},e.prototype.setLocalFromExtMsg=function(e){K.info("MsgExpansion.setLocalFromExtMsg ===>",e);var t=e.channelId,n=e.conversationType,o=e.targetId;e.messageUId;var r=e.content,i=e.sentTime,s=r,a=s.put,c=this._cppProto.getMessage(s.mid),u=JSON.parse(c).extMsg,p=JSON.parse(u||"{}");if(K.info("MsgExpansion.setLocalFromExtMsg, serverExtObj",a,"localExt",p),a)for(var l in a){var d=p[l];d&&d.ts<i-this._setTime?(d.v=a[l],d.ts=i-this._setTime):(p[l]={v:"",ts:0},p[l].v=a[l],p[l].ts=i-this._setTime)}s.del&&s.del.forEach((function(e){delete p[e]})),this._setToProtocol(n,o,s.mid,p,t||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),n={};for(var o in t)n[o]=t[o].v;return n},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),n=JSON.parse(t||"{}"),o={};for(var r in n)o[r]=n[r].v;return o},e}(),X=function(e){var t=[];return JSON.parse(e).list.forEach((function(e){t.push(JSON.parse(e.obj))})),t},z=function(e){return JSON.parse(e).list.map((function(e){return{key:Object.keys(e)[0],value:Object.values(e)[0]}}))},Q=null;function $(e,t,n,o,r){return void 0===r&&(r=!0),B(this,void 0,void 0,(function(){var i;return H(this,(function(s){switch(s.label){case 0:return Q?[2,Q]:(Q=function(e,t,n,o,r){return void 0===r&&(r=!0),B(this,void 0,void 0,(function(){var i,s,a,c;return H(this,(function(u){switch(u.label){case 0:i=function(i,s){var a,c,u,p,l;return H(this,(function(s){switch(s.label){case 0:return a="".concat(t[i],"/navi.json?r=").concat(Date.now()),c="token=".concat(encodeURIComponent(o),"&v=").concat((d=e,d.match(/\d+(\.\d+){2}/)[0]),"&p=PC&ev=").concat("5.4.4"),K.info("request navi -> url: ".concat(a,", body: ").concat(c)),[4,new Promise((function(e){var t=/^https/.test(a),o={headers:{appId:n},method:"POST"};t&&(o.rejectUnauthorized=r,o.agent=new b(o));var i=(t?x:L)(a,o,(function(t){var n=t.statusCode,o="";t.setEncoding("utf8"),t.on("data",(function(e){o+=e})),t.on("end",(function(){e({status:n||0,data:o})}))}));i.on("error",(function(t){K.error(t),e({status:0})})),i.write(c),i.end()}))];case 1:if(200!==(u=s.sent()).status)return K.error("request navi failed -> ".concat(a)),u.data&&K.error(u.data),[2,"continue"];K.info("request navi success -> ".concat(a));try{return p=JSON.parse(u.data),l=/^https/.test(a)?"https":"http",p.protocol=l,[2,{value:p}]}catch(e){K.error("parse navi err => ".concat(u.data))}return[2]}var d}))},s=0,a=t.length,u.label=1;case 1:return s<a?[5,i(s,a)]:[3,4];case 2:if("object"==typeof(c=u.sent()))return[2,c.value];u.label=3;case 3:return s+=1,[3,1];case 4:return[2,null]}}))}))}(e,t,n,o,r),[4,Q]);case 1:return i=s.sent(),Q=null,[2,i]}}))}))}var Z=function(){function e(e,t,n){void 0===t&&(t=""),void 0===n&&(n=!1);var o=this;this._cppProtocol=e,this._dbpath=t,this._reconnectKickEnable=n,this._currentToken="",this._connectionStatus=r.DISCONNECTED,this._promiseHandler={},this._customMessageType={},this._heartbeat={},this._cppConnectionStatus=r.DISCONNECTED,this._connectedTime=0,this._currentUserId="",this._inited=!1,this._naviInfo=null,this._version="5.4.4",this._electronLogger={debug:this._superElectronLog.bind(this,"debug",i.DEBUG),info:this._superElectronLog.bind(this,"info",i.INFO),warn:this._superElectronLog.bind(this,"warn",i.WARN),error:this._superElectronLog.bind(this,"error",i.ERROR),fatal:this._superElectronLog.bind(this,"fatal",i.FATAL)},this._logger={debug:this._superLog.bind(this,"debug",i.DEBUG),info:this._superLog.bind(this,"info",i.INFO),warn:this._superLog.bind(this,"warn",i.WARN),error:this._superLog.bind(this,"error",i.ERROR),fatal:this._superLog.bind(this,"fatal",i.FATAL)},this._senders={},T.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return B(o,void 0,void 0,(function(){var o,r,i,s;return H(this,(function(c){switch(c.label){case 0:if((s=this._electronLogger).debug.apply(s,F(["__RC_CHANNEL_CALL_MAIN_SYNC__",t],n,!1)),"function"!=typeof(o=this[t]))return e.returnValue=a.NOT_SUPPORT,[2];r=a.EXTRA_METHOD_UNDEFINED,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,o.call.apply(o,F([this],n,!1))];case 2:return r=c.sent(),[3,4];case 3:return i=c.sent(),this._electronLogger.error("call main process method `".concat(t,"` failed.")),this._electronLogger.error(i),[3,4];case 4:return e.returnValue=r,[2]}}))}))})),T.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];return B(o,void 0,void 0,(function(){var o,i,s,c,u,p=this;return H(this,(function(l){switch(l.label){case 0:if((u=this._electronLogger).debug.apply(u,F(["__RC_CHANNEL_CALL_MAIN__",t,n],r,!1)),"function"!=typeof(o=this[n]))return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,a.NOT_SUPPORT),[2];"sendMessage"===n&&(i=r[3],r[3]=function(t){p._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",i,t)}),s=a.EXTRA_METHOD_UNDEFINED,l.label=1;case 1:return l.trys.push([1,3,,4]),[4,o.call.apply(o,F([this],r,!1))];case 2:return s=l.sent(),[3,4];case 3:return c=l.sent(),this._electronLogger.error("call main process method `".concat(n,"` failed.")),this._electronLogger.error(c),[3,4];case 4:return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,s),[2]}}))}))})),T.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];(n=o._electronLogger).debug.apply(n,F(["__RC_CHANNEL_CALL_MAIN__",t],r,!1));var s=o[t];if("function"==typeof s)try{s.call.apply(s,F([o],r,!1))}catch(e){o._electronLogger.error("call main process method `".concat(t,"` failed.")),o._electronLogger.error(e)}else o._electronLogger.error("cannot not found method: ".concat(t))})),T.on("__RC_INNER_COMMAND_INIT__",this._init.bind(this)),this._msgExpansionHandler=new Y(this._cppProtocol)}return e.prototype._callCppProxy=function(e){for(var t,n,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];try{return(t=this._cppProtocol)[e].apply(t,o)}catch(t){(n=this._electronLogger).error.apply(n,F([t,e],o,!1))}},e.prototype._superElectronLog=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];if(K[e]&&K[e].apply(K,n),t!==i.DEBUG){var r=Object.keys(this._senders);if(r.length>0){var s=n.reduce((function(e,t){return e+JSON.stringify(t)}),"");this._senders[r[0]].send("__RC_CHANNEL_CALL_RENDER__","_insertLog2IndexDB",t,s,"RCMain")}}},e.prototype._superLog=function(e,t,n,o,r){if(s[e]&&s[e](n,o,r),t!==i.DEBUG){var a=Object.keys(this._senders);a.length>0&&this._senders[a[0]].send("__RC_CHANNEL_CALL_RENDER__","_insertLog2IndexDB",t,o,n,null==r?void 0:r.logSource)}},e.prototype.getCppProto=function(){return this._cppProtocol},e.prototype.callExtra=function(e){for(var t,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];(t=this._electronLogger).info.apply(t,F(["callExtra -> ".concat(e)],n,!1));var r=this[e];if(!r)return this._electronLogger.warn("ExtraHandler.".concat(e," is undefined")),Promise.resolve({code:a.EXTRA_METHOD_UNDEFINED});try{return r.call.apply(r,F([this],n,!1))}catch(e){this._electronLogger.error(e)}return Promise.resolve({code:a.MAIN_PROCESS_ERROR})},e.prototype.getConversationsByPage=function(e,t,n,o){var r,i=this,s=this._callCppProxy("getConversationListByPage",e,t,n,o||"");try{r=JSON.parse(s).list.map((function(e){return i._buildConversation(e.obj)}))}catch(e){return this._electronLogger.error(e),Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:r})},e.prototype.getConversationListWithAllChannel=function(){var e,t=this,n=[c.PRIVATE,c.GROUP],o=this._callCppProxy("getConversationListWithAllChannel",n);try{e=JSON.parse(o).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return this._electronLogger.error(e),Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:e})},e.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,o=this,r=[c.PRIVATE,c.GROUP],i=this._callCppProxy("getConversationListWithAllChannelByPage",r,e,t);try{n=JSON.parse(i).list.map((function(e){return o._buildConversation(e.obj)}))}catch(e){return this._electronLogger.error(e),Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:n})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,n,o,r,i,s){var c=0===i,u=o+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,u,r,c,s||""),l=[];try{var d=JSON.parse(p).list;d.reverse();for(var f=0;f<d.length;f++){var C=this._buildMessage(d[f].obj);l[f]=C}}catch(e){return this._electronLogger.error(e),Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:{list:u===l.length?l.slice(1,u):l,hasMore:o<l.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,n,o){void 0===o&&(o=""),this._electronLogger.info("updateMessageReceiptStatus ->",e,t,n,o);var r=this._callCppProxy("updateMessageReceiptStatus",e,t,n,o);return Promise.resolve({code:a.SUCCESS,data:r})},e.prototype.requestNaviInfo=function(e,t,n,o){return B(this,void 0,void 0,(function(){return H(this,(function(r){return[2,$(this._initOptions.apiVersion,e,t,n,o)]}))}))},e.prototype.getNaviInfoFromCache=function(){return this._naviInfo},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){var e;return(null===(e=this._naviInfo)||void 0===e?void 0:e.userId)||""},e.prototype._send2Renderer=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,F([t],n,!1))},e.prototype._send2AllRenderer=function(e,t,n){var o=this;void 0===n&&(n=[]),Object.keys(this._senders).forEach((function(r){var i=o._senders[r];n.includes(i)||o._send2Renderer(i,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype._init=function(e,t){var o=this,r=e.sender,i=r.id;if(this._senders[i]||(this._senders[i]=r,r.once("destroyed",(function(){delete o._senders[i]}))),!this._inited){this._inited=!0,this._initOptions=t,this._electronLogger.info("init ->",t);var s=this._dbpath||n(I.getPath("userData"));this._logger.info(u.P_INIT_O,{"proto-commitId":this._cppProtocol.getNodeVersion(),appkey:t.appkey,dbpath:s}),this._callCppProxy("initWithAppkey",t.appkey,s),this._electronLogger.warn("cppProto version ->",this._cppProtocol.getNodeVersion()),this._registerMsgTypes();var a=G(s);this._electronLogger.info("deviceId -> ".concat(a)),this._callCppProxy("setDeviceId",a),this._setConnectionStatusListener(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener()}},e.prototype._registerMsgTypes=function(){for(var e in p["RC:RcCmd"]={isCounted:!1,isPersited:!1},p){var t=p[e],n=t.isCounted,o=0;t.isPersited&&(o|=1),n&&(o|=2),"RC:TypSts"===e&&(o=16),this._electronLogger.info("_registerMsgTypes ====>",e,o),this._callCppProxy("registerMessageType",e,o)}},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,o=t.buildFrom,r=JSON.parse(e);this._electronLogger.debug("_buildMessage:",r);var i=r.channelId,s=r.conversationType,a=r.targetId,c=r.senderUserId,u=r.content,g=r.objectName,h=r.messageUid,_=r.direction,v=r.status;r.source;var S=r.messageId,y=r.sentTime,m=r.readReceiptRequest,P=r.supportExt;r.extMsg;var E,R=r.pushContent,T=r.pushTitle,I=r.pushId,N=r.pushConfig,O=r.templateId,U=r.disableTitle,M=r.forcePushDetail;if(l(u))E=u;else try{E=u?JSON.parse(u):u}catch(e){K.warn("cpp engine build messaga error:",e),E=u}var L={isCounted:!1,isPersited:!1};g in p?L=p[g]:g in this._customMessageType&&(L=this._customMessageType[g]);var b=null;P&&(b=this._msgExpansionHandler.parseReceiveExpansion(r),"conversation"!==o&&"history"!==o||(b=this._msgExpansionHandler.parseConverOrHisExpansion(r)));var x=d(n)?y<this._connectedTime:n,w={};N&&(w=f(N,I));var D=k(k({},w),{pushTitle:T,pushContent:R,pushData:R,disablePushTitle:U,forceShowDetailContent:M,templateId:O}),A={channelId:i,conversationType:s,targetId:a,senderUserId:c,content:E||{},messageType:g,messageUId:h,messageDirection:_,isOffLineMessage:x,sentTime:y,receivedTime:0,isPersited:L.isPersited,isCounted:L.isCounted,isMentioned:!1,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:P,expansion:P?b:null,receivedStatus:v,messageId:S,pushConfig:D};if(_===C.RECEIVE?A.receivedStatus=v:_===C.SEND&&(A.sentStatus=v),m){var J=JSON.parse(m),B=J.hasRespond,H=J.readerInfo,F={hasRespond:B,readCount:J.readCount,totalCount:J.totalCount},j=[];if(H)for(var V in H)j.push({userId:V,readTime:H[V]});F.readerList=j,A.readReceiptInfo=F}return A},e.prototype._updateReadReceiptInfo=function(e,t){var n=this._callCppProxy("getMessage",e),o=JSON.parse(n),r=o.readReceiptRequest?JSON.parse(o.readReceiptRequest):{},i=k(k({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(i))},e.prototype._buildConversation=function(e){var t=JSON.parse(e);this._electronLogger.debug("_buildConversation",t);var n=t.channelId,o=t.conversationType,r=t.targetId,i=t.unreadCount,s=t.lastestMsg,a=t.isTop,c=t.isBlocked,u=t.matchCount,p=c?g.OPEN:g.CLOSE;return{channelId:n,conversationType:o,targetId:r,unreadMessageCount:i,latestMessage:-1===JSON.parse(s).messageId?null:this._buildMessage(s),hasMentioned:!1,mentionedInfo:null,notificationStatus:p,isTop:a,lastUnreadTime:0,matchCount:u}},e.prototype._sendConnectionStatus2Renderer=function(e){this._send2AllRenderer("status",e)},e.prototype._convertResultList=function(e,t){var n=JSON.parse(e).list;return n=n.map((function(e){var n=JSON.parse(e.obj);return t?t(n):n}))},e.prototype._connectResolve=function(e){this._promiseHandler.connect&&this._promiseHandler.connect.length>0&&(this._promiseHandler.connect.forEach((function(t){t.resolve(e)})),delete this._promiseHandler.connect)},e.prototype._setConnectionStatusListener=function(){var e=this;this._cppProtocol.setConnectionStatusListener((function(t){var n;switch(e._electronLogger.warn("protocol connection status changed:",t),e._cppConnectionStatus=t,t){case 10:n=r.CONNECTING;break;case 31004:return void setTimeout((function(){e._connectResolve(a.RC_CONN_USER_OR_PASSWD_ERROR)}));case 12:n=r.DISCONNECTED;break;case 13:n=r.BLOCKED,setTimeout((function(){e._connectResolve(a.RC_CONN_USER_BLOCKED)}));break;case 31023:n=r.FORBID_RECONNECT_BY_OTHER_SAME_CLIENT,setTimeout((function(){e._connectResolve(a.RC_DISCONN_SAME_CLIENT_ON_LINE)}));break;case 1:case 9:case 11:case 31011:case 3e4:case 30002:n=r.NETWORK_UNAVAILABLE;break;case 30010:n=r.NETWORK_UNAVAILABLE,setTimeout((function(){e._connectionStatus===r.NETWORK_UNAVAILABLE&&e._doConnect()}),5e3);break;case 0:case 33005:n=r.CONNECTED,e._connectedTime=Date.now()-e._cppProtocol.getDeltaTime(),setTimeout((function(){e._connectResolve(a.SUCCESS),e._heartbeat=q.init(!0,e._handleHeartTimeout.bind(e)),e._heartbeat.start(e._sendHeartbeat.bind(e))}));break;case r.KICKED_OFFLINE_BY_OTHER_CLIENT:n=r.KICKED_OFFLINE_BY_OTHER_CLIENT;break;case 30004:return;case 8:case 31006:case 32061:case 32012:n=r.REDIRECT;break;default:n=t}n!==r.CONNECTED&&e._heartbeat&&e._heartbeat.stop&&e._heartbeat.stop(),e._connectionStatus=n,e._logger.info(u.P_CONNECT_S,{status:t}),e._sendConnectionStatus2Renderer(n)}),this._dbOpenCallback,(function(){e._heartbeat.setHeartbeatRes(!0)}))},e.prototype._handleHeartTimeout=function(){var e=this;K.warn("network unavailable! try to reconnect!"),this._sendConnectionStatus2Renderer(r.NETWORK_UNAVAILABLE),this._heartbeat.stop(),setTimeout((function(){return e._doConnect()}),5e3)},e.prototype._dbOpenCallback=function(e){K.info("Sqlite DB Open -> ".concat(e))},e.prototype._sendHeartbeat=function(){K.debug("send ping"),this._cppProtocol.sendHeartbeat()},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,o,r){var i=e._buildMessage(t,{isOffLineMessage:o});if(i.messageType===h.GROUP_READ_RECEIPT_REQUEST){var s=i.content,a=s.msgId,c=s.rrn,u=s.tmn;e._updateReadReceiptInfo(a,{readCount:c,totalCount:u})}if("RC:MsgExMsg"===i.messageType)return e._msgExpansionHandler.setLocalFromExtMsg(i),void e._sendMessageExpansion(i);if(i.canIncludeExpansion&&e._msgExpansionHandler.setLocalFromReceiveMsg(i),i.messageType===h.SYNC_READ_STATUS){if(i.senderUserId!==e._currentUserId)return;e._callCppProxy("clearUnreadCountByTimestamp",i.conversationType,i.targetId,i.content.lastMessageSendTime,i.channelId||"")}var p=!0;if(0!==n||r||(p=!1),i.messageType!==h.LOG_COMMAND||"rongcloudsystem"!==i.senderUserId){var l=i.conversationType,d=i.targetId;i.messageType===h.RECALL&&i.senderUserId===e._currentUserId&&(l=i.content.conversationType||l,d=i.content.targetId||d),e._sendMessageNotification(Object.assign(i,{hasMoreMsg:p,conversationType:l,targetId:d}))}else{var f=Object.keys(e._senders).map((function(t){return e._senders[t]}));f.length>0&&e._sendMessageNotification(Object.assign(i,{hasMoreMsg:p}),f.slice(1))}}),(function(){e._sendPullOfflineFinished()}))},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var n=e.channelId,o=e.content,r=o.put,i=o.del,s=o.mid,a={};r&&(a.updatedExpansion={channelId:n,messageUId:s,expansion:r}),i&&(a.deletedExpansion={channelId:n,messageUId:s,deletedKeys:i}),this._send2AllRenderer("expansion",a,t)},e.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},e.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},e.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var n=JSON.parse(t).list,o=[];n.forEach((function(e){var t=JSON.parse(e.obj),n=t.conversationType,r=t.targetId,i=t.status,s=t.channelId,a={notificationStatus:2,isTop:!1};i.forEach((function(e){var t=JSON.parse(e.item);1===t.type?a.notificationStatus=1===Number(t.value)?g.OPEN:g.CLOSE:a.isTop=1===Number(t.value)})),o.push({channelId:s,conversationType:n,targetId:r,updatedItems:{notificationStatus:{val:a.notificationStatus,time:0},isTop:{val:a.isTop,time:0}}})})),e._send2AllRenderer("conversation",o)}),(function(t){e._electronLogger.info("会话标签状态变更",t),e._send2AllRenderer("conversationTag",t)}))},e.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._electronLogger.info("标签变更",t),e._send2AllRenderer("tag",t)}))},e.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){K.info("RTC Room Data Change:",t);var n=JSON.parse(t).list.map((function(e){var t=JSON.parse(e.obj);return{key:t.key,value:t.value,uid:t.operator,timestamp:t.version,status:t.isDeleted?1:0,roomId:t.roomId||""}}));e._send2AllRenderer("onRTCDataChange",n)}))},e.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,n){e._send2AllRenderer("chatroom",{chatroomDestroyed:t})}))},e.prototype._clearListener=function(){this._cppProtocol.setOnReceiveMessageListener(),this._cppProtocol.setConnectionStatusListener(),this._cppProtocol.setOnReceiveStatusListener(),this._cppProtocol.setUserProfileListener()},e.prototype.registerMessageType=function(e,t,n,o){var r=0;t&&(r|=1),n&&(r|=2),this._customMessageType[e]={isCounted:n,isPersited:t},this._logger.info(u.P_REGTYP_O,{messageType:e,isCounted:n,searchProps:o,isPersited:t}),this._callCppProxy("registerMessageType",e,r,o)},e.prototype.connect=function(e,t,n,o){var i=this;return this._electronLogger.info("connect ->",e,t,n),this._logger.info(u.P_CONNECT_O,{token:e,reconnectKickEnable:n,version:this._version},{traceId:o}),this._currentToken===e&&this._connectionStatus===r.CONNECTED?(this._sendConnectionStatus2Renderer(this._connectionStatus),Promise.resolve(a.SUCCESS)):(this._currentToken=e,this._naviInfo=t,this._currentUserId=t.userId,!this._promiseHandler.connect&&this._doConnect(n),new Promise((function(e,t){i._promiseHandler.connect?i._promiseHandler.connect.push({resolve:e,reject:t}):i._promiseHandler.connect=[{resolve:e,reject:t}]})))},e.prototype._doConnect=function(e){var t=d(e)?this._reconnectKickEnable:e;this._callCppProxy("connectWithToken",this._currentToken,this._initOptions.apiVersion,JSON.stringify(this._naviInfo),t)},e.prototype.reportSDKInfo=function(e){this._cppProtocol.uploadSDKVersion&&this._cppProtocol.uploadSDKVersion(JSON.stringify(e)),this._electronLogger.info(e)},e.prototype.disconnect=function(){this._cppProtocol.disconnect(!0),this._heartbeat.stop(),this._connectResolve(a.TIMEOUT)},e.prototype.logout=function(){this.disconnect()},e.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,n){t({userId:e,status:n})}));var n=e.userIds||[];n.length&&this.subscribeUserStatus(n)},e.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("subscribeUserStatus",e,(function(){n(a.SUCCESS)}),n)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("setUserStatus",e,(function(){n(a.SUCCESS)}),n)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getUserStatus",e,(function(e){n({code:a.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},e.prototype.sendMessage=function(e,t,n,o,r){var i=this,s=n.messageType,p=n.content,l=n.pushContent,d=n.pushData,f=n.directionalUserIdList,C=n.disableNotification,g=n.canIncludeExpansion,S=n.expansion,y=n.isVoipPush,m=n.pushConfig,P=n.channelId,E=n.isMentioned,R=n.mentionedType,T=n.mentionedUserIdList,I=m||{},N=I.iOSConfig,O=I.androidConfig,U=I.pushTitle,M=I.pushContent,L=I.pushData,b=I.disablePushTitle,x=I.forceShowDetailContent,w=I.templateId,D=_(N,O);return new Promise((function(n){l=M||l||"",d=L||d||"",C=C||!1,y=y||!1,U=U||"",M=M||"",L=L||"",b=b||!1,x=x||!1,g=g||!1;var _=(null==O?void 0:O.notificationId)||"";if(f=f||[],P=P||"",e===c.GROUP&&E&&p&&(p.mentionedInfo={userIdList:T,type:R||v.ALL}),e===c.GROUP&&s===h.READ_RECEIPT_RESPONSE&&p.receiptMessageDic)for(var m in p.receiptMessageDic)f.push(m);var I={};for(var m in S)I[m]={v:""},I[m].v=S[m];var N=w||"";i._logger.info(u.P_SEND_MSG_T,{messageType:s,conversationType:e,targetId:t,channelId:P},{traceId:r});var A=i._callCppProxy("sendMessage",(function(e,t){var o=i._buildMessage(e,{isOffLineMessage:!1});return i._logger.info(u.P_SEND_MSG_R,{code:t,messageUId:o.messageUId,messageId:o.messageId},{traceId:r}),t===a.SENSITIVE_REPLACE?n({code:t}):("RC:MsgExMsg"===o.messageType&&i._msgExpansionHandler.setLocalFromExtMsg(o),o.canIncludeExpansion&&i._msgExpansionHandler.setLocalFromReceiveMsg(o),n({code:a.SUCCESS,data:o}))}),(function(e,t){var o=i._buildMessage(e,{isOffLineMessage:!1});return i._logger.warn(u.P_SEND_MSG_R,{code:t,messageUId:o.messageUId,messageId:o.messageId},{traceId:r}),o.sentTime=Date.now()-i._cppProtocol.getDeltaTime(),n({code:t,data:o})}),e,t,s,JSON.stringify(p),f,C,b,x,l,d,_,U,D,N,g,JSON.stringify(I),y,P),J=JSON.parse(A);o&&o(J.messageId)}))},e.prototype.recallMsg=function(e,t,n,o,r){var i=this;return new Promise((function(s,c){var u,p=r.user,l=r.pushContent,d=r.channelId,f=r.extra,g=r.pushConfig,v=r.disableNotification,y=r.isDelete,m={conversationType:e,targetId:t,messageUId:n,sentTime:o,user:p,extra:f,channelId:d,isDelete:y||!1};p&&(m.user=p),f&&(m.extra=f);var P={conversationType:e,targetId:t,senderUserId:i._currentUserId,content:m,objectName:h.RECALL,messageUid:n,direction:C.SEND,status:S.UNREAD,sentTime:o,channelId:d},E=i._buildMessage(JSON.stringify(P),{isOffLineMessage:!1});i._callCppProxy("recallMessage",(function(){s({code:a.SUCCESS,data:E})}),(function(e){s({code:e})}),h.RECALL,JSON.stringify(m),v||!1,(null==g?void 0:g.disablePushTitle)||!1,(null==g?void 0:g.forceShowDetailContent)||!1,l||"",(null==g?void 0:g.pushData)||"",(null===(u=null==g?void 0:g.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==g?void 0:g.pushTitle)||"",_(null==g?void 0:g.iOSConfig,null==g?void 0:g.androidConfig),(null==g?void 0:g.templateId)||"",d)}))},e.prototype.getHistoryMessage=function(e,t,n,o,r,i,s){var c=this;return new Promise((function(u,p){n=n||0;var l=0===r,d=o+1,f=c._callCppProxy("getHistoryMessages",e,t,n,d,s,l,i),C=JSON.parse(f).list,g=[];C.reverse();for(var h=0;h<C.length;h++){var _=c._buildMessage(C[h].obj);g[h]=_}u({code:a.SUCCESS,data:{list:d===g.length?g.slice(1,d):g,hasMore:o<g.length}})}))},e.prototype.getRemoteHistoryMessages=function(e,t,n,o,r,i){var s=this;return new Promise((function(c,u){n=n||0;s._callCppProxy("getRemoteHistoryMessages",e,t,n,o,(function(e,t){var n=JSON.parse(e).list,o=[];n.reverse();for(var r=0;r<n.length;r++){var i=s._buildMessage(n[r].obj);o[r]=i}c({code:a.SUCCESS,data:{list:o,hasMore:!!t}})}),(function(e){c({code:e})}),r,!0,i)}))},e.prototype.deleteRemoteMessage=function(e,t,n,o){var r=this;return new Promise((function(i,s){var c=JSON.stringify(n);r._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,o,(function(){i(a.SUCCESS)}),i)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(i,s){r._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){i(a.SUCCESS)}),(function(e){i(e)}),o)}))},e.prototype.clearMessages=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("clearMessages",e,t,n),r(a.SUCCESS)}))},e.prototype.getConversationList=function(e,t,n,o,r){var i=this;return void 0===r&&(r=""),new Promise((function(e,t){for(var n=i._callCppProxy("getConversationList",[1,3,6,7],r),o=JSON.parse(n).list,s=[],c=0;c<o.length;c++)s.push(i._buildConversation(o[c].obj));e({code:a.SUCCESS,data:s})}))},e.prototype.getConversation=function(e,t,n){var o=this;return new Promise((function(r,i){var s=o._callCppProxy("getConversation",e,t,n);if(s)r({code:a.SUCCESS,data:o._buildConversation(s)});else{var c=o._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),u=void 0;try{u=JSON.parse(c).list}catch(e){o._electronLogger.warn("json parse cppMessagaes error",e),u=[]}var p=null;u.length>0&&(p=o._buildMessage(u[0].obj));var l=o._callCppProxy("getConversationNotificationStatus",e,t,n),d=o._callCppProxy("getConversationTopStatus",e,t,n);r({code:a.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:p,notificationStatus:l?g.OPEN:g.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,n){var o=this._callCppProxy("removeConversation",e,t,n);return this._electronLogger.info("removeConversation result -> ".concat(o)),Promise.resolve(o?a.SUCCESS:a.UNKNOWN)},e.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(o,r){var i=[];i=y(e)?e:[c.PRIVATE,c.GROUP,c.SYSTEM,c.PUBLIC_SERVICE],n._callCppProxy("clearConversations",i,t),o(a.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,n){var o=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:a.SUCCESS,data:o})},e.prototype.getConversationUnreadCount=function(e,t,n){var o=this;return void 0===n&&(n=""),new Promise((function(r){var i=o._callCppProxy("getUnreadCount",e,t,n);r({code:a.SUCCESS,data:i})}))},e.prototype.clearConversationUnreadCount=function(e,t,n){var o=this;return void 0===n&&(n=""),new Promise((function(r,i){o._callCppProxy("clearUnreadCount",e,t,n),r(a.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(i,s){r._callCppProxy("clearUnreadCountByTimestamp",e,t,n,o),i(a.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,n){var o=this;return new Promise((function(r,i){var s=o._callCppProxy("getTheFirstUnreadMessage",e,t,n),c=o._buildMessage(s);r({code:a.SUCCESS,data:-1!==c.messageId?c:null})}))},e.prototype.setConversationToTop=function(e,t,n,o){var r=this;return void 0===o&&(o=""),new Promise((function(i,s){r._electronLogger.info("setConversationToTop",e,t,n,o,true),r._callCppProxy("setConversationToTop",e,t,n,o,true),i(a.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,n,o){var r=this;return new Promise((function(i,s){r._callCppProxy("setConversationHidden",e,t,n,o),i(a.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,n,o){var r=this;return new Promise((function(i,s){r._electronLogger.info("setConversationNotificationStatus",e,t,n,o),r._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){i(a.SUCCESS)}),i,o)}))},e.prototype.setConversationStatus=function(e,t,n,o,r){var i=this;return new Promise((function(s,c){i._electronLogger.info("setConversationStatus",e,t,n,o,r,true),i._callCppProxy("setConversationStatus",e,t,n,o,(function(){s(a.SUCCESS)}),s,r,true)}))},e.prototype.getConversationNotificationStatus=function(e,t,n){var o=this;return new Promise((function(r,i){var s=o._callCppProxy("getConversationNotificationStatus",e,t,n);r({code:a.SUCCESS,data:s?g.OPEN:g.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,n,o){var r=this;return new Promise((function(i,s){o=o||[1,3,6,7];for(var c=r._callCppProxy("searchConversationByContent",o,e,t,n),u=JSON.parse(c).list,p=[],l=0;l<u.length;l++)p[l]=r._buildConversation(u[l].obj);i({code:a.SUCCESS,data:p})}))},e.prototype.searchConversationByContentWithAllChannel=function(e,t,n){var o=this;return new Promise((function(r,i){n=n||[1,3,6,7];for(var s=o._callCppProxy("searchConversationByContentWithAllChannel",n,e,t),c=JSON.parse(s).list,u=[],p=0;p<c.length;p++)u[p]=o._buildConversation(c[p].obj);r({code:a.SUCCESS,data:u})}))},e.prototype.searchMessageByContent=function(e,t,n,o,r,i,s){var c=this;return new Promise((function(i,u){c._callCppProxy("searchMessageByContent",e,t,n,o,r,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],o=[],r=0;r<n.length;r++)o[r]=c._buildMessage(n[r].obj);i({code:a.SUCCESS,data:{messages:o,count:t}})}),s)}))},e.prototype.searchMessageByContentWithAllChannel=function(e,t,n,o,r){var i=this;return new Promise((function(s,c){i._callCppProxy("searchMessageByContentWithAllChannel",e,t,n,o,r,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],o=[],r=0;r<n.length;r++)o[r]=i._buildMessage(n[r].obj);s({code:a.SUCCESS,data:{messages:o,count:t}})}))}))},e.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(e,t,n,o,r,i,s){var c=this;return new Promise((function(u,p){c._callCppProxy("searchMessageByTimestampWithAllChannel",e,t,n,o,r,i,s,(function(e){for(var t=e?JSON.parse(e).list:[],n=[],o=0;o<t.length;o++)n[o]=c._buildMessage(t[o].obj);u({code:a.SUCCESS,data:{messages:n}})}))}))},e.prototype.getUnreadMentionedMessages=function(e,t,n){for(var o=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,n)).list,r=0;r<o.length;r++)o[r]=this._buildMessage(o[r].obj);return o},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("addToBlacklist",e,(function(){n(a.SUCCESS)}),n)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("removeFromBlacklist",e,(function(){n(a.SUCCESS)}),n)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){e._callCppProxy("getBlacklist",(function(e){t({code:a.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},e.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:a.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.insertMessage=function(e,t,n){var o=this,r=n.content,i=n.senderUserId,s=n.messageType,c=n.messageDirection,u=n.readStatus,p=n.sentStatus,l=n.sentTime,d=n.searchContent,f=n.isUnread,C=n.messageUId,g=n.disableNotification,h=n.canIncludeExpansion,_=n.expansionMsg,v=n.channelId;return r=JSON.stringify(r),new Promise((function(n,S){var y=f?0:1,m=o._callCppProxy("insertMessage",e,t,i,s,r,(function(){}),(function(e){n({code:e})}),c,u,p,l,d,y,C,g,h,_,v);o._electronLogger.info("after insert msg",m);var P=o._buildMessage(m,{isOffLineMessage:!1});P.messageUId=C,P.sentTime=l,n({code:-1===P.messageId?a.MSG_INSERT_ERROR:a.SUCCESS,data:P})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,o){t._logger.debug(u.P_DELETE_MSG_S,{messageIds:e}),t._callCppProxy("deleteMessages",e),n(a.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,n,o,r){var i=this;return new Promise((function(s,c){i._callCppProxy("deleteMessagesByTimestamp",e,t,n,o,r),s(a.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(n,o){var r=t._callCppProxy("getMessage",e);t._electronLogger.info("getMessage ===>",r);var i=t._buildMessage(r,{isOffLineMessage:!1});n({code:a.SUCCESS,data:i})}))},e.prototype.setMessageContent=function(e,t,n){var o=this;return new Promise((function(r,i){t=JSON.stringify(t),o._callCppProxy("setMessageContent",e,t,n),r(a.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("setMessageSearchField",e,t,n),r(a.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageSentStatus",e,t),o(a.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageReceivedStatus",e,t),o(a.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,n,o){throw new Error("Method not implemented.")},e.prototype.getConversationMessageDraft=function(e,t,n){throw new Error("Method not implemented.")},e.prototype.clearConversationMessageDraft=function(e,t,n){throw new Error("Method not implemented.")},e.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},e.prototype.batchSetConversationStatus=function(e){var t=e[0],n=t.conversationType,o=t.targetId,r=t.isTop,i=t.notificationStatus,s=t.channelId;if(void 0!==r&&void 0===i)return this.setConversationToTop(n,o,r,s);if(void 0!==i&&void 0===r){var a=i===g.OPEN;return this.setConversationNotificationStatus(n,o,a,s)}a=i===g.OPEN;return this.setConversationStatus(n,o,a,r,s)},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("sendReadReceipt",e,n||"",t,(function(){t.forEach((function(e){o._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(o._callCppProxy("getMessage",e)).messageId;o.setMessageReceivedStatus(t,1)}catch(t){o._electronLogger.warn("format message error, messageUId: "+e)}})),r({code:a.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getMessageReader=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("getMessageReader",e,n,t,(function(e,n){o._electronLogger.info("getMessageReader -> ",e,n);var i=[],s={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),n=t.id,o=t.time;i.push({userId:n,readTime:o}),s[n]=o}));var c={readerInfo:s,readCount:i.length,totalCount:n};o._updateReadReceiptInfo(t,c),r({code:a.SUCCESS,data:{list:i,totalMemberCount:n}})}),(function(e){r({code:e})}))}))},e.prototype.joinChatroom=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("clearMessages",c.CHATROOM,e,""),n._callCppProxy("joinChatRoom",e,t,(function(){o(a.SUCCESS)}),o)}))},e.prototype.joinExistChatroom=function(e,t){throw new Error("Method not implemented.")},e.prototype.quitChatroom=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("quitChatRoom",e,(function(){n(a.SUCCESS)}),n)}))},e.prototype.getChatroomInfo=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("getChatroomInfo",e,t,n,(function(e,t){var n=e?JSON.parse(e).list:[],o=[];if(n.length>0)for(var i=0;i<n.length;i++)o.push(JSON.parse(n[i].obj));r({code:a.SUCCESS,data:{userInfos:o,userCount:t}})}),(function(e){r({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,n,o){var r=this;return new Promise((function(i,s){r._callCppProxy("getChatroomHistoryMessage",e,t,n,o,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var n=t.list;if(n&&n.length)try{t.list=n.map((function(e){return r._buildMessage(e.obj)}))}catch(e){t.list=[]}i({code:a.SUCCESS,data:t})}),(function(e){i({code:e})}),"")}))},e.prototype.setChatroomEntry=function(e,t){var n=this;return new Promise((function(o,r){var i='[{"key":"'+t.key+'", "value":"'+t.value+'"}]';n._callCppProxy("setChatroomKV",e,i,!!t.isAutoDelete,!!t.isOverwrite,(function(){o(a.SUCCESS)}),(function(e){o(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var n=this,o=[t.key];return new Promise((function(r,i){n._callCppProxy("deleteChatroomKV",e,o,!!t.isOverwrite,(function(){r(a.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(o){var r=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return B(this,void 0,void 0,(function(){var n;return H(this,(function(o){switch(o.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=o.sent()).code===a.SUCCESS?[2,{code:a.SUCCESS,data:n.data?n.data[t]:null}]:[2,{code:n.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}n({code:a.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},e.prototype.getFileToken=function(e,t,n,o){var r=this;return n=n||"",o=o||"",new Promise((function(i){var s;s=o&&"uploads"!==o?t||"":m(e,t),r._callCppProxy("getUploadToken",e,s,n,o,(function(e,t,n,o,r,c,u,p,l,d,f,C,g,h,_,v,S,y){i({code:a.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:o,osskeyId:r,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:s,s3Credential:l,s3Algorithm:d,s3Date:f,s3Policy:C,s3Signature:g,s3BucketName:h,stcAuthorization:_,stcContentSha256:v,stcDate:S,stcBucketName:y}})}),(function(e){i({code:e})}))}))},e.prototype.getFileUrl=function(e,t,n,o){var r=this;return new Promise((function(i){r._callCppProxy("getDownloadUrl",e,n,o,t-1,(function(e){i({code:a.SUCCESS,data:{downloadUrl:e}})}),(function(e){i({code:e})}))}))},e.prototype.clearData=function(){var e=this;return new Promise((function(t,n){var o=e._callCppProxy("clearData");t({code:a.SUCCESS,data:o})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||n(I.getPath("userData"));return G(e)},e.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("getVoIPKey",e,t,"",(function(e){o({code:a.SUCCESS,data:e})}),(function(e){o({code:e})}))}))},e.prototype.joinRTCRoom=function(e,t,n,o,r,i){var s=this;return new Promise((function(c){var u=r?JSON.stringify(r):"",p=i?JSON.stringify(i):"";s._callCppProxy("joinRTCRoom",e,t,n||0,o||P.KICK,(function(e,t,n,o,r,i){var s=JSON.parse(e).list,u={token:t,sessionId:n,users:{},roomInfo:z(o),kvEntries:[],offlineKickTime:i};s.forEach((function(e){var t=e.id,n=e.data;u.users[t]=n[0]||{}})),c({code:a.SUCCESS,data:u})}),(function(e){s._electronLogger.error("joinRTCRoom error -> ".concat(e)),c({code:e})}),"","",u,p)}))},e.prototype.quitRTCRoom=function(e){var t=this;return new Promise((function(n){t._callCppProxy("exitRTCRoom",e,(function(){n(a.SUCCESS)}),n)}))},e.prototype.rtcPing=function(e,t,n){var o=this;return new Promise((function(t){o._callCppProxy("sendRTCPing",e,(function(){t(a.SUCCESS)}),t)}))},e.prototype.getRTCRoomInfo=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getRTCResouce",e,2,(function(e){n({code:a.SUCCESS,data:JSON.parse(e)})}),(function(e){n({code:e})}))}))},e.prototype.getRTCUserInfoList=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getRTCResouce",e,1,(function(e){var t=JSON.parse(e).list,o={users:{}};t.forEach((function(e){var t=e.id,n=e.data;o.users[t]=n[0]||{}})),n({code:a.SUCCESS,data:o})}),(function(e){n({code:e})}))}))},e.prototype.getRTCUserInfo=function(e){throw new Error("Method not implemented.")},e.prototype.setRTCUserInfo=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("setRTCInnerData",e,E.PERSON,t,n,"","",(function(){r(a.SUCCESS)}),r)}))},e.prototype.removeRTCUserInfo=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("deleteRTCInnerData",e,E.PERSON,t,"","",(function(){o(a.SUCCESS)}),o)}))},e.prototype.setRTCData=function(e,t,n,o,r,i){var s=this;return new Promise((function(c){var u={room_innder:function(e,t,n,o,r,i,a){s._callCppProxy("setRTCInnerData",e,E.ROOM,t,n,o,r,i,a)},room_outer:function(e,t,n,o,r,i,a){s._callCppProxy("setRTCOuterData",e,E.ROOM,t,n,o,r,i,a)},user_innder:function(e,t,n,o,r,i,a){s._callCppProxy("setRTCInnerData",e,E.PERSON,t,n,o,r,i,a)},user_outer:function(e,t,n,o,r,i,a){s._callCppProxy("setRTCOuterData",e,E.PERSON,t,n,o,r,i,a)}},p=E.PERSON===r?"user":"room",l=o?"inner":"outer",d=u["".concat(p,"_").concat(l)];if(d){var f=(null==i?void 0:i.content)?JSON.stringify(i.content):"",C=(null==i?void 0:i.name)||"";d(e,t,n,C,f,(function(){c(a.SUCCESS)}),(function(e){c(e)}))}}))},e.prototype.setRTCTotalRes=function(e,t,n,o,r){var i=this;return new Promise((function(s){var c=t.name,u=t.content;i._callCppProxy("setUserResource",e,c,u,o,n,r,(function(){return s(a.SUCCESS)}),s)}))},e.prototype.setRTCCDNUris=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("setRTCCDNUris",e,t,n,(function(){return r(a.SUCCESS)}))}))},e.prototype.getRTCData=function(e,t,n,o){var r=this;return new Promise((function(i){var s={room_inner:function(e,t,n,o){r._callCppProxy("getRTCInnerData",e,E.ROOM,t,n,o).getRTCInnerData()},room_outer:function(e,t,n,o){r._callCppProxy("getRTCOuterData",e,E.ROOM,t,n,o)}},c=E.PERSON===o?"user":"room",u=n?"inner":"outer",p=s["".concat(c,"_").concat(u)];p&&p(e,t,(function(e){var t=JSON.parse(e),n={};t.list.forEach((function(e){var t=Object.keys(e)[0],o=Object.values(e)[0];n[t]=o})),i({code:a.SUCCESS,data:n})}),(function(e){i({code:e})}))}))},e.prototype.removeRTCData=function(e,t,n,o,r){var i=this;return new Promise((function(s){i._callCppProxy;var c={room_inner:function(e,t,n,o,r,s){i._callCppProxy("deleteRTCInnerData",e,E.ROOM,t,n,o,r,s)},room_outer:function(e,t,n,o,r,s){i._callCppProxy("deleteRTCOuterData",e,E.ROOM,t,n,o,r,s)},user_inner:function(e,t,n,o,r,s){i._callCppProxy("deleteRTCInnerData",e,E.PERSON,t,n,o,r,s)},user_outer:function(e,t,n,o,r,s){i._callCppProxy("deleteRTCOuterData",e,E.PERSON,t,n,o,r,s)}},u=E.PERSON===o?"user":"room",p=n?"inner":"outer",l=c["".concat(u,"_").concat(p)];if(l){var d=(null==r?void 0:r.content)?JSON.stringify(r.content):"",f=(null==r?void 0:r.name)||"";l(e,t,f,d,(function(){s(a.SUCCESS)}),(function(e){s(e)}))}}))},e.prototype.setRTCOutData=function(e,t,n,o){throw new Error("Method not implemented.")},e.prototype.getRTCOutData=function(e,t){throw new Error("Method not implemented.")},e.prototype.getRTCToken=function(e,t,n){var o=this;return new Promise((function(t){o._callCppProxy("getRTCToken",e,(function(e){t({code:a.SUCCESS,data:{rtcToken:e}})}),(function(e){t({code:e})}))}))},e.prototype.setRTCState=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("setRTCUserState",e,t,(function(){o(a.SUCCESS)}),o)}))},e.prototype.getRTCUserList=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getRTCUsers",e,1,(function(e){n({code:a.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:a.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("deleteTag",e,(function(){n({code:a.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:a.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t,n){var o=e._callCppProxy("getTags");e._electronLogger.info("getTagList -> ",o);var r=e._convertResultList(o,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:a.SUCCESS,data:r})}))},e.prototype.addTagForConversations=function(e,t){var n=this;return new Promise((function(o,r){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(o,r){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,n,o){var r=this;return new Promise((function(i,s){var c=r._callCppProxy("getConversationsForTagByPage",e,t,n||20,o||"");r._electronLogger.info("getConversationListByTag -> ",c);var u=r._convertResultList(c,(function(e){return k(k({},r._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));i({code:a.SUCCESS,data:u})}))},e.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(o,r){var i=n._callCppProxy("getConversationUnreadCountForTag",e,t);n._electronLogger.info("getUnreadCountByTag -> ",i),o({code:a.SUCCESS,data:i})}))},e.prototype.setConversationStatusInTag=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.isTop||!1,(function(){r({code:a.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(n,o){var r=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||"");t._electronLogger.info("getTagsForConversation -> ",r);var i=t._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));n({code:a.SUCCESS,data:i})}))},e.prototype.joinLivingRoomAsAudience=function(e,t,n){return B(this,void 0,void 0,(function(){var n=this;return H(this,(function(o){return[2,new Promise((function(o,r){n._cppProtocol.audienceJoinRoom(e,t,(function(e,t){K.info("joinLivingRoomAsAudience data:",e,t),o({data:{token:e,kvEntries:X(t)},code:a.SUCCESS})}),(function(e){o({code:e})}))}))]}))}))},e.prototype.quitLivingRoomAsAudience=function(e){var t=this;return new Promise((function(n,o){t._cppProtocol.audienceLeaveRoom(e,(function(){n(a.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.switchLivingRoomRole=function(e,t,n){var o=this;return void 0===n&&(n=R.AUDIO_AND_VIDEO),new Promise((function(r,i){o._cppProtocol.switchRole(e,n,t,"","",(function(e,t,n,o,i,s){K.info("switchLivingRoomRole data:",e,t,n,o,i);var c=JSON.parse(e).list,u={token:t,sessionId:n,users:{},roomInfo:z(o),kvEntries:X(i),offlineKickTime:s};c.forEach((function(e){var t=e.id,n=e.data;u.users[t]=n[0]||{}})),r({code:a.SUCCESS,data:u})}),(function(e){r({code:e})}))}))},e.prototype.getRTCJoinedUserInfo=function(e){var t=this;return new Promise((function(e){t._callCppProxy("queryJoinedRoom",(function(n){t._electronLogger.info("getRTCJoinedUserInfo -> ",n);var o=JSON.parse(n).list[0];e(o?{code:a.SUCCESS,data:[JSON.parse(o.obj)]}:{code:a.SUCCESS})}),(function(t){e({code:t})}))}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},e.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},e.prototype.requestRoomPK=function(e){var t=this;return new Promise((function(n,o){var r=e.roomId,i=e.invitedRoomId,s=e.invitedUserId,c=e.inviteSessionId,u=e.inviteTimeout,p=e.inviteInfo;t._callCppProxy("livePKInvitation",r,s,i,p,c,u,(function(){n(a.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.cancelRoomPK=function(e){var t=this;return new Promise((function(n,o){var r=e.roomId,i=e.invitedRoomId,s=e.invitedUserId,c=e.inviteSessionId,u=e.inviteInfo;t._callCppProxy("livePKCancel",r,s,i,u,c,(function(){n(a.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.responseRoomPK=function(e){var t=this;return new Promise((function(n,o){var r=e.roomId,i=e.inviteUserId,s=e.inviteRoomId,c=e.inviteSessionId,u=e.content,p=e.key,l=e.value,d=e.agree?1:0;t._callCppProxy("livePKAnswer",r,d,i,s,c,u,p,l,(function(){n(a.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.endRoomPK=function(e){var t=this;return new Promise((function(n,o){var r=e.roomId,i=e.endRoomId,s=e.sessionId,c=e.content,u=e.keys;t._callCppProxy("livePKHangup",r,i,s,c,u,(function(){n(a.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n,o){var r=e.chatRoomId,i=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",r,i,(function(){n(a.SUCCESS)}),(function(e){n(e)}))}))},e}(),ee=function(e){return function(e,t){return s.init({customLogPrint:null==t?void 0:t.logStdout,localLogLevel:null==t?void 0:t.logLevel}),K.setLogLevel(null==t?void 0:t.logLevel),K.setLogStdout(null==t?void 0:t.logStdout),new Z(e,null==t?void 0:t.dbpath,null==t?void 0:t.reconnectKickEnable)}(J,e)};export{ee as default};
|
|
1
|
+
import{platform as e,arch as t}from"os";import{resolve as n}from"path";import{Logger as o,ConnectionStatus as r,LogLevel as s,logger as i,ErrorCode as a,ConversationType as c,LogTagId as u,SEND_MESSAGE_TYPE_OPTION as p,isObject as l,isUndefined as d,pushJSONToConfigs as f,MessageDirection as g,NotificationStatus as h,MessageType as _,pushConfigsToJSON as C,MentionedType as v,ReceivedStatus as S,isArray as y,getUploadFileName as m}from"@rongcloud/engine";import{ipcMain as E,app as P}from"electron";import{existsSync as T,readFileSync as R,writeFileSync as I}from"fs";import{createHash as N}from"crypto";import{request as M}from"http";import{Agent as L,request as b}from"https";var O=process.versions.electron.replace(/\.\d+$/,""),U=n(__dirname,"binding","electron-v".concat(O,"-").concat(e(),"-").concat(t(),".node")),x=null;try{x=require(U)}catch(e){console.error("error ->",U,"\n",e)}var w=x,A=function(){return A=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},A.apply(this,arguments)};function D(e,t,n,o){return new(n||(n=Promise))((function(r,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))}function H(e,t){var n,o,r,s,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,o=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){i.label=s[1];break}if(6===s[0]&&i.label<r[1]){i.label=r[1],r=s;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(s);break}r[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}}function B(e,t,n){if(n||2===arguments.length)for(var o,r=0,s=t.length;r<s;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var k,F=new o("RCMain"),J=null,j=function(){var n,o=Date.now(),r=[t(),e(),process.pid,o,Math.floor(Math.random()*o)].join("__");return n=r,N("md5").update(n).digest("hex")},K=function(e){if(J)return J;var t=n(e,"deviceId");return F.debug("deviceIdPath -> ".concat(t)),T(t)?J=R(t).toString():(J=j(),F.debug("createDeviceId -> ".concat(J)),I(t,J),J)},V=function(){function e(e,t){this._timerId=0,this._heartbeatTimeoutId=0,this._isFirstPing=!0,this._lossCount=0,this._hasPingRes=e,this._reconnect=t}return e.init=function(t,n){return k?(k.stop(),k):k=new e(t,n)},e.prototype.start=function(e){var t=this,n=this,o=function(){var r=t._isFirstPing?0:15e3;n._timerId=setTimeout((function(){n._isFirstPing=!1,F.debug("current lossCount: "+n._lossCount),n._hasPingRes?(e(),n._hasPingRes=!1,o()):n._lossCount<4?(n._lossCount++,e(),o()):n._reconnect()}),r)};o()},e.prototype.stop=function(){this._lossCount=0,clearTimeout(this._timerId)},e.prototype.setHeartbeatRes=function(e){F.debug("receive ping"),this._hasPingRes=e,this._lossCount=0},e}(),W=function(){function e(e){this._setTime=15962112e5,this._cppProto=e}return e.prototype._setToProtocol=function(e,t,n,o,r){var s=JSON.stringify(o);F.info("MsgExpansion._setToProtocol ===>",e,t,n,s,r),this._cppProto.setMessageExtension(e,t,n,s,r)},e.prototype.setLocalFromReceiveMsg=function(e){F.info("MsgExpansion.setLocalFromReceiveMsg ===>",e);var t=e.channelId,n=e.conversationType,o=e.targetId,r=e.messageUId,s=e.expansion,i=e.sentTime,a={};for(var c in s)a[c]={v:"",ts:0},a[c].v=s[c],a[c].ts=i;this._setToProtocol(n,o,r,a,t||"")},e.prototype.setLocalFromExtMsg=function(e){F.info("MsgExpansion.setLocalFromExtMsg ===>",e);var t=e.channelId,n=e.conversationType,o=e.targetId;e.messageUId;var r=e.content,s=e.sentTime,i=r,a=i.put,c=this._cppProto.getMessage(i.mid),u=JSON.parse(c).extMsg,p=JSON.parse(u||"{}");if(F.info("MsgExpansion.setLocalFromExtMsg, serverExtObj",a,"localExt",p),a)for(var l in a){var d=p[l];d&&d.ts<s-this._setTime?(d.v=a[l],d.ts=s-this._setTime):(p[l]={v:"",ts:0},p[l].v=a[l],p[l].ts=s-this._setTime)}i.del&&i.del.forEach((function(e){delete p[e]})),this._setToProtocol(n,o,i.mid,p,t||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),n={};for(var o in t)n[o]=t[o].v;return n},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),n=JSON.parse(t||"{}"),o={};for(var r in n)o[r]=n[r].v;return o},e}(),G=null;function q(e,t,n,o,r){return void 0===r&&(r=!0),D(this,void 0,void 0,(function(){var s;return H(this,(function(i){switch(i.label){case 0:return G?[2,G]:(G=function(e,t,n,o,r){return void 0===r&&(r=!0),D(this,void 0,void 0,(function(){var s,i,a,c;return H(this,(function(u){switch(u.label){case 0:s=function(s,i){var a,c,u,p,l;return H(this,(function(i){switch(i.label){case 0:return a="".concat(t[s],"/navi.json?r=").concat(Date.now()),c="token=".concat(encodeURIComponent(o),"&v=").concat((d=e,d.match(/\d+(\.\d+){2}/)[0]),"&p=PC&ev=").concat("5.5.0-enterprise-alpha.2"),F.info("request navi -> url: ".concat(a,", body: ").concat(c)),[4,new Promise((function(e){var t=/^https/.test(a),o={headers:{appId:n},method:"POST"};t&&(o.rejectUnauthorized=r,o.agent=new L(o));var s=(t?b:M)(a,o,(function(t){var n=t.statusCode,o="";t.setEncoding("utf8"),t.on("data",(function(e){o+=e})),t.on("end",(function(){e({status:n||0,data:o})}))}));s.on("error",(function(t){F.error(t),e({status:0})})),s.write(c),s.end()}))];case 1:if(200!==(u=i.sent()).status)return F.error("request navi failed -> ".concat(a)),u.data&&F.error(u.data),[2,"continue"];F.info("request navi success -> ".concat(a));try{return p=JSON.parse(u.data),l=/^https/.test(a)?"https":"http",p.protocol=l,[2,{value:p}]}catch(e){F.error("parse navi err => ".concat(u.data))}return[2]}var d}))},i=0,a=t.length,u.label=1;case 1:return i<a?[5,s(i,a)]:[3,4];case 2:if("object"==typeof(c=u.sent()))return[2,c.value];u.label=3;case 3:return i+=1,[3,1];case 4:return[2,null]}}))}))}(e,t,n,o,r),[4,G]);case 1:return s=i.sent(),G=null,[2,s]}}))}))}var Y=function(){function e(e,t,n){void 0===t&&(t=""),void 0===n&&(n=!1);var o=this;this._cppProtocol=e,this._dbpath=t,this._reconnectKickEnable=n,this._currentToken="",this._connectionStatus=r.DISCONNECTED,this._promiseHandler={},this._customMessageType={},this._heartbeat={},this._cppConnectionStatus=r.DISCONNECTED,this._connectedTime=0,this._currentUserId="",this._inited=!1,this._naviInfo=null,this._version="5.5.0-enterprise-alpha.2",this._electronLogger={debug:this._superElectronLog.bind(this,"debug",s.DEBUG),info:this._superElectronLog.bind(this,"info",s.INFO),warn:this._superElectronLog.bind(this,"warn",s.WARN),error:this._superElectronLog.bind(this,"error",s.ERROR),fatal:this._superElectronLog.bind(this,"fatal",s.FATAL)},this._logger={debug:this._superLog.bind(this,"debug",s.DEBUG),info:this._superLog.bind(this,"info",s.INFO),warn:this._superLog.bind(this,"warn",s.WARN),error:this._superLog.bind(this,"error",s.ERROR),fatal:this._superLog.bind(this,"fatal",s.FATAL)},this._senders={},this.rtcHeartbeatResolves={},E.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return D(o,void 0,void 0,(function(){var o,r,s,i;return H(this,(function(c){switch(c.label){case 0:if((i=this._electronLogger).debug.apply(i,B(["__RC_CHANNEL_CALL_MAIN_SYNC__",t],n,!1)),"function"!=typeof(o=this[t]))return e.returnValue=a.NOT_SUPPORT,[2];r=a.EXTRA_METHOD_UNDEFINED,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,o.call.apply(o,B([this],n,!1))];case 2:return r=c.sent(),[3,4];case 3:return s=c.sent(),this._electronLogger.error("call main process method `".concat(t,"` failed.")),this._electronLogger.error(s),[3,4];case 4:return e.returnValue=r,[2]}}))}))})),E.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var r=[],s=3;s<arguments.length;s++)r[s-3]=arguments[s];return D(o,void 0,void 0,(function(){var o,s,i,c,u,p=this;return H(this,(function(l){switch(l.label){case 0:if((u=this._electronLogger).debug.apply(u,B(["__RC_CHANNEL_CALL_MAIN__",t,n],r,!1)),"function"!=typeof(o=this[n]))return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,a.NOT_SUPPORT),[2];"sendMessage"===n&&(s=r[3],r[3]=function(t){p._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",s,t)}),i=a.EXTRA_METHOD_UNDEFINED,l.label=1;case 1:return l.trys.push([1,3,,4]),[4,o.call.apply(o,B([this],r,!1))];case 2:return i=l.sent(),[3,4];case 3:return c=l.sent(),this._electronLogger.error("call main process method `".concat(n,"` failed.")),this._electronLogger.error(c),[3,4];case 4:return this._electronLogger.debug("__RC_CHANNEL_RESULT_FROM_MAIN__",t,n,i),this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,i),[2]}}))}))})),E.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var n,r=[],s=2;s<arguments.length;s++)r[s-2]=arguments[s];(n=o._electronLogger).debug.apply(n,B(["__RC_CHANNEL_CALL_MAIN__",t],r,!1));var i=o[t];if("function"==typeof i)try{i.call.apply(i,B([o],r,!1))}catch(e){o._electronLogger.error("call main process method `".concat(t,"` failed.")),o._electronLogger.error(e)}else o._electronLogger.error("cannot not found method: ".concat(t))})),E.on("__RC_INNER_COMMAND_INIT__",this._init.bind(this)),this._msgExpansionHandler=new W(this._cppProtocol)}return e.prototype._callCppProxy=function(e){for(var t,n,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];try{return(t=this._cppProtocol)[e].apply(t,o)}catch(t){(n=this._electronLogger).error.apply(n,B([t,e],o,!1))}},e.prototype._superElectronLog=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];if(F[e]&&F[e].apply(F,n),t!==s.DEBUG){var r=Object.keys(this._senders);if(r.length>0){var i=n.reduce((function(e,t){return e+JSON.stringify(t)}),"");this._senders[r[0]].send("__RC_CHANNEL_CALL_RENDER__","_insertLog2IndexDB",t,i,"RCMain")}}},e.prototype._superLog=function(e,t,n,o,r){if(i[e]&&i[e](n,o,r),t!==s.DEBUG){var a=Object.keys(this._senders);a.length>0&&this._senders[a[0]].send("__RC_CHANNEL_CALL_RENDER__","_insertLog2IndexDB",t,o,n,null==r?void 0:r.logSource)}},e.prototype.getCppProto=function(){return this._cppProtocol},e.prototype.callExtra=function(e){for(var t,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];(t=this._electronLogger).info.apply(t,B(["callExtra -> ".concat(e)],n,!1));var r=this[e];if(!r)return this._electronLogger.warn("ExtraHandler.".concat(e," is undefined")),Promise.resolve({code:a.EXTRA_METHOD_UNDEFINED});try{return r.call.apply(r,B([this],n,!1))}catch(e){this._electronLogger.error(e)}return Promise.resolve({code:a.MAIN_PROCESS_ERROR})},e.prototype.getConversationsByPage=function(e,t,n,o){var r,s=this,i=this._callCppProxy("getConversationListByPage",e,t,n,o||"");try{r=JSON.parse(i).list.map((function(e){return s._buildConversation(e.obj)}))}catch(e){return this._electronLogger.error(e),Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:r})},e.prototype.getConversationListWithAllChannel=function(){var e,t=this,n=[c.PRIVATE,c.GROUP],o=this._callCppProxy("getConversationListWithAllChannel",n);try{e=JSON.parse(o).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return this._electronLogger.error(e),Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:e})},e.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,o=this,r=[c.PRIVATE,c.GROUP],s=this._callCppProxy("getConversationListWithAllChannelByPage",r,e,t);try{n=JSON.parse(s).list.map((function(e){return o._buildConversation(e.obj)}))}catch(e){return this._electronLogger.error(e),Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:n})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,n,o,r,s,i){var c=0===s,u=o+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,u,r,c,i||""),l=[];try{var d=JSON.parse(p).list;d.reverse();for(var f=0;f<d.length;f++){var g=this._buildMessage(d[f].obj);l[f]=g}}catch(e){return this._electronLogger.error(e),Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:{list:u===l.length?l.slice(1,u):l,hasMore:o<l.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,n,o){void 0===o&&(o=""),this._electronLogger.info("updateMessageReceiptStatus ->",e,t,n,o);var r=this._callCppProxy("updateMessageReceiptStatus",e,t,n,o);return Promise.resolve({code:a.SUCCESS,data:r})},e.prototype.requestNaviInfo=function(e,t,n,o){return D(this,void 0,void 0,(function(){return H(this,(function(r){return[2,q(this._initOptions.apiVersion,e,t,n,o)]}))}))},e.prototype.getNaviInfoFromCache=function(){return this._naviInfo},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){var e;return(null===(e=this._naviInfo)||void 0===e?void 0:e.userId)||""},e.prototype._send2Renderer=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,B([t],n,!1))},e.prototype._send2AllRenderer=function(e,t,n){var o=this;void 0===n&&(n=[]),Object.keys(this._senders).forEach((function(r){var s=o._senders[r];n.includes(s)||o._send2Renderer(s,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype._init=function(e,t){var o=this,r=e.sender,s=r.id;if(this._senders[s]||(this._senders[s]=r,r.once("destroyed",(function(){delete o._senders[s]}))),!this._inited){this._inited=!0,this._initOptions=t,this._electronLogger.info("init ->",t);var i=this._dbpath||n(P.getPath("userData"));this._logger.info(u.P_INIT_O,{"proto-commitId":this._cppProtocol.getNodeVersion(),appkey:t.appkey,dbpath:i}),this._callCppProxy("initWithAppkey",t.appkey,i),this._electronLogger.warn("cppProto version ->",this._cppProtocol.getNodeVersion()),this._registerMsgTypes();var a=K(i);this._electronLogger.info("deviceId -> ".concat(a)),this._callCppProxy("setDeviceId",a),this._setConnectionStatusListener(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener()}},e.prototype._registerMsgTypes=function(){for(var e in p["RC:RcCmd"]={isCounted:!1,isPersited:!1},p){var t=p[e],n=t.isCounted,o=0;t.isPersited&&(o|=1),n&&(o|=2),"RC:TypSts"===e&&(o=16),this._electronLogger.info("_registerMsgTypes ====>",e,o),this._callCppProxy("registerMessageType",e,o)}},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,o=t.buildFrom,r=JSON.parse(e);this._electronLogger.debug("_buildMessage:",r);var s=r.channelId,i=r.conversationType,a=r.targetId,c=r.senderUserId,u=r.content,h=r.objectName,_=r.messageUid,C=r.direction,v=r.status;r.source;var S=r.messageId,y=r.sentTime,m=r.readReceiptRequest,E=r.supportExt;r.extMsg;var P,T=r.pushContent,R=r.pushTitle,I=r.pushId,N=r.pushConfig,M=r.templateId,L=r.disableTitle,b=r.forcePushDetail;if(l(u))P=u;else try{P=u?JSON.parse(u):u}catch(e){F.warn("cpp engine build messaga error:",e),P=u}var O={isCounted:!1,isPersited:!1};h in p?O=p[h]:h in this._customMessageType&&(O=this._customMessageType[h]);var U=null;E&&(U=this._msgExpansionHandler.parseReceiveExpansion(r),"conversation"!==o&&"history"!==o||(U=this._msgExpansionHandler.parseConverOrHisExpansion(r)));var x=d(n)?y<this._connectedTime:n,w={};N&&(w=f(N,I));var D=A(A({},w),{pushTitle:R,pushContent:T,pushData:T,disablePushTitle:L,forceShowDetailContent:b,templateId:M}),H={channelId:s,conversationType:i,targetId:a,senderUserId:c,content:P||{},messageType:h,messageUId:_,messageDirection:C,isOffLineMessage:x,sentTime:y,receivedTime:0,isPersited:O.isPersited,isCounted:O.isCounted,isMentioned:!1,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:E,expansion:E?U:null,receivedStatus:v,messageId:S,pushConfig:D};if(C===g.RECEIVE?H.receivedStatus=v:C===g.SEND&&(H.sentStatus=v),m){var B=JSON.parse(m),k=B.hasRespond,J=B.readerInfo,j={hasRespond:k,readCount:B.readCount,totalCount:B.totalCount},K=[];if(J)for(var V in J)K.push({userId:V,readTime:J[V]});j.readerList=K,H.readReceiptInfo=j}return H},e.prototype._updateReadReceiptInfo=function(e,t){var n=this._callCppProxy("getMessage",e),o=JSON.parse(n),r=o.readReceiptRequest?JSON.parse(o.readReceiptRequest):{},s=A(A({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},e.prototype._buildConversation=function(e){var t=JSON.parse(e);this._electronLogger.debug("_buildConversation",t);var n=t.channelId,o=t.conversationType,r=t.targetId,s=t.unreadCount,i=t.lastestMsg,a=t.isTop,c=t.isBlocked,u=t.matchCount,p=c?h.OPEN:h.CLOSE;return{channelId:n,conversationType:o,targetId:r,unreadMessageCount:s,latestMessage:-1===JSON.parse(i).messageId?null:this._buildMessage(i),hasMentioned:!1,mentionedInfo:null,notificationStatus:p,isTop:a,lastUnreadTime:0,matchCount:u}},e.prototype._sendConnectionStatus2Renderer=function(e){this._send2AllRenderer("status",e)},e.prototype._convertResultList=function(e,t){var n=JSON.parse(e).list;return n=n.map((function(e){var n=JSON.parse(e.obj);return t?t(n):n}))},e.prototype._connectResolve=function(e){this._promiseHandler.connect&&this._promiseHandler.connect.length>0&&(this._promiseHandler.connect.forEach((function(t){t.resolve(e)})),delete this._promiseHandler.connect)},e.prototype._setConnectionStatusListener=function(){var e=this;this._cppProtocol.setConnectionStatusListener((function(t){var n;switch(e._electronLogger.warn("protocol connection status changed:",t),e._cppConnectionStatus=t,t){case 10:n=r.CONNECTING;break;case 31004:return void setTimeout((function(){e._connectResolve(a.RC_CONN_USER_OR_PASSWD_ERROR)}));case 12:n=r.DISCONNECTED;break;case 13:n=r.BLOCKED,setTimeout((function(){e._connectResolve(a.RC_CONN_USER_BLOCKED)}));break;case 31023:n=r.FORBID_RECONNECT_BY_OTHER_SAME_CLIENT,setTimeout((function(){e._connectResolve(a.RC_DISCONN_SAME_CLIENT_ON_LINE)}));break;case 1:case 9:case 11:case 31011:case 3e4:case 30002:n=r.NETWORK_UNAVAILABLE;break;case 30010:n=r.NETWORK_UNAVAILABLE,setTimeout((function(){e._connectionStatus===r.NETWORK_UNAVAILABLE&&e._doConnect()}),5e3);break;case 0:case 33005:n=r.CONNECTED,e._connectedTime=Date.now()-e._cppProtocol.getDeltaTime(),setTimeout((function(){e._connectResolve(a.SUCCESS),e._heartbeat=V.init(!0,e._handleHeartTimeout.bind(e)),e._heartbeat.start(e._sendHeartbeat.bind(e))}));break;case r.KICKED_OFFLINE_BY_OTHER_CLIENT:n=r.KICKED_OFFLINE_BY_OTHER_CLIENT;break;case 30004:return;case 8:case 31006:case 32061:case 32012:n=r.REDIRECT;break;default:n=t}n!==r.CONNECTED&&e._heartbeat&&e._heartbeat.stop&&e._heartbeat.stop(),e._connectionStatus=n,e._logger.info(u.P_CONNECT_S,{status:t}),e._sendConnectionStatus2Renderer(n)}),this._dbOpenCallback,(function(){e._heartbeat.setHeartbeatRes(!0)}))},e.prototype._handleHeartTimeout=function(){var e=this;F.warn("network unavailable! try to reconnect!"),this._sendConnectionStatus2Renderer(r.NETWORK_UNAVAILABLE),this._heartbeat.stop(),setTimeout((function(){return e._doConnect()}),5e3)},e.prototype._dbOpenCallback=function(e){F.info("Sqlite DB Open -> ".concat(e))},e.prototype._sendHeartbeat=function(){F.debug("send ping"),this._cppProtocol.sendHeartbeat()},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,o,r){var s=e._buildMessage(t,{isOffLineMessage:o});if(s.messageType===_.GROUP_READ_RECEIPT_REQUEST){var i=s.content,a=i.msgId,c=i.rrn,u=i.tmn;e._updateReadReceiptInfo(a,{readCount:c,totalCount:u})}if("RC:MsgExMsg"===s.messageType)return e._msgExpansionHandler.setLocalFromExtMsg(s),void e._sendMessageExpansion(s);if(s.canIncludeExpansion&&e._msgExpansionHandler.setLocalFromReceiveMsg(s),s.messageType===_.SYNC_READ_STATUS){if(s.senderUserId!==e._currentUserId)return;e._callCppProxy("clearUnreadCountByTimestamp",s.conversationType,s.targetId,s.content.lastMessageSendTime,s.channelId||"")}var p=!0;if(0!==n||r||(p=!1),s.messageType!==_.LOG_COMMAND||"rongcloudsystem"!==s.senderUserId){var l=s.conversationType,d=s.targetId;s.messageType===_.RECALL&&s.senderUserId===e._currentUserId&&(l=s.content.conversationType||l,d=s.content.targetId||d),e._sendMessageNotification(Object.assign(s,{hasMoreMsg:p,conversationType:l,targetId:d}))}else{var f=Object.keys(e._senders).map((function(t){return e._senders[t]}));f.length>0&&e._sendMessageNotification(Object.assign(s,{hasMoreMsg:p}),f.slice(1))}}),(function(){e._sendPullOfflineFinished()}))},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var n=e.channelId,o=e.content,r=o.put,s=o.del,i=o.mid,a={};r&&(a.updatedExpansion={channelId:n,messageUId:i,expansion:r}),s&&(a.deletedExpansion={channelId:n,messageUId:i,deletedKeys:s}),this._send2AllRenderer("expansion",a,t)},e.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},e.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},e.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var n=JSON.parse(t).list,o=[];n.forEach((function(e){var t=JSON.parse(e.obj),n=t.conversationType,r=t.targetId,s=t.status,i=t.channelId,a={notificationStatus:2,isTop:!1};s.forEach((function(e){var t=JSON.parse(e.item);1===t.type?a.notificationStatus=1===Number(t.value)?h.OPEN:h.CLOSE:a.isTop=1===Number(t.value)})),o.push({channelId:i,conversationType:n,targetId:r,updatedItems:{notificationStatus:{val:a.notificationStatus,time:0},isTop:{val:a.isTop,time:0}}})})),e._send2AllRenderer("conversation",o)}),(function(t){e._electronLogger.info("会话标签状态变更",t),e._send2AllRenderer("conversationTag",t)}))},e.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._electronLogger.info("标签变更",t),e._send2AllRenderer("tag",t)}))},e.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){var n=new Uint8Array(t).buffer;e._send2AllRenderer("onRTCDataChange",n)}))},e.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,n){e._send2AllRenderer("chatroom",{chatroomDestroyed:t})}))},e.prototype._clearListener=function(){this._cppProtocol.setOnReceiveMessageListener(),this._cppProtocol.setConnectionStatusListener(),this._cppProtocol.setOnReceiveStatusListener(),this._cppProtocol.setUserProfileListener()},e.prototype.registerMessageType=function(e,t,n,o){var r=0;t&&(r|=1),n&&(r|=2),this._customMessageType[e]={isCounted:n,isPersited:t},this._logger.info(u.P_REGTYP_O,{messageType:e,isCounted:n,searchProps:o,isPersited:t}),this._callCppProxy("registerMessageType",e,r,o)},e.prototype.connect=function(e,t,n,o){var s=this;return this._electronLogger.info("connect ->",e,t,n),this._logger.info(u.P_CONNECT_O,{token:e,reconnectKickEnable:n,version:this._version},{traceId:o}),this._currentToken===e&&this._connectionStatus===r.CONNECTED?(this._sendConnectionStatus2Renderer(this._connectionStatus),Promise.resolve(a.SUCCESS)):(this._currentToken=e,this._naviInfo=t,this._currentUserId=t.userId,!this._promiseHandler.connect&&this._doConnect(n),new Promise((function(e,t){s._promiseHandler.connect?s._promiseHandler.connect.push({resolve:e,reject:t}):s._promiseHandler.connect=[{resolve:e,reject:t}]})))},e.prototype._doConnect=function(e){var t=d(e)?this._reconnectKickEnable:e;this._callCppProxy("connectWithToken",this._currentToken,this._initOptions.apiVersion,JSON.stringify(this._naviInfo),t)},e.prototype.reportSDKInfo=function(e){this._cppProtocol.uploadSDKVersion&&this._cppProtocol.uploadSDKVersion(JSON.stringify(e)),this._electronLogger.info(e)},e.prototype.disconnect=function(){this._cppProtocol.disconnect(!0),this._heartbeat.stop(),this._connectResolve(a.TIMEOUT)},e.prototype.logout=function(){this.disconnect()},e.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,n){t({userId:e,status:n})}));var n=e.userIds||[];n.length&&this.subscribeUserStatus(n)},e.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("subscribeUserStatus",e,(function(){n(a.SUCCESS)}),n)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("setUserStatus",e,(function(){n(a.SUCCESS)}),n)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getUserStatus",e,(function(e){n({code:a.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},e.prototype.sendMessage=function(e,t,n,o,r){var s=this,i=n.messageType,p=n.content,l=n.pushContent,d=n.pushData,f=n.directionalUserIdList,g=n.disableNotification,h=n.canIncludeExpansion,S=n.expansion,y=n.isVoipPush,m=n.pushConfig,E=n.channelId,P=n.isMentioned,T=n.mentionedType,R=n.mentionedUserIdList,I=m||{},N=I.iOSConfig,M=I.androidConfig,L=I.pushTitle,b=I.pushContent,O=I.pushData,U=I.disablePushTitle,x=I.forceShowDetailContent,w=I.templateId,A=C(N,M);return new Promise((function(n){l=b||l||"",d=O||d||"",g=g||!1,y=y||!1,L=L||"",b=b||"",O=O||"",U=U||!1,x=x||!1,h=h||!1;var C=(null==M?void 0:M.notificationId)||"";if(f=f||[],E=E||"",e===c.GROUP&&P&&p&&(p.mentionedInfo={userIdList:R,type:T||v.ALL}),e===c.GROUP&&i===_.READ_RECEIPT_RESPONSE&&p.receiptMessageDic)for(var m in p.receiptMessageDic)f.push(m);var I={};for(var m in S)I[m]={v:""},I[m].v=S[m];var N=w||"";s._logger.info(u.P_SEND_MSG_T,{messageType:i,conversationType:e,targetId:t,channelId:E},{traceId:r});var D=s._callCppProxy("sendMessage",(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s._logger.info(u.P_SEND_MSG_R,{code:t,messageUId:o.messageUId,messageId:o.messageId},{traceId:r}),t===a.SENSITIVE_REPLACE?n({code:t}):("RC:MsgExMsg"===o.messageType&&s._msgExpansionHandler.setLocalFromExtMsg(o),o.canIncludeExpansion&&s._msgExpansionHandler.setLocalFromReceiveMsg(o),n({code:a.SUCCESS,data:o}))}),(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s._logger.warn(u.P_SEND_MSG_R,{code:t,messageUId:o.messageUId,messageId:o.messageId},{traceId:r}),o.sentTime=Date.now()-s._cppProtocol.getDeltaTime(),n({code:t,data:o})}),e,t,i,JSON.stringify(p),f,g,U,x,l,d,C,L,A,N,h,JSON.stringify(I),y,E,0),H=JSON.parse(D);o&&o(H.messageId)}))},e.prototype.recallMsg=function(e,t,n,o,r){var s=this;return new Promise((function(i,c){var u,p=r.user,l=r.pushContent,d=r.channelId,f=r.extra,h=r.pushConfig,v=r.disableNotification,y=r.isDelete,m={conversationType:e,targetId:t,messageUId:n,sentTime:o,user:p,extra:f,channelId:d,isDelete:y||!1};p&&(m.user=p),f&&(m.extra=f);var E={conversationType:e,targetId:t,senderUserId:s._currentUserId,content:m,objectName:_.RECALL,messageUid:n,direction:g.SEND,status:S.UNREAD,sentTime:o,channelId:d},P=s._buildMessage(JSON.stringify(E),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){i({code:a.SUCCESS,data:P})}),(function(e){i({code:e})}),_.RECALL,JSON.stringify(m),v||!1,(null==h?void 0:h.disablePushTitle)||!1,(null==h?void 0:h.forceShowDetailContent)||!1,l||"",(null==h?void 0:h.pushData)||"",(null===(u=null==h?void 0:h.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==h?void 0:h.pushTitle)||"",C(null==h?void 0:h.iOSConfig,null==h?void 0:h.androidConfig),(null==h?void 0:h.templateId)||"",d)}))},e.prototype.getHistoryMessage=function(e,t,n,o,r,s,i){var c=this;return new Promise((function(u,p){n=n||0;var l=0===r,d=o+1,f=c._callCppProxy("getHistoryMessages",e,t,n,d,i,l,s),g=JSON.parse(f).list,h=[];g.reverse();for(var _=0;_<g.length;_++){var C=c._buildMessage(g[_].obj);h[_]=C}u({code:a.SUCCESS,data:{list:d===h.length?h.slice(1,d):h,hasMore:o<h.length}})}))},e.prototype.getRemoteHistoryMessages=function(e,t,n,o,r,s){var i=this;return new Promise((function(c,u){n=n||0;i._callCppProxy("getRemoteHistoryMessages",e,t,n,o,(function(e,t){var n=JSON.parse(e).list,o=[];n.reverse();for(var r=0;r<n.length;r++){var s=i._buildMessage(n[r].obj);o[r]=s}c({code:a.SUCCESS,data:{list:o,hasMore:!!t}})}),(function(e){c({code:e})}),r,!0,s)}))},e.prototype.deleteRemoteMessage=function(e,t,n,o){var r=this;return new Promise((function(s,i){var c=JSON.stringify(n);r._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,o,(function(){s(a.SUCCESS)}),s)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){s(a.SUCCESS)}),(function(e){s(e)}),o)}))},e.prototype.clearMessages=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("clearMessages",e,t,n),r(a.SUCCESS)}))},e.prototype.getConversationList=function(e,t,n,o,r){var s=this;return void 0===r&&(r=""),new Promise((function(e,t){for(var n=s._callCppProxy("getConversationList",[1,3,6,7],r),o=JSON.parse(n).list,i=[],c=0;c<o.length;c++)i.push(s._buildConversation(o[c].obj));e({code:a.SUCCESS,data:i})}))},e.prototype.getConversation=function(e,t,n){var o=this;return new Promise((function(r,s){var i=o._callCppProxy("getConversation",e,t,n);if(i)r({code:a.SUCCESS,data:o._buildConversation(i)});else{var c=o._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),u=void 0;try{u=JSON.parse(c).list}catch(e){o._electronLogger.warn("json parse cppMessagaes error",e),u=[]}var p=null;u.length>0&&(p=o._buildMessage(u[0].obj));var l=o._callCppProxy("getConversationNotificationStatus",e,t,n),d=o._callCppProxy("getConversationTopStatus",e,t,n);r({code:a.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:p,notificationStatus:l?h.OPEN:h.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,n){var o=this._callCppProxy("removeConversation",e,t,n);return this._electronLogger.info("removeConversation result -> ".concat(o)),Promise.resolve(o?a.SUCCESS:a.UNKNOWN)},e.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(o,r){var s=[];s=y(e)?e:[c.PRIVATE,c.GROUP,c.SYSTEM,c.PUBLIC_SERVICE],n._callCppProxy("clearConversations",s,t),o(a.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,n){var o=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:a.SUCCESS,data:o})},e.prototype.getConversationUnreadCount=function(e,t,n){var o=this;return void 0===n&&(n=""),new Promise((function(r){var s=o._callCppProxy("getUnreadCount",e,t,n);r({code:a.SUCCESS,data:s})}))},e.prototype.clearConversationUnreadCount=function(e,t,n){var o=this;return void 0===n&&(n=""),new Promise((function(r,s){o._callCppProxy("clearUnreadCount",e,t,n),r(a.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("clearUnreadCountByTimestamp",e,t,n,o),s(a.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,n){var o=this;return new Promise((function(r,s){var i=o._callCppProxy("getTheFirstUnreadMessage",e,t,n),c=o._buildMessage(i);r({code:a.SUCCESS,data:-1!==c.messageId?c:null})}))},e.prototype.setConversationToTop=function(e,t,n,o){var r=this;return void 0===o&&(o=""),new Promise((function(s,i){r._electronLogger.info("setConversationToTop",e,t,n,o,true),r._callCppProxy("setConversationToTop",e,t,n,o,true),s(a.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("setConversationHidden",e,t,n,o),s(a.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._electronLogger.info("setConversationNotificationStatus",e,t,n,o),r._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){s(a.SUCCESS)}),s,o)}))},e.prototype.setConversationStatus=function(e,t,n,o,r){var s=this;return new Promise((function(i,c){s._electronLogger.info("setConversationStatus",e,t,n,o,r,true),s._callCppProxy("setConversationStatus",e,t,n,o,(function(){i(a.SUCCESS)}),i,r,true)}))},e.prototype.getConversationNotificationStatus=function(e,t,n){var o=this;return new Promise((function(r,s){var i=o._callCppProxy("getConversationNotificationStatus",e,t,n);r({code:a.SUCCESS,data:i?h.OPEN:h.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,n,o){var r=this;return new Promise((function(s,i){o=o||[1,3,6,7];for(var c=r._callCppProxy("searchConversationByContent",o,e,t,n),u=JSON.parse(c).list,p=[],l=0;l<u.length;l++)p[l]=r._buildConversation(u[l].obj);s({code:a.SUCCESS,data:p})}))},e.prototype.searchConversationByContentWithAllChannel=function(e,t,n){var o=this;return new Promise((function(r,s){n=n||[1,3,6,7];for(var i=o._callCppProxy("searchConversationByContentWithAllChannel",n,e,t),c=JSON.parse(i).list,u=[],p=0;p<c.length;p++)u[p]=o._buildConversation(c[p].obj);r({code:a.SUCCESS,data:u})}))},e.prototype.searchMessageByContent=function(e,t,n,o,r,s,i){var c=this;return new Promise((function(s,u){c._callCppProxy("searchMessageByContent",e,t,n,o,r,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],o=[],r=0;r<n.length;r++)o[r]=c._buildMessage(n[r].obj);s({code:a.SUCCESS,data:{messages:o,count:t}})}),i)}))},e.prototype.searchMessageByContentWithAllChannel=function(e,t,n,o,r){var s=this;return new Promise((function(i,c){s._callCppProxy("searchMessageByContentWithAllChannel",e,t,n,o,r,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],o=[],r=0;r<n.length;r++)o[r]=s._buildMessage(n[r].obj);i({code:a.SUCCESS,data:{messages:o,count:t}})}))}))},e.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(e,t,n,o,r,s,i){var c=this;return new Promise((function(u,p){c._callCppProxy("searchMessageByTimestampWithAllChannel",e,t,n,o,r,s,i,(function(e){for(var t=e?JSON.parse(e).list:[],n=[],o=0;o<t.length;o++)n[o]=c._buildMessage(t[o].obj);u({code:a.SUCCESS,data:{messages:n}})}))}))},e.prototype.getUnreadMentionedMessages=function(e,t,n){for(var o=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,n)).list,r=0;r<o.length;r++)o[r]=this._buildMessage(o[r].obj);return o},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("addToBlacklist",e,(function(){n(a.SUCCESS)}),n)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("removeFromBlacklist",e,(function(){n(a.SUCCESS)}),n)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){e._callCppProxy("getBlacklist",(function(e){t({code:a.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},e.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:a.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.insertMessage=function(e,t,n){var o=this,r=n.content,s=n.senderUserId,i=n.messageType,c=n.messageDirection,u=n.readStatus,p=n.sentStatus,l=n.sentTime,d=n.searchContent,f=n.isUnread,g=n.messageUId,h=n.disableNotification,_=n.canIncludeExpansion,C=n.expansionMsg,v=n.channelId;return r=JSON.stringify(r),new Promise((function(n,S){var y=f?0:1,m=o._callCppProxy("insertMessage",e,t,s,i,r,(function(){}),(function(e){n({code:e})}),c,u,p,l,d,y,g,h,_,C,v);o._electronLogger.info("after insert msg",m);var E=o._buildMessage(m,{isOffLineMessage:!1});E.messageUId=g,E.sentTime=l,n({code:-1===E.messageId?a.MSG_INSERT_ERROR:a.SUCCESS,data:E})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,o){t._logger.debug(u.P_DELETE_MSG_S,{messageIds:e}),t._callCppProxy("deleteMessages",e),n(a.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,n,o,r){var s=this;return new Promise((function(i,c){s._callCppProxy("deleteMessagesByTimestamp",e,t,n,o,r),i(a.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(n,o){var r=t._callCppProxy("getMessage",e);t._electronLogger.info("getMessage ===>",r);var s=t._buildMessage(r,{isOffLineMessage:!1});n({code:a.SUCCESS,data:s})}))},e.prototype.setMessageContent=function(e,t,n){var o=this;return new Promise((function(r,s){t=JSON.stringify(t),o._callCppProxy("setMessageContent",e,t,n),r(a.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("setMessageSearchField",e,t,n),r(a.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageSentStatus",e,t),o(a.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageReceivedStatus",e,t),o(a.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,n,o){throw new Error("Method not implemented.")},e.prototype.getConversationMessageDraft=function(e,t,n){throw new Error("Method not implemented.")},e.prototype.clearConversationMessageDraft=function(e,t,n){throw new Error("Method not implemented.")},e.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},e.prototype.batchSetConversationStatus=function(e){var t=e[0],n=t.conversationType,o=t.targetId,r=t.isTop,s=t.notificationStatus,i=t.channelId;if(void 0!==r&&void 0===s)return this.setConversationToTop(n,o,r,i);if(void 0!==s&&void 0===r){var a=s===h.OPEN;return this.setConversationNotificationStatus(n,o,a,i)}a=s===h.OPEN;return this.setConversationStatus(n,o,a,r,i)},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("sendReadReceipt",e,n||"",t,(function(){t.forEach((function(e){o._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(o._callCppProxy("getMessage",e)).messageId;o.setMessageReceivedStatus(t,1)}catch(t){o._electronLogger.warn("format message error, messageUId: "+e)}})),r({code:a.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getMessageReader=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("getMessageReader",e,n,t,(function(e,n){o._electronLogger.info("getMessageReader -> ",e,n);var s=[],i={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),n=t.id,o=t.time;s.push({userId:n,readTime:o}),i[n]=o}));var c={readerInfo:i,readCount:s.length,totalCount:n};o._updateReadReceiptInfo(t,c),r({code:a.SUCCESS,data:{list:s,totalMemberCount:n}})}),(function(e){r({code:e})}))}))},e.prototype.joinChatroom=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("clearMessages",c.CHATROOM,e,""),n._callCppProxy("joinChatRoom",e,t,(function(){o(a.SUCCESS)}),o)}))},e.prototype.joinExistChatroom=function(e,t){throw new Error("Method not implemented.")},e.prototype.quitChatroom=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("quitChatRoom",e,(function(){n(a.SUCCESS)}),n)}))},e.prototype.getChatroomInfo=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("getChatroomInfo",e,t,n,(function(e,t){var n=e?JSON.parse(e).list:[],o=[];if(n.length>0)for(var s=0;s<n.length;s++)o.push(JSON.parse(n[s].obj));r({code:a.SUCCESS,data:{userInfos:o,userCount:t}})}),(function(e){r({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("getChatroomHistoryMessage",e,t,n,o,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var n=t.list;if(n&&n.length)try{t.list=n.map((function(e){return r._buildMessage(e.obj)}))}catch(e){t.list=[]}s({code:a.SUCCESS,data:t})}),(function(e){s({code:e})}),"")}))},e.prototype.setChatroomEntry=function(e,t){var n=this;return new Promise((function(o,r){var s='[{"key":"'+t.key+'", "value":"'+t.value+'"}]';n._callCppProxy("setChatroomKV",e,s,!!t.isAutoDelete,!!t.isOverwrite,(function(){o(a.SUCCESS)}),(function(e){o(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var n=this,o=[t.key];return new Promise((function(r,s){n._callCppProxy("deleteChatroomKV",e,o,!!t.isOverwrite,(function(){r(a.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(o){var r=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return D(this,void 0,void 0,(function(){var n;return H(this,(function(o){switch(o.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=o.sent()).code===a.SUCCESS?[2,{code:a.SUCCESS,data:n.data?n.data[t]:null}]:[2,{code:n.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}n({code:a.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},e.prototype.getFileToken=function(e,t,n,o){var r=this;return n=n||"",o=o||"",new Promise((function(s){var i;i=o&&"uploads"!==o?t||"":m(e,t),r._callCppProxy("getUploadToken",e,i,n,o,(function(e,t,n,o,r,c,u,p,l,d,f,g,h,_,C,v,S,y){s({code:a.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:o,osskeyId:r,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:i,s3Credential:l,s3Algorithm:d,s3Date:f,s3Policy:g,s3Signature:h,s3BucketName:_,stcAuthorization:C,stcContentSha256:v,stcDate:S,stcBucketName:y}})}),(function(e){s({code:e})}))}))},e.prototype.getFileUrl=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("getDownloadUrl",e,n,o,t-1,(function(e){s({code:a.SUCCESS,data:{downloadUrl:e}})}),(function(e){s({code:e})}))}))},e.prototype.clearData=function(){var e=this;return new Promise((function(t,n){var o=e._callCppProxy("clearData");t({code:a.SUCCESS,data:o})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||n(P.getPath("userData"));return K(e)},e.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("getVoIPKey",e,t,"",(function(e){o({code:a.SUCCESS,data:e})}),(function(e){o({code:e})}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n,o){var r=e.chatRoomId,s=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",r,s,(function(){n(a.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.rtcSignaling=function(e,t,n,o){var r=this,s=Array.prototype.slice.call(new Uint8Array(o));return new Promise((function(o){r._callCppProxy("rtcSignaling",e,t,n,s,(function(e){var t=new Uint8Array(e).buffer;o({code:a.SUCCESS,buffer:t})}),(function(e){o({code:e})}))}))},e.prototype._setRTCHeartbeatListener=function(){var e=this;this._cppProtocol.setRTCHeartbeatListener((function(t,n){var o=e.rtcHeartbeatResolves[t];if(o){var r=o.find((function(e){return""===e.seqId}));r&&(r.seqId=n)}}),(function(t,n,o){var r=e.rtcHeartbeatResolves[t];if(r){var s=r.findIndex((function(e){return e.seqId===o}));-1!==s&&r.splice(s,1)[0].resolve(n)}}))},e.prototype.rtcPing=function(e,t,n){var o=this;return new Promise((function(t){var n={resolve:t,seqId:""},r=o.rtcHeartbeatResolves[e];r?r.push(n):o.rtcHeartbeatResolves[e]=[n],o._callCppProxy("sendRTCHeartbeat",[e])}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:a.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("deleteTag",e,(function(){n({code:a.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:a.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t,n){var o=e._callCppProxy("getTags");e._electronLogger.info("getTagList -> ",o);var r=e._convertResultList(o,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:a.SUCCESS,data:r})}))},e.prototype.addTagForConversations=function(e,t){var n=this;return new Promise((function(o,r){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(o,r){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,n,o){var r=this;return new Promise((function(s,i){var c=r._callCppProxy("getConversationsForTagByPage",e,t,n||20,o||"");r._electronLogger.info("getConversationListByTag -> ",c);var u=r._convertResultList(c,(function(e){return A(A({},r._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:a.SUCCESS,data:u})}))},e.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(o,r){var s=n._callCppProxy("getConversationUnreadCountForTag",e,t);n._electronLogger.info("getUnreadCountByTag -> ",s),o({code:a.SUCCESS,data:s})}))},e.prototype.setConversationStatusInTag=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.isTop||!1,(function(){r({code:a.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(n,o){var r=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||"");t._electronLogger.info("getTagsForConversation -> ",r);var s=t._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));n({code:a.SUCCESS,data:s})}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},e.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},e}(),X=function(e){return function(e,t){return i.init({customLogPrint:null==t?void 0:t.logStdout,localLogLevel:null==t?void 0:t.logLevel}),F.setLogLevel(null==t?void 0:t.logLevel),F.setLogStdout(null==t?void 0:t.logStdout),new Y(e,null==t?void 0:t.dbpath,null==t?void 0:t.reconnectKickEnable)}(w,e)};export{X as default};
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("os"),t=require("path"),o=require("@rongcloud/engine"),n=require("electron"),r=require("fs"),i=require("crypto"),s=require("http"),a=require("https"),c=process.versions.electron.replace(/\.\d+$/,""),u=t.resolve(__dirname,"binding","electron-v".concat(c,"-").concat(e.platform(),"-").concat(e.arch(),".node")),p=null;try{p=require(u)}catch(e){console.error("error ->",u,"\n",e)}var l=p,d=function(){return d=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},d.apply(this,arguments)};function C(e,t,o,n){return new(o||(o=Promise))((function(r,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function f(e,t){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function g(e,t,o){if(o||2===arguments.length)for(var n,r=0,i=t.length;r<i;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))}var h,v=new o.Logger("RCMain"),_=null,S=function(){var t,o=Date.now(),n=[e.arch(),e.platform(),process.pid,o,Math.floor(Math.random()*o)].join("__");return t=n,i.createHash("md5").update(t).digest("hex")},y=function(e){if(_)return _;var o=t.resolve(e,"deviceId");return v.debug("deviceIdPath -> ".concat(o)),r.existsSync(o)?_=r.readFileSync(o).toString():(_=S(),v.debug("createDeviceId -> ".concat(_)),r.writeFileSync(o,_),_)},E=function(){function e(e,t){this._timerId=0,this._heartbeatTimeoutId=0,this._isFirstPing=!0,this._lossCount=0,this._hasPingRes=e,this._reconnect=t}return e.init=function(t,o){return h?(h.stop(),h):h=new e(t,o)},e.prototype.start=function(e){var t=this,o=this,n=function(){var r=t._isFirstPing?0:15e3;o._timerId=setTimeout((function(){o._isFirstPing=!1,v.debug("current lossCount: "+o._lossCount),o._hasPingRes?(e(),o._hasPingRes=!1,n()):o._lossCount<4?(o._lossCount++,e(),n()):o._reconnect()}),r)};n()},e.prototype.stop=function(){this._lossCount=0,clearTimeout(this._timerId)},e.prototype.setHeartbeatRes=function(e){v.debug("receive ping"),this._hasPingRes=e,this._lossCount=0},e}(),m=function(){function e(e){this._setTime=15962112e5,this._cppProto=e}return e.prototype._setToProtocol=function(e,t,o,n,r){var i=JSON.stringify(n);v.info("MsgExpansion._setToProtocol ===>",e,t,o,i,r),this._cppProto.setMessageExtension(e,t,o,i,r)},e.prototype.setLocalFromReceiveMsg=function(e){v.info("MsgExpansion.setLocalFromReceiveMsg ===>",e);var t=e.channelId,o=e.conversationType,n=e.targetId,r=e.messageUId,i=e.expansion,s=e.sentTime,a={};for(var c in i)a[c]={v:"",ts:0},a[c].v=i[c],a[c].ts=s;this._setToProtocol(o,n,r,a,t||"")},e.prototype.setLocalFromExtMsg=function(e){v.info("MsgExpansion.setLocalFromExtMsg ===>",e);var t=e.channelId,o=e.conversationType,n=e.targetId;e.messageUId;var r=e.content,i=e.sentTime,s=r,a=s.put,c=this._cppProto.getMessage(s.mid),u=JSON.parse(c).extMsg,p=JSON.parse(u||"{}");if(v.info("MsgExpansion.setLocalFromExtMsg, serverExtObj",a,"localExt",p),a)for(var l in a){var d=p[l];d&&d.ts<i-this._setTime?(d.v=a[l],d.ts=i-this._setTime):(p[l]={v:"",ts:0},p[l].v=a[l],p[l].ts=i-this._setTime)}s.del&&s.del.forEach((function(e){delete p[e]})),this._setToProtocol(o,n,s.mid,p,t||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var n in t)o[n]=t[n].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),n={};for(var r in o)n[r]=o[r].v;return n},e}(),P=function(e){var t=[];return JSON.parse(e).list.forEach((function(e){t.push(JSON.parse(e.obj))})),t},T=function(e){return JSON.parse(e).list.map((function(e){return{key:Object.keys(e)[0],value:Object.values(e)[0]}}))},R=null;function I(e,t,o,n,r){return void 0===r&&(r=!0),C(this,void 0,void 0,(function(){var i;return f(this,(function(c){switch(c.label){case 0:return R?[2,R]:(R=function(e,t,o,n,r){return void 0===r&&(r=!0),C(this,void 0,void 0,(function(){var i,c,u,p;return f(this,(function(l){switch(l.label){case 0:i=function(i,c){var u,p,l,d,C;return f(this,(function(c){switch(c.label){case 0:return u="".concat(t[i],"/navi.json?r=").concat(Date.now()),p="token=".concat(encodeURIComponent(n),"&v=").concat((f=e,f.match(/\d+(\.\d+){2}/)[0]),"&p=PC&ev=").concat("5.4.4"),v.info("request navi -> url: ".concat(u,", body: ").concat(p)),[4,new Promise((function(e){var t=/^https/.test(u),n={headers:{appId:o},method:"POST"};t&&(n.rejectUnauthorized=r,n.agent=new a.Agent(n));var i=(t?a.request:s.request)(u,n,(function(t){var o=t.statusCode,n="";t.setEncoding("utf8"),t.on("data",(function(e){n+=e})),t.on("end",(function(){e({status:o||0,data:n})}))}));i.on("error",(function(t){v.error(t),e({status:0})})),i.write(p),i.end()}))];case 1:if(200!==(l=c.sent()).status)return v.error("request navi failed -> ".concat(u)),l.data&&v.error(l.data),[2,"continue"];v.info("request navi success -> ".concat(u));try{return d=JSON.parse(l.data),C=/^https/.test(u)?"https":"http",d.protocol=C,[2,{value:d}]}catch(e){v.error("parse navi err => ".concat(l.data))}return[2]}var f}))},c=0,u=t.length,l.label=1;case 1:return c<u?[5,i(c,u)]:[3,4];case 2:if("object"==typeof(p=l.sent()))return[2,p.value];l.label=3;case 3:return c+=1,[3,1];case 4:return[2,null]}}))}))}(e,t,o,n,r),[4,R]);case 1:return i=c.sent(),R=null,[2,i]}}))}))}var N=function(){function e(e,t,r){void 0===t&&(t=""),void 0===r&&(r=!1);var i=this;this._cppProtocol=e,this._dbpath=t,this._reconnectKickEnable=r,this._currentToken="",this._connectionStatus=o.ConnectionStatus.DISCONNECTED,this._promiseHandler={},this._customMessageType={},this._heartbeat={},this._cppConnectionStatus=o.ConnectionStatus.DISCONNECTED,this._connectedTime=0,this._currentUserId="",this._inited=!1,this._naviInfo=null,this._version="5.4.4",this._electronLogger={debug:this._superElectronLog.bind(this,"debug",o.LogLevel.DEBUG),info:this._superElectronLog.bind(this,"info",o.LogLevel.INFO),warn:this._superElectronLog.bind(this,"warn",o.LogLevel.WARN),error:this._superElectronLog.bind(this,"error",o.LogLevel.ERROR),fatal:this._superElectronLog.bind(this,"fatal",o.LogLevel.FATAL)},this._logger={debug:this._superLog.bind(this,"debug",o.LogLevel.DEBUG),info:this._superLog.bind(this,"info",o.LogLevel.INFO),warn:this._superLog.bind(this,"warn",o.LogLevel.WARN),error:this._superLog.bind(this,"error",o.LogLevel.ERROR),fatal:this._superLog.bind(this,"fatal",o.LogLevel.FATAL)},this._senders={},n.ipcMain.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return C(i,void 0,void 0,(function(){var r,i,s,a;return f(this,(function(c){switch(c.label){case 0:if((a=this._electronLogger).debug.apply(a,g(["__RC_CHANNEL_CALL_MAIN_SYNC__",t],n,!1)),"function"!=typeof(r=this[t]))return e.returnValue=o.ErrorCode.NOT_SUPPORT,[2];i=o.ErrorCode.EXTRA_METHOD_UNDEFINED,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,r.call.apply(r,g([this],n,!1))];case 2:return i=c.sent(),[3,4];case 3:return s=c.sent(),this._electronLogger.error("call main process method `".concat(t,"` failed.")),this._electronLogger.error(s),[3,4];case 4:return e.returnValue=i,[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var r=[],s=3;s<arguments.length;s++)r[s-3]=arguments[s];return C(i,void 0,void 0,(function(){var i,s,a,c,u,p=this;return f(this,(function(l){switch(l.label){case 0:if((u=this._electronLogger).debug.apply(u,g(["__RC_CHANNEL_CALL_MAIN__",t,n],r,!1)),"function"!=typeof(i=this[n]))return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,o.ErrorCode.NOT_SUPPORT),[2];"sendMessage"===n&&(s=r[3],r[3]=function(t){p._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",s,t)}),a=o.ErrorCode.EXTRA_METHOD_UNDEFINED,l.label=1;case 1:return l.trys.push([1,3,,4]),[4,i.call.apply(i,g([this],r,!1))];case 2:return a=l.sent(),[3,4];case 3:return c=l.sent(),this._electronLogger.error("call main process method `".concat(n,"` failed.")),this._electronLogger.error(c),[3,4];case 4:return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,a),[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o,n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];(o=i._electronLogger).debug.apply(o,g(["__RC_CHANNEL_CALL_MAIN__",t],n,!1));var s=i[t];if("function"==typeof s)try{s.call.apply(s,g([i],n,!1))}catch(e){i._electronLogger.error("call main process method `".concat(t,"` failed.")),i._electronLogger.error(e)}else i._electronLogger.error("cannot not found method: ".concat(t))})),n.ipcMain.on("__RC_INNER_COMMAND_INIT__",this._init.bind(this)),this._msgExpansionHandler=new m(this._cppProtocol)}return e.prototype._callCppProxy=function(e){for(var t,o,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];try{return(t=this._cppProtocol)[e].apply(t,n)}catch(t){(o=this._electronLogger).error.apply(o,g([t,e],n,!1))}},e.prototype._superElectronLog=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(v[e]&&v[e].apply(v,n),t!==o.LogLevel.DEBUG){var i=Object.keys(this._senders);if(i.length>0){var s=n.reduce((function(e,t){return e+JSON.stringify(t)}),"");this._senders[i[0]].send("__RC_CHANNEL_CALL_RENDER__","_insertLog2IndexDB",t,s,"RCMain")}}},e.prototype._superLog=function(e,t,n,r,i){if(o.logger[e]&&o.logger[e](n,r,i),t!==o.LogLevel.DEBUG){var s=Object.keys(this._senders);s.length>0&&this._senders[s[0]].send("__RC_CHANNEL_CALL_RENDER__","_insertLog2IndexDB",t,r,n,null==i?void 0:i.logSource)}},e.prototype.getCppProto=function(){return this._cppProtocol},e.prototype.callExtra=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(t=this._electronLogger).info.apply(t,g(["callExtra -> ".concat(e)],n,!1));var i=this[e];if(!i)return this._electronLogger.warn("ExtraHandler.".concat(e," is undefined")),Promise.resolve({code:o.ErrorCode.EXTRA_METHOD_UNDEFINED});try{return i.call.apply(i,g([this],n,!1))}catch(e){this._electronLogger.error(e)}return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})},e.prototype.getConversationsByPage=function(e,t,n,r){var i,s=this,a=this._callCppProxy("getConversationListByPage",e,t,n,r||"");try{i=JSON.parse(a).list.map((function(e){return s._buildConversation(e.obj)}))}catch(e){return this._electronLogger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:i})},e.prototype.getConversationListWithAllChannel=function(){var e,t=this,n=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],r=this._callCppProxy("getConversationListWithAllChannel",n);try{e=JSON.parse(r).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return this._electronLogger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:e})},e.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,r=this,i=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],s=this._callCppProxy("getConversationListWithAllChannelByPage",i,e,t);try{n=JSON.parse(s).list.map((function(e){return r._buildConversation(e.obj)}))}catch(e){return this._electronLogger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:n})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,n,r,i,s,a){var c=0===s,u=r+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,u,i,c,a||""),l=[];try{var d=JSON.parse(p).list;d.reverse();for(var C=0;C<d.length;C++){var f=this._buildMessage(d[C].obj);l[C]=f}}catch(e){return this._electronLogger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:{list:u===l.length?l.slice(1,u):l,hasMore:r<l.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,n,r){void 0===r&&(r=""),this._electronLogger.info("updateMessageReceiptStatus ->",e,t,n,r);var i=this._callCppProxy("updateMessageReceiptStatus",e,t,n,r);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:i})},e.prototype.requestNaviInfo=function(e,t,o,n){return C(this,void 0,void 0,(function(){return f(this,(function(r){return[2,I(this._initOptions.apiVersion,e,t,o,n)]}))}))},e.prototype.getNaviInfoFromCache=function(){return this._naviInfo},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){var e;return(null===(e=this._naviInfo)||void 0===e?void 0:e.userId)||""},e.prototype._send2Renderer=function(e,t){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,g([t],o,!1))},e.prototype._send2AllRenderer=function(e,t,o){var n=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(r){var i=n._senders[r];o.includes(i)||n._send2Renderer(i,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype._init=function(e,r){var i=this,s=e.sender,a=s.id;if(this._senders[a]||(this._senders[a]=s,s.once("destroyed",(function(){delete i._senders[a]}))),!this._inited){this._inited=!0,this._initOptions=r,this._electronLogger.info("init ->",r);var c=this._dbpath||t.resolve(n.app.getPath("userData"));this._logger.info(o.LogTagId.P_INIT_O,{"proto-commitId":this._cppProtocol.getNodeVersion(),appkey:r.appkey,dbpath:c}),this._callCppProxy("initWithAppkey",r.appkey,c),this._electronLogger.warn("cppProto version ->",this._cppProtocol.getNodeVersion()),this._registerMsgTypes();var u=y(c);this._electronLogger.info("deviceId -> ".concat(u)),this._callCppProxy("setDeviceId",u),this._setConnectionStatusListener(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener()}},e.prototype._registerMsgTypes=function(){for(var e in o.SEND_MESSAGE_TYPE_OPTION["RC:RcCmd"]={isCounted:!1,isPersited:!1},o.SEND_MESSAGE_TYPE_OPTION){var t=o.SEND_MESSAGE_TYPE_OPTION[e],n=t.isCounted,r=0;t.isPersited&&(r|=1),n&&(r|=2),"RC:TypSts"===e&&(r=16),this._electronLogger.info("_registerMsgTypes ====>",e,r),this._callCppProxy("registerMessageType",e,r)}},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,r=t.buildFrom,i=JSON.parse(e);this._electronLogger.debug("_buildMessage:",i);var s=i.channelId,a=i.conversationType,c=i.targetId,u=i.senderUserId,p=i.content,l=i.objectName,C=i.messageUid,f=i.direction,g=i.status;i.source;var h=i.messageId,_=i.sentTime,S=i.readReceiptRequest,y=i.supportExt;i.extMsg;var E,m=i.pushContent,P=i.pushTitle,T=i.pushId,R=i.pushConfig,I=i.templateId,N=i.disableTitle,O=i.forcePushDetail;if(o.isObject(p))E=p;else try{E=p?JSON.parse(p):p}catch(e){v.warn("cpp engine build messaga error:",e),E=p}var L={isCounted:!1,isPersited:!1};l in o.SEND_MESSAGE_TYPE_OPTION?L=o.SEND_MESSAGE_TYPE_OPTION[l]:l in this._customMessageType&&(L=this._customMessageType[l]);var M=null;y&&(M=this._msgExpansionHandler.parseReceiveExpansion(i),"conversation"!==r&&"history"!==r||(M=this._msgExpansionHandler.parseConverOrHisExpansion(i)));var U=o.isUndefined(n)?_<this._connectedTime:n,b={};R&&(b=o.pushJSONToConfigs(R,T));var x=d(d({},b),{pushTitle:P,pushContent:m,pushData:m,disablePushTitle:N,forceShowDetailContent:O,templateId:I}),w={channelId:s,conversationType:a,targetId:c,senderUserId:u,content:E||{},messageType:l,messageUId:C,messageDirection:f,isOffLineMessage:U,sentTime:_,receivedTime:0,isPersited:L.isPersited,isCounted:L.isCounted,isMentioned:!1,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:y,expansion:y?M:null,receivedStatus:g,messageId:h,pushConfig:x};if(f===o.MessageDirection.RECEIVE?w.receivedStatus=g:f===o.MessageDirection.SEND&&(w.sentStatus=g),S){var A=JSON.parse(S),D=A.hasRespond,J=A.readerInfo,k={hasRespond:D,readCount:A.readCount,totalCount:A.totalCount},F=[];if(J)for(var H in J)F.push({userId:H,readTime:J[H]});k.readerList=F,w.readReceiptInfo=k}return w},e.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),n=JSON.parse(o),r=n.readReceiptRequest?JSON.parse(n.readReceiptRequest):{},i=d(d({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(i))},e.prototype._buildConversation=function(e){var t=JSON.parse(e);this._electronLogger.debug("_buildConversation",t);var n=t.channelId,r=t.conversationType,i=t.targetId,s=t.unreadCount,a=t.lastestMsg,c=t.isTop,u=t.isBlocked,p=t.matchCount,l=u?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE;return{channelId:n,conversationType:r,targetId:i,unreadMessageCount:s,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:!1,mentionedInfo:null,notificationStatus:l,isTop:c,lastUnreadTime:0,matchCount:p}},e.prototype._sendConnectionStatus2Renderer=function(e){this._send2AllRenderer("status",e)},e.prototype._convertResultList=function(e,t){var o=JSON.parse(e).list;return o=o.map((function(e){var o=JSON.parse(e.obj);return t?t(o):o}))},e.prototype._connectResolve=function(e){this._promiseHandler.connect&&this._promiseHandler.connect.length>0&&(this._promiseHandler.connect.forEach((function(t){t.resolve(e)})),delete this._promiseHandler.connect)},e.prototype._setConnectionStatusListener=function(){var e=this;this._cppProtocol.setConnectionStatusListener((function(t){var n;switch(e._electronLogger.warn("protocol connection status changed:",t),e._cppConnectionStatus=t,t){case 10:n=o.ConnectionStatus.CONNECTING;break;case 31004:return void setTimeout((function(){e._connectResolve(o.ErrorCode.RC_CONN_USER_OR_PASSWD_ERROR)}));case 12:n=o.ConnectionStatus.DISCONNECTED;break;case 13:n=o.ConnectionStatus.BLOCKED,setTimeout((function(){e._connectResolve(o.ErrorCode.RC_CONN_USER_BLOCKED)}));break;case 31023:n=o.ConnectionStatus.FORBID_RECONNECT_BY_OTHER_SAME_CLIENT,setTimeout((function(){e._connectResolve(o.ErrorCode.RC_DISCONN_SAME_CLIENT_ON_LINE)}));break;case 1:case 9:case 11:case 31011:case 3e4:case 30002:n=o.ConnectionStatus.NETWORK_UNAVAILABLE;break;case 30010:n=o.ConnectionStatus.NETWORK_UNAVAILABLE,setTimeout((function(){e._connectionStatus===o.ConnectionStatus.NETWORK_UNAVAILABLE&&e._doConnect()}),5e3);break;case 0:case 33005:n=o.ConnectionStatus.CONNECTED,e._connectedTime=Date.now()-e._cppProtocol.getDeltaTime(),setTimeout((function(){e._connectResolve(o.ErrorCode.SUCCESS),e._heartbeat=E.init(!0,e._handleHeartTimeout.bind(e)),e._heartbeat.start(e._sendHeartbeat.bind(e))}));break;case o.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT:n=o.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT;break;case 30004:return;case 8:case 31006:case 32061:case 32012:n=o.ConnectionStatus.REDIRECT;break;default:n=t}n!==o.ConnectionStatus.CONNECTED&&e._heartbeat&&e._heartbeat.stop&&e._heartbeat.stop(),e._connectionStatus=n,e._logger.info(o.LogTagId.P_CONNECT_S,{status:t}),e._sendConnectionStatus2Renderer(n)}),this._dbOpenCallback,(function(){e._heartbeat.setHeartbeatRes(!0)}))},e.prototype._handleHeartTimeout=function(){var e=this;v.warn("network unavailable! try to reconnect!"),this._sendConnectionStatus2Renderer(o.ConnectionStatus.NETWORK_UNAVAILABLE),this._heartbeat.stop(),setTimeout((function(){return e._doConnect()}),5e3)},e.prototype._dbOpenCallback=function(e){v.info("Sqlite DB Open -> ".concat(e))},e.prototype._sendHeartbeat=function(){v.debug("send ping"),this._cppProtocol.sendHeartbeat()},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,r,i){var s=e._buildMessage(t,{isOffLineMessage:r});if(s.messageType===o.MessageType.GROUP_READ_RECEIPT_REQUEST){var a=s.content,c=a.msgId,u=a.rrn,p=a.tmn;e._updateReadReceiptInfo(c,{readCount:u,totalCount:p})}if("RC:MsgExMsg"===s.messageType)return e._msgExpansionHandler.setLocalFromExtMsg(s),void e._sendMessageExpansion(s);if(s.canIncludeExpansion&&e._msgExpansionHandler.setLocalFromReceiveMsg(s),s.messageType===o.MessageType.SYNC_READ_STATUS){if(s.senderUserId!==e._currentUserId)return;e._callCppProxy("clearUnreadCountByTimestamp",s.conversationType,s.targetId,s.content.lastMessageSendTime,s.channelId||"")}var l=!0;if(0!==n||i||(l=!1),s.messageType!==o.MessageType.LOG_COMMAND||"rongcloudsystem"!==s.senderUserId){var d=s.conversationType,C=s.targetId;s.messageType===o.MessageType.RECALL&&s.senderUserId===e._currentUserId&&(d=s.content.conversationType||d,C=s.content.targetId||C),e._sendMessageNotification(Object.assign(s,{hasMoreMsg:l,conversationType:d,targetId:C}))}else{var f=Object.keys(e._senders).map((function(t){return e._senders[t]}));f.length>0&&e._sendMessageNotification(Object.assign(s,{hasMoreMsg:l}),f.slice(1))}}),(function(){e._sendPullOfflineFinished()}))},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var o=e.channelId,n=e.content,r=n.put,i=n.del,s=n.mid,a={};r&&(a.updatedExpansion={channelId:o,messageUId:s,expansion:r}),i&&(a.deletedExpansion={channelId:o,messageUId:s,deletedKeys:i}),this._send2AllRenderer("expansion",a,t)},e.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},e.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},e.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var n=JSON.parse(t).list,r=[];n.forEach((function(e){var t=JSON.parse(e.obj),n=t.conversationType,i=t.targetId,s=t.status,a=t.channelId,c={notificationStatus:2,isTop:!1};s.forEach((function(e){var t=JSON.parse(e.item);1===t.type?c.notificationStatus=1===Number(t.value)?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE:c.isTop=1===Number(t.value)})),r.push({channelId:a,conversationType:n,targetId:i,updatedItems:{notificationStatus:{val:c.notificationStatus,time:0},isTop:{val:c.isTop,time:0}}})})),e._send2AllRenderer("conversation",r)}),(function(t){e._electronLogger.info("会话标签状态变更",t),e._send2AllRenderer("conversationTag",t)}))},e.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._electronLogger.info("标签变更",t),e._send2AllRenderer("tag",t)}))},e.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){v.info("RTC Room Data Change:",t);var o=JSON.parse(t).list.map((function(e){var t=JSON.parse(e.obj);return{key:t.key,value:t.value,uid:t.operator,timestamp:t.version,status:t.isDeleted?1:0,roomId:t.roomId||""}}));e._send2AllRenderer("onRTCDataChange",o)}))},e.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._send2AllRenderer("chatroom",{chatroomDestroyed:t})}))},e.prototype._clearListener=function(){this._cppProtocol.setOnReceiveMessageListener(),this._cppProtocol.setConnectionStatusListener(),this._cppProtocol.setOnReceiveStatusListener(),this._cppProtocol.setUserProfileListener()},e.prototype.registerMessageType=function(e,t,n,r){var i=0;t&&(i|=1),n&&(i|=2),this._customMessageType[e]={isCounted:n,isPersited:t},this._logger.info(o.LogTagId.P_REGTYP_O,{messageType:e,isCounted:n,searchProps:r,isPersited:t}),this._callCppProxy("registerMessageType",e,i,r)},e.prototype.connect=function(e,t,n,r){var i=this;return this._electronLogger.info("connect ->",e,t,n),this._logger.info(o.LogTagId.P_CONNECT_O,{token:e,reconnectKickEnable:n,version:this._version},{traceId:r}),this._currentToken===e&&this._connectionStatus===o.ConnectionStatus.CONNECTED?(this._sendConnectionStatus2Renderer(this._connectionStatus),Promise.resolve(o.ErrorCode.SUCCESS)):(this._currentToken=e,this._naviInfo=t,this._currentUserId=t.userId,!this._promiseHandler.connect&&this._doConnect(n),new Promise((function(e,t){i._promiseHandler.connect?i._promiseHandler.connect.push({resolve:e,reject:t}):i._promiseHandler.connect=[{resolve:e,reject:t}]})))},e.prototype._doConnect=function(e){var t=o.isUndefined(e)?this._reconnectKickEnable:e;this._callCppProxy("connectWithToken",this._currentToken,this._initOptions.apiVersion,JSON.stringify(this._naviInfo),t)},e.prototype.reportSDKInfo=function(e){this._cppProtocol.uploadSDKVersion&&this._cppProtocol.uploadSDKVersion(JSON.stringify(e)),this._electronLogger.info(e)},e.prototype.disconnect=function(){this._cppProtocol.disconnect(!0),this._heartbeat.stop(),this._connectResolve(o.ErrorCode.TIMEOUT)},e.prototype.logout=function(){this.disconnect()},e.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,o){t({userId:e,status:o})}));var o=e.userIds||[];o.length&&this.subscribeUserStatus(o)},e.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("subscribeUserStatus",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("setUserStatus",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getUserStatus",e,(function(e){n({code:o.ErrorCode.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},e.prototype.sendMessage=function(e,t,n,r,i){var s=this,a=n.messageType,c=n.content,u=n.pushContent,p=n.pushData,l=n.directionalUserIdList,d=n.disableNotification,C=n.canIncludeExpansion,f=n.expansion,g=n.isVoipPush,h=n.pushConfig,v=n.channelId,_=n.isMentioned,S=n.mentionedType,y=n.mentionedUserIdList,E=h||{},m=E.iOSConfig,P=E.androidConfig,T=E.pushTitle,R=E.pushContent,I=E.pushData,N=E.disablePushTitle,O=E.forceShowDetailContent,L=E.templateId,M=o.pushConfigsToJSON(m,P);return new Promise((function(n){u=R||u||"",p=I||p||"",d=d||!1,g=g||!1,T=T||"",R=R||"",I=I||"",N=N||!1,O=O||!1,C=C||!1;var h=(null==P?void 0:P.notificationId)||"";if(l=l||[],v=v||"",e===o.ConversationType.GROUP&&_&&c&&(c.mentionedInfo={userIdList:y,type:S||o.MentionedType.ALL}),e===o.ConversationType.GROUP&&a===o.MessageType.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var E in c.receiptMessageDic)l.push(E);var m={};for(var E in f)m[E]={v:""},m[E].v=f[E];var U=L||"";s._logger.info(o.LogTagId.P_SEND_MSG_T,{messageType:a,conversationType:e,targetId:t,channelId:v},{traceId:i});var b=s._callCppProxy("sendMessage",(function(e,t){var r=s._buildMessage(e,{isOffLineMessage:!1});return s._logger.info(o.LogTagId.P_SEND_MSG_R,{code:t,messageUId:r.messageUId,messageId:r.messageId},{traceId:i}),t===o.ErrorCode.SENSITIVE_REPLACE?n({code:t}):("RC:MsgExMsg"===r.messageType&&s._msgExpansionHandler.setLocalFromExtMsg(r),r.canIncludeExpansion&&s._msgExpansionHandler.setLocalFromReceiveMsg(r),n({code:o.ErrorCode.SUCCESS,data:r}))}),(function(e,t){var r=s._buildMessage(e,{isOffLineMessage:!1});return s._logger.warn(o.LogTagId.P_SEND_MSG_R,{code:t,messageUId:r.messageUId,messageId:r.messageId},{traceId:i}),r.sentTime=Date.now()-s._cppProtocol.getDeltaTime(),n({code:t,data:r})}),e,t,a,JSON.stringify(c),l,d,N,O,u,p,h,T,M,U,C,JSON.stringify(m),g,v),x=JSON.parse(b);r&&r(x.messageId)}))},e.prototype.recallMsg=function(e,t,n,r,i){var s=this;return new Promise((function(a,c){var u,p=i.user,l=i.pushContent,d=i.channelId,C=i.extra,f=i.pushConfig,g=i.disableNotification,h=i.isDelete,v={conversationType:e,targetId:t,messageUId:n,sentTime:r,user:p,extra:C,channelId:d,isDelete:h||!1};p&&(v.user=p),C&&(v.extra=C);var _={conversationType:e,targetId:t,senderUserId:s._currentUserId,content:v,objectName:o.MessageType.RECALL,messageUid:n,direction:o.MessageDirection.SEND,status:o.ReceivedStatus.UNREAD,sentTime:r,channelId:d},S=s._buildMessage(JSON.stringify(_),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){a({code:o.ErrorCode.SUCCESS,data:S})}),(function(e){a({code:e})}),o.MessageType.RECALL,JSON.stringify(v),g||!1,(null==f?void 0:f.disablePushTitle)||!1,(null==f?void 0:f.forceShowDetailContent)||!1,l||"",(null==f?void 0:f.pushData)||"",(null===(u=null==f?void 0:f.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==f?void 0:f.pushTitle)||"",o.pushConfigsToJSON(null==f?void 0:f.iOSConfig,null==f?void 0:f.androidConfig),(null==f?void 0:f.templateId)||"",d)}))},e.prototype.getHistoryMessage=function(e,t,n,r,i,s,a){var c=this;return new Promise((function(u,p){n=n||0;var l=0===i,d=r+1,C=c._callCppProxy("getHistoryMessages",e,t,n,d,a,l,s),f=JSON.parse(C).list,g=[];f.reverse();for(var h=0;h<f.length;h++){var v=c._buildMessage(f[h].obj);g[h]=v}u({code:o.ErrorCode.SUCCESS,data:{list:d===g.length?g.slice(1,d):g,hasMore:r<g.length}})}))},e.prototype.getRemoteHistoryMessages=function(e,t,n,r,i,s){var a=this;return new Promise((function(c,u){n=n||0;a._callCppProxy("getRemoteHistoryMessages",e,t,n,r,(function(e,t){var n=JSON.parse(e).list,r=[];n.reverse();for(var i=0;i<n.length;i++){var s=a._buildMessage(n[i].obj);r[i]=s}c({code:o.ErrorCode.SUCCESS,data:{list:r,hasMore:!!t}})}),(function(e){c({code:e})}),i,!0,s)}))},e.prototype.deleteRemoteMessage=function(e,t,n,r){var i=this;return new Promise((function(s,a){var c=JSON.stringify(n);i._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,r,(function(){s(o.ErrorCode.SUCCESS)}),s)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){s(o.ErrorCode.SUCCESS)}),(function(e){s(e)}),r)}))},e.prototype.clearMessages=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("clearMessages",e,t,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.getConversationList=function(e,t,n,r,i){var s=this;return void 0===i&&(i=""),new Promise((function(e,t){for(var n=s._callCppProxy("getConversationList",[1,3,6,7],i),r=JSON.parse(n).list,a=[],c=0;c<r.length;c++)a.push(s._buildConversation(r[c].obj));e({code:o.ErrorCode.SUCCESS,data:a})}))},e.prototype.getConversation=function(e,t,n){var r=this;return new Promise((function(i,s){var a=r._callCppProxy("getConversation",e,t,n);if(a)i({code:o.ErrorCode.SUCCESS,data:r._buildConversation(a)});else{var c=r._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),u=void 0;try{u=JSON.parse(c).list}catch(e){r._electronLogger.warn("json parse cppMessagaes error",e),u=[]}var p=null;u.length>0&&(p=r._buildMessage(u[0].obj));var l=r._callCppProxy("getConversationNotificationStatus",e,t,n),d=r._callCppProxy("getConversationTopStatus",e,t,n);i({code:o.ErrorCode.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:p,notificationStatus:l?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,n){var r=this._callCppProxy("removeConversation",e,t,n);return this._electronLogger.info("removeConversation result -> ".concat(r)),Promise.resolve(r?o.ErrorCode.SUCCESS:o.ErrorCode.UNKNOWN)},e.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(r,i){var s=[];s=o.isArray(e)?e:[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.PUBLIC_SERVICE],n._callCppProxy("clearConversations",s,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,n){var r=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:r})},e.prototype.getConversationUnreadCount=function(e,t,n){var r=this;return void 0===n&&(n=""),new Promise((function(i){var s=r._callCppProxy("getUnreadCount",e,t,n);i({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.clearConversationUnreadCount=function(e,t,n){var r=this;return void 0===n&&(n=""),new Promise((function(i,s){r._callCppProxy("clearUnreadCount",e,t,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._callCppProxy("clearUnreadCountByTimestamp",e,t,n,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,n){var r=this;return new Promise((function(i,s){var a=r._callCppProxy("getTheFirstUnreadMessage",e,t,n),c=r._buildMessage(a);i({code:o.ErrorCode.SUCCESS,data:-1!==c.messageId?c:null})}))},e.prototype.setConversationToTop=function(e,t,n,r){var i=this;return void 0===r&&(r=""),new Promise((function(s,a){i._electronLogger.info("setConversationToTop",e,t,n,r,true),i._callCppProxy("setConversationToTop",e,t,n,r,true),s(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._callCppProxy("setConversationHidden",e,t,n,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._electronLogger.info("setConversationNotificationStatus",e,t,n,r),i._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){s(o.ErrorCode.SUCCESS)}),s,r)}))},e.prototype.setConversationStatus=function(e,t,n,r,i){var s=this;return new Promise((function(a,c){s._electronLogger.info("setConversationStatus",e,t,n,r,i,true),s._callCppProxy("setConversationStatus",e,t,n,r,(function(){a(o.ErrorCode.SUCCESS)}),a,i,true)}))},e.prototype.getConversationNotificationStatus=function(e,t,n){var r=this;return new Promise((function(i,s){var a=r._callCppProxy("getConversationNotificationStatus",e,t,n);i({code:o.ErrorCode.SUCCESS,data:a?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,n,r){var i=this;return new Promise((function(s,a){r=r||[1,3,6,7];for(var c=i._callCppProxy("searchConversationByContent",r,e,t,n),u=JSON.parse(c).list,p=[],l=0;l<u.length;l++)p[l]=i._buildConversation(u[l].obj);s({code:o.ErrorCode.SUCCESS,data:p})}))},e.prototype.searchConversationByContentWithAllChannel=function(e,t,n){var r=this;return new Promise((function(i,s){n=n||[1,3,6,7];for(var a=r._callCppProxy("searchConversationByContentWithAllChannel",n,e,t),c=JSON.parse(a).list,u=[],p=0;p<c.length;p++)u[p]=r._buildConversation(c[p].obj);i({code:o.ErrorCode.SUCCESS,data:u})}))},e.prototype.searchMessageByContent=function(e,t,n,r,i,s,a){var c=this;return new Promise((function(s,u){c._callCppProxy("searchMessageByContent",e,t,n,r,i,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],r=[],i=0;i<n.length;i++)r[i]=c._buildMessage(n[i].obj);s({code:o.ErrorCode.SUCCESS,data:{messages:r,count:t}})}),a)}))},e.prototype.searchMessageByContentWithAllChannel=function(e,t,n,r,i){var s=this;return new Promise((function(a,c){s._callCppProxy("searchMessageByContentWithAllChannel",e,t,n,r,i,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],r=[],i=0;i<n.length;i++)r[i]=s._buildMessage(n[i].obj);a({code:o.ErrorCode.SUCCESS,data:{messages:r,count:t}})}))}))},e.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(e,t,n,r,i,s,a){var c=this;return new Promise((function(u,p){c._callCppProxy("searchMessageByTimestampWithAllChannel",e,t,n,r,i,s,a,(function(e){for(var t=e?JSON.parse(e).list:[],n=[],r=0;r<t.length;r++)n[r]=c._buildMessage(t[r].obj);u({code:o.ErrorCode.SUCCESS,data:{messages:n}})}))}))},e.prototype.getUnreadMentionedMessages=function(e,t,o){for(var n=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,r=0;r<n.length;r++)n[r]=this._buildMessage(n[r].obj);return n},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("addToBlacklist",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("removeFromBlacklist",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){e._callCppProxy("getBlacklist",(function(e){t({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},e.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.insertMessage=function(e,t,n){var r=this,i=n.content,s=n.senderUserId,a=n.messageType,c=n.messageDirection,u=n.readStatus,p=n.sentStatus,l=n.sentTime,d=n.searchContent,C=n.isUnread,f=n.messageUId,g=n.disableNotification,h=n.canIncludeExpansion,v=n.expansionMsg,_=n.channelId;return i=JSON.stringify(i),new Promise((function(n,S){var y=C?0:1,E=r._callCppProxy("insertMessage",e,t,s,a,i,(function(){}),(function(e){n({code:e})}),c,u,p,l,d,y,f,g,h,v,_);r._electronLogger.info("after insert msg",E);var m=r._buildMessage(E,{isOffLineMessage:!1});m.messageUId=f,m.sentTime=l,n({code:-1===m.messageId?o.ErrorCode.MSG_INSERT_ERROR:o.ErrorCode.SUCCESS,data:m})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,r){t._logger.debug(o.LogTagId.P_DELETE_MSG_S,{messageIds:e}),t._callCppProxy("deleteMessages",e),n(o.ErrorCode.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,n,r,i){var s=this;return new Promise((function(a,c){s._callCppProxy("deleteMessagesByTimestamp",e,t,n,r,i),a(o.ErrorCode.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(n,r){var i=t._callCppProxy("getMessage",e);t._electronLogger.info("getMessage ===>",i);var s=t._buildMessage(i,{isOffLineMessage:!1});n({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.setMessageContent=function(e,t,n){var r=this;return new Promise((function(i,s){t=JSON.stringify(t),r._callCppProxy("setMessageContent",e,t,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("setMessageSearchField",e,t,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("setMessageSentStatus",e,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("setMessageReceivedStatus",e,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,o,n){throw new Error("Method not implemented.")},e.prototype.getConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.clearConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},e.prototype.batchSetConversationStatus=function(e){var t=e[0],n=t.conversationType,r=t.targetId,i=t.isTop,s=t.notificationStatus,a=t.channelId;if(void 0!==i&&void 0===s)return this.setConversationToTop(n,r,i,a);if(void 0!==s&&void 0===i){var c=s===o.NotificationStatus.OPEN;return this.setConversationNotificationStatus(n,r,c,a)}c=s===o.NotificationStatus.OPEN;return this.setConversationStatus(n,r,c,i,a)},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("sendReadReceipt",e,n||"",t,(function(){t.forEach((function(e){r._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(r._callCppProxy("getMessage",e)).messageId;r.setMessageReceivedStatus(t,1)}catch(t){r._electronLogger.warn("format message error, messageUId: "+e)}})),i({code:o.ErrorCode.SUCCESS})}),(function(e){i({code:e})}))}))},e.prototype.getMessageReader=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("getMessageReader",e,n,t,(function(e,n){r._electronLogger.info("getMessageReader -> ",e,n);var s=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,n=t.time;s.push({userId:o,readTime:n}),a[o]=n}));var c={readerInfo:a,readCount:s.length,totalCount:n};r._updateReadReceiptInfo(t,c),i({code:o.ErrorCode.SUCCESS,data:{list:s,totalMemberCount:n}})}),(function(e){i({code:e})}))}))},e.prototype.joinChatroom=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("clearMessages",o.ConversationType.CHATROOM,e,""),n._callCppProxy("joinChatRoom",e,t,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.joinExistChatroom=function(e,t){throw new Error("Method not implemented.")},e.prototype.quitChatroom=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("quitChatRoom",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getChatroomInfo=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("getChatroomInfo",e,t,n,(function(e,t){var n=e?JSON.parse(e).list:[],r=[];if(n.length>0)for(var s=0;s<n.length;s++)r.push(JSON.parse(n[s].obj));i({code:o.ErrorCode.SUCCESS,data:{userInfos:r,userCount:t}})}),(function(e){i({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._callCppProxy("getChatroomHistoryMessage",e,t,n,r,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var n=t.list;if(n&&n.length)try{t.list=n.map((function(e){return i._buildMessage(e.obj)}))}catch(e){t.list=[]}s({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){s({code:e})}),"")}))},e.prototype.setChatroomEntry=function(e,t){var n=this;return new Promise((function(r,i){var s='[{"key":"'+t.key+'", "value":"'+t.value+'"}]';n._callCppProxy("setChatroomKV",e,s,!!t.isAutoDelete,!!t.isOverwrite,(function(){r(o.ErrorCode.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var n=this;return new Promise((function(r){n._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var n=this,r=[t.key];return new Promise((function(i,s){n._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){i(o.ErrorCode.SUCCESS)}),(function(e){i(e)}))}))},e.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(r){var i=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,i,!!t.isOverwrite,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return C(this,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=r.sent()).code===o.ErrorCode.SUCCESS?[2,{code:o.ErrorCode.SUCCESS,data:n.data?n.data[t]:null}]:[2,{code:n.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}n({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},e.prototype.getFileToken=function(e,t,n,r){var i=this;return n=n||"",r=r||"",new Promise((function(s){var a;a=r&&"uploads"!==r?t||"":o.getUploadFileName(e,t),i._callCppProxy("getUploadToken",e,a,n,r,(function(e,t,n,r,i,c,u,p,l,d,C,f,g,h,v,_,S,y){s({code:o.ErrorCode.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:r,osskeyId:i,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:a,s3Credential:l,s3Algorithm:d,s3Date:C,s3Policy:f,s3Signature:g,s3BucketName:h,stcAuthorization:v,stcContentSha256:_,stcDate:S,stcBucketName:y}})}),(function(e){s({code:e})}))}))},e.prototype.getFileUrl=function(e,t,n,r){var i=this;return new Promise((function(s){i._callCppProxy("getDownloadUrl",e,n,r,t-1,(function(e){s({code:o.ErrorCode.SUCCESS,data:{downloadUrl:e}})}),(function(e){s({code:e})}))}))},e.prototype.clearData=function(){var e=this;return new Promise((function(t,n){var r=e._callCppProxy("clearData");t({code:o.ErrorCode.SUCCESS,data:r})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||t.resolve(n.app.getPath("userData"));return y(e)},e.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("getVoIPKey",e,t,"",(function(e){r({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){r({code:e})}))}))},e.prototype.joinRTCRoom=function(e,t,n,r,i,s){var a=this;return new Promise((function(c){var u=i?JSON.stringify(i):"",p=s?JSON.stringify(s):"";a._callCppProxy("joinRTCRoom",e,t,n||0,r||o.RTCJoinType.KICK,(function(e,t,n,r,i,s){var a=JSON.parse(e).list,u={token:t,sessionId:n,users:{},roomInfo:T(r),kvEntries:[],offlineKickTime:s};a.forEach((function(e){var t=e.id,o=e.data;u.users[t]=o[0]||{}})),c({code:o.ErrorCode.SUCCESS,data:u})}),(function(e){a._electronLogger.error("joinRTCRoom error -> ".concat(e)),c({code:e})}),"","",u,p)}))},e.prototype.quitRTCRoom=function(e){var t=this;return new Promise((function(n){t._callCppProxy("exitRTCRoom",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.rtcPing=function(e,t,n){var r=this;return new Promise((function(t){r._callCppProxy("sendRTCPing",e,(function(){t(o.ErrorCode.SUCCESS)}),t)}))},e.prototype.getRTCRoomInfo=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getRTCResouce",e,2,(function(e){n({code:o.ErrorCode.SUCCESS,data:JSON.parse(e)})}),(function(e){n({code:e})}))}))},e.prototype.getRTCUserInfoList=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getRTCResouce",e,1,(function(e){var t=JSON.parse(e).list,r={users:{}};t.forEach((function(e){var t=e.id,o=e.data;r.users[t]=o[0]||{}})),n({code:o.ErrorCode.SUCCESS,data:r})}),(function(e){n({code:e})}))}))},e.prototype.getRTCUserInfo=function(e){throw new Error("Method not implemented.")},e.prototype.setRTCUserInfo=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("setRTCInnerData",e,o.RTCApiType.PERSON,t,n,"","",(function(){i(o.ErrorCode.SUCCESS)}),i)}))},e.prototype.removeRTCUserInfo=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("deleteRTCInnerData",e,o.RTCApiType.PERSON,t,"","",(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.setRTCData=function(e,t,n,r,i,s){var a=this;return new Promise((function(c){var u={room_innder:function(e,t,n,r,i,s,c){a._callCppProxy("setRTCInnerData",e,o.RTCApiType.ROOM,t,n,r,i,s,c)},room_outer:function(e,t,n,r,i,s,c){a._callCppProxy("setRTCOuterData",e,o.RTCApiType.ROOM,t,n,r,i,s,c)},user_innder:function(e,t,n,r,i,s,c){a._callCppProxy("setRTCInnerData",e,o.RTCApiType.PERSON,t,n,r,i,s,c)},user_outer:function(e,t,n,r,i,s,c){a._callCppProxy("setRTCOuterData",e,o.RTCApiType.PERSON,t,n,r,i,s,c)}},p=o.RTCApiType.PERSON===i?"user":"room",l=r?"inner":"outer",d=u["".concat(p,"_").concat(l)];if(d){var C=(null==s?void 0:s.content)?JSON.stringify(s.content):"",f=(null==s?void 0:s.name)||"";d(e,t,n,f,C,(function(){c(o.ErrorCode.SUCCESS)}),(function(e){c(e)}))}}))},e.prototype.setRTCTotalRes=function(e,t,n,r,i){var s=this;return new Promise((function(a){var c=t.name,u=t.content;s._callCppProxy("setUserResource",e,c,u,r,n,i,(function(){return a(o.ErrorCode.SUCCESS)}),a)}))},e.prototype.setRTCCDNUris=function(e,t,n){var r=this;return new Promise((function(i){r._callCppProxy("setRTCCDNUris",e,t,n,(function(){return i(o.ErrorCode.SUCCESS)}))}))},e.prototype.getRTCData=function(e,t,n,r){var i=this;return new Promise((function(s){var a={room_inner:function(e,t,n,r){i._callCppProxy("getRTCInnerData",e,o.RTCApiType.ROOM,t,n,r).getRTCInnerData()},room_outer:function(e,t,n,r){i._callCppProxy("getRTCOuterData",e,o.RTCApiType.ROOM,t,n,r)}},c=o.RTCApiType.PERSON===r?"user":"room",u=n?"inner":"outer",p=a["".concat(c,"_").concat(u)];p&&p(e,t,(function(e){var t=JSON.parse(e),n={};t.list.forEach((function(e){var t=Object.keys(e)[0],o=Object.values(e)[0];n[t]=o})),s({code:o.ErrorCode.SUCCESS,data:n})}),(function(e){s({code:e})}))}))},e.prototype.removeRTCData=function(e,t,n,r,i){var s=this;return new Promise((function(a){s._callCppProxy;var c={room_inner:function(e,t,n,r,i,a){s._callCppProxy("deleteRTCInnerData",e,o.RTCApiType.ROOM,t,n,r,i,a)},room_outer:function(e,t,n,r,i,a){s._callCppProxy("deleteRTCOuterData",e,o.RTCApiType.ROOM,t,n,r,i,a)},user_inner:function(e,t,n,r,i,a){s._callCppProxy("deleteRTCInnerData",e,o.RTCApiType.PERSON,t,n,r,i,a)},user_outer:function(e,t,n,r,i,a){s._callCppProxy("deleteRTCOuterData",e,o.RTCApiType.PERSON,t,n,r,i,a)}},u=o.RTCApiType.PERSON===r?"user":"room",p=n?"inner":"outer",l=c["".concat(u,"_").concat(p)];if(l){var d=(null==i?void 0:i.content)?JSON.stringify(i.content):"",C=(null==i?void 0:i.name)||"";l(e,t,C,d,(function(){a(o.ErrorCode.SUCCESS)}),(function(e){a(e)}))}}))},e.prototype.setRTCOutData=function(e,t,o,n){throw new Error("Method not implemented.")},e.prototype.getRTCOutData=function(e,t){throw new Error("Method not implemented.")},e.prototype.getRTCToken=function(e,t,n){var r=this;return new Promise((function(t){r._callCppProxy("getRTCToken",e,(function(e){t({code:o.ErrorCode.SUCCESS,data:{rtcToken:e}})}),(function(e){t({code:e})}))}))},e.prototype.setRTCState=function(e,t){var n=this;return new Promise((function(r){n._callCppProxy("setRTCUserState",e,t,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.getRTCUserList=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getRTCUsers",e,1,(function(e){n({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("deleteTag",e,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t,n){var r=e._callCppProxy("getTags");e._electronLogger.info("getTagList -> ",r);var i=e._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.addTagForConversations=function(e,t){var n=this;return new Promise((function(r,i){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(r,i){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,n,r){var i=this;return new Promise((function(s,a){var c=i._callCppProxy("getConversationsForTagByPage",e,t,n||20,r||"");i._electronLogger.info("getConversationListByTag -> ",c);var u=i._convertResultList(c,(function(e){return d(d({},i._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:o.ErrorCode.SUCCESS,data:u})}))},e.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(r,i){var s=n._callCppProxy("getConversationUnreadCountForTag",e,t);n._electronLogger.info("getUnreadCountByTag -> ",s),r({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.setConversationStatusInTag=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.isTop||!1,(function(){i({code:o.ErrorCode.SUCCESS})}),(function(e){i({code:e})}))}))},e.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(n,r){var i=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||"");t._electronLogger.info("getTagsForConversation -> ",i);var s=t._convertResultList(i,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));n({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.joinLivingRoomAsAudience=function(e,t,n){return C(this,void 0,void 0,(function(){var n=this;return f(this,(function(r){return[2,new Promise((function(r,i){n._cppProtocol.audienceJoinRoom(e,t,(function(e,t){v.info("joinLivingRoomAsAudience data:",e,t),r({data:{token:e,kvEntries:P(t)},code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))]}))}))},e.prototype.quitLivingRoomAsAudience=function(e){var t=this;return new Promise((function(n,r){t._cppProtocol.audienceLeaveRoom(e,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.switchLivingRoomRole=function(e,t,n){var r=this;return void 0===n&&(n=o.LiveType.AUDIO_AND_VIDEO),new Promise((function(i,s){r._cppProtocol.switchRole(e,n,t,"","",(function(e,t,n,r,s,a){v.info("switchLivingRoomRole data:",e,t,n,r,s);var c=JSON.parse(e).list,u={token:t,sessionId:n,users:{},roomInfo:T(r),kvEntries:P(s),offlineKickTime:a};c.forEach((function(e){var t=e.id,o=e.data;u.users[t]=o[0]||{}})),i({code:o.ErrorCode.SUCCESS,data:u})}),(function(e){i({code:e})}))}))},e.prototype.getRTCJoinedUserInfo=function(e){var t=this;return new Promise((function(e){t._callCppProxy("queryJoinedRoom",(function(n){t._electronLogger.info("getRTCJoinedUserInfo -> ",n);var r=JSON.parse(n).list[0];e(r?{code:o.ErrorCode.SUCCESS,data:[JSON.parse(r.obj)]}:{code:o.ErrorCode.SUCCESS})}),(function(t){e({code:t})}))}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},e.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},e.prototype.requestRoomPK=function(e){var t=this;return new Promise((function(n,r){var i=e.roomId,s=e.invitedRoomId,a=e.invitedUserId,c=e.inviteSessionId,u=e.inviteTimeout,p=e.inviteInfo;t._callCppProxy("livePKInvitation",i,a,s,p,c,u,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.cancelRoomPK=function(e){var t=this;return new Promise((function(n,r){var i=e.roomId,s=e.invitedRoomId,a=e.invitedUserId,c=e.inviteSessionId,u=e.inviteInfo;t._callCppProxy("livePKCancel",i,a,s,u,c,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.responseRoomPK=function(e){var t=this;return new Promise((function(n,r){var i=e.roomId,s=e.inviteUserId,a=e.inviteRoomId,c=e.inviteSessionId,u=e.content,p=e.key,l=e.value,d=e.agree?1:0;t._callCppProxy("livePKAnswer",i,d,s,a,c,u,p,l,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.endRoomPK=function(e){var t=this;return new Promise((function(n,r){var i=e.roomId,s=e.endRoomId,a=e.sessionId,c=e.content,u=e.keys;t._callCppProxy("livePKHangup",i,s,a,c,u,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n,r){var i=e.chatRoomId,s=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",i,s,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e}();module.exports=function(e){return function(e,t){return o.logger.init({customLogPrint:null==t?void 0:t.logStdout,localLogLevel:null==t?void 0:t.logLevel}),v.setLogLevel(null==t?void 0:t.logLevel),v.setLogStdout(null==t?void 0:t.logStdout),new N(e,null==t?void 0:t.dbpath,null==t?void 0:t.reconnectKickEnable)}(l,e)};
|
|
1
|
+
"use strict";var e=require("os"),t=require("path"),o=require("@rongcloud/engine"),n=require("electron"),r=require("fs"),s=require("crypto"),i=require("http"),a=require("https"),c=process.versions.electron.replace(/\.\d+$/,""),u=t.resolve(__dirname,"binding","electron-v".concat(c,"-").concat(e.platform(),"-").concat(e.arch(),".node")),p=null;try{p=require(u)}catch(e){console.error("error ->",u,"\n",e)}var l=p,d=function(){return d=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},d.apply(this,arguments)};function C(e,t,o,n){return new(o||(o=Promise))((function(r,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))}function g(e,t){var o,n,r,s,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(o)throw new TypeError("Generator is already executing.");for(;i;)try{if(o=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){i.label=s[1];break}if(6===s[0]&&i.label<r[1]){i.label=r[1],r=s;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(s);break}r[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],n=0}finally{o=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}}function f(e,t,o){if(o||2===arguments.length)for(var n,r=0,s=t.length;r<s;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))}var h,_=new o.Logger("RCMain"),v=null,S=function(){var t,o=Date.now(),n=[e.arch(),e.platform(),process.pid,o,Math.floor(Math.random()*o)].join("__");return t=n,s.createHash("md5").update(t).digest("hex")},y=function(e){if(v)return v;var o=t.resolve(e,"deviceId");return _.debug("deviceIdPath -> ".concat(o)),r.existsSync(o)?v=r.readFileSync(o).toString():(v=S(),_.debug("createDeviceId -> ".concat(v)),r.writeFileSync(o,v),v)},E=function(){function e(e,t){this._timerId=0,this._heartbeatTimeoutId=0,this._isFirstPing=!0,this._lossCount=0,this._hasPingRes=e,this._reconnect=t}return e.init=function(t,o){return h?(h.stop(),h):h=new e(t,o)},e.prototype.start=function(e){var t=this,o=this,n=function(){var r=t._isFirstPing?0:15e3;o._timerId=setTimeout((function(){o._isFirstPing=!1,_.debug("current lossCount: "+o._lossCount),o._hasPingRes?(e(),o._hasPingRes=!1,n()):o._lossCount<4?(o._lossCount++,e(),n()):o._reconnect()}),r)};n()},e.prototype.stop=function(){this._lossCount=0,clearTimeout(this._timerId)},e.prototype.setHeartbeatRes=function(e){_.debug("receive ping"),this._hasPingRes=e,this._lossCount=0},e}(),m=function(){function e(e){this._setTime=15962112e5,this._cppProto=e}return e.prototype._setToProtocol=function(e,t,o,n,r){var s=JSON.stringify(n);_.info("MsgExpansion._setToProtocol ===>",e,t,o,s,r),this._cppProto.setMessageExtension(e,t,o,s,r)},e.prototype.setLocalFromReceiveMsg=function(e){_.info("MsgExpansion.setLocalFromReceiveMsg ===>",e);var t=e.channelId,o=e.conversationType,n=e.targetId,r=e.messageUId,s=e.expansion,i=e.sentTime,a={};for(var c in s)a[c]={v:"",ts:0},a[c].v=s[c],a[c].ts=i;this._setToProtocol(o,n,r,a,t||"")},e.prototype.setLocalFromExtMsg=function(e){_.info("MsgExpansion.setLocalFromExtMsg ===>",e);var t=e.channelId,o=e.conversationType,n=e.targetId;e.messageUId;var r=e.content,s=e.sentTime,i=r,a=i.put,c=this._cppProto.getMessage(i.mid),u=JSON.parse(c).extMsg,p=JSON.parse(u||"{}");if(_.info("MsgExpansion.setLocalFromExtMsg, serverExtObj",a,"localExt",p),a)for(var l in a){var d=p[l];d&&d.ts<s-this._setTime?(d.v=a[l],d.ts=s-this._setTime):(p[l]={v:"",ts:0},p[l].v=a[l],p[l].ts=s-this._setTime)}i.del&&i.del.forEach((function(e){delete p[e]})),this._setToProtocol(o,n,i.mid,p,t||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var n in t)o[n]=t[n].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),n={};for(var r in o)n[r]=o[r].v;return n},e}(),P=null;function T(e,t,o,n,r){return void 0===r&&(r=!0),C(this,void 0,void 0,(function(){var s;return g(this,(function(c){switch(c.label){case 0:return P?[2,P]:(P=function(e,t,o,n,r){return void 0===r&&(r=!0),C(this,void 0,void 0,(function(){var s,c,u,p;return g(this,(function(l){switch(l.label){case 0:s=function(s,c){var u,p,l,d,C;return g(this,(function(c){switch(c.label){case 0:return u="".concat(t[s],"/navi.json?r=").concat(Date.now()),p="token=".concat(encodeURIComponent(n),"&v=").concat((g=e,g.match(/\d+(\.\d+){2}/)[0]),"&p=PC&ev=").concat("5.5.0-enterprise-alpha.2"),_.info("request navi -> url: ".concat(u,", body: ").concat(p)),[4,new Promise((function(e){var t=/^https/.test(u),n={headers:{appId:o},method:"POST"};t&&(n.rejectUnauthorized=r,n.agent=new a.Agent(n));var s=(t?a.request:i.request)(u,n,(function(t){var o=t.statusCode,n="";t.setEncoding("utf8"),t.on("data",(function(e){n+=e})),t.on("end",(function(){e({status:o||0,data:n})}))}));s.on("error",(function(t){_.error(t),e({status:0})})),s.write(p),s.end()}))];case 1:if(200!==(l=c.sent()).status)return _.error("request navi failed -> ".concat(u)),l.data&&_.error(l.data),[2,"continue"];_.info("request navi success -> ".concat(u));try{return d=JSON.parse(l.data),C=/^https/.test(u)?"https":"http",d.protocol=C,[2,{value:d}]}catch(e){_.error("parse navi err => ".concat(l.data))}return[2]}var g}))},c=0,u=t.length,l.label=1;case 1:return c<u?[5,s(c,u)]:[3,4];case 2:if("object"==typeof(p=l.sent()))return[2,p.value];l.label=3;case 3:return c+=1,[3,1];case 4:return[2,null]}}))}))}(e,t,o,n,r),[4,P]);case 1:return s=c.sent(),P=null,[2,s]}}))}))}var N=function(){function e(e,t,r){void 0===t&&(t=""),void 0===r&&(r=!1);var s=this;this._cppProtocol=e,this._dbpath=t,this._reconnectKickEnable=r,this._currentToken="",this._connectionStatus=o.ConnectionStatus.DISCONNECTED,this._promiseHandler={},this._customMessageType={},this._heartbeat={},this._cppConnectionStatus=o.ConnectionStatus.DISCONNECTED,this._connectedTime=0,this._currentUserId="",this._inited=!1,this._naviInfo=null,this._version="5.5.0-enterprise-alpha.2",this._electronLogger={debug:this._superElectronLog.bind(this,"debug",o.LogLevel.DEBUG),info:this._superElectronLog.bind(this,"info",o.LogLevel.INFO),warn:this._superElectronLog.bind(this,"warn",o.LogLevel.WARN),error:this._superElectronLog.bind(this,"error",o.LogLevel.ERROR),fatal:this._superElectronLog.bind(this,"fatal",o.LogLevel.FATAL)},this._logger={debug:this._superLog.bind(this,"debug",o.LogLevel.DEBUG),info:this._superLog.bind(this,"info",o.LogLevel.INFO),warn:this._superLog.bind(this,"warn",o.LogLevel.WARN),error:this._superLog.bind(this,"error",o.LogLevel.ERROR),fatal:this._superLog.bind(this,"fatal",o.LogLevel.FATAL)},this._senders={},this.rtcHeartbeatResolves={},n.ipcMain.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return C(s,void 0,void 0,(function(){var r,s,i,a;return g(this,(function(c){switch(c.label){case 0:if((a=this._electronLogger).debug.apply(a,f(["__RC_CHANNEL_CALL_MAIN_SYNC__",t],n,!1)),"function"!=typeof(r=this[t]))return e.returnValue=o.ErrorCode.NOT_SUPPORT,[2];s=o.ErrorCode.EXTRA_METHOD_UNDEFINED,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,r.call.apply(r,f([this],n,!1))];case 2:return s=c.sent(),[3,4];case 3:return i=c.sent(),this._electronLogger.error("call main process method `".concat(t,"` failed.")),this._electronLogger.error(i),[3,4];case 4:return e.returnValue=s,[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];return C(s,void 0,void 0,(function(){var s,i,a,c,u,p=this;return g(this,(function(l){switch(l.label){case 0:if((u=this._electronLogger).debug.apply(u,f(["__RC_CHANNEL_CALL_MAIN__",t,n],r,!1)),"function"!=typeof(s=this[n]))return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,o.ErrorCode.NOT_SUPPORT),[2];"sendMessage"===n&&(i=r[3],r[3]=function(t){p._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",i,t)}),a=o.ErrorCode.EXTRA_METHOD_UNDEFINED,l.label=1;case 1:return l.trys.push([1,3,,4]),[4,s.call.apply(s,f([this],r,!1))];case 2:return a=l.sent(),[3,4];case 3:return c=l.sent(),this._electronLogger.error("call main process method `".concat(n,"` failed.")),this._electronLogger.error(c),[3,4];case 4:return this._electronLogger.debug("__RC_CHANNEL_RESULT_FROM_MAIN__",t,n,a),this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,a),[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o,n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];(o=s._electronLogger).debug.apply(o,f(["__RC_CHANNEL_CALL_MAIN__",t],n,!1));var i=s[t];if("function"==typeof i)try{i.call.apply(i,f([s],n,!1))}catch(e){s._electronLogger.error("call main process method `".concat(t,"` failed.")),s._electronLogger.error(e)}else s._electronLogger.error("cannot not found method: ".concat(t))})),n.ipcMain.on("__RC_INNER_COMMAND_INIT__",this._init.bind(this)),this._msgExpansionHandler=new m(this._cppProtocol)}return e.prototype._callCppProxy=function(e){for(var t,o,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];try{return(t=this._cppProtocol)[e].apply(t,n)}catch(t){(o=this._electronLogger).error.apply(o,f([t,e],n,!1))}},e.prototype._superElectronLog=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(_[e]&&_[e].apply(_,n),t!==o.LogLevel.DEBUG){var s=Object.keys(this._senders);if(s.length>0){var i=n.reduce((function(e,t){return e+JSON.stringify(t)}),"");this._senders[s[0]].send("__RC_CHANNEL_CALL_RENDER__","_insertLog2IndexDB",t,i,"RCMain")}}},e.prototype._superLog=function(e,t,n,r,s){if(o.logger[e]&&o.logger[e](n,r,s),t!==o.LogLevel.DEBUG){var i=Object.keys(this._senders);i.length>0&&this._senders[i[0]].send("__RC_CHANNEL_CALL_RENDER__","_insertLog2IndexDB",t,r,n,null==s?void 0:s.logSource)}},e.prototype.getCppProto=function(){return this._cppProtocol},e.prototype.callExtra=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(t=this._electronLogger).info.apply(t,f(["callExtra -> ".concat(e)],n,!1));var s=this[e];if(!s)return this._electronLogger.warn("ExtraHandler.".concat(e," is undefined")),Promise.resolve({code:o.ErrorCode.EXTRA_METHOD_UNDEFINED});try{return s.call.apply(s,f([this],n,!1))}catch(e){this._electronLogger.error(e)}return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})},e.prototype.getConversationsByPage=function(e,t,n,r){var s,i=this,a=this._callCppProxy("getConversationListByPage",e,t,n,r||"");try{s=JSON.parse(a).list.map((function(e){return i._buildConversation(e.obj)}))}catch(e){return this._electronLogger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:s})},e.prototype.getConversationListWithAllChannel=function(){var e,t=this,n=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],r=this._callCppProxy("getConversationListWithAllChannel",n);try{e=JSON.parse(r).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return this._electronLogger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:e})},e.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,r=this,s=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],i=this._callCppProxy("getConversationListWithAllChannelByPage",s,e,t);try{n=JSON.parse(i).list.map((function(e){return r._buildConversation(e.obj)}))}catch(e){return this._electronLogger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:n})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,n,r,s,i,a){var c=0===i,u=r+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,u,s,c,a||""),l=[];try{var d=JSON.parse(p).list;d.reverse();for(var C=0;C<d.length;C++){var g=this._buildMessage(d[C].obj);l[C]=g}}catch(e){return this._electronLogger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:{list:u===l.length?l.slice(1,u):l,hasMore:r<l.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,n,r){void 0===r&&(r=""),this._electronLogger.info("updateMessageReceiptStatus ->",e,t,n,r);var s=this._callCppProxy("updateMessageReceiptStatus",e,t,n,r);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:s})},e.prototype.requestNaviInfo=function(e,t,o,n){return C(this,void 0,void 0,(function(){return g(this,(function(r){return[2,T(this._initOptions.apiVersion,e,t,o,n)]}))}))},e.prototype.getNaviInfoFromCache=function(){return this._naviInfo},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){var e;return(null===(e=this._naviInfo)||void 0===e?void 0:e.userId)||""},e.prototype._send2Renderer=function(e,t){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,f([t],o,!1))},e.prototype._send2AllRenderer=function(e,t,o){var n=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(r){var s=n._senders[r];o.includes(s)||n._send2Renderer(s,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype._init=function(e,r){var s=this,i=e.sender,a=i.id;if(this._senders[a]||(this._senders[a]=i,i.once("destroyed",(function(){delete s._senders[a]}))),!this._inited){this._inited=!0,this._initOptions=r,this._electronLogger.info("init ->",r);var c=this._dbpath||t.resolve(n.app.getPath("userData"));this._logger.info(o.LogTagId.P_INIT_O,{"proto-commitId":this._cppProtocol.getNodeVersion(),appkey:r.appkey,dbpath:c}),this._callCppProxy("initWithAppkey",r.appkey,c),this._electronLogger.warn("cppProto version ->",this._cppProtocol.getNodeVersion()),this._registerMsgTypes();var u=y(c);this._electronLogger.info("deviceId -> ".concat(u)),this._callCppProxy("setDeviceId",u),this._setConnectionStatusListener(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener()}},e.prototype._registerMsgTypes=function(){for(var e in o.SEND_MESSAGE_TYPE_OPTION["RC:RcCmd"]={isCounted:!1,isPersited:!1},o.SEND_MESSAGE_TYPE_OPTION){var t=o.SEND_MESSAGE_TYPE_OPTION[e],n=t.isCounted,r=0;t.isPersited&&(r|=1),n&&(r|=2),"RC:TypSts"===e&&(r=16),this._electronLogger.info("_registerMsgTypes ====>",e,r),this._callCppProxy("registerMessageType",e,r)}},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,r=t.buildFrom,s=JSON.parse(e);this._electronLogger.debug("_buildMessage:",s);var i=s.channelId,a=s.conversationType,c=s.targetId,u=s.senderUserId,p=s.content,l=s.objectName,C=s.messageUid,g=s.direction,f=s.status;s.source;var h=s.messageId,v=s.sentTime,S=s.readReceiptRequest,y=s.supportExt;s.extMsg;var E,m=s.pushContent,P=s.pushTitle,T=s.pushId,N=s.pushConfig,I=s.templateId,L=s.disableTitle,R=s.forcePushDetail;if(o.isObject(p))E=p;else try{E=p?JSON.parse(p):p}catch(e){_.warn("cpp engine build messaga error:",e),E=p}var M={isCounted:!1,isPersited:!1};l in o.SEND_MESSAGE_TYPE_OPTION?M=o.SEND_MESSAGE_TYPE_OPTION[l]:l in this._customMessageType&&(M=this._customMessageType[l]);var O=null;y&&(O=this._msgExpansionHandler.parseReceiveExpansion(s),"conversation"!==r&&"history"!==r||(O=this._msgExpansionHandler.parseConverOrHisExpansion(s)));var b=o.isUndefined(n)?v<this._connectedTime:n,U={};N&&(U=o.pushJSONToConfigs(N,T));var x=d(d({},U),{pushTitle:P,pushContent:m,pushData:m,disablePushTitle:L,forceShowDetailContent:R,templateId:I}),w={channelId:i,conversationType:a,targetId:c,senderUserId:u,content:E||{},messageType:l,messageUId:C,messageDirection:g,isOffLineMessage:b,sentTime:v,receivedTime:0,isPersited:M.isPersited,isCounted:M.isCounted,isMentioned:!1,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:y,expansion:y?O:null,receivedStatus:f,messageId:h,pushConfig:x};if(g===o.MessageDirection.RECEIVE?w.receivedStatus=f:g===o.MessageDirection.SEND&&(w.sentStatus=f),S){var A=JSON.parse(S),D=A.hasRespond,H=A.readerInfo,F={hasRespond:D,readCount:A.readCount,totalCount:A.totalCount},J=[];if(H)for(var B in H)J.push({userId:B,readTime:H[B]});F.readerList=J,w.readReceiptInfo=F}return w},e.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),n=JSON.parse(o),r=n.readReceiptRequest?JSON.parse(n.readReceiptRequest):{},s=d(d({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},e.prototype._buildConversation=function(e){var t=JSON.parse(e);this._electronLogger.debug("_buildConversation",t);var n=t.channelId,r=t.conversationType,s=t.targetId,i=t.unreadCount,a=t.lastestMsg,c=t.isTop,u=t.isBlocked,p=t.matchCount,l=u?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE;return{channelId:n,conversationType:r,targetId:s,unreadMessageCount:i,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:!1,mentionedInfo:null,notificationStatus:l,isTop:c,lastUnreadTime:0,matchCount:p}},e.prototype._sendConnectionStatus2Renderer=function(e){this._send2AllRenderer("status",e)},e.prototype._convertResultList=function(e,t){var o=JSON.parse(e).list;return o=o.map((function(e){var o=JSON.parse(e.obj);return t?t(o):o}))},e.prototype._connectResolve=function(e){this._promiseHandler.connect&&this._promiseHandler.connect.length>0&&(this._promiseHandler.connect.forEach((function(t){t.resolve(e)})),delete this._promiseHandler.connect)},e.prototype._setConnectionStatusListener=function(){var e=this;this._cppProtocol.setConnectionStatusListener((function(t){var n;switch(e._electronLogger.warn("protocol connection status changed:",t),e._cppConnectionStatus=t,t){case 10:n=o.ConnectionStatus.CONNECTING;break;case 31004:return void setTimeout((function(){e._connectResolve(o.ErrorCode.RC_CONN_USER_OR_PASSWD_ERROR)}));case 12:n=o.ConnectionStatus.DISCONNECTED;break;case 13:n=o.ConnectionStatus.BLOCKED,setTimeout((function(){e._connectResolve(o.ErrorCode.RC_CONN_USER_BLOCKED)}));break;case 31023:n=o.ConnectionStatus.FORBID_RECONNECT_BY_OTHER_SAME_CLIENT,setTimeout((function(){e._connectResolve(o.ErrorCode.RC_DISCONN_SAME_CLIENT_ON_LINE)}));break;case 1:case 9:case 11:case 31011:case 3e4:case 30002:n=o.ConnectionStatus.NETWORK_UNAVAILABLE;break;case 30010:n=o.ConnectionStatus.NETWORK_UNAVAILABLE,setTimeout((function(){e._connectionStatus===o.ConnectionStatus.NETWORK_UNAVAILABLE&&e._doConnect()}),5e3);break;case 0:case 33005:n=o.ConnectionStatus.CONNECTED,e._connectedTime=Date.now()-e._cppProtocol.getDeltaTime(),setTimeout((function(){e._connectResolve(o.ErrorCode.SUCCESS),e._heartbeat=E.init(!0,e._handleHeartTimeout.bind(e)),e._heartbeat.start(e._sendHeartbeat.bind(e))}));break;case o.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT:n=o.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT;break;case 30004:return;case 8:case 31006:case 32061:case 32012:n=o.ConnectionStatus.REDIRECT;break;default:n=t}n!==o.ConnectionStatus.CONNECTED&&e._heartbeat&&e._heartbeat.stop&&e._heartbeat.stop(),e._connectionStatus=n,e._logger.info(o.LogTagId.P_CONNECT_S,{status:t}),e._sendConnectionStatus2Renderer(n)}),this._dbOpenCallback,(function(){e._heartbeat.setHeartbeatRes(!0)}))},e.prototype._handleHeartTimeout=function(){var e=this;_.warn("network unavailable! try to reconnect!"),this._sendConnectionStatus2Renderer(o.ConnectionStatus.NETWORK_UNAVAILABLE),this._heartbeat.stop(),setTimeout((function(){return e._doConnect()}),5e3)},e.prototype._dbOpenCallback=function(e){_.info("Sqlite DB Open -> ".concat(e))},e.prototype._sendHeartbeat=function(){_.debug("send ping"),this._cppProtocol.sendHeartbeat()},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,r,s){var i=e._buildMessage(t,{isOffLineMessage:r});if(i.messageType===o.MessageType.GROUP_READ_RECEIPT_REQUEST){var a=i.content,c=a.msgId,u=a.rrn,p=a.tmn;e._updateReadReceiptInfo(c,{readCount:u,totalCount:p})}if("RC:MsgExMsg"===i.messageType)return e._msgExpansionHandler.setLocalFromExtMsg(i),void e._sendMessageExpansion(i);if(i.canIncludeExpansion&&e._msgExpansionHandler.setLocalFromReceiveMsg(i),i.messageType===o.MessageType.SYNC_READ_STATUS){if(i.senderUserId!==e._currentUserId)return;e._callCppProxy("clearUnreadCountByTimestamp",i.conversationType,i.targetId,i.content.lastMessageSendTime,i.channelId||"")}var l=!0;if(0!==n||s||(l=!1),i.messageType!==o.MessageType.LOG_COMMAND||"rongcloudsystem"!==i.senderUserId){var d=i.conversationType,C=i.targetId;i.messageType===o.MessageType.RECALL&&i.senderUserId===e._currentUserId&&(d=i.content.conversationType||d,C=i.content.targetId||C),e._sendMessageNotification(Object.assign(i,{hasMoreMsg:l,conversationType:d,targetId:C}))}else{var g=Object.keys(e._senders).map((function(t){return e._senders[t]}));g.length>0&&e._sendMessageNotification(Object.assign(i,{hasMoreMsg:l}),g.slice(1))}}),(function(){e._sendPullOfflineFinished()}))},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var o=e.channelId,n=e.content,r=n.put,s=n.del,i=n.mid,a={};r&&(a.updatedExpansion={channelId:o,messageUId:i,expansion:r}),s&&(a.deletedExpansion={channelId:o,messageUId:i,deletedKeys:s}),this._send2AllRenderer("expansion",a,t)},e.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},e.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},e.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var n=JSON.parse(t).list,r=[];n.forEach((function(e){var t=JSON.parse(e.obj),n=t.conversationType,s=t.targetId,i=t.status,a=t.channelId,c={notificationStatus:2,isTop:!1};i.forEach((function(e){var t=JSON.parse(e.item);1===t.type?c.notificationStatus=1===Number(t.value)?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE:c.isTop=1===Number(t.value)})),r.push({channelId:a,conversationType:n,targetId:s,updatedItems:{notificationStatus:{val:c.notificationStatus,time:0},isTop:{val:c.isTop,time:0}}})})),e._send2AllRenderer("conversation",r)}),(function(t){e._electronLogger.info("会话标签状态变更",t),e._send2AllRenderer("conversationTag",t)}))},e.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._electronLogger.info("标签变更",t),e._send2AllRenderer("tag",t)}))},e.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){var o=new Uint8Array(t).buffer;e._send2AllRenderer("onRTCDataChange",o)}))},e.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._send2AllRenderer("chatroom",{chatroomDestroyed:t})}))},e.prototype._clearListener=function(){this._cppProtocol.setOnReceiveMessageListener(),this._cppProtocol.setConnectionStatusListener(),this._cppProtocol.setOnReceiveStatusListener(),this._cppProtocol.setUserProfileListener()},e.prototype.registerMessageType=function(e,t,n,r){var s=0;t&&(s|=1),n&&(s|=2),this._customMessageType[e]={isCounted:n,isPersited:t},this._logger.info(o.LogTagId.P_REGTYP_O,{messageType:e,isCounted:n,searchProps:r,isPersited:t}),this._callCppProxy("registerMessageType",e,s,r)},e.prototype.connect=function(e,t,n,r){var s=this;return this._electronLogger.info("connect ->",e,t,n),this._logger.info(o.LogTagId.P_CONNECT_O,{token:e,reconnectKickEnable:n,version:this._version},{traceId:r}),this._currentToken===e&&this._connectionStatus===o.ConnectionStatus.CONNECTED?(this._sendConnectionStatus2Renderer(this._connectionStatus),Promise.resolve(o.ErrorCode.SUCCESS)):(this._currentToken=e,this._naviInfo=t,this._currentUserId=t.userId,!this._promiseHandler.connect&&this._doConnect(n),new Promise((function(e,t){s._promiseHandler.connect?s._promiseHandler.connect.push({resolve:e,reject:t}):s._promiseHandler.connect=[{resolve:e,reject:t}]})))},e.prototype._doConnect=function(e){var t=o.isUndefined(e)?this._reconnectKickEnable:e;this._callCppProxy("connectWithToken",this._currentToken,this._initOptions.apiVersion,JSON.stringify(this._naviInfo),t)},e.prototype.reportSDKInfo=function(e){this._cppProtocol.uploadSDKVersion&&this._cppProtocol.uploadSDKVersion(JSON.stringify(e)),this._electronLogger.info(e)},e.prototype.disconnect=function(){this._cppProtocol.disconnect(!0),this._heartbeat.stop(),this._connectResolve(o.ErrorCode.TIMEOUT)},e.prototype.logout=function(){this.disconnect()},e.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,o){t({userId:e,status:o})}));var o=e.userIds||[];o.length&&this.subscribeUserStatus(o)},e.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("subscribeUserStatus",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("setUserStatus",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getUserStatus",e,(function(e){n({code:o.ErrorCode.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},e.prototype.sendMessage=function(e,t,n,r,s){var i=this,a=n.messageType,c=n.content,u=n.pushContent,p=n.pushData,l=n.directionalUserIdList,d=n.disableNotification,C=n.canIncludeExpansion,g=n.expansion,f=n.isVoipPush,h=n.pushConfig,_=n.channelId,v=n.isMentioned,S=n.mentionedType,y=n.mentionedUserIdList,E=h||{},m=E.iOSConfig,P=E.androidConfig,T=E.pushTitle,N=E.pushContent,I=E.pushData,L=E.disablePushTitle,R=E.forceShowDetailContent,M=E.templateId,O=o.pushConfigsToJSON(m,P);return new Promise((function(n){u=N||u||"",p=I||p||"",d=d||!1,f=f||!1,T=T||"",N=N||"",I=I||"",L=L||!1,R=R||!1,C=C||!1;var h=(null==P?void 0:P.notificationId)||"";if(l=l||[],_=_||"",e===o.ConversationType.GROUP&&v&&c&&(c.mentionedInfo={userIdList:y,type:S||o.MentionedType.ALL}),e===o.ConversationType.GROUP&&a===o.MessageType.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var E in c.receiptMessageDic)l.push(E);var m={};for(var E in g)m[E]={v:""},m[E].v=g[E];var b=M||"";i._logger.info(o.LogTagId.P_SEND_MSG_T,{messageType:a,conversationType:e,targetId:t,channelId:_},{traceId:s});var U=i._callCppProxy("sendMessage",(function(e,t){var r=i._buildMessage(e,{isOffLineMessage:!1});return i._logger.info(o.LogTagId.P_SEND_MSG_R,{code:t,messageUId:r.messageUId,messageId:r.messageId},{traceId:s}),t===o.ErrorCode.SENSITIVE_REPLACE?n({code:t}):("RC:MsgExMsg"===r.messageType&&i._msgExpansionHandler.setLocalFromExtMsg(r),r.canIncludeExpansion&&i._msgExpansionHandler.setLocalFromReceiveMsg(r),n({code:o.ErrorCode.SUCCESS,data:r}))}),(function(e,t){var r=i._buildMessage(e,{isOffLineMessage:!1});return i._logger.warn(o.LogTagId.P_SEND_MSG_R,{code:t,messageUId:r.messageUId,messageId:r.messageId},{traceId:s}),r.sentTime=Date.now()-i._cppProtocol.getDeltaTime(),n({code:t,data:r})}),e,t,a,JSON.stringify(c),l,d,L,R,u,p,h,T,O,b,C,JSON.stringify(m),f,_,0),x=JSON.parse(U);r&&r(x.messageId)}))},e.prototype.recallMsg=function(e,t,n,r,s){var i=this;return new Promise((function(a,c){var u,p=s.user,l=s.pushContent,d=s.channelId,C=s.extra,g=s.pushConfig,f=s.disableNotification,h=s.isDelete,_={conversationType:e,targetId:t,messageUId:n,sentTime:r,user:p,extra:C,channelId:d,isDelete:h||!1};p&&(_.user=p),C&&(_.extra=C);var v={conversationType:e,targetId:t,senderUserId:i._currentUserId,content:_,objectName:o.MessageType.RECALL,messageUid:n,direction:o.MessageDirection.SEND,status:o.ReceivedStatus.UNREAD,sentTime:r,channelId:d},S=i._buildMessage(JSON.stringify(v),{isOffLineMessage:!1});i._callCppProxy("recallMessage",(function(){a({code:o.ErrorCode.SUCCESS,data:S})}),(function(e){a({code:e})}),o.MessageType.RECALL,JSON.stringify(_),f||!1,(null==g?void 0:g.disablePushTitle)||!1,(null==g?void 0:g.forceShowDetailContent)||!1,l||"",(null==g?void 0:g.pushData)||"",(null===(u=null==g?void 0:g.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==g?void 0:g.pushTitle)||"",o.pushConfigsToJSON(null==g?void 0:g.iOSConfig,null==g?void 0:g.androidConfig),(null==g?void 0:g.templateId)||"",d)}))},e.prototype.getHistoryMessage=function(e,t,n,r,s,i,a){var c=this;return new Promise((function(u,p){n=n||0;var l=0===s,d=r+1,C=c._callCppProxy("getHistoryMessages",e,t,n,d,a,l,i),g=JSON.parse(C).list,f=[];g.reverse();for(var h=0;h<g.length;h++){var _=c._buildMessage(g[h].obj);f[h]=_}u({code:o.ErrorCode.SUCCESS,data:{list:d===f.length?f.slice(1,d):f,hasMore:r<f.length}})}))},e.prototype.getRemoteHistoryMessages=function(e,t,n,r,s,i){var a=this;return new Promise((function(c,u){n=n||0;a._callCppProxy("getRemoteHistoryMessages",e,t,n,r,(function(e,t){var n=JSON.parse(e).list,r=[];n.reverse();for(var s=0;s<n.length;s++){var i=a._buildMessage(n[s].obj);r[s]=i}c({code:o.ErrorCode.SUCCESS,data:{list:r,hasMore:!!t}})}),(function(e){c({code:e})}),s,!0,i)}))},e.prototype.deleteRemoteMessage=function(e,t,n,r){var s=this;return new Promise((function(i,a){var c=JSON.stringify(n);s._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,r,(function(){i(o.ErrorCode.SUCCESS)}),i)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){i(o.ErrorCode.SUCCESS)}),(function(e){i(e)}),r)}))},e.prototype.clearMessages=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("clearMessages",e,t,n),s(o.ErrorCode.SUCCESS)}))},e.prototype.getConversationList=function(e,t,n,r,s){var i=this;return void 0===s&&(s=""),new Promise((function(e,t){for(var n=i._callCppProxy("getConversationList",[1,3,6,7],s),r=JSON.parse(n).list,a=[],c=0;c<r.length;c++)a.push(i._buildConversation(r[c].obj));e({code:o.ErrorCode.SUCCESS,data:a})}))},e.prototype.getConversation=function(e,t,n){var r=this;return new Promise((function(s,i){var a=r._callCppProxy("getConversation",e,t,n);if(a)s({code:o.ErrorCode.SUCCESS,data:r._buildConversation(a)});else{var c=r._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),u=void 0;try{u=JSON.parse(c).list}catch(e){r._electronLogger.warn("json parse cppMessagaes error",e),u=[]}var p=null;u.length>0&&(p=r._buildMessage(u[0].obj));var l=r._callCppProxy("getConversationNotificationStatus",e,t,n),d=r._callCppProxy("getConversationTopStatus",e,t,n);s({code:o.ErrorCode.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:p,notificationStatus:l?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,n){var r=this._callCppProxy("removeConversation",e,t,n);return this._electronLogger.info("removeConversation result -> ".concat(r)),Promise.resolve(r?o.ErrorCode.SUCCESS:o.ErrorCode.UNKNOWN)},e.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(r,s){var i=[];i=o.isArray(e)?e:[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.PUBLIC_SERVICE],n._callCppProxy("clearConversations",i,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,n){var r=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:r})},e.prototype.getConversationUnreadCount=function(e,t,n){var r=this;return void 0===n&&(n=""),new Promise((function(s){var i=r._callCppProxy("getUnreadCount",e,t,n);s({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.clearConversationUnreadCount=function(e,t,n){var r=this;return void 0===n&&(n=""),new Promise((function(s,i){r._callCppProxy("clearUnreadCount",e,t,n),s(o.ErrorCode.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("clearUnreadCountByTimestamp",e,t,n,r),i(o.ErrorCode.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,n){var r=this;return new Promise((function(s,i){var a=r._callCppProxy("getTheFirstUnreadMessage",e,t,n),c=r._buildMessage(a);s({code:o.ErrorCode.SUCCESS,data:-1!==c.messageId?c:null})}))},e.prototype.setConversationToTop=function(e,t,n,r){var s=this;return void 0===r&&(r=""),new Promise((function(i,a){s._electronLogger.info("setConversationToTop",e,t,n,r,true),s._callCppProxy("setConversationToTop",e,t,n,r,true),i(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("setConversationHidden",e,t,n,r),i(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._electronLogger.info("setConversationNotificationStatus",e,t,n,r),s._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){i(o.ErrorCode.SUCCESS)}),i,r)}))},e.prototype.setConversationStatus=function(e,t,n,r,s){var i=this;return new Promise((function(a,c){i._electronLogger.info("setConversationStatus",e,t,n,r,s,true),i._callCppProxy("setConversationStatus",e,t,n,r,(function(){a(o.ErrorCode.SUCCESS)}),a,s,true)}))},e.prototype.getConversationNotificationStatus=function(e,t,n){var r=this;return new Promise((function(s,i){var a=r._callCppProxy("getConversationNotificationStatus",e,t,n);s({code:o.ErrorCode.SUCCESS,data:a?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,n,r){var s=this;return new Promise((function(i,a){r=r||[1,3,6,7];for(var c=s._callCppProxy("searchConversationByContent",r,e,t,n),u=JSON.parse(c).list,p=[],l=0;l<u.length;l++)p[l]=s._buildConversation(u[l].obj);i({code:o.ErrorCode.SUCCESS,data:p})}))},e.prototype.searchConversationByContentWithAllChannel=function(e,t,n){var r=this;return new Promise((function(s,i){n=n||[1,3,6,7];for(var a=r._callCppProxy("searchConversationByContentWithAllChannel",n,e,t),c=JSON.parse(a).list,u=[],p=0;p<c.length;p++)u[p]=r._buildConversation(c[p].obj);s({code:o.ErrorCode.SUCCESS,data:u})}))},e.prototype.searchMessageByContent=function(e,t,n,r,s,i,a){var c=this;return new Promise((function(i,u){c._callCppProxy("searchMessageByContent",e,t,n,r,s,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],r=[],s=0;s<n.length;s++)r[s]=c._buildMessage(n[s].obj);i({code:o.ErrorCode.SUCCESS,data:{messages:r,count:t}})}),a)}))},e.prototype.searchMessageByContentWithAllChannel=function(e,t,n,r,s){var i=this;return new Promise((function(a,c){i._callCppProxy("searchMessageByContentWithAllChannel",e,t,n,r,s,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],r=[],s=0;s<n.length;s++)r[s]=i._buildMessage(n[s].obj);a({code:o.ErrorCode.SUCCESS,data:{messages:r,count:t}})}))}))},e.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(e,t,n,r,s,i,a){var c=this;return new Promise((function(u,p){c._callCppProxy("searchMessageByTimestampWithAllChannel",e,t,n,r,s,i,a,(function(e){for(var t=e?JSON.parse(e).list:[],n=[],r=0;r<t.length;r++)n[r]=c._buildMessage(t[r].obj);u({code:o.ErrorCode.SUCCESS,data:{messages:n}})}))}))},e.prototype.getUnreadMentionedMessages=function(e,t,o){for(var n=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,r=0;r<n.length;r++)n[r]=this._buildMessage(n[r].obj);return n},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("addToBlacklist",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("removeFromBlacklist",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){e._callCppProxy("getBlacklist",(function(e){t({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},e.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.insertMessage=function(e,t,n){var r=this,s=n.content,i=n.senderUserId,a=n.messageType,c=n.messageDirection,u=n.readStatus,p=n.sentStatus,l=n.sentTime,d=n.searchContent,C=n.isUnread,g=n.messageUId,f=n.disableNotification,h=n.canIncludeExpansion,_=n.expansionMsg,v=n.channelId;return s=JSON.stringify(s),new Promise((function(n,S){var y=C?0:1,E=r._callCppProxy("insertMessage",e,t,i,a,s,(function(){}),(function(e){n({code:e})}),c,u,p,l,d,y,g,f,h,_,v);r._electronLogger.info("after insert msg",E);var m=r._buildMessage(E,{isOffLineMessage:!1});m.messageUId=g,m.sentTime=l,n({code:-1===m.messageId?o.ErrorCode.MSG_INSERT_ERROR:o.ErrorCode.SUCCESS,data:m})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,r){t._logger.debug(o.LogTagId.P_DELETE_MSG_S,{messageIds:e}),t._callCppProxy("deleteMessages",e),n(o.ErrorCode.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,n,r,s){var i=this;return new Promise((function(a,c){i._callCppProxy("deleteMessagesByTimestamp",e,t,n,r,s),a(o.ErrorCode.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(n,r){var s=t._callCppProxy("getMessage",e);t._electronLogger.info("getMessage ===>",s);var i=t._buildMessage(s,{isOffLineMessage:!1});n({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.setMessageContent=function(e,t,n){var r=this;return new Promise((function(s,i){t=JSON.stringify(t),r._callCppProxy("setMessageContent",e,t,n),s(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("setMessageSearchField",e,t,n),s(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("setMessageSentStatus",e,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("setMessageReceivedStatus",e,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,o,n){throw new Error("Method not implemented.")},e.prototype.getConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.clearConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},e.prototype.batchSetConversationStatus=function(e){var t=e[0],n=t.conversationType,r=t.targetId,s=t.isTop,i=t.notificationStatus,a=t.channelId;if(void 0!==s&&void 0===i)return this.setConversationToTop(n,r,s,a);if(void 0!==i&&void 0===s){var c=i===o.NotificationStatus.OPEN;return this.setConversationNotificationStatus(n,r,c,a)}c=i===o.NotificationStatus.OPEN;return this.setConversationStatus(n,r,c,s,a)},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("sendReadReceipt",e,n||"",t,(function(){t.forEach((function(e){r._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(r._callCppProxy("getMessage",e)).messageId;r.setMessageReceivedStatus(t,1)}catch(t){r._electronLogger.warn("format message error, messageUId: "+e)}})),s({code:o.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},e.prototype.getMessageReader=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("getMessageReader",e,n,t,(function(e,n){r._electronLogger.info("getMessageReader -> ",e,n);var i=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,n=t.time;i.push({userId:o,readTime:n}),a[o]=n}));var c={readerInfo:a,readCount:i.length,totalCount:n};r._updateReadReceiptInfo(t,c),s({code:o.ErrorCode.SUCCESS,data:{list:i,totalMemberCount:n}})}),(function(e){s({code:e})}))}))},e.prototype.joinChatroom=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("clearMessages",o.ConversationType.CHATROOM,e,""),n._callCppProxy("joinChatRoom",e,t,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.joinExistChatroom=function(e,t){throw new Error("Method not implemented.")},e.prototype.quitChatroom=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("quitChatRoom",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getChatroomInfo=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("getChatroomInfo",e,t,n,(function(e,t){var n=e?JSON.parse(e).list:[],r=[];if(n.length>0)for(var i=0;i<n.length;i++)r.push(JSON.parse(n[i].obj));s({code:o.ErrorCode.SUCCESS,data:{userInfos:r,userCount:t}})}),(function(e){s({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("getChatroomHistoryMessage",e,t,n,r,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var n=t.list;if(n&&n.length)try{t.list=n.map((function(e){return s._buildMessage(e.obj)}))}catch(e){t.list=[]}i({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){i({code:e})}),"")}))},e.prototype.setChatroomEntry=function(e,t){var n=this;return new Promise((function(r,s){var i='[{"key":"'+t.key+'", "value":"'+t.value+'"}]';n._callCppProxy("setChatroomKV",e,i,!!t.isAutoDelete,!!t.isOverwrite,(function(){r(o.ErrorCode.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var n=this;return new Promise((function(r){n._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var n=this,r=[t.key];return new Promise((function(s,i){n._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){s(o.ErrorCode.SUCCESS)}),(function(e){s(e)}))}))},e.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(r){var s=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,s,!!t.isOverwrite,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return C(this,void 0,void 0,(function(){var n;return g(this,(function(r){switch(r.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=r.sent()).code===o.ErrorCode.SUCCESS?[2,{code:o.ErrorCode.SUCCESS,data:n.data?n.data[t]:null}]:[2,{code:n.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}n({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},e.prototype.getFileToken=function(e,t,n,r){var s=this;return n=n||"",r=r||"",new Promise((function(i){var a;a=r&&"uploads"!==r?t||"":o.getUploadFileName(e,t),s._callCppProxy("getUploadToken",e,a,n,r,(function(e,t,n,r,s,c,u,p,l,d,C,g,f,h,_,v,S,y){i({code:o.ErrorCode.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:r,osskeyId:s,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:a,s3Credential:l,s3Algorithm:d,s3Date:C,s3Policy:g,s3Signature:f,s3BucketName:h,stcAuthorization:_,stcContentSha256:v,stcDate:S,stcBucketName:y}})}),(function(e){i({code:e})}))}))},e.prototype.getFileUrl=function(e,t,n,r){var s=this;return new Promise((function(i){s._callCppProxy("getDownloadUrl",e,n,r,t-1,(function(e){i({code:o.ErrorCode.SUCCESS,data:{downloadUrl:e}})}),(function(e){i({code:e})}))}))},e.prototype.clearData=function(){var e=this;return new Promise((function(t,n){var r=e._callCppProxy("clearData");t({code:o.ErrorCode.SUCCESS,data:r})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||t.resolve(n.app.getPath("userData"));return y(e)},e.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("getVoIPKey",e,t,"",(function(e){r({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){r({code:e})}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n,r){var s=e.chatRoomId,i=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",s,i,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.rtcSignaling=function(e,t,n,r){var s=this,i=Array.prototype.slice.call(new Uint8Array(r));return new Promise((function(r){s._callCppProxy("rtcSignaling",e,t,n,i,(function(e){var t=new Uint8Array(e).buffer;r({code:o.ErrorCode.SUCCESS,buffer:t})}),(function(e){r({code:e})}))}))},e.prototype._setRTCHeartbeatListener=function(){var e=this;this._cppProtocol.setRTCHeartbeatListener((function(t,o){var n=e.rtcHeartbeatResolves[t];if(n){var r=n.find((function(e){return""===e.seqId}));r&&(r.seqId=o)}}),(function(t,o,n){var r=e.rtcHeartbeatResolves[t];if(r){var s=r.findIndex((function(e){return e.seqId===n}));-1!==s&&r.splice(s,1)[0].resolve(o)}}))},e.prototype.rtcPing=function(e,t,o){var n=this;return new Promise((function(t){var o={resolve:t,seqId:""},r=n.rtcHeartbeatResolves[e];r?r.push(o):n.rtcHeartbeatResolves[e]=[o],n._callCppProxy("sendRTCHeartbeat",[e])}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("deleteTag",e,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t,n){var r=e._callCppProxy("getTags");e._electronLogger.info("getTagList -> ",r);var s=e._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.addTagForConversations=function(e,t){var n=this;return new Promise((function(r,s){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(r,s){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,n,r){var s=this;return new Promise((function(i,a){var c=s._callCppProxy("getConversationsForTagByPage",e,t,n||20,r||"");s._electronLogger.info("getConversationListByTag -> ",c);var u=s._convertResultList(c,(function(e){return d(d({},s._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));i({code:o.ErrorCode.SUCCESS,data:u})}))},e.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(r,s){var i=n._callCppProxy("getConversationUnreadCountForTag",e,t);n._electronLogger.info("getUnreadCountByTag -> ",i),r({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.setConversationStatusInTag=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.isTop||!1,(function(){s({code:o.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},e.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(n,r){var s=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||"");t._electronLogger.info("getTagsForConversation -> ",s);var i=t._convertResultList(s,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));n({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},e.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},e}();module.exports=function(e){return function(e,t){return o.logger.init({customLogPrint:null==t?void 0:t.logStdout,localLogLevel:null==t?void 0:t.logLevel}),_.setLogLevel(null==t?void 0:t.logLevel),_.setLogStdout(null==t?void 0:t.logStdout),new N(e,null==t?void 0:t.dbpath,null==t?void 0:t.reconnectKickEnable)}(l,e)};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"types": "index.d.ts",
|
|
13
13
|
"module": "index.esm.js",
|
|
14
|
-
"version": "5.
|
|
14
|
+
"version": "5.5.0-enterprise-alpha.2",
|
|
15
15
|
"author": "pass-web@rongcloud.cn",
|
|
16
16
|
"license": "LGPL 2.1",
|
|
17
17
|
"homepage": "https://www.rongcloud.cn",
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"globals": "RCMain"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@rongcloud/engine": "=5.
|
|
25
|
+
"@rongcloud/engine": "=5.5.0-enterprise-alpha.2"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|