1 line
20 KiB
JavaScript
1 line
20 KiB
JavaScript
"use strict";const t=12,e=20,o=23,s=27;class n{constructor(t=0,e=0){this.high=t,this.low=e}equal(t){return null!==t&&this.low===t.low&&this.high===t.high}toString(){var t=Number(this.high).toString(16);let e=Number(this.low).toString(16);if(e.length<8){let t=8-e.length;for(;t;)e="0"+e,t--}return t+e}}const i={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},r={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15},l="CHINA",u={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(t=l){this.CURRENT=i.PRODUCTION[t]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",FOLLOW:"follow"}},a=(new n(0,Math.pow(2,0)).toString(),new n(0,Math.pow(2,1)).toString(),new n(0,Math.pow(2,2)).toString(),new n(0,Math.pow(2,3)).toString(),new n(0,Math.pow(2,4)).toString(),new n(0,Math.pow(2,6)).toString(),new n(0,Math.pow(2,7)).toString(),new n(0,Math.pow(2,9)).toString(),new n(0,Math.pow(2,10)).toString(),new n(0,Math.pow(2,11)).toString(),new n(0,Math.pow(2,13)).toString(),new n(0,Math.pow(2,15)).toString(),new n(Math.pow(2,6)).toString(),new n(Math.pow(2,7)).toString(),new n(Math.pow(2,8)).toString(),new n(Math.pow(2,9)).toString(),new n(Math.pow(2,10)).toString(),new n(Math.pow(2,16)).toString(),u.HOST.setCurrent(l),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)),c=(a&&wx.createGamePortal,"undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting)),h="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),_="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),g="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,m="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,w=a||c||h||_||g||m||f,d=("undefined"!=typeof uni||"undefined"!=typeof window)&&!w,p=(c?qq:h?tt:_?swan:g?my:a?wx:m?uni:f&&jd,d&&window&&window.navigator&&window.navigator.userAgent||""),L=/(micromessenger|webbrowser)/i.test(p),I=/AppleWebKit\/([\d.]+)/i.exec(p),T=(I&&parseFloat(I.pop()),function(){let t="WEB";return L?t="WEB":c?t="QQ_MP":h?t="TT_MP":_?t="BAIDU_MP":g?t="ALI_MP":a?t="WX_MP":m&&(t="UNI_NATIVE_APP"),r[t]}()),M=(!function(){var t=p.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),function(){var t,e,o=p.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);o&&(t=o[1]&&parseFloat(o[1]),e=o[2]&&parseFloat(o[2]),t&&e&&parseFloat(o[1]+"."+o[2]))}(),function(){var t=p.match(/Chrome\/(\d+)/);t&&t[1]&&parseFloat(t[1])}(),/MSIE/.test(p)||-1<p.indexOf("Trident")&&-1<p.indexOf("rv:11.0"));let y,A;!function(){var t=/MSIE\s(\d+)\.\d/.exec(p),t=t&&parseFloat(t[1]);!t&&/Trident\/7.0/i.test(p)&&/rv:11.0/.test(p)}(),function(){var t=p.match(/TBS\/(\d+)/i);t&&t[1]&&t[1]}(),y="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const S=function(){},E=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let F=E.length;for(;F--;)A=E[F],console[A]||(y[A]=S);var O=y;const U=function(){return(new Date).getTime()+0},C="Tag_Profile_IM_Nick",D="Tag_Profile_IM_Gender",N="Tag_Profile_IM_BirthDay",P="Tag_Profile_IM_Location",v="Tag_Profile_IM_SelfSignature",b="Tag_Profile_IM_AllowType",R="Tag_Profile_IM_Language",G="Tag_Profile_IM_Image",q="Tag_Profile_IM_MsgSettings",k="Tag_Profile_IM_AdminForbidType",x="Tag_Profile_IM_Level",W="Tag_Profile_IM_Role",$=Object.prototype.hasOwnProperty,B=function(t){return"map"===z(t)},j=function(t){return"set"===z(t)},H=function(t){return"file"===z(t)},K=function(t){return null!==t&&("number"==typeof t&&!isNaN(+t)||"object"==typeof t&&t.constructor===Number)},Y=function(t){if("object"!=typeof t||null===t)return!1;t=Object.getPrototypeOf(t);if(null===t)return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return t===e},X=function(t){return void 0===t},V=function(t){return e=t,("function"==typeof Array.isArray?Array.isArray(e):"array"===z(e))||null!==t&&"object"==typeof t;var e},z=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()},J=(Date.now||(Date.now=function(){return(new Date).getTime()}),"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),Q=J.length;function Z(){return!M&&!w}let et=0;function ot(){return Z()?"%c Chat %c":"Chat"}function st(){const t=function(){const t=new Date;return t.setTime(U()),t}();return t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(t){let e;switch(t.toString().length){case 1:e="00"+t;break;case 2:e="0"+t;break;default:e=t}return e}(t.getMilliseconds())}const nt={arguments2String(o){let s="";if(1===o.length)s=o[0];else for(let t=0,e=o.length;t<e;t++)V(o[t])?o[t]instanceof Error?s+=(n=o[t],JSON.stringify(n,["message","code"])):s+=JSON.stringify(o[t]):s+=o[t],s+=" ";var n;return s},_exec(t,e){Z()?O[t](ot(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",st(),e):O[t](`${ot()} ${st()} `+e)},d:function(){var t;et<=-1&&(t=this.arguments2String(arguments),this._exec("debug",t))},l:function(){var t;et<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},log:function(){var t;et<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},i:function(){var t;et<=1&&(t=this.arguments2String(arguments),this._exec("info",t))},w:function(){var t;et<=2&&(t=this.arguments2String(arguments),this._exec("warn",t))},e:function(){var t;et<=3&&(t=this.arguments2String(arguments),this._exec("error",t))},setLevel:function(t){t<4&&this._exec("log","set level from "+et+" to "+t),et=t},getLevel:function(){return et}},it=function(t){return{code:0,data:t||{}}};class rt extends Error{constructor(t){super();var{code:t,message:e,data:o}=t;this.code=t,this.message=e||this._getErrorMessage(this.code),this.data=o||{}}}const lt=2805,ut=2903,at=3122,ct="onMyFollowersListUpdated",ht="onMyFollowingListUpdated",_t="onMutualFollowersListUpdated",gt="error";let ft=null;const mt=function(t){return Promise.resolve(it(t))},wt=function(t,e=!1){if(t instanceof rt)return e&&null!==ft&&ft.emit(gt,t),Promise.reject(t);if(t instanceof Error){const t=new rt({code:ut});return e&&null!==ft&&ft.emit(gt,t),Promise.reject(t)}if(X(t)||X(t.code))return Promise.reject(new rt({code:ut}));t=new rt(t);return e&&null!==ft&&ft.emit(gt,t),Promise.reject(t)},dt="follow_add",pt="follow_delete",Lt="follow_get",It="follow_get_info",Tt={info:4,warning:5,error:6},Mt={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},yt={login:4,plugin_translate:16,plugin_voice_to_text:16,plugin_cs:16,plugin_push:16,plugin_bot:16};class At{constructor(t){this._n="SSOLogData",this.eventType=yt[t]||0,this.timestamp=0,this.networkType=8,this.code=0,this.message="",this.moreMessage="",this.extension=t,this.costTime=0,this.duplicate=!1,this.level=4,this.uiPlatform=void 0,this._sentFlag=!1,this._startts=U()}static bindEventStatModule(t){At.prototype._eventStatModule=t}static bindNetMonitorModule(t){At.prototype._netMonitorModule=t}updateTimeStamp(){this.timestamp=U()}start(t){return this._startts=t,this}end(t=!1){if(!this._sentFlag){if(this._netMonitorModule){const t=this._netMonitorModule.getNetworkType();this.setNetworkType(t)}var e=U();0===this.costTime&&(this.costTime=e-this._startts),this.setMoreMessage(`startts:${this._startts} endts:`+e),t?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout(()=>{this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)},0)}}setError(t){if(!(t instanceof Error))return nt.w(this._n+".setError value not instanceof Error, please check!"),this;if(this._sentFlag)return this;let e=!0;if(e=this._netMonitorModule?this._netMonitorModule.isOnline():e)t.code&&this.setCode(t.code),t.message&&this.setMoreMessage(t.message);else{const t=lt;this.setCode(t)}return this.setLevel("error"),this}setCode(t){return X(t)||this._sentFlag||("ECONNABORTED"===t&&(this.code=103),K(t)?this.code=t:nt.w(this._n+".setCode value not a number, please check!",t,typeof t)),this}setMessage(t){return X(t)||this._sentFlag||(K(t)&&(this.message=t.toString()),"string"==typeof t&&(this.message=t)),this}setCostTime(t){return this.costTime=t,this}setLevel(t){return X(t)||this._sentFlag||(this.level=Tt[t]),this}setMoreMessage(t){return function(t){if(null==t)return 1;if("boolean"!=typeof t){if("number"==typeof t)return 0===t;if("string"==typeof t)return 0===t.length;if("function"==typeof t)return 0===t.length;if(Array.isArray(t))return 0===t.length;if(t instanceof Error)return""===t.message;if(Y(t)){for(const e in t)if($.call(t,e))return;return 1}return(B(t)||j(t)||H(t))&&0===t.size}}(this.moreMessage)?this.moreMessage=""+t:this.moreMessage+=" "+t,this}setNetworkType(t){return X(t)?nt.w(this._n+".setNetworkType value is undefined, please check!"):(t=Mt[t.toLowerCase()],X(t)||(this.networkType=t)),this}getStartTs(){return this._startts}setUIPlatform(t){return this.uiPlatform=t,this}setExtension(t){return this.extension=t,this}setEventType(t){return this.eventType=t,this}}const St={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"},Et={NONE:0,FOLLOWERS:1,FOLLOWING:2,MUTUAL:3};class Ft extends class{constructor(t){this._m=t,this._n=""}isLoggedIn(){return this._m.get(t).isLoggedIn()}isOversea(){return this._m.get(t).isOversea()}isPrivateNetWork(){return this._m.get(t).isPrivateNetWork()}getFileDownloadProxy(){return this._m.get(t).getFileDownloadProxy()}getMyUserID(){return this._m.get(t).getUserID()}getMyTinyID(){return this._m.get(t).getTinyID()}getSDKAppID(){return this._m.get(t).getSDKAppID()}isIntl(){return this._m.get(t).isIntl()}isUsingChatCore(){return this._m.get(t).isUsingChatCore()}isDevMode(){return this._m.get(t).isDevMode()}get(t){return this._m.get(t)}getPlatform(){return T}getCloudConfig(t){return this._m.get(o).getCloudConfig(t)}emitOuterEvent(t,e){this._m.getOuterEmitterInstance().emit(t,e)}emitInnerEvent(t,e){this._m.getInnerEmitterInstance().emit(t,e)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(e){return this._m.get(t).getTinyID()+"-"+e.random}req(t){return this._m.get(e).req(t)}canIUse(t){return this._m.get(s).canIUse(t)}getErrorMessage(t,e,o){return this._m.getErrorMessage(t,e,o)}outputWarning(t,e,o){t=this.getErrorMessage(t,e,o);t&&nt.w(t)}cannotUseCommercialAbility(t){var e=at;return wt({code:e,message:this.getErrorMessage(e,t)})}}{constructor(t){super(t),this._n="FollowModule",this._myFollowersList=new Map,this._myFollowingList=new Map,this._myMutualFollowersList=new Map,this._myFollowInfo=new Map,this.MAX_CATCH_TIME=6e5,this.FIRST_PAGE_INDEX=function(){let e="";for(let t=32;0<t;--t)e+=J[Math.floor(Math.random()*Q)];return e}(),this.DEFAULT_COUNT=100,this.MAX_COUNT=1e3;const e=this.getInnerEmitterInstance();e.on(St.A2KEY_AND_TINYID_UPDATED,this._init,this),e.on(St.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_init(){this.getUserFollowInfo()}_onCloudConfigUpdated(){var t=this.getCloudConfig("follow_req_count");X(t)||(t=Number(t),this.DEFAULT_COUNT=t>this.MAX_COUNT?this.MAX_COUNT:t,this._myFollowersList.clear(),this._myFollowingList.clear(),this._myMutualFollowersList.clear())}getMyFollowInfoOnReconnected(){this.getUserFollowInfo()}onFollowInfoNotify(t){var{followAddList:t=[],followDeleteList:e=[],pushType:o,from:s}=t.dataList||{},n=this._initFollowInfo();1===o?this._handleFollowAddList({from:s,followAddList:t,followInfo:n}):this._handleFollowDeleteList({from:s,followDeleteList:e,followInfo:n}),this._setMyFollowInfo({followersCount:n[Et.FOLLOWERS].count,followingCount:n[Et.FOLLOWING].count,mutualFollowersCount:n[Et.MUTUAL].count}),this._emitEvent(n),nt.l(`${this._n}.onFollowInfoNotify from:${s} pushType:${o} followAddList:${t.length} followDeleteList:`+e.length)}_initFollowInfo(){var{followersCount:t=0,followingCount:e=0,mutualFollowersCount:o=0}=this._getMyFollowInfo();return{[Et.FOLLOWERS]:{count:t,addList:[],deleteList:[]},[Et.FOLLOWING]:{count:e,addList:[],deleteList:[]},[Et.MUTUAL]:{count:o,addList:[],deleteList:[]}}}_handleFollowAddList(t){const{from:e,followAddList:o,followInfo:s}=t;o.forEach(t=>{t.followType===Et.MUTUAL&&(e===this.getMyUserID()?(s[Et.FOLLOWERS].count--,s[Et.FOLLOWERS].deleteList.push(t.userID)):(s[Et.FOLLOWING].count--,s[Et.FOLLOWING].deleteList.push(t.userID))),s[t.followType].count++,s[t.followType].addList.push(t)})}_handleFollowDeleteList(t){const{from:e,followDeleteList:o,followInfo:s}=t;o.forEach(t=>{t.followType===Et.NONE&&(e===this.getMyUserID()?(s[Et.FOLLOWING].count--,s[Et.FOLLOWING].deleteList.push(t.userID)):(s[Et.FOLLOWERS].count--,s[Et.FOLLOWERS].deleteList.push(t.userID))),t.followType!==Et.FOLLOWERS&&t.followType!==Et.FOLLOWING||(e===this.getMyUserID()?(s[Et.FOLLOWERS].count++,s[Et.FOLLOWERS].addList.push(t)):(s[Et.FOLLOWING].count++,s[Et.FOLLOWING].addList.push(t)),s[Et.MUTUAL].count--,s[Et.MUTUAL].deleteList.push(t.userID))})}_emitEvent(o){Object.values(Et).forEach(t=>{var e={totalCount:o[t].count<0?0:o[t].count,addUserInfoList:o[t].addList,deleteUserIDList:o[t].deleteList};(0<e.addUserInfoList.length||0<e.deleteUserIDList.length)&&(t===Et.FOLLOWERS&&this.emitOuterEvent(ct,e),t===Et.FOLLOWING&&this.emitOuterEvent(ht,e),t===Et.MUTUAL&&this.emitOuterEvent(_t,e))})}followUser(t){const e=this._n+".followUser",o="userIDList:"+t.length,s=new At("followUser");return s.setMessage(o),nt.l(e+" "+o),this.req({proto:dt,data:{fromAccount:this.getMyUserID(),userIDList:t.map(t=>({userID:t}))}}).then(t=>(s.end(),nt.l(e+" ok."),it(t.data.resultList))).catch(t=>(s.setError(t).end(),nt.e(e+" failed. error:",t),wt(t)))}unfollowUser(t){const e=this._n+".unfollowUser",o="userIDList:"+t.length,s=new At("unfollowUser");return s.setMessage(o),nt.l(e+" "+o),this.req({proto:pt,data:{fromAccount:this.getMyUserID(),userIDList:t}}).then(t=>(s.end(),nt.l(e+" ok."),it(t.data.resultList))).catch(t=>(s.setError(t).end(),nt.e(e+" failed. error:",t),wt(t)))}getMyFollowersList(t=""){const e=t||this.FIRST_PAGE_INDEX;if(this._myFollowersList.has(e)){const{resultList:t,nextCursor:o="",lastUpdateTime:s}=this._myFollowersList.get(e);if(Date.now()-s<this.MAX_CATCH_TIME&&0<t.length)return nt.l(`${this._n}.getMyFollowersList startCursor:${e} from cache.`),mt({resultList:t,nextCursor:o})}return this._getFollowList(t,Et.FOLLOWERS).then(t=>(this._myFollowersList.set(e,{...t,lastUpdateTime:Date.now()}),nt.l(`${this._n}.getMyFollowersList startCursor:${e} from remote.`),it(t)))}getMyFollowingList(t=""){const e=t||this.FIRST_PAGE_INDEX;if(this._myFollowingList.has(e)){const{resultList:t,nextCursor:o,lastUpdateTime:s}=this._myFollowingList.get(e);if(Date.now()-s<this.MAX_CATCH_TIME&&0<t.length)return nt.l(`${this._n}.getMyFollowingList startCursor:${e} from cache.`),mt({resultList:t,nextCursor:o})}return this._getFollowList(t,Et.FOLLOWING).then(t=>(this._myFollowingList.set(e,{...t,lastUpdateTime:Date.now()}),nt.l(`${this._n}.getMyFollowingList startCursor:${e} from remote.`),it(t)))}getMutualFollowersList(t=""){const e=t||this.FIRST_PAGE_INDEX;if(this._myMutualFollowersList.has(e)){const{resultList:t,nextCursor:o,lastUpdateTime:s}=this._myMutualFollowersList.get(e);if(Date.now()-s<this.MAX_CATCH_TIME&&0<t.length)return nt.l(`${this._n}.getMutualFollowersList startCursor:${e} from cache.`),mt({resultList:t,nextCursor:o})}return this._getFollowList(t,Et.MUTUAL).then(t=>(this._myMutualFollowersList.set(e,{...t,lastUpdateTime:Date.now()}),nt.l(`${this._n}.getMutualFollowersList startCursor:${e} from remote.`),it(t)))}_getFollowList(t,e){const n=new At("_getFollowList");return n.setMessage(`startCursor:${t} type:`+e),this.req({proto:Lt,data:{fromAccount:this.getMyUserID(),count:this.DEFAULT_COUNT,startCursor:t,type:e}}).then(t=>{n.end();const{resultList:e=[],nextCursor:o=""}=t.data,s=[];return e.forEach(t=>{var{userID:t,followTime:e,profileList:o=[]}=t;s.push({userID:t,followTime:e,...this._handleProfileItem(o)})}),{resultList:s,nextCursor:o}}).catch(t=>(n.setError(t).end(),nt.e(this._n+"._getFollowList failed. error:",t),wt(t)))}_handleProfileItem(t){const e={};return t.forEach(t=>{switch(t.tag){case C:e.nick=t.value;break;case D:e.gender=t.value;break;case N:e.birthday=t.value;break;case P:e.location=t.value;break;case v:e.selfSignature=t.value;break;case b:e.allowType=t.value;break;case R:e.language=t.value;break;case G:e.avatar=t.value;break;case q:e.messageSettings=t.value;break;case k:e.adminForbidType=t.value;break;case x:e.level=t.value;break;case W:e.role=t.value;break;default:e[t.tag]=t.value}}),e}getUserFollowInfo(t){let e=t,o=!1;X(t)&&(e=[this.getMyUserID()],o=!0);const n=this._n+".getUserFollowInfo",s=`userIDList:${e.length} isGetMyFollowInfo:`+o,i=new At("getUserFollowInfo");return i.setMessage(s),nt.l(n+" "+s),this.req({proto:It,data:{fromAccount:this.getMyUserID(),userIDList:e}}).then(t=>{i.end(),nt.l(n+" ok.");const{followInfoList:e=[]}=t.data;if(o){const{followersCount:t,followingCount:o,mutualFollowersCount:n}=e[0];this._setMyFollowInfo({followersCount:t,followingCount:o,mutualFollowersCount:n})}const s=[];return e.forEach(t=>{var{followersCount:t,followingCount:e,mutualFollowersCount:o}=t;s.push({followersCount:t,followingCount:e,mutualFollowersCount:o})}),it(s)}).catch(t=>(i.setError(t).end(),nt.e(n+" failed. error:",t),wt(t)))}_getMyFollowInfo(){var t=this.getMyUserID();return this._myFollowInfo.get(t)}_setMyFollowInfo(t){var e=this.getMyUserID();this._myFollowInfo.set(e,t)}reset(){nt.l(this._n+".reset"),this._myFollowersList.clear(),this._myFollowingList.clear(),this._myMutualFollowersList.clear(),this._myFollowInfo.clear()}}export{Ft as default}; |