easemob-websdk 4.2.1 → 4.3.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.
@@ -218,7 +218,7 @@ export interface Contact {
218
218
  addUsersToBlocklist(options: {
219
219
  /** The user ID. You can type a specific user ID to add a single user to the blocklist or type an array of user IDs, like ["user1","user2"], to add multiple users. */
220
220
  name: UserId | UserId[];
221
- }): Promise<void>;
221
+ }): Promise<AsyncResult<IndexTypes.OperateResult>>;
222
222
 
223
223
  /**
224
224
  *
@@ -438,6 +438,47 @@ export interface Contact {
438
438
  */
439
439
  isPinned: boolean;
440
440
  }): Promise<AsyncResult<IndexTypes.PinConversation>>;
441
+
442
+ /**
443
+ * Set contact remark.
444
+ *
445
+ * ```typescript
446
+ * setContactRemark({userId: 'userId', remark: 'remark'})
447
+ * ```
448
+ */
449
+ setContactRemark(params: {
450
+ /**
451
+ * The ID of the contact to set the remark for.
452
+ */
453
+ userId: UserId;
454
+ /**
455
+ * The remark to set.
456
+ */
457
+ remark: string;
458
+ }): Promise<void>;
459
+
460
+ /**
461
+ * Gets the all contacts.
462
+ *
463
+ * ```typescript
464
+ * connection.getAllContacts()
465
+ * ```
466
+ */
467
+ getAllContacts(): Promise<AsyncResult<IndexTypes.ContactItem[]>>;
468
+
469
+ /**
470
+ * Gets the list of contacts with pagination.
471
+ *
472
+ * ```typescript
473
+ * connection.getContactsWithCursor({pageSize:50, cursor: ''})
474
+ * ```
475
+ */
476
+ getContactsWithCursor(params: {
477
+ /** The number of contacts that you expect to get on each page. The value range is [1,50] and the default value is `20`. */
478
+ pageSize?: number;
479
+ /** The position from which to start getting data. */
480
+ cursor?: string;
481
+ }): Promise<AsyncResult<IndexTypes.CursorContactsResult>>;
441
482
  }
442
483
 
443
484
  export { IndexTypes, ReactionTypes, AsyncResult, UserId, MessageType };
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.websdk=t():e.websdk=t()}(this,(function(){return(this.webpackChunkwebsdk=this.webpackChunkwebsdk||[]).push([[564],{7479:function(e,t,r){r.r(t),r.d(t,{acceptContactInvite:function(){return G},acceptInvitation:function(){return X},addContact:function(){return B},addReaction:function(){return $},addToBlackList:function(){return H},addUsersToBlacklist:function(){return K},addUsersToBlocklist:function(){return D},declineContactInvite:function(){return q},declineInvitation:function(){return J},deleteContact:function(){return L},deleteConversation:function(){return N},deleteReaction:function(){return ee},deleteSession:function(){return j},fetchHistoryMessages:function(){return M},fetchUserInfoById:function(){return P},getBlacklist:function(){return S},getBlocklist:function(){return I},getChatToken:function(){return U},getContacts:function(){return k},getConversationlist:function(){return A},getHistoryMessages:function(){return x},getReactionDetail:function(){return ae},getReactionList:function(){return te},getReactionlist:function(){return re},getRoster:function(){return E},getServerConversations:function(){return se},getServerPinnedConversations:function(){return ce},getSessionList:function(){return b},modifyMessage:function(){return Y},pinConversation:function(){return ue},recallMessage:function(){return V},removeFromBlackList:function(){return F},removeHistoryMessages:function(){return oe},removeRoster:function(){return z},removeUserFromBlackList:function(){return W},removeUserFromBlocklist:function(){return Q},reportMessage:function(){return ne},updateCurrentUserNick:function(){return O},updateOwnUserInfo:function(){return R},updateUserInfo:function(){return w},uploadPushToken:function(){return C},uploadToken:function(){return _}}),r(9601),r(1539),r(8674),r(2526),r(1817),r(2165),r(6992),r(8783),r(3948),r(9554),r(4747),r(2222),r(7941),r(6699),r(3710),r(9714),r(9600),r(5069),r(561),r(9753),r(8309),r(1249);var a=r(3246),n=r(5531),o=r(7252),s=r(4370),i=r(8161),c=r(4968),u=r(4188),l=r.n(u),p=r(7360),d=r(1595),h=r(4363),f=r(7288),g=r(9743),m=function(){return m=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},m.apply(this,arguments)},y=function(e,t,r,a){return new(r||(r=Promise))((function(n,o){function s(e){try{c(a.next(e))}catch(e){o(e)}}function i(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,i)}c((a=a.apply(e,t||[])).next())}))},v=function(e,t){var r,a,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,a&&(n=2&o[0]?a.return:o[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,o[1])).done)return n;switch(a=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,a=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],a=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}},T={chat:"singleChat",chatroom:"chatRoom",groupchat:"groupChat",singleChat:"singleChat",chatRoom:"chatRoom",groupChat:"groupChat"};function S(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l={url:this.apiUrl+"/"+i+"/"+c+"/users/"+this.user+"/blocks/users",dataType:"json",type:"GET",headers:{Authorization:"Bearer "+u},success:function(t){var r={};t.data.forEach((function(e){r[e]={name:e}})),"function"==typeof(null==e?void 0:e.success)&&e.success(t)},error:function(t){"function"==typeof(null==e?void 0:e.error)&&e.error(t)}};return p.kg.debug("Call getBlocklist"),s.hj.call(this,l,d.fI.GET_BLACK_LIST)}var I=S,E=k;function k(e){var t=this;if(!a.XZ.call(this)){var r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(r)}var i=this.context,c=i.orgName,u=i.appName,l=i.accessToken,h={url:this.apiUrl+"/"+c+"/"+u+"/users/"+this.user+"/contacts/users",dataType:"json",type:"GET",headers:{Authorization:"Bearer "+l},success:function(r){var a=[];r.data.forEach((function(e){a.push({name:e,subscription:"both",jid:t.context.jid})})),"function"==typeof(null==e?void 0:e.success)&&e.success(a)},error:function(t){"function"==typeof(null==e?void 0:e.error)&&e.error(t)}};return p.kg.debug("Call getContacts"),s.hj.call(this,h,d.fI.GET_CONTACTS)}function _(e){if("string"!=typeof e.deviceId||""===e.deviceId)throw Error('Invalid parameter: "deviceId"');if("string"!=typeof e.deviceToken||""===e.deviceToken)throw Error('Invalid parameter: "deviceToken"');if("string"!=typeof e.notifierName||""===e.notifierName)throw Error('Invalid parameter: "notifierName"');if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user),type:"PUT",data:JSON.stringify({device_id:e.deviceId,device_token:e.deviceToken,notifier_name:e.notifierName}),dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"},success:e.success,error:e.error};return p.kg.debug("Call uploadPushToken",e),s.hj.call(this,l,d.fI.UPLOAD_PUSH_TOKEN)}var C=_;function b(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user,"/user_channels"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"},success:e&&(null==e?void 0:e.success),error:e&&(null==e?void 0:e.error)};return p.kg.debug("Call getSessionList"),s.hj.call(this,l,d.fI.GET_SESSION_LIST)}function A(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l=!!(e&&"number"==typeof e.pageNum&&"number"==typeof e.pageSize&&e.pageNum>0&&e.pageSize>0),f={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user,"/user_channels").concat(l?"/page":""),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"},success:e&&(null==e?void 0:e.success),error:e&&(null==e?void 0:e.error)};return l&&(f.data={pageNum:e.pageNum,pageSize:e.pageSize}),p.kg.debug("Call getConversationlist"),s.hj.call(this,f,d.fI.GET_SESSION_LIST).then((function(e){return function(e){var t=e.data.channel_infos;return null==t||t.forEach((function(e){e.meta&&"{}"!==JSON.stringify(e.meta)?(e.meta.payload=JSON.parse(e.meta.payload),e.lastMessage=(0,h.w)(e.meta)):e.lastMessage=e.meta,delete e.meta})),e}(e)}))}function j(e){if(e&&"string"!=typeof e.channel)throw Error("Invalid parameter channel: ".concat(e.channel));if(e&&"singleChat"!==e.chatType&&"groupChat"!==e.chatType)throw Error("Invalid parameter chatType: ".concat(e.chatType));if(e&&"boolean"!=typeof e.deleteRoam)throw Error("Invalid parameter deleteRoam: ".concat(e.deleteRoam));if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r,i=this.context,c=i.orgName,u=i.appName,l=i.accessToken,h=i.jid;r="singleChat"===e.chatType?"chat":"groupChat";var f={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/user/").concat(this.user,"/user_channel?resource=").concat(h.clientResource),dataType:"json",type:"DELETE",data:JSON.stringify({channel:e.channel,type:r,delete_roam:e.deleteRoam}),headers:{Authorization:"Bearer "+l,"Content-Type":"application/json"},success:e.success,error:e.error};return p.kg.debug("Call deleteSession",e),s.hj.call(this,f,d.fI.DELETE_SESSION)}var N=j;function R(e,t){if(!a.XZ.call(this)){var r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(r)}var i=this.context,c=i.orgName,u=i.appName,l=i.accessToken,h=["nickname","avatarurl","mail","phone","gender","sign","birth","ext"],f={};if("undefined"!=typeof wx||"undefined"!=typeof qq)if("string"==typeof e&&void 0!==t){if(!h.includes(e))throw new Error("illegal key, only these keys: nickname, avatarurl, mail, phone, gender, sign, birth, ext are allowed");f[e]=t}else{if("[object Object]"!==Object.prototype.toString.call(e))throw new Error("illegal params");h.forEach((function(t){h.includes(t)&&void 0!==e[t]&&(f[t]=e[t])}))}else if("string"==typeof e){if(!h.includes(e))throw new Error("illegal key, only these keys: nickname, avatarurl, mail, phone, gender, sign, birth, ext are allowed");f=e+"="+t}else{if("[object Object]"!==Object.prototype.toString.call(e))throw new Error("illegal params");var g=[];h.forEach((function(t){if(h.includes(t)&&void 0!==e[t]){var r=encodeURIComponent(t),a=encodeURIComponent(e[t]);g.push(r+"="+a)}})),f=g.join("&")}var m={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/metadata/user/").concat(this.user),type:"PUT",data:f,dataType:"json",headers:{Authorization:"Bearer "+l,"Content-Type":"application/x-www-form-urlencoded"}};return p.kg.debug("Call updateOwnUserInfo",e),s.hj.call(this,m,d.fI.UPDATE_USER_INFO)}var w=R;function P(e,t){if(!a.XZ.call(this)){var r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(r)}var i,c=this.context,u=c.orgName,l=c.appName,h=c.accessToken,f=[];if("string"==typeof e)f=[e];else{if("[object Array]"!==Object.prototype.toString.call(e))throw new Error("illegal params");f=e}i="string"==typeof t?[t]:t&&"[object Array]"===Object.prototype.toString.call(t)?t:["nickname","avatarurl","mail","phone","gender","sign","birth","ext"];var g={url:"".concat(this.apiUrl,"/").concat(u,"/").concat(l,"/metadata/user/get"),type:"POST",data:JSON.stringify({targets:f,properties:i}),dataType:"json",headers:{Authorization:"Bearer "+h,"Content-Type":"application/json"}};return p.kg.debug("Call fetchUserInfoById",e),s.hj.call(this,g,d.fI.GET_USER_INFO)}function O(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user),type:"PUT",dataType:"json",data:JSON.stringify({nickname:e}),headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}};return p.kg.debug("Call updateCurrentUserNick",e),s.hj.call(this,l)}function U(e){if("string"!=typeof e||""===e)throw Error('Invalid parameter: "agoraToken"');var t=this.context,r=t.orgName,a=t.appName,n={url:this.apiUrl+"/"+r+"/"+a+"/token",dataType:"json",type:"POST",data:JSON.stringify({grant_type:"agora"}),headers:{Authorization:"Bearer "+e,"Content-Type":"application/json"}};return p.kg.debug("Call getChatToken",e),s.hj.call(this,n,d.fI.SDK_INTERNAL)}function M(e){var t=this;return new Promise((function(r,s){if(!e.queue)throw Error('Invalid parameter: "specified"');if(!a.XZ.call(t)){var i=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(i)}(function e(t){var a=this,n=t.count||20;Z.call(this,{count:n,isGroup:!!t.isGroup,queue:t.queue,start:t.start,format:t.format,success:function(o){if(o.msgs.length>=n||o.is_last){var s=o.msgs.splice(0,n).reverse();t.success&&t.success(s),r(s)}else e.call(a,m(m({},t),{start:null}))},fail:function(e){s(e),t.fail&&t.fail(e)}})}).call(t,e),p.kg.debug("Call fetchHistoryMessages",e)}))}function Z(e){var t=this,r=e.queue,a=this.mr_cache[r]||(this.mr_cache[r]={msgs:[]}),c=this.context.userId,u=e.start||-1,p=e.count||20;if(a.msgs.length>=p||a.is_last)"function"==typeof e.success&&e.success(a);else{a&&a.next_key&&(u=a.next_key),e.start&&(u=e.start);var h={queue:r+(e.isGroup?"@conference.easemob.com":"@easemob.com"),start:u,end:-1},f=this.context,g=f.orgName,m=f.appName,T={url:"".concat(this.apiUrl,"/").concat(g,"/").concat(m,"/users/").concat(c,"/messageroaming"),dataType:"json",type:"POST",headers:{Authorization:"Bearer "+this.token,"Content-Type":"application/json"},data:JSON.stringify(h),success:function(r){return y(t,void 0,void 0,(function(){var t,n,o,s,c,u,p=this;return v(this,(function(d){switch(d.label){case 0:if(t=null==r?void 0:r.data,!r.data.msgs)return"function"==typeof e.success&&e.success(a),a.is_last=!0,a.next_key="",[2];n=t.msgs,o=n.length,a.is_last=t.is_last,a.next_key=t.next_key,s=function(t){return y(p,void 0,void 0,(function(){var r,a,n,o,s;return v(this,(function(c){switch(c.label){case 0:for(r=[],t=l().atob(t),a=0,n=t.length;a<n;++a)r.push(t.charCodeAt(a));return o=(o=this.context.root.lookup("easemob.pb.Meta")).decode(r),s={errorCode:0,reason:""},1!==o.ns?[3,2]:[4,i.Z.call(this,o,s,!0,e.format)];case 1:return[2,c.sent()];case 2:return[2]}}))}))},c=0,d.label=1;case 1:return c<o?[4,s(n[c].msg)]:[3,4];case 2:(u=d.sent())&&a.msgs.push(u),d.label=3;case 3:return c++,[3,1];case 4:return"function"==typeof e.success&&e.success(a),[2]}}))}))},error:function(e){if(e.error&&e.error_description){var r=o.Z.create({type:n.E.WEBIM_CONNCTION_AJAX_ERROR,message:"fetch history messages error",data:e});t.onError&&t.onError(r)}}};s.hj.call(this,T,d.fI.GET_HISTORY_MSG).catch((function(t){"function"==typeof e.fail&&e.fail(t)}))}}function x(e){var t=this;return new Promise((function(r,c){var u=e.targetId,d=e.cursor,h=void 0===d?-1:d,f=e.pageSize,g=void 0===f?20:f,m=e.chatType,T=e.searchDirection,S=e.searchOptions,I=void 0===S?{}:S,E=I.msgTypes,k=void 0===E?[]:E,_=I.startTime,C=void 0===_?null:_,b=I.endTime,A=void 0===b?null:b,j=I.from,N=void 0===j?null:j;if("string"!=typeof u||""===u)throw Error('"Invalid parameter": "targetId"');if(N&&"string"!=typeof N)throw Error('"Invalid parameter": "searchOptions.from"');if(k&&!Array.isArray(k))throw Error('"Invalid parameter": "searchOptions.msgTypes"');if(C&&"number"!=typeof C)throw Error('"Invalid parameter": "searchOptions.startTime"');if(A&&"number"!=typeof C)throw Error('"Invalid parameter": "searchOptions.endTime"');if(!a.XZ.call(t)){var R=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return c(R)}var w=t.context,P=w.orgName,O=w.appName,U=w.userId,M="groupChat"===e.chatType?"@conference.easemob.com":"@easemob.com",Z={queue:"".concat(u).concat(M),start:h,pull_number:g,is_positive:"down"===T,msgType:k.join(",")||"",end:-1,startTime:C,endTime:A,userId:"singleChat"===m?null:N},x={url:"".concat(t.apiUrl,"/").concat(P,"/").concat(O,"/users/").concat(U,"/messageroaming"),dataType:"json",type:"POST",headers:{Authorization:"Bearer "+t.token,"Content-Type":"application/json"},data:JSON.stringify(Z),success:function(a){return y(t,void 0,void 0,(function(){var t,n,o,s,c,u,p,d,h=this;return v(this,(function(f){switch(f.label){case 0:t=null==a?void 0:a.data,n=t.msgs||[],o=function(e){return y(h,void 0,void 0,(function(){var t,r,a,n,o;return v(this,(function(s){switch(s.label){case 0:for(t=[],e=l().atob(e),r=0,a=e.length;r<a;++r)t.push(e.charCodeAt(r));return n=(n=this.context.root.lookup("easemob.pb.Meta")).decode(t),o={errorCode:0,reason:""},1!==n.ns?[3,2]:[4,i.Z.call(this,n,o,!0,!0)];case 1:return[2,s.sent()];case 2:return[2]}}))}))},s=[],c=0,f.label=1;case 1:return c<n.length?[4,o(n[c].msg)]:[3,4];case 2:(u=f.sent())&&s.push(u),f.label=3;case 3:return c++,[3,1];case 4:return t.msgs=s,p={cursor:t.next_key,messages:s,isLast:t.is_last},null===(d=e.success)||void 0===d||d.call(e,p),r(p),[2]}}))}))},error:e.fail};s.hj.call(t,x).catch((function(e){c(e)})),p.kg.debug("Call getHistoryMessages",e)}))}function B(e,t){var r=this;return new Promise((function(a,n){var o={id:r.getUniqueId(),to:e,message:t};c.Z.operatRoster.call(r,o,"add",a,n),p.kg.debug("Call addContact",o)}))}var z=L;function L(e){var t=this;return new Promise((function(r,a){var n={id:t.getUniqueId(),to:e};c.Z.operatRoster.call(t,n,"remove",r,a),p.kg.debug("Call deleteContact",n)}))}function X(e){var t=this;return new Promise((function(r,a){var n={id:t.getUniqueId(),to:e};c.Z.operatRoster.call(t,n,"accept",r,a),p.kg.debug("Call acceptInvitation",n)}))}var G=X;function J(e){var t=this;return new Promise((function(r,a){var n={id:t.getUniqueId(),to:e};c.Z.operatRoster.call(t,n,"decline",r,a),p.kg.debug("Call declineContactInvite",n)}))}var q=J;function H(e){var t=this;return new Promise((function(r,a){c.Z.operatRoster.call(t,{to:e.name},"ban",r,a),p.kg.debug("Call addUsersToBlocklist",e)}))}var K=H,D=H;function F(e){var t=this;return new Promise((function(r,a){c.Z.operatRoster.call(t,{to:e.name},"allow",r,a),p.kg.debug("Call removeUserFromBlocklist",e)}))}var W=F,Q=F;function V(e){var t=this,r=this.getUniqueId(),a={id:r,to:e.to};this._msgHash[r]=m({},a);var n="";void 0!==e.chatType?n=e.chatType:void 0!==e.type&&(n="chat"===e.type?"singleChat":e.type);var o={id:r,type:"recall",chatType:n,ackId:e.mid,to:e.to,isChatThread:e.isChatThread||!1,success:function(r){return y(t,void 0,void 0,(function(){var t,a,o,s,i,c,u,l,p;return v(this,(function(d){switch(d.label){case 0:return d.trys.push([0,5,,6]),"singleChat"!==n&&"groupChat"!==n?[3,4]:[4,null===(o=null===(a=this._localCache)||void 0===a?void 0:a.getInstance())||void 0===o?void 0:o.removeMsgByServerMsgId(e.mid)];case 1:return d.sent(),[4,null===(i=null===(s=this._localCache)||void 0===s?void 0:s.getInstance())||void 0===i?void 0:i.getConversationLastMessage(e.to,n)];case 2:return t=d.sent(),[4,null===(u=null===(c=this._localCache)||void 0===c?void 0:c.getInstance())||void 0===u?void 0:u.updateLocalConversation((0,g.MQ)({conversationId:e.to,conversationType:n}),{lastMessageId:null==t?void 0:t.serverMsgId})];case 3:d.sent(),d.label=4;case 4:return null===(l=null==e?void 0:e.success)||void 0===l||l.call(e,r),[3,6];case 5:return d.sent(),null===(p=null==e?void 0:e.success)||void 0===p||p.call(e,r),[3,6];case 6:return[2]}}))}))},fail:e.fail};return p.kg.debug("Call recallMessage",e),this.mSync.send(o,this)}function Y(e){var t=e||{},r=t.messageId,a=t.modifiedMessage;if(p.kg.debug("Call modifyMessage",r,a),""===r)throw Error('Invalid parameter: "messageId"');if("txt"!==a.type)throw Error('Invalid parameter: "modifiedMessage.type"');return this.mSync.send(m({editMessageId:r},a))}function $(e){return y(this,void 0,void 0,(function(){var t,r,i,c,u,l,p,d,h;return v(this,(function(f){switch(f.label){case 0:if("string"!=typeof e.messageId||!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if("string"!=typeof e.reaction||!e.reaction)throw Error("Invalid parameter reaction: ".concat(e.reaction));return a.XZ.call(this)?(r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l=e.reaction,p=e.messageId,d={msgId:p,message:l},h={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/reaction/user/").concat(this.user),type:"POST",data:JSON.stringify(d),dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.hj.call(this,h)]):(t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)]);case 1:return f.sent(),[2]}}))}))}function ee(e){return y(this,void 0,void 0,(function(){var t,r,i,c,u,l,p,d;return v(this,(function(h){switch(h.label){case 0:if("string"!=typeof e.reaction||!e.reaction)throw Error("Invalid parameter reactionId: ".concat(e.reaction));return a.XZ.call(this)?(r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l=e.messageId,p=e.reaction,d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/reaction/user/").concat(this.user,"?msgId=").concat(l,"&message=").concat(p),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.hj.call(this,d)]):(t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)]);case 1:return h.sent(),[2]}}))}))}function te(e){if("string"!=typeof e.chatType||!e.chatType)throw Error("Invalid parameter chatType: ".concat(e.chatType));if(!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l=e.chatType,p=e.messageId,d={msgIdList:"string"==typeof p?[p]:p,msgType:"singleChat"===l?"chat":"groupchat",groupId:e.groupId||null},h={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/reaction/user/").concat(this.user),type:"GET",data:d,dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}};return s.hj.call(this,h).then((function(e){var t=e.data;return null==t||t.forEach((function(e){null==e||e.reactionList.forEach((function(e){e.isAddedBySelf=e.state,delete e.state,delete e.reactionId}))})),e}))}var re=te;function ae(e){if("string"!=typeof e.reaction||!e.reaction)throw Error("Invalid parameter reaction: ".concat(e.reaction));if("string"!=typeof e.messageId||!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l=e.cursor,p=e.pageSize,d={msgId:e.messageId,message:e.reaction,currentPage:l||null,pageSize:p||20},h={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/reaction/user/").concat(this.user,"/detail"),type:"GET",data:d,dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}};return s.hj.call(this,h).then((function(e){return e.data.isAddedBySelf=e.data.state,delete e.data.state,delete e.data.reactionId,e}))}function ne(e){return y(this,void 0,void 0,(function(){var t,r,i,c,u,l,p,d,h,f,g;return v(this,(function(m){switch(m.label){case 0:if("string"!=typeof e.reportType||!e.reportType)throw Error("Invalid parameter reportType: ".concat(e.reportType));if("string"!=typeof e.messageId||!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if("string"!=typeof e.reportReason||!e.reportReason)throw Error("Invalid parameter messageId: ".concat(e.reportReason));return a.XZ.call(this)?(r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l=e.reportType,p=e.reportReason,d=e.messageId,h={username:this.user,reportType:l,reportReason:p},f="".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/user/").concat(this.user,"/moderation/report/message/").concat(d),g={url:f,type:"POST",data:JSON.stringify(h),dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.hj.call(this,g)]):(t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)]);case 1:return m.sent(),[2]}}))}))}function oe(e){var t;return y(this,void 0,void 0,(function(){var r,i,c,u,l,d,h,f,g;return v(this,(function(m){switch(m.label){case 0:if("string"!=typeof e.targetId||""===e.targetId)throw Error('"Invalid parameter targetId": '+e.targetId);if(!["singleChat","groupChat"].includes(e.chatType))throw Error('"Invalid parameter chatType": '+e.chatType);if(e.beforeTimeStamp&&("number"!=typeof e.beforeTimeStamp||e.beforeTimeStamp<0||(null===(t=e.beforeTimeStamp)||void 0===t?void 0:t.toString().length)>18))throw Error('"Invalid parameter beforeTimeStamp": '+e.beforeTimeStamp);if(e.messageIds&&!(Array.isArray(e.messageIds)&&e.messageIds.length>0&&e.messageIds.length<=20))throw Error('"Invalid parameter messageIds": '+e.messageIds);if(!e.messageIds&&!e.beforeTimeStamp)throw Error("messageIds or beforeTimeStamp field is required.");return a.XZ.call(this)?(i=this.context,c=i.orgName,u=i.appName,l=i.userId,d="singleChat"===e.chatType?"userId":"groupId",h="singleChat"===e.chatType?"chat":"group",f=e.messageIds?"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/sdk/message/roaming/").concat(h,"/user/").concat(l,"?").concat(d,"=").concat(e.targetId,"&msgIdList=").concat(e.messageIds,"&resource=").concat(this.clientResource):"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/sdk/message/roaming/").concat(h,"/user/").concat(l,"/time?").concat(d,"=").concat(e.targetId,"&delTime=").concat(e.beforeTimeStamp,"&&resource=").concat(this.clientResource),g={url:f,dataType:"json",type:"DELETE",headers:{Authorization:"Bearer "+this.token,"Content-Type":"application/json"}},p.kg.debug("Call removeHistoryMessages",e),[4,s.hj.call(this,g)]):(r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(r)]);case 1:return m.sent(),[2]}}))}))}function se(e){var t=this;if(!a.XZ.call(this)){var r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(r)}if((null==e?void 0:e.pageSize)&&"number"!=typeof e.pageSize)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));if((null==e?void 0:e.cursor)&&"string"!=typeof e.cursor)throw Error("Invalid parameter cursor: ".concat(e.cursor));var i=this.context,c=i.orgName,u=i.appName,l=i.accessToken,h={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/sdk/user/").concat(this.user,"/user_channels/list?"),type:"GET",dataType:"json",data:{limit:(null==e?void 0:e.pageSize)||20,cursor:(null==e?void 0:e.cursor)||""},headers:{Authorization:"Bearer "+l,"Content-Type":"application/json"}};return p.kg.debug("Call getServerConversations",e),new Promise((function(e,r){s.hj.call(t,h,d.fI.GET_SESSION_LIST).then((function(r){return y(t,void 0,void 0,(function(){var t,a=this;return v(this,(function(n){switch(n.label){case 0:return t=ie(r),this._localCache?[4,Promise.all(t.data.conversations.map((function(e){return y(a,void 0,void 0,(function(){var t,r,a=this;return v(this,(function(n){return null===(r=null===(t=this._localCache)||void 0===t?void 0:t.getInstance())||void 0===r||r.storeMessage(e.lastMessage,f.r.SUCCESS,!0).then((function(){var t,r;null===(r=null===(t=a._localCache)||void 0===t?void 0:t.getInstance())||void 0===r||r.updateLocalConversation((0,g.MQ)({conversationId:e.conversationId,conversationType:e.conversationType}),{unReadCount:e.unReadCount})})),[2]}))}))})))]:[3,2];case 1:return n.sent(),e(t),[2];case 2:return e(t),[2]}}))}))})).catch((function(e){r(e)}))}))}function ie(e){var t=e.data,r=t.cursor,a=t.channel_infos,n=[];null==a||a.forEach((function(e){var t=null;(null==e?void 0:e.meta)&&"{}"!==JSON.stringify(e.meta)&&(e.meta.payload=JSON.parse(e.meta.payload),"delivery"!==(t=(0,h.w)(e.meta)).type&&"read"!==t.type&&"channel"!==t.type&&(t.chatType=T[t.chatType]));var r={conversationId:e.session_to,conversationType:"chat"===e.session_type?"singleChat":"groupChat",isPinned:e.is_top,pinnedTime:e.is_top?e.update_top_status_time:0,unReadCount:e.unread_num,lastMessage:t};n.push(r)}));var o={conversations:n,cursor:r||""};return{type:e.type,data:o}}function ce(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}if((null==e?void 0:e.pageSize)&&"number"!=typeof e.pageSize)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));if((null==e?void 0:e.cursor)&&"string"!=typeof e.cursor)throw Error("Invalid parameter cursor: ".concat(e.cursor));var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/sdk/user/").concat(this.user,"/user_channels/list?"),type:"GET",dataType:"json",data:{limit:(null==e?void 0:e.pageSize)||20,cursor:(null==e?void 0:e.cursor)||"",is_top:!0},headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}};return p.kg.debug("Call getServerConversations",e),s.hj.call(this,l,d.fI.GET_SESSION_LIST).then((function(e){return ie(e)}))}function ue(e){return y(this,void 0,void 0,(function(){var t,r,i,c,u,l,h,f,g,m,y,T,S,I;return v(this,(function(v){if(!a.XZ.call(this))return t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)];if(r=e.conversationId,i=e.conversationType,c=e.isPinned,u="singleChat"===i?"chat":"groupChat","string"!=typeof r||""===r)throw Error("Invalid parameter conversationId: ".concat(r));if(!["singleChat","groupChat"].includes(i))throw Error("Invalid parameter conversationType: ".concat(i));if("boolean"!=typeof c)throw Error("Invalid parameter isPinned: ".concat(c));return l=this.context,h=l.orgName,f=l.appName,g=l.accessToken,m=l.jid,y={type:u,to:r},T=c?"":"type=".concat(u,"&to=").concat(r,"&"),S="".concat(this.apiUrl,"/").concat(h,"/").concat(f,"/sdk/user/").concat(this.user,"/user_channel/top?").concat(T,"resource=").concat(m.clientResource),I={url:S,type:c?"POST":"DELETE",dataType:"json",headers:{Authorization:"Bearer "+g,"Content-Type":"application/json"}},c&&(I.data=JSON.stringify(y)),p.kg.debug("Call pinConversation",e),[2,s.hj.call(this,I,d.fI.PIN_CONVERSATION).then((function(e){var t=e.type,r=e.data;return{type:t,data:{isPinned:r.is_top||!1,pinnedTime:r.is_top?r.update_top_status_time:0}}}))]}))}))}},3246:function(e,t,r){r.d(t,{H7:function(){return u},XZ:function(){return i},_W:function(){return c}}),r(7941),r(9554),r(1539),r(4747),r(6699),r(2023);var a=r(5531),n=r(7252);function o(){var e=this.context.appName,t=this.context.orgName;return!(!e||!t)||(this.onError&&this.onError({type:a.E.WEBIM_CONNCTION_AUTH_ERROR,message:"appName or orgName is illegal"}),!1)}function s(){var e;if(!this.context.accessToken){var t=n.Z.create({type:a.E.WEBIM_CONNCTION_TOKEN_NOT_ASSIGN_ERROR,message:"token not assign error"});return this.onError&&this.onError(t),null===(e=this.eventHandler)||void 0===e||e.dispatch("onError",t),!1}return!0}function i(){return s.call(this)&&o.call(this)}function c(e){var t=e.data,r=e.type;return{data:{status:Object.keys(t.errorKeys).length>0?"fail":"success",errorKeys:t.errorKeys,successKeys:t.successKeys},type:r}}function u(e){var t=e.data,r=void 0;return Object.keys(t.errorKeys).length>0&&Object.keys(t.errorKeys).forEach((function(e){var o=t.errorKeys[e];r=o.includes("is not part of you")?n.Z.create({type:a.E.NO_PERMISSION,message:o}):o.includes("size of metadata for this single chatroom exceeds the user defined limit")||o.includes("total size of chatroom metadata for this app exceeds the user defined limit")||o.includes("is exceeding maximum limit")?n.Z.create({type:a.E.MAX_LIMIT,message:o}):o.includes("is not Legal")?n.Z.create({type:a.E.REQUEST_PARAMETER_ERROR,message:o}):o.includes("Failed to update userMetadata. Concurrent updates not allowed")?n.Z.create({type:a.E.OPERATION_NOT_ALLOWED,message:o}):n.Z.create({type:a.E.WEBIM_CONNCTION_AJAX_ERROR,message:o})})),r}},5069:function(e,t,r){var a=r(2109),n=r(1702),o=r(3157),s=n([].reverse),i=[1,2];a({target:"Array",proto:!0,forced:String(i)===String(i.reverse())},{reverse:function(){return o(this)&&(this.length=this.length),s(this)}})}},function(e){return 7479,e(e.s=7479)}])}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.websdk=t():e.websdk=t()}(this,(function(){return(this.webpackChunkwebsdk=this.webpackChunkwebsdk||[]).push([[564],{7479:function(e,t,r){r.r(t),r.d(t,{acceptContactInvite:function(){return X},acceptInvitation:function(){return L},addContact:function(){return x},addReaction:function(){return Y},addToBlackList:function(){return D},addUsersToBlacklist:function(){return K},addUsersToBlocklist:function(){return H},declineContactInvite:function(){return J},declineInvitation:function(){return G},deleteContact:function(){return z},deleteConversation:function(){return j},deleteReaction:function(){return $},deleteSession:function(){return R},fetchHistoryMessages:function(){return U},fetchUserInfoById:function(){return w},getAllContacts:function(){return le},getBlacklist:function(){return T},getBlocklist:function(){return S},getContacts:function(){return I},getContactsWithCursor:function(){return pe},getConversationlist:function(){return C},getHistoryMessages:function(){return Z},getReactionDetail:function(){return re},getReactionList:function(){return ee},getReactionlist:function(){return te},getRoster:function(){return E},getServerConversations:function(){return oe},getServerPinnedConversations:function(){return ie},getSessionList:function(){return A},getTokenExpireTimestamp:function(){return P},modifyMessage:function(){return V},pinConversation:function(){return ce},recallMessage:function(){return Q},removeFromBlackList:function(){return q},removeHistoryMessages:function(){return ne},removeRoster:function(){return B},removeUserFromBlackList:function(){return W},removeUserFromBlocklist:function(){return F},reportMessage:function(){return ae},setContactRemark:function(){return ue},updateCurrentUserNick:function(){return O},updateOwnUserInfo:function(){return N},updateUserInfo:function(){return b},uploadPushToken:function(){return _},uploadToken:function(){return k}}),r(9601),r(1539),r(8674),r(2526),r(1817),r(2165),r(6992),r(8783),r(3948),r(9554),r(4747),r(2222),r(7941),r(6699),r(3710),r(9714),r(9600),r(5069),r(561),r(9753),r(8309),r(1249);var a=r(3246),n=r(5531),o=r(7252),s=r(4370),i=r(8161),c=r(4188),u=r.n(c),l=r(7360),p=r(1595),h=r(4363),d=r(7288),f=r(9743),m=function(){return m=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},m.apply(this,arguments)},g=function(e,t,r,a){return new(r||(r=Promise))((function(n,o){function s(e){try{c(a.next(e))}catch(e){o(e)}}function i(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,i)}c((a=a.apply(e,t||[])).next())}))},y=function(e,t){var r,a,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,a&&(n=2&o[0]?a.return:o[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,o[1])).done)return n;switch(a=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,a=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],a=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}},v={chat:"singleChat",chatroom:"chatRoom",groupchat:"groupChat",singleChat:"singleChat",chatRoom:"chatRoom",groupChat:"groupChat"};function T(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,h={url:this.apiUrl+"/"+i+"/"+c+"/users/"+this.user+"/blocks/users",dataType:"json",type:"GET",headers:{Authorization:"Bearer "+u},success:function(t){var r={};t.data.forEach((function(e){r[e]={name:e}})),"function"==typeof(null==e?void 0:e.success)&&e.success(t)},error:function(t){"function"==typeof(null==e?void 0:e.error)&&e.error(t)}};return l.kg.debug("Call getBlocklist"),s.hj.call(this,h,p.fI.GET_BLACK_LIST)}var S=T,E=I;function I(e){var t=this;if(!a.XZ.call(this)){var r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(r)}var i=this.context,c=i.orgName,u=i.appName,h=i.accessToken,d={url:this.apiUrl+"/"+c+"/"+u+"/users/"+this.user+"/contacts/users",dataType:"json",type:"GET",headers:{Authorization:"Bearer "+h},success:function(r){var a=[];r.data.forEach((function(e){a.push({name:e,subscription:"both",jid:t.context.jid})})),"function"==typeof(null==e?void 0:e.success)&&e.success(a)},error:function(t){"function"==typeof(null==e?void 0:e.error)&&e.error(t)}};return l.kg.debug("Call getContacts"),s.hj.call(this,d,p.fI.GET_CONTACTS)}function k(e){if("string"!=typeof e.deviceId||""===e.deviceId)throw Error('Invalid parameter: "deviceId"');if("string"!=typeof e.deviceToken||""===e.deviceToken)throw Error('Invalid parameter: "deviceToken"');if("string"!=typeof e.notifierName||""===e.notifierName)throw Error('Invalid parameter: "notifierName"');if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,h={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user),type:"PUT",data:JSON.stringify({device_id:e.deviceId,device_token:e.deviceToken,notifier_name:e.notifierName}),dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"},success:e.success,error:e.error};return l.kg.debug("Call uploadPushToken",e),s.hj.call(this,h,p.fI.UPLOAD_PUSH_TOKEN)}var _=k;function A(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,h={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user,"/user_channels"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"},success:e&&(null==e?void 0:e.success),error:e&&(null==e?void 0:e.error)};return l.kg.debug("Call getSessionList"),s.hj.call(this,h,p.fI.GET_SESSION_LIST)}function C(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,d=!!(e&&"number"==typeof e.pageNum&&"number"==typeof e.pageSize&&e.pageNum>0&&e.pageSize>0),f={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user,"/user_channels").concat(d?"/page":""),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"},success:e&&(null==e?void 0:e.success),error:e&&(null==e?void 0:e.error)};return d&&(f.data={pageNum:e.pageNum,pageSize:e.pageSize}),l.kg.debug("Call getConversationlist"),s.hj.call(this,f,p.fI.GET_SESSION_LIST).then((function(e){return function(e){var t=e.data.channel_infos;return null==t||t.forEach((function(e){e.meta&&"{}"!==JSON.stringify(e.meta)?(e.meta.payload=JSON.parse(e.meta.payload),e.lastMessage=(0,h.w)(e.meta)):e.lastMessage=e.meta,delete e.meta})),e}(e)}))}function R(e){if(e&&"string"!=typeof e.channel)throw Error("Invalid parameter channel: ".concat(e.channel));if(e&&"singleChat"!==e.chatType&&"groupChat"!==e.chatType)throw Error("Invalid parameter chatType: ".concat(e.chatType));if(e&&"boolean"!=typeof e.deleteRoam)throw Error("Invalid parameter deleteRoam: ".concat(e.deleteRoam));if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r,i=this.context,c=i.orgName,u=i.appName,h=i.accessToken,d=i.jid;r="singleChat"===e.chatType?"chat":"groupChat";var f={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/user/").concat(this.user,"/user_channel?resource=").concat(d.clientResource),dataType:"json",type:"DELETE",data:JSON.stringify({channel:e.channel,type:r,delete_roam:e.deleteRoam}),headers:{Authorization:"Bearer "+h,"Content-Type":"application/json"},success:e.success,error:e.error};return l.kg.debug("Call deleteSession",e),s.hj.call(this,f,p.fI.DELETE_SESSION)}var j=R;function N(e,t){if(!a.XZ.call(this)){var r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(r)}var i=this.context,c=i.orgName,u=i.appName,h=i.accessToken,d=["nickname","avatarurl","mail","phone","gender","sign","birth","ext"],f={};if("undefined"!=typeof wx||"undefined"!=typeof qq)if("string"==typeof e&&void 0!==t){if(!d.includes(e))throw new Error("illegal key, only these keys: nickname, avatarurl, mail, phone, gender, sign, birth, ext are allowed");f[e]=t}else{if("[object Object]"!==Object.prototype.toString.call(e))throw new Error("illegal params");d.forEach((function(t){d.includes(t)&&void 0!==e[t]&&(f[t]=e[t])}))}else if("string"==typeof e){if(!d.includes(e))throw new Error("illegal key, only these keys: nickname, avatarurl, mail, phone, gender, sign, birth, ext are allowed");f=e+"="+t}else{if("[object Object]"!==Object.prototype.toString.call(e))throw new Error("illegal params");var m=[];d.forEach((function(t){if(d.includes(t)&&void 0!==e[t]){var r=encodeURIComponent(t),a=encodeURIComponent(e[t]);m.push(r+"="+a)}})),f=m.join("&")}var g={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/metadata/user/").concat(this.user),type:"PUT",data:f,dataType:"json",headers:{Authorization:"Bearer "+h,"Content-Type":"application/x-www-form-urlencoded"}};return l.kg.debug("Call updateOwnUserInfo",e),s.hj.call(this,g,p.fI.UPDATE_USER_INFO)}var b=N;function w(e,t){if(!a.XZ.call(this)){var r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(r)}var i,c=this.context,u=c.orgName,h=c.appName,d=c.accessToken,f=[];if("string"==typeof e)f=[e];else{if("[object Array]"!==Object.prototype.toString.call(e))throw new Error("illegal params");f=e}i="string"==typeof t?[t]:t&&"[object Array]"===Object.prototype.toString.call(t)?t:["nickname","avatarurl","mail","phone","gender","sign","birth","ext"];var m={url:"".concat(this.apiUrl,"/").concat(u,"/").concat(h,"/metadata/user/get"),type:"POST",data:JSON.stringify({targets:f,properties:i}),dataType:"json",headers:{Authorization:"Bearer "+d,"Content-Type":"application/json"}};return l.kg.debug("Call fetchUserInfoById",e),s.hj.call(this,m,p.fI.GET_USER_INFO)}function O(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,p={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user),type:"PUT",dataType:"json",data:JSON.stringify({nickname:e}),headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}};return l.kg.debug("Call updateCurrentUserNick",e),s.hj.call(this,p)}function P(e){if("string"!=typeof e||""===e)throw Error('Invalid parameter: "token"');var t=this.context,r=t.orgName,a=t.appName,n={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(a,"/sdk/users/").concat(this.user,"/token/expires"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+e,"Content-Type":"application/json"}};return l.kg.debug("Call getTokenExpireTimestamp",e),s.hj.call(this,n,p.fI.SDK_INTERNAL)}function U(e){var t=this;return new Promise((function(r,s){if(!e.queue)throw Error('Invalid parameter: "specified"');if(!a.XZ.call(t)){var i=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(i)}(function e(t){var a=this,n=t.count||20;M.call(this,{count:n,isGroup:!!t.isGroup,queue:t.queue,start:t.start,format:t.format,success:function(o){if(o.msgs.length>=n||o.is_last){var s=o.msgs.splice(0,n).reverse();t.success&&t.success(s),r(s)}else e.call(a,m(m({},t),{start:null}))},fail:function(e){s(e),t.fail&&t.fail(e)}})}).call(t,e),l.kg.debug("Call fetchHistoryMessages",e)}))}function M(e){var t=this,r=e.queue,a=this.mr_cache[r]||(this.mr_cache[r]={msgs:[]}),c=this.context.userId,l=e.start||-1,h=e.count||20;if(a.msgs.length>=h||a.is_last)"function"==typeof e.success&&e.success(a);else{a&&a.next_key&&(l=a.next_key),e.start&&(l=e.start);var d={queue:r+(e.isGroup?"@conference.easemob.com":"@easemob.com"),start:l,end:-1},f=this.context,m=f.orgName,v=f.appName,T={url:"".concat(this.apiUrl,"/").concat(m,"/").concat(v,"/users/").concat(c,"/messageroaming"),dataType:"json",type:"POST",headers:{Authorization:"Bearer "+this.token,"Content-Type":"application/json"},data:JSON.stringify(d),success:function(r){return g(t,void 0,void 0,(function(){var t,n,o,s,c,l,p=this;return y(this,(function(h){switch(h.label){case 0:if(t=null==r?void 0:r.data,!r.data.msgs)return"function"==typeof e.success&&e.success(a),a.is_last=!0,a.next_key="",[2];n=t.msgs,o=n.length,a.is_last=t.is_last,a.next_key=t.next_key,s=function(t){return g(p,void 0,void 0,(function(){var r,a,n,o,s;return y(this,(function(c){switch(c.label){case 0:for(r=[],t=u().atob(t),a=0,n=t.length;a<n;++a)r.push(t.charCodeAt(a));return o=(o=this.context.root.lookup("easemob.pb.Meta")).decode(r),s={errorCode:0,reason:""},1!==o.ns?[3,2]:[4,i.Z.call(this,o,s,!0,e.format)];case 1:return[2,c.sent()];case 2:return[2]}}))}))},c=0,h.label=1;case 1:return c<o?[4,s(n[c].msg)]:[3,4];case 2:(l=h.sent())&&a.msgs.push(l),h.label=3;case 3:return c++,[3,1];case 4:return"function"==typeof e.success&&e.success(a),[2]}}))}))},error:function(e){if(e.error&&e.error_description){var r=o.Z.create({type:n.E.WEBIM_CONNCTION_AJAX_ERROR,message:"fetch history messages error",data:e});t.onError&&t.onError(r)}}};s.hj.call(this,T,p.fI.GET_HISTORY_MSG).catch((function(t){"function"==typeof e.fail&&e.fail(t)}))}}function Z(e){var t=this;return new Promise((function(r,c){var p=e.targetId,h=e.cursor,d=void 0===h?-1:h,f=e.pageSize,m=void 0===f?20:f,v=e.chatType,T=e.searchDirection,S=e.searchOptions,E=void 0===S?{}:S,I=E.msgTypes,k=void 0===I?[]:I,_=E.startTime,A=void 0===_?null:_,C=E.endTime,R=void 0===C?null:C,j=E.from,N=void 0===j?null:j;if("string"!=typeof p||""===p)throw Error('"Invalid parameter": "targetId"');if(N&&"string"!=typeof N)throw Error('"Invalid parameter": "searchOptions.from"');if(k&&!Array.isArray(k))throw Error('"Invalid parameter": "searchOptions.msgTypes"');if(A&&"number"!=typeof A)throw Error('"Invalid parameter": "searchOptions.startTime"');if(R&&"number"!=typeof A)throw Error('"Invalid parameter": "searchOptions.endTime"');if(!a.XZ.call(t)){var b=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return c(b)}var w=t.context,O=w.orgName,P=w.appName,U=w.userId,M="groupChat"===e.chatType?"@conference.easemob.com":"@easemob.com",Z={queue:"".concat(p).concat(M),start:d,pull_number:m,is_positive:"down"===T,msgType:k.join(",")||"",end:-1,startTime:A,endTime:R,userId:"singleChat"===v?null:N},x={url:"".concat(t.apiUrl,"/").concat(O,"/").concat(P,"/users/").concat(U,"/messageroaming"),dataType:"json",type:"POST",headers:{Authorization:"Bearer "+t.token,"Content-Type":"application/json"},data:JSON.stringify(Z),success:function(a){return g(t,void 0,void 0,(function(){var t,n,o,s,c,l,p,h,d=this;return y(this,(function(f){switch(f.label){case 0:t=null==a?void 0:a.data,n=t.msgs||[],o=function(e){return g(d,void 0,void 0,(function(){var t,r,a,n,o;return y(this,(function(s){switch(s.label){case 0:for(t=[],e=u().atob(e),r=0,a=e.length;r<a;++r)t.push(e.charCodeAt(r));return n=(n=this.context.root.lookup("easemob.pb.Meta")).decode(t),o={errorCode:0,reason:""},1!==n.ns?[3,2]:[4,i.Z.call(this,n,o,!0,!0)];case 1:return[2,s.sent()];case 2:return[2]}}))}))},s=[],c=0,f.label=1;case 1:return c<n.length?[4,o(n[c].msg)]:[3,4];case 2:(l=f.sent())&&s.push(l),f.label=3;case 3:return c++,[3,1];case 4:return t.msgs=s,p={cursor:t.next_key,messages:s,isLast:t.is_last},null===(h=e.success)||void 0===h||h.call(e,p),r(p),[2]}}))}))},error:e.fail};s.hj.call(t,x).catch((function(e){c(e)})),l.kg.debug("Call getHistoryMessages",e)}))}function x(e,t){return g(this,void 0,void 0,(function(){var r,i,c,u,h,d,f;return y(this,(function(m){switch(m.label){case 0:if(!a.XZ.call(this))return r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(r)];if("string"!=typeof e||""===e)throw Error('"Invalid parameter": "to"');return l.kg.debug("Call addContact",e,t),i=this.context,c=i.orgName,u=i.appName,h=i.accessToken,d=i.jid,f={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/users/").concat(this.user,"/contacts/apply?resource=").concat(d.clientResource),type:"POST",dataType:"json",data:JSON.stringify({usernames:[e],reason:t}),headers:{Authorization:"Bearer "+h,"Content-Type":"application/json"}},[4,s.hj.call(this,f,p.fI.ROSTER_ADD)];case 1:return m.sent(),[2]}}))}))}var B=z;function z(e){return g(this,void 0,void 0,(function(){var t,r,i,c,u,h,d;return y(this,(function(f){switch(f.label){case 0:if(!a.XZ.call(this))return t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)];if("string"!=typeof e||""===e)throw Error('"Invalid parameter": "to"');return l.kg.debug("Call deleteContact",e),r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,h=r.jid,d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user,"/contacts/users/").concat(e,"?resource=").concat(h.clientResource),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.hj.call(this,d,p.fI.ROSTER_REMOVE)];case 1:return f.sent(),[2]}}))}))}function L(e){return g(this,void 0,void 0,(function(){var t,r,i,c,u,h,d;return y(this,(function(f){switch(f.label){case 0:if(!a.XZ.call(this))return t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)];if("string"!=typeof e||""===e)throw Error('"Invalid parameter": "to"');return l.kg.debug("Call acceptInvitation",e),r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,h=r.jid,d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user,"/contacts/accept/users/").concat(e,"?resource=").concat(h.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.hj.call(this,d,p.fI.ROSTER_ACCEPT)];case 1:return f.sent(),[2]}}))}))}var X=L;function G(e){return g(this,void 0,void 0,(function(){var t,r,i,c,u,h,d;return y(this,(function(f){switch(f.label){case 0:if(!a.XZ.call(this))return t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)];if("string"!=typeof e||""===e)throw Error('"Invalid parameter": "to"');return l.kg.debug("Call declineInvitation",e),r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,h=r.jid,d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user,"/contacts/decline/users/").concat(e,"?resource=").concat(h.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.hj.call(this,d,p.fI.ROSTER_DECLINE)];case 1:return f.sent(),[2]}}))}))}var J=G;function D(e){return g(this,void 0,void 0,(function(){var t,r,i,c,u,h,d,f,m;return y(this,(function(g){switch(g.label){case 0:if(!a.XZ.call(this))return t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)];if(r=e.name,i=[],"string"==typeof r){if(""===r)throw Error('"Invalid parameter": "name"');i=[r]}else{if(!Array.isArray(r))throw Error('"Invalid parameter": "name"');i=r}return l.kg.debug("Call addToBlockList",e),c=this.context,u=c.orgName,h=c.appName,d=c.accessToken,f=c.jid,m={url:"".concat(this.apiUrl,"/").concat(u,"/").concat(h,"/sdk/user/").concat(this.user,"/blocks?resource=").concat(f.clientResource),type:"POST",dataType:"json",data:JSON.stringify({usernames:i}),headers:{Authorization:"Bearer "+d,"Content-Type":"application/json"}},[4,s.hj.call(this,m,p.fI.ROSTER_BAN).then((function(e){return{type:e.type,data:{userIds:(null==e?void 0:e.data)||[]}}}))];case 1:return[2,g.sent()]}}))}))}var K=D,H=D;function q(e){return g(this,void 0,void 0,(function(){var t,r,i,c,u,h,d,f,m;return y(this,(function(g){switch(g.label){case 0:if(!a.XZ.call(this))return t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)];if(r=e.name,i=[],"string"==typeof r){if(""===r)throw Error('"Invalid parameter": "name"');i=[r]}else{if(!Array.isArray(r))throw Error('"Invalid parameter": "name"');i=r}return l.kg.debug("Call removeFromBlockList",e),c=this.context,u=c.orgName,h=c.appName,d=c.accessToken,f=c.jid,m={url:"".concat(this.apiUrl,"/").concat(u,"/").concat(h,"/sdk/user/").concat(this.user,"/blocks?resource=").concat(f.clientResource),type:"DELETE",dataType:"json",data:JSON.stringify({usernames:i}),headers:{Authorization:"Bearer "+d,"Content-Type":"application/json"}},[4,s.hj.call(this,m,p.fI.ROSTER_ALLOW)];case 1:return g.sent(),[2]}}))}))}var W=q,F=q;function Q(e){var t=this,r=this.getUniqueId(),a={id:r,to:e.to};this._msgHash[r]=m({},a);var n="";void 0!==e.chatType?n=e.chatType:void 0!==e.type&&(n="chat"===e.type?"singleChat":e.type);var o={id:r,type:"recall",chatType:n,ackId:e.mid,to:e.to,isChatThread:e.isChatThread||!1,success:function(r){return g(t,void 0,void 0,(function(){var t,a,o,s,i,c,u,l,p;return y(this,(function(h){switch(h.label){case 0:return h.trys.push([0,5,,6]),"singleChat"!==n&&"groupChat"!==n?[3,4]:[4,null===(o=null===(a=this._localCache)||void 0===a?void 0:a.getInstance())||void 0===o?void 0:o.removeMsgByServerMsgId(e.mid)];case 1:return h.sent(),[4,null===(i=null===(s=this._localCache)||void 0===s?void 0:s.getInstance())||void 0===i?void 0:i.getConversationLastMessage(e.to,n)];case 2:return t=h.sent(),[4,null===(u=null===(c=this._localCache)||void 0===c?void 0:c.getInstance())||void 0===u?void 0:u.updateLocalConversation((0,f.MQ)({conversationId:e.to,conversationType:n}),{lastMessageId:null==t?void 0:t.serverMsgId})];case 3:h.sent(),h.label=4;case 4:return null===(l=null==e?void 0:e.success)||void 0===l||l.call(e,r),[3,6];case 5:return h.sent(),null===(p=null==e?void 0:e.success)||void 0===p||p.call(e,r),[3,6];case 6:return[2]}}))}))},fail:e.fail};return l.kg.debug("Call recallMessage",e),this.mSync.send(o,this)}function V(e){var t=e||{},r=t.messageId,a=t.modifiedMessage;if(l.kg.debug("Call modifyMessage",r,a),""===r)throw Error('Invalid parameter: "messageId"');if("txt"!==a.type)throw Error('Invalid parameter: "modifiedMessage.type"');return this.mSync.send(m({editMessageId:r},a))}function Y(e){return g(this,void 0,void 0,(function(){var t,r,i,c,u,l,p,h,d;return y(this,(function(f){switch(f.label){case 0:if("string"!=typeof e.messageId||!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if("string"!=typeof e.reaction||!e.reaction)throw Error("Invalid parameter reaction: ".concat(e.reaction));return a.XZ.call(this)?(r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l=e.reaction,p=e.messageId,h={msgId:p,message:l},d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/reaction/user/").concat(this.user),type:"POST",data:JSON.stringify(h),dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.hj.call(this,d)]):(t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)]);case 1:return f.sent(),[2]}}))}))}function $(e){return g(this,void 0,void 0,(function(){var t,r,i,c,u,l,p,h;return y(this,(function(d){switch(d.label){case 0:if("string"!=typeof e.reaction||!e.reaction)throw Error("Invalid parameter reactionId: ".concat(e.reaction));return a.XZ.call(this)?(r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l=e.messageId,p=e.reaction,h={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/reaction/user/").concat(this.user,"?msgId=").concat(l,"&message=").concat(p),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.hj.call(this,h)]):(t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)]);case 1:return d.sent(),[2]}}))}))}function ee(e){if("string"!=typeof e.chatType||!e.chatType)throw Error("Invalid parameter chatType: ".concat(e.chatType));if(!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l=e.chatType,p=e.messageId,h={msgIdList:"string"==typeof p?[p]:p,msgType:"singleChat"===l?"chat":"groupchat",groupId:e.groupId||null},d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/reaction/user/").concat(this.user),type:"GET",data:h,dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}};return s.hj.call(this,d).then((function(e){var t=e.data;return null==t||t.forEach((function(e){null==e||e.reactionList.forEach((function(e){e.isAddedBySelf=e.state,delete e.state,delete e.reactionId}))})),e}))}var te=ee;function re(e){if("string"!=typeof e.reaction||!e.reaction)throw Error("Invalid parameter reaction: ".concat(e.reaction));if("string"!=typeof e.messageId||!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l=e.cursor,p=e.pageSize,h={msgId:e.messageId,message:e.reaction,currentPage:l||null,pageSize:p||20},d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/reaction/user/").concat(this.user,"/detail"),type:"GET",data:h,dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}};return s.hj.call(this,d).then((function(e){return e.data.isAddedBySelf=e.data.state,delete e.data.state,delete e.data.reactionId,e}))}function ae(e){return g(this,void 0,void 0,(function(){var t,r,i,c,u,l,p,h,d,f,m;return y(this,(function(g){switch(g.label){case 0:if("string"!=typeof e.reportType||!e.reportType)throw Error("Invalid parameter reportType: ".concat(e.reportType));if("string"!=typeof e.messageId||!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if("string"!=typeof e.reportReason||!e.reportReason)throw Error("Invalid parameter messageId: ".concat(e.reportReason));return a.XZ.call(this)?(r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,l=e.reportType,p=e.reportReason,h=e.messageId,d={username:this.user,reportType:l,reportReason:p},f="".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/user/").concat(this.user,"/moderation/report/message/").concat(h),m={url:f,type:"POST",data:JSON.stringify(d),dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.hj.call(this,m)]):(t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)]);case 1:return g.sent(),[2]}}))}))}function ne(e){var t;return g(this,void 0,void 0,(function(){var r,i,c,u,p,h,d,f,m;return y(this,(function(g){switch(g.label){case 0:if("string"!=typeof e.targetId||""===e.targetId)throw Error('"Invalid parameter targetId": '+e.targetId);if(!["singleChat","groupChat"].includes(e.chatType))throw Error('"Invalid parameter chatType": '+e.chatType);if(e.beforeTimeStamp&&("number"!=typeof e.beforeTimeStamp||e.beforeTimeStamp<0||(null===(t=e.beforeTimeStamp)||void 0===t?void 0:t.toString().length)>18))throw Error('"Invalid parameter beforeTimeStamp": '+e.beforeTimeStamp);if(e.messageIds&&!(Array.isArray(e.messageIds)&&e.messageIds.length>0&&e.messageIds.length<=20))throw Error('"Invalid parameter messageIds": '+e.messageIds);if(!e.messageIds&&!e.beforeTimeStamp)throw Error("messageIds or beforeTimeStamp field is required.");return a.XZ.call(this)?(i=this.context,c=i.orgName,u=i.appName,p=i.userId,h="singleChat"===e.chatType?"userId":"groupId",d="singleChat"===e.chatType?"chat":"group",f=e.messageIds?"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/sdk/message/roaming/").concat(d,"/user/").concat(p,"?").concat(h,"=").concat(e.targetId,"&msgIdList=").concat(e.messageIds,"&resource=").concat(this.clientResource):"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/sdk/message/roaming/").concat(d,"/user/").concat(p,"/time?").concat(h,"=").concat(e.targetId,"&delTime=").concat(e.beforeTimeStamp,"&&resource=").concat(this.clientResource),m={url:f,dataType:"json",type:"DELETE",headers:{Authorization:"Bearer "+this.token,"Content-Type":"application/json"}},l.kg.debug("Call removeHistoryMessages",e),[4,s.hj.call(this,m)]):(r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(r)]);case 1:return g.sent(),[2]}}))}))}function oe(e){var t=this;if(!a.XZ.call(this)){var r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(r)}if((null==e?void 0:e.pageSize)&&"number"!=typeof e.pageSize)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));if((null==e?void 0:e.cursor)&&"string"!=typeof e.cursor)throw Error("Invalid parameter cursor: ".concat(e.cursor));var i=this.context,c=i.orgName,u=i.appName,h=i.accessToken,m={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/sdk/user/").concat(this.user,"/user_channels/list?"),type:"GET",dataType:"json",data:{limit:(null==e?void 0:e.pageSize)||20,cursor:(null==e?void 0:e.cursor)||""},headers:{Authorization:"Bearer "+h,"Content-Type":"application/json"}};return l.kg.debug("Call getServerConversations",e),new Promise((function(e,r){s.hj.call(t,m,p.fI.GET_SESSION_LIST).then((function(r){return g(t,void 0,void 0,(function(){var t,a=this;return y(this,(function(n){switch(n.label){case 0:return t=se(r),this._localCache?[4,Promise.all(t.data.conversations.map((function(e){return g(a,void 0,void 0,(function(){var t,r,a=this;return y(this,(function(n){return null===(r=null===(t=this._localCache)||void 0===t?void 0:t.getInstance())||void 0===r||r.storeMessage(e.lastMessage,d.r.SUCCESS,!0).then((function(){var t,r;null===(r=null===(t=a._localCache)||void 0===t?void 0:t.getInstance())||void 0===r||r.updateLocalConversation((0,f.MQ)({conversationId:e.conversationId,conversationType:e.conversationType}),{unReadCount:e.unReadCount})})),[2]}))}))})))]:[3,2];case 1:return n.sent(),e(t),[2];case 2:return e(t),[2]}}))}))})).catch((function(e){r(e)}))}))}function se(e){var t=e.data,r=t.cursor,a=t.channel_infos,n=[];null==a||a.forEach((function(e){var t=null;(null==e?void 0:e.meta)&&"{}"!==JSON.stringify(e.meta)&&(e.meta.payload=JSON.parse(e.meta.payload),"delivery"!==(t=(0,h.w)(e.meta)).type&&"read"!==t.type&&"channel"!==t.type&&(t.chatType=v[t.chatType]));var r={conversationId:e.session_to,conversationType:"chat"===e.session_type?"singleChat":"groupChat",isPinned:e.is_top,pinnedTime:e.is_top?e.update_top_status_time:0,unReadCount:e.unread_num,lastMessage:t};n.push(r)}));var o={conversations:n,cursor:r||""};return{type:e.type,data:o}}function ie(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}if((null==e?void 0:e.pageSize)&&"number"!=typeof e.pageSize)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));if((null==e?void 0:e.cursor)&&"string"!=typeof e.cursor)throw Error("Invalid parameter cursor: ".concat(e.cursor));var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,h={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/sdk/user/").concat(this.user,"/user_channels/list?"),type:"GET",dataType:"json",data:{limit:(null==e?void 0:e.pageSize)||20,cursor:(null==e?void 0:e.cursor)||"",is_top:!0},headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}};return l.kg.debug("Call getServerConversations",e),s.hj.call(this,h,p.fI.GET_SESSION_LIST).then((function(e){return se(e)}))}function ce(e){return g(this,void 0,void 0,(function(){var t,r,i,c,u,h,d,f,m,g,v,T,S,E;return y(this,(function(y){if(!a.XZ.call(this))return t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)];if(r=e.conversationId,i=e.conversationType,c=e.isPinned,u="singleChat"===i?"chat":"groupChat","string"!=typeof r||""===r)throw Error("Invalid parameter conversationId: ".concat(r));if(!["singleChat","groupChat"].includes(i))throw Error("Invalid parameter conversationType: ".concat(i));if("boolean"!=typeof c)throw Error("Invalid parameter isPinned: ".concat(c));return h=this.context,d=h.orgName,f=h.appName,m=h.accessToken,g=h.jid,v={type:u,to:r},T=c?"":"type=".concat(u,"&to=").concat(r,"&"),S="".concat(this.apiUrl,"/").concat(d,"/").concat(f,"/sdk/user/").concat(this.user,"/user_channel/top?").concat(T,"resource=").concat(g.clientResource),E={url:S,type:c?"POST":"DELETE",dataType:"json",headers:{Authorization:"Bearer "+m,"Content-Type":"application/json"}},c&&(E.data=JSON.stringify(v)),l.kg.debug("Call pinConversation",e),[2,s.hj.call(this,E,p.fI.PIN_CONVERSATION).then((function(e){var t=e.type,r=e.data;return{type:t,data:{isPinned:r.is_top||!1,pinnedTime:r.is_top?r.update_top_status_time:0}}}))]}))}))}function ue(e){return g(this,void 0,void 0,(function(){var t,r,i,c,u,h,d,f,m,g;return y(this,(function(y){switch(y.label){case 0:if(t=e.userId,r=e.remark,!a.XZ.call(this))return i=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(i)];if("string"!=typeof t||""===t)throw Error('Invalid parameter: "userId"');if("string"!=typeof r)throw Error('Invalid parameter: "remark"');return l.kg.debug("Call setContactRemark",e),c=this.context,u=c.orgName,h=c.appName,d=c.accessToken,f=c.jid,m="".concat(this.apiUrl,"/").concat(u,"/").concat(h,"/users/").concat(this.context.userId,"/contacts/users/").concat(t,"?resource=").concat(f.clientResource),g={url:m,type:"PUT",data:JSON.stringify({remark:r}),dataType:"json",headers:{Authorization:"Bearer "+d,"Content-Type":"application/json"}},[4,s.hj.call(this,g,p.fI.ROSTER_SET_CONTACT_REMARK)];case 1:return y.sent(),[2]}}))}))}function le(){if(!a.XZ.call(this)){var e=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(e)}var t=this.context,r=t.orgName,i=t.appName,c=t.accessToken,u={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(i,"/users/").concat(this.user,"/contacts/users?needReturnRemark=true"),dataType:"json",type:"GET",headers:{Authorization:"Bearer "+c}};return l.kg.debug("Call getAllContacts"),s.hj.call(this,u,p.fI.ROSTER_GET_ALL_CONTACTS_REMARKS).then((function(e){var t=((null==e?void 0:e.entities)||[]).map((function(e){return{userId:e.username,remark:e.remark}}));return{type:e.type,data:t}}))}function pe(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}l.kg.debug("Call getContactsWithCursor",e);var r=e||{},i=r.pageSize,c=void 0===i?20:i,u=r.cursor,h=void 0===u?"":u;if(c&&"number"!=typeof c)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));var d=this.context,f=d.orgName,m=d.appName,g=d.accessToken,y={url:"".concat(this.apiUrl,"/").concat(f,"/").concat(m,"/users/").concat(this.user,"/contacts?needReturnRemark=true&limit=").concat(c,"&cursor=").concat(h),dataType:"json",type:"GET",headers:{Authorization:"Bearer "+g}};return s.hj.call(this,y,p.fI.ROSTER_GET_ALL_CONTACTS_REMARKS_FROM_SERVER_BY_PAGE).then((function(e){var t,r,a=(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.contacts)||[],n=(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.cursor)||"",o=a.map((function(e){return{userId:e.username,remark:e.remark}}));return{type:e.type,data:{cursor:n,contacts:o}}}))}},3246:function(e,t,r){r.d(t,{H7:function(){return u},XZ:function(){return i},_W:function(){return c}}),r(7941),r(9554),r(1539),r(4747),r(6699),r(2023);var a=r(5531),n=r(7252);function o(){var e=this.context.appName,t=this.context.orgName;return!(!e||!t)||(this.onError&&this.onError({type:a.E.WEBIM_CONNCTION_AUTH_ERROR,message:"appName or orgName is illegal"}),!1)}function s(){var e;if(!this.context.accessToken){var t=n.Z.create({type:a.E.WEBIM_CONNCTION_TOKEN_NOT_ASSIGN_ERROR,message:"token not assign error"});return this.onError&&this.onError(t),null===(e=this.eventHandler)||void 0===e||e.dispatch("onError",t),!1}return!0}function i(){return s.call(this)&&o.call(this)}function c(e){var t=e.data,r=e.type;return{data:{status:Object.keys(t.errorKeys).length>0?"fail":"success",errorKeys:t.errorKeys,successKeys:t.successKeys},type:r}}function u(e){var t=e.data,r=void 0;return Object.keys(t.errorKeys).length>0&&Object.keys(t.errorKeys).forEach((function(e){var o=t.errorKeys[e];r=o.includes("is not part of you")?n.Z.create({type:a.E.NO_PERMISSION,message:o}):o.includes("size of metadata for this single chatroom exceeds the user defined limit")||o.includes("total size of chatroom metadata for this app exceeds the user defined limit")||o.includes("is exceeding maximum limit")?n.Z.create({type:a.E.MAX_LIMIT,message:o}):o.includes("is not Legal")?n.Z.create({type:a.E.REQUEST_PARAMETER_ERROR,message:o}):o.includes("Failed to update userMetadata. Concurrent updates not allowed")?n.Z.create({type:a.E.OPERATION_NOT_ALLOWED,message:o}):n.Z.create({type:a.E.WEBIM_CONNCTION_AJAX_ERROR,message:o})})),r}},5069:function(e,t,r){var a=r(2109),n=r(1702),o=r(3157),s=n([].reverse),i=[1,2];a({target:"Array",proto:!0,forced:String(i)===String(i.reverse())},{reverse:function(){return o(this)&&(this.length=this.length),s(this)}})}},function(e){return 7479,e(e.s=7479)}])}));
@@ -86,6 +86,8 @@ export interface AudioMsgBody extends AudioMsgSetParameters {
86
86
  isChatThread?: boolean;
87
87
  /** Message priority. */
88
88
  priority?: MessagePriority;
89
+ /** Whether global notify message or not. */
90
+ broadcast?: boolean;
89
91
  /** Whether the message is delivered only when the recipient(s) is/are online:
90
92
  * - `true`: The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
91
93
  * - (Default) `false`: The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.
package/message/cmd.d.ts CHANGED
@@ -71,6 +71,8 @@ export interface CmdMsgBody {
71
71
  isChatThread?: boolean;
72
72
  /** Message priority. */
73
73
  priority?: MessagePriority;
74
+ /** Whether global notify message or not. */
75
+ broadcast?: boolean;
74
76
  /** Whether the message is delivered only when the recipient(s) is/are online:
75
77
  * - `true`: The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
76
78
  * - (Default) `false`: The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.
@@ -1,157 +1,164 @@
1
- import { ChannelMsgBody, ChatType, DeliveryMsgBody, MessagePriority, MessagesType, ReadMsgBody } from '../types/message';
1
+ import {
2
+ ChannelMsgBody,
3
+ ChatType,
4
+ DeliveryMsgBody,
5
+ MessagePriority,
6
+ MessagesType,
7
+ ReadMsgBody,
8
+ } from '../types/message';
2
9
  export interface CombineParameters {
3
- /** The message type. */
4
- /** 消息类型。 */
5
- type: 'combine';
6
- /** The message ID. */
7
- /** 消息 ID。*/
8
- id: string;
10
+ /** The message type. */
11
+ /** 消息类型。 */
12
+ type: 'combine';
13
+ /** The message ID. */
14
+ /** 消息 ID。*/
15
+ id: string;
9
16
  }
10
17
  export interface CombineMsgBody {
11
- /** The message ID. */
12
- /** 消息 ID。*/
13
- id: string;
14
- /** The conversation type. */
15
- /** 会话类型。 */
16
- chatType: ChatType;
17
- /** The message type. */
18
- /** 消息类型。 */
19
- type: 'combine';
20
- /** The recipient. */
21
- /** 消息接收方。 */
22
- to: string;
23
- /** The sender, which can only be the current user and can not be changed.*/
24
- /** 消息发送方,只能是当前用户,无法修改。*/
25
- from?: string;
26
- /** @deprecated Whether the conversation type is chat room. */
27
- /** @deprecated 会话类型是否是聊天室。 */
28
- roomType?: boolean;
29
- /** @deprecated Whether the conversation type is group. */
30
- /** @deprecated 会话类型是否是群组。 */
31
- group?: string;
32
- /** Message extension. */
33
- /** 消息扩展。 */
34
- ext?: {
35
- [key: string]: any;
36
- };
37
- /** Whether read receipts are required during a group conversation. */
38
- /** 群组会话时是否需返回已读回执。*/
39
- msgConfig?: {
40
- allowGroupAck?: boolean;
41
- languages?: string[];
42
- };
43
- /** Time. */
44
- /** 时间。 */
45
- time: number;
46
- /** Whether the message is a threaded message. */
47
- /** 消息是否为子区消息 */
48
- isChatThread?: boolean;
49
- /** The message priority. */
50
- /** 消息优先级 */
51
- priority?: MessagePriority;
52
- /** Whether the message is delivered only when the recipient(s) is/are online:
53
- * - `true`: The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
54
- * - (Default) `false`: The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.
55
- */
56
- /** 消息是否只投递给在线用户:
57
- * - `true`: 只有消息接收方在线时才能投递成功。若接收方离线,则消息会被丢弃。
58
- * - (默认)`false`: 如果用户在线,则直接投递;如果用户离线,消息会在用户上线时投递。
59
- */
60
- deliverOnlineOnly?: boolean;
61
- /** The list of message recipients. */
62
- /** 消息接收方列表。 */
63
- receiverList?: string[];
64
- /** The compatibility information for combining message. */
65
- /** 合并消息的兼容信息。 */
66
- compatibleText: string;
67
- /** The title of the combined message. */
68
- /** 合并消息的标题。 */
69
- title: string;
70
- /** The summary list of the combined message. */
71
- /** 合并消息的摘要列表。 */
72
- summary: string;
73
- /** The message list of the combined message. */
74
- /** 合并消息列表。 */
75
- messageList: MessagesType[];
76
- /** The callback of a file upload error. */
77
- /** 文件上传错误的回调。 */
78
- onFileUploadError?: (error: any) => void;
79
- /** The callback of file upload completion. */
80
- /** 文件上传完成的回调。 */
81
- onFileUploadComplete?: (data: {
82
- url: string;
83
- secret: string;
84
- }) => void;
18
+ /** The message ID. */
19
+ /** 消息 ID。*/
20
+ id: string;
21
+ /** The conversation type. */
22
+ /** 会话类型。 */
23
+ chatType: ChatType;
24
+ /** The message type. */
25
+ /** 消息类型。 */
26
+ type: 'combine';
27
+ /** The recipient. */
28
+ /** 消息接收方。 */
29
+ to: string;
30
+ /** The sender, which can only be the current user and can not be changed.*/
31
+ /** 消息发送方,只能是当前用户,无法修改。*/
32
+ from?: string;
33
+ /** @deprecated Whether the conversation type is chat room. */
34
+ /** @deprecated 会话类型是否是聊天室。 */
35
+ roomType?: boolean;
36
+ /** @deprecated Whether the conversation type is group. */
37
+ /** @deprecated 会话类型是否是群组。 */
38
+ group?: string;
39
+ /** Message extension. */
40
+ /** 消息扩展。 */
41
+ ext?: {
42
+ [key: string]: any;
43
+ };
44
+ /** Whether read receipts are required during a group conversation. */
45
+ /** 群组会话时是否需返回已读回执。*/
46
+ msgConfig?: {
47
+ allowGroupAck?: boolean;
48
+ languages?: string[];
49
+ };
50
+ /** Time. */
51
+ /** 时间。 */
52
+ time: number;
53
+ /** Whether the message is a threaded message. */
54
+ /** 消息是否为子区消息 */
55
+ isChatThread?: boolean;
56
+ /** The message priority. */
57
+ /** 消息优先级 */
58
+ priority?: MessagePriority;
59
+ /** Whether global notify message or not. */
60
+ /** 判断是否是全局广播消息。 */
61
+ broadcast?: boolean;
62
+ /** Whether the message is delivered only when the recipient(s) is/are online:
63
+ * - `true`: The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
64
+ * - (Default) `false`: The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.
65
+ */
66
+ /** 消息是否只投递给在线用户:
67
+ * - `true`: 只有消息接收方在线时才能投递成功。若接收方离线,则消息会被丢弃。
68
+ * - (默认)`false`: 如果用户在线,则直接投递;如果用户离线,消息会在用户上线时投递。
69
+ */
70
+ deliverOnlineOnly?: boolean;
71
+ /** The list of message recipients. */
72
+ /** 消息接收方列表。 */
73
+ receiverList?: string[];
74
+ /** The compatibility information for combining message. */
75
+ /** 合并消息的兼容信息。 */
76
+ compatibleText: string;
77
+ /** The title of the combined message. */
78
+ /** 合并消息的标题。 */
79
+ title: string;
80
+ /** The summary list of the combined message. */
81
+ /** 合并消息的摘要列表。 */
82
+ summary: string;
83
+ /** The message list of the combined message. */
84
+ /** 合并消息列表。 */
85
+ messageList: MessagesType[];
86
+ /** The callback of a file upload error. */
87
+ /** 文件上传错误的回调。 */
88
+ onFileUploadError?: (error: any) => void;
89
+ /** The callback of file upload completion. */
90
+ /** 文件上传完成的回调。 */
91
+ onFileUploadComplete?: (data: { url: string; secret: string }) => void;
85
92
  }
86
93
  export interface CreateCombineMsgParameters {
87
- /** The conversation type. */
88
- /** 会话类型。 */
89
- chatType: ChatType;
90
- /** The message type. */
91
- /** 消息类型。 */
92
- type: 'combine';
93
- /** The recipient. */
94
- /** 消息接收方。 */
95
- to: string;
96
- /** The sender, which can only be the current user and can not be changed. */
97
- /** 消息发送方,只能是当前用户,无法修改。*/
98
- from?: string;
99
- /** The message extension. */
100
- /** 消息扩展。 */
101
- ext?: {
102
- [key: string]: any;
103
- };
104
- /** Whether read receipts are required during a group conversation. */
105
- /** 群组会话时是否需返回已读回执。*/
106
- msgConfig?: {
107
- allowGroupAck?: boolean;
108
- languages?: string[];
109
- };
110
- /** Whether the message is a threaded message. */
111
- /** 消息是否为子区消息。 */
112
- isChatThread?: boolean;
113
- /** Message priority. */
114
- /** 消息优先级 */
115
- priority?: MessagePriority;
116
- /** Whether the message is delivered only when the recipient(s) is/are online:
117
- * - `true`: The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
118
- * - (Default) `false`: The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.
119
- */
120
- /** 消息是否只投递给在线用户:
121
- * - `true`: 只有消息接收方在线时才能投递成功。若接收方离线,则消息会被丢弃。
122
- * - (默认)`false`: 如果用户在线,则直接投递;如果用户离线,消息会在用户上线时投递。
123
- */
124
- deliverOnlineOnly?: boolean;
125
- /** The list of message recipients. */
126
- /** 消息接收方列表。 */
127
- receiverList?: string[];
128
- /** The compatible text of the combined message. */
129
- /** 合并消息的兼容信息。 */
130
- compatibleText: string;
131
- /** The title of the combined message. */
132
- /** 合并消息的标题。 */
133
- title: string;
134
- /** The summary list of the combined message. */
135
- /** 合并消息摘要列表。 */
136
- summary: string;
137
- /** The message list of the combined message. */
138
- /** 合并消息的消息列表。 */
139
- messageList: Exclude<MessagesType, DeliveryMsgBody | ReadMsgBody | ChannelMsgBody>[];
140
- /** The callback of a file upload error. */
141
- /** 文件上传错误的回调。 */
142
- onFileUploadError?: (error: any) => void;
143
- /** The callback of file upload completion. */
144
- /** 文件上传完成的回调。 */
145
- onFileUploadComplete?: (data: {
146
- url: string;
147
- secret: string;
148
- }) => void;
94
+ /** The conversation type. */
95
+ /** 会话类型。 */
96
+ chatType: ChatType;
97
+ /** The message type. */
98
+ /** 消息类型。 */
99
+ type: 'combine';
100
+ /** The recipient. */
101
+ /** 消息接收方。 */
102
+ to: string;
103
+ /** The sender, which can only be the current user and can not be changed. */
104
+ /** 消息发送方,只能是当前用户,无法修改。*/
105
+ from?: string;
106
+ /** The message extension. */
107
+ /** 消息扩展。 */
108
+ ext?: {
109
+ [key: string]: any;
110
+ };
111
+ /** Whether read receipts are required during a group conversation. */
112
+ /** 群组会话时是否需返回已读回执。*/
113
+ msgConfig?: {
114
+ allowGroupAck?: boolean;
115
+ languages?: string[];
116
+ };
117
+ /** Whether the message is a threaded message. */
118
+ /** 消息是否为子区消息。 */
119
+ isChatThread?: boolean;
120
+ /** Message priority. */
121
+ /** 消息优先级 */
122
+ priority?: MessagePriority;
123
+ /** Whether the message is delivered only when the recipient(s) is/are online:
124
+ * - `true`: The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
125
+ * - (Default) `false`: The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.
126
+ */
127
+ /** 消息是否只投递给在线用户:
128
+ * - `true`: 只有消息接收方在线时才能投递成功。若接收方离线,则消息会被丢弃。
129
+ * - (默认)`false`: 如果用户在线,则直接投递;如果用户离线,消息会在用户上线时投递。
130
+ */
131
+ deliverOnlineOnly?: boolean;
132
+ /** The list of message recipients. */
133
+ /** 消息接收方列表。 */
134
+ receiverList?: string[];
135
+ /** The compatible text of the combined message. */
136
+ /** 合并消息的兼容信息。 */
137
+ compatibleText: string;
138
+ /** The title of the combined message. */
139
+ /** 合并消息的标题。 */
140
+ title: string;
141
+ /** The summary list of the combined message. */
142
+ /** 合并消息摘要列表。 */
143
+ summary: string;
144
+ /** The message list of the combined message. */
145
+ /** 合并消息的消息列表。 */
146
+ messageList: Exclude<
147
+ MessagesType,
148
+ DeliveryMsgBody | ReadMsgBody | ChannelMsgBody
149
+ >[];
150
+ /** The callback of a file upload error. */
151
+ /** 文件上传错误的回调。 */
152
+ onFileUploadError?: (error: any) => void;
153
+ /** The callback of file upload completion. */
154
+ /** 文件上传完成的回调。 */
155
+ onFileUploadComplete?: (data: { url: string; secret: string }) => void;
149
156
  }
150
157
  export declare class Combine {
151
- id: string;
152
- type: 'combine';
153
- value: string;
154
- body?: CombineMsgBody;
155
- constructor(parameters: CombineParameters);
156
- static create(options: CreateCombineMsgParameters): CombineMsgBody;
158
+ id: string;
159
+ type: 'combine';
160
+ value: string;
161
+ body?: CombineMsgBody;
162
+ constructor(parameters: CombineParameters);
163
+ static create(options: CreateCombineMsgParameters): CombineMsgBody;
157
164
  }
@@ -58,6 +58,8 @@ export interface CustomMsgBody extends CreateCustomMsgParameters {
58
58
  time: number;
59
59
  /** Message priority. */
60
60
  priority?: MessagePriority;
61
+ /** Whether global notify message or not. */
62
+ broadcast?: boolean;
61
63
  /** Whether the message is delivered only when the recipient(s) is/are online:
62
64
  * - `true`: The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
63
65
  * - (Default) `false`: The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.
package/message/file.d.ts CHANGED
@@ -83,6 +83,8 @@ export interface FileMsgBody extends CreateFileMsgParameters {
83
83
  };
84
84
  /** Message priority. */
85
85
  priority?: MessagePriority;
86
+ /** Whether global notify message or not. */
87
+ broadcast?: boolean;
86
88
  /** Whether the message is delivered only when the recipient(s) is/are online:
87
89
  * - `true`: The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
88
90
  * - (Default) `false`: The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.
package/message/img.d.ts CHANGED
@@ -96,6 +96,8 @@ export interface ImgMsgBody extends CreateImgMsgParameters {
96
96
  fail?: () => void;
97
97
  /** Message priority. */
98
98
  priority?: MessagePriority;
99
+ /** Whether global notify message or not. */
100
+ broadcast?: boolean;
99
101
  /** Whether the message is delivered only when the recipient(s) is/are online:
100
102
  * - `true`: The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
101
103
  * - (Default) `false`: The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.
@@ -59,6 +59,8 @@ export interface LocationMsgBody extends CreateLocationMsgParameters {
59
59
  time: number;
60
60
  /** Message priority. */
61
61
  priority?: MessagePriority;
62
+ /** Whether global notify message or not. */
63
+ broadcast?: boolean;
62
64
  /** Whether the message is delivered only when the recipient(s) is/are online:
63
65
  * - `true`: The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
64
66
  * - (Default) `false`: The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.