Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index c472aea..3526ac2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfeac=['customerAvatar','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','download','user-agent-parser','setUA','headers','getResult','chat','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','difference','ListId','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','List','Contacts','DESC','ChatApplication','account','Applications','list','applications','orderBy','priority','asc','defaults','contact','customerIp','cf-connecting-ip','x-forwarded-for','first','split','firstName','x-real-port','referer','browser','format','%s\x20%s','version','unknown','device','vendor','%s\x20%s\x20%s','stringify','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','lastName','messageId','created','push','*,*,*,*','ChatMessage','AttachmentId','UserId','User','unshift','agent','Start','startRouting','notify','offline','files','createdAt','updatedAt','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','send','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','offlineMessageBody','ChatOfflineMessage','fromString','mimetype','server','attachments','offline-chat','basename','openNewInteraction','sequelize','transaction','Attachment','MailServerOut','Smtp','CloudProvider','forwardOffline','forwardOfflineAddress','sendMail','\x22%s\x22\x20<%s>','offlineMessageSubject','MailAccountId','originalname','subjectOffline','toPairsIn','mapValues','email','Chat','NotifyMailAccount','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','Contact','Owner','fullname','internal','Tags','color','tag','rows','Command','getSnippet','timezone','iftime\x20%s,%s','iftime\x20%s','interval','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','getProactiveActions','License','increment','chatLicenseExceeded','Intervals','all','some','origin','3.1.0','remote','x-real-ip','connection','remoteAddress','virtual','replace','verticalAlignment','labelText','textColor','textButtonColor','color_button','backgroundColor','hideWhenOffline','READ_COMMITTED','bulkCreate','findAndCountAll','finally','getApplications','addProactiveActions','chatProactiveAction','getFields','online','false','offlineForm','onlineForm','items','fromKey','getOfflineMessages','Attachments','addAgents','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','emit','getAgents','bluebird','mustache','util','path','ejs','fs-extra','lodash','querystring','ioredis','../../components/parsers/qs','api','../../config/environment','url','../../mysqldb','redis','localhost','socket.io-emitter','./chatWebsite.socket','html-to-text','jayson/promise','client','http','request','then','info','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','ChatWebsite,\x20%s,\x20%s','result','sendStatus','status','end','offset','undefined','count','limit','set','Content-Range','json','update','destroy','get','UserProfileResource','stack','name','index','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','order','sort','where','filter','VIRTUAL','merge','options','includeAll','include','findAll','show','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ChatWebsiteId','getDispositions','findOne','Disposition','nolimit','pick','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','hasOwnProperty','removeAnswers','addLogo','sitepic','file','filename','addCustomerAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','../../config/license/util','getLicense','custom','existsSync','server/files/images/logos/','getAvatar','isNil','agentAvatar','server/files/images/avatars/','server/files/images/avatars/customer_avatar.png'];(function(_0x208327,_0x26b904){var _0x3127bd=function(_0x424aa6){while(--_0x424aa6){_0x208327['push'](_0x208327['shift']());}};_0x3127bd(++_0x26b904);}(_0xfeac,0xba));var _0xcfea=function(_0x55b433,_0x1de67d){_0x55b433=_0x55b433-0x0;var _0x20e28e=_0xfeac[_0x55b433];return _0x20e28e;};'use strict';var BPromise=require(_0xcfea('0x0'));var Mustache=require(_0xcfea('0x1'));var util=require(_0xcfea('0x2'));var path=require(_0xcfea('0x3'));var ejs=require(_0xcfea('0x4'));var fs=require('fs');var fs_extra=require(_0xcfea('0x5'));var _=require(_0xcfea('0x6'));var querystring=require(_0xcfea('0x7'));var Redis=require(_0xcfea('0x8'));var qs=require(_0xcfea('0x9'));var logger=require('../../config/logger')(_0xcfea('0xa'));var config=require(_0xcfea('0xb'));var url=require(_0xcfea('0xc'));var db=require(_0xcfea('0xd'))['db'];config[_0xcfea('0xe')]=_['defaults'](config[_0xcfea('0xe')],{'host':_0xcfea('0xf'),'port':0x18eb});var socket=require(_0xcfea('0x10'))(new Redis(config[_0xcfea('0xe')]));require(_0xcfea('0x11'))['register'](socket);var htmlToText=require(_0xcfea('0x12'));var jayson=require(_0xcfea('0x13'));var client=jayson[_0xcfea('0x14')][_0xcfea('0x15')]({'port':0x232c});var client9002=jayson[_0xcfea('0x14')][_0xcfea('0x15')]({'port':0x232a});var client9003=jayson[_0xcfea('0x14')][_0xcfea('0x15')]({'port':0x232b});var client9001=jayson[_0xcfea('0x14')]['http']({'port':0x2329});function respondWithRpcPromise(_0x26fd3d,_0x4c7672,_0x14c681,_0x4e3757){return new BPromise(function(_0x2926d6,_0x40e87f){var _0x408e3a=_0x4e3757||client;return _0x408e3a[_0xcfea('0x16')](_0x26fd3d,_0x14c681)[_0xcfea('0x17')](function(_0xa73df5){logger[_0xcfea('0x18')]('ChatWebsite,\x20%s,\x20%s',_0x4c7672,'request\x20sent');logger[_0xcfea('0x19')](_0xcfea('0x1a'),_0x4c7672,_0xcfea('0x1b'),JSON['stringify'](_0xa73df5));if(_0xa73df5[_0xcfea('0x1c')]){if(_0xa73df5[_0xcfea('0x1c')][_0xcfea('0x1d')]===0x1f4){logger[_0xcfea('0x1c')]('ChatWebsite,\x20%s,\x20%s',_0x4c7672,_0xa73df5[_0xcfea('0x1c')][_0xcfea('0x1e')]);return _0x40e87f(_0xa73df5[_0xcfea('0x1c')][_0xcfea('0x1e')]);}logger['error'](_0xcfea('0x1f'),_0x4c7672,_0xa73df5['error']['message']);return _0x2926d6(_0xa73df5['error'][_0xcfea('0x1e')]);}else{logger[_0xcfea('0x18')]('ChatWebsite,\x20%s,\x20%s',_0x4c7672,_0xcfea('0x1b'));_0x2926d6(_0xa73df5[_0xcfea('0x20')][_0xcfea('0x1e')]);}})['catch'](function(_0x1ba1ef){logger[_0xcfea('0x1c')](_0xcfea('0x1f'),_0x4c7672,_0x1ba1ef);_0x40e87f(_0x1ba1ef);});});}function respondWithStatusCode(_0x4cee74,_0x9b738e){_0x9b738e=_0x9b738e||0xcc;return function(_0x3f6637){if(_0x3f6637){return _0x4cee74[_0xcfea('0x21')](_0x9b738e);}return _0x4cee74[_0xcfea('0x22')](_0x9b738e)[_0xcfea('0x23')]();};}function respondWithResult(_0x8038cd,_0x3dcde3){_0x3dcde3=_0x3dcde3||0xc8;return function(_0x3c7434){if(_0x3c7434){return _0x8038cd['status'](_0x3dcde3)['json'](_0x3c7434);}};}function respondWithFilteredResult(_0x5dcd63,_0x67dfa7){return function(_0x16babe){if(_0x16babe){var _0x1e689f=typeof _0x67dfa7[_0xcfea('0x24')]===_0xcfea('0x25')&&typeof _0x67dfa7['limit']===_0xcfea('0x25');var _0x1988b0=_0x16babe['count'];var _0x1c5a69=_0x1e689f?0x0:_0x67dfa7[_0xcfea('0x24')];var _0x3488d6=_0x1e689f?_0x16babe[_0xcfea('0x26')]:_0x67dfa7['offset']+_0x67dfa7[_0xcfea('0x27')];var _0x3279b4;if(_0x3488d6>=_0x1988b0){_0x3488d6=_0x1988b0;_0x3279b4=0xc8;}else{_0x3279b4=0xce;}_0x5dcd63[_0xcfea('0x22')](_0x3279b4);return _0x5dcd63[_0xcfea('0x28')](_0xcfea('0x29'),_0x1c5a69+'-'+_0x3488d6+'/'+_0x1988b0)[_0xcfea('0x2a')](_0x16babe);}return null;};}function saveUpdates(_0x28c14e){return function(_0x3bf88a){if(_0x3bf88a){return _0x3bf88a[_0xcfea('0x2b')](_0x28c14e)[_0xcfea('0x17')](function(_0x539a32){return _0x539a32;});}return null;};}function removeEntity(_0x1b8c6d){return function(_0xba88c0){if(_0xba88c0){return _0xba88c0[_0xcfea('0x2c')]()[_0xcfea('0x17')](function(){var _0x567429=_0xba88c0[_0xcfea('0x2d')]({'plain':!![]});var _0x475e05='ChatWebsites';return db[_0xcfea('0x2e')][_0xcfea('0x2c')]({'where':{'type':_0x475e05,'resourceId':_0x567429['id']}})['then'](function(){return _0xba88c0;});})[_0xcfea('0x17')](function(){_0x1b8c6d[_0xcfea('0x22')](0xcc)['end']();});}};}function handleEntityNotFound(_0x59030c){return function(_0x526d2e){if(!_0x526d2e){_0x59030c[_0xcfea('0x21')](0x194);}return _0x526d2e;};}function handleError(_0x1846a6,_0x8600e3){_0x8600e3=_0x8600e3||0x1f4;return function(_0x530b9d){logger[_0xcfea('0x1c')](_0x530b9d[_0xcfea('0x2f')]);if(_0x530b9d[_0xcfea('0x30')]){delete _0x530b9d[_0xcfea('0x30')];}_0x1846a6[_0xcfea('0x22')](_0x8600e3)['send'](_0x530b9d);};}exports[_0xcfea('0x31')]=function(_0x3a830f,_0x27e748){var _0x582de8={'include':[{'model':db[_0xcfea('0x32')],'as':_0xcfea('0x33')}]},_0x5bd4aa={},_0x55fb3c={'count':0x0,'rows':[]};var _0x546893=_[_0xcfea('0x34')](db[_0xcfea('0x35')][_0xcfea('0x36')],function(_0x20d0f8){return{'name':_0x20d0f8[_0xcfea('0x37')],'type':_0x20d0f8[_0xcfea('0x38')][_0xcfea('0x39')]};});_0x5bd4aa[_0xcfea('0x3a')]=_[_0xcfea('0x34')](_0x546893,_0xcfea('0x30'));_0x5bd4aa[_0xcfea('0x3b')]=_[_0xcfea('0x3c')](_0x3a830f['query']);_0x5bd4aa[_0xcfea('0x3d')]=_[_0xcfea('0x3e')](_0x5bd4aa[_0xcfea('0x3a')],_0x5bd4aa['query']);_0x582de8[_0xcfea('0x3f')]=_[_0xcfea('0x3e')](_0x5bd4aa[_0xcfea('0x3a')],qs[_0xcfea('0x40')](_0x3a830f['query'][_0xcfea('0x40')]));_0x582de8[_0xcfea('0x3f')]=_0x582de8['attributes'][_0xcfea('0x41')]?_0x582de8['attributes']:_0x5bd4aa[_0xcfea('0x3a')];if(!_0x3a830f[_0xcfea('0x3b')]['hasOwnProperty']('nolimit')){_0x582de8[_0xcfea('0x27')]=qs[_0xcfea('0x27')](_0x3a830f['query']['limit']);_0x582de8['offset']=qs[_0xcfea('0x24')](_0x3a830f['query'][_0xcfea('0x24')]);}_0x582de8[_0xcfea('0x42')]=qs[_0xcfea('0x43')](_0x3a830f[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x582de8[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_['pick'](_0x3a830f[_0xcfea('0x3b')],_0x5bd4aa['filters']),_0x546893);if(_0x3a830f[_0xcfea('0x3b')][_0xcfea('0x45')]){_0x582de8[_0xcfea('0x44')]=_['merge'](_0x582de8['where'],{'$or':_[_0xcfea('0x34')](_0x546893,function(_0x1d98cd){if(_0x1d98cd[_0xcfea('0x38')]!==_0xcfea('0x46')){var _0x2a6666={};_0x2a6666[_0x1d98cd[_0xcfea('0x30')]]={'$like':'%'+_0x3a830f['query'][_0xcfea('0x45')]+'%'};return _0x2a6666;}})});}_0x582de8=_[_0xcfea('0x47')]({},_0x582de8,_0x3a830f[_0xcfea('0x48')]);var _0x25ee9b={'where':_0x582de8[_0xcfea('0x44')]};return db[_0xcfea('0x35')][_0xcfea('0x26')](_0x25ee9b)[_0xcfea('0x17')](function(_0x4f2b6d){_0x55fb3c[_0xcfea('0x26')]=_0x4f2b6d;if(_0x3a830f[_0xcfea('0x3b')][_0xcfea('0x49')]){_0x582de8[_0xcfea('0x4a')]=[{'all':!![]}];}return db[_0xcfea('0x35')][_0xcfea('0x4b')](_0x582de8);})[_0xcfea('0x17')](function(_0x47579b){_0x55fb3c['rows']=_0x47579b;return _0x55fb3c;})[_0xcfea('0x17')](respondWithFilteredResult(_0x27e748,_0x582de8))['catch'](handleError(_0x27e748,null));};exports[_0xcfea('0x4c')]=function(_0x3f91a1,_0x3ffb48){var _0x785a3d={'raw':![],'where':{'id':_0x3f91a1[_0xcfea('0x4d')]['id']},'include':[{'model':db[_0xcfea('0x32')],'as':'mandatoryDispositionPause'}]},_0x4b29e9={};_0x4b29e9[_0xcfea('0x3a')]=_['keys'](db[_0xcfea('0x35')]['rawAttributes']);_0x4b29e9[_0xcfea('0x3b')]=_['keys'](_0x3f91a1[_0xcfea('0x3b')]);_0x4b29e9[_0xcfea('0x3d')]=_['intersection'](_0x4b29e9[_0xcfea('0x3a')],_0x4b29e9[_0xcfea('0x3b')]);_0x785a3d[_0xcfea('0x3f')]=_['intersection'](_0x4b29e9[_0xcfea('0x3a')],qs[_0xcfea('0x40')](_0x3f91a1[_0xcfea('0x3b')]['fields']));_0x785a3d['attributes']=_0x785a3d['attributes']['length']?_0x785a3d[_0xcfea('0x3f')]:_0x4b29e9[_0xcfea('0x3a')];if(_0x3f91a1[_0xcfea('0x3b')][_0xcfea('0x49')]){_0x785a3d[_0xcfea('0x4a')]=[{'all':!![]}];}_0x785a3d=_[_0xcfea('0x47')]({},_0x785a3d,_0x3f91a1[_0xcfea('0x48')]);return db['ChatWebsite'][_0xcfea('0x4e')](_0x785a3d)[_0xcfea('0x17')](handleEntityNotFound(_0x3ffb48,null))[_0xcfea('0x17')](respondWithResult(_0x3ffb48,null))['catch'](handleError(_0x3ffb48,null));};exports[_0xcfea('0x4f')]=function(_0x3e4fea,_0x14ab74){return db[_0xcfea('0x35')]['create'](_0x3e4fea[_0xcfea('0x50')],{})[_0xcfea('0x17')](function(_0x4d9fd0){var _0x3accbb=_0x3e4fea[_0xcfea('0x51')][_0xcfea('0x2d')]({'plain':!![]});if(!_0x3accbb)throw new Error(_0xcfea('0x52'));if(_0x3accbb[_0xcfea('0x53')]==='user'){var _0x4f7752=_0x4d9fd0[_0xcfea('0x2d')]({'plain':!![]});var _0x5ad7d7='ChatWebsites';return db[_0xcfea('0x54')][_0xcfea('0x4e')]({'where':{'name':_0x5ad7d7,'userProfileId':_0x3accbb[_0xcfea('0x55')]},'raw':!![]})['then'](function(_0x35e6f9){if(_0x35e6f9&&_0x35e6f9['autoAssociation']===0x0){return db[_0xcfea('0x2e')][_0xcfea('0x4f')]({'name':_0x4f7752[_0xcfea('0x30')],'resourceId':_0x4f7752['id'],'type':_0x35e6f9[_0xcfea('0x30')],'sectionId':_0x35e6f9['id']},{})[_0xcfea('0x17')](function(){return _0x4d9fd0;});}else{return _0x4d9fd0;}})[_0xcfea('0x56')](function(_0x21c18f){logger[_0xcfea('0x1c')](_0xcfea('0x57'),_0x21c18f);throw _0x21c18f;});}return _0x4d9fd0;})[_0xcfea('0x17')](respondWithResult(_0x14ab74,0xc9))[_0xcfea('0x56')](handleError(_0x14ab74,null));};exports['update']=function(_0x1f6677,_0x574188){if(_0x1f6677[_0xcfea('0x50')]['id']){delete _0x1f6677['body']['id'];}return db['ChatWebsite'][_0xcfea('0x4e')]({'where':{'id':_0x1f6677[_0xcfea('0x4d')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]})['then'](handleEntityNotFound(_0x574188,null))[_0xcfea('0x17')](saveUpdates(_0x1f6677[_0xcfea('0x50')],null))[_0xcfea('0x17')](respondWithResult(_0x574188,null))['catch'](handleError(_0x574188,null));};exports[_0xcfea('0x2c')]=function(_0x70ae5f,_0x21f7ad){return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x70ae5f[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x21f7ad,null))[_0xcfea('0x17')](removeEntity(_0x21f7ad,null))['catch'](handleError(_0x21f7ad,null));};exports[_0xcfea('0x58')]=function(_0x1a44cb,_0x5cb1b8){return db['ChatWebsite'][_0xcfea('0x58')]()[_0xcfea('0x17')](respondWithResult(_0x5cb1b8,null))[_0xcfea('0x56')](handleError(_0x5cb1b8,null));};exports[_0xcfea('0x59')]=function(_0x5c1066,_0x42010c){if(_0x5c1066[_0xcfea('0x50')]['id']){delete _0x5c1066[_0xcfea('0x50')]['id'];}return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x5c1066['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x42010c,null))[_0xcfea('0x17')](function(_0x479d03){if(_0x479d03){_0x5c1066['body'][_0xcfea('0x5a')]=_0x479d03['id'];return db['Disposition'][_0xcfea('0x4f')](_0x5c1066['body']);}})[_0xcfea('0x17')](respondWithResult(_0x42010c,null))['catch'](handleError(_0x42010c,null));};exports[_0xcfea('0x5b')]=function(_0x3b51f6,_0xd9df9d){var _0x3eab88={'raw':![],'where':{}};var _0x5d5990={};var _0x4a2a88={'count':0x0,'rows':[]};return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x3b51f6[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0xd9df9d,null))['then'](function(_0x29de50){if(_0x29de50){_0x5d5990['model']=_[_0xcfea('0x3c')](db[_0xcfea('0x5d')][_0xcfea('0x36')]);_0x5d5990[_0xcfea('0x3b')]=_['keys'](_0x3b51f6[_0xcfea('0x3b')]);_0x5d5990[_0xcfea('0x3d')]=_[_0xcfea('0x3e')](_0x5d5990['model'],_0x5d5990[_0xcfea('0x3b')]);_0x3eab88[_0xcfea('0x3f')]=_['intersection'](_0x5d5990[_0xcfea('0x3a')],qs[_0xcfea('0x40')](_0x3b51f6[_0xcfea('0x3b')]['fields']));_0x3eab88[_0xcfea('0x3f')]=_0x3eab88[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x3eab88[_0xcfea('0x3f')]:_0x5d5990[_0xcfea('0x3a')];if(!_0x3b51f6['query']['hasOwnProperty'](_0xcfea('0x5e'))){_0x3eab88['limit']=qs[_0xcfea('0x27')](_0x3b51f6[_0xcfea('0x3b')][_0xcfea('0x27')]);_0x3eab88[_0xcfea('0x24')]=qs[_0xcfea('0x24')](_0x3b51f6[_0xcfea('0x3b')]['offset']);}_0x3eab88[_0xcfea('0x42')]=qs[_0xcfea('0x43')](_0x3b51f6[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x3eab88[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_[_0xcfea('0x5f')](_0x3b51f6[_0xcfea('0x3b')],_0x5d5990['filters']));_0x3eab88[_0xcfea('0x44')][_0xcfea('0x5a')]=_0x29de50['id'];if(_0x3b51f6[_0xcfea('0x3b')][_0xcfea('0x45')]){_0x3eab88[_0xcfea('0x44')]=_[_0xcfea('0x47')](_0x3eab88[_0xcfea('0x44')],{'$or':_[_0xcfea('0x34')](_0x3eab88[_0xcfea('0x3f')],function(_0x457208){var _0x5d273f={};_0x5d273f[_0x457208]={'$like':'%'+_0x3b51f6[_0xcfea('0x3b')][_0xcfea('0x45')]+'%'};return _0x5d273f;})});}_0x3eab88=_['merge']({},_0x3eab88,_0x3b51f6[_0xcfea('0x48')]);return db[_0xcfea('0x5d')][_0xcfea('0x26')]({'where':_0x3eab88[_0xcfea('0x44')]})[_0xcfea('0x17')](function(_0xcbca8d){_0x4a2a88[_0xcfea('0x26')]=_0xcbca8d;if(_0x3b51f6[_0xcfea('0x3b')][_0xcfea('0x49')]){_0x3eab88[_0xcfea('0x4a')]=[{'all':!![]}];}return db['Disposition'][_0xcfea('0x4b')](_0x3eab88);})['then'](function(_0x4d08d5){_0x4a2a88['rows']=_0x4d08d5;return _0x4a2a88;});}})['then'](respondWithFilteredResult(_0xd9df9d,_0x3eab88))[_0xcfea('0x56')](handleError(_0xd9df9d,null));};exports[_0xcfea('0x60')]=function(_0xe4f178,_0xa244ae){return db['ChatWebsite'][_0xcfea('0x4e')]({'where':{'id':_0xe4f178[_0xcfea('0x4d')]['id']}})['then'](handleEntityNotFound(_0xa244ae,null))[_0xcfea('0x17')](function(_0x59998f){if(_0x59998f){return _0x59998f['removeDispositions'](_0xe4f178[_0xcfea('0x3b')][_0xcfea('0x61')]);}})['then'](respondWithStatusCode(_0xa244ae,null))[_0xcfea('0x56')](handleError(_0xa244ae,null));};exports[_0xcfea('0x62')]=function(_0x4071d2,_0x4b7b32){if(_0x4071d2[_0xcfea('0x50')]['id']){delete _0x4071d2[_0xcfea('0x50')]['id'];}return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x4071d2[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x4b7b32,null))[_0xcfea('0x17')](function(_0x141535){if(_0x141535){_0x4071d2['body']['ChatWebsiteId']=_0x141535['id'];return db[_0xcfea('0x63')][_0xcfea('0x4f')](_0x4071d2[_0xcfea('0x50')]);}})['then'](respondWithResult(_0x4b7b32,null))[_0xcfea('0x56')](handleError(_0x4b7b32,null));};exports[_0xcfea('0x64')]=function(_0x5f0e1c,_0x40e39d){var _0x299ae5={'raw':![],'where':{}};var _0x1f6438={};var _0x34ece2={'count':0x0,'rows':[]};return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x5f0e1c['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x40e39d,null))[_0xcfea('0x17')](function(_0x75a111){if(_0x75a111){_0x1f6438[_0xcfea('0x3a')]=_[_0xcfea('0x3c')](db[_0xcfea('0x63')][_0xcfea('0x36')]);_0x1f6438['query']=_[_0xcfea('0x3c')](_0x5f0e1c[_0xcfea('0x3b')]);_0x1f6438[_0xcfea('0x3d')]=_[_0xcfea('0x3e')](_0x1f6438[_0xcfea('0x3a')],_0x1f6438[_0xcfea('0x3b')]);_0x299ae5[_0xcfea('0x3f')]=_[_0xcfea('0x3e')](_0x1f6438[_0xcfea('0x3a')],qs[_0xcfea('0x40')](_0x5f0e1c['query'][_0xcfea('0x40')]));_0x299ae5[_0xcfea('0x3f')]=_0x299ae5[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x299ae5['attributes']:_0x1f6438[_0xcfea('0x3a')];if(!_0x5f0e1c[_0xcfea('0x3b')][_0xcfea('0x65')](_0xcfea('0x5e'))){_0x299ae5[_0xcfea('0x27')]=qs[_0xcfea('0x27')](_0x5f0e1c['query']['limit']);_0x299ae5[_0xcfea('0x24')]=qs[_0xcfea('0x24')](_0x5f0e1c[_0xcfea('0x3b')][_0xcfea('0x24')]);}_0x299ae5[_0xcfea('0x42')]=qs[_0xcfea('0x43')](_0x5f0e1c[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x299ae5[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_[_0xcfea('0x5f')](_0x5f0e1c[_0xcfea('0x3b')],_0x1f6438['filters']));_0x299ae5['where'][_0xcfea('0x5a')]=_0x75a111['id'];if(_0x5f0e1c[_0xcfea('0x3b')]['filter']){_0x299ae5[_0xcfea('0x44')]=_[_0xcfea('0x47')](_0x299ae5['where'],{'$or':_[_0xcfea('0x34')](_0x299ae5[_0xcfea('0x3f')],function(_0x544303){var _0x593293={};_0x593293[_0x544303]={'$like':'%'+_0x5f0e1c[_0xcfea('0x3b')][_0xcfea('0x45')]+'%'};return _0x593293;})});}_0x299ae5=_[_0xcfea('0x47')]({},_0x299ae5,_0x5f0e1c[_0xcfea('0x48')]);return db['CannedAnswer']['count']({'where':_0x299ae5[_0xcfea('0x44')]})['then'](function(_0x3b8fe3){_0x34ece2['count']=_0x3b8fe3;if(_0x5f0e1c[_0xcfea('0x3b')][_0xcfea('0x49')]){_0x299ae5[_0xcfea('0x4a')]=[{'all':!![]}];}return db['CannedAnswer'][_0xcfea('0x4b')](_0x299ae5);})[_0xcfea('0x17')](function(_0xa277bb){_0x34ece2['rows']=_0xa277bb;return _0x34ece2;});}})[_0xcfea('0x17')](respondWithFilteredResult(_0x40e39d,_0x299ae5))['catch'](handleError(_0x40e39d,null));};exports[_0xcfea('0x66')]=function(_0x319a81,_0x2a3a07){return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x319a81[_0xcfea('0x4d')]['id']}})['then'](handleEntityNotFound(_0x2a3a07,null))[_0xcfea('0x17')](function(_0x439ab5){if(_0x439ab5){return _0x439ab5[_0xcfea('0x66')](_0x319a81[_0xcfea('0x3b')][_0xcfea('0x61')]);}})[_0xcfea('0x17')](respondWithStatusCode(_0x2a3a07,null))['catch'](handleError(_0x2a3a07,null));};exports[_0xcfea('0x67')]=function(_0x3dbe2f,_0x1286f5){_0x3dbe2f[_0xcfea('0x50')][_0xcfea('0x68')]=_0x3dbe2f[_0xcfea('0x69')][_0xcfea('0x6a')];return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x3dbe2f['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x1286f5,null))[_0xcfea('0x17')](saveUpdates(_0x3dbe2f[_0xcfea('0x50')],null))[_0xcfea('0x17')](respondWithResult(_0x1286f5,null))[_0xcfea('0x56')](handleError(_0x1286f5,null));};exports['addAvatar']=function(_0x7dc116,_0x348e65){_0x7dc116['body']['agentAvatar']=_0x7dc116[_0xcfea('0x69')][_0xcfea('0x6a')];return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x7dc116['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x348e65,null))[_0xcfea('0x17')](saveUpdates(_0x7dc116[_0xcfea('0x50')],null))[_0xcfea('0x17')](respondWithResult(_0x348e65,null))[_0xcfea('0x56')](handleError(_0x348e65,null));};exports[_0xcfea('0x6b')]=function(_0x5704ee,_0x3709f7){_0x5704ee[_0xcfea('0x50')]['customerAvatar']=_0x5704ee[_0xcfea('0x69')]['filename'];return db[_0xcfea('0x35')]['find']({'where':{'id':_0x5704ee[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x3709f7,null))[_0xcfea('0x17')](saveUpdates(_0x5704ee['body'],null))[_0xcfea('0x17')](respondWithResult(_0x3709f7,null))[_0xcfea('0x56')](handleError(_0x3709f7,null));};exports[_0xcfea('0x6c')]=function(_0x59613a,_0x5b5836){_0x59613a[_0xcfea('0x50')][_0xcfea('0x6d')]=_0x59613a['file'][_0xcfea('0x6a')];return db['ChatWebsite'][_0xcfea('0x4e')]({'where':{'id':_0x59613a[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x5b5836,null))[_0xcfea('0x17')](saveUpdates(_0x59613a[_0xcfea('0x50')],null))[_0xcfea('0x17')](respondWithResult(_0x5b5836,null))[_0xcfea('0x56')](handleError(_0x5b5836,null));};exports[_0xcfea('0x6e')]=function(_0x6fd62f,_0xe2356d){var _0x452825=path[_0xcfea('0x6f')](config[_0xcfea('0x70')],_0xcfea('0x71'));var _0x2935be={'where':{'id':_0x6fd62f[_0xcfea('0x4d')]['id']},'attributes':['id',_0xcfea('0x68')],'raw':!![]};var _0x461568=![];return require(_0xcfea('0x72'))[_0xcfea('0x73')]()['then'](function(_0x4101a5){if(_0x4101a5){_0x461568=_0x4101a5[_0xcfea('0x74')];}})[_0xcfea('0x17')](function(){return db[_0xcfea('0x35')][_0xcfea('0x4e')](_0x2935be);})['then'](handleEntityNotFound(_0xe2356d,null))[_0xcfea('0x17')](function(_0x5ecfe5){if(_0x5ecfe5){if(!_['isNil'](_0x5ecfe5['sitepic'])){if(fs[_0xcfea('0x75')](path[_0xcfea('0x6f')](config[_0xcfea('0x70')],_0xcfea('0x76'),_0x5ecfe5[_0xcfea('0x68')]))&&_0x461568){_0x452825=path['join'](config[_0xcfea('0x70')],_0xcfea('0x76'),_0x5ecfe5[_0xcfea('0x68')]);}}return _0xe2356d['download'](_0x452825);}})['catch'](handleError(_0xe2356d,null));};exports[_0xcfea('0x77')]=function(_0xa23629,_0x578aa2){var _0x4ae185=path['join'](config['root'],'server/files/images/avatars/default_avatar.png');var _0x146ed0={'where':{'id':_0xa23629[_0xcfea('0x4d')]['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db[_0xcfea('0x35')][_0xcfea('0x4e')](_0x146ed0)['then'](handleEntityNotFound(_0x578aa2,null))[_0xcfea('0x17')](function(_0x501ec3){if(_0x501ec3){if(!_[_0xcfea('0x78')](_0x501ec3[_0xcfea('0x79')])){if(fs[_0xcfea('0x75')](path[_0xcfea('0x6f')](config['root'],'server/files/images/avatars/',_0x501ec3['agentAvatar']))){_0x4ae185=path[_0xcfea('0x6f')](config[_0xcfea('0x70')],_0xcfea('0x7a'),_0x501ec3['agentAvatar']);}}return _0x578aa2['download'](_0x4ae185);}})[_0xcfea('0x56')](handleError(_0x578aa2,null));};exports['getCustomerAvatar']=function(_0x432491,_0x4ac594){var _0x15ebbc=path['join'](config[_0xcfea('0x70')],_0xcfea('0x7b'));var _0x39f48a={'where':{'id':_0x432491['params']['id']},'attributes':['id',_0xcfea('0x7c'),_0xcfea('0x7d')],'raw':!![]};return db[_0xcfea('0x35')]['find'](_0x39f48a)[_0xcfea('0x17')](handleEntityNotFound(_0x4ac594,null))[_0xcfea('0x17')](function(_0x5d0934){if(_0x5d0934){if(!_[_0xcfea('0x78')](_0x5d0934[_0xcfea('0x7c')])){if(fs[_0xcfea('0x75')](path[_0xcfea('0x6f')](config['root'],_0xcfea('0x7a'),_0x5d0934[_0xcfea('0x7c')]))&&_0x5d0934[_0xcfea('0x7d')]){_0x15ebbc=path[_0xcfea('0x6f')](config['root'],'server/files/images/avatars/',_0x5d0934[_0xcfea('0x7c')]);}}return _0x4ac594['download'](_0x15ebbc);}})[_0xcfea('0x56')](handleError(_0x4ac594,null));};exports[_0xcfea('0x7e')]=function(_0x47c5b9,_0x15c10e){var _0x540ced=path[_0xcfea('0x6f')](config['root'],_0xcfea('0x7f'));var _0x224fe6={'where':{'id':_0x47c5b9[_0xcfea('0x4d')]['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db[_0xcfea('0x35')]['find'](_0x224fe6)[_0xcfea('0x17')](handleEntityNotFound(_0x15c10e,null))['then'](function(_0x104bb7){if(_0x104bb7){if(!_[_0xcfea('0x78')](_0x104bb7['systemAvatar'])){if(fs['existsSync'](path[_0xcfea('0x6f')](config[_0xcfea('0x70')],'server/files/images/avatars/',_0x104bb7[_0xcfea('0x6d')]))){_0x540ced=path[_0xcfea('0x6f')](config[_0xcfea('0x70')],'server/files/images/avatars/',_0x104bb7[_0xcfea('0x6d')]);}}return _0x15c10e[_0xcfea('0x80')](_0x540ced);}})[_0xcfea('0x56')](handleError(_0x15c10e,null));};exports['notify']=function(_0x517dfd,_0x3fcdbd){var _0x5a69df=require(_0xcfea('0x81'));var _0x518401=new _0x5a69df();var _0x59c771=_0x518401[_0xcfea('0x82')](_0x517dfd[_0xcfea('0x83')]['user-agent'])[_0xcfea('0x84')]();var _0x5b8ef0={'body':_0x517dfd[_0xcfea('0x50')],'channel':_0xcfea('0x85')};var _0x3f30dd=[];var _0x3872e6=[];var _0x370ff3={};var _0x5f2500=![];return db[_0xcfea('0x86')][_0xcfea('0x58')]()['then'](function(_0x2c3f13){if(!_0x2c3f13){throw new db[(_0xcfea('0x87'))][(_0xcfea('0x88'))](_0xcfea('0x89'));}_0x3f30dd=_[_0xcfea('0x8a')](_[_0xcfea('0x3c')](_0x2c3f13),['createdAt','updatedAt']);_0x3872e6=_[_0xcfea('0x8a')](_['keys'](_0x2c3f13),['createdAt','updatedAt','CompanyId',_0xcfea('0x8b')]);if(_0x517dfd[_0xcfea('0x50')]['id']){delete _0x517dfd['body']['id'];}if(_['isNil'](_0x517dfd['body'][_0xcfea('0x8c')])){throw new db[(_0xcfea('0x87'))]['ValidationError'](_0xcfea('0x8d'));}if(_[_0xcfea('0x78')](_0x517dfd[_0xcfea('0x50')][_0xcfea('0x50')])||_0x517dfd[_0xcfea('0x50')][_0xcfea('0x50')]===''){throw new db[(_0xcfea('0x87'))][(_0xcfea('0x88'))](_0xcfea('0x8e'));}if(_[_0xcfea('0x78')](_0x517dfd[_0xcfea('0x50')][_0xcfea('0x8f')])){throw new db[(_0xcfea('0x87'))][(_0xcfea('0x88'))](_0xcfea('0x90')+_0x3872e6);}if(!_[_0xcfea('0x91')](_0x3872e6,_0x517dfd['body'][_0xcfea('0x8f')])){throw new db[(_0xcfea('0x87'))]['ValidationError'](_0xcfea('0x92')+_0x3872e6);}_0x370ff3[_0x517dfd[_0xcfea('0x50')][_0xcfea('0x8f')]]=_0x517dfd[_0xcfea('0x50')][_0xcfea('0x8c')];})['then'](function(){return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x517dfd[_0xcfea('0x4d')]['id']},'include':[{'model':db['CmList'],'as':_0xcfea('0x93'),'include':[{'model':db['CmContact'],'as':_0xcfea('0x94'),'where':_0x370ff3,'limit':0x1,'order':[['updatedAt',_0xcfea('0x95')]]}]},{'model':db[_0xcfea('0x96')],'as':'Applications'}]});})[_0xcfea('0x17')](handleEntityNotFound(_0x3fcdbd,null))[_0xcfea('0x17')](function(_0x404470){if(_0x404470&&_0x404470[_0xcfea('0x93')]){_0x5b8ef0[_0xcfea('0x97')]=_0x404470;_0x5b8ef0['applications']=_0x404470[_0xcfea('0x98')];_0x5b8ef0[_0xcfea('0x99')]=_0x404470[_0xcfea('0x93')];_0x5b8ef0[_0xcfea('0x9a')]=_[_0xcfea('0x9b')](_0x5b8ef0['applications'],[_0xcfea('0x9c')],[_0xcfea('0x9d')]);if(_0x5b8ef0[_0xcfea('0x97')][_0xcfea('0x98')]){delete _0x5b8ef0[_0xcfea('0x97')]['Applications'];}if(_0x5b8ef0['account'][_0xcfea('0x93')]&&_0x5b8ef0[_0xcfea('0x97')][_0xcfea('0x93')][_0xcfea('0x94')][_0xcfea('0x41')]){return _0x5b8ef0[_0xcfea('0x97')][_0xcfea('0x93')][_0xcfea('0x94')][0x0];}var _0x13d11d=_[_0xcfea('0x9e')](_0x517dfd[_0xcfea('0x50')],{'firstName':_0x517dfd['body'][_0xcfea('0x8c')],'ListId':_0x404470[_0xcfea('0x8b')]});_0x13d11d[_0x517dfd[_0xcfea('0x50')]['mapKey']]=_0x517dfd[_0xcfea('0x50')][_0xcfea('0x8c')];return db[_0xcfea('0x86')][_0xcfea('0x4f')](_0x13d11d,{'fields':_0x3f30dd,'raw':!![]});}})['then'](handleEntityNotFound(_0x3fcdbd,null))['then'](function(_0x211b8c){_0x5b8ef0[_0xcfea('0x9f')]=_0x211b8c;var _0x1561c8=_0x517dfd[_0xcfea('0x50')][_0xcfea('0xa0')];if(_0x517dfd[_0xcfea('0x83')][_0xcfea('0xa1')]){_0x1561c8=_0x517dfd[_0xcfea('0x83')][_0xcfea('0xa1')];}else if(_0x517dfd[_0xcfea('0x83')][_0xcfea('0xa2')]){_0x1561c8=_[_0xcfea('0xa3')](_0x517dfd['headers'][_0xcfea('0xa2')][_0xcfea('0xa4')](','));}if(_0x211b8c){var _0xbceae8={'ContactId':_0x211b8c['id'],'ChatWebsiteId':_0x517dfd['params']['id'],'from':(_0x211b8c[_0xcfea('0xa5')]||'')+'\x20'+(_0x211b8c['lastName']||''),'customerIp':_0x1561c8,'customerPort':_0x517dfd['headers']['x-real-port']?_0x517dfd[_0xcfea('0x83')][_0xcfea('0xa6')]:null,'referer':_0x517dfd[_0xcfea('0x50')][_0xcfea('0xa7')],'browserName':_0x59c771['browser'][_0xcfea('0x30')]&&_0x59c771[_0xcfea('0xa8')]['version']?util[_0xcfea('0xa9')](_0xcfea('0xaa'),_0x59c771[_0xcfea('0xa8')][_0xcfea('0x30')],_0x59c771[_0xcfea('0xa8')][_0xcfea('0xab')]):_0xcfea('0xac'),'browserVersion':_0x59c771[_0xcfea('0xa8')][_0xcfea('0xab')]||_0xcfea('0xac'),'osName':util['format'](_0xcfea('0xaa'),_0x59c771['os']['name'],_0x59c771['os']['version']),'osVersion':_0x59c771['os'][_0xcfea('0xab')],'deviceModel':_0x59c771['device'][_0xcfea('0x3a')]&&_0x59c771[_0xcfea('0xad')][_0xcfea('0xae')]?util[_0xcfea('0xa9')](_0xcfea('0xaf'),_0x59c771[_0xcfea('0xad')][_0xcfea('0x3a')],_0x59c771[_0xcfea('0xad')][_0xcfea('0xae')],_0x59c771[_0xcfea('0xad')][_0xcfea('0x38')]):null,'deviceVendor':_0x59c771['device'][_0xcfea('0xae')],'deviceType':_0x59c771[_0xcfea('0xad')][_0xcfea('0x38')],'formData':JSON[_0xcfea('0xb0')](_0x517dfd[_0xcfea('0x50')])};var _0x242b9e={'ChatWebsiteId':_0x517dfd['params']['id'],'closed':![]};if(_0x517dfd[_0xcfea('0x50')]['threadId']){_0x242b9e[_0xcfea('0xb1')]=_0x517dfd['body'][_0xcfea('0xb1')];return db[_0xcfea('0xb2')]['find']({'where':_0x242b9e})[_0xcfea('0x17')](function(_0x153019){if(_0x153019){return[_0x153019,![]];}_0xbceae8['threadId']=_0x517dfd[_0xcfea('0x50')][_0xcfea('0xb1')];_0xbceae8[_0xcfea('0xb3')]=_0x517dfd[_0xcfea('0x50')][_0xcfea('0xb3')];return db[_0xcfea('0xb2')][_0xcfea('0x4f')](_0xbceae8)['then'](function(_0x5f3982){return[_0x5f3982,!![]];});});}_0x242b9e[_0xcfea('0xb4')]=_0x211b8c['id'];if(_0x517dfd[_0xcfea('0x50')]['interaction']&&_0x517dfd[_0xcfea('0x50')]['interaction']['id']){_0x242b9e['id']=_0x517dfd[_0xcfea('0x50')][_0xcfea('0xb5')]['id'];return db[_0xcfea('0xb2')]['find']({'where':_0x242b9e})['then'](function(_0x3ee281){if(_0x3ee281){return[_0x3ee281,![]];}return db[_0xcfea('0xb2')][_0xcfea('0x4f')](_0xbceae8)[_0xcfea('0x17')](function(_0x263f02){return[_0x263f02,!![]];});});}return db[_0xcfea('0xb2')]['create'](_0xbceae8)['then'](function(_0x4de82e){return[_0x4de82e,!![]];});}})[_0xcfea('0xb6')](function(_0x3a0ca8,_0x2d6f49){if(_0x3a0ca8){_0x5f2500=_0x2d6f49;if(!_0x2d6f49){var _0x484862={'from':(_0x5b8ef0['contact'][_0xcfea('0xa5')]||'')+'\x20'+(_0x5b8ef0[_0xcfea('0x9f')][_0xcfea('0xb7')]||'')};if(_0x517dfd['body'][_0xcfea('0xb1')]&&_0x517dfd[_0xcfea('0x50')]['messageId']&&_0x517dfd[_0xcfea('0x50')]['threadId']!=_0x517dfd[_0xcfea('0x50')][_0xcfea('0xb8')]){_0x484862[_0xcfea('0xb1')]=_0x517dfd[_0xcfea('0x50')][_0xcfea('0xb8')];}return _0x3a0ca8[_0xcfea('0x2b')](_0x484862);}else{return _0x3a0ca8;}}})[_0xcfea('0x17')](function(_0x1cad09){_0x5b8ef0[_0xcfea('0xb5')]=_0x1cad09[_0xcfea('0x2d')]({'plain':!![]});_0x5b8ef0[_0xcfea('0xb5')][_0xcfea('0xb9')]=_0x5f2500;if(_0x5b8ef0[_0xcfea('0xb5')][_0xcfea('0xb9')]){if(_0x5b8ef0[_0xcfea('0x97')]['autoclose']){_0x5b8ef0[_0xcfea('0x9a')][_0xcfea('0xba')]({'id':0x0,'priority':_0x5b8ef0[_0xcfea('0x9a')][_0xcfea('0x41')]+0x1,'app':'close','appdata':'unmanaged','interval':_0xcfea('0xbb')});}}return db[_0xcfea('0xbc')][_0xcfea('0x4f')]({'body':_0x517dfd[_0xcfea('0x50')]['body'],'ChatWebsiteId':_0x517dfd[_0xcfea('0x4d')]['id'],'ChatInteractionId':_0x1cad09['id'],'direction':'in','ContactId':_0x5b8ef0['contact']['id'],'AttachmentId':_0x517dfd[_0xcfea('0x50')][_0xcfea('0xbd')]});})[_0xcfea('0x17')](function(_0x4a736f){_0x5b8ef0['message']=_0x4a736f;if(_0x5b8ef0['interaction'][_0xcfea('0xbe')]){return db[_0xcfea('0xbf')][_0xcfea('0x4e')]({'attributes':['id','name'],'where':{'id':_0x5b8ef0[_0xcfea('0xb5')][_0xcfea('0xbe')]}})[_0xcfea('0x17')](function(_0x5b579f){if(_0x5b579f){_0x5b8ef0[_0xcfea('0x9a')][_0xcfea('0xc0')]({'id':0x0,'priority':0x0,'app':_0xcfea('0xc1'),'appdata':_0x5b579f['name']+','+(_0x5b8ef0[_0xcfea('0x97')]['waitForTheAssignedAgent']||0xa),'interval':_0xcfea('0xbb')});_0x5b8ef0['forcedOwnership']=!![];}return respondWithRpcPromise(_0xcfea('0xc2'),_0xcfea('0xc3'),_0x5b8ef0);});}return respondWithRpcPromise(_0xcfea('0xc2'),'startRouting',_0x5b8ef0);})[_0xcfea('0x17')](function(_0x2e60dd){respondWithRpcPromise('EventManager','EventManager',{'event':_0xcfea('0xc4'),'message':_0x2e60dd},client9002);return _0x2e60dd;})[_0xcfea('0x17')](respondWithResult(_0x3fcdbd,null))['catch'](handleError(_0x3fcdbd,null));};exports[_0xcfea('0xc5')]=function(_0x2000bd,_0x366bc3){var _0x15e81a,_0x41a19e,_0x766279;var _0x5f59df=[];var _0x171eaf={};var _0x3d5e62=_0x2000bd[_0xcfea('0xc6')]||[];var _0x48604f=[];var _0x5b97f6;return db[_0xcfea('0x86')][_0xcfea('0x58')]()[_0xcfea('0x17')](function(_0x907ef1){if(!_0x907ef1){throw new db['Sequelize'][(_0xcfea('0x88'))]('no\x20available\x20attributes');}_0x5f59df=_[_0xcfea('0x8a')](_['keys'](_0x907ef1),[_0xcfea('0xc7'),_0xcfea('0xc8'),'CompanyId',_0xcfea('0x8b')]);if(_0x2000bd[_0xcfea('0x50')]['id']){delete _0x2000bd[_0xcfea('0x50')]['id'];}if(_[_0xcfea('0x78')](_0x2000bd['body']['from'])){throw _0x366bc3['status'](0x1f4)['send'](new db[(_0xcfea('0x87'))][(_0xcfea('0x88'))](_0xcfea('0x8d')));}if(_['isNil'](_0x2000bd['body'][_0xcfea('0x50')])||_0x2000bd['body'][_0xcfea('0x50')]===''){throw _0x366bc3[_0xcfea('0x22')](0x1f4)['send'](new db[(_0xcfea('0x87'))]['ValidationError'](_0xcfea('0x8e')));}if(_[_0xcfea('0x78')](_0x2000bd[_0xcfea('0x50')][_0xcfea('0xc9')])){throw _0x366bc3['status'](0x1f4)['send'](new db[(_0xcfea('0x87'))][(_0xcfea('0x88'))](_0xcfea('0xca')+_0x5f59df));}if(!_[_0xcfea('0x91')](_0x5f59df,_0x2000bd[_0xcfea('0x50')][_0xcfea('0xc9')])){throw _0x366bc3[_0xcfea('0x22')](0x1f4)[_0xcfea('0xcb')](new db[(_0xcfea('0x87'))][(_0xcfea('0x88'))](_0xcfea('0xcc')+_0x5f59df));}_0x171eaf[_0x2000bd[_0xcfea('0x50')][_0xcfea('0xc9')]]=_0x2000bd[_0xcfea('0x50')][_0xcfea('0x8c')];})['then'](function(){return db['ChatWebsite'][_0xcfea('0x4e')]({'where':{'id':_0x2000bd['params']['id']},'include':[{'model':db['CmList'],'as':_0xcfea('0x93')},{'model':db[_0xcfea('0xcd')],'as':_0xcfea('0xcd')}]});})[_0xcfea('0x17')](handleEntityNotFound(_0x366bc3,null))[_0xcfea('0x17')](function(_0x366ef6){if(_0x366ef6&&_0x366ef6[_0xcfea('0x93')]){_0x41a19e=_0x366ef6;var _0x148b22=_[_0xcfea('0x9e')](_0x2000bd[_0xcfea('0x50')],{'firstName':_0x2000bd['body'][_0xcfea('0x8c')],'phone':_0x2000bd[_0xcfea('0x50')][_0xcfea('0x8c')],'ListId':_0x366ef6['ListId']});_0x148b22[_0x2000bd[_0xcfea('0x50')]['mapKeyOffline']]=_0x2000bd[_0xcfea('0x50')]['from'];return db[_0xcfea('0x86')][_0xcfea('0xce')]({'where':_0x171eaf,'defaults':_0x148b22});}})[_0xcfea('0xb6')](function(_0x3a21ca){if(_0x3a21ca){_0x766279=_0x3a21ca;var _0x470634=fs[_0xcfea('0xcf')](path[_0xcfea('0x6f')](config['root'],_0xcfea('0xd0')),_0xcfea('0xd1'));var _0x3a394b=ejs[_0xcfea('0xd2')](_0x470634,{'body':_['toPairs'](_0x2000bd['body'][_0xcfea('0x50')]),'bodyTitle':_0x41a19e[_0xcfea('0xd3')]});return db[_0xcfea('0xd4')][_0xcfea('0x4f')]({'body':_0x3a394b,'plainBody':htmlToText[_0xcfea('0xd5')](_0x3a394b),'ContactId':_0x3a21ca['id'],'ChatWebsiteId':_0x41a19e['id']});}})[_0xcfea('0x17')](function(_0x5a123a){_0x5b97f6=_0x5a123a;if(_0x3d5e62[_0xcfea('0x41')]){var _0x45bbf5=_0x3d5e62['map'](function(_0xadb458){return{'name':_0xadb458['originalname'],'basename':_0xadb458['filename'],'type':_0xadb458[_0xcfea('0xd6')],'ChatOfflineMessageId':_0x5a123a['id']};});_0x48604f=_0x45bbf5[_0xcfea('0x34')](_0x496f74=>{var _0x1e85c2={'filename':_0x496f74[_0xcfea('0x30')],'path':path[_0xcfea('0x6f')](config['root'],_0xcfea('0xd7'),_0xcfea('0xc6'),_0xcfea('0xd8'),_0xcfea('0xd9'),_0x496f74[_0xcfea('0xda')])};return _0x1e85c2;});if(!_0x41a19e[_0xcfea('0xdb')]){return db[_0xcfea('0xdc')][_0xcfea('0xdd')](function(_0x114b98){return db[_0xcfea('0xde')]['bulkCreate'](_0x45bbf5,{'transaction':_0x114b98});});}}})[_0xcfea('0x17')](function(){if(_0x5b97f6){_0x15e81a=_0x5b97f6;return db[_0xcfea('0xcd')][_0xcfea('0x5c')]({'where':{'service':!![]},'include':[{'model':db[_0xcfea('0xdf')],'as':_0xcfea('0xe0'),'raw':!![],'include':[{'model':db[_0xcfea('0xe1')],'as':'CloudProvider','raw':!![]}]}]});}})['then'](function(_0x409121){if(_0x409121&&_0x409121[_0xcfea('0xe0')]&&_0x41a19e[_0xcfea('0xe2')]&&_0x41a19e[_0xcfea('0xe3')]){var _0xede4f6=_0x409121['getSmtpOptions']();return respondWithRpcPromise('SendMail',_0xcfea('0xe4'),{'account':_0xede4f6,'message':{'from':util[_0xcfea('0xa9')](_0xcfea('0xe5'),_0x409121['name'],_0x409121['email']||_0x409121['Smtp']['user']),'to':_0x41a19e[_0xcfea('0xe3')],'subject':_0x41a19e[_0xcfea('0xe6')],'html':_0x15e81a[_0xcfea('0x50')],'attachments':_0x48604f}},client9003)[_0xcfea('0x17')](function(){return _0x15e81a;})[_0xcfea('0x56')](function(_0x254aa0){logger['error'](_0x254aa0);});}})['then'](function(){if(_0x41a19e&&_0x41a19e['openNewInteraction']&&_0x41a19e[_0xcfea('0xe7')]){var _0xeacd1c=[];if(_0x3d5e62[_0xcfea('0x41')]){_0xeacd1c=_0x3d5e62[_0xcfea('0x34')](function(_0x44683c){return{'name':_0x44683c[_0xcfea('0xe8')],'basename':_0x44683c[_0xcfea('0x6a')],'type':_0x44683c[_0xcfea('0xd6')],'ChatOfflineMessageId':_0x5b97f6['id']};});}var _0x3c89dc;if(!_[_0xcfea('0x78')](_0x41a19e[_0xcfea('0xe9')])){var _0x47b2f9=_[_0xcfea('0x34')](_0x2000bd['body'],function(_0xdc5b21){return _0xdc5b21;});var _0x50b4bc=_[_0xcfea('0xea')](_0x47b2f9)[0x0];var _0x598362=_[_0xcfea('0xeb')](_0x50b4bc,function(_0x88f986){return _0x88f986;});_0x3c89dc=_0x598362[0x1][_0x41a19e['subjectOffline']];}var _0x1fe8b5={'from':_0x766279[_0xcfea('0xec')],'firstName':_0x766279[_0xcfea('0xa5')],'lastName':_0x766279[_0xcfea('0xb7')],'mapKey':_0xcfea('0xec'),'message':{'from':_0x766279[_0xcfea('0xec')],'to':_0x41a19e['MailAccount']['email'],'cc':'','subject':_[_0xcfea('0x78')](_0x3c89dc)?_0x41a19e[_0xcfea('0xe6')]:_0x3c89dc,'messageId':'','sentAt':new Date(),'attach':_0xeacd1c[_0xcfea('0x41')],'attachments':_0xeacd1c,'originChannel':_0xcfea('0xed'),'ChatWebsiteId':_0x41a19e['id'],'ChatOfflineMessageId':_0x15e81a['id'],'originTo':_0x41a19e['MailAccount'][_0xcfea('0xec')]},'body':_0x15e81a[_0xcfea('0x50')]};var _0x4e37fd={'account':{'id':_0x41a19e[_0xcfea('0xe7')]},'body':_0x1fe8b5,'log':'NotifyMailAccount'};return respondWithRpcPromise(_0xcfea('0xee'),'notifyMail',_0x4e37fd,client9001)['then'](function(){return _0x15e81a;})[_0xcfea('0x56')](function(_0xf6d892){logger[_0xcfea('0x1c')](_0xf6d892);});}return;})[_0xcfea('0x17')](function(){if(_0x15e81a){return _0x15e81a;}})[_0xcfea('0x17')](respondWithResult(_0x366bc3,null))[_0xcfea('0x56')](function(_0xe2bd59){logger[_0xcfea('0x1c')](_0xcfea('0x56'),_0xe2bd59);for(var _0x472543 of _0x3d5e62){var _0x3c8b90=path[_0xcfea('0x6f')](config[_0xcfea('0x70')],'server',_0xcfea('0xc6'),_0xcfea('0xd8'),_0xcfea('0xd9'),_0x472543[_0xcfea('0x6a')]);fs_extra[_0xcfea('0xef')](_0x3c8b90)[_0xcfea('0x56')](function(_0x2bba9d){logger[_0xcfea('0x1c')](_0xcfea('0xf0'),_0x3c8b90,_0x2bba9d);});}});};exports['addInteraction']=function(_0x5465e5,_0x3f0d95){return db[_0xcfea('0xb2')][_0xcfea('0x4e')]({'where':{'id':_0x5465e5[_0xcfea('0x4d')]['id']}})['then'](handleEntityNotFound(_0x3f0d95,null))[_0xcfea('0x17')](function(_0x3557d5){if(_0x3557d5){return _0x3557d5[_0xcfea('0xf1')](_0x5465e5[_0xcfea('0x50')][_0xcfea('0x61')],_[_0xcfea('0xf2')](_0x5465e5['body'],[_0xcfea('0x61'),'id'])||{});}})['then'](respondWithResult(_0x3f0d95,null))['catch'](handleError(_0x3f0d95,null));};exports['getInteractions']=function(_0x218217,_0x5b8ab0){var _0x2f6286={'raw':![],'where':{}};var _0x48dba0={};var _0x255c55={'count':0x0,'rows':[]};return db['ChatWebsite'][_0xcfea('0x5c')]({'where':{'id':_0x218217['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x5b8ab0,null))[_0xcfea('0x17')](function(_0x5df211){if(_0x5df211){_0x48dba0[_0xcfea('0x3a')]=_[_0xcfea('0x3c')](db['ChatInteraction']['rawAttributes']);_0x48dba0[_0xcfea('0x3b')]=_['keys'](_0x218217[_0xcfea('0x3b')]);_0x48dba0[_0xcfea('0x3d')]=_['intersection'](_0x48dba0[_0xcfea('0x3a')],_0x48dba0['query']);_0x2f6286[_0xcfea('0x3f')]=_[_0xcfea('0x3e')](_0x48dba0['model'],qs[_0xcfea('0x40')](_0x218217[_0xcfea('0x3b')]['fields']));_0x2f6286[_0xcfea('0x3f')]=_0x2f6286[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x2f6286[_0xcfea('0x3f')]:_0x48dba0[_0xcfea('0x3a')];if(!_0x218217['query'][_0xcfea('0x65')]('nolimit')){_0x2f6286[_0xcfea('0x27')]=qs[_0xcfea('0x27')](_0x218217[_0xcfea('0x3b')][_0xcfea('0x27')]);_0x2f6286['offset']=qs[_0xcfea('0x24')](_0x218217[_0xcfea('0x3b')][_0xcfea('0x24')]);}_0x2f6286[_0xcfea('0x42')]=qs[_0xcfea('0x43')](_0x218217[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x2f6286[_0xcfea('0x44')]=qs['filters'](_[_0xcfea('0x5f')](_0x218217[_0xcfea('0x3b')],_0x48dba0[_0xcfea('0x3d')]));_0x2f6286['where'][_0xcfea('0x5a')]=_0x5df211['id'];if(_0x218217['query'][_0xcfea('0x45')]){_0x2f6286['where']=_[_0xcfea('0x47')](_0x2f6286[_0xcfea('0x44')],{'$or':_['map'](_0x2f6286[_0xcfea('0x3f')],function(_0x3c2d77){var _0x1330f4={};_0x1330f4[_0x3c2d77]={'$like':'%'+_0x218217['query'][_0xcfea('0x45')]+'%'};return _0x1330f4;})});}_0x2f6286=_[_0xcfea('0x47')]({},_0x2f6286,_0x218217['options']);return db['ChatInteraction'][_0xcfea('0x26')]({'where':_0x2f6286['where']})[_0xcfea('0x17')](function(_0x397b20){_0x255c55[_0xcfea('0x26')]=_0x397b20;if(_0x218217[_0xcfea('0x3b')][_0xcfea('0x49')]){_0x2f6286[_0xcfea('0x4a')]=[{'model':db[_0xcfea('0x86')],'as':_0xcfea('0xf3'),'required':![]},{'model':db['User'],'as':_0xcfea('0xf4'),'attributes':[_0xcfea('0x30'),_0xcfea('0xf5'),_0xcfea('0xf6')],'required':![]},{'model':db['Tag'],'as':_0xcfea('0xf7'),'attributes':['id',_0xcfea('0x30'),_0xcfea('0xf8')],'where':_0x218217['query'][_0xcfea('0xf9')]?{'id':_0x218217[_0xcfea('0x3b')][_0xcfea('0xf9')]}:undefined,'required':_0x218217[_0xcfea('0x3b')][_0xcfea('0xf9')]?!![]:![]}];}return db[_0xcfea('0xb2')][_0xcfea('0x4b')](_0x2f6286);})['then'](function(_0xae7d5c){_0x255c55[_0xcfea('0xfa')]=_0xae7d5c;return _0x255c55;});}})['then'](respondWithFilteredResult(_0x5b8ab0,_0x2f6286))[_0xcfea('0x56')](handleError(_0x5b8ab0,null));};function iftimePromise(_0x4a9e1d,_0x584ea0){return respondWithRpcPromise(_0xcfea('0xfb'),_0xcfea('0xfc'),{'command':_0x584ea0[_0xcfea('0xfd')]?util['format'](_0xcfea('0xfe'),_0x4a9e1d['interval'],_0x584ea0[_0xcfea('0xfd')]):util[_0xcfea('0xa9')](_0xcfea('0xff'),_0x4a9e1d[_0xcfea('0x100')])},client9002)[_0xcfea('0x17')](function(_0x4ab1f8){var _0x2cec0b=_0x4ab1f8&&_0x4ab1f8[_0xcfea('0x101')](_0xcfea('0x102'))>=0x0?!![]:![];logger[_0xcfea('0x18')](_0xcfea('0x103'),_0x584ea0['id'],_0x4a9e1d['id'],_0x4a9e1d[_0xcfea('0x100')],_0x2cec0b?_0xcfea('0x104'):_0xcfea('0x105'),_0x584ea0['timezone']?_0x584ea0[_0xcfea('0xfd')]:_0xcfea('0x106'));return _0x2cec0b;})[_0xcfea('0x56')](function(_0x18fb70){logger[_0xcfea('0x1c')](_0xcfea('0x103'),_0x584ea0['id'],_0x4a9e1d['id'],_0x4a9e1d[_0xcfea('0x100')],util[_0xcfea('0x107')](_0x18fb70,{'showHidden':![],'depth':null}),_0x584ea0[_0xcfea('0xfd')]?_0x584ea0[_0xcfea('0xfd')]:_0xcfea('0x106'));return![];});}exports['getSnippet']=function(_0xcb357c,_0x47cd9b){var _0x362ee3=0x0;var _0x227ac2=0x0;var _0x1faffa=![];var _0x3f03a2;var _0x5b3308;return db['ChatWebsite'][_0xcfea('0x4e')]({'where':{'id':_0xcb357c[_0xcfea('0x4d')]['id']},'include':[{'model':db[_0xcfea('0x108')],'as':_0xcfea('0x108'),'include':[{'model':db['Interval'],'as':'Intervals','attributes':['id',_0xcfea('0x100')],'raw':!![]}]}]})[_0xcfea('0x17')](handleEntityNotFound(_0x47cd9b,null))[_0xcfea('0x17')](function(_0x53cdd7){if(_0x53cdd7){_0x3f03a2=_0x53cdd7;return _0x53cdd7[_0xcfea('0x109')]({'raw':!![]});}})[_0xcfea('0x17')](function(_0x17f8fb){if(_0x3f03a2){if(_0x17f8fb){_0x5b3308=_0x17f8fb;}}return require('../../config/license/util')[_0xcfea('0x73')]();})['then'](function(_0x1b287f){if(_0x1b287f){_0x227ac2=_0x1b287f['virtual'];_0x1faffa=_0x1b287f[_0xcfea('0x74')];}})[_0xcfea('0x17')](function(){return db[_0xcfea('0xb2')][_0xcfea('0x26')]({'where':{'closed':![]}});})[_0xcfea('0x17')](function(_0x451e11){_0x362ee3=_0x451e11;if(_0x227ac2&&_0x451e11>_0x227ac2){return db[_0xcfea('0x10a')][_0xcfea('0x5c')]({'where':{'id':0x1}})['then'](function(_0x1ffd57){if(_0x1ffd57){_0x1ffd57[_0xcfea('0x10b')](_0xcfea('0x10c'));}});}})[_0xcfea('0x17')](function(){if(_0x3f03a2[_0xcfea('0x108')]&&_0x3f03a2[_0xcfea('0x108')][_0xcfea('0x10d')]){var _0x19c356=[];for(var _0x99da58=0x0;_0x99da58<_0x3f03a2[_0xcfea('0x108')][_0xcfea('0x10d')][_0xcfea('0x41')];_0x99da58++){var _0x16f58f=_0x3f03a2[_0xcfea('0x108')][_0xcfea('0x10d')][_0x99da58][_0xcfea('0x2d')]({'plain':!![]});_0x19c356['push'](iftimePromise(_0x16f58f,_0x3f03a2));}return BPromise[_0xcfea('0x10e')](_0x19c356)[_0xcfea('0x17')](function(_0x345e45){return _[_0xcfea('0x10f')](_0x345e45);});}else{return!![];}})[_0xcfea('0x17')](function(_0xd9e7ef){var _0x2f3e64=fs[_0xcfea('0xcf')](path[_0xcfea('0x6f')](config[_0xcfea('0x70')],'server/files/chat/iframe.ejs'),_0xcfea('0xd1'));var _0x4bf605=new url['URL'](_0x3f03a2['address'])[_0xcfea('0x110')];var _0x1888df=_0xcfea('0x111');var _0x309476=![];var _0x59003a={'chatVersion':_0x1888df,'chatWebsiteAddressOrigin':_0x4bf605,'remote':_0x3f03a2[_0xcfea('0x112')],'query':querystring[_0xcfea('0xb0')](_[_0xcfea('0x47')](_0x3f03a2['get']({'plain':!![]}),{'customerIp':_0xcb357c[_0xcfea('0x83')]['x-forwarded-for']||_0xcb357c[_0xcfea('0x83')][_0xcfea('0x113')]||_0xcb357c[_0xcfea('0x114')][_0xcfea('0x115')]||_0xcb357c['ip'],'referer':_0xcb357c[_0xcfea('0x83')][_0xcfea('0xa7')],'openedInteractions':_0x362ee3,'maxInteractions':_0x227ac2,'virtual':_0x1faffa[_0xcfea('0x116')],'online':_0xd9e7ef,'custom':_0x1faffa}))[_0xcfea('0x117')](/'/g,'\x5c\x27')};_0x47cd9b[_0xcfea('0xcb')](ejs[_0xcfea('0xd2')](Mustache['render'](_0x2f3e64,_0x59003a),{'proactiveActions':_0x5b3308,'alignment':_0x3f03a2['alignment'],'verticalAlignment':_0x3f03a2[_0xcfea('0x118')],'div_color':_0x3f03a2[_0xcfea('0xf8')],'labelText':_0x3f03a2[_0xcfea('0x119')],'text_color':_0x3f03a2[_0xcfea('0x11a')],'text_button_color':_0x3f03a2[_0xcfea('0x11b')],'button_color':_0x3f03a2[_0xcfea('0x11c')],'background_color':_0x3f03a2[_0xcfea('0x11d')],'hideWhenOffline':_0x3f03a2[_0xcfea('0x11e')],'intervalId':_0x3f03a2['IntervalId'],'isDevelopment':_0x309476,'chatVersion':_0x1888df}));})['catch'](handleError(_0x47cd9b,null));};exports['addApplications']=function(_0x12e3aa,_0x5b4084){var _0x5a1888=_0x12e3aa[_0xcfea('0x4d')]['id'];var _0x56a16d=_0x12e3aa[_0xcfea('0x50')];var _0x472250=0xc8;var _0x5bf796=null;return db[_0xcfea('0xdc')]['transaction']({'isolationLevel':db[_0xcfea('0xdc')]['Transaction']['ISOLATION_LEVELS'][_0xcfea('0x11f')]},function(_0x1bf5c4){return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x5a1888},'transaction':_0x1bf5c4})['then'](function(_0x58325f){if(_0x58325f){return db[_0xcfea('0x96')][_0xcfea('0x2c')]({'where':{'ChatWebsiteId':_0x5a1888},'transaction':_0x1bf5c4})[_0xcfea('0x17')](function(){var _0x1af3fc=_[_0xcfea('0x34')](_0x56a16d,function(_0x51e7f8){_0x51e7f8['ChatWebsiteId']=_0x5a1888;return _0x51e7f8;});return db['ChatApplication'][_0xcfea('0x120')](_0x1af3fc,{'transaction':_0x1bf5c4});});}else{_0x472250=0x194;_0x5bf796=[];}});})[_0xcfea('0x17')](function(){if(_0x472250!==0x194){return db[_0xcfea('0x96')][_0xcfea('0x121')]({'where':{'ChatWebsiteId':_0x5a1888},'order':_0xcfea('0x9c')})['then'](function(_0x5d7bf8){_0x5bf796=_0x5d7bf8;});}})[_0xcfea('0x56')](function(_0x3b3187){_0x472250=0x1f4;logger[_0xcfea('0x1c')](_0x3b3187['stack']);if(_0x3b3187[_0xcfea('0x30')]){delete _0x3b3187[_0xcfea('0x30')];}_0x5bf796=_0x3b3187;})[_0xcfea('0x122')](function(){if(_0x5bf796===null){_0x5b4084[_0xcfea('0x21')](_0x472250);}else{if(_0x472250===0x1f4){_0x5b4084[_0xcfea('0x22')](_0x472250)[_0xcfea('0xcb')](_0x5bf796);}else{_0x5b4084[_0xcfea('0x22')](_0x472250)[_0xcfea('0x2a')](_0x5bf796);}}});};exports[_0xcfea('0x123')]=function(_0x1f34d8,_0xcf0d9d){var _0x45636c={};var _0x3e2e5c={};var _0xbb7350;var _0x27fb5b;return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x1f34d8['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0xcf0d9d,null))[_0xcfea('0x17')](function(_0x11dd9d){if(_0x11dd9d){_0xbb7350=_0x11dd9d;_0x3e2e5c[_0xcfea('0x3a')]=_[_0xcfea('0x3c')](db[_0xcfea('0x96')][_0xcfea('0x36')]);_0x3e2e5c[_0xcfea('0x3b')]=_[_0xcfea('0x3c')](_0x1f34d8['query']);_0x3e2e5c[_0xcfea('0x3d')]=_[_0xcfea('0x3e')](_0x3e2e5c[_0xcfea('0x3a')],_0x3e2e5c['query']);_0x45636c[_0xcfea('0x3f')]=_[_0xcfea('0x3e')](_0x3e2e5c['model'],qs[_0xcfea('0x40')](_0x1f34d8['query'][_0xcfea('0x40')]));_0x45636c['attributes']=_0x45636c[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x45636c[_0xcfea('0x3f')]:_0x3e2e5c[_0xcfea('0x3a')];_0x45636c['order']=qs[_0xcfea('0x43')](_0x1f34d8['query'][_0xcfea('0x43')]);_0x45636c[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_[_0xcfea('0x5f')](_0x1f34d8[_0xcfea('0x3b')],_0x3e2e5c[_0xcfea('0x3d')]));if(_0x1f34d8['query'][_0xcfea('0x45')]){_0x45636c['where']=_[_0xcfea('0x47')](_0x45636c[_0xcfea('0x44')],{'$or':_[_0xcfea('0x34')](_0x45636c['attributes'],function(_0x1b16eb){var _0x4e3790={};_0x4e3790[_0x1b16eb]={'$like':'%'+_0x1f34d8[_0xcfea('0x3b')]['filter']+'%'};return _0x4e3790;})});}_0x45636c=_[_0xcfea('0x47')]({},_0x45636c,_0x1f34d8[_0xcfea('0x48')]);return _0xbb7350['getApplications'](_0x45636c);}})[_0xcfea('0x17')](function(_0x2ef9d9){if(_0x2ef9d9){_0x27fb5b=_0x2ef9d9[_0xcfea('0x41')];if(!_0x1f34d8['query']['hasOwnProperty'](_0xcfea('0x5e'))){_0x45636c['limit']=qs[_0xcfea('0x27')](_0x1f34d8[_0xcfea('0x3b')][_0xcfea('0x27')]);_0x45636c[_0xcfea('0x24')]=qs[_0xcfea('0x24')](_0x1f34d8['query'][_0xcfea('0x24')]);}return _0xbb7350[_0xcfea('0x123')](_0x45636c);}})[_0xcfea('0x17')](function(_0x292ec3){if(_0x292ec3){return _0x292ec3?{'count':_0x27fb5b,'rows':_0x292ec3}:null;}})[_0xcfea('0x17')](respondWithResult(_0xcf0d9d,null))[_0xcfea('0x56')](handleError(_0xcf0d9d,null));};exports[_0xcfea('0x124')]=function(_0x4d3218,_0x395461){return db[_0xcfea('0x125')][_0xcfea('0x4e')]({'where':{'id':_0x4d3218[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x395461,null))[_0xcfea('0x17')](function(_0x19499b){if(_0x19499b){return _0x19499b[_0xcfea('0x124')](_0x4d3218['body']['ids'],_['omit'](_0x4d3218[_0xcfea('0x50')],[_0xcfea('0x61'),'id'])||{});}})[_0xcfea('0x17')](respondWithResult(_0x395461,null))[_0xcfea('0x56')](handleError(_0x395461,null));};exports['getProactiveActions']=function(_0x111329,_0x4736c2){var _0x1b862b={};var _0x483a4f={};var _0x57b998;var _0x2a2172;return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x111329[_0xcfea('0x4d')]['id']}})['then'](handleEntityNotFound(_0x4736c2,null))[_0xcfea('0x17')](function(_0xaa2da4){if(_0xaa2da4){_0x57b998=_0xaa2da4;_0x483a4f[_0xcfea('0x3a')]=_[_0xcfea('0x3c')](db['ChatProactiveAction']['rawAttributes']);_0x483a4f[_0xcfea('0x3b')]=_[_0xcfea('0x3c')](_0x111329[_0xcfea('0x3b')]);_0x483a4f[_0xcfea('0x3d')]=_[_0xcfea('0x3e')](_0x483a4f[_0xcfea('0x3a')],_0x483a4f['query']);_0x1b862b[_0xcfea('0x3f')]=_[_0xcfea('0x3e')](_0x483a4f[_0xcfea('0x3a')],qs[_0xcfea('0x40')](_0x111329[_0xcfea('0x3b')][_0xcfea('0x40')]));_0x1b862b[_0xcfea('0x3f')]=_0x1b862b[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x1b862b['attributes']:_0x483a4f[_0xcfea('0x3a')];_0x1b862b[_0xcfea('0x42')]=qs[_0xcfea('0x43')](_0x111329[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x1b862b[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_['pick'](_0x111329[_0xcfea('0x3b')],_0x483a4f[_0xcfea('0x3d')]));if(_0x111329[_0xcfea('0x3b')][_0xcfea('0x45')]){_0x1b862b[_0xcfea('0x44')]=_[_0xcfea('0x47')](_0x1b862b[_0xcfea('0x44')],{'$or':_[_0xcfea('0x34')](_0x1b862b[_0xcfea('0x3f')],function(_0x347824){var _0x31a0fe={};_0x31a0fe[_0x347824]={'$like':'%'+_0x111329['query']['filter']+'%'};return _0x31a0fe;})});}_0x1b862b=_['merge']({},_0x1b862b,_0x111329[_0xcfea('0x48')]);return _0x57b998[_0xcfea('0x109')](_0x1b862b);}})[_0xcfea('0x17')](function(_0x306421){if(_0x306421){_0x2a2172=_0x306421[_0xcfea('0x41')];if(!_0x111329[_0xcfea('0x3b')][_0xcfea('0x65')](_0xcfea('0x5e'))){_0x1b862b[_0xcfea('0x27')]=qs[_0xcfea('0x27')](_0x111329[_0xcfea('0x3b')][_0xcfea('0x27')]);_0x1b862b[_0xcfea('0x24')]=qs['offset'](_0x111329[_0xcfea('0x3b')][_0xcfea('0x24')]);}return _0x57b998[_0xcfea('0x109')](_0x1b862b);}})['then'](function(_0x529c21){if(_0x529c21){return _0x529c21?{'count':_0x2a2172,'rows':_0x529c21}:null;}})[_0xcfea('0x17')](respondWithResult(_0x4736c2,null))[_0xcfea('0x56')](handleError(_0x4736c2,null));};exports[_0xcfea('0x126')]=function(_0x45f712,_0x25b269){var _0x34b3ee=_0x45f712['query'][_0xcfea('0x127')]===_0xcfea('0x128')?_0xcfea('0x129'):_0xcfea('0x12a');return db['ChatWebsite']['find']({'attributes':['id',_0x34b3ee],'where':{'id':_0x45f712['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x25b269,null))[_0xcfea('0x17')](function(_0x150846){if(_0x150846){var _0x2e84a1=_0x150846[_0x34b3ee];var _0x2c9ead=_0x2e84a1&&_0x2e84a1[_0xcfea('0x12b')]?_0x2e84a1[_0xcfea('0x12b')]:[];_0x25b269[_0xcfea('0xcb')]({'fromKey':_[_0xcfea('0x78')](_0x2e84a1[_0xcfea('0x12c')])?undefined:_0x2e84a1[_0xcfea('0x12c')],'count':_0x2c9ead[_0xcfea('0x41')],'rows':_0x2c9ead});}})[_0xcfea('0x56')](handleError(_0x25b269,null));};exports[_0xcfea('0x12d')]=function(_0x38af27,_0x216480){var _0x5a27bf={'raw':![],'where':{}};var _0x1b63ba={};var _0x5eb6f1={'count':0x0,'rows':[]};return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x38af27[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x216480,null))['then'](function(_0x45a352){if(_0x45a352){_0x1b63ba[_0xcfea('0x3a')]=_['keys'](db[_0xcfea('0xd4')][_0xcfea('0x36')]);_0x1b63ba[_0xcfea('0x3b')]=_[_0xcfea('0x3c')](_0x38af27[_0xcfea('0x3b')]);_0x1b63ba[_0xcfea('0x3d')]=_[_0xcfea('0x3e')](_0x1b63ba[_0xcfea('0x3a')],_0x1b63ba[_0xcfea('0x3b')]);_0x5a27bf['attributes']=_[_0xcfea('0x3e')](_0x1b63ba['model'],qs[_0xcfea('0x40')](_0x38af27[_0xcfea('0x3b')]['fields']));_0x5a27bf[_0xcfea('0x3f')]=_0x5a27bf[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x5a27bf['attributes']:_0x1b63ba['model'];if(!_0x38af27[_0xcfea('0x3b')]['hasOwnProperty'](_0xcfea('0x5e'))){_0x5a27bf[_0xcfea('0x27')]=qs['limit'](_0x38af27[_0xcfea('0x3b')][_0xcfea('0x27')]);_0x5a27bf[_0xcfea('0x24')]=qs[_0xcfea('0x24')](_0x38af27[_0xcfea('0x3b')][_0xcfea('0x24')]);}_0x5a27bf[_0xcfea('0x42')]=qs['sort'](_0x38af27[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x5a27bf[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_[_0xcfea('0x5f')](_0x38af27[_0xcfea('0x3b')],_0x1b63ba['filters']));_0x5a27bf['where'][_0xcfea('0x5a')]=_0x45a352['id'];if(_0x38af27['query'][_0xcfea('0x45')]){_0x5a27bf[_0xcfea('0x44')]=_[_0xcfea('0x47')](_0x5a27bf[_0xcfea('0x44')],{'$or':_[_0xcfea('0x34')](_0x5a27bf['attributes'],function(_0x594c4d){var _0x27128c={};_0x27128c[_0x594c4d]={'$like':'%'+_0x38af27[_0xcfea('0x3b')][_0xcfea('0x45')]+'%'};return _0x27128c;})});}_0x5a27bf=_['merge']({},_0x5a27bf,_0x38af27[_0xcfea('0x48')]);return db['ChatOfflineMessage'][_0xcfea('0x26')]({'where':_0x5a27bf[_0xcfea('0x44')]})[_0xcfea('0x17')](function(_0xc2ef93){_0x5eb6f1[_0xcfea('0x26')]=_0xc2ef93;if(_0x38af27[_0xcfea('0x3b')][_0xcfea('0x49')]){_0x5a27bf[_0xcfea('0x4a')]=[{'all':!![]}];}else{_0x5a27bf['include']=[{'model':db[_0xcfea('0x86')],'as':_0xcfea('0xf3'),'required':![]},{'model':db[_0xcfea('0xde')],'as':_0xcfea('0x12e'),'required':![]}];}return db[_0xcfea('0xd4')]['findAll'](_0x5a27bf);})[_0xcfea('0x17')](function(_0x13fa4b){_0x5eb6f1['rows']=_0x13fa4b;return _0x5eb6f1;});}})[_0xcfea('0x17')](respondWithFilteredResult(_0x216480,_0x5a27bf))['catch'](handleError(_0x216480,null));};exports[_0xcfea('0x12f')]=function(_0x270ff7,_0x2a86dd){return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x270ff7[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x2a86dd,null))[_0xcfea('0x17')](function(_0x55fbf5){if(_0x55fbf5){return _0x55fbf5[_0xcfea('0x12f')](_0x270ff7[_0xcfea('0x50')]['ids'],_['omit'](_0x270ff7['body'],['ids','id'])||{})[_0xcfea('0xb6')](function(_0x2d5f93){for(var _0x7ec349=0x0;_0x7ec349<_0x270ff7[_0xcfea('0x50')][_0xcfea('0x61')]['length'];_0x7ec349+=0x1){socket['emit'](_0xcfea('0x130'),{'UserId':Number(_0x270ff7['body']['ids'][_0x7ec349]),'ChatWebsiteId':Number(_0x270ff7['params']['id'])});}return _0x2d5f93;});}})[_0xcfea('0x17')](respondWithResult(_0x2a86dd,null))[_0xcfea('0x56')](handleError(_0x2a86dd,null));};exports[_0xcfea('0x131')]=function(_0x151681,_0x4c997b){return db[_0xcfea('0x35')]['find']({'where':{'id':_0x151681[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x4c997b,null))[_0xcfea('0x17')](function(_0x430893){if(_0x430893){return _0x430893['removeAgents'](_0x151681[_0xcfea('0x3b')][_0xcfea('0x61')])['then'](function(){if(_[_0xcfea('0x132')](_0x151681[_0xcfea('0x3b')][_0xcfea('0x61')])){for(var _0x55d521=0x0;_0x55d521<_0x151681[_0xcfea('0x3b')]['ids'][_0xcfea('0x41')];_0x55d521+=0x1){socket['emit'](_0xcfea('0x133'),{'UserId':Number(_0x151681[_0xcfea('0x3b')][_0xcfea('0x61')][_0x55d521]),'ChatWebsiteId':Number(_0x151681[_0xcfea('0x4d')]['id'])});}}else{socket[_0xcfea('0x134')](_0xcfea('0x133'),{'UserId':Number(_0x151681['query'][_0xcfea('0x61')]),'ChatWebsiteId':Number(_0x151681[_0xcfea('0x4d')]['id'])});}});}})[_0xcfea('0x17')](respondWithStatusCode(_0x4c997b,null))[_0xcfea('0x56')](handleError(_0x4c997b,null));};exports[_0xcfea('0x135')]=function(_0x4a7099,_0x36218b){var _0x4c6b10={};var _0x4ca748={};var _0x1b0a0e;var _0x4400e7;return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x4a7099[_0xcfea('0x4d')]['id']}})['then'](handleEntityNotFound(_0x36218b,null))[_0xcfea('0x17')](function(_0x4a569c){if(_0x4a569c){_0x1b0a0e=_0x4a569c;_0x4ca748[_0xcfea('0x3a')]=_['keys'](db[_0xcfea('0xbf')]['rawAttributes']);_0x4ca748[_0xcfea('0x3b')]=_[_0xcfea('0x3c')](_0x4a7099[_0xcfea('0x3b')]);_0x4ca748['filters']=_[_0xcfea('0x3e')](_0x4ca748[_0xcfea('0x3a')],_0x4ca748[_0xcfea('0x3b')]);_0x4c6b10[_0xcfea('0x3f')]=_['intersection'](_0x4ca748[_0xcfea('0x3a')],qs[_0xcfea('0x40')](_0x4a7099[_0xcfea('0x3b')][_0xcfea('0x40')]));_0x4c6b10[_0xcfea('0x3f')]=_0x4c6b10[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x4c6b10[_0xcfea('0x3f')]:_0x4ca748[_0xcfea('0x3a')];_0x4c6b10['order']=qs['sort'](_0x4a7099[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x4c6b10[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_[_0xcfea('0x5f')](_0x4a7099[_0xcfea('0x3b')],_0x4ca748[_0xcfea('0x3d')]));if(_0x4a7099[_0xcfea('0x3b')][_0xcfea('0x45')]){_0x4c6b10[_0xcfea('0x44')]=_[_0xcfea('0x47')](_0x4c6b10[_0xcfea('0x44')],{'$or':_[_0xcfea('0x34')](_0x4c6b10[_0xcfea('0x3f')],function(_0x31d767){var _0x12b293={};_0x12b293[_0x31d767]={'$like':'%'+_0x4a7099[_0xcfea('0x3b')][_0xcfea('0x45')]+'%'};return _0x12b293;})});}_0x4c6b10=_['merge']({},_0x4c6b10,_0x4a7099['options']);return _0x1b0a0e[_0xcfea('0x135')](_0x4c6b10);}})[_0xcfea('0x17')](function(_0x374dd7){if(_0x374dd7){_0x4400e7=_0x374dd7[_0xcfea('0x41')];if(!_0x4a7099[_0xcfea('0x3b')][_0xcfea('0x65')](_0xcfea('0x5e'))){_0x4c6b10[_0xcfea('0x27')]=qs[_0xcfea('0x27')](_0x4a7099['query'][_0xcfea('0x27')]);_0x4c6b10[_0xcfea('0x24')]=qs['offset'](_0x4a7099[_0xcfea('0x3b')][_0xcfea('0x24')]);}return _0x1b0a0e[_0xcfea('0x135')](_0x4c6b10);}})[_0xcfea('0x17')](function(_0x2a72cd){if(_0x2a72cd){return _0x2a72cd?{'count':_0x4400e7,'rows':_0x2a72cd}:null;}})[_0xcfea('0x17')](respondWithResult(_0x36218b,null))['catch'](handleError(_0x36218b,null));};
\ No newline at end of file
+var _0x671a=['../../errors/api','APINotFoundError','../../mysqldb','redis','localhost','./chatWebsite.socket','register','http','client','request','then','ChatWebsite,\x20%s,\x20%s','request\x20sent','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','update','destroy','get','ChatWebsites','UserProfileResource','stack','name','Command','getSnippet','timezone','format','interval','indexOf','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','inspect','No\x20timezone','map','all','some','setUA','user-agent','getResult','customerIp','cf-connecting-ip','first','x-forwarded-for','split','firstName','lastName','x-real-port','referer','browser','%s\x20%s','unknown','version','device','vendor','%s\x20%s\x20%s','model','type','index','Pause','mandatoryDispositionPause','ChatWebsite','rawAttributes','fieldName','key','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filters','pick','filter','options','includeAll','findAll','include','find','create','body','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','Disposition','getDispositions','findOne','order','ChatWebsiteId','merge','rows','removeDispositions','ids','CannedAnswer','getAnswers','keys','removeAnswers','addLogo','sitepic','file','filename','addAvatar','agentAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','../../config/license/util','getLicense','custom','isNil','existsSync','server/files/images/logos/','download','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','customerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','notify','chat','CmContact','Sequelize','no\x20available\x20attributes','createdAt','difference','updatedAt','ListId','from','ValidationError','from\x20is\x20mandatory','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','DESC','ChatApplication','Applications','Interval','Intervals','Chat\x20Website\x20with\x20id\x20%s\x20not\x20found','account','list','applications','orderBy','priority','asc','Contacts','defaults','contact','threadId','externalUrl','ChatInteraction','interaction','messageId','created','autoclose','push','close','unmanaged','ChatMessage','AttachmentId','UserId','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','queueId','ChatQueue','unshift','queue','waitForTheAssignedQueue','Start','startRouting','EventManager','offline','files','CompanyId','send','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','spread','readFileSync','toPairs','offlineMessageBody','ChatOfflineMessage','fromString','server','attachments','offline-chat','basename','openNewInteraction','transaction','Attachment','Smtp','CloudProvider','forwardOffline','forwardOfflineAddress','getSmtpOptions','SendMail','\x22%s\x22\x20<%s>','email','user','offlineMessageSubject','MailAccountId','originalname','mimetype','subjectOffline','toPairsIn','NotifyMailAccount','notifyMail','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','Owner','fullname','Tag','Tags','color','tag','License','chatLicenseExceeded','server/files/chat/iframe.ejs','utf8','URL','origin','3.5.0','remote','headers','x-real-ip','remoteAddress','virtual','replace','render','alignment','verticalAlignment','labelText','textButtonColor','color_button','backgroundColor','hideWhenOffline','IntervalId','addApplications','sequelize','Transaction','ISOLATION_LEVELS','READ_COMMITTED','findAndCountAll','finally','getApplications','addProactiveActions','getProactiveActions','ChatProactiveAction','getFields','online','offlineForm','items','fromKey','getOfflineMessages','Attachments','addAgents','removeAgents','isArray','emit','userChatWebsite:remove','User','getAgents','mustache','util','ejs','fs-extra','lodash','querystring','html-to-text','ioredis','jayson/promise','../../components/parsers/qs','../../config/logger','api','../../config/environment','APIOutOfIntervalError'];(function(_0x333f19,_0x3f6eed){var _0x453f98=function(_0x1d025c){while(--_0x1d025c){_0x333f19['push'](_0x333f19['shift']());}};_0x453f98(++_0x3f6eed);}(_0x671a,0x12b));var _0xa671=function(_0x598408,_0x5e6f74){_0x598408=_0x598408-0x0;var _0x560720=_0x671a[_0x598408];return _0x560720;};'use strict';var Mustache=require(_0xa671('0x0'));var util=require(_0xa671('0x1'));var path=require('path');var ejs=require(_0xa671('0x2'));var fs=require('fs');var fs_extra=require(_0xa671('0x3'));var _=require(_0xa671('0x4'));var querystring=require(_0xa671('0x5'));var htmlToText=require(_0xa671('0x6'));var Redis=require(_0xa671('0x7'));var jayson=require(_0xa671('0x8'));var url=require('url');var qs=require(_0xa671('0x9'));var logger=require(_0xa671('0xa'))(_0xa671('0xb'));var config=require(_0xa671('0xc'));var APIOutOfIntervalError=require('../../errors/api')[_0xa671('0xd')];var APINotFoundError=require(_0xa671('0xe'))[_0xa671('0xf')];var APIHandleError=require(_0xa671('0xe'))['handleError'];var db=require(_0xa671('0x10'))['db'];config[_0xa671('0x11')]=_['defaults'](config[_0xa671('0x11')],{'host':_0xa671('0x12'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa671('0x11')]));require(_0xa671('0x13'))[_0xa671('0x14')](socket);var client=jayson['client'][_0xa671('0x15')]({'port':0x232c});var client9002=jayson[_0xa671('0x16')]['http']({'port':0x232a});var client9003=jayson[_0xa671('0x16')]['http']({'port':0x232b});var client9001=jayson[_0xa671('0x16')][_0xa671('0x15')]({'port':0x2329});function respondWithRpcPromise(_0x4b1d0e,_0x2e2c18,_0x459c24,_0x4bc393){return new Promise(function(_0xddcb05,_0x373dd5){var _0x1c8475=_0x4bc393||client;return _0x1c8475[_0xa671('0x17')](_0x4b1d0e,_0x459c24)[_0xa671('0x18')](function(_0x9e6765){logger['info'](_0xa671('0x19'),_0x2e2c18,_0xa671('0x1a'));logger['debug'](_0xa671('0x1b'),_0x2e2c18,'request\x20sent',JSON[_0xa671('0x1c')](_0x9e6765));if(_0x9e6765[_0xa671('0x1d')]){if(_0x9e6765[_0xa671('0x1d')][_0xa671('0x1e')]===0x1f4){logger[_0xa671('0x1d')]('ChatWebsite,\x20%s,\x20%s',_0x2e2c18,_0x9e6765[_0xa671('0x1d')]['message']);return _0x373dd5(_0x9e6765[_0xa671('0x1d')][_0xa671('0x1f')]);}logger[_0xa671('0x1d')]('ChatWebsite,\x20%s,\x20%s',_0x2e2c18,_0x9e6765['error'][_0xa671('0x1f')]);return _0xddcb05(_0x9e6765[_0xa671('0x1d')]['message']);}else{logger[_0xa671('0x20')](_0xa671('0x19'),_0x2e2c18,_0xa671('0x1a'));_0xddcb05(_0x9e6765[_0xa671('0x21')][_0xa671('0x1f')]);}})[_0xa671('0x22')](function(_0x3f5d85){logger[_0xa671('0x1d')]('ChatWebsite,\x20%s,\x20%s',_0x2e2c18,_0x3f5d85);_0x373dd5(_0x3f5d85);});});}function respondWithStatusCode(_0x28d586,_0xf2110f){_0xf2110f=_0xf2110f||0xcc;return function(_0x31ab5a){if(_0x31ab5a){return _0x28d586[_0xa671('0x23')](_0xf2110f);}return _0x28d586[_0xa671('0x24')](_0xf2110f)[_0xa671('0x25')]();};}function respondWithResult(_0x306648,_0x1ff023){_0x1ff023=_0x1ff023||0xc8;return function(_0x2cd231){if(_0x2cd231){return _0x306648[_0xa671('0x24')](_0x1ff023)[_0xa671('0x26')](_0x2cd231);}};}function respondWithFilteredResult(_0x48efd0,_0x461a6d){return function(_0x563ad5){if(_0x563ad5){var _0x3b6702=typeof _0x461a6d[_0xa671('0x27')]==='undefined'&&typeof _0x461a6d['limit']===_0xa671('0x28');var _0x46ddd2=_0x563ad5[_0xa671('0x29')];var _0xc5d732=_0x3b6702?0x0:_0x461a6d[_0xa671('0x27')];var _0x2b3b1c=_0x3b6702?_0x563ad5[_0xa671('0x29')]:_0x461a6d[_0xa671('0x27')]+_0x461a6d[_0xa671('0x2a')];var _0xcfbc74;if(_0x2b3b1c>=_0x46ddd2){_0x2b3b1c=_0x46ddd2;_0xcfbc74=0xc8;}else{_0xcfbc74=0xce;}_0x48efd0[_0xa671('0x24')](_0xcfbc74);return _0x48efd0[_0xa671('0x2b')](_0xa671('0x2c'),_0xc5d732+'-'+_0x2b3b1c+'/'+_0x46ddd2)[_0xa671('0x26')](_0x563ad5);}return null;};}function saveUpdates(_0x2689ed){return function(_0x5be149){if(_0x5be149){return _0x5be149[_0xa671('0x2d')](_0x2689ed)[_0xa671('0x18')](function(_0x2f3697){return _0x2f3697;});}return null;};}function removeEntity(_0x4a5c17){return function(_0x431c9b){if(_0x431c9b){return _0x431c9b[_0xa671('0x2e')]()[_0xa671('0x18')](function(){var _0x12e528=_0x431c9b[_0xa671('0x2f')]({'plain':!![]});var _0x32ff1b=_0xa671('0x30');return db[_0xa671('0x31')][_0xa671('0x2e')]({'where':{'type':_0x32ff1b,'resourceId':_0x12e528['id']}})[_0xa671('0x18')](function(){return _0x431c9b;});})[_0xa671('0x18')](function(){_0x4a5c17[_0xa671('0x24')](0xcc)[_0xa671('0x25')]();});}};}function handleEntityNotFound(_0x4e4713){return function(_0x3aaa82){if(!_0x3aaa82){_0x4e4713[_0xa671('0x23')](0x194);}return _0x3aaa82;};}function handleError(_0x23f20d,_0x1374ff){_0x1374ff=_0x1374ff||0x1f4;return function(_0x263b40){logger[_0xa671('0x1d')](_0x263b40[_0xa671('0x32')]);if(_0x263b40[_0xa671('0x33')]){delete _0x263b40[_0xa671('0x33')];}_0x23f20d[_0xa671('0x24')](_0x1374ff)['send'](_0x263b40);};}function iftimePromise(_0x231cdb,_0x1c0c44){return respondWithRpcPromise(_0xa671('0x34'),_0xa671('0x35'),{'command':_0x1c0c44[_0xa671('0x36')]?util[_0xa671('0x37')]('iftime\x20%s,%s',_0x231cdb[_0xa671('0x38')],_0x1c0c44[_0xa671('0x36')]):util[_0xa671('0x37')]('iftime\x20%s',_0x231cdb[_0xa671('0x38')])},client9002)[_0xa671('0x18')](function(_0x3e8ee0){var _0x4f166d=_0x3e8ee0&&_0x3e8ee0[_0xa671('0x39')]('true')>=0x0?!![]:![];logger['info'](_0xa671('0x3a'),_0x1c0c44['id'],_0x231cdb['id'],_0x231cdb[_0xa671('0x38')],_0x4f166d?_0xa671('0x3b'):'OFFLINE',_0x1c0c44[_0xa671('0x36')]?_0x1c0c44[_0xa671('0x36')]:'No\x20timezone');return _0x4f166d;})[_0xa671('0x22')](function(_0x3b7566){logger[_0xa671('0x1d')](_0xa671('0x3a'),_0x1c0c44['id'],_0x231cdb['id'],_0x231cdb['interval'],util[_0xa671('0x3c')](_0x3b7566,{'showHidden':![],'depth':null}),_0x1c0c44['timezone']?_0x1c0c44[_0xa671('0x36')]:_0xa671('0x3d'));return![];});}function checkWebsiteIntervals(_0x3a7879){var _0xfa06ae=_[_0xa671('0x3e')](_0x3a7879['Interval']['Intervals'],function(_0x49cf9f){var _0x36158c=_0x49cf9f[_0xa671('0x2f')]({'plain':!![]});return iftimePromise(_0x36158c,_0x3a7879);});return Promise[_0xa671('0x3f')](_0xfa06ae)[_0xa671('0x18')](function(_0x23fb31){return _[_0xa671('0x40')](_0x23fb31);});}function createInteractionObject(_0x2ea5da,_0x3c1173,_0x4a6dfb,_0x10b51f){var _0x1bb826=require('user-agent-parser');var _0x455bb4=new _0x1bb826();var _0x5786c5=_0x455bb4[_0xa671('0x41')](_0x4a6dfb[_0xa671('0x42')])[_0xa671('0x43')]();var _0x4aed93=_0x3c1173[_0xa671('0x44')];if(_0x4a6dfb[_0xa671('0x45')]){_0x4aed93=_0x4a6dfb['cf-connecting-ip'];}else if(_0x4a6dfb['x-forwarded-for']){_0x4aed93=_[_0xa671('0x46')](_0x4a6dfb[_0xa671('0x47')][_0xa671('0x48')](','));}return{'ContactId':_0x10b51f['id'],'ChatWebsiteId':_0x2ea5da,'from':(_0x10b51f[_0xa671('0x49')]||'')+'\x20'+(_0x10b51f[_0xa671('0x4a')]||''),'customerIp':_0x4aed93,'customerPort':_0x4a6dfb[_0xa671('0x4b')]?_0x4a6dfb['x-real-port']:null,'referer':_0x3c1173[_0xa671('0x4c')],'browserName':_0x5786c5[_0xa671('0x4d')][_0xa671('0x33')]&&_0x5786c5[_0xa671('0x4d')]['version']?util[_0xa671('0x37')](_0xa671('0x4e'),_0x5786c5['browser'][_0xa671('0x33')],_0x5786c5[_0xa671('0x4d')]['version']):_0xa671('0x4f'),'browserVersion':_0x5786c5[_0xa671('0x4d')][_0xa671('0x50')]||'unknown','osName':util[_0xa671('0x37')](_0xa671('0x4e'),_0x5786c5['os']['name'],_0x5786c5['os'][_0xa671('0x50')]),'osVersion':_0x5786c5['os'][_0xa671('0x50')],'deviceModel':_0x5786c5[_0xa671('0x51')]['model']&&_0x5786c5[_0xa671('0x51')][_0xa671('0x52')]?util['format'](_0xa671('0x53'),_0x5786c5[_0xa671('0x51')][_0xa671('0x54')],_0x5786c5[_0xa671('0x51')][_0xa671('0x52')],_0x5786c5[_0xa671('0x51')][_0xa671('0x55')]):null,'deviceVendor':_0x5786c5['device'][_0xa671('0x52')],'deviceType':_0x5786c5[_0xa671('0x51')]['type'],'formData':JSON[_0xa671('0x1c')](_0x3c1173)};}exports[_0xa671('0x56')]=function(_0x3133d4,_0x1a1200){var _0x29fcd8={'include':[{'model':db[_0xa671('0x57')],'as':_0xa671('0x58')}]},_0x25abdb={},_0x43f71f={'count':0x0,'rows':[]};var _0x163c20=_[_0xa671('0x3e')](db[_0xa671('0x59')][_0xa671('0x5a')],function(_0x2eaa05){return{'name':_0x2eaa05[_0xa671('0x5b')],'type':_0x2eaa05[_0xa671('0x55')][_0xa671('0x5c')]};});_0x25abdb[_0xa671('0x54')]=_[_0xa671('0x3e')](_0x163c20,_0xa671('0x33'));_0x25abdb[_0xa671('0x5d')]=_['keys'](_0x3133d4[_0xa671('0x5d')]);_0x25abdb['filters']=_[_0xa671('0x5e')](_0x25abdb[_0xa671('0x54')],_0x25abdb[_0xa671('0x5d')]);_0x29fcd8[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x25abdb[_0xa671('0x54')],qs[_0xa671('0x60')](_0x3133d4[_0xa671('0x5d')]['fields']));_0x29fcd8[_0xa671('0x5f')]=_0x29fcd8[_0xa671('0x5f')][_0xa671('0x61')]?_0x29fcd8[_0xa671('0x5f')]:_0x25abdb['model'];if(!_0x3133d4[_0xa671('0x5d')][_0xa671('0x62')](_0xa671('0x63'))){_0x29fcd8[_0xa671('0x2a')]=qs[_0xa671('0x2a')](_0x3133d4['query'][_0xa671('0x2a')]);_0x29fcd8['offset']=qs[_0xa671('0x27')](_0x3133d4[_0xa671('0x5d')][_0xa671('0x27')]);}_0x29fcd8['order']=qs[_0xa671('0x64')](_0x3133d4[_0xa671('0x5d')]['sort']);_0x29fcd8[_0xa671('0x65')]=qs[_0xa671('0x66')](_[_0xa671('0x67')](_0x3133d4['query'],_0x25abdb[_0xa671('0x66')]),_0x163c20);if(_0x3133d4[_0xa671('0x5d')][_0xa671('0x68')]){_0x29fcd8[_0xa671('0x65')]=_['merge'](_0x29fcd8[_0xa671('0x65')],{'$or':_['map'](_0x163c20,function(_0x5cc41b){if(_0x5cc41b[_0xa671('0x55')]!=='VIRTUAL'){var _0x136280={};_0x136280[_0x5cc41b[_0xa671('0x33')]]={'$like':'%'+_0x3133d4[_0xa671('0x5d')]['filter']+'%'};return _0x136280;}})});}_0x29fcd8=_['merge']({},_0x29fcd8,_0x3133d4[_0xa671('0x69')]);var _0x48c0b3={'where':_0x29fcd8[_0xa671('0x65')]};return db[_0xa671('0x59')][_0xa671('0x29')](_0x48c0b3)['then'](function(_0x2b95d1){_0x43f71f[_0xa671('0x29')]=_0x2b95d1;if(_0x3133d4[_0xa671('0x5d')][_0xa671('0x6a')]){_0x29fcd8['include']=[{'all':!![]}];}return db[_0xa671('0x59')][_0xa671('0x6b')](_0x29fcd8);})[_0xa671('0x18')](function(_0x589a2b){_0x43f71f['rows']=_0x589a2b;return _0x43f71f;})[_0xa671('0x18')](respondWithFilteredResult(_0x1a1200,_0x29fcd8))[_0xa671('0x22')](handleError(_0x1a1200,null));};exports['show']=function(_0x4d7930,_0x4596e4){var _0x466f69={'raw':![],'where':{'id':_0x4d7930['params']['id']},'include':[{'model':db['Pause'],'as':_0xa671('0x58')}]},_0x1397ac={};_0x1397ac[_0xa671('0x54')]=_['keys'](db['ChatWebsite'][_0xa671('0x5a')]);_0x1397ac['query']=_['keys'](_0x4d7930[_0xa671('0x5d')]);_0x1397ac[_0xa671('0x66')]=_[_0xa671('0x5e')](_0x1397ac[_0xa671('0x54')],_0x1397ac[_0xa671('0x5d')]);_0x466f69[_0xa671('0x5f')]=_['intersection'](_0x1397ac[_0xa671('0x54')],qs[_0xa671('0x60')](_0x4d7930[_0xa671('0x5d')][_0xa671('0x60')]));_0x466f69['attributes']=_0x466f69['attributes'][_0xa671('0x61')]?_0x466f69[_0xa671('0x5f')]:_0x1397ac['model'];if(_0x4d7930[_0xa671('0x5d')][_0xa671('0x6a')]){_0x466f69[_0xa671('0x6c')]=[{'all':!![]}];}_0x466f69=_['merge']({},_0x466f69,_0x4d7930[_0xa671('0x69')]);return db[_0xa671('0x59')][_0xa671('0x6d')](_0x466f69)['then'](handleEntityNotFound(_0x4596e4,null))['then'](respondWithResult(_0x4596e4,null))[_0xa671('0x22')](handleError(_0x4596e4,null));};exports[_0xa671('0x6e')]=function(_0x44b859,_0x1ff0e0){return db[_0xa671('0x59')][_0xa671('0x6e')](_0x44b859[_0xa671('0x6f')],{})[_0xa671('0x18')](function(_0x83cee0){var _0x18a93a=_0x44b859['user'][_0xa671('0x2f')]({'plain':!![]});if(!_0x18a93a)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x18a93a[_0xa671('0x70')]==='user'){var _0x4e4332=_0x83cee0[_0xa671('0x2f')]({'plain':!![]});var _0x13541f='ChatWebsites';return db[_0xa671('0x71')][_0xa671('0x6d')]({'where':{'name':_0x13541f,'userProfileId':_0x18a93a[_0xa671('0x72')]},'raw':!![]})['then'](function(_0x262a92){if(_0x262a92&&_0x262a92[_0xa671('0x73')]===0x0){return db[_0xa671('0x31')][_0xa671('0x6e')]({'name':_0x4e4332[_0xa671('0x33')],'resourceId':_0x4e4332['id'],'type':_0x262a92[_0xa671('0x33')],'sectionId':_0x262a92['id']},{})[_0xa671('0x18')](function(){return _0x83cee0;});}else{return _0x83cee0;}})[_0xa671('0x22')](function(_0xbfd306){logger[_0xa671('0x1d')](_0xa671('0x74'),_0xbfd306);throw _0xbfd306;});}return _0x83cee0;})[_0xa671('0x18')](respondWithResult(_0x1ff0e0,0xc9))['catch'](handleError(_0x1ff0e0,null));};exports['update']=function(_0x1c3627,_0x1566aa){if(_0x1c3627['body']['id']){delete _0x1c3627[_0xa671('0x6f')]['id'];}return db[_0xa671('0x59')]['find']({'where':{'id':_0x1c3627[_0xa671('0x75')]['id']},'include':[{'model':db[_0xa671('0x57')],'as':_0xa671('0x58')}]})[_0xa671('0x18')](handleEntityNotFound(_0x1566aa,null))[_0xa671('0x18')](saveUpdates(_0x1c3627[_0xa671('0x6f')],null))[_0xa671('0x18')](respondWithResult(_0x1566aa,null))['catch'](handleError(_0x1566aa,null));};exports[_0xa671('0x2e')]=function(_0x492be5,_0x4b0e7a){return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x492be5['params']['id']}})['then'](handleEntityNotFound(_0x4b0e7a,null))[_0xa671('0x18')](removeEntity(_0x4b0e7a,null))[_0xa671('0x22')](handleError(_0x4b0e7a,null));};exports[_0xa671('0x76')]=function(_0x2c3611,_0x3f6f3a){return db[_0xa671('0x59')]['describe']()[_0xa671('0x18')](respondWithResult(_0x3f6f3a,null))[_0xa671('0x22')](handleError(_0x3f6f3a,null));};exports['addDisposition']=function(_0x615d9,_0x42c381){if(_0x615d9[_0xa671('0x6f')]['id']){delete _0x615d9[_0xa671('0x6f')]['id'];}return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x615d9[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x42c381,null))[_0xa671('0x18')](function(_0x210ec7){if(_0x210ec7){_0x615d9[_0xa671('0x6f')]['ChatWebsiteId']=_0x210ec7['id'];return db[_0xa671('0x77')][_0xa671('0x6e')](_0x615d9[_0xa671('0x6f')]);}})['then'](respondWithResult(_0x42c381,null))[_0xa671('0x22')](handleError(_0x42c381,null));};exports[_0xa671('0x78')]=function(_0x5f83e4,_0x113b33){var _0x18b906={'raw':![],'where':{}};var _0x13eef0={};var _0x3ff43f={'count':0x0,'rows':[]};return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x5f83e4[_0xa671('0x75')]['id']}})['then'](handleEntityNotFound(_0x113b33,null))[_0xa671('0x18')](function(_0x3a4bd3){if(_0x3a4bd3){_0x13eef0[_0xa671('0x54')]=_['keys'](db[_0xa671('0x77')][_0xa671('0x5a')]);_0x13eef0[_0xa671('0x5d')]=_['keys'](_0x5f83e4['query']);_0x13eef0[_0xa671('0x66')]=_[_0xa671('0x5e')](_0x13eef0[_0xa671('0x54')],_0x13eef0[_0xa671('0x5d')]);_0x18b906[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x13eef0[_0xa671('0x54')],qs[_0xa671('0x60')](_0x5f83e4[_0xa671('0x5d')][_0xa671('0x60')]));_0x18b906[_0xa671('0x5f')]=_0x18b906[_0xa671('0x5f')]['length']?_0x18b906[_0xa671('0x5f')]:_0x13eef0['model'];if(!_0x5f83e4['query'][_0xa671('0x62')](_0xa671('0x63'))){_0x18b906[_0xa671('0x2a')]=qs['limit'](_0x5f83e4[_0xa671('0x5d')][_0xa671('0x2a')]);_0x18b906[_0xa671('0x27')]=qs[_0xa671('0x27')](_0x5f83e4[_0xa671('0x5d')]['offset']);}_0x18b906[_0xa671('0x7a')]=qs['sort'](_0x5f83e4['query']['sort']);_0x18b906[_0xa671('0x65')]=qs[_0xa671('0x66')](_[_0xa671('0x67')](_0x5f83e4['query'],_0x13eef0[_0xa671('0x66')]));_0x18b906[_0xa671('0x65')][_0xa671('0x7b')]=_0x3a4bd3['id'];if(_0x5f83e4[_0xa671('0x5d')][_0xa671('0x68')]){_0x18b906[_0xa671('0x65')]=_[_0xa671('0x7c')](_0x18b906[_0xa671('0x65')],{'$or':_[_0xa671('0x3e')](_0x18b906[_0xa671('0x5f')],function(_0x3b3a50){var _0x51f406={};_0x51f406[_0x3b3a50]={'$like':'%'+_0x5f83e4[_0xa671('0x5d')][_0xa671('0x68')]+'%'};return _0x51f406;})});}_0x18b906=_['merge']({},_0x18b906,_0x5f83e4[_0xa671('0x69')]);return db[_0xa671('0x77')][_0xa671('0x29')]({'where':_0x18b906[_0xa671('0x65')]})[_0xa671('0x18')](function(_0x27587a){_0x3ff43f[_0xa671('0x29')]=_0x27587a;if(_0x5f83e4[_0xa671('0x5d')][_0xa671('0x6a')]){_0x18b906['include']=[{'all':!![]}];}return db[_0xa671('0x77')][_0xa671('0x6b')](_0x18b906);})[_0xa671('0x18')](function(_0x3fd62d){_0x3ff43f[_0xa671('0x7d')]=_0x3fd62d;return _0x3ff43f;});}})['then'](respondWithFilteredResult(_0x113b33,_0x18b906))['catch'](handleError(_0x113b33,null));};exports[_0xa671('0x7e')]=function(_0x44a4ad,_0x3aae7e){return db['ChatWebsite'][_0xa671('0x6d')]({'where':{'id':_0x44a4ad[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x3aae7e,null))[_0xa671('0x18')](function(_0x12574e){if(_0x12574e){return _0x12574e[_0xa671('0x7e')](_0x44a4ad[_0xa671('0x5d')][_0xa671('0x7f')]);}})['then'](respondWithStatusCode(_0x3aae7e,null))[_0xa671('0x22')](handleError(_0x3aae7e,null));};exports['addAnswer']=function(_0x5c34a6,_0x124a98){if(_0x5c34a6[_0xa671('0x6f')]['id']){delete _0x5c34a6[_0xa671('0x6f')]['id'];}return db['ChatWebsite'][_0xa671('0x6d')]({'where':{'id':_0x5c34a6[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x124a98,null))[_0xa671('0x18')](function(_0x37a335){if(_0x37a335){_0x5c34a6[_0xa671('0x6f')][_0xa671('0x7b')]=_0x37a335['id'];return db[_0xa671('0x80')][_0xa671('0x6e')](_0x5c34a6[_0xa671('0x6f')]);}})[_0xa671('0x18')](respondWithResult(_0x124a98,null))[_0xa671('0x22')](handleError(_0x124a98,null));};exports[_0xa671('0x81')]=function(_0x30f0f9,_0x3dac8c){var _0x2194d7={'raw':![],'where':{}};var _0x27d61c={};var _0x8492d1={'count':0x0,'rows':[]};return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x30f0f9[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x3dac8c,null))[_0xa671('0x18')](function(_0x18906c){if(_0x18906c){_0x27d61c[_0xa671('0x54')]=_[_0xa671('0x82')](db['CannedAnswer'][_0xa671('0x5a')]);_0x27d61c['query']=_[_0xa671('0x82')](_0x30f0f9['query']);_0x27d61c['filters']=_[_0xa671('0x5e')](_0x27d61c['model'],_0x27d61c[_0xa671('0x5d')]);_0x2194d7['attributes']=_[_0xa671('0x5e')](_0x27d61c[_0xa671('0x54')],qs[_0xa671('0x60')](_0x30f0f9['query']['fields']));_0x2194d7[_0xa671('0x5f')]=_0x2194d7[_0xa671('0x5f')][_0xa671('0x61')]?_0x2194d7[_0xa671('0x5f')]:_0x27d61c['model'];if(!_0x30f0f9['query'][_0xa671('0x62')](_0xa671('0x63'))){_0x2194d7['limit']=qs['limit'](_0x30f0f9['query'][_0xa671('0x2a')]);_0x2194d7[_0xa671('0x27')]=qs[_0xa671('0x27')](_0x30f0f9['query'][_0xa671('0x27')]);}_0x2194d7[_0xa671('0x7a')]=qs[_0xa671('0x64')](_0x30f0f9[_0xa671('0x5d')]['sort']);_0x2194d7[_0xa671('0x65')]=qs['filters'](_['pick'](_0x30f0f9[_0xa671('0x5d')],_0x27d61c['filters']));_0x2194d7['where']['ChatWebsiteId']=_0x18906c['id'];if(_0x30f0f9['query'][_0xa671('0x68')]){_0x2194d7[_0xa671('0x65')]=_[_0xa671('0x7c')](_0x2194d7[_0xa671('0x65')],{'$or':_[_0xa671('0x3e')](_0x2194d7[_0xa671('0x5f')],function(_0x44f87a){var _0x36352c={};_0x36352c[_0x44f87a]={'$like':'%'+_0x30f0f9['query']['filter']+'%'};return _0x36352c;})});}_0x2194d7=_[_0xa671('0x7c')]({},_0x2194d7,_0x30f0f9[_0xa671('0x69')]);return db[_0xa671('0x80')]['count']({'where':_0x2194d7[_0xa671('0x65')]})[_0xa671('0x18')](function(_0x31836b){_0x8492d1[_0xa671('0x29')]=_0x31836b;if(_0x30f0f9['query']['includeAll']){_0x2194d7[_0xa671('0x6c')]=[{'all':!![]}];}return db[_0xa671('0x80')]['findAll'](_0x2194d7);})[_0xa671('0x18')](function(_0xa20825){_0x8492d1[_0xa671('0x7d')]=_0xa20825;return _0x8492d1;});}})['then'](respondWithFilteredResult(_0x3dac8c,_0x2194d7))['catch'](handleError(_0x3dac8c,null));};exports[_0xa671('0x83')]=function(_0x542735,_0x5c0e4a){return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x542735['params']['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x5c0e4a,null))['then'](function(_0x2c7e77){if(_0x2c7e77){return _0x2c7e77[_0xa671('0x83')](_0x542735['query'][_0xa671('0x7f')]);}})[_0xa671('0x18')](respondWithStatusCode(_0x5c0e4a,null))[_0xa671('0x22')](handleError(_0x5c0e4a,null));};exports[_0xa671('0x84')]=function(_0x361e3b,_0x31abe8){_0x361e3b[_0xa671('0x6f')][_0xa671('0x85')]=_0x361e3b[_0xa671('0x86')][_0xa671('0x87')];return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x361e3b[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x31abe8,null))[_0xa671('0x18')](saveUpdates(_0x361e3b['body'],null))[_0xa671('0x18')](respondWithResult(_0x31abe8,null))['catch'](handleError(_0x31abe8,null));};exports[_0xa671('0x88')]=function(_0x439141,_0x195019){_0x439141['body'][_0xa671('0x89')]=_0x439141[_0xa671('0x86')][_0xa671('0x87')];return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x439141[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x195019,null))[_0xa671('0x18')](saveUpdates(_0x439141[_0xa671('0x6f')],null))[_0xa671('0x18')](respondWithResult(_0x195019,null))[_0xa671('0x22')](handleError(_0x195019,null));};exports['addCustomerAvatar']=function(_0x51eed8,_0x8b5a88){_0x51eed8['body']['customerAvatar']=_0x51eed8[_0xa671('0x86')][_0xa671('0x87')];return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x51eed8[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x8b5a88,null))[_0xa671('0x18')](saveUpdates(_0x51eed8[_0xa671('0x6f')],null))[_0xa671('0x18')](respondWithResult(_0x8b5a88,null))[_0xa671('0x22')](handleError(_0x8b5a88,null));};exports[_0xa671('0x8a')]=function(_0x11cf22,_0x3fc688){_0x11cf22[_0xa671('0x6f')][_0xa671('0x8b')]=_0x11cf22[_0xa671('0x86')][_0xa671('0x87')];return db[_0xa671('0x59')]['find']({'where':{'id':_0x11cf22[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x3fc688,null))[_0xa671('0x18')](saveUpdates(_0x11cf22[_0xa671('0x6f')],null))['then'](respondWithResult(_0x3fc688,null))[_0xa671('0x22')](handleError(_0x3fc688,null));};exports[_0xa671('0x8c')]=function(_0x3879da,_0x443f39){var _0x239417=path[_0xa671('0x8d')](config[_0xa671('0x8e')],'server/files/images/logos/default_logo.svg');var _0x3223c6={'where':{'id':_0x3879da[_0xa671('0x75')]['id']},'attributes':['id',_0xa671('0x85')],'raw':!![]};var _0x321345=![];return require(_0xa671('0x8f'))[_0xa671('0x90')]()['then'](function(_0x28e306){if(_0x28e306){_0x321345=_0x28e306[_0xa671('0x91')];}})[_0xa671('0x18')](function(){return db[_0xa671('0x59')][_0xa671('0x6d')](_0x3223c6);})[_0xa671('0x18')](handleEntityNotFound(_0x443f39,null))[_0xa671('0x18')](function(_0x257c65){if(_0x257c65){if(!_[_0xa671('0x92')](_0x257c65[_0xa671('0x85')])){if(fs[_0xa671('0x93')](path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0x94'),_0x257c65[_0xa671('0x85')]))&&_0x321345){_0x239417=path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0x94'),_0x257c65['sitepic']);}}return _0x443f39[_0xa671('0x95')](_0x239417);}})[_0xa671('0x22')](handleError(_0x443f39,null));};exports['getAvatar']=function(_0x5d3057,_0x2f3514){var _0x4893d3=path['join'](config['root'],_0xa671('0x96'));var _0x276831={'where':{'id':_0x5d3057[_0xa671('0x75')]['id']},'attributes':['id',_0xa671('0x89')],'raw':!![]};return db[_0xa671('0x59')][_0xa671('0x6d')](_0x276831)[_0xa671('0x18')](handleEntityNotFound(_0x2f3514,null))[_0xa671('0x18')](function(_0x8eb126){if(_0x8eb126){if(!_['isNil'](_0x8eb126['agentAvatar'])){if(fs[_0xa671('0x93')](path['join'](config[_0xa671('0x8e')],_0xa671('0x97'),_0x8eb126['agentAvatar']))){_0x4893d3=path[_0xa671('0x8d')](config[_0xa671('0x8e')],'server/files/images/avatars/',_0x8eb126[_0xa671('0x89')]);}}return _0x2f3514[_0xa671('0x95')](_0x4893d3);}})['catch'](handleError(_0x2f3514,null));};exports[_0xa671('0x98')]=function(_0x5a2e12,_0x1a789b){var _0x1d1ff4=path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0x99'));var _0x441ecb={'where':{'id':_0x5a2e12['params']['id']},'attributes':['id','customerAvatar',_0xa671('0x9a')],'raw':!![]};return db['ChatWebsite'][_0xa671('0x6d')](_0x441ecb)[_0xa671('0x18')](handleEntityNotFound(_0x1a789b,null))[_0xa671('0x18')](function(_0x3e09d0){if(_0x3e09d0){if(!_[_0xa671('0x92')](_0x3e09d0[_0xa671('0x9b')])){if(fs[_0xa671('0x93')](path[_0xa671('0x8d')](config['root'],_0xa671('0x97'),_0x3e09d0[_0xa671('0x9b')]))&&_0x3e09d0[_0xa671('0x9a')]){_0x1d1ff4=path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0x97'),_0x3e09d0[_0xa671('0x9b')]);}}return _0x1a789b['download'](_0x1d1ff4);}})[_0xa671('0x22')](handleError(_0x1a789b,null));};exports[_0xa671('0x9c')]=function(_0x362c31,_0x42098e){var _0x44838a=path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0x9d'));var _0x45da4b={'where':{'id':_0x362c31['params']['id']},'attributes':['id',_0xa671('0x8b')],'raw':!![]};return db[_0xa671('0x59')][_0xa671('0x6d')](_0x45da4b)[_0xa671('0x18')](handleEntityNotFound(_0x42098e,null))['then'](function(_0x150978){if(_0x150978){if(!_['isNil'](_0x150978[_0xa671('0x8b')])){if(fs[_0xa671('0x93')](path[_0xa671('0x8d')](config['root'],_0xa671('0x97'),_0x150978[_0xa671('0x8b')]))){_0x44838a=path[_0xa671('0x8d')](config[_0xa671('0x8e')],'server/files/images/avatars/',_0x150978[_0xa671('0x8b')]);}}return _0x42098e[_0xa671('0x95')](_0x44838a);}})[_0xa671('0x22')](handleError(_0x42098e,null));};exports[_0xa671('0x9e')]=function(_0xd3307a,_0x2d126b){var _0x231a8d={'body':_0xd3307a[_0xa671('0x6f')],'channel':_0xa671('0x9f')};var _0x10d739=[];var _0x167912=[];var _0x26a137={};var _0x33786f=![];return db[_0xa671('0xa0')][_0xa671('0x76')]()[_0xa671('0x18')](function(_0x41e31c){if(!_0x41e31c){throw new db[(_0xa671('0xa1'))]['ValidationError'](_0xa671('0xa2'));}_0x10d739=_['difference'](_[_0xa671('0x82')](_0x41e31c),[_0xa671('0xa3'),'updatedAt']);_0x167912=_[_0xa671('0xa4')](_[_0xa671('0x82')](_0x41e31c),['createdAt',_0xa671('0xa5'),'CompanyId',_0xa671('0xa6')]);if(_0xd3307a[_0xa671('0x6f')]['id']){delete _0xd3307a[_0xa671('0x6f')]['id'];}if(_[_0xa671('0x92')](_0xd3307a[_0xa671('0x6f')][_0xa671('0xa7')])){throw new db[(_0xa671('0xa1'))][(_0xa671('0xa8'))](_0xa671('0xa9'));}if(_[_0xa671('0x92')](_0xd3307a[_0xa671('0x6f')]['body'])||_0xd3307a[_0xa671('0x6f')]['body']===''){throw new db[(_0xa671('0xa1'))][(_0xa671('0xa8'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_['isNil'](_0xd3307a[_0xa671('0x6f')][_0xa671('0xaa')])){throw new db[(_0xa671('0xa1'))][(_0xa671('0xa8'))](_0xa671('0xab')+_0x167912);}if(!_[_0xa671('0xac')](_0x167912,_0xd3307a[_0xa671('0x6f')][_0xa671('0xaa')])){throw new db['Sequelize'][(_0xa671('0xa8'))](_0xa671('0xad')+_0x167912);}_0x26a137[_0xd3307a['body'][_0xa671('0xaa')]]=_0xd3307a[_0xa671('0x6f')]['from'];})[_0xa671('0x18')](function(){return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0xd3307a[_0xa671('0x75')]['id']},'include':[{'model':db[_0xa671('0xae')],'as':_0xa671('0xaf'),'include':[{'model':db['CmContact'],'as':'Contacts','where':_0x26a137,'limit':0x1,'order':[[_0xa671('0xa5'),_0xa671('0xb0')]]}]},{'model':db[_0xa671('0xb1')],'as':_0xa671('0xb2')},{'model':db[_0xa671('0xb3')],'as':_0xa671('0xb3'),'include':[{'model':db[_0xa671('0xb3')],'as':_0xa671('0xb4'),'attributes':['id',_0xa671('0x38')],'raw':!![]}]}]});})[_0xa671('0x18')](function(_0x1a5606){if(!_0x1a5606)throw new APINotFoundError(util['format'](_0xa671('0xb5'),_0xd3307a['params']['id']));if(!_0x1a5606[_0xa671('0xb3')]||!_0x1a5606[_0xa671('0xb3')][_0xa671('0xb4')])return[_0x1a5606,!![]];return[_0x1a5606,checkWebsiteIntervals(_0x1a5606)];})['spread'](function(_0x40c7fe,_0x5db064){if(!_0x5db064)throw new APIOutOfIntervalError();if(!_0x40c7fe['List'])return;_0x231a8d[_0xa671('0xb6')]=_0x40c7fe;_0x231a8d[_0xa671('0xb7')]=_0x40c7fe[_0xa671('0xaf')];_0x231a8d[_0xa671('0xb8')]=_[_0xa671('0xb9')](_0x40c7fe[_0xa671('0xb2')],[_0xa671('0xba')],[_0xa671('0xbb')]);if(_0x231a8d[_0xa671('0xb6')][_0xa671('0xb2')]){delete _0x231a8d[_0xa671('0xb6')][_0xa671('0xb2')];}if(_0x231a8d[_0xa671('0xb6')][_0xa671('0xaf')]&&_0x231a8d[_0xa671('0xb6')][_0xa671('0xaf')][_0xa671('0xbc')][_0xa671('0x61')]){return _0x231a8d[_0xa671('0xb6')][_0xa671('0xaf')][_0xa671('0xbc')][0x0];}var _0x268793=_[_0xa671('0xbd')](_0xd3307a[_0xa671('0x6f')],{'firstName':_0xd3307a['body'][_0xa671('0xa7')],'ListId':_0x40c7fe['ListId']});_0x268793[_0xd3307a[_0xa671('0x6f')][_0xa671('0xaa')]]=_0xd3307a[_0xa671('0x6f')][_0xa671('0xa7')];return db[_0xa671('0xa0')]['create'](_0x268793,{'fields':_0x10d739,'raw':!![]});})[_0xa671('0x18')](function(_0x3c1892){_0x231a8d[_0xa671('0xbe')]=_0x3c1892;var _0x454ade=createInteractionObject(_0xd3307a['params']['id'],_0xd3307a['body'],_0xd3307a['headers'],_0x3c1892);var _0xcdd55c={'ChatWebsiteId':_0xd3307a[_0xa671('0x75')]['id'],'closed':![]};if(_0xd3307a['body']['threadId']){_0xcdd55c['threadId']=_0xd3307a[_0xa671('0x6f')]['threadId'];return db['ChatInteraction'][_0xa671('0x6d')]({'where':_0xcdd55c})[_0xa671('0x18')](function(_0x174dd0){if(_0x174dd0){_0x33786f=!![];return _0x174dd0;}_0x454ade[_0xa671('0xbf')]=_0xd3307a['body'][_0xa671('0xbf')];_0x454ade['externalUrl']=_0xd3307a[_0xa671('0x6f')][_0xa671('0xc0')];return db[_0xa671('0xc1')][_0xa671('0x6e')](_0x454ade);});}_0xcdd55c['ContactId']=_0x3c1892['id'];if(_0xd3307a[_0xa671('0x6f')][_0xa671('0xc2')]&&_0xd3307a[_0xa671('0x6f')][_0xa671('0xc2')]['id']){_0xcdd55c['id']=_0xd3307a[_0xa671('0x6f')][_0xa671('0xc2')]['id'];return db[_0xa671('0xc1')][_0xa671('0x6d')]({'where':_0xcdd55c})['then'](function(_0x2c5482){if(_0x2c5482){_0x33786f=!![];return _0x2c5482;}return db[_0xa671('0xc1')][_0xa671('0x6e')](_0x454ade);});}return db[_0xa671('0xc1')]['create'](_0x454ade);})[_0xa671('0x18')](function(_0x48368c){if(!_0x33786f)return _0x48368c;var _0x54a174={'from':(_0x231a8d[_0xa671('0xbe')][_0xa671('0x49')]||'')+'\x20'+(_0x231a8d[_0xa671('0xbe')][_0xa671('0x4a')]||'')};if(_0xd3307a[_0xa671('0x6f')][_0xa671('0xbf')]&&_0xd3307a[_0xa671('0x6f')][_0xa671('0xc3')]&&_0xd3307a['body'][_0xa671('0xbf')]!=_0xd3307a[_0xa671('0x6f')][_0xa671('0xc3')]){_0x54a174['threadId']=_0xd3307a[_0xa671('0x6f')][_0xa671('0xc3')];}return _0x48368c[_0xa671('0x2d')](_0x54a174);})[_0xa671('0x18')](function(_0x50bca0){_0x231a8d[_0xa671('0xc2')]=_0x50bca0['get']({'plain':!![]});_0x231a8d[_0xa671('0xc2')][_0xa671('0xc4')]=!_0x33786f;if(_0x231a8d[_0xa671('0xc2')][_0xa671('0xc4')]){if(_0x231a8d[_0xa671('0xb6')][_0xa671('0xc5')]){_0x231a8d['applications'][_0xa671('0xc6')]({'id':0x0,'priority':_0x231a8d[_0xa671('0xb8')]['length']+0x1,'app':_0xa671('0xc7'),'appdata':_0xa671('0xc8'),'interval':'*,*,*,*'});}}return db[_0xa671('0xc9')][_0xa671('0x6e')]({'body':_0xd3307a['body'][_0xa671('0x6f')],'ChatWebsiteId':_0xd3307a[_0xa671('0x75')]['id'],'ChatInteractionId':_0x50bca0['id'],'direction':'in','ContactId':_0x231a8d[_0xa671('0xbe')]['id'],'AttachmentId':_0xd3307a[_0xa671('0x6f')][_0xa671('0xca')]});})['then'](function(_0x5812b3){_0x231a8d[_0xa671('0x1f')]=_0x5812b3;if(!_0x231a8d[_0xa671('0xc2')][_0xa671('0xcb')]){return;}return db['User']['find']({'attributes':['id',_0xa671('0x33')],'where':{'id':_0x231a8d[_0xa671('0xc2')]['UserId']}});})[_0xa671('0x18')](function(_0x402863){if(_0x402863){_0x231a8d[_0xa671('0xb8')]['unshift']({'id':0x0,'priority':0x0,'app':_0xa671('0xcc'),'appdata':_0x402863[_0xa671('0x33')]+','+(_0x231a8d[_0xa671('0xb6')][_0xa671('0xcd')]||0xa),'interval':_0xa671('0xce')});_0x231a8d[_0xa671('0xcf')]=!![];}if(!_0x231a8d[_0xa671('0xc2')][_0xa671('0xd0')]){return;}return db[_0xa671('0xd1')][_0xa671('0x6d')]({'attributes':['id',_0xa671('0x33')],'where':{'id':_0x231a8d[_0xa671('0xc2')][_0xa671('0xd0')]}});})[_0xa671('0x18')](function(_0x33ad5c){if(_0x33ad5c){_0x231a8d['applications'][_0xa671('0xd2')]({'id':0x0,'priority':0x1,'app':_0xa671('0xd3'),'appdata':_0x33ad5c[_0xa671('0x33')]+','+(_0x231a8d[_0xa671('0xb6')][_0xa671('0xd4')]||0x12c),'interval':_0xa671('0xce')});}return respondWithRpcPromise(_0xa671('0xd5'),_0xa671('0xd6'),_0x231a8d);})[_0xa671('0x18')](function(_0x585c86){respondWithRpcPromise(_0xa671('0xd7'),_0xa671('0xd7'),{'event':_0xa671('0x9e'),'message':_0x585c86},client9002);return _0x585c86;})[_0xa671('0x18')](respondWithResult(_0x2d126b,null))[_0xa671('0x22')](APIHandleError(_0x2d126b));};exports[_0xa671('0xd8')]=function(_0x5a1f38,_0x4dbeb5){var _0x21b488,_0x315f1e,_0x5e28e8;var _0x4c3d6d=[];var _0x9ca8c2={};var _0xb50ab9=_0x5a1f38[_0xa671('0xd9')]||[];var _0x6baa4d=[];var _0x37a5b9;return db[_0xa671('0xa0')][_0xa671('0x76')]()[_0xa671('0x18')](function(_0x32295e){if(!_0x32295e){throw new db['Sequelize'][(_0xa671('0xa8'))](_0xa671('0xa2'));}_0x4c3d6d=_['difference'](_['keys'](_0x32295e),[_0xa671('0xa3'),_0xa671('0xa5'),_0xa671('0xda'),'ListId']);if(_0x5a1f38[_0xa671('0x6f')]['id']){delete _0x5a1f38[_0xa671('0x6f')]['id'];}if(_[_0xa671('0x92')](_0x5a1f38[_0xa671('0x6f')][_0xa671('0xa7')])){throw _0x4dbeb5[_0xa671('0x24')](0x1f4)['send'](new db[(_0xa671('0xa1'))][(_0xa671('0xa8'))](_0xa671('0xa9')));}if(_[_0xa671('0x92')](_0x5a1f38[_0xa671('0x6f')][_0xa671('0x6f')])||_0x5a1f38[_0xa671('0x6f')][_0xa671('0x6f')]===''){throw _0x4dbeb5[_0xa671('0x24')](0x1f4)[_0xa671('0xdb')](new db[(_0xa671('0xa1'))][(_0xa671('0xa8'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0xa671('0x92')](_0x5a1f38[_0xa671('0x6f')]['mapKeyOffline'])){throw _0x4dbeb5[_0xa671('0x24')](0x1f4)[_0xa671('0xdb')](new db[(_0xa671('0xa1'))][(_0xa671('0xa8'))](_0xa671('0xdc')+_0x4c3d6d));}if(!_[_0xa671('0xac')](_0x4c3d6d,_0x5a1f38[_0xa671('0x6f')][_0xa671('0xdd')])){throw _0x4dbeb5[_0xa671('0x24')](0x1f4)[_0xa671('0xdb')](new db['Sequelize']['ValidationError'](_0xa671('0xde')+_0x4c3d6d));}_0x9ca8c2[_0x5a1f38[_0xa671('0x6f')][_0xa671('0xdd')]]=_0x5a1f38[_0xa671('0x6f')]['from'];})[_0xa671('0x18')](function(){return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x5a1f38[_0xa671('0x75')]['id']},'include':[{'model':db['CmList'],'as':_0xa671('0xaf')},{'model':db[_0xa671('0xdf')],'as':_0xa671('0xdf')}]});})[_0xa671('0x18')](handleEntityNotFound(_0x4dbeb5,null))['then'](function(_0x44688e){if(_0x44688e&&_0x44688e['List']){_0x315f1e=_0x44688e;var _0x3f1ed2=_[_0xa671('0xbd')](_0x5a1f38[_0xa671('0x6f')],{'firstName':_0x5a1f38[_0xa671('0x6f')][_0xa671('0xa7')],'phone':_0x5a1f38['body'][_0xa671('0xa7')],'ListId':_0x44688e[_0xa671('0xa6')]});_0x3f1ed2[_0x5a1f38[_0xa671('0x6f')][_0xa671('0xdd')]]=_0x5a1f38[_0xa671('0x6f')][_0xa671('0xa7')];return db[_0xa671('0xa0')][_0xa671('0xe0')]({'where':_0x9ca8c2,'defaults':_0x3f1ed2});}})[_0xa671('0xe1')](function(_0xa34564){if(_0xa34564){_0x5e28e8=_0xa34564;var _0x2a3d8e=fs[_0xa671('0xe2')](path['join'](config[_0xa671('0x8e')],'server/files/templates/chatOfflineMessage.ejs'),'utf8');var _0x244e61=ejs['render'](_0x2a3d8e,{'body':_[_0xa671('0xe3')](_0x5a1f38['body'][_0xa671('0x6f')]),'bodyTitle':_0x315f1e[_0xa671('0xe4')]});return db[_0xa671('0xe5')]['create']({'body':_0x244e61,'plainBody':htmlToText[_0xa671('0xe6')](_0x244e61),'ContactId':_0xa34564['id'],'ChatWebsiteId':_0x315f1e['id']});}})[_0xa671('0x18')](function(_0x2ef7a6){_0x37a5b9=_0x2ef7a6;if(_0xb50ab9['length']){var _0x220a1b=_0xb50ab9['map'](function(_0x194bf5){return{'name':_0x194bf5['originalname'],'basename':_0x194bf5[_0xa671('0x87')],'type':_0x194bf5['mimetype'],'ChatOfflineMessageId':_0x2ef7a6['id']};});_0x6baa4d=_0x220a1b[_0xa671('0x3e')](_0x5603b5=>{var _0x4ba825={'filename':_0x5603b5[_0xa671('0x33')],'path':path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0xe7'),'files',_0xa671('0xe8'),_0xa671('0xe9'),_0x5603b5[_0xa671('0xea')])};return _0x4ba825;});if(!_0x315f1e[_0xa671('0xeb')]){return db['sequelize'][_0xa671('0xec')](function(_0x62f02f){return db[_0xa671('0xed')]['bulkCreate'](_0x220a1b,{'transaction':_0x62f02f});});}}})['then'](function(){if(_0x37a5b9){_0x21b488=_0x37a5b9;return db[_0xa671('0xdf')][_0xa671('0x79')]({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':_0xa671('0xee'),'raw':!![],'include':[{'model':db[_0xa671('0xef')],'as':_0xa671('0xef'),'raw':!![]}]}]});}})['then'](function(_0x24274b){if(_0x24274b&&_0x24274b[_0xa671('0xee')]&&_0x315f1e[_0xa671('0xf0')]&&_0x315f1e[_0xa671('0xf1')]){var _0x58a2bf=_0x24274b[_0xa671('0xf2')]();return respondWithRpcPromise(_0xa671('0xf3'),'sendMail',{'account':_0x58a2bf,'message':{'from':util[_0xa671('0x37')](_0xa671('0xf4'),_0x24274b['name'],_0x24274b[_0xa671('0xf5')]||_0x24274b[_0xa671('0xee')][_0xa671('0xf6')]),'to':_0x315f1e[_0xa671('0xf1')],'subject':_0x315f1e[_0xa671('0xf7')],'html':_0x21b488['body'],'attachments':_0x6baa4d}},client9003)[_0xa671('0x18')](function(){return _0x21b488;})[_0xa671('0x22')](function(_0x2cc72e){logger[_0xa671('0x1d')](_0x2cc72e);});}})['then'](function(){if(_0x315f1e&&_0x315f1e['openNewInteraction']&&_0x315f1e[_0xa671('0xf8')]){var _0xde4625=[];if(_0xb50ab9['length']){_0xde4625=_0xb50ab9['map'](function(_0x1f6e3a){return{'name':_0x1f6e3a[_0xa671('0xf9')],'basename':_0x1f6e3a[_0xa671('0x87')],'type':_0x1f6e3a[_0xa671('0xfa')],'ChatOfflineMessageId':_0x37a5b9['id']};});}var _0x6d444f;if(!_['isNil'](_0x315f1e[_0xa671('0xfb')])){var _0x389ef5=_['map'](_0x5a1f38[_0xa671('0x6f')],function(_0x56a103){return _0x56a103;});var _0x3c52b1=_[_0xa671('0xfc')](_0x389ef5)[0x0];var _0x21b4f1=_['mapValues'](_0x3c52b1,function(_0x3db0c4){return _0x3db0c4;});_0x6d444f=_0x21b4f1[0x1][_0x315f1e[_0xa671('0xfb')]];}var _0x416a0c={'from':_0x5e28e8[_0xa671('0xf5')],'firstName':_0x5e28e8[_0xa671('0x49')],'lastName':_0x5e28e8[_0xa671('0x4a')],'mapKey':_0xa671('0xf5'),'message':{'from':_0x5e28e8[_0xa671('0xf5')],'to':_0x315f1e['MailAccount'][_0xa671('0xf5')],'cc':'','subject':_[_0xa671('0x92')](_0x6d444f)?_0x315f1e[_0xa671('0xf7')]:_0x6d444f,'messageId':'','sentAt':new Date(),'attach':_0xde4625['length'],'attachments':_0xde4625,'originChannel':'Chat','ChatWebsiteId':_0x315f1e['id'],'ChatOfflineMessageId':_0x21b488['id'],'originTo':_0x315f1e['MailAccount'][_0xa671('0xf5')]},'body':_0x21b488[_0xa671('0x6f')]};var _0x180f0d={'account':{'id':_0x315f1e[_0xa671('0xf8')]},'body':_0x416a0c,'log':'NotifyMailAccount'};return respondWithRpcPromise(_0xa671('0xfd'),_0xa671('0xfe'),_0x180f0d,client9001)[_0xa671('0x18')](function(){return _0x21b488;})[_0xa671('0x22')](function(_0x416384){logger[_0xa671('0x1d')](_0x416384);});}return;})['then'](function(){if(_0x21b488){return _0x21b488;}})[_0xa671('0x18')](respondWithResult(_0x4dbeb5,null))[_0xa671('0x22')](function(){for(var _0x50dde1 of _0xb50ab9){var _0x3ef76a=path[_0xa671('0x8d')](config['root'],_0xa671('0xe7'),_0xa671('0xd9'),'attachments',_0xa671('0xe9'),_0x50dde1[_0xa671('0x87')]);fs_extra['remove'](_0x3ef76a)['catch'](function(_0x41e0b3){logger['error'](_0xa671('0xff'),_0x3ef76a,_0x41e0b3);});}});};exports[_0xa671('0x100')]=function(_0x1fa555,_0x59a8bb){return db[_0xa671('0xc1')]['find']({'where':{'id':_0x1fa555[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x59a8bb,null))[_0xa671('0x18')](function(_0x16fdfd){if(_0x16fdfd){return _0x16fdfd[_0xa671('0x100')](_0x1fa555['body'][_0xa671('0x7f')],_[_0xa671('0x101')](_0x1fa555['body'],[_0xa671('0x7f'),'id'])||{});}})['then'](respondWithResult(_0x59a8bb,null))[_0xa671('0x22')](handleError(_0x59a8bb,null));};exports[_0xa671('0x102')]=function(_0x57255b,_0x4fd3cc){var _0x50371f={'raw':![],'where':{}};var _0x36a3b9={};var _0x53d56f={'count':0x0,'rows':[]};return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x57255b[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x4fd3cc,null))[_0xa671('0x18')](function(_0x3b4cd7){if(_0x3b4cd7){_0x36a3b9[_0xa671('0x54')]=_[_0xa671('0x82')](db[_0xa671('0xc1')][_0xa671('0x5a')]);_0x36a3b9[_0xa671('0x5d')]=_[_0xa671('0x82')](_0x57255b[_0xa671('0x5d')]);_0x36a3b9[_0xa671('0x66')]=_[_0xa671('0x5e')](_0x36a3b9['model'],_0x36a3b9['query']);_0x50371f[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x36a3b9['model'],qs[_0xa671('0x60')](_0x57255b[_0xa671('0x5d')]['fields']));_0x50371f[_0xa671('0x5f')]=_0x50371f[_0xa671('0x5f')][_0xa671('0x61')]?_0x50371f[_0xa671('0x5f')]:_0x36a3b9[_0xa671('0x54')];if(!_0x57255b['query'][_0xa671('0x62')]('nolimit')){_0x50371f['limit']=qs[_0xa671('0x2a')](_0x57255b[_0xa671('0x5d')]['limit']);_0x50371f[_0xa671('0x27')]=qs[_0xa671('0x27')](_0x57255b[_0xa671('0x5d')][_0xa671('0x27')]);}_0x50371f[_0xa671('0x7a')]=qs[_0xa671('0x64')](_0x57255b[_0xa671('0x5d')][_0xa671('0x64')]);_0x50371f['where']=qs['filters'](_[_0xa671('0x67')](_0x57255b['query'],_0x36a3b9[_0xa671('0x66')]));_0x50371f[_0xa671('0x65')][_0xa671('0x7b')]=_0x3b4cd7['id'];if(_0x57255b[_0xa671('0x5d')][_0xa671('0x68')]){_0x50371f[_0xa671('0x65')]=_[_0xa671('0x7c')](_0x50371f['where'],{'$or':_['map'](_0x50371f[_0xa671('0x5f')],function(_0x390352){var _0x479ecd={};_0x479ecd[_0x390352]={'$like':'%'+_0x57255b[_0xa671('0x5d')]['filter']+'%'};return _0x479ecd;})});}_0x50371f=_['merge']({},_0x50371f,_0x57255b[_0xa671('0x69')]);return db[_0xa671('0xc1')]['count']({'where':_0x50371f[_0xa671('0x65')]})[_0xa671('0x18')](function(_0x5a7b1a){_0x53d56f['count']=_0x5a7b1a;if(_0x57255b[_0xa671('0x5d')][_0xa671('0x6a')]){_0x50371f[_0xa671('0x6c')]=[{'model':db[_0xa671('0xa0')],'as':_0xa671('0x103'),'required':![]},{'model':db['User'],'as':_0xa671('0x104'),'attributes':['name',_0xa671('0x105'),'internal'],'required':![]},{'model':db[_0xa671('0x106')],'as':_0xa671('0x107'),'attributes':['id',_0xa671('0x33'),_0xa671('0x108')],'where':_0x57255b[_0xa671('0x5d')]['tag']?{'id':_0x57255b['query'][_0xa671('0x109')]}:undefined,'required':_0x57255b[_0xa671('0x5d')]['tag']?!![]:![]}];}return db[_0xa671('0xc1')]['findAll'](_0x50371f);})[_0xa671('0x18')](function(_0xb90da4){_0x53d56f['rows']=_0xb90da4;return _0x53d56f;});}})[_0xa671('0x18')](respondWithFilteredResult(_0x4fd3cc,_0x50371f))[_0xa671('0x22')](handleError(_0x4fd3cc,null));};exports[_0xa671('0x35')]=function(_0x521972,_0xfc8411){var _0x5c6dbe=0x0;var _0x52fea4=0x0;var _0x5aeae1=![];var _0x9e00af;var _0x2540f7;return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x521972[_0xa671('0x75')]['id']},'include':[{'model':db[_0xa671('0xb3')],'as':_0xa671('0xb3'),'include':[{'model':db[_0xa671('0xb3')],'as':'Intervals','attributes':['id','interval']}]}]})[_0xa671('0x18')](handleEntityNotFound(_0xfc8411,null))[_0xa671('0x18')](function(_0x5b9266){if(_0x5b9266){_0x9e00af=_0x5b9266;return _0x5b9266['getProactiveActions']({'raw':!![]});}})[_0xa671('0x18')](function(_0x1b77ff){if(_0x9e00af){if(_0x1b77ff){_0x2540f7=_0x1b77ff;}}return require('../../config/license/util')[_0xa671('0x90')]();})[_0xa671('0x18')](function(_0x337e9b){if(_0x337e9b){_0x52fea4=_0x337e9b['virtual'];_0x5aeae1=_0x337e9b[_0xa671('0x91')];}})[_0xa671('0x18')](function(){return db['ChatInteraction'][_0xa671('0x29')]({'where':{'closed':![]}});})[_0xa671('0x18')](function(_0x597081){_0x5c6dbe=_0x597081;if(_0x52fea4&&_0x597081>_0x52fea4){return db[_0xa671('0x10a')][_0xa671('0x79')]({'where':{'id':0x1}})[_0xa671('0x18')](function(_0x49deae){if(_0x49deae){_0x49deae['increment'](_0xa671('0x10b'));}});}})[_0xa671('0x18')](function(){if(!_0x9e00af[_0xa671('0xb3')]||!_0x9e00af['Interval'][_0xa671('0xb4')])return!![];return checkWebsiteIntervals(_0x9e00af);})[_0xa671('0x18')](function(_0x1e0044){var _0x397098=fs['readFileSync'](path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0x10c')),_0xa671('0x10d'));var _0x3eddb1=new url[(_0xa671('0x10e'))](_0x9e00af['address'])[_0xa671('0x10f')];var _0x2b7a58=_0xa671('0x110');var _0x31f00a=![];var _0x5822cb={'chatVersion':_0x2b7a58,'chatWebsiteAddressOrigin':_0x3eddb1,'remote':_0x9e00af[_0xa671('0x111')],'query':querystring[_0xa671('0x1c')](_['merge'](_0x9e00af[_0xa671('0x2f')]({'plain':!![]}),{'customerIp':_0x521972[_0xa671('0x112')][_0xa671('0x47')]||_0x521972[_0xa671('0x112')][_0xa671('0x113')]||_0x521972['connection'][_0xa671('0x114')]||_0x521972['ip'],'referer':_0x521972[_0xa671('0x112')][_0xa671('0x4c')],'openedInteractions':_0x5c6dbe,'maxInteractions':_0x52fea4,'virtual':_0x5aeae1[_0xa671('0x115')],'online':_0x1e0044,'custom':_0x5aeae1}))[_0xa671('0x116')](/'/g,'\x5c\x27')};_0xfc8411['send'](ejs['render'](Mustache[_0xa671('0x117')](_0x397098,_0x5822cb),{'proactiveActions':_0x2540f7,'alignment':_0x9e00af[_0xa671('0x118')],'verticalAlignment':_0x9e00af[_0xa671('0x119')],'div_color':_0x9e00af['color'],'labelText':_0x9e00af[_0xa671('0x11a')],'text_color':_0x9e00af['textColor'],'text_button_color':_0x9e00af[_0xa671('0x11b')],'button_color':_0x9e00af[_0xa671('0x11c')],'background_color':_0x9e00af[_0xa671('0x11d')],'hideWhenOffline':_0x9e00af[_0xa671('0x11e')],'intervalId':_0x9e00af[_0xa671('0x11f')],'isDevelopment':_0x31f00a,'chatVersion':_0x2b7a58}));})[_0xa671('0x22')](handleError(_0xfc8411,null));};exports[_0xa671('0x120')]=function(_0x120c67,_0x16b53a){var _0x1d8dc2=_0x120c67[_0xa671('0x75')]['id'];var _0x321f05=_0x120c67[_0xa671('0x6f')];var _0x4cbcde=0xc8;var _0xbd77db=null;return db[_0xa671('0x121')][_0xa671('0xec')]({'isolationLevel':db['sequelize'][_0xa671('0x122')][_0xa671('0x123')][_0xa671('0x124')]},function(_0x21930d){return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x1d8dc2},'transaction':_0x21930d})[_0xa671('0x18')](function(_0x5abd3e){if(_0x5abd3e){return db[_0xa671('0xb1')]['destroy']({'where':{'ChatWebsiteId':_0x1d8dc2},'transaction':_0x21930d})[_0xa671('0x18')](function(){var _0x22e985=_[_0xa671('0x3e')](_0x321f05,function(_0x2fc56f){_0x2fc56f[_0xa671('0x7b')]=_0x1d8dc2;return _0x2fc56f;});return db['ChatApplication']['bulkCreate'](_0x22e985,{'transaction':_0x21930d});});}else{_0x4cbcde=0x194;_0xbd77db=[];}});})[_0xa671('0x18')](function(){if(_0x4cbcde!==0x194){return db[_0xa671('0xb1')][_0xa671('0x125')]({'where':{'ChatWebsiteId':_0x1d8dc2},'order':_0xa671('0xba')})['then'](function(_0x31feef){_0xbd77db=_0x31feef;});}})['catch'](function(_0x2987cf){_0x4cbcde=0x1f4;logger['error'](_0x2987cf[_0xa671('0x32')]);if(_0x2987cf[_0xa671('0x33')]){delete _0x2987cf['name'];}_0xbd77db=_0x2987cf;})[_0xa671('0x126')](function(){if(_0xbd77db===null){_0x16b53a['sendStatus'](_0x4cbcde);}else{if(_0x4cbcde===0x1f4){_0x16b53a[_0xa671('0x24')](_0x4cbcde)['send'](_0xbd77db);}else{_0x16b53a[_0xa671('0x24')](_0x4cbcde)[_0xa671('0x26')](_0xbd77db);}}});};exports['getApplications']=function(_0x501737,_0x3d30ff){var _0x2fa4d0={};var _0x1ec719={};var _0x2e289e;var _0x4e24e0;return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x501737[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x3d30ff,null))['then'](function(_0x190d20){if(_0x190d20){_0x2e289e=_0x190d20;_0x1ec719[_0xa671('0x54')]=_[_0xa671('0x82')](db[_0xa671('0xb1')][_0xa671('0x5a')]);_0x1ec719[_0xa671('0x5d')]=_[_0xa671('0x82')](_0x501737[_0xa671('0x5d')]);_0x1ec719['filters']=_['intersection'](_0x1ec719[_0xa671('0x54')],_0x1ec719['query']);_0x2fa4d0[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x1ec719[_0xa671('0x54')],qs[_0xa671('0x60')](_0x501737[_0xa671('0x5d')][_0xa671('0x60')]));_0x2fa4d0[_0xa671('0x5f')]=_0x2fa4d0[_0xa671('0x5f')][_0xa671('0x61')]?_0x2fa4d0['attributes']:_0x1ec719[_0xa671('0x54')];_0x2fa4d0[_0xa671('0x7a')]=qs['sort'](_0x501737[_0xa671('0x5d')]['sort']);_0x2fa4d0[_0xa671('0x65')]=qs[_0xa671('0x66')](_[_0xa671('0x67')](_0x501737[_0xa671('0x5d')],_0x1ec719[_0xa671('0x66')]));if(_0x501737['query']['filter']){_0x2fa4d0['where']=_['merge'](_0x2fa4d0[_0xa671('0x65')],{'$or':_[_0xa671('0x3e')](_0x2fa4d0[_0xa671('0x5f')],function(_0x5624b6){var _0x4043f6={};_0x4043f6[_0x5624b6]={'$like':'%'+_0x501737[_0xa671('0x5d')]['filter']+'%'};return _0x4043f6;})});}_0x2fa4d0=_[_0xa671('0x7c')]({},_0x2fa4d0,_0x501737[_0xa671('0x69')]);return _0x2e289e[_0xa671('0x127')](_0x2fa4d0);}})['then'](function(_0x498ace){if(_0x498ace){_0x4e24e0=_0x498ace[_0xa671('0x61')];if(!_0x501737[_0xa671('0x5d')][_0xa671('0x62')](_0xa671('0x63'))){_0x2fa4d0['limit']=qs['limit'](_0x501737['query'][_0xa671('0x2a')]);_0x2fa4d0[_0xa671('0x27')]=qs['offset'](_0x501737[_0xa671('0x5d')]['offset']);}return _0x2e289e[_0xa671('0x127')](_0x2fa4d0);}})[_0xa671('0x18')](function(_0x2f2a4e){if(_0x2f2a4e){return _0x2f2a4e?{'count':_0x4e24e0,'rows':_0x2f2a4e}:null;}})['then'](respondWithResult(_0x3d30ff,null))[_0xa671('0x22')](handleError(_0x3d30ff,null));};exports[_0xa671('0x128')]=function(_0x5ed53c,_0x865393){return db['chatProactiveAction'][_0xa671('0x6d')]({'where':{'id':_0x5ed53c[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x865393,null))[_0xa671('0x18')](function(_0x4c46e8){if(_0x4c46e8){return _0x4c46e8[_0xa671('0x128')](_0x5ed53c[_0xa671('0x6f')][_0xa671('0x7f')],_[_0xa671('0x101')](_0x5ed53c[_0xa671('0x6f')],['ids','id'])||{});}})[_0xa671('0x18')](respondWithResult(_0x865393,null))[_0xa671('0x22')](handleError(_0x865393,null));};exports[_0xa671('0x129')]=function(_0x3fa742,_0xbfbc0a){var _0x264652={};var _0x2daf8f={};var _0x9c44ce;var _0x229bbc;return db['ChatWebsite']['findOne']({'where':{'id':_0x3fa742['params']['id']}})[_0xa671('0x18')](handleEntityNotFound(_0xbfbc0a,null))[_0xa671('0x18')](function(_0x151ca9){if(_0x151ca9){_0x9c44ce=_0x151ca9;_0x2daf8f[_0xa671('0x54')]=_['keys'](db[_0xa671('0x12a')][_0xa671('0x5a')]);_0x2daf8f['query']=_['keys'](_0x3fa742[_0xa671('0x5d')]);_0x2daf8f[_0xa671('0x66')]=_['intersection'](_0x2daf8f['model'],_0x2daf8f[_0xa671('0x5d')]);_0x264652[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x2daf8f[_0xa671('0x54')],qs[_0xa671('0x60')](_0x3fa742['query']['fields']));_0x264652['attributes']=_0x264652[_0xa671('0x5f')][_0xa671('0x61')]?_0x264652['attributes']:_0x2daf8f[_0xa671('0x54')];_0x264652[_0xa671('0x7a')]=qs[_0xa671('0x64')](_0x3fa742[_0xa671('0x5d')][_0xa671('0x64')]);_0x264652[_0xa671('0x65')]=qs['filters'](_[_0xa671('0x67')](_0x3fa742[_0xa671('0x5d')],_0x2daf8f['filters']));if(_0x3fa742[_0xa671('0x5d')][_0xa671('0x68')]){_0x264652[_0xa671('0x65')]=_[_0xa671('0x7c')](_0x264652['where'],{'$or':_[_0xa671('0x3e')](_0x264652[_0xa671('0x5f')],function(_0x535e9b){var _0x54a2e5={};_0x54a2e5[_0x535e9b]={'$like':'%'+_0x3fa742['query'][_0xa671('0x68')]+'%'};return _0x54a2e5;})});}_0x264652=_[_0xa671('0x7c')]({},_0x264652,_0x3fa742[_0xa671('0x69')]);return _0x9c44ce[_0xa671('0x129')](_0x264652);}})[_0xa671('0x18')](function(_0x121d94){if(_0x121d94){_0x229bbc=_0x121d94['length'];if(!_0x3fa742[_0xa671('0x5d')][_0xa671('0x62')](_0xa671('0x63'))){_0x264652['limit']=qs[_0xa671('0x2a')](_0x3fa742[_0xa671('0x5d')]['limit']);_0x264652[_0xa671('0x27')]=qs[_0xa671('0x27')](_0x3fa742['query']['offset']);}return _0x9c44ce['getProactiveActions'](_0x264652);}})[_0xa671('0x18')](function(_0x352a8d){if(_0x352a8d){return _0x352a8d?{'count':_0x229bbc,'rows':_0x352a8d}:null;}})['then'](respondWithResult(_0xbfbc0a,null))[_0xa671('0x22')](handleError(_0xbfbc0a,null));};exports[_0xa671('0x12b')]=function(_0x12e571,_0x122484){var _0x5cd8ec=_0x12e571[_0xa671('0x5d')][_0xa671('0x12c')]==='false'?_0xa671('0x12d'):'onlineForm';return db[_0xa671('0x59')]['find']({'attributes':['id',_0x5cd8ec],'where':{'id':_0x12e571['params']['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x122484,null))[_0xa671('0x18')](function(_0x8c001e){if(_0x8c001e){var _0x57dff4=_0x8c001e[_0x5cd8ec];var _0x234a0e=_0x57dff4&&_0x57dff4['items']?_0x57dff4[_0xa671('0x12e')]:[];_0x122484[_0xa671('0xdb')]({'fromKey':_[_0xa671('0x92')](_0x57dff4[_0xa671('0x12f')])?undefined:_0x57dff4[_0xa671('0x12f')],'count':_0x234a0e[_0xa671('0x61')],'rows':_0x234a0e});}})[_0xa671('0x22')](handleError(_0x122484,null));};exports[_0xa671('0x130')]=function(_0x1bd02e,_0x118962){var _0x19696a={'raw':![],'where':{}};var _0x4a0a08={};var _0x5c40e7={'count':0x0,'rows':[]};return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x1bd02e[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x118962,null))[_0xa671('0x18')](function(_0x13502f){if(_0x13502f){_0x4a0a08['model']=_['keys'](db[_0xa671('0xe5')]['rawAttributes']);_0x4a0a08[_0xa671('0x5d')]=_[_0xa671('0x82')](_0x1bd02e[_0xa671('0x5d')]);_0x4a0a08['filters']=_['intersection'](_0x4a0a08[_0xa671('0x54')],_0x4a0a08[_0xa671('0x5d')]);_0x19696a[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x4a0a08[_0xa671('0x54')],qs[_0xa671('0x60')](_0x1bd02e[_0xa671('0x5d')][_0xa671('0x60')]));_0x19696a[_0xa671('0x5f')]=_0x19696a[_0xa671('0x5f')][_0xa671('0x61')]?_0x19696a['attributes']:_0x4a0a08[_0xa671('0x54')];if(!_0x1bd02e[_0xa671('0x5d')][_0xa671('0x62')]('nolimit')){_0x19696a[_0xa671('0x2a')]=qs[_0xa671('0x2a')](_0x1bd02e['query'][_0xa671('0x2a')]);_0x19696a[_0xa671('0x27')]=qs[_0xa671('0x27')](_0x1bd02e[_0xa671('0x5d')][_0xa671('0x27')]);}_0x19696a[_0xa671('0x7a')]=qs[_0xa671('0x64')](_0x1bd02e[_0xa671('0x5d')][_0xa671('0x64')]);_0x19696a[_0xa671('0x65')]=qs[_0xa671('0x66')](_[_0xa671('0x67')](_0x1bd02e['query'],_0x4a0a08[_0xa671('0x66')]));_0x19696a[_0xa671('0x65')][_0xa671('0x7b')]=_0x13502f['id'];if(_0x1bd02e[_0xa671('0x5d')][_0xa671('0x68')]){_0x19696a[_0xa671('0x65')]=_[_0xa671('0x7c')](_0x19696a[_0xa671('0x65')],{'$or':_['map'](_0x19696a[_0xa671('0x5f')],function(_0x49c6d8){var _0x1e1a36={};_0x1e1a36[_0x49c6d8]={'$like':'%'+_0x1bd02e[_0xa671('0x5d')][_0xa671('0x68')]+'%'};return _0x1e1a36;})});}_0x19696a=_[_0xa671('0x7c')]({},_0x19696a,_0x1bd02e[_0xa671('0x69')]);return db[_0xa671('0xe5')][_0xa671('0x29')]({'where':_0x19696a[_0xa671('0x65')]})[_0xa671('0x18')](function(_0x73202e){_0x5c40e7['count']=_0x73202e;if(_0x1bd02e[_0xa671('0x5d')][_0xa671('0x6a')]){_0x19696a[_0xa671('0x6c')]=[{'all':!![]}];}else{_0x19696a[_0xa671('0x6c')]=[{'model':db[_0xa671('0xa0')],'as':_0xa671('0x103'),'required':![]},{'model':db[_0xa671('0xed')],'as':_0xa671('0x131'),'required':![]}];}return db['ChatOfflineMessage']['findAll'](_0x19696a);})[_0xa671('0x18')](function(_0x45da8){_0x5c40e7[_0xa671('0x7d')]=_0x45da8;return _0x5c40e7;});}})[_0xa671('0x18')](respondWithFilteredResult(_0x118962,_0x19696a))[_0xa671('0x22')](handleError(_0x118962,null));};exports['addAgents']=function(_0x2dde91,_0x1b31f9){return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x2dde91['params']['id']}})['then'](handleEntityNotFound(_0x1b31f9,null))[_0xa671('0x18')](function(_0xe280ef){if(_0xe280ef){return _0xe280ef[_0xa671('0x132')](_0x2dde91[_0xa671('0x6f')]['ids'],_[_0xa671('0x101')](_0x2dde91['body'],[_0xa671('0x7f'),'id'])||{})['spread'](function(_0x405da2){for(var _0x37b5e4=0x0;_0x37b5e4<_0x2dde91[_0xa671('0x6f')][_0xa671('0x7f')][_0xa671('0x61')];_0x37b5e4+=0x1){socket['emit']('userChatWebsite:save',{'UserId':Number(_0x2dde91['body'][_0xa671('0x7f')][_0x37b5e4]),'ChatWebsiteId':Number(_0x2dde91[_0xa671('0x75')]['id'])});}return _0x405da2;});}})['then'](respondWithResult(_0x1b31f9,null))['catch'](handleError(_0x1b31f9,null));};exports[_0xa671('0x133')]=function(_0x50a31a,_0x2e0525){return db[_0xa671('0x59')]['find']({'where':{'id':_0x50a31a[_0xa671('0x75')]['id']}})['then'](handleEntityNotFound(_0x2e0525,null))['then'](function(_0x220bc6){if(_0x220bc6){return _0x220bc6[_0xa671('0x133')](_0x50a31a['query'][_0xa671('0x7f')])['then'](function(){if(_[_0xa671('0x134')](_0x50a31a[_0xa671('0x5d')][_0xa671('0x7f')])){for(var _0xcfe4eb=0x0;_0xcfe4eb<_0x50a31a[_0xa671('0x5d')][_0xa671('0x7f')][_0xa671('0x61')];_0xcfe4eb+=0x1){socket[_0xa671('0x135')](_0xa671('0x136'),{'UserId':Number(_0x50a31a[_0xa671('0x5d')]['ids'][_0xcfe4eb]),'ChatWebsiteId':Number(_0x50a31a[_0xa671('0x75')]['id'])});}}else{socket[_0xa671('0x135')](_0xa671('0x136'),{'UserId':Number(_0x50a31a[_0xa671('0x5d')]['ids']),'ChatWebsiteId':Number(_0x50a31a[_0xa671('0x75')]['id'])});}});}})[_0xa671('0x18')](respondWithStatusCode(_0x2e0525,null))[_0xa671('0x22')](handleError(_0x2e0525,null));};exports['getAgents']=function(_0x4c1050,_0x55f1cd){var _0x38c97b={};var _0x3e5133={};var _0x339aa3;var _0x129955;return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x4c1050[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x55f1cd,null))[_0xa671('0x18')](function(_0x1bccab){if(_0x1bccab){_0x339aa3=_0x1bccab;_0x3e5133[_0xa671('0x54')]=_[_0xa671('0x82')](db[_0xa671('0x137')][_0xa671('0x5a')]);_0x3e5133[_0xa671('0x5d')]=_[_0xa671('0x82')](_0x4c1050[_0xa671('0x5d')]);_0x3e5133[_0xa671('0x66')]=_[_0xa671('0x5e')](_0x3e5133[_0xa671('0x54')],_0x3e5133[_0xa671('0x5d')]);_0x38c97b[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x3e5133['model'],qs[_0xa671('0x60')](_0x4c1050[_0xa671('0x5d')][_0xa671('0x60')]));_0x38c97b[_0xa671('0x5f')]=_0x38c97b['attributes'][_0xa671('0x61')]?_0x38c97b[_0xa671('0x5f')]:_0x3e5133[_0xa671('0x54')];_0x38c97b['order']=qs[_0xa671('0x64')](_0x4c1050[_0xa671('0x5d')][_0xa671('0x64')]);_0x38c97b[_0xa671('0x65')]=qs['filters'](_[_0xa671('0x67')](_0x4c1050[_0xa671('0x5d')],_0x3e5133[_0xa671('0x66')]));if(_0x4c1050[_0xa671('0x5d')][_0xa671('0x68')]){_0x38c97b[_0xa671('0x65')]=_['merge'](_0x38c97b[_0xa671('0x65')],{'$or':_[_0xa671('0x3e')](_0x38c97b[_0xa671('0x5f')],function(_0xcc01fb){var _0x15f8b4={};_0x15f8b4[_0xcc01fb]={'$like':'%'+_0x4c1050['query'][_0xa671('0x68')]+'%'};return _0x15f8b4;})});}_0x38c97b=_[_0xa671('0x7c')]({},_0x38c97b,_0x4c1050['options']);return _0x339aa3[_0xa671('0x138')](_0x38c97b);}})[_0xa671('0x18')](function(_0x387377){if(_0x387377){_0x129955=_0x387377['length'];if(!_0x4c1050['query']['hasOwnProperty']('nolimit')){_0x38c97b[_0xa671('0x2a')]=qs['limit'](_0x4c1050['query']['limit']);_0x38c97b[_0xa671('0x27')]=qs[_0xa671('0x27')](_0x4c1050[_0xa671('0x5d')]['offset']);}return _0x339aa3[_0xa671('0x138')](_0x38c97b);}})[_0xa671('0x18')](function(_0x13779a){if(_0x13779a){return _0x13779a?{'count':_0x129955,'rows':_0x13779a}:null;}})[_0xa671('0x18')](respondWithResult(_0x55f1cd,null))[_0xa671('0x22')](handleError(_0x55f1cd,null));};
\ No newline at end of file