qn-im-sdk
Version:
QnzsIM SDK
3 lines (2 loc) • 44.4 kB
JavaScript
class e{constructor(){this.events=void 0,this.events={}}emit(e,t){return this.events[e]&&this.events[e].forEach(e=>e(t)),this}on(e,t){return this.events[e]?this.events[e].push(t):this.events[e]=[t],this}off(e,t){if(e&&"function"==typeof t){const s=this.events[e],i=s.findIndex(e=>e===t);s.splice(i,1)}else this.events[e]=[];return this}}function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var i in s)({}).hasOwnProperty.call(s,i)&&(e[i]=s[i])}return e},t.apply(null,arguments)}var s,i,n;!function(e){e.INITSDK="InitSDK",e.LOGIN="Login",e.LOGOUT="Logout",e.GETLOGINSTATUS="GetLoginStatus",e.GETLOGINUSER="GetLoginUser",e.GETSELFUSERINFO="GetSelfUserInfo",e.CREATETEXTMESSAGE="CreateTextMessage",e.CREATETEXTATMESSAGE="CreateTextAtMessage",e.CREATEADVANCEDTEXTMESSAGE="CreateAdvancedTextMessage",e.CREATEIMAGEMESSAGEFROMBYURL="CreateImageMessageByURL",e.CREATESOUNDMESSAGEBYURL="CreateSoundMessageByURL",e.CREATEVIDEOMESSAGEBYURL="CreateVideoMessageByURL",e.CREATEFILEMESSAGEBYURL="CreateFileMessageByURL",e.CREATEIMAGEMESSAGEFROMFULLPATH="CreateImageMessageFromFullPath",e.CREATESOUNDMESSAGEFROMFULLPATH="CreateSoundMessageFromFullPath",e.CREATEVIDEOMESSAGEFROMFULLPATH="CreateVideoMessageFromFullPath",e.CREATEFILEMESSAGEFROMFULLPATH="CreateFileMessageFromFullPath",e.CREATELOCATIONMESSAGE="CreateLocationMessage",e.CREATECUSTOMMESSAGE="CreateCustomMessage",e.CREATEMERGERMESSAGE="CreateMergerMessage",e.CREATEFORWARDMESSAGE="CreateForwardMessage",e.CREATEQUOTEMESSAGE="CreateQuoteMessage",e.CREATEADVANCEDQUOTEMESSAGE="CreateAdvancedQuoteMessage",e.CREATECARDMESSAGE="CreateCardMessage",e.CREATEFACEMESSAGE="CreateFaceMessage",e.SENDMESSAGE="SendMessage",e.SENDMESSAGENOTOSS="SendMessageNotOss",e.GETHISTORYMESSAGELIST="GetHistoryMessageList",e.GETADVANCEDHISTORYMESSAGELIST="GetAdvancedHistoryMessageList",e.GETHISTORYMESSAGELISTREVERSE="GetHistoryMessageListReverse",e.REVOKEMESSAGE="RevokeMessage",e.SETONECONVERSATIONPRIVATECHAT="SetOneConversationPrivateChat",e.DELETEMESSAGEFROMLOCALSTORAGE="DeleteMessageFromLocalStorage",e.DELETEMESSAGEFROMLOCALANDSVR="DeleteMessageFromLocalAndSvr",e.DELETECONVERSATIONFROMLOCALANDSVR="DeleteConversationFromLocalAndSvr",e.DELETEALLCONVERSATIONFROMLOCAL="DeleteAllConversationFromLocal",e.DELETEALLMSGFROMLOCALANDSVR="DeleteAllMsgFromLocalAndSvr",e.DELETEALLMSGFROMLOCAL="DeleteAllMsgFromLocal",e.MARKSINGLEMESSAGEHASREAD="MarkSingleMessageHasRead",e.INSERTSINGLEMESSAGETOLOCALSTORAGE="InsertSingleMessageToLocalStorage",e.INSERTGROUPMESSAGETOLOCALSTORAGE="InsertGroupMessageToLocalStorage",e.TYPINGSTATUSUPDATE="TypingStatusUpdate",e.MARKC2CMESSAGEASREAD="MarkC2CMessageAsRead",e.MARKMESSAGEASREADBYCONID="MarkMessageAsReadByConID",e.CLEARC2CHISTORYMESSAGE="ClearC2CHistoryMessage",e.CLEARC2CHISTORYMESSAGEFROMLOCALANDSVR="ClearC2CHistoryMessageFromLocalAndSvr",e.CLEARGROUPHISTORYMESSAGE="ClearGroupHistoryMessage",e.CLEARGROUPHISTORYMESSAGEFROMLOCALANDSVR="ClearGroupHistoryMessageFromLocalAndSvr",e.ADDFRIEND="AddFriend",e.SEARCHFRIENDS="SearchFriends",e.GETDESIGNATEDFRIENDSINFO="GetDesignatedFriendsInfo",e.GETRECVFRIENDAPPLICATIONLIST="GetRecvFriendApplicationList",e.GETSENDFRIENDAPPLICATIONLIST="GetSendFriendApplicationList",e.GETFRIENDLIST="GetFriendList",e.SETFRIENDREMARK="SetFriendRemark",e.ADDBLACK="AddBlack",e.GETBLACKLIST="GetBlackList",e.REMOVEBLACK="RemoveBlack",e.CHECKFRIEND="CheckFriend",e.ACCEPTFRIENDAPPLICATION="AcceptFriendApplication",e.REFUSEFRIENDAPPLICATION="RefuseFriendApplication",e.DELETEFRIEND="DeleteFriend",e.GETUSERSINFO="GetUsersInfo",e.SETSELFINFO="SetSelfInfo",e.GETALLCONVERSATIONLIST="GetAllConversationList",e.GETCONVERSATIONLISTSPLIT="GetConversationListSplit",e.GETONECONVERSATION="GetOneConversation",e.GETCONVERSATIONIDBYSESSIONTYPE="GetConversationIDBySessionType",e.GETMULTIPLECONVERSATION="GetMultipleConversation",e.DELETECONVERSATION="DeleteConversation",e.SETCONVERSATIONDRAFT="SetConversationDraft",e.PINCONVERSATION="PinConversation",e.GETTOTALUNREADMSGCOUNT="GetTotalUnreadMsgCount",e.GETCONVERSATIONRECVMESSAGEOPT="GetConversationRecvMessageOpt",e.SETCONVERSATIONRECVMESSAGEOPT="SetConversationRecvMessageOpt",e.SEARCHLOCALMESSAGES="SearchLocalMessages",e.MARKGROUPMESSAGEHASREAD="MarkGroupMessageHasRead",e.MARKGROUPMESSAGEASREAD="MarkGroupMessageAsRead",e.INVITEUSERTOGROUP="InviteUserToGroup",e.KICKGROUPMEMBER="KickGroupMember",e.GETGROUPMEMBERSINFO="GetGroupMembersInfo",e.GETGROUPMEMBERLIST="GetGroupMemberList",e.GETGROUPMEMBERLISTBYJOINTIMEFILTER="GetGroupMemberListByJoinTimeFilter",e.SEARCHGROUPMEMBERS="SearchGroupMembers",e.SETGROUPAPPLYMEMBERFRIEND="SetGroupApplyMemberFriend",e.SETGROUPLOOKMEMBERINFO="SetGroupLookMemberInfo",e.GETJOINEDGROUPLIST="GetJoinedGroupList",e.CREATEGROUP="CreateGroup",e.SETGROUPINFO="SetGroupInfo",e.SETGROUPMEMBERNICKNAME="SetGroupMemberNickname",e.GETGROUPSINFO="GetGroupsInfo",e.JOINGROUP="JoinGroup",e.SEARCHGROUPS="SearchGroups",e.QUITGROUP="QuitGroup",e.DISMISSGROUP="DismissGroup",e.CHANGEGROUPMUTE="ChangeGroupMute",e.CHANGEGROUPMEMBERMUTE="ChangeGroupMemberMute",e.TRANSFERGROUPOWNER="TransferGroupOwner",e.GETSENDGROUPAPPLICATIONLIST="GetSendGroupApplicationList",e.GETRECVGROUPAPPLICATIONLIST="GetRecvGroupApplicationList",e.ACCEPTGROUPAPPLICATION="AcceptGroupApplication",e.REFUSEGROUPAPPLICATION="RefuseGroupApplication",e.SIGNAL_INGINVITE="SignalingInvite",e.SIGNALINGINVITEINGROUP="SignalingInviteInGroup",e.SIGNALINGACCEPT="SignalingAccept",e.SIGNALINGREJECT="SignalingReject",e.SIGNALINGCANCEL="SignalingCancel",e.SIGNALINGHUNGUP="SignalingHungUp",e.GETSUBDEPARTMENT="GetSubDepartment",e.GETDEPARTMENTMEMBER="GetDepartmentMember",e.GETUSERINDEPARTMENT="GetUserInDepartment",e.GETDEPARTMENTMEMBERANDSUBDEPARTMENT="GetDepartmentMemberAndSubDepartment",e.GETDEPARTMENTINFO="GetDepartmentInfo",e.SEARCHORGANIZATION="SearchOrganization",e.RESETCONVERSATIONGROUPATTYPE="ResetConversationGroupAtType",e.SETGROUPMEMBERROLELEVEL="SetGroupMemberRoleLevel",e.SETGROUPVERIFICATION="SetGroupVerification",e.SETGLOBALRECVMESSAGEOPT="SetGlobalRecvMessageOpt",e.NEWREVOKEMESSAGE="NewRevokeMessage",e.FINDMESSAGELIST="FindMessageList"}(s||(s={})),function(e){e.ONCONNECTFAILED="OnConnectFailed",e.ONCONNECTSUCCESS="OnConnectSuccess",e.ONCONNECTING="OnConnecting",e.ONKICKEDOFFLINE="OnKickedOffline",e.ONSELFINFOUPDATED="OnSelfInfoUpdated",e.ONUSERTOKENEXPIRED="OnUserTokenExpired",e.ONPROGRESS="OnProgress",e.ONRECVNEWMESSAGE="OnRecvNewMessage",e.ONRECVNEWMESSAGES="OnRecvNewMessages",e.ONRECVMESSAGEREVOKED="OnRecvMessageRevoked",e.ONRECVC2CREADRECEIPT="OnRecvC2CReadReceipt",e.ONRECVGROUPREADRECEIPT="OnRecvGroupReadReceipt",e.ONCONVERSATIONCHANGED="OnConversationChanged",e.ONNEWCONVERSATION="OnNewConversation",e.ONSYNCSERVERFAILED="OnSyncServerFailed",e.ONSYNCSERVERFINISH="OnSyncServerFinish",e.ONSYNCSERVERSTART="OnSyncServerStart",e.ONTOTALUNREADMESSAGECOUNTCHANGED="OnTotalUnreadMessageCountChanged",e.ONBLACKADDED="OnBlackAdded",e.ONBLACKDELETED="OnBlackDeleted",e.ONFRIENDAPPLICATIONACCEPTED="OnFriendApplicationAccepted",e.ONFRIENDAPPLICATIONADDED="OnFriendApplicationAdded",e.ONFRIENDAPPLICATIONDELETED="OnFriendApplicationDeleted",e.ONFRIENDAPPLICATIONREJECTED="OnFriendApplicationRejected",e.ONFRIENDINFOCHANGED="OnFriendInfoChanged",e.ONFRIENDADDED="OnFriendAdded",e.ONFRIENDDELETED="OnFriendDeleted",e.ONJOINEDGROUPADDED="OnJoinedGroupAdded",e.ONJOINEDGROUPDELETED="OnJoinedGroupDeleted",e.ONGROUPMEMBERADDED="OnGroupMemberAdded",e.ONGROUPMEMBERDELETED="OnGroupMemberDeleted",e.ONGROUPAPPLICATIONADDED="OnGroupApplicationAdded",e.ONGROUPAPPLICATIONDELETED="OnGroupApplicationDeleted",e.ONGROUPINFOCHANGED="OnGroupInfoChanged",e.ONGROUPMEMBERINFOCHANGED="OnGroupMemberInfoChanged",e.ONGROUPAPPLICATIONACCEPTED="OnGroupApplicationAccepted",e.ONGROUPAPPLICATIONREJECTED="OnGroupApplicationRejected",e.ONRECEIVENEWINVITATION="OnReceiveNewInvitation",e.ONINVITEEACCEPTED="OnInviteeAccepted",e.ONINVITEEREJECTED="OnInviteeRejected",e.ONINVITATIONCANCELLED="OnInvitationCancelled",e.ONHANGUP="OnHangUp",e.ONINVITATIONTIMEOUT="OnInvitationTimeout",e.ONINVITEEACCEPTEDBYOTHERDEVICE="OnInviteeAcceptedByOtherDevice",e.ONINVITEEREJECTEDBYOTHERDEVICE="OnInviteeRejectedByOtherDevice",e.ONORGANIZATIONUPDATED="OnOrganizationUpdated",e.ONRECVNEWMESSAGEFROMOTHERWEB="OnRecvNewMessageFromOtherWeb",e.ONNEWRECVMESSAGEREVOKED="OnNewRecvMessageRevoked",e.ONSENSITIVEWORDBLOCKED="OnSensitiveWordBlocked"}(i||(i={})),function(e){e[e.UPLOAD_RATE_LIMIT=10001]="UPLOAD_RATE_LIMIT",e[e.SENSITIVE_WORD_BLOCKED=10002]="SENSITIVE_WORD_BLOCKED"}(n||(n={}));const o=e=>{try{e&&e.terminate()}catch(e){console.log(e)}},r=e=>(36*Math.random()).toString(36).slice(2)+(new Date).getTime().toString()+e;class a{constructor(){this.userUploadRecords=new Map,this.UPLOAD_LIMIT=6,this.TIME_WINDOW=6e4,this.PENDING_EXPIRE_TIME=6e4}static getInstance(){return a.instance||(a.instance=new a),a.instance}checkUploadLimit(e){const t=Date.now();let s=this.userUploadRecords.get(e);return s||(s={timestamps:[],pendingUploads:new Map},this.userUploadRecords.set(e,s)),s.timestamps=s.timestamps.filter(e=>t-e<this.TIME_WINDOW),s.timestamps.length>=this.UPLOAD_LIMIT?(console.log(`[UploadRateLimit] 用户 ${e} 上传次数已达限制: ${s.timestamps.length}/${this.UPLOAD_LIMIT}`),!1):(s.timestamps.push(t),console.log(`[UploadRateLimit] 用户 ${e} 上传记录: ${s.timestamps.length}/${this.UPLOAD_LIMIT}`),!0)}checkLimit(e){const t=Date.now();let s=this.userUploadRecords.get(e);s||(s={timestamps:[],pendingUploads:new Map},this.userUploadRecords.set(e,s)),s.timestamps=s.timestamps.filter(e=>t-e<this.TIME_WINDOW);for(const[e,i]of s.pendingUploads.entries())t-i>this.TIME_WINDOW&&s.pendingUploads.delete(e);const i=s.timestamps.length+s.pendingUploads.size;return!(i>=this.UPLOAD_LIMIT&&(console.log(`[UploadRateLimit] 用户 ${e} 达到限制: 实际${s.timestamps.length} + 预占${s.pendingUploads.size} = ${i}/${this.UPLOAD_LIMIT}`),1))}recordUpload(e,t){const s=Date.now();let i=this.userUploadRecords.get(e);i||(i={timestamps:[],pendingUploads:new Map},this.userUploadRecords.set(e,i)),t?(i.pendingUploads.set(t,s),console.log(`[UploadRateLimit] 用户 ${e} 预占用配额,token: ${t}`)):i.timestamps.push(s)}releaseQuota(e,t){const s=this.userUploadRecords.get(e);s&&s.pendingUploads.has(t)&&(s.pendingUploads.delete(t),console.log(`[UploadRateLimit] 用户 ${e} 释放配额,token: ${t}`))}getRemainingTime(e){const t=Date.now(),s=this.userUploadRecords.get(e);if(!s)return 0;const i=[...s.timestamps];for(const[e,t]of s.pendingUploads.entries())i.push(t);const n=i.filter(e=>t-e<this.TIME_WINDOW);return n.length<this.UPLOAD_LIMIT?0:(n.sort((e,t)=>e-t),Math.max(0,this.TIME_WINDOW-(t-n[n.length-this.UPLOAD_LIMIT])))}clearUserRecord(e){this.userUploadRecords.delete(e)}clearAllRecords(){this.userUploadRecords.clear()}}a.instance=void 0;var E=a.getInstance(),d=["乱伦","春药","疆独","藏独","暴动","毛片","军火","针孔","女优","肉棍","反华","反共","换妻","偷拍","露点","走光","共奴","乱交","鸡巴","露毛","肉棒","龟头","冰毒","迷药","性奴","暴政","婊子","法+輪+功","干 你 妈","草你妈","老 婊 子","蒙-汗-药","迷-魂-药","迷魂药","迷昏药","江泽民","胡锦涛","习近平","毛泽东","李克强"],u=new class{constructor(){this.words=[],this.mode=2,this.loadWords(d)}loadWords(e){this.words=e}setMode(e){this.mode=e}getMode(){return this.mode}detect(e){const t=[];for(const s of this.words)e.includes(s)&&t.push(s);return{hasSensitive:t.length>0,words:t}}replace(e){let t=e;for(const e of this.words){const s="*".repeat(e.length),i=new RegExp(e,"g");t=t.replace(i,s)}return t}filter(e){return this.detect(e).hasSensitive?1===this.mode?{success:!0,content:this.replace(e)}:{success:!1,content:e,message:"该消息有敏感词被屏蔽"}:{success:!0,content:e}}};class I extends e{constructor(){super(),this.ws=void 0,this.uid=void 0,this.token=void 0,this.platform="web",this.wsUrl="",this.lock=!1,this.logoutFlag=!1,this.ws2promise={},this.onceFlag=!0,this.timer=void 0,this.lastTime=0,this.heartbeatCount=0,this.heartbeatStartTime=0,this.platformID=0,this.isBatch=!1,this.worker=null,this.checkUploadPermission=e=>new Promise((t,s)=>{const i=e||r(this.uid);if(!E.checkLimit(this.uid||""))return this.emitUploadLimitMessage(i),void s({event:"checkUploadPermission",errCode:n.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:{allowed:!1,reason:"rate_limit",remainingTime:E.getRemainingTime(this.uid||"")},operationID:i});const o=i;E.recordUpload(this.uid||"",o),t({event:"checkUploadPermission",errCode:0,errMsg:"",data:{allowed:!0,uploadToken:o,expiresIn:6e4},operationID:i})}),this.releaseUploadQuota=e=>{E.releaseQuota(this.uid||"",e)},this.getLoginStatus=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.GETLOGINSTATUS,operationID:n,userID:this.uid,data:""},t,i)}),this.getLoginUser=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.GETLOGINUSER,operationID:n,userID:this.uid,data:""},t,i)}),this.getSelfUserInfo=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.GETSELFUSERINFO,operationID:n,userID:this.uid,data:""},t,i)}),this.getUsersInfo=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETUSERSINFO,operationID:o,userID:this.uid,data:e},i,n)}),this.setSelfInfo=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SETSELFINFO,operationID:o,userID:this.uid,data:e},i,n)}),this.createTextMessage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CREATETEXTMESSAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.createTextAtMessage=(e,i)=>new Promise((n,o)=>{const a=t({},e);a.atUserIDList=JSON.stringify(a.atUserIDList),a.atUsersInfo=JSON.stringify(a.atUsersInfo);const E=i||r(this.uid);this.wsSend({reqFuncName:s.CREATETEXTATMESSAGE,operationID:E,userID:this.uid,data:a},n,o)}),this.createAdvancedTextMessage=(e,i)=>new Promise((n,o)=>{const a=t({},e);a.messageEntityList=JSON.stringify(a.messageEntityList);const E=i||r(this.uid);this.wsSend({reqFuncName:s.CREATEADVANCEDTEXTMESSAGE,operationID:E,userID:this.uid,data:a},n,o)}),this.createImageMessage=(e,i)=>new Promise((o,a)=>{const d=i||r(this.uid);if(!E.checkUploadLimit(this.uid||"unknown"))return this.emitUploadLimitMessage(d),void a({event:s.CREATEIMAGEMESSAGEFROMBYURL,errCode:n.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:d});let u=t({},e);u.bigPicture=JSON.stringify(u.bigPicture),u.snapshotPicture=JSON.stringify(u.snapshotPicture),u.sourcePicture=JSON.stringify(u.sourcePicture);const I={reqFuncName:s.CREATEIMAGEMESSAGEFROMBYURL,operationID:d,userID:this.uid,data:JSON.stringify(u)};this.wsSend(I,o,a)}),this.createSoundMessage=(e,t)=>new Promise((i,o)=>{const a=t||r(this.uid);if(!E.checkUploadLimit(this.uid||"unknown"))return this.emitUploadLimitMessage(a),void o({event:s.CREATESOUNDMESSAGEBYURL,errCode:n.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:a});let d={soundBaseInfo:JSON.stringify(e)};const u={reqFuncName:s.CREATESOUNDMESSAGEBYURL,operationID:a,userID:this.uid,data:JSON.stringify(d)};this.wsSend(u,i,o)}),this.createVideoMessage=(e,t)=>new Promise((i,o)=>{const a=t||r(this.uid);if(!E.checkUploadLimit(this.uid||"unknown"))return this.emitUploadLimitMessage(a),void o({event:s.CREATEVIDEOMESSAGEBYURL,errCode:n.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:a});let d={videoBaseInfo:JSON.stringify(e)};const u={reqFuncName:s.CREATEVIDEOMESSAGEBYURL,operationID:a,userID:this.uid,data:JSON.stringify(d)};this.wsSend(u,i,o)}),this.createFileMessage=(e,t)=>new Promise((i,o)=>{const a=t||r(this.uid);if(!E.checkUploadLimit(this.uid||"unknown"))return this.emitUploadLimitMessage(a),void o({event:s.CREATEFILEMESSAGEBYURL,errCode:n.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:a});let d={fileBaseInfo:JSON.stringify(e)};const u={reqFuncName:s.CREATEFILEMESSAGEBYURL,operationID:a,userID:this.uid,data:JSON.stringify(d)};this.wsSend(u,i,o)}),this.createFileMessageFromFullPath=(e,t)=>new Promise((i,o)=>{const a=t||r(this.uid);if(!E.checkUploadLimit(this.uid||"unknown"))return this.emitUploadLimitMessage(a),void o({event:s.CREATEFILEMESSAGEFROMFULLPATH,errCode:n.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:a});this.wsSend({reqFuncName:s.CREATEFILEMESSAGEFROMFULLPATH,operationID:a,userID:this.uid,data:e},i,o)}),this.createImageMessageFromFullPath=(e,t)=>new Promise((i,o)=>{const a=t||r(this.uid);if(!E.checkUploadLimit(this.uid||"unknown"))return this.emitUploadLimitMessage(a),void o({event:s.CREATEIMAGEMESSAGEFROMFULLPATH,errCode:n.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:a});this.wsSend({reqFuncName:s.CREATEIMAGEMESSAGEFROMFULLPATH,operationID:a,userID:this.uid,data:e},i,o)}),this.createSoundMessageFromFullPath=(e,t)=>new Promise((i,o)=>{const a=t||r(this.uid);if(!E.checkUploadLimit(this.uid||"unknown"))return this.emitUploadLimitMessage(a),void o({event:s.CREATESOUNDMESSAGEFROMFULLPATH,errCode:n.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:a});this.wsSend({reqFuncName:s.CREATESOUNDMESSAGEFROMFULLPATH,operationID:a,userID:this.uid,data:e},i,o)}),this.createVideoMessageFromFullPath=(e,t)=>new Promise((i,o)=>{const a=t||r(this.uid);if(!E.checkUploadLimit(this.uid||"unknown"))return this.emitUploadLimitMessage(a),void o({event:s.CREATEVIDEOMESSAGEFROMFULLPATH,errCode:n.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:a});this.wsSend({reqFuncName:s.CREATEVIDEOMESSAGEFROMFULLPATH,operationID:a,userID:this.uid,data:e},i,o)}),this.createMergerMessage=(e,i)=>new Promise((n,o)=>{const a=i||r(this.uid);let E=t({},e);E.messageList=JSON.stringify(e.messageList),E.summaryList=JSON.stringify(e.summaryList),this.wsSend({reqFuncName:s.CREATEMERGERMESSAGE,operationID:a,userID:this.uid,data:E},n,o)}),this.createForwardMessage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CREATEFORWARDMESSAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.createFaceMessage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CREATEFACEMESSAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.createLocationMessage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CREATELOCATIONMESSAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.createCustomMessage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CREATECUSTOMMESSAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.createQuoteMessage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CREATEQUOTEMESSAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.createAdvancedQuoteMessage=(e,i)=>new Promise((n,o)=>{const a=i||r(this.uid),E=t({},e);E.messageEntityList=JSON.stringify(E.messageEntityList),this.wsSend({reqFuncName:s.CREATEADVANCEDQUOTEMESSAGE,operationID:a,userID:this.uid,data:E},n,o)}),this.createCardMessage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CREATECARDMESSAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.sendMessage=(e,o)=>new Promise((a,E)=>{const d=o||r(this.uid),I=t({},e);try{const t=JSON.parse(e.message);if([101,106,114,117].includes(t.contentType)&&t.content){const o=u.filter(t.content);if(!o.success){const r=u.detect(t.content);console.log("[IM SDK] 检测到敏感词,阻止发送:",r.words);const a={clientMsgID:`system_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,serverMsgID:"",createTime:Date.now(),sendTime:Date.now(),contentType:101,content:"[系统提示] 该消息有敏感词被屏蔽",senderUserID:"system",senderNickname:"系统提示",recvID:e.recvID,groupID:e.groupID,status:1,isRead:!0,msgFrom:100,attachedInfo:"",ex:"",localEx:JSON.stringify({isSensitiveWordBlocked:!0,blockedWords:r.words,originalContent:t.content})};setTimeout(()=>{this.emit(i.ONRECVNEWMESSAGE,{event:i.ONRECVNEWMESSAGE,errCode:0,errMsg:"",data:a,operationID:d})},0),this.emit(i.ONSENSITIVEWORDBLOCKED,{originalMessage:t,blockedWords:r.words,recvID:e.recvID,groupID:e.groupID});const I={event:s.SENDMESSAGE,errCode:n.SENSITIVE_WORD_BLOCKED,errMsg:o.message||"该消息有敏感词被屏蔽",data:"",operationID:d};return console.log("[IM SDK] 返回敏感词错误:",I),void E(I)}o.content!==t.content&&(console.log("[IM SDK] 敏感词已替换"),t.content=o.content,I.message=JSON.stringify(t))}}catch(e){console.error("[IM SDK] 解析消息内容失败:",e)}I.offlinePushInfo=I.offlinePushInfo?JSON.stringify(e.offlinePushInfo):"",this.wsSend({reqFuncName:s.SENDMESSAGE,operationID:d,userID:this.uid,data:I},a,E)}),this.sendMessageNotOss=(e,o)=>new Promise((a,E)=>{const d=o||r(this.uid),I=t({},e);try{const t=JSON.parse(e.message);if([101,106,114,117].includes(t.contentType)&&t.content){const o=u.filter(t.content);if(!o.success){const r=u.detect(t.content);console.log("[IM SDK] 检测到敏感词,阻止发送:",r.words);const a={clientMsgID:`system_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,serverMsgID:"",createTime:Date.now(),sendTime:Date.now(),contentType:101,content:"[系统提示] 该消息有敏感词被屏蔽",senderUserID:"system",senderNickname:"系统提示",recvID:e.recvID,groupID:e.groupID,status:1,isRead:!0,msgFrom:100,attachedInfo:"",ex:"",localEx:JSON.stringify({isSensitiveWordBlocked:!0,blockedWords:r.words,originalContent:t.content})};setTimeout(()=>{this.emit(i.ONRECVNEWMESSAGE,{event:i.ONRECVNEWMESSAGE,errCode:0,errMsg:"",data:a,operationID:d})},0),this.emit(i.ONSENSITIVEWORDBLOCKED,{originalMessage:t,blockedWords:r.words,recvID:e.recvID,groupID:e.groupID});const I={event:s.SENDMESSAGENOTOSS,errCode:n.SENSITIVE_WORD_BLOCKED,errMsg:o.message||"该消息有敏感词被屏蔽",data:"",operationID:d};return console.log("[IM SDK] 返回敏感词错误:",I),void E(I)}o.content!==t.content&&(console.log("[IM SDK] 敏感词已替换"),t.content=o.content,I.message=JSON.stringify(t))}}catch(e){console.error("[IM SDK] 解析消息内容失败:",e)}I.offlinePushInfo=I.offlinePushInfo?JSON.stringify(e.offlinePushInfo):"",this.wsSend({reqFuncName:s.SENDMESSAGENOTOSS,operationID:d,userID:this.uid,data:I},a,E)}),this.getHistoryMessageList=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETHISTORYMESSAGELIST,operationID:o,userID:this.uid,data:e},i,n)}),this.getAdvancedHistoryMessageList=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETADVANCEDHISTORYMESSAGELIST,operationID:o,userID:this.uid,data:e},i,n)}),this.getHistoryMessageListReverse=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETHISTORYMESSAGELISTREVERSE,operationID:o,userID:this.uid,data:e},i,n)}),this.revokeMessage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.REVOKEMESSAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.setOneConversationPrivateChat=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SETONECONVERSATIONPRIVATECHAT,operationID:o,userID:this.uid,data:e},i,n)}),this.deleteMessageFromLocalStorage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.DELETEMESSAGEFROMLOCALSTORAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.deleteMessageFromLocalAndSvr=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.DELETEMESSAGEFROMLOCALANDSVR,operationID:o,userID:this.uid,data:e},i,n)}),this.deleteConversationFromLocalAndSvr=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.DELETECONVERSATIONFROMLOCALANDSVR,operationID:o,userID:this.uid,data:e},i,n)}),this.deleteAllConversationFromLocal=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.DELETEALLCONVERSATIONFROMLOCAL,operationID:n,userID:this.uid,data:""},t,i)}),this.deleteAllMsgFromLocal=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.DELETEALLMSGFROMLOCAL,operationID:n,userID:this.uid,data:""},t,i)}),this.deleteAllMsgFromLocalAndSvr=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.DELETEALLMSGFROMLOCALANDSVR,operationID:n,userID:this.uid,data:""},t,i)}),this.markGroupMessageHasRead=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.MARKGROUPMESSAGEHASREAD,operationID:o,userID:this.uid,data:e},i,n)}),this.markGroupMessageAsRead=(e,i)=>new Promise((n,o)=>{const a=i||r(this.uid),E=t({},e);E.msgIDList=JSON.stringify(E.msgIDList),this.wsSend({reqFuncName:s.MARKGROUPMESSAGEASREAD,operationID:a,userID:this.uid,data:E},n,o)}),this.insertSingleMessageToLocalStorage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.INSERTSINGLEMESSAGETOLOCALSTORAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.insertGroupMessageToLocalStorage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.INSERTGROUPMESSAGETOLOCALSTORAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.typingStatusUpdate=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.TYPINGSTATUSUPDATE,operationID:o,userID:this.uid,data:e},i,n)}),this.markC2CMessageAsRead=(e,i)=>new Promise((n,o)=>{let a=t({},e);a.msgIDList=JSON.stringify(a.msgIDList);const E=i||r(this.uid);this.wsSend({reqFuncName:s.MARKC2CMESSAGEASREAD,operationID:E,userID:this.uid,data:a},n,o)}),this.markNotifyMessageHasRead=(e,t)=>{this.markMessageAsReadByConID({conversationID:e,msgIDList:[]})},this.markMessageAsReadByConID=(e,i)=>new Promise((n,o)=>{let a=t({},e);a.msgIDList=JSON.stringify(a.msgIDList);const E=i||r(this.uid);this.wsSend({reqFuncName:s.MARKMESSAGEASREADBYCONID,operationID:E,userID:this.uid,data:a},n,o)}),this.clearC2CHistoryMessage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CLEARC2CHISTORYMESSAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.clearC2CHistoryMessageFromLocalAndSvr=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CLEARC2CHISTORYMESSAGEFROMLOCALANDSVR,operationID:o,userID:this.uid,data:e},i,n)}),this.clearGroupHistoryMessage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CLEARGROUPHISTORYMESSAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.clearGroupHistoryMessageFromLocalAndSvr=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CLEARGROUPHISTORYMESSAGEFROMLOCALANDSVR,operationID:o,userID:this.uid,data:e},i,n)}),this.getAllConversationList=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.GETALLCONVERSATIONLIST,operationID:n,userID:this.uid,data:""},t,i)}),this.getConversationListSplit=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETCONVERSATIONLISTSPLIT,operationID:o,userID:this.uid,data:e},i,n)}),this.getOneConversation=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETONECONVERSATION,operationID:o,userID:this.uid,data:e},i,n)}),this.getConversationIDBySessionType=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETCONVERSATIONIDBYSESSIONTYPE,operationID:o,userID:this.uid,data:e},i,n)}),this.getMultipleConversation=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETMULTIPLECONVERSATION,operationID:o,userID:this.uid,data:e},i,n)}),this.deleteConversation=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.DELETECONVERSATION,operationID:o,userID:this.uid,data:e},i,n)}),this.setConversationDraft=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SETCONVERSATIONDRAFT,operationID:o,userID:this.uid,data:e},i,n)}),this.pinConversation=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.PINCONVERSATION,operationID:o,userID:this.uid,data:e},i,n)}),this.getTotalUnreadMsgCount=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.GETTOTALUNREADMSGCOUNT,operationID:n,userID:this.uid,data:""},t,i)}),this.getConversationRecvMessageOpt=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETCONVERSATIONRECVMESSAGEOPT,operationID:o,userID:this.uid,data:e},i,n)}),this.setConversationRecvMessageOpt=(e,i)=>new Promise((n,o)=>{const a=i||r(this.uid),E=t({},e);E.conversationIDList=JSON.stringify(e.conversationIDList),this.wsSend({reqFuncName:s.SETCONVERSATIONRECVMESSAGEOPT,operationID:a,userID:this.uid,data:E},n,o)}),this.searchLocalMessages=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SEARCHLOCALMESSAGES,operationID:o,userID:this.uid,data:e},i,n)}),this.addFriend=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.ADDFRIEND,operationID:o,userID:this.uid,data:e},i,n)}),this.searchFriends=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SEARCHFRIENDS,operationID:o,userID:this.uid,data:e},i,n)}),this.getDesignatedFriendsInfo=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETDESIGNATEDFRIENDSINFO,operationID:o,userID:this.uid,data:e},i,n)}),this.getRecvFriendApplicationList=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.GETRECVFRIENDAPPLICATIONLIST,operationID:n,userID:this.uid,data:""},t,i)}),this.getSendFriendApplicationList=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.GETSENDFRIENDAPPLICATIONLIST,operationID:n,userID:this.uid,data:""},t,i)}),this.getFriendList=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.GETFRIENDLIST,operationID:n,userID:this.uid,data:""},t,i)}),this.setFriendRemark=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SETFRIENDREMARK,operationID:o,userID:this.uid,data:e},i,n)}),this.checkFriend=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CHECKFRIEND,operationID:o,userID:this.uid,data:e},i,n)}),this.acceptFriendApplication=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.ACCEPTFRIENDAPPLICATION,operationID:o,userID:this.uid,data:e},i,n)}),this.refuseFriendApplication=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.REFUSEFRIENDAPPLICATION,operationID:o,userID:this.uid,data:e},i,n)}),this.deleteFriend=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.DELETEFRIEND,operationID:o,userID:this.uid,data:e},i,n)}),this.addBlack=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.ADDBLACK,operationID:o,userID:this.uid,data:e},i,n)}),this.removeBlack=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.REMOVEBLACK,operationID:o,userID:this.uid,data:e},i,n)}),this.getBlackList=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.GETBLACKLIST,operationID:n,userID:this.uid,data:""},t,i)}),this.inviteUserToGroup=(e,i)=>new Promise((n,o)=>{const a=i||r(this.uid),E=t({},e);E.userIDList=JSON.stringify(E.userIDList),this.wsSend({reqFuncName:s.INVITEUSERTOGROUP,operationID:a,userID:this.uid,data:E},n,o)}),this.kickGroupMember=(e,i)=>new Promise((n,o)=>{const a=i||r(this.uid),E=t({},e);E.userIDList=JSON.stringify(E.userIDList),this.wsSend({reqFuncName:s.KICKGROUPMEMBER,operationID:a,userID:this.uid,data:E},n,o)}),this.getGroupMembersInfo=(e,i)=>new Promise((n,o)=>{const a=i||r(this.uid),E=t({},e);E.userIDList=JSON.stringify(E.userIDList),this.wsSend({reqFuncName:s.GETGROUPMEMBERSINFO,operationID:a,userID:this.uid,data:E},n,o)}),this.getGroupMemberList=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETGROUPMEMBERLIST,operationID:o,userID:this.uid,data:e},i,n)}),this.getGroupMemberListByJoinTimeFilter=(e,i)=>new Promise((n,o)=>{const a=i||r(this.uid),E=t({},e);E.filterUserIDList=JSON.stringify(E.filterUserIDList),this.wsSend({reqFuncName:s.GETGROUPMEMBERLISTBYJOINTIMEFILTER,operationID:a,userID:this.uid,data:E},n,o)}),this.searchGroupMembers=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid),a={reqFuncName:s.SEARCHGROUPMEMBERS,operationID:o,userID:this.uid,data:{searchParam:JSON.stringify(e)}};this.wsSend(a,i,n)}),this.setGroupApplyMemberFriend=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SETGROUPAPPLYMEMBERFRIEND,operationID:o,userID:this.uid,data:e},i,n)}),this.setGroupLookMemberInfo=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SETGROUPLOOKMEMBERINFO,operationID:o,userID:this.uid,data:e},i,n)}),this.getJoinedGroupList=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.GETJOINEDGROUPLIST,operationID:n,userID:this.uid,data:""},t,i)}),this.createGroup=(e,i)=>new Promise((n,o)=>{const a=i||r(this.uid),E=t({},e);E.groupBaseInfo=JSON.stringify(E.groupBaseInfo),E.memberList=JSON.stringify(E.memberList),this.wsSend({reqFuncName:s.CREATEGROUP,operationID:a,userID:this.uid,data:E},n,o)}),this.setGroupInfo=(e,i)=>new Promise((n,o)=>{const a=i||r(this.uid),E=t({},e);E.groupInfo=JSON.stringify(E.groupInfo),this.wsSend({reqFuncName:s.SETGROUPINFO,operationID:a,userID:this.uid,data:E},n,o)}),this.setGroupMemberNickname=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SETGROUPMEMBERNICKNAME,operationID:o,userID:this.uid,data:e},i,n)}),this.getGroupsInfo=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETGROUPSINFO,operationID:o,userID:this.uid,data:e},i,n)}),this.joinGroup=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.JOINGROUP,operationID:o,userID:this.uid,data:e},i,n)}),this.searchGroups=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SEARCHGROUPS,operationID:o,userID:this.uid,data:e},i,n)}),this.quitGroup=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.QUITGROUP,operationID:o,userID:this.uid,data:e},i,n)}),this.dismissGroup=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.DISMISSGROUP,operationID:o,userID:this.uid,data:e},i,n)}),this.changeGroupMute=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CHANGEGROUPMUTE,operationID:o,userID:this.uid,data:e},i,n)}),this.changeGroupMemberMute=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.CHANGEGROUPMEMBERMUTE,operationID:o,userID:this.uid,data:e},i,n)}),this.transferGroupOwner=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.TRANSFERGROUPOWNER,operationID:o,userID:this.uid,data:e},i,n)}),this.getSendGroupApplicationList=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.GETSENDGROUPAPPLICATIONLIST,operationID:n,userID:this.uid,data:""},t,i)}),this.getRecvGroupApplicationList=e=>new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.GETRECVGROUPAPPLICATIONLIST,operationID:n,userID:this.uid,data:""},t,i)}),this.acceptGroupApplication=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.ACCEPTGROUPAPPLICATION,operationID:o,userID:this.uid,data:e},i,n)}),this.refuseGroupApplication=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.REFUSEGROUPAPPLICATION,operationID:o,userID:this.uid,data:e},i,n)}),this.signalingInvite=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid),a={};a.invitation=e,this.wsSend({reqFuncName:s.SIGNAL_INGINVITE,operationID:o,userID:this.uid,data:a},i,n)}),this.signalingInviteInGroup=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid),a={};a.invitation=e,this.wsSend({reqFuncName:s.SIGNALINGINVITEINGROUP,operationID:o,userID:this.uid,data:a},i,n)}),this.signalingAccept=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SIGNALINGACCEPT,operationID:o,userID:this.uid,data:e},i,n)}),this.signalingReject=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SIGNALINGREJECT,operationID:o,userID:this.uid,data:e},i,n)}),this.signalingCancel=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SIGNALINGCANCEL,operationID:o,userID:this.uid,data:e},i,n)}),this.signalingHungUp=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SIGNALINGHUNGUP,operationID:o,userID:this.uid,data:e},i,n)}),this.getSubDepartment=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETSUBDEPARTMENT,operationID:o,userID:this.uid,data:e},i,n)}),this.getDepartmentMember=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETDEPARTMENTMEMBER,operationID:o,userID:this.uid,data:e},i,n)}),this.getUserInDepartment=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETUSERINDEPARTMENT,operationID:o,userID:this.uid,data:e},i,n)}),this.getDepartmentMemberAndSubDepartment=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETDEPARTMENTMEMBERANDSUBDEPARTMENT,operationID:o,userID:this.uid,data:e},i,n)}),this.getDepartmentInfo=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.GETDEPARTMENTINFO,operationID:o,userID:this.uid,data:e},i,n)}),this.searchOrganization=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid),a=e;a.input=JSON.stringify(a.input),this.wsSend({reqFuncName:s.SEARCHORGANIZATION,operationID:o,userID:this.uid,data:a},i,n)}),this.resetConversationGroupAtType=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.RESETCONVERSATIONGROUPATTYPE,operationID:o,userID:this.uid,data:e},i,n)}),this.setGroupMemberRoleLevel=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SETGROUPMEMBERROLELEVEL,operationID:o,userID:this.uid,data:e},i,n)}),this.setGroupVerification=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SETGROUPVERIFICATION,operationID:o,userID:this.uid,data:e},i,n)}),this.setGlobalRecvMessageOpt=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.SETGLOBALRECVMESSAGEOPT,operationID:o,userID:this.uid,data:e},i,n)}),this.newRevokeMessage=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.NEWREVOKEMESSAGE,operationID:o,userID:this.uid,data:e},i,n)}),this.findMessageList=(e,t)=>new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.FINDMESSAGELIST,operationID:o,userID:this.uid,data:e},i,n)}),this.wsSend=(e,t,n)=>{var o,a,E;if(null!=(o=window)&&o.navigator&&!window.navigator.onLine)return void n({event:e.reqFuncName,errCode:113,errMsg:"net work error",data:"",operationID:e.operationID||""});if((null==(a=this.ws)?void 0:a.readyState)!==(null==(E=this.ws)?void 0:E.OPEN))return void n({event:e.reqFuncName,errCode:112,errMsg:"ws conecting...",data:"",operationID:e.operationID||""});"object"==typeof e.data&&(e.data=JSON.stringify(e.data));const d={oid:e.operationID||r(this.uid),mname:e.reqFuncName,mrsve:t,mrjet:n,flag:!1};this.ws2promise[d.oid]=d;const u=t=>{this.lastTime=(new Date).getTime();const n=JSON.parse(t.data);if(i[n.event.toUpperCase()])return void this.emit(n.event,n);e.reqFuncName===s.LOGOUT&&(this.logoutFlag=!0,this.ws.close(),this.ws=void 0);const o=this.ws2promise[n.operationID];o?(0===n.errCode?o.mrsve(n):o.mrjet(n),delete this.ws2promise[n.operationID]):n.event!==s.SENDMESSAGE&&n.event!==s.SENDMESSAGENOTOSS||this.emit(i.ONRECVNEWMESSAGEFROMOTHERWEB,n)};try{"web"==this.platform?(this.ws.send(JSON.stringify(e)),this.ws.onmessage=u):(this.ws.send({data:JSON.stringify(e),success:e=>{"uni"===this.platform&&void 0!==this.ws._callbacks&&void 0!==this.ws._callbacks.message&&(this.ws._callbacks.message=[])}}),this.onceFlag&&(this.ws.onMessage(u),this.onceFlag=!1))}catch(t){return void n({event:e.reqFuncName,errCode:112,errMsg:"no ws conect...",data:"",operationID:e.operationID||""})}e.reqFuncName===s.LOGOUT&&(this.onceFlag=!0)},this.getPlatform()}emitUploadLimitMessage(e){const t={clientMsgID:`system_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,serverMsgID:"",createTime:Date.now(),sendTime:Date.now(),contentType:101,content:"[系统提示] 上传太频繁,每分钟最多上传6次文件",senderUserID:"system",senderNickname:"系统提示",recvID:this.uid||"",groupID:"",status:1,isRead:!0,msgFrom:100,attachedInfo:"",ex:"",localEx:JSON.stringify({isUploadLimitExceeded:!0,limitType:"file_upload",limit:6,timeWindow:60})};setTimeout(()=>{this.emit(i.ONRECVNEWMESSAGE,{event:i.ONRECVNEWMESSAGE,errCode:0,errMsg:"",data:t,operationID:e})},0)}login(e){var t=this;return new Promise((i,n)=>{const{userID:o,token:r,url:a,platformID:E,isBatch:d=!1,operationID:u,censorWordsUrl:I}=e;this.wsUrl=`${a}?sendID=${o}&token=${r}&platformID=${E}`,this.platformID=E;const h={userID:o,token:r};let S={event:s.LOGIN,errCode:0,errMsg:"",data:"",operationID:u||""};this.createWs(()=>{this.uid=o,this.token=r,this.isBatch=d,this.iLogin(h,u).then(async function(e){if(t.logoutFlag=!1,t.heartbeat(),I)try{await t.loadRemoteCensorWords(I)}catch(e){console.warn("Failed to load remote censor words:",e)}i(e)}).catch(e=>{S.errCode=e.errCode,S.errMsg=e.errMsg,n(S)})},()=>{S.errCode=111,S.errMsg="ws connect close...",this.logoutFlag||Object.values(this.ws2promise).forEach(e=>e.mrjet({event:e.mname,errCode:111,errMsg:"ws connect close...",data:"",operationID:e.oid})),n(S)},e=>{console.log(e),S.errCode=112,S.errMsg="ws connect error...",n(S)}),this.ws||(S.errCode=112,S.errMsg="The current platform is not supported...",n(S))})}iLogin(e,t){return new Promise((i,n)=>{const o=t||r(this.uid);this.wsSend({reqFuncName:s.LOGIN,operationID:o,userID:this.uid,data:e,batchMsg:this.isBatch?1:0},i,n)})}logout(e){return new Promise((t,i)=>{const n=e||r(this.uid);this.wsSend({reqFuncName:s.LOGOUT,operationID:n,userID:this.uid,data:""},t,i)})}async loadRemoteCensorWords(e){try{let t=[];if("web"===this.platform){const s=await fetch(e);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const i=await s.json();t=i.words||i}else if("uni"===this.platform){const[s,i]=await uni.request({url:e,method:"GET"});if(s)throw s;const n=i.data;t=n.words||n}else"wx"===this.platform&&(t=await new Promise((t,s)=>{wx.request({url:e,method:"GET",success:e=>{const s=e.data;t(s.words||s)},fail:s})}));Array.isArray(t)&&t.length>0&&(u.loadWords(t),console.log(`Loaded ${t.length} censor words from remote`))}catch(e){throw console.error("Error loading remote censor words:",e),e}}getPlatform(){const e=typeof WebSocket,t=typeof uni,s=typeof wx;this.platform="undefined"===e?"object"===t&&"object"!==s?"uni":"object"!==t&&"object"===s?"wx":"unknow":"web"}createWs(e,t,s){return console.log("start createWs..."),new Promise((i,n)=>{var o;null==(o=this.ws)||o.close(),this.ws=void 0;let r=()=>{this.iLogin({userID:this.uid,token:this.token}).then(e=>{this.logoutFlag=!1,console.log("iLogin suc..."),this.heartbeat(),i()})};e&&(r=e);let a=()=>{console.log("ws close agin:::"),this.logoutFlag||Object.values(this.ws2promise).forEach(e=>e.mrjet({event:e.mname,errCode:111,errMsg:"ws connect close...",data:"",operationID:e.oid}))};t&&(a=t);let E=()=>{};if(s&&(E=s),"web"===this.platform)return this.ws=new WebSocket(this.wsUrl),this.ws.onclose=a,this.ws.onopen=r,void(this.ws.onerror=E);const d="uni"===this.platform?uni:wx;this.ws=d.connectSocket({url:this.wsUrl,complete:()=>{}}),this.ws.onClose(a),this.ws.onOpen(r),this.ws.onError(E)})}reconnect(){this.onceFlag||(this.onceFlag=!0),this.lock||(this.lock=!0,this.clearTimer(),this.timer=setTimeout(()=>{this.createWs(),this.lock=!1},500))}clearTimer(){this.timer&&clearTimeout(this.timer)}heartbeat(){console.log("start heartbeat..."),this.clearTimer();const e=()=>{var e,t,s,i;this.logoutFlag?this.worker&&o(this.worker):(null==(e=this.ws)?void 0:e.readyState)===(null==(t=this.ws)?void 0:t.CONNECTING)||(null==(s=this.ws)?void 0:s.readyState)===(null==(i=this.ws)?void 0:i.OPEN)?(new Date).getTime()-this.lastTime<9e3||this.getLoginStatus().catch(e=>this.reconnect()):this.reconnect()};this.worker&&o(this.worker);try{this.worker=(e=>{const t=function(){const e=new Blob(["(function (e) {\n setInterval(function () {\n this.postMessage(null)\n }, 10000)\n })()"]),t=window.URL.createObjectURL(e);return new Worker(t)}();return t.onmessage=e,t})(e)}catch(e){}}}export{i as CbEvents,I as QnzsIMSDK,s as RequestFunc,e as emitter,r as uuid};
//# sourceMappingURL=index.modern.js.map