@tencentcloud/lite-chat 1.5.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/basic.es.js +1 -3
- package/basic.js +1 -3
- package/package.json +1 -1
- package/plugins/avchatroom.es.js +1 -1
- package/plugins/avchatroom.js +1 -1
- package/plugins/cloud-search.es.js +1 -1
- package/plugins/cloud-search.js +1 -1
- package/plugins/conversation-group.es.js +1 -1
- package/plugins/conversation-group.js +1 -1
- package/plugins/conversation.es.js +1 -1
- package/plugins/conversation.js +1 -1
- package/plugins/follow.es.js +1 -1
- package/plugins/follow.js +1 -1
- package/plugins/friend.es.js +1 -1
- package/plugins/friend.js +1 -1
- package/plugins/group.es.js +1 -1
- package/plugins/group.js +1 -1
- package/plugins/message-enhancer.es.js +1 -3
- package/plugins/message-enhancer.js +1 -3
- package/plugins/offline-message-synchronizer.es.js +1 -1
- package/plugins/offline-message-synchronizer.js +1 -1
- package/plugins/rich-media-message.es.js +1 -1
- package/plugins/rich-media-message.js +1 -1
- package/plugins/signaling.es.js +1 -1
- package/plugins/signaling.js +1 -1
- package/plugins/topic.es.js +1 -1
- package/plugins/topic.js +1 -1
- package/professional.es.js +1 -5
- package/professional.js +1 -5
- package/standard.es.js +1 -5
- package/standard.js +1 -5
package/plugins/topic.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TencentCloudChatTopic=t()}(this,function(){let i=new class{init(e){this.core=e}},s=["topicID","topicName","avatar","introduction","notification","unreadCount","muteAllMembers","customData","nextMessageSeq","selfInfo","lastMessage"],o=e=>{var{common:{getMessagePreviewText:t}}=i["core"];return{lastTime:(null==e?void 0:e.time)||0,lastSequence:(null==e?void 0:e.sequence)||0,fromAccount:(null==e?void 0:e.from)||"",payload:(null==e?void 0:e.payload)||null,type:(null==e?void 0:e.type)||"",messageForShow:t(null==e?void 0:e.type,null==e?void 0:e.payload),nick:(null==e?void 0:e.nick)||"",avatar:(null==e?void 0:e.avatar)||"",version:(null==e?void 0:e.version)||0,cloudCustomData:(null==e?void 0:e.cloudCustomData)||"",isRevoked:(null==e?void 0:e.isRevoked)||!1,revoker:(null==e?void 0:e.revoker)||null}};class n{constructor(e){this.topicID="",this.topicName="",this.avatar="",this.introduction="",this.notification="",this.unreadCount=0,this.muteAllMembers=!1,this.customData="",this.groupAtInfoList=[],this.nextMessageSeq=0,this.lastMessage=o(),this.selfInfo={muteTime:0,readedSequence:0,messageRemindType:"",excludedUnreadSequenceList:void 0},this._init(e)}_init(e){for(var t in e)s.includes(t)&&("lastMessage"===t?this[t]=o(e[t]):"selfInfo"===t?this.updateSelfInfo(e[t]):this[t]="muteAllMembers"===t?1===e[t]:e[t])}updateUnreadCount(e=0){this.unreadCount=e}updateReadSequence(e=0,t=!1){t&&(this.selfInfo.readedSequence=e)}updateNextMessageSeq(e){this.nextMessageSeq=e}updateLastMessage(e){this.lastMessage=o(e)}updateGroupAtInfoList(e){var{common:{updateGroupAtInfo:t}}=i["core"];t(e,this.groupAtInfoList)}updateTopic(e){var{utils:{isUndefined:t},common:{deepMerge:s}}=i["core"];t(e.selfInfo)||this.updateSelfInfo(e.selfInfo),t(e.muteAllMembers)||(this.muteAllMembers=1===e.muteAllMembers),s(this,e,["groupID","lastMessageTime","selfInfo","muteAllMembers","lastMsg","groupAtInfoList"])}updateSelfInfo(e){var{common:{deepMerge:t}}=i["core"];return 0<t(this.selfInfo,e,[],[""])}reduceUnreadCount(){return 1<=this.unreadCount&&(--this.unreadCount,!0)}isLastMessageRevoked(e){return e===(null==(e=this.lastMessage)?void 0:e.lastSequence)}setLastMessageRevoked(e){this.lastMessage.isRevoked=e}setLastMessageRevoker(e){this.lastMessage.revoker=e}clearGroupAtInfoList(){this.groupAtInfoList.length=0}}var p=new class{constructor(){this._name="TopicDataHandler",this._topicMap=new Map,this._topicRequestInfo=new Map}init(e){var{helper:e,constants:t,notificationCenter:s,InnerEvent:{LOGOUT:i,DESTROY:o}}=this._core=e;e.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.TOPIC_REQUEST_INFO_RESET,this._resetTopicRequestInfo,this),s.subscribeInnerEvent(i,this._reset,this),s.subscribeInnerEvent(o,this._dispose,this),console.log(this._name+".init")}_hasTopic(e,t){return!(null==(e=this._topicMap.get(e))||!e.get(t))}_setTopic(e,t,s){null!=(e=this._topicMap.get(e))&&e.set(t,s)}_deleteTopic(e,t){null!=(e=this._topicMap.get(e))&&e.delete(t)}getTopic(e,t){return null==(e=this._topicMap.get(e))?void 0:e.get(t)}updateTopic(e){e.forEach(e=>{var{groupID:t,topicID:s}=e;let i=null;this._topicMap.has(t)||this._topicMap.set(t,new Map),this._hasTopic(t,s)?null!=(i=this.getTopic(t,s))&&i.updateTopic(e):(this._getLastMessage(e),i=new n(e),this._setTopic(t,s,i));e=this.computeUnreadCount(i);null!=i&&i.updateUnreadCount(e)})}_getLastMessage(s){var{isEmpty:i,isUndefined:o,isArray:n}=this._core["utils"];if(!o(s.lastMsg)){let e=null,t="";t=(n(s.lastMsg.elements)?(e=s.lastMsg.elements[0].content,s.lastMsg.elements[0]):(e=s.lastMsg.elements.content,s.lastMsg.elements)).type;o={payload:e,type:t,time:s.lastMsg.time,sequence:s.lastMsg.sequence,from:s.lastMsg.from,nick:s.lastMsg.nick,avatar:s.lastMsg.avatar,version:s.lastMsg.messageVersion,cloudCustomData:s.lastMsg.cloudCustomData,isRevoked:2===s.lastMsg.isPlaceMessage,revoker:i(s.lastMsg.revokerInfo)?null:s.lastMsg.revokerInfo.revoker};s.lastMessage=o}}computeUnreadCount(s){let{excludedUnreadSequenceList:e=[],readedSequence:i}=s.selfInfo,o=s.nextMessageSeq-s.selfInfo.readedSequence-1;if(0<e.length){let t=0;e.forEach(e=>{e>i&&e<=s.nextMessageSeq-1&&(t+=1)}),1<=t&&(o-=t)}return 0<o?o:0}updateTopicAtInfo(e){0!==e.length&&e.forEach(e=>{var t=this._core["utils"]["isEmpty"],e=e["groupAtInfoList"];t(e)||this.updateGroupAtInfoList(e)})}updateGroupAtInfoList(s,r=!1){if(0!==s.length){let{common:{getCurrentUserID:e},utils:{isUndefined:o,isEmpty:t}}=this._core,n=e(),a=null;s.forEach(e=>{var{groupID:t,topicID:s,from:i}=e;i!==n&&((a=this.getTopic(t,s))&&a.updateGroupAtInfoList(e),o(a))&&r&&(this.updateTopic([{groupID:t,topicID:s}]),null!=(i=this.getTopic(t,s)))&&i.updateGroupAtInfoList(e)}),t(a)||this.emitTopicUpdate(a)}}getTopicList(e,t=[]){var e=this._topicMap.get(e),s=[];return e&&s.push(...e.values()),0<t.length?s.filter(e=>t.includes(e.topicID)):s}deleteTopicList(t,e=[]){this._topicMap.has(t)&&(e.forEach(e=>{this._hasTopic(t,e)&&this._deleteTopic(t,e)}),console.log(this._name+`.deleteTopicList groupID:${t} topicID:`+e.join(",")))}clearGroupAtInfoList(e,t){var s=this._core["utils"]["isEmpty"],e=this.getTopic(e,t);s(null==e?void 0:e.groupAtInfoList)||(null!=e&&e.clearGroupAtInfoList(),console.log(this._name+".clearGroupAtInfoList topicID:"+t))}markMessageAsRead(e,s){let{message:{messageDataHandler:t},OuterConstant:{CONV_GROUP:i}}=this._core,o=(null==t?void 0:t.getLocalMessageList(""+i+e))||[];if(0!==o.length){e=o["length"];for(let t=e-1;0<=t;t--){let e=o[t];if(!(s&&e.sequence>s)){if("in"===e.flow&&e.isRead)break;e.setIsRead(!0)}}}}updateUnreadCount(e,t){var{message:{messageDataHandler:s},OuterConstant:{CONV_GROUP:i}}=this._core;let o=!1;e=this.getTopic(e,t);e&&(s=(null==s?void 0:s.getLocalMessageList(""+i+t))||[],i=e.unreadCount,s=null==s?void 0:s.filter(e=>!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted).length,console.log(this._name+`._updateUnreadCount topicID:${t} currentUnreadCount:${i} newUnreadCount:`+s),i!==s&&(e.updateUnreadCount(s),o=!0),o)&&this.emitTopicUpdate(e)}updateSelfInfo(e){var{groupID:e,topicID:t,selfInfo:s}=e,i=this.getTopic(e,t);if(i){let e=i.updateSelfInfo(s);console.log(`${this._name}.updateSelfInfo topicID:${t} info:${JSON.stringify(s)} isUpdated:`+e),e&&this.emitTopicUpdate(i)}}getTopicRequestInfo(e){return this._topicRequestInfo.get(e)||{}}setTopicRequestInfo(e,t){return this._topicRequestInfo.set(e,t)}emitTopicUpdate(e){var{OuterEvent:t,notificationCenter:s}=this._core;s.emitOuterEvent(t.TOPIC_UPDATED,{name:t.TOPIC_UPDATED,data:e})}_resetTopicRequestInfo(){this._topicRequestInfo.clear()}_reset(){this._topicMap.clear(),this._topicRequestInfo.clear()}_dispose(){this._reset();var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};let d=(e="")=>{var{OuterConstant:t}=i["core"];return e.replace(t.CONV_GROUP,"")},h=(e="")=>e.split("@TOPIC#_")[0];var t=new class{constructor(){this._name="TopicMessageHandler"}init(e){var{helper:e,notificationCenter:t,constants:{WORKFLOW_NAME:s,WORKFLOW_STEP:i},InnerEvent:{MESSAGE_PUSH:o,TOPIC_NEW_MESSAGE:n,TOPIC_MESSAGE_DELETED:a,TOPIC_MESSAGE_REVOKED:r,TOPIC_MESSAGE_MODIFIED:c,DESTROY:u}}=this._core=e,{TOPIC_AT_TIPS:l,TOPIC_LATEST_MESSAGE:p}=t["InnerEventSubType"];e.registerWorkflowStep(s.SYNC_SERVER_INFO_AFTER_LOGIN,i.UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED,this._handleUnreadSyncFinished,this),e.registerWorkflowStep(s.RECEIVE_GROUP_NEW_MESSAGE,i.UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE,this._handleNewMessage,this),t.subscribeInnerEvent(n,this._handleNewMessage,this),t.subscribeInnerEvent(a,this._handleMessageDeleted,this),t.subscribeInnerEvent(r,this._handleMessageRevoked,this),t.subscribeInnerEvent(c,this._handleMessageModified,this),t.subscribeInnerEvent(o,l,this._handleTopicAtTips,this),t.subscribeInnerEvent(o,p,this._handleLatestMessage,this),t.subscribeInnerEvent(u,this._dispose,this),console.log(this._name+".init")}_handleUnreadSyncFinished(e){let s,{WORKFLOW_STEP:t}=this._core.constants,{groupTipList:i=[]}=e.result[t.UNREAD_MESSAGE_SYNC]||{};for(let t=0;t<i.length;t++){let e=i[t];12===e.Event&&null!=(s=e.GroupTips[0].MsgBody)&&s.TopicId&&this._handleTopicAtTips(e)}}_handleNewMessage(e){var{conversationUpdateFieldList:e=[]}=e.result||{};if(0!==e.length){var t=this._core["common"]["isTopic"];if(t(e[0].conversationID)){let a=this._core["common"]["getCurrentUserID"];e.forEach(e=>{let{conversationID:t="",lastMessage:o}=e,s=d(t),i=h(s),n=p.getTopic(i,s);if(n){let{from:e,sequence:t}=o,s=t+1,i=e===a();if(s>n.nextMessageSeq){n.updateNextMessageSeq(s),n.updateLastMessage(o),n.updateReadSequence(t,i);let e=i?0:p.computeUnreadCount(n);n.updateUnreadCount(e),this._emitTopicUpdate(n)}}})}}}_handleMessageDeleted(s){var i=d(s),o=h(i),o=p.getTopic(o,i);if(console.log(this._name+`._handleMessageDeleted, topicID:${i} hasTopic:`+!!o),o){var{message:{messageDataHandler:n},utils:{isEmpty:a}}=this._core,r=(null==n?void 0:n.getLocalMessageList(s))||[];let t={};for(let e=(r.length||0)-1;0<=e;e--)if(!r[e].isDeleted){t=r[e];break}let e=!1;o.lastMessage.lastSequence!==t.sequence&&(a(t)&&(t={}),o.updateLastMessage(t),e=!0),e&&(this._emitTopicUpdate(o),console.log(this._name+`._handleMessageDeleted, topicID:${i} with lastMessage:`+o.lastMessage))}}_handleMessageRevoked(e){var{messageList:e=[]}=e;if(console.log(this._name+"._handleMessageRevoked messageList:"+e.length),0!==e.length){let o=null,n=!1;e.forEach(e=>{var{to:e,sequence:t,revoker:s}=e,i=h(e);if(o=p.getTopic(i,e)){o.reduceUnreadCount()&&(n=!0),o.isLastMessageRevoked(t)&&(o.setLastMessageRevoked(!0),o.setLastMessageRevoker(s),n=!0);let{excludedUnreadSequenceList:e=[]}=o.selfInfo;e.push(t),o.updateSelfInfo({excludedUnreadSequenceList:e})}}),n&&this._emitTopicUpdate(o)}}_handleMessageModified(e){let{conversationID:t,messageList:s}=e,i=d(t),o=h(i),r=p.getTopic(o,i);if(console.log(`${this._name}._handleMessageModified topicID:${i} hasTopic:`+!!r),r){var c=r["lastMessage"];if(c){let a=(null==s?void 0:s[0])||{};if(this._shouldUpdateLastMessage(c,a)){let{getMessagePreviewText:e}=this._core["common"],{time:t,sequence:s,elements:i,cloudCustomData:o,messageVersion:n}=a;c.type=i[0].type,c.payload=i[0].content,c.messageForShow=e(c.type,c.payload),c.cloudCustomData=o,c.version=n,c.lastSequence=s,c.lastTime=t,this._emitTopicUpdate(r)}}}}_shouldUpdateLastMessage(e,t){var s;return null===e.payload||({sequence:t,messageVersion:s}=t,e.lastSequence===t&&e.version!==s)}_emitTopicUpdate(e){var{notificationCenter:t,OuterEvent:s}=this._core;t.emitOuterEvent(s.TOPIC_UPDATED,{name:s.TOPIC_UPDATED,data:e})}_handleTopicAtTips(e){let{GroupTips:t=[]}=e,n=[],a=!1;t.forEach(e=>{var{GroupAtTips:e,MsgBody:t,MsgRandom:s,ClientSeq:i}=e;let o={};e?o=this._convertAtInfo(e):t&&(o=this._convertAtInfo(t),a=!0),o.__random=s,o.__sequence=i,n.push(o)}),p.updateGroupAtInfoList(n,a)}_convertAtInfo(e){var{From_Account:e,GroupId:t,TopicId:s,MsgSeq:i,GroupAtType:o}=e;return{groupID:t,topicID:s,from:e,sequence:i,groupAtType:o}}_handleLatestMessage(e){let{utils:{isEmpty:t},message:{messageHelper:i,messageFactory:o}}=this._core,{NewMsg:n,NoUnreadSeqList:a}=e||{};if(!t(n)){let{TopicId:e}=n["GroupInfo"],t=i.parseServerGroupMessage(n),s=o.createMessage(t);s.setElement(t.elements),this._updateUnreadCountAndLastMessage({topicID:e,message:s,excludedUnreadSequenceList:a})}}_updateUnreadCountAndLastMessage(e){let{isUndefined:t}=this._core["utils"],{topicID:s,message:i,excludedUnreadSequenceList:o}=e,n=h(s),a=p.getTopic(n,s);if(a){let e=a.selfInfo.excludedUnreadSequenceList||[];if(t(o)||(e=o),i._isExcludedFromUnreadCount&&e.push(i.sequence),a.updateSelfInfo({excludedUnreadSequenceList:e}),console.log(`${this._name}._updateUnreadCountAndLastMessage latest message sequence:${i.sequence} lastMessage sequence:`+a.lastMessage.lastSequence),i.sequence>a.lastMessage.lastSequence){let e=i.sequence+1,t=(a.updateLastMessage(i),a.updateNextMessageSeq(e),p.computeUnreadCount(a));a.updateUnreadCount(t),this._emitTopicUpdate(a)}}}_dispose(){var{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t,TOPIC_NEW_MESSAGE:s,TOPIC_MESSAGE_DELETED:i,TOPIC_MESSAGE_REVOKED:o,TOPIC_MESSAGE_MODIFIED:n,DESTROY:a}}=this._core,{TOPIC_AT_TIPS:r,TOPIC_LATEST_MESSAGE:c}=e["InnerEventSubType"];e.unSubscribeInnerEvent(s,this._handleNewMessage,this),e.unSubscribeInnerEvent(i,this._handleMessageDeleted,this),e.unSubscribeInnerEvent(o,this._handleMessageRevoked,this),e.unSubscribeInnerEvent(n,this._handleMessageModified,this),e.unSubscribeInnerEvent(t,r,this._handleTopicAtTips,this),e.unSubscribeInnerEvent(t,c,this._handleLatestMessage,this),e.unSubscribeInnerEvent(a,this._dispose,this)}},a=new class{constructor(){this._name="TopicOperationHandler"}init(e){var{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t,DESTROY:s}}=this._core=e,{TOPIC_TIPS_NOTIFICATION:i,TOPIC_SYSTEM_NOTIFICATION:o,TOPIC_MESSAGE_READ_SYNC:n}=e["InnerEventSubType"];e.subscribeInnerEvent(t,i,this._handleTopicTips,this),e.subscribeInnerEvent(t,o,this._handleTopicNotices,this),e.subscribeInnerEvent(t,n,this._handleTopicMessageReadSynced,this),e.subscribeInnerEvent(s,this._dispose,this),console.log(this._name+".init")}_handleTopicTips(e){var{GroupTips:t=[]}=e;for(let e=0;e<t.length;e++){var s=t[e];7!==s.MsgBody.OpType?8!==s.MsgBody.OpType?this._emitTopicTips(s):this._handleTopicProfileUpdated(s):this._handleMuteTimeUpdated(s)}}_handleMuteTimeUpdated(e){var{getCurrentUserID:t}=this._core["common"],{GroupInfo:{GroupId:s,TopicId:i},MsgBody:{MsgMemberInfo:o=[]}}=e;for(let e=0;e<o.length;e++){var{User_Account:n,ShutupTime:a}=o[e];if(n===t()&&0<=a){p.updateSelfInfo({groupID:s,topicID:i,selfInfo:{muteTime:a}});break}}}_handleTopicProfileUpdated(e){var{GroupInfo:{GroupId:e,TopicId:t},MsgBody:{MsgTopicNewInfo:{CustomString:s,ShutupAll:i,TopicFaceUrl:o,TopicIntroduction:n,TopicName:a,TopicNotification:r}}}=e,c=p.getTopic(e,t);c&&(c.updateTopic({groupID:e,topicID:t,customData:s,muteAllMembers:i,avatar:o,introduction:n,topicName:a,notification:r}),p.emitTopicUpdate(c))}_handleTopicNotices(e){var{GroupTips:t=[]}=e;for(let e=0;e<t.length;e++){var s=t[e],{MsgBody:{ReportType:i,TopicIdArray:o,MsgFlag:n},GroupInfo:{GroupId:a,TopicId:r}}=s;17===i?this._handleTopicCreated({groupID:a,topicID:r}):18===i?this._handleTopicDeleted({groupID:a,topicIDList:o}):20===i?this._handleMessageRemindTypeUpdated({groupID:a,topicID:r,messageRemindType:n}):this._emitTopicNotices(s)}}_handleTopicCreated(e){var{OuterEvent:t,notificationCenter:s}=this._core;p.setTopicRequestInfo(e.groupID,{}),s.emitOuterEvent(t.TOPIC_CREATED,{name:t.TOPIC_CREATED,data:e})}_handleTopicDeleted(e){var{OuterEvent:t,notificationCenter:s}=this._core,{groupID:i,topicIDList:o=[]}=e;p.deleteTopicList(i,o),s.emitOuterEvent(t.TOPIC_DELETED,{name:t.TOPIC_DELETED,data:e})}_handleMessageRemindTypeUpdated(e){var{groupID:e,topicID:t,messageRemindType:s}=e;p.updateSelfInfo({groupID:e,topicID:t,selfInfo:{messageRemindType:s}})}_handleTopicMessageReadSynced(e){let t=e["GroupTips"],{isUndefined:s}=this._core["utils"];t.forEach(e=>{e=e.MsgBody.GroupReadInfoArray;s(e)||e.forEach(e=>{var{GroupId:e,TopicId:t,LastReadMsgSeq:s}=e;console.log(this._name+`._handleTopicMessageReadSynced topicID:${t} lastReadSequence:`+s),p.updateSelfInfo({groupID:e,topicID:t,selfInfo:{readedSequence:s}}),p.clearGroupAtInfoList(e,t),p.markMessageAsRead(t,s),p.updateUnreadCount(e,t)})})}_emitTopicTips(e){var{message:{messageHelper:t,messageFactory:s},OuterConstant:i,OuterEvent:o,notificationCenter:n}=this._core,t=(e.MsgBody.MsgType=i.MSG_GRP_TIP,t.parseServerGroupMessage(e)),e=(t.flow="in",t.conversationType=i.CONV_GROUP,s.createMessage(t));e.setElement(t.elements),e.isSystemMessage=!0,n.emitOuterEvent(o.MESSAGE_RECEIVED,{name:o.MESSAGE_RECEIVED,data:[e]})}_emitTopicNotices(e){var{message:{messageHelper:t,messageFactory:s},OuterConstant:i,OuterEvent:o,notificationCenter:n}=this._core,t=(e.MsgBody.MsgType=i.MSG_GRP_SYS_NOTICE,t.parseServerGroupMessage(e)),e=(t.flow="in",t.conversationType=i.CONV_SYSTEM,t.conversationID=i.CONV_SYSTEM,s.createMessage(t));e.setElement(t.elements),e.isSystemMessage=!0,n.emitOuterEvent(o.MESSAGE_RECEIVED,{name:o.MESSAGE_RECEIVED,data:[e]})}_dispose(){var{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t,DESTROY:s}}=this._core,{TOPIC_TIPS_NOTIFICATION:i,TOPIC_SYSTEM_NOTIFICATION:o,TOPIC_MESSAGE_READ_SYNC:n}=e["InnerEventSubType"];e.unSubscribeInnerEvent(t,i,this._handleTopicTips,this),e.unSubscribeInnerEvent(t,o,this._handleTopicNotices,this),e.unSubscribeInnerEvent(t,n,this._handleTopicMessageReadSynced,this),e.unSubscribeInnerEvent(s,this._dispose,this)}};function g(e,a,r,c){return new(r=r||Promise)(function(s,t){function i(e){try{n(c.next(e))}catch(e){t(e)}}function o(e){try{n(c.throw(e))}catch(e){t(e)}}function n(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(i,o)}n((c=c.apply(e,a||[])).next())})}var r=new class{constructor(){this._name="GetJoinedCommunityHandler"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getJoinedCommunityList",context:this})}getJoinedCommunityList(){return g(this,void 0,void 0,function*(){var e=this._core["apiMap"]["getGroupList"],e=(yield e(!0)).filter(e=>!0===e.isSupportTopic);return console.log(this._name+".getJoinedCommunityList ok, count:"+e.length),{code:0,data:{groupList:e}}})}},c=new class{constructor(){this._name="CreateTopicHandler"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"createTopicInCommunity",context:this})}createTopicInCommunity(n){return g(this,void 0,void 0,function*(){let s="createTopicInCommunity",{utils:{isUndefined:e},common:{isTopic:t},helper:{ChatError:i}}=this._core,o=n["topicID"];if(!e(o)&&!t(o)){let e=new i({functionName:s,code:3021});throw console.error(this._name+`.${s} fail:`,e),e}try{let e=yield function(r,c){return g(this,void 0,void 0,function*(){var{groupID:e,topicID:t,topicName:s,avatar:i,notification:o,introduction:n,customData:a}=r;return c.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.create_topic",data:{GroupId:e,TopicId:t,TopicName:s,FaceUrl:i,Notification:o,Introduction:n,CustomString:a}})})}(n,this._core),{TopicId:t=""}=e||{};return console.log(this._name+`.${s} ok, topicID:`+t),p.updateTopic([Object.assign(Object.assign({},n),{topicID:t})]),{code:0,data:{topicID:t}}}catch(e){throw console.error(this._name+`.${s} failed, error:`,e),e}})}},u=new class{constructor(){this._name="DeleteTopicHandler"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"deleteTopicFromCommunity",context:this})}deleteTopicFromCommunity(c){return g(this,void 0,void 0,function*(){var s="deleteTopicFromCommunity",{groupID:a,topicIDList:r=[]}=c;try{let e=yield function(s,i){return g(this,void 0,void 0,function*(){var{groupID:e,topicIDList:t}=s;return i.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.destroy_topic",data:{GroupId:e,TopicIdList:t}})})}({groupID:a,topicIDList:r},this._core),{DestroyResultItem:t=[]}=e||{},i=[],o=[],n=[];return t.forEach(e=>{var{TopicId:e,ErrorCode:t,ErrorInfo:s}=e;0===t?(i.push({topicID:e}),n.push(e)):o.push({topicID:e,code:t,message:s})}),0<n.length&&p.deleteTopicList(c.groupID,n),console.log(`${this._name}.${s} ok, groupID:${a} success:${i.length} fail:`+o.length),{code:0,data:{successTopicList:i,failureTopicList:o}}}catch(e){throw console.error(this._name+`.${s} failed, error:`,e),e}})}},l=new class{constructor(){this._name="GetTopicHandler",this._getCloudConfig=e=>{var t=this._core["store"];return(t.get("cloudConfig")||{})[e]}}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getTopicList",context:this})}getTopicList(e){return g(this,void 0,void 0,function*(){var{groupID:t,topicIDList:s=[]}=e,i=0===s.length;if(this._isFetchingFromCache(t,i)){let e=p.getTopicList(t,s);if(i||e.length===s.length)return console.log(this._name+`.getTopicList groupID:${t} from cache, count:`+e.length),{code:0,data:{successTopicList:e,failureTopicList:[]}}}return this._getTopicListFromServer({groupID:t,topicIDList:s},i)})}_isFetchingFromCache(e,t){var{hasFetchedAllTopics:e=!1,time:s=0}=p.getTopicRequestInfo(e);return!(!e&&(t||e))&&Date.now()-s<this._getCacheDuration()}_getCacheDuration(){var{isUndefined:e}=this._core["utils"];let t=this._getCloudConfig("topic_cache_time");return!e(t)&&0<=(t=parseInt(t,10))&&t<=3600?1e3*t:3e5}_getTopicListFromServer(u,l){return g(this,void 0,void 0,function*(){var i="_getTopicListFromServer",{isEmpty:o}=this._core["utils"],c=u["groupID"];try{let e=yield function(s,i){return g(this,void 0,void 0,function*(){var{groupID:e,topicIDList:t}=s;return i.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.get_topic",data:{GroupId:e,TopicIdList:t,MemberInfoFilter:["NoUnreadSeqList"]}})})}(u,this._core),{TopicAndSelfInfo:t=[]}=e||{},n=[],a=[],r=[],s=(this._convertTopicInfoList(t).forEach(e=>{var{topic:e,selfInfo:t,code:s,message:i}=e,o=e["topicID"];0===s?(n.push(Object.assign(Object.assign({},e),{selfInfo:t})),a.push(o)):r.push({topicID:o,code:s,message:i})}),p.updateTopic(n),p.updateTopicAtInfo(n),console.log(`${this._name}.${i} groupID:${c} from remote, success count:${a.length}, fail count:`+r.length),[]);return o(a)||(p.setTopicRequestInfo(c,{hasFetchedAllTopics:l,time:Date.now()}),s=p.getTopicList(c,a)),{code:0,data:{successTopicList:s,failureTopicList:r}}}catch(e){throw console.error(this._name+`.${i} failed, error:`,e),e}})}_convertTopicInfoList(e){let o=[];return e.forEach(e=>{var{TopicInfo:e={},SelfInfo:t={},ErrorCode:s,ErrorInfo:i}=e;o.push({code:s,message:i,topic:this._convertTopicInfo(e),selfInfo:this._convertSelfInfo(t)})}),o}_convertTopicInfo(e){var t,s,i,o,n,a,r,c,u,l,p,d=this._core["utils"]["isEmpty"];return d(e)?{}:({CreateTime:d,CustomString:e,FaceUrl:t,GroupId:s,LastMsgTime:i,NextMsgSeq:o,Introduction:n,Notification:a,ShutUpAllFlag:r,TopicId:c,TopicName:u,LastMsg:l,AtInfoList:p}=e,{createTime:d,customData:e,avatar:t,groupID:s,lastMessageTime:i,nextMessageSeq:o,introduction:n,notification:a,muteAllMembers:r,topicID:c,topicName:u,lastMsg:this._convertLastMsg(l),groupAtInfoList:this._convertAtInfoList({groupID:s,topicID:c,atInfoList:p})})}_convertLastMsg(e){var t,{utils:{isUndefined:s},OuterConstant:i}=this._core;if(!s(e))return 4===e.Event&&(e.MsgBody.MsgType=i.MSG_GRP_TIP),{messageHelper:s}=this._core["message"],i=s.parseServerGroupMessage(e),{From_AccountHeadurl:s,From_AccountNick:e,LastMsgSeq:t}=e,Object.assign(Object.assign({},i),{avatar:s,nick:e,sequence:t})}_convertAtInfoList(e){let{groupID:i,topicID:o,atInfoList:t=[]}=e;if(0===t.length)return[];let n=[];return t.forEach(e=>{var{AtFlagList:e,AtMsgSeq:t,From_Account:s}=e;n.push({groupID:i,topicID:o,groupAtType:e,sequence:t,from:s})}),n}_convertSelfInfo(e){var t,s,i,o=this._core["utils"]["isEmpty"];return o(e)?{}:({InheritGroupReceiveOption:o,MsgFlag:e,MsgSeq:t,NoUnreadSeqList:s,ShutUpTime:i}=e,{inheritGroupReceiveOption:o,messageRemindType:e,readedSequence:t,excludedUnreadSequenceList:s,muteTime:i})}},_=new class{constructor(){this._name="UpdateTopicHandler"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"updateTopicProfile",context:this})}updateTopicProfile(n){return g(this,void 0,void 0,function*(){var t="updateTopicProfile",{isUndefined:e}=this._core["utils"],{groupID:s,topicID:i,muteAllMembers:o}=n;e(n.muteAllMembers)||(n.muteAllMembers=!0===o?"On":"Off");try{return yield function(c,u){return g(this,void 0,void 0,function*(){var{groupID:e,topicID:t,topicName:s,avatar:i,notification:o,introduction:n,customData:a,muteAllMembers:r}=c;return u.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.modify_topic",data:{GroupId:e,TopicId:t,TopicName:s,FaceUrl:i,Notification:o,Introduction:n,CustomString:a,ShutUpAllMember:r}})})}(n,this._core),console.log(this._name+`.${t} ok, topicID:`+i),p.updateTopic([n]),{code:0,data:{topic:p.getTopic(s,i)}}}catch(e){throw console.error(this._name+`.${t} failed, topicID:${i} error:`,e),e}})}},m=new class{constructor(){this._name="MessageReadHandler"}init(e){let{helper:t,common:{isTopic:s}}=this._core=e;t.registerApi({apiName:"setMessageRead",context:this,matcher:e=>s(e[0].conversationID)})}setMessageRead(l){return g(this,void 0,void 0,function*(){let{utils:{isEmpty:e},ssoLog:t,helper:{ChatError:o}}=this._core,s=l["conversationID"],i={code:0,data:{}},n=d(s),a=h(n),r=p.getTopic(a,n);if(console.log(this._name+`.setMessageRead topicID:${n} unreadCount:`+((null==r?void 0:r.unreadCount)||0)),r&&(e(r.groupAtInfoList)||this._deleteTopicAtTips(a,n),0!==r.unreadCount)){var c=this._getLocalMessageMaxSequence(r),u=t.createSSOLogData({method:"setMessageRead"});u.setLogInfo({message:"conversationID:"+s,moreMessage:"lastMessageSequence:"+c});try{yield this._setTopicMessageRead(a,n,c),u.end()}catch(e){let{errorCode:t,errorInfo:s}=e,i=new o({functionName:"setMessageRead",code:t,message:s});throw u.setError(i).end(),i}}return i})}_deleteTopicAtTips(n,a){return g(this,void 0,void 0,function*(){console.log(this._name+`._deleteTopicAtTips groupID:${n} topicID:`+a);let e=p.getTopic(n,a);if(e){var i=(null==e?void 0:e.groupAtInfoList)||[];if(0!==i.length)try{let{common:{getCurrentUserID:t},OuterConstant:{CONV_AT_ALL:s}}=this._core;var o=[...i];0===(o=i.filter(e=>!e.atTypeArray.includes(s))).length?p.clearGroupAtInfoList(n,a):(yield function(t,s){return g(this,void 0,void 0,function*(){var e=t["messageListToDelete"];return s.common.buildAndSendPacket({servcmd:"openim.deletemsg",data:{DelMsgList:e}})})}({messageListToDelete:o.map(e=>({From_Account:e.from,To_Account:t(),MsgSeq:e.__sequence,MsgRandom:e.__random,GroupId:e.groupID}))},this._core),console.log(this._name+"._deleteTopicAtTips ok. count:"+i.length),p.clearGroupAtInfoList(n,a))}catch(e){console.error(this._name+"._deleteTopicAtTips fail:",e)}}})}_getLocalMessageMaxSequence(e){var{message:{messageDataHandler:t},OuterConstant:{CONV_GROUP:s}}=this._core,i=e["topicID"],t=t.getLocalMessageList(""+s+i),s=Math.max(...t.map(e=>e.sequence));let o=(null==(i=null==e?void 0:e.lastMessage)?void 0:i.lastSequence)||0;return s>o&&(console.log(`${this._name}._getLocalMessageMaxSequence update lastMessageSequence from ${o} to `+s),o=s),o}_setTopicMessageRead(e,t,s){return g(this,void 0,void 0,function*(){try{yield function(i,o){return g(this,void 0,void 0,function*(){var{groupID:e,topicID:t,lastMessageSequence:s}=i;return o.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.msg_read_report",data:{GroupId:e,TopicId:t,MsgReadedSeq:s}})})}({groupID:e,topicID:t,lastMessageSequence:s},this._core),console.log(this._name+"._setTopicMessageRead ok, lastReadSequence:"+s),p.updateSelfInfo({groupID:e,topicID:t,selfInfo:{readedSequence:s}}),p.markMessageAsRead(t,s),p.updateUnreadCount(e,t)}catch(e){throw console.error(this._name+"._setTopicMessageRead fail:",e),e}})}},I=new class{init(e){console.log("TopicAction.init"),r.init(e),c.init(e),u.init(e),l.init(e),_.init(e),m.init(e)}};let e={required:!0,rules:["string"],allowEmpty:!1},T={createTopicInCommunity:{groupID:e,topicName:e},deleteTopicFromCommunity:{groupID:e,topicIDList:{required:!1,rules:["array"],allowEmpty:!0}},getTopicList:{groupID:e,topicIDList:{required:!1,rules:["array"],allowEmpty:!0}},updateTopicProfile:{groupID:e,topicID:e}},f={getJoinedCommunityList:!0,createTopicInCommunity:!0,deleteTopicFromCommunity:!0,getTopicList:!0,updateTopicProfile:!0};return new class{constructor(){this.name="Topic"}install(e){i.init(e),p.init(e),t.init(e),a.init(e),I.init(e),e.helper.registerValidateConfig({auth:f,params:T})}}});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TencentCloudChatTopic=t()}(this,function(){let i=new class{init(e){this.core=e}},s=["topicID","topicName","avatar","introduction","notification","unreadCount","muteAllMembers","customData","nextMessageSeq","selfInfo","lastMessage"],o=e=>{var{common:{getMessagePreviewText:t}}=i["core"];return{lastTime:(null==e?void 0:e.time)||0,lastSequence:(null==e?void 0:e.sequence)||0,fromAccount:(null==e?void 0:e.from)||"",payload:(null==e?void 0:e.payload)||null,type:(null==e?void 0:e.type)||"",messageForShow:t(null==e?void 0:e.type,null==e?void 0:e.payload),nick:(null==e?void 0:e.nick)||"",avatar:(null==e?void 0:e.avatar)||"",version:(null==e?void 0:e.version)||0,cloudCustomData:(null==e?void 0:e.cloudCustomData)||"",isRevoked:(null==e?void 0:e.isRevoked)||!1,revoker:(null==e?void 0:e.revoker)||null}};class n{constructor(e){this.topicID="",this.topicName="",this.avatar="",this.introduction="",this.notification="",this.unreadCount=0,this.muteAllMembers=!1,this.customData="",this.groupAtInfoList=[],this.nextMessageSeq=0,this.lastMessage=o(),this.selfInfo={muteTime:0,readedSequence:0,messageRemindType:"",excludedUnreadSequenceList:void 0},this._init(e)}_init(e){for(var t in e)s.includes(t)&&("lastMessage"===t?this[t]=o(e[t]):"selfInfo"===t?this.updateSelfInfo(e[t]):this[t]="muteAllMembers"===t?1===e[t]:e[t])}updateUnreadCount(e=0){this.unreadCount=e}updateReadSequence(e=0,t=!1){t&&(this.selfInfo.readedSequence=e)}updateNextMessageSeq(e){this.nextMessageSeq=e}updateLastMessage(e){this.lastMessage=o(e)}updateGroupAtInfoList(e){var{common:{updateGroupAtInfo:t}}=i["core"];t(e,this.groupAtInfoList)}updateTopic(e){var{utils:{isUndefined:t},common:{deepMerge:s}}=i["core"];t(e.selfInfo)||this.updateSelfInfo(e.selfInfo),t(e.muteAllMembers)||(this.muteAllMembers=1===e.muteAllMembers),s(this,e,["groupID","lastMessageTime","selfInfo","muteAllMembers","lastMsg","groupAtInfoList"])}updateSelfInfo(e){var{common:{deepMerge:t}}=i["core"];return 0<t(this.selfInfo,e,[],[""])}reduceUnreadCount(){return 1<=this.unreadCount&&(--this.unreadCount,!0)}isLastMessageRevoked(e){return e===(null==(e=this.lastMessage)?void 0:e.lastSequence)}setLastMessageRevoked(e){this.lastMessage.isRevoked=e}setLastMessageRevoker(e){this.lastMessage.revoker=e}clearGroupAtInfoList(){this.groupAtInfoList.length=0}}var l=new class{constructor(){this._name="TopicDataHandler",this._topicMap=new Map,this._topicRequestInfo=new Map}init(e){var{helper:t,constants:s,notificationCenter:i,InnerEvent:{LOGOUT:o,DESTROY:n}}=this._core=e;t.registerWorkflowStep(s.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,s.WORKFLOW_STEP.TOPIC_REQUEST_INFO_RESET,this._resetTopicRequestInfo,this),i.subscribeInnerEvent(o,this._reset,this),i.subscribeInnerEvent(n,this._dispose,this),e.ssoLog.debug(this._name+".init")}_hasTopic(e,t){return!(null==(e=this._topicMap.get(e))||!e.get(t))}_setTopic(e,t,s){null!=(e=this._topicMap.get(e))&&e.set(t,s)}_deleteTopic(e,t){null!=(e=this._topicMap.get(e))&&e.delete(t)}getTopic(e,t){return null==(e=this._topicMap.get(e))?void 0:e.get(t)}updateTopic(e){e.forEach(e=>{var{groupID:t,topicID:s}=e;let i=null;this._topicMap.has(t)||this._topicMap.set(t,new Map),this._hasTopic(t,s)?null!=(i=this.getTopic(t,s))&&i.updateTopic(e):(this._getLastMessage(e),i=new n(e),this._setTopic(t,s,i));e=this.computeUnreadCount(i);null!=i&&i.updateUnreadCount(e)})}_getLastMessage(s){var{isEmpty:i,isUndefined:o,isArray:n}=this._core["utils"];if(!o(s.lastMsg)){let e=null,t="";t=(n(s.lastMsg.elements)?(e=s.lastMsg.elements[0].content,s.lastMsg.elements[0]):(e=s.lastMsg.elements.content,s.lastMsg.elements)).type;o={payload:e,type:t,time:s.lastMsg.time,sequence:s.lastMsg.sequence,from:s.lastMsg.from,nick:s.lastMsg.nick,avatar:s.lastMsg.avatar,version:s.lastMsg.messageVersion,cloudCustomData:s.lastMsg.cloudCustomData,isRevoked:2===s.lastMsg.isPlaceMessage,revoker:i(s.lastMsg.revokerInfo)?null:s.lastMsg.revokerInfo.revoker};s.lastMessage=o}}computeUnreadCount(s){let{excludedUnreadSequenceList:e=[],readedSequence:i}=s.selfInfo,o=s.nextMessageSeq-s.selfInfo.readedSequence-1;if(0<e.length){let t=0;e.forEach(e=>{e>i&&e<=s.nextMessageSeq-1&&(t+=1)}),1<=t&&(o-=t)}return 0<o?o:0}updateTopicAtInfo(e){0!==e.length&&e.forEach(e=>{var t=this._core["utils"]["isEmpty"],e=e["groupAtInfoList"];t(e)||this.updateGroupAtInfoList(e)})}updateGroupAtInfoList(s,r=!1){if(0!==s.length){let{common:{getCurrentUserID:e},utils:{isUndefined:o,isEmpty:t}}=this._core,n=e(),a=null;s.forEach(e=>{var{groupID:t,topicID:s,from:i}=e;i!==n&&((a=this.getTopic(t,s))&&a.updateGroupAtInfoList(e),o(a))&&r&&(this.updateTopic([{groupID:t,topicID:s}]),null!=(i=this.getTopic(t,s)))&&i.updateGroupAtInfoList(e)}),t(a)||this.emitTopicUpdate(a)}}getTopicList(e,t=[]){var e=this._topicMap.get(e),s=[];return e&&s.push(...e.values()),0<t.length?s.filter(e=>t.includes(e.topicID)):s}deleteTopicList(t,e=[]){this._topicMap.has(t)&&(e.forEach(e=>{this._hasTopic(t,e)&&this._deleteTopic(t,e)}),console.log(this._name+`.deleteTopicList groupID:${t} topicID:`+e.join(",")))}clearGroupAtInfoList(e,t){var s=this._core["utils"]["isEmpty"],e=this.getTopic(e,t);s(null==e?void 0:e.groupAtInfoList)||(null!=e&&e.clearGroupAtInfoList(),console.log(this._name+".clearGroupAtInfoList topicID:"+t))}markMessageAsRead(e,s){let{message:{messageDataHandler:t},OuterConstant:{CONV_GROUP:i}}=this._core,o=(null==t?void 0:t.getLocalMessageList(""+i+e))||[];if(0!==o.length){e=o["length"];for(let t=e-1;0<=t;t--){let e=o[t];if(!(s&&e.sequence>s)){if("in"===e.flow&&e.isRead)break;e.setIsRead(!0)}}}}updateUnreadCount(e,t){var{message:{messageDataHandler:s},OuterConstant:{CONV_GROUP:i}}=this._core;let o=!1;e=this.getTopic(e,t);e&&(s=(null==s?void 0:s.getLocalMessageList(""+i+t))||[],i=e.unreadCount,s=null==s?void 0:s.filter(e=>!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted).length,console.log(this._name+`._updateUnreadCount topicID:${t} currentUnreadCount:${i} newUnreadCount:`+s),i!==s&&(e.updateUnreadCount(s),o=!0),o)&&this.emitTopicUpdate(e)}updateSelfInfo(e){var{groupID:e,topicID:t,selfInfo:s}=e,i=this.getTopic(e,t);if(i){let e=i.updateSelfInfo(s);console.log(`${this._name}.updateSelfInfo topicID:${t} info:${JSON.stringify(s)} isUpdated:`+e),e&&this.emitTopicUpdate(i)}}getTopicRequestInfo(e){return this._topicRequestInfo.get(e)||{}}setTopicRequestInfo(e,t){return this._topicRequestInfo.set(e,t)}emitTopicUpdate(e){var{OuterEvent:t,notificationCenter:s}=this._core;s.emitOuterEvent(t.TOPIC_UPDATED,{name:t.TOPIC_UPDATED,data:e})}_resetTopicRequestInfo(){this._topicRequestInfo.clear()}_reset(){this._topicMap.clear(),this._topicRequestInfo.clear()}_dispose(){this._reset();var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};let d=(e="")=>{var{OuterConstant:t}=i["core"];return e.replace(t.CONV_GROUP,"")},h=(e="")=>e.split("@TOPIC#_")[0];var t=new class{constructor(){this._name="TopicMessageHandler"}init(e){var{helper:t,notificationCenter:s,constants:{WORKFLOW_NAME:i,WORKFLOW_STEP:o},InnerEvent:{MESSAGE_PUSH:n,TOPIC_NEW_MESSAGE:a,TOPIC_MESSAGE_DELETED:r,TOPIC_MESSAGE_REVOKED:c,TOPIC_MESSAGE_MODIFIED:u,DESTROY:p}}=this._core=e,{TOPIC_AT_TIPS:l,TOPIC_LATEST_MESSAGE:d}=s["InnerEventSubType"];t.registerWorkflowStep(i.SYNC_SERVER_INFO_AFTER_LOGIN,o.UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED,this._handleUnreadSyncFinished,this),t.registerWorkflowStep(i.RECEIVE_GROUP_NEW_MESSAGE,o.UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE,this._handleNewMessage,this),s.subscribeInnerEvent(a,this._handleNewMessage,this),s.subscribeInnerEvent(r,this._handleMessageDeleted,this),s.subscribeInnerEvent(c,this._handleMessageRevoked,this),s.subscribeInnerEvent(u,this._handleMessageModified,this),s.subscribeInnerEvent(n,l,this._handleTopicAtTips,this),s.subscribeInnerEvent(n,d,this._handleLatestMessage,this),s.subscribeInnerEvent(p,this._dispose,this),e.ssoLog.debug(this._name+".init")}_handleUnreadSyncFinished(e){let s,{WORKFLOW_STEP:t}=this._core.constants,{groupTipList:i=[]}=e.result[t.UNREAD_MESSAGE_SYNC]||{};for(let t=0;t<i.length;t++){let e=i[t];12===e.Event&&null!=(s=e.GroupTips[0].MsgBody)&&s.TopicId&&this._handleTopicAtTips(e)}}_handleNewMessage(e){var{conversationUpdateFieldList:e=[]}=e.result||{};if(0!==e.length){var t=this._core["common"]["isTopic"];if(t(e[0].conversationID)){let a=this._core["common"]["getCurrentUserID"];e.forEach(e=>{let{conversationID:t="",lastMessage:o}=e,s=d(t),i=h(s),n=l.getTopic(i,s);if(n){let{from:e,sequence:t}=o,s=t+1,i=e===a();if(s>n.nextMessageSeq){n.updateNextMessageSeq(s),n.updateLastMessage(o),n.updateReadSequence(t,i);let e=i?0:l.computeUnreadCount(n);n.updateUnreadCount(e),this._emitTopicUpdate(n)}}})}}}_handleMessageDeleted(s){var i=d(s),o=h(i),o=l.getTopic(o,i);if(console.log(this._name+`._handleMessageDeleted, topicID:${i} hasTopic:`+!!o),o){var{message:{messageDataHandler:n},utils:{isEmpty:a}}=this._core,r=(null==n?void 0:n.getLocalMessageList(s))||[];let t={};for(let e=(r.length||0)-1;0<=e;e--)if(!r[e].isDeleted){t=r[e];break}let e=!1;o.lastMessage.lastSequence!==t.sequence&&(a(t)&&(t={}),o.updateLastMessage(t),e=!0),e&&(this._emitTopicUpdate(o),console.log(this._name+`._handleMessageDeleted, topicID:${i} with lastMessage:`+o.lastMessage))}}_handleMessageRevoked(e){var{messageList:e=[]}=e;if(console.log(this._name+"._handleMessageRevoked messageList:"+e.length),0!==e.length){let o=null,n=!1;e.forEach(e=>{var{to:e,sequence:t,revoker:s}=e,i=h(e);if(o=l.getTopic(i,e)){o.reduceUnreadCount()&&(n=!0),o.isLastMessageRevoked(t)&&(o.setLastMessageRevoked(!0),o.setLastMessageRevoker(s),n=!0);let{excludedUnreadSequenceList:e=[]}=o.selfInfo;e.push(t),o.updateSelfInfo({excludedUnreadSequenceList:e})}}),n&&this._emitTopicUpdate(o)}}_handleMessageModified(e){let{conversationID:t,messageList:s}=e,i=d(t),o=h(i),r=l.getTopic(o,i);if(console.log(`${this._name}._handleMessageModified topicID:${i} hasTopic:`+!!r),r){var c=r["lastMessage"];if(c){let a=(null==s?void 0:s[0])||{};if(this._shouldUpdateLastMessage(c,a)){let{getMessagePreviewText:e}=this._core["common"],{time:t,sequence:s,elements:i,cloudCustomData:o,messageVersion:n}=a;c.type=i[0].type,c.payload=i[0].content,c.messageForShow=e(c.type,c.payload),c.cloudCustomData=o,c.version=n,c.lastSequence=s,c.lastTime=t,this._emitTopicUpdate(r)}}}}_shouldUpdateLastMessage(e,t){var s;return null===e.payload||({sequence:t,messageVersion:s}=t,e.lastSequence===t&&e.version!==s)}_emitTopicUpdate(e){var{notificationCenter:t,OuterEvent:s}=this._core;t.emitOuterEvent(s.TOPIC_UPDATED,{name:s.TOPIC_UPDATED,data:e})}_handleTopicAtTips(e){let{GroupTips:t=[]}=e,n=[],a=!1;t.forEach(e=>{var{GroupAtTips:e,MsgBody:t,MsgRandom:s,ClientSeq:i}=e;let o={};e?o=this._convertAtInfo(e):t&&(o=this._convertAtInfo(t),a=!0),o.__random=s,o.__sequence=i,n.push(o)}),l.updateGroupAtInfoList(n,a)}_convertAtInfo(e){var{From_Account:e,GroupId:t,TopicId:s,MsgSeq:i,GroupAtType:o}=e;return{groupID:t,topicID:s,from:e,sequence:i,groupAtType:o}}_handleLatestMessage(e){let{utils:{isEmpty:t},message:{messageHelper:i,messageFactory:o}}=this._core,{NewMsg:n,NoUnreadSeqList:a}=e||{};if(!t(n)){let{TopicId:e}=n["GroupInfo"],t=i.parseServerGroupMessage(n),s=o.createMessage(t);s.setElement(t.elements),this._updateUnreadCountAndLastMessage({topicID:e,message:s,excludedUnreadSequenceList:a})}}_updateUnreadCountAndLastMessage(e){let{isUndefined:t}=this._core["utils"],{topicID:s,message:i,excludedUnreadSequenceList:o}=e,n=h(s),a=l.getTopic(n,s);if(a){let e=a.selfInfo.excludedUnreadSequenceList||[];if(t(o)||(e=o),i._isExcludedFromUnreadCount&&e.push(i.sequence),a.updateSelfInfo({excludedUnreadSequenceList:e}),console.log(`${this._name}._updateUnreadCountAndLastMessage latest message sequence:${i.sequence} lastMessage sequence:`+a.lastMessage.lastSequence),i.sequence>a.lastMessage.lastSequence){let e=i.sequence+1,t=(a.updateLastMessage(i),a.updateNextMessageSeq(e),l.computeUnreadCount(a));a.updateUnreadCount(t),this._emitTopicUpdate(a)}}}_dispose(){var{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t,TOPIC_NEW_MESSAGE:s,TOPIC_MESSAGE_DELETED:i,TOPIC_MESSAGE_REVOKED:o,TOPIC_MESSAGE_MODIFIED:n,DESTROY:a}}=this._core,{TOPIC_AT_TIPS:r,TOPIC_LATEST_MESSAGE:c}=e["InnerEventSubType"];e.unSubscribeInnerEvent(s,this._handleNewMessage,this),e.unSubscribeInnerEvent(i,this._handleMessageDeleted,this),e.unSubscribeInnerEvent(o,this._handleMessageRevoked,this),e.unSubscribeInnerEvent(n,this._handleMessageModified,this),e.unSubscribeInnerEvent(t,r,this._handleTopicAtTips,this),e.unSubscribeInnerEvent(t,c,this._handleLatestMessage,this),e.unSubscribeInnerEvent(a,this._dispose,this)}},a=new class{constructor(){this._name="TopicOperationHandler"}init(e){var{notificationCenter:t,InnerEvent:{MESSAGE_PUSH:s,DESTROY:i}}=this._core=e,{TOPIC_TIPS_NOTIFICATION:o,TOPIC_SYSTEM_NOTIFICATION:n,TOPIC_MESSAGE_READ_SYNC:a}=t["InnerEventSubType"];t.subscribeInnerEvent(s,o,this._handleTopicTips,this),t.subscribeInnerEvent(s,n,this._handleTopicNotices,this),t.subscribeInnerEvent(s,a,this._handleTopicMessageReadSynced,this),t.subscribeInnerEvent(i,this._dispose,this),e.ssoLog.debug(this._name+".init")}_handleTopicTips(e){var{GroupTips:t=[]}=e;for(let e=0;e<t.length;e++){var s=t[e];7!==s.MsgBody.OpType?8!==s.MsgBody.OpType?this._emitTopicTips(s):this._handleTopicProfileUpdated(s):this._handleMuteTimeUpdated(s)}}_handleMuteTimeUpdated(e){var{getCurrentUserID:t}=this._core["common"],{GroupInfo:{GroupId:s,TopicId:i},MsgBody:{MsgMemberInfo:o=[]}}=e;for(let e=0;e<o.length;e++){var{User_Account:n,ShutupTime:a}=o[e];if(n===t()&&0<=a){l.updateSelfInfo({groupID:s,topicID:i,selfInfo:{muteTime:a}});break}}}_handleTopicProfileUpdated(e){var{GroupInfo:{GroupId:e,TopicId:t},MsgBody:{MsgTopicNewInfo:{CustomString:s,ShutupAll:i,TopicFaceUrl:o,TopicIntroduction:n,TopicName:a,TopicNotification:r}}}=e,c=l.getTopic(e,t);c&&(c.updateTopic({groupID:e,topicID:t,customData:s,muteAllMembers:i,avatar:o,introduction:n,topicName:a,notification:r}),l.emitTopicUpdate(c))}_handleTopicNotices(e){var{GroupTips:t=[]}=e;for(let e=0;e<t.length;e++){var s=t[e],{MsgBody:{ReportType:i,TopicIdArray:o,MsgFlag:n},GroupInfo:{GroupId:a,TopicId:r}}=s;17===i?this._handleTopicCreated({groupID:a,topicID:r}):18===i?this._handleTopicDeleted({groupID:a,topicIDList:o}):20===i?this._handleMessageRemindTypeUpdated({groupID:a,topicID:r,messageRemindType:n}):this._emitTopicNotices(s)}}_handleTopicCreated(e){var{OuterEvent:t,notificationCenter:s}=this._core;l.setTopicRequestInfo(e.groupID,{}),s.emitOuterEvent(t.TOPIC_CREATED,{name:t.TOPIC_CREATED,data:e})}_handleTopicDeleted(e){var{OuterEvent:t,notificationCenter:s}=this._core,{groupID:i,topicIDList:o=[]}=e;l.deleteTopicList(i,o),s.emitOuterEvent(t.TOPIC_DELETED,{name:t.TOPIC_DELETED,data:e})}_handleMessageRemindTypeUpdated(e){var{groupID:e,topicID:t,messageRemindType:s}=e;l.updateSelfInfo({groupID:e,topicID:t,selfInfo:{messageRemindType:s}})}_handleTopicMessageReadSynced(e){let t=e["GroupTips"],{isUndefined:s}=this._core["utils"];t.forEach(e=>{e=e.MsgBody.GroupReadInfoArray;s(e)||e.forEach(e=>{var{GroupId:e,TopicId:t,LastReadMsgSeq:s}=e;console.log(this._name+`._handleTopicMessageReadSynced topicID:${t} lastReadSequence:`+s),l.updateSelfInfo({groupID:e,topicID:t,selfInfo:{readedSequence:s}}),l.clearGroupAtInfoList(e,t),l.markMessageAsRead(t,s),l.updateUnreadCount(e,t)})})}_emitTopicTips(e){var{message:{messageHelper:t,messageFactory:s},OuterConstant:i,OuterEvent:o,notificationCenter:n}=this._core,t=(e.MsgBody.MsgType=i.MSG_GRP_TIP,t.parseServerGroupMessage(e)),e=(t.flow="in",t.conversationType=i.CONV_GROUP,s.createMessage(t));e.setElement(t.elements),e.isSystemMessage=!0,n.emitOuterEvent(o.MESSAGE_RECEIVED,{name:o.MESSAGE_RECEIVED,data:[e]})}_emitTopicNotices(e){var{message:{messageHelper:t,messageFactory:s},OuterConstant:i,OuterEvent:o,notificationCenter:n}=this._core,t=(e.MsgBody.MsgType=i.MSG_GRP_SYS_NOTICE,t.parseServerGroupMessage(e)),e=(t.flow="in",t.conversationType=i.CONV_SYSTEM,t.conversationID=i.CONV_SYSTEM,s.createMessage(t));e.setElement(t.elements),e.isSystemMessage=!0,n.emitOuterEvent(o.MESSAGE_RECEIVED,{name:o.MESSAGE_RECEIVED,data:[e]})}_dispose(){var{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t,DESTROY:s}}=this._core,{TOPIC_TIPS_NOTIFICATION:i,TOPIC_SYSTEM_NOTIFICATION:o,TOPIC_MESSAGE_READ_SYNC:n}=e["InnerEventSubType"];e.unSubscribeInnerEvent(t,i,this._handleTopicTips,this),e.unSubscribeInnerEvent(t,o,this._handleTopicNotices,this),e.unSubscribeInnerEvent(t,n,this._handleTopicMessageReadSynced,this),e.unSubscribeInnerEvent(s,this._dispose,this)}};function g(e,a,r,c){return new(r=r||Promise)(function(s,t){function i(e){try{n(c.next(e))}catch(e){t(e)}}function o(e){try{n(c.throw(e))}catch(e){t(e)}}function n(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(i,o)}n((c=c.apply(e,a||[])).next())})}var r=new class{constructor(){this._name="GetJoinedCommunityHandler"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getJoinedCommunityList",context:this})}getJoinedCommunityList(){return g(this,void 0,void 0,function*(){var e=this._core["apiMap"]["getGroupList"],e=(yield e(!0)).filter(e=>!0===e.isSupportTopic);return console.log(this._name+".getJoinedCommunityList ok, count:"+e.length),{code:0,data:{groupList:e}}})}},c=new class{constructor(){this._name="CreateTopicHandler"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"createTopicInCommunity",context:this})}createTopicInCommunity(n){return g(this,void 0,void 0,function*(){let s="createTopicInCommunity",{utils:{isUndefined:e},common:{isTopic:t},helper:{ChatError:i}}=this._core,o=n["topicID"];if(!e(o)&&!t(o)){let e=new i({functionName:s,code:3021});throw console.error(this._name+`.${s} fail:`,e),e}try{let e=yield function(r,c){return g(this,void 0,void 0,function*(){var{groupID:e,topicID:t,topicName:s,avatar:i,notification:o,introduction:n,customData:a}=r;return c.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.create_topic",data:{GroupId:e,TopicId:t,TopicName:s,FaceUrl:i,Notification:o,Introduction:n,CustomString:a}})})}(n,this._core),{TopicId:t=""}=e||{};return console.log(this._name+`.${s} ok, topicID:`+t),l.updateTopic([Object.assign(Object.assign({},n),{topicID:t})]),{code:0,data:{topicID:t}}}catch(e){throw console.error(this._name+`.${s} failed, error:`,e),e}})}},u=new class{constructor(){this._name="DeleteTopicHandler"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"deleteTopicFromCommunity",context:this})}deleteTopicFromCommunity(c){return g(this,void 0,void 0,function*(){var s="deleteTopicFromCommunity",{groupID:a,topicIDList:r=[]}=c;try{let e=yield function(s,i){return g(this,void 0,void 0,function*(){var{groupID:e,topicIDList:t}=s;return i.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.destroy_topic",data:{GroupId:e,TopicIdList:t}})})}({groupID:a,topicIDList:r},this._core),{DestroyResultItem:t=[]}=e||{},i=[],o=[],n=[];return t.forEach(e=>{var{TopicId:e,ErrorCode:t,ErrorInfo:s}=e;0===t?(i.push({topicID:e}),n.push(e)):o.push({topicID:e,code:t,message:s})}),0<n.length&&l.deleteTopicList(c.groupID,n),console.log(`${this._name}.${s} ok, groupID:${a} success:${i.length} fail:`+o.length),{code:0,data:{successTopicList:i,failureTopicList:o}}}catch(e){throw console.error(this._name+`.${s} failed, error:`,e),e}})}},p=new class{constructor(){this._name="GetTopicHandler",this._getCloudConfig=e=>{var t=this._core["store"];return(t.get("cloudConfig")||{})[e]}}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getTopicList",context:this})}getTopicList(e){return g(this,void 0,void 0,function*(){var{groupID:t,topicIDList:s=[]}=e,i=0===s.length;if(this._isFetchingFromCache(t,i)){let e=l.getTopicList(t,s);if(i||e.length===s.length)return console.log(this._name+`.getTopicList groupID:${t} from cache, count:`+e.length),{code:0,data:{successTopicList:e,failureTopicList:[]}}}return this._getTopicListFromServer({groupID:t,topicIDList:s},i)})}_isFetchingFromCache(e,t){var{hasFetchedAllTopics:e=!1,time:s=0}=l.getTopicRequestInfo(e);return!(!e&&(t||e))&&Date.now()-s<this._getCacheDuration()}_getCacheDuration(){var{isUndefined:e}=this._core["utils"];let t=this._getCloudConfig("topic_cache_time");return!e(t)&&0<=(t=parseInt(t,10))&&t<=3600?1e3*t:3e5}_getTopicListFromServer(u,p){return g(this,void 0,void 0,function*(){var i="_getTopicListFromServer",{isEmpty:o}=this._core["utils"],c=u["groupID"];try{let e=yield function(s,i){return g(this,void 0,void 0,function*(){var{groupID:e,topicIDList:t}=s;return i.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.get_topic",data:{GroupId:e,TopicIdList:t,MemberInfoFilter:["NoUnreadSeqList"]}})})}(u,this._core),{TopicAndSelfInfo:t=[]}=e||{},n=[],a=[],r=[],s=(this._convertTopicInfoList(t).forEach(e=>{var{topic:e,selfInfo:t,code:s,message:i}=e,o=e["topicID"];0===s?(n.push(Object.assign(Object.assign({},e),{selfInfo:t})),a.push(o)):r.push({topicID:o,code:s,message:i})}),l.updateTopic(n),l.updateTopicAtInfo(n),console.log(`${this._name}.${i} groupID:${c} from remote, success count:${a.length}, fail count:`+r.length),[]);return o(a)||(l.setTopicRequestInfo(c,{hasFetchedAllTopics:p,time:Date.now()}),s=l.getTopicList(c,a)),{code:0,data:{successTopicList:s,failureTopicList:r}}}catch(e){throw console.error(this._name+`.${i} failed, error:`,e),e}})}_convertTopicInfoList(e){let o=[];return e.forEach(e=>{var{TopicInfo:e={},SelfInfo:t={},ErrorCode:s,ErrorInfo:i}=e;o.push({code:s,message:i,topic:this._convertTopicInfo(e),selfInfo:this._convertSelfInfo(t)})}),o}_convertTopicInfo(e){var t,s,i,o,n,a,r,c,u,p,l,d=this._core["utils"]["isEmpty"];return d(e)?{}:({CreateTime:d,CustomString:e,FaceUrl:t,GroupId:s,LastMsgTime:i,NextMsgSeq:o,Introduction:n,Notification:a,ShutUpAllFlag:r,TopicId:c,TopicName:u,LastMsg:p,AtInfoList:l}=e,{createTime:d,customData:e,avatar:t,groupID:s,lastMessageTime:i,nextMessageSeq:o,introduction:n,notification:a,muteAllMembers:r,topicID:c,topicName:u,lastMsg:this._convertLastMsg(p),groupAtInfoList:this._convertAtInfoList({groupID:s,topicID:c,atInfoList:l})})}_convertLastMsg(e){var t,{utils:{isUndefined:s},OuterConstant:i}=this._core;if(!s(e))return 4===e.Event&&(e.MsgBody.MsgType=i.MSG_GRP_TIP),{messageHelper:s}=this._core["message"],i=s.parseServerGroupMessage(e),{From_AccountHeadurl:s,From_AccountNick:e,LastMsgSeq:t}=e,Object.assign(Object.assign({},i),{avatar:s,nick:e,sequence:t})}_convertAtInfoList(e){let{groupID:i,topicID:o,atInfoList:t=[]}=e;if(0===t.length)return[];let n=[];return t.forEach(e=>{var{AtFlagList:e,AtMsgSeq:t,From_Account:s}=e;n.push({groupID:i,topicID:o,groupAtType:e,sequence:t,from:s})}),n}_convertSelfInfo(e){var t,s,i,o=this._core["utils"]["isEmpty"];return o(e)?{}:({InheritGroupReceiveOption:o,MsgFlag:e,MsgSeq:t,NoUnreadSeqList:s,ShutUpTime:i}=e,{inheritGroupReceiveOption:o,messageRemindType:e,readedSequence:t,excludedUnreadSequenceList:s,muteTime:i})}},_=new class{constructor(){this._name="UpdateTopicHandler"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"updateTopicProfile",context:this})}updateTopicProfile(n){return g(this,void 0,void 0,function*(){var t="updateTopicProfile",{isUndefined:e}=this._core["utils"],{groupID:s,topicID:i,muteAllMembers:o}=n;e(n.muteAllMembers)||(n.muteAllMembers=!0===o?"On":"Off");try{return yield function(c,u){return g(this,void 0,void 0,function*(){var{groupID:e,topicID:t,topicName:s,avatar:i,notification:o,introduction:n,customData:a,muteAllMembers:r}=c;return u.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.modify_topic",data:{GroupId:e,TopicId:t,TopicName:s,FaceUrl:i,Notification:o,Introduction:n,CustomString:a,ShutUpAllMember:r}})})}(n,this._core),console.log(this._name+`.${t} ok, topicID:`+i),l.updateTopic([n]),{code:0,data:{topic:l.getTopic(s,i)}}}catch(e){throw console.error(this._name+`.${t} failed, topicID:${i} error:`,e),e}})}},m=new class{constructor(){this._name="MessageReadHandler"}init(e){let{helper:t,common:{isTopic:s}}=this._core=e;t.registerApi({apiName:"setMessageRead",context:this,matcher:e=>s(e[0].conversationID)})}setMessageRead(p){return g(this,void 0,void 0,function*(){let{utils:{isEmpty:e},ssoLog:t,helper:{ChatError:i}}=this._core,s=p["conversationID"],o={code:0,data:{}},n=d(s),a=h(n),r=l.getTopic(a,n),c=this._name+`.setMessageRead topicID:${n} conversationID:${s} unreadCount:`+((null==r?void 0:r.unreadCount)||0);if(o.successLog={message:c},!r)return o;if(e(r.groupAtInfoList)||this._deleteTopicAtTips(a,n),0===r.unreadCount)return o;var u=this._getLocalMessageMaxSequence(r);try{yield this._setTopicMessageRead(a,n,u)}catch(e){let{errorCode:t,errorInfo:s}=e;throw new i({functionName:"setMessageRead",code:t,message:s,moreMessage:c})}return Object.assign(Object.assign({},o),{successLog:{message:c+" lastMessageSequence:"+u}})})}_deleteTopicAtTips(n,a){return g(this,void 0,void 0,function*(){this._core.ssoLog.debug("_deleteTopicAtTips",this._name+`._deleteTopicAtTips groupID:${n} topicID:`+a);let e=l.getTopic(n,a);if(e){var i=(null==e?void 0:e.groupAtInfoList)||[];if(0!==i.length)try{let{common:{getCurrentUserID:t},OuterConstant:{CONV_AT_ALL:s}}=this._core;var o=[...i];0===(o=i.filter(e=>!e.atTypeArray.includes(s))).length?l.clearGroupAtInfoList(n,a):(yield function(t,s){return g(this,void 0,void 0,function*(){var e=t["messageListToDelete"];return s.common.buildAndSendPacket({servcmd:"openim.deletemsg",data:{DelMsgList:e}})})}({messageListToDelete:o.map(e=>({From_Account:e.from,To_Account:t(),MsgSeq:e.__sequence,MsgRandom:e.__random,GroupId:e.groupID}))},this._core),this._core.ssoLog.debug(this._name+"._deleteTopicAtTips ok. count:"+i.length),l.clearGroupAtInfoList(n,a))}catch(e){console.error(this._name+"._deleteTopicAtTips fail:",e)}}})}_getLocalMessageMaxSequence(e){var{message:{messageDataHandler:t},OuterConstant:{CONV_GROUP:s}}=this._core,i=e["topicID"],t=t.getLocalMessageList(""+s+i),s=Math.max(...t.map(e=>e.sequence));let o=(null==(i=null==e?void 0:e.lastMessage)?void 0:i.lastSequence)||0;return s>o&&(console.log(`${this._name}._getLocalMessageMaxSequence update lastMessageSequence from ${o} to `+s),o=s),o}_setTopicMessageRead(e,t,s){return g(this,void 0,void 0,function*(){try{yield function(i,o){return g(this,void 0,void 0,function*(){var{groupID:e,topicID:t,lastMessageSequence:s}=i;return o.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.msg_read_report",data:{GroupId:e,TopicId:t,MsgReadedSeq:s}})})}({groupID:e,topicID:t,lastMessageSequence:s},this._core),console.log(this._name+"._setTopicMessageRead ok, lastReadSequence:"+s),l.updateSelfInfo({groupID:e,topicID:t,selfInfo:{readedSequence:s}}),l.markMessageAsRead(t,s),l.updateUnreadCount(e,t)}catch(e){throw console.error(this._name+"._setTopicMessageRead fail:",e),e}})}},I=new class{init(e){e.ssoLog.debug("TopicAction.init"),r.init(e),c.init(e),u.init(e),p.init(e),_.init(e),m.init(e)}};let e={required:!0,rules:["string"],allowEmpty:!1},T={createTopicInCommunity:{groupID:e,topicName:e},deleteTopicFromCommunity:{groupID:e,topicIDList:{required:!1,rules:["array"],allowEmpty:!0}},getTopicList:{groupID:e,topicIDList:{required:!1,rules:["array"],allowEmpty:!0}},updateTopicProfile:{groupID:e,topicID:e}},f={getJoinedCommunityList:!0,createTopicInCommunity:!0,deleteTopicFromCommunity:!0,getTopicList:!0,updateTopicProfile:!0};return new class{constructor(){this.name="Topic"}install(e){i.init(e),l.init(e),t.init(e),a.init(e),I.init(e),e.helper.registerValidateConfig({auth:f,params:T})}}});
|