jiuyiUniapp/service/node_modules/@tencentcloud/chat/modules/follow-module.js

1 line
21 KiB
JavaScript

"use strict";const t=12,e=20,s=23,o=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:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT0:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT0:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT0:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT0:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{DEFAULT0:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT0:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT0:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.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,DONUT_NATIVE_APP:19,NS_NATIVE_APP:20,RN_NATIVE_APP:21},l="CHINA",c={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",GRP_SEARCH:"group_search",GRP_MEMBER_SEARCH:"group_member_search",USER_SEARCH:"user_search",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report",IM_MSG_LOGIC:"im_msg_db_logic"}},u={SEARCH_GRP_SNS:new n(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new n(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new n(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new n(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new n(0,Math.pow(2,6)).toString(),USER_STATUS:new n(0,Math.pow(2,7)).toString(),CONV_MARK:new n(0,Math.pow(2,9)).toString(),CONV_GROUP:new n(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new n(0,Math.pow(2,11)).toString(),MSG_EXT:new n(0,Math.pow(2,13)).toString(),GRP_COUNTER:new n(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new n(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new n(Math.pow(2,7)).toString(),PLUGIN_CS:new n(Math.pow(2,8)).toString(),PLUGIN_PUSH:new n(Math.pow(2,9)).toString(),PLUGIN_BOT:new n(Math.pow(2,10)).toString(),MSG_REACTION:new n(Math.pow(2,16)).toString(),FOLLOW:new n(Math.pow(2,20)).toString()},a=(c.HOST.setCurrent(l),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)),_=(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),m="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),g="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),w="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,f="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,d=a&&"object"==typeof wx.miniapp,p=a||_||h||m||g||f||w,T="undefined"==typeof window&&!p&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,I="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),A="undefined"!=typeof uni?!p:"undefined"!=typeof window&&!p&&!I,L=(_?qq:h?tt:m?swan:g?my:a?wx:f?uni:w&&jd,A&&window&&window.navigator&&window.navigator.userAgent||""),E=/(micromessenger|webbrowser)/i.test(L),M=function(){let t="WEB";return E?t="WEB":_?t="QQ_MP":h?t="TT_MP":m?t="BAIDU_MP":g?t="ALI_MP":a?t=d?"DONUT_NATIVE_APP":"WX_MP":f?t="UNI_NATIVE_APP":T?t="NS_NATIVE_APP":I&&(t="RN_NATIVE_APP"),r[t]}(),y=(!function(){var t=L.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),function(){var t,e,s=L.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);s&&(t=s[1]&&parseFloat(s[1]),e=s[2]&&parseFloat(s[2]),t&&e&&parseFloat(s[1]+"."+s[2]))}(),/MSIE/.test(L)||-1<L.indexOf("Trident")&&-1<L.indexOf("rv:11.0"));let S,U;!function(){var t=/MSIE\s(\d+)\.\d/.exec(L),t=t&&parseFloat(t[1]);!t&&/Trident\/7.0/i.test(L)&&/rv:11.0/.test(L)}(),S="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const F=function(){},O=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let P=O.length;for(;P--;)U=O[P],console[U]||(S[U]=F);var N=S;const C=function(){return(new Date).getTime()+0},D="Tag_Profile_IM_Nick",v="Tag_Profile_IM_Gender",R="Tag_Profile_IM_BirthDay",b="Tag_Profile_IM_Location",G="Tag_Profile_IM_SelfSignature",q="Tag_Profile_IM_AllowType",k="Tag_Profile_IM_Language",x="Tag_Profile_IM_Image",$="Tag_Profile_IM_MsgSettings",B="Tag_Profile_IM_AdminForbidType",V="Tag_Profile_IM_Level",W="Tag_Profile_IM_Role",j=Object.prototype.hasOwnProperty,H=function(t){return"map"===Z(t)},K=function(t){return"set"===Z(t)},X=function(t){return"file"===Z(t)},Y=function(t){return null!==t&&("number"==typeof t&&!isNaN(+t)||"object"==typeof t&&t.constructor===Number)},z=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},J=function(t){return void 0===t},Q=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()},et=(Date.now||(Date.now=function(){return(new Date).getTime()}),"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),st=et.length;function ot(){return!y&&!p}let nt=0;function it(){return ot()?"%c Chat %c":"Chat"}function rt(){const t=function(){const t=new Date;return t.setTime(C()),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 lt={arguments2String(s){let o="";if(1===s.length)o=s[0];else for(let t=0,e=s.length;t<e;t++){if(Q(s[t]))try{o+=s[t]instanceof Error?JSON.stringify(s[t],["message","code"]):JSON.stringify(s[t])}catch(t){o+=t?t.message:"";break}else o+=s[t];o+=" "}return o},_exec(t,e){ot()?N[t](it(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",rt(),e):N[t](`${it()} ${rt()} `+e)},d:function(){var t;nt<=-1&&(t=this.arguments2String(arguments),this._exec("debug",t))},l:function(){var t;nt<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},log:function(){var t;nt<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},i:function(){var t;nt<=1&&(t=this.arguments2String(arguments),this._exec("info",t))},w:function(){var t;nt<=2&&(t=this.arguments2String(arguments),this._exec("warn",t))},e:function(){var t;nt<=3&&(t=this.arguments2String(arguments),this._exec("error",t))},setLevel:function(t){t<4&&this._exec("log","set level from "+nt+" to "+t),nt=t},getLevel:function(){return nt}},ct=function(t){return{code:0,data:t||{}}};class ut extends Error{constructor(t){super();var{code:t,message:e,data:s}=t;this.code=t,e?this.message=e:this._getErrMsg&&(this.message=this._getErrMsg(this.code)),this.data=s||{}}}const at=2805,_t=2903,ht=3122,mt="onMyFollowersListUpdated",gt="onMyFollowingListUpdated",wt="onMutualFollowersListUpdated",ft="error";let dt=null;const pt=function(t){return Promise.resolve(ct(t))},Tt=function(t,e=!1){if(t instanceof ut)return e&&null!==dt&&dt.emit(ft,t),Promise.reject(t);if(t instanceof Error){const t=new ut({code:_t});return e&&null!==dt&&dt.emit(ft,t),Promise.reject(t)}if(J(t)||J(t.code))return Promise.reject(new ut({code:_t}));t=new ut(t);return e&&null!==dt&&dt.emit(ft,t),Promise.reject(t)},It="follow_add",At="follow_delete",Lt="follow_get",Et="follow_get_info",Mt="follow_check",yt={info:4,warning:5,error:6},St={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},Ut={login:4,plugin_search:16,plugin_translate:16,plugin_voice_to_text:16,plugin_cs:16,plugin_push:16,plugin_bot:16,plugin_emoji_reaction:16,tui_key_features:16};class Ft{constructor(t){this._n="SSOLogData",this.eventType=Ut[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=C()}static bindEventStatModule(t){Ft.prototype._eventStatModule=t}static bindNetMonitorModule(t){Ft.prototype._netMonitorModule=t}updateTimeStamp(){this.timestamp=C()}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=C();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 lt.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=at;this.setCode(t)}return this.setLevel("error"),this}setCode(t){return J(t)||this._sentFlag||("ECONNABORTED"===t&&(this.code=103),Y(t)?this.code=t:lt.w(this._n+".setCode value not a number, please check!",t,typeof t)),this}setMessage(t){return J(t)||this._sentFlag||(Y(t)&&(this.message=t.toString()),"string"==typeof t&&(this.message=t)),this}setCostTime(t){return this.costTime=t,this}setLevel(t){return J(t)||this._sentFlag||(this.level=yt[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(z(t)){for(const e in t)if(j.call(t,e))return;return 1}return(H(t)||K(t)||X(t))&&0===t.size}}(this.moreMessage)?this.moreMessage=""+t:this.moreMessage+=" "+t,this}setNetworkType(t){return J(t)?lt.w(this._n+".setNetworkType value is undefined, please check!"):(t=St[t.toLowerCase()],J(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 Ot={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"},Pt={NONE:0,FOLLOWERS:1,FOLLOWING:2,MUTUAL:3};class Nt extends class{constructor(t){this._m=t,this._n=""}isLoggedIn(){return this._m.get(t).isLoggedIn()}isOversea(){return this._m.get(t).isOversea()}isPrivateNetWork(){const e=this._m.get(t);return e.isPrivateNetWork()&&!e.getFileDownloadProxy()}getFileDownloadProxy(){return this._m.get(t).getFileDownloadProxy()}getDowloadFileAuthKey(){return this._m.get(t).getDowloadFileAuthKey()}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 M}getCloudConfig(t){return this._m.get(s).getCloudConfig(t)}emitOEvt(t,e){this._m.getOEmitInst().emit(t,e)}emitIEvt(t,e){this._m.getIEmitInst().emit(t,e)}getIEmitInst(){return this._m.getIEmitInst()}req(t){return this._m.get(e).req(t)}canIUse(t){return this._m.get(o).canIUse(t)}getErrMsg(t,e,s){return this._m.getErrMsg(t,e,s)}warn(t,e,s){t=this.getErrMsg(t,e,s);t&&lt.w(t)}noUse(t){var e=ht;return Tt({code:e,message:this.getErrMsg(e,t)})}}{constructor(t){super(t),this._n="FollowModule",this._myFollowersList=new Map,this._myFollowingList=new Map,this._myMutualFollowersList=new Map,this.MAX_CATCH_TIME=6e5,this.FIRST_PAGE_INDEX=function(){let e="";for(let t=32;0<t;--t)e+=et[Math.floor(Math.random()*st)];return e}(),this.DEFAULT_COUNT=500,this.MAX_COUNT=1e3,this.getIEmitInst().on(Ot.CLOUD_CONFIG,this._onCloudConfig,this)}_onCloudConfig(){var t=this.getCloudConfig("follow_req_count");J(t)||(t=Number(t),this.DEFAULT_COUNT=t>this.MAX_COUNT?this.MAX_COUNT:t,this._clearFollowList())}clearCacheOnReconnected(){this._clearFollowList()}onFollowNotify(t){const e=t.dataList||[];lt.l(this._n+".onFollowNotify followChangeList:"+e.length),e.forEach(t=>{const{followDiffList:e=[],...s}=t,{from:n,...i}=s;e.forEach(t=>{const{isAdd:e,followType:s=0}=t,o=this._initFollowInfo();1===e?(i.userID=n,o[s].userInfoList.push(i),o[s].isAdd=!0):(o[s].userInfoList.push(n),o[s].isAdd=!1),this._emitEvent(o)})})}_initFollowInfo(){const e={};return Object.values(Pt).forEach(t=>{t!==Pt.NONE&&(e[t]={userInfoList:[],isAdd:!1})}),e}_emitEvent(s){Object.keys(s).forEach(t=>{var t=Number(t),e=s[t];0<e.userInfoList.length&&(t===Pt.FOLLOWERS&&(this._clearFollowList(Pt.FOLLOWERS),this.emitOEvt(mt,e)),t===Pt.FOLLOWING&&(this._clearFollowList(Pt.FOLLOWING),this.emitOEvt(gt,e)),t===Pt.MUTUAL&&(this._clearFollowList(Pt.MUTUAL),this.emitOEvt(wt,e)))})}followUser(t){if(!this.canIUse(u.FOLLOW))return this.noUse("followUser");const e=this._n+".followUser",s="userIDList:"+t.length,o=new Ft("followUser");return o.setMessage(s),lt.l(e+" "+s),this.req({P:It,data:{fromAccount:this.getMyUserID(),userIDList:t.map(t=>({userID:t}))}}).then(t=>(o.end(),lt.l(e+" ok."),ct(t.data.resultList))).catch(t=>(o.setError(t).end(),lt.e(e+" failed. error:",t),Tt(t)))}unfollowUser(t){if(!this.canIUse(u.FOLLOW))return this.noUse("unfollowUser");const e=this._n+".unfollowUser",s="userIDList:"+t.length,o=new Ft("unfollowUser");return o.setMessage(s),lt.l(e+" "+s),this.req({P:At,data:{fromAccount:this.getMyUserID(),userIDList:t}}).then(t=>(o.end(),lt.l(e+" ok."),ct(t.data.resultList))).catch(t=>(o.setError(t).end(),lt.e(e+" failed. error:",t),Tt(t)))}getMyFollowersList(e=""){const s="getMyFollowersList";if(!this.canIUse(u.FOLLOW))return this.noUse(s);const o=e||this.FIRST_PAGE_INDEX;if(this._myFollowersList.has(o)){var{resultList:t,nextCursor:n,lastUpdateTime:i}=this._myFollowersList.get(o);if(Date.now()-i<this.MAX_CATCH_TIME&&0<t.length)return lt.l(`${this._n}.${s} nextCursor:${e} from local.`),pt({resultList:t,nextCursor:n})}return this._getFollowList(e,Pt.FOLLOWERS).then(t=>(this._myFollowersList.set(o,{...t,lastUpdateTime:Date.now()}),lt.l(`${this._n}.${s} nextCursor:${e} from remote.`),ct(t)))}getMyFollowingList(e=""){const s="getMyFollowingList";if(!this.canIUse(u.FOLLOW))return this.noUse(s);const o=e||this.FIRST_PAGE_INDEX;if(this._myFollowingList.has(o)){var{resultList:t,nextCursor:n,lastUpdateTime:i}=this._myFollowingList.get(o);if(Date.now()-i<this.MAX_CATCH_TIME&&0<t.length)return lt.l(`${this._n}.${s} nextCursor:${e} from local.`),pt({resultList:t,nextCursor:n})}return this._getFollowList(e,Pt.FOLLOWING).then(t=>(this._myFollowingList.set(o,{...t,lastUpdateTime:Date.now()}),lt.l(`${this._n}.${s} nextCursor:${e} from remote.`),ct(t)))}getMutualFollowersList(e=""){const s="getMutualFollowersList";if(!this.canIUse(u.FOLLOW))return this.noUse(s);const o=e||this.FIRST_PAGE_INDEX;if(this._myMutualFollowersList.has(o)){var{resultList:t,nextCursor:n,lastUpdateTime:i}=this._myMutualFollowersList.get(o);if(Date.now()-i<this.MAX_CATCH_TIME&&0<t.length)return lt.l(`${this._n}.${s} nextCursor:${e} from local.`),pt({resultList:t,nextCursor:n})}return this._getFollowList(e,Pt.MUTUAL).then(t=>(this._myMutualFollowersList.set(o,{...t,lastUpdateTime:Date.now()}),lt.l(`${this._n}.${s} nextCursor:${e} from remote.`),ct(t)))}_getFollowList(t,e){const n=new Ft("_getFollowList");return n.setMessage(`nextCursor:${t} type:`+e),this.req({P:Lt,data:{fromAccount:this.getMyUserID(),count:this.DEFAULT_COUNT,nextCursor:t,type:e}}).then(t=>{n.end();const{resultList:e=[],nextCursor:s=""}=t.data,o=[];return e.forEach(t=>{var{userID:t,followTime:e,profileList:s=[]}=t;o.push({userID:t,followTime:e,...this._handleProfileItem(s)})}),{resultList:o,nextCursor:s}}).catch(t=>(n.setError(t).end(),lt.e(this._n+"._getFollowList failed. error:",t),Tt(t)))}_handleProfileItem(t){const e={};return t.forEach(t=>{switch(t.tag){case D:e.nick=t.value;break;case v:e.gender=t.value;break;case R:e.birthday=t.value;break;case b:e.location=t.value;break;case G:e.selfSignature=t.value;break;case q:e.allowType=t.value;break;case k:e.language=t.value;break;case x:e.avatar=t.value;break;case $:e.messageSettings=t.value;break;case B:e.adminForbidType=t.value;break;case V:e.level=t.value;break;case W:e.role=t.value;break;default:e[t.tag]=t.value}}),e}getUserFollowInfo(t){if(!this.canIUse(u.FOLLOW))return this.noUse("getUserFollowInfo");let e=t,s=!1;J(t)&&(e=[this.getMyUserID()],s=!0);const n=this._n+".getUserFollowInfo",o=`userIDList:${e.length} isGetMyFollowInfo:`+s,i=new Ft("getUserFollowInfo");return i.setMessage(o),lt.l(n+" "+o),this.req({P:Et,data:{fromAccount:this.getMyUserID(),userIDList:e}}).then(t=>{i.end(),lt.l(n+" ok.");const{followInfoList:e=[]}=t.data,o=[];return e.forEach(t=>{var{followersCount:t,followingCount:e,mutualFollowersCount:s}=t;o.push({followersCount:t,followingCount:e,mutualFollowersCount:s})}),ct(o)}).catch(t=>(i.setError(t).end(),lt.e(n+" failed. error:",t),Tt(t)))}checkFollowType(t){if(!this.canIUse(u.FOLLOW))return this.noUse("checkFollowType");100<t.length&&(t=t.slice(0,100),lt.w(o+" "+"the length of userIDList cannot exceed 100"));const o=this._n+".checkFollowType",e=`userIDList length:${t.length} `,n=new Ft("checkFollowType");return n.setMessage(e),lt.l(o+" "+e),this.req({P:Mt,data:{fromAccount:this.getMyUserID(),userIDList:t}}).then(t=>{n.end(),lt.l(o+" ok.");const{resultList:e=[]}=t.data,s=[];return e.forEach(t=>{var{userID:t,followType:e}=t;s.push({userID:t,followType:e})}),ct(s)}).catch(t=>(n.setError(t).end(),lt.e(o+" failed. error:",t),Tt(t)))}_clearFollowList(t){if(J(t))return this._myFollowersList.clear(),this._myFollowingList.clear(),void this._myMutualFollowersList.clear();t!==Pt.FOLLOWERS?t!==Pt.FOLLOWING?t!==Pt.MUTUAL||this._myMutualFollowersList.clear():this._myFollowingList.clear():this._myFollowersList.clear()}reset(){lt.l(this._n+".reset"),this._clearFollowList()}}export{Nt as default};