Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/im/controller/dist/ |
Upload File : |
this.BX=this.BX||{};this.BX.Messenger=this.BX.Messenger||{};(function(e,t,i,s){"use strict";var a=function(){function e(){babelHelpers.classCallCheck(this,e);this.store=null;this.restClient=null;this.templateEngine=null;this.timer=new t.Timer;this._prepareFilesBeforeSave=function(e){return e};this.defaultMessageLimit=20;this.requestMessageLimit=this.getDefaultMessageLimit();this.messageLastReadId={};this.messageReadQueue={}}babelHelpers.createClass(e,[{key:"setTemplateEngine",value:function e(t){this.templateEngine=t}},{key:"setRestClient",value:function e(t){this.restClient=t}},{key:"setStore",value:function e(t){this.store=t}},{key:"getSiteId",value:function e(){return this.store.state.application.common.siteId}},{key:"getUserId",value:function e(){return this.store.state.application.common.userId}},{key:"getLanguageId",value:function e(){return this.store.state.application.common.languageId}},{key:"getCurrentUser",value:function e(){return this.store.getters["users/get"](this.store.state.application.common.userId,true)}},{key:"getChatId",value:function e(){return this.store.state.application.dialog.chatId}},{key:"getDialogId",value:function e(){return this.store.state.application.dialog.dialogId}},{key:"getDialogData",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.getDialogId();if(this.store.state.dialogues.collection[t]){return this.store.state.dialogues.collection[t]}return this.store.getters["dialogues/getBlank"]()}},{key:"getDialogCrmData",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.getDialogId();var s={enabled:false,entityType:i.DialogCrmType.none,entityId:0};var a=this.getDialogData(t);if(a.type===i.DialogType.call){if(a.entityData1&&typeof a.entityData1==="string"){var n=a.entityData1.split("|"),r=babelHelpers.slicedToArray(n,3),u=r[0],o=r[1],d=r[2];if(u){o=o?o.toString().toLowerCase():i.DialogCrmType.none;s={enabled:u,entityType:o,entityId:d}}}}else if(a.type===i.DialogType.crm){var l=a.entityId.split("|"),g=babelHelpers.slicedToArray(l,2),h=g[0],f=g[1];h=h?h.toString().toLowerCase():i.DialogCrmType.none;s={enabled:true,entityType:h,entityId:f}}return s}},{key:"getDialogIdByChatId",value:function e(t){if(this.getDialogId()==="chat"+t){return this.getDialogId()}var i=this.store.getters["dialogues/getByChatId"](t);if(!i){return 0}return i.dialogId}},{key:"getDiskFolderId",value:function e(){return this.store.state.application.dialog.diskFolderId}},{key:"getMessageLimit",value:function e(){return this.store.state.application.dialog.messageLimit}},{key:"getDefaultMessageLimit",value:function e(){return this.defaultMessageLimit}},{key:"getRequestMessageLimit",value:function e(){return this.requestMessageLimit}},{key:"emit",value:function e(t){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};this.templateEngine.$emit(t,i);return true}},{key:"listen",value:function e(t,i){if(typeof i!=="function"){return false}this.templateEngine.$on(t,i);return true}},{key:"getReadedList",value:function e(){var t=this.store.state.dialogues.collection[this.getDialogId()];if(!t){return[]}return t.readedList}},{key:"muteDialog",value:function e(){var t=this;var a=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:this.getDialogId();if(s.Utils.dialog.isEmptyDialogId(n)){return false}if(a===null){a=!this.isDialogMuted()}this.timer.start("muteDialog",n,.3,function(e){t.restClient.callMethod(i.RestMethod.imChatMute,{DIALOG_ID:n,ACTION:a?"Y":"N"})});var r=[];if(a){r=this.getDialogData().muteList;r.push(this.getUserId())}else{r=this.getDialogData().muteList.filter(function(e){return e!==t.getUserId()})}this.store.dispatch("dialogues/update",{dialogId:n,fields:{muteList:r}});return true}},{key:"isDialogMuted",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.getDialogId();return this.getDialogData().muteList.includes(this.getUserId())}},{key:"isUnreadMessagesLoaded",value:function e(){var t=this.store.state.dialogues.collection[this.getDialogId()];if(!t){return true}if(t.unreadLastId<=0){return true}var i=this.store.state.messages.collection[this.getChatId()];if(!i||i.length<=0){return true}var s=0;for(var a=i.length-1;a>=0;a--){var n=i[a];if(typeof n.id==="number"){s=n.id;break}}return s>=t.unreadLastId}},{key:"prepareFilesBeforeSave",value:function e(t){return this._prepareFilesBeforeSave(t)}},{key:"setPrepareFilesBeforeSaveFunction",value:function e(t){this._prepareFilesBeforeSave=t.bind(this)}},{key:"showSmiles",value:function e(){this.store.dispatch("application/showSmiles")}},{key:"hideSmiles",value:function e(){this.store.dispatch("application/hideSmiles")}},{key:"startOpponentWriting",value:function e(t){var i=this;var s=t.dialogId,a=t.userId,n=t.userName;this.store.dispatch("dialogues/updateWriting",{dialogId:s,userId:a,userName:n,action:true});this.timer.start("writingEnd",s+"|"+a,35,function(e,t){var s=t.dialogId,a=t.userId;i.store.dispatch("dialogues/updateWriting",{dialogId:s,userId:a,action:false})},{dialogId:s,userId:a});return true}},{key:"stopOpponentWriting",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var i=t.dialogId,s=t.userId,a=t.userName;this.timer.stop("writingStart",i+"|"+s,true);this.timer.stop("writingEnd",i+"|"+s);return true}},{key:"startWriting",value:function e(){var t=this;var a=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.getDialogId();if(s.Utils.dialog.isEmptyDialogId(a)||this.timer.has("writes",a)){return false}this.timer.start("writes",a,28);this.timer.start("writesSend",a,5,function(e){t.restClient.callMethod(i.RestMethod.imDialogWriting,{DIALOG_ID:a}).catch(function(){t.timer.stop("writes",a)})})}},{key:"stopWriting",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.getDialogId();this.timer.stop("writes",t,true);this.timer.stop("writesSend",t,true)}},{key:"joinParentChat",value:function e(t,s){var a=this;return new Promise(function(e,n){if(!t||!s){return n()}if(typeof a.tempJoinChat==="undefined"){a.tempJoinChat={}}else if(a.tempJoinChat["wait"]){return n()}a.tempJoinChat["wait"]=true;a.restClient.callMethod(i.RestMethod.imChatParentJoin,{DIALOG_ID:s,MESSAGE_ID:t}).then(function(){a.tempJoinChat["wait"]=false;a.tempJoinChat[s]=true;return e(s)}).catch(function(){a.tempJoinChat["wait"]=false;return n()})})}},{key:"setTextareaMessage",value:function e(t){var i=t.message,s=i===void 0?"":i,a=t.dialogId,n=a===void 0?this.getDialogId():a;this.store.dispatch("dialogues/update",{dialogId:n,fields:{textareaMessage:s}})}},{key:"setSendingMessageFlag",value:function e(t){this.store.dispatch("messages/actionStart",{id:t,chatId:this.getChatId()})}},{key:"reactMessage",value:function e(t){var s=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"auto";this.restClient.callMethod(i.RestMethod.imMessageLike,{MESSAGE_ID:t,ACTION:s==="auto"?"auto":s==="set"?"plus":"minus"})}},{key:"readMessage",value:function e(){var t=this;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var s=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var a=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var n=this.getChatId();if(typeof this.messageLastReadId[n]==="undefined"){this.messageLastReadId[n]=null}if(typeof this.messageReadQueue[n]==="undefined"){this.messageReadQueue[n]=[]}if(i){this.messageReadQueue[n].push(parseInt(i))}this.timer.stop("readMessage",n,true);this.timer.stop("readMessageServer",n,true);if(s){return this.readMessageExecute(n,a)}return new Promise(function(e,i){t.timer.start("readMessage",n,.1,function(i,s){return t.readMessageExecute(i,a).then(function(t){return e(t)})})})}},{key:"readMessageExecute",value:function e(t){var s=this;var a=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return new Promise(function(e,n){if(s.messageReadQueue[t]){s.messageReadQueue[t]=s.messageReadQueue[t].filter(function(e){if(!s.messageLastReadId[t]){s.messageLastReadId[t]=e}else if(s.messageLastReadId[t]<e){s.messageLastReadId[t]=e}})}var r=s.getDialogIdByChatId(t);var u=s.messageLastReadId[t]||0;if(u<=0){e({dialogId:r,lastId:0});return true}s.store.dispatch("messages/readMessages",{chatId:t,readId:u}).then(function(n){s.store.dispatch("dialogues/decreaseCounter",{dialogId:r,count:n.count});if(s.getChatId()===t&&s.store.getters["dialogues/canSaveChat"]){var o=s.store.getters["dialogues/get"](r);if(o.counter<=0){s.store.commit("application/clearDialogExtraCount")}}if(a){e({dialogId:r,lastId:u})}else{s.timer.start("readMessageServer",t,.5,function(){s.restClient.callMethod(i.RestMethod.imDialogRead,{DIALOG_ID:r,MESSAGE_ID:u}).then(function(){return e({dialogId:r,lastId:u})}).catch(function(){return e({dialogId:r,lastId:u})})})}}).catch(function(){e()})})}},{key:"unreadMessage",value:function e(){var t=this;var s=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var a=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var n=this.getChatId();if(typeof this.messageLastReadId[n]==="undefined"){this.messageLastReadId[n]=null}if(typeof this.messageReadQueue[n]==="undefined"){this.messageReadQueue[n]=[]}if(s){this.messageReadQueue[n]=this.messageReadQueue[n].filter(function(e){return e<s})}this.timer.stop("readMessage",n,true);this.timer.stop("readMessageServer",n,true);this.messageLastReadId[n]=s;this.store.dispatch("messages/unreadMessages",{chatId:n,unreadId:this.messageLastReadId[n]}).then(function(e){var r=t.getDialogIdByChatId(n);t.store.dispatch("dialogues/update",{dialogId:r,fields:{unreadId:s}});t.store.dispatch("dialogues/increaseCounter",{dialogId:r,count:e.count});if(!a){t.restClient.callMethod(i.RestMethod.imDialogUnread,{DIALOG_ID:r,MESSAGE_ID:t.messageLastReadId[n]})}}).catch(function(){})}},{key:"shareMessage",value:function e(t,s){this.restClient.callMethod(i.RestMethod.imMessageShare,{DIALOG_ID:this.getDialogId(),MESSAGE_ID:t,TYPE:s});return true}}]);return e}();e.ApplicationController=a})(this.BX.Messenger.Controller=this.BX.Messenger.Controller||{},BX.Messenger,BX.Messenger.Const,BX.Messenger); //# sourceMappingURL=registry.bundle.map.js