Built motion from commit 351e7f9c.|2.6.31
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 805a49a..259a9be 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0bde=['query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','options','ChatWebsite','includeAll','include','findAll','show','params','Pause','keys','find','create','body','address','forEach','testWildcardValidity','trim','\x22\x20is\x20not\x20a\x20valid\x20wildcard\x20expression','user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','describe','ChatWebsiteId','Disposition','getDispositions','findOne','merge','rows','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','addLogo','sitepic','filename','addAvatar','agentAvatar','file','addCustomerAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','../../config/license/util','getLicense','existsSync','download','getAvatar','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','server/files/images/avatars/customer_avatar.png','customerAvatar','showCustomerAvatar','isNil','getSystemAvatar','server/files/images/avatars/system_avatar.png','Interval','notify','chat','From\x20is\x20mandatory','MapKey\x20is\x20mandatory','CmContact','No\x20available\x20attributes','createdAt','updatedAt','includes','CompanyId','Invalid\x20MapKey\x20parameter.\x20Allowed\x20values:\x20','mapKey','List','Contacts','DESC','ChatApplication','Applications','Intervals','interval','Chat\x20Website\x20with\x20id\x20%s\x20not\x20found','applications','orderBy','priority','asc','account','list','ListId','defaults','from','contact','threadId','ChatInteraction','closed','Writing\x20on\x20closed\x20interaction','externalUrl','interaction','messageId','created','autoclose','push','close','unmanaged','AttachmentId','UserId','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','ChatQueue','queueId','Start','startRouting','EventManager','offline','files','Sequelize','difference','from\x20is\x20mandatory','mapKeyOffline','ValidationError','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','MailAccount','findOrCreate','spread','server/files/templates/chatOfflineMessage.ejs','render','toPairs','ChatOfflineMessage','fromString','originalname','mimetype','basename','sequelize','transaction','Attachment','bulkCreate','MailServerOut','Smtp','CloudProvider','forwardOffline','forwardOfflineAddress','getSmtpOptions','sendMail','offlineMessageSubject','openNewInteraction','MailAccountId','subjectOffline','toPairsIn','mapValues','email','lastName','NotifyMailAccount','notifyMail','server','attachments','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','User','Owner','internal','Tags','tag','getSnippet','getProactiveActions','custom','License','increment','chatLicenseExceeded','timezone','ifTime','server/files/chat/iframe.ejs','utf8','3.13.0','headers','origin','testWebsiteWithWildcard','x-forwarded-for','remoteAddress','virtual','replace','alignment','verticalAlignment','labelText','textColor','textButtonColor','backgroundColor','IntervalId','ISOLATION_LEVELS','READ_COMMITTED','findAndCountAll','finally','getApplications','addProactiveActions','chatProactiveAction','ChatProactiveAction','getFields','online','false','offlineForm','onlineForm','items','fromKey','getOfflineMessages','Attachments','addAgents','emit','userChatWebsite:save','removeAgents','userChatWebsite:remove','getAgents','util','ejs','fs-extra','lodash','querystring','html-to-text','jayson/promise','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../errors/api','APIBadRequestError','APINotFoundError','APIOutOfIntervalError','handleError','APIConflictError','./helpers/wildcard-expressions','redis','localhost','socket.io-emitter','./chatWebsite.socket','client','http','request','info','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','error','code','ChatWebsite,\x20%s,\x20%s','message','result','catch','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','destroy','then','get','ChatWebsites','UserProfileResource','stack','name','send','setUA','user-agent','customerIp','cf-connecting-ip','first','split','firstName','x-real-port','referer','browser','version','%s\x20%s','unknown','format','device','model','vendor','%s\x20%s\x20%s','type','stringify','index','mandatoryDispositionPause','map','rawAttributes','key'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x0bde,0xe7));var _0xe0bd=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x0bde[_0x321bb2];return _0x9c12ed;};'use strict';var Mustache=require('mustache');var util=require(_0xe0bd('0x0'));var path=require('path');var ejs=require(_0xe0bd('0x1'));var fs=require('fs');var fs_extra=require(_0xe0bd('0x2'));var _=require(_0xe0bd('0x3'));var querystring=require(_0xe0bd('0x4'));var htmlToText=require(_0xe0bd('0x5'));var Redis=require('ioredis');var jayson=require(_0xe0bd('0x6'));var qs=require(_0xe0bd('0x7'));var logger=require(_0xe0bd('0x8'))(_0xe0bd('0x9'));var config=require(_0xe0bd('0xa'));var APIBadRequestError=require(_0xe0bd('0xb'))[_0xe0bd('0xc')];var APINotFoundError=require('../../errors/api')[_0xe0bd('0xd')];var APIOutOfIntervalError=require(_0xe0bd('0xb'))[_0xe0bd('0xe')];var APIHandleError=require(_0xe0bd('0xb'))[_0xe0bd('0xf')];var APIConflictError=require(_0xe0bd('0xb'))[_0xe0bd('0x10')];var wildcardUtils=require(_0xe0bd('0x11'));var URL=require('url')['URL'];var db=require('../../mysqldb')['db'];config[_0xe0bd('0x12')]=_['defaults'](config['redis'],{'host':_0xe0bd('0x13'),'port':0x18eb});var socket=require(_0xe0bd('0x14'))(new Redis(config['redis']));require(_0xe0bd('0x15'))['register'](socket);var client=jayson[_0xe0bd('0x16')][_0xe0bd('0x17')]({'port':0x232c});var client9002=jayson[_0xe0bd('0x16')][_0xe0bd('0x17')]({'port':0x232a});var client9003=jayson[_0xe0bd('0x16')][_0xe0bd('0x17')]({'port':0x232b});var client9001=jayson[_0xe0bd('0x16')][_0xe0bd('0x17')]({'port':0x2329});function respondWithRpcPromise(_0x4f63fa,_0x50891d,_0x4fb006,_0x2ff887){return new Promise(function(_0x8179fb,_0x2cd832){var _0x379ea2=_0x2ff887||client;return _0x379ea2[_0xe0bd('0x18')](_0x4f63fa,_0x4fb006)['then'](function(_0x4ebe7a){logger[_0xe0bd('0x19')]('ChatWebsite,\x20%s,\x20%s',_0x50891d,_0xe0bd('0x1a'));logger[_0xe0bd('0x1b')](_0xe0bd('0x1c'),_0x50891d,_0xe0bd('0x1a'),JSON['stringify'](_0x4ebe7a));if(_0x4ebe7a[_0xe0bd('0x1d')]){if(_0x4ebe7a[_0xe0bd('0x1d')][_0xe0bd('0x1e')]===0x1f4){logger['error'](_0xe0bd('0x1f'),_0x50891d,_0x4ebe7a[_0xe0bd('0x1d')][_0xe0bd('0x20')]);return _0x2cd832(_0x4ebe7a['error'][_0xe0bd('0x20')]);}logger[_0xe0bd('0x1d')](_0xe0bd('0x1f'),_0x50891d,_0x4ebe7a['error'][_0xe0bd('0x20')]);return _0x8179fb(_0x4ebe7a['error'][_0xe0bd('0x20')]);}else{logger[_0xe0bd('0x19')]('ChatWebsite,\x20%s,\x20%s',_0x50891d,_0xe0bd('0x1a'));_0x8179fb(_0x4ebe7a[_0xe0bd('0x21')][_0xe0bd('0x20')]);}})[_0xe0bd('0x22')](function(_0x2a1f92){logger[_0xe0bd('0x1d')](_0xe0bd('0x1f'),_0x50891d,_0x2a1f92);_0x2cd832(_0x2a1f92);});});}function respondWithStatusCode(_0x162356,_0x537708){_0x537708=_0x537708||0xcc;return function(_0x54e38d){if(_0x54e38d){return _0x162356[_0xe0bd('0x23')](_0x537708);}return _0x162356[_0xe0bd('0x24')](_0x537708)['end']();};}function respondWithResult(_0x4e8f11,_0x3bac51){_0x3bac51=_0x3bac51||0xc8;return function(_0x303f9d){if(_0x303f9d){return _0x4e8f11[_0xe0bd('0x24')](_0x3bac51)[_0xe0bd('0x25')](_0x303f9d);}};}function respondWithFilteredResult(_0x50464f,_0x24edc0){return function(_0x4ef39b){if(_0x4ef39b){var _0x9146fe=typeof _0x24edc0[_0xe0bd('0x26')]===_0xe0bd('0x27')&&typeof _0x24edc0[_0xe0bd('0x28')]===_0xe0bd('0x27');var _0x43f122=_0x4ef39b[_0xe0bd('0x29')];var _0x2d31e9=_0x9146fe?0x0:_0x24edc0[_0xe0bd('0x26')];var _0x36e0f7=_0x9146fe?_0x4ef39b[_0xe0bd('0x29')]:_0x24edc0[_0xe0bd('0x26')]+_0x24edc0[_0xe0bd('0x28')];var _0x56f310;if(_0x36e0f7>=_0x43f122){_0x36e0f7=_0x43f122;_0x56f310=0xc8;}else{_0x56f310=0xce;}_0x50464f[_0xe0bd('0x24')](_0x56f310);return _0x50464f[_0xe0bd('0x2a')](_0xe0bd('0x2b'),_0x2d31e9+'-'+_0x36e0f7+'/'+_0x43f122)[_0xe0bd('0x25')](_0x4ef39b);}return null;};}function saveUpdates(_0x8c9de3){return function(_0x380c13){if(_0x380c13){return _0x380c13['update'](_0x8c9de3)['then'](function(_0x35019d){return _0x35019d;});}return null;};}function removeEntity(_0x324795){return function(_0xbf0bd4){if(_0xbf0bd4){return _0xbf0bd4[_0xe0bd('0x2c')]()[_0xe0bd('0x2d')](function(){var _0x249bd2=_0xbf0bd4[_0xe0bd('0x2e')]({'plain':!![]});var _0x5a52ab=_0xe0bd('0x2f');return db[_0xe0bd('0x30')][_0xe0bd('0x2c')]({'where':{'type':_0x5a52ab,'resourceId':_0x249bd2['id']}})[_0xe0bd('0x2d')](function(){return _0xbf0bd4;});})[_0xe0bd('0x2d')](function(){_0x324795[_0xe0bd('0x24')](0xcc)['end']();});}};}function handleEntityNotFound(_0xd82ced){return function(_0xa7b799){if(!_0xa7b799){_0xd82ced[_0xe0bd('0x23')](0x194);}return _0xa7b799;};}function handleError(_0x24ce61,_0x26a044){_0x26a044=_0x26a044||0x1f4;return function(_0x5881e5){logger['error'](_0x5881e5[_0xe0bd('0x31')]);if(_0x5881e5[_0xe0bd('0x32')]){delete _0x5881e5[_0xe0bd('0x32')];}_0x24ce61['status'](_0x26a044)[_0xe0bd('0x33')](_0x5881e5);};}function createInteractionObject(_0x4eefae,_0x4b3d07,_0x670469,_0x124d47){var _0x4d8695=require('user-agent-parser');var _0x50338e=new _0x4d8695();var _0x170499=_0x50338e[_0xe0bd('0x34')](_0x670469[_0xe0bd('0x35')])['getResult']();var _0x20827d=_0x4b3d07[_0xe0bd('0x36')];if(_0x670469[_0xe0bd('0x37')]){_0x20827d=_0x670469['cf-connecting-ip'];}else if(_0x670469['x-forwarded-for']){_0x20827d=_[_0xe0bd('0x38')](_0x670469['x-forwarded-for'][_0xe0bd('0x39')](','));}return{'ContactId':_0x124d47['id'],'ChatWebsiteId':_0x4eefae,'from':(_0x124d47[_0xe0bd('0x3a')]||'')+'\x20'+(_0x124d47['lastName']||''),'customerIp':_0x20827d,'customerPort':_0x670469[_0xe0bd('0x3b')]?_0x670469[_0xe0bd('0x3b')]:null,'referer':_0x4b3d07[_0xe0bd('0x3c')],'browserName':_0x170499[_0xe0bd('0x3d')][_0xe0bd('0x32')]&&_0x170499[_0xe0bd('0x3d')][_0xe0bd('0x3e')]?util['format'](_0xe0bd('0x3f'),_0x170499[_0xe0bd('0x3d')][_0xe0bd('0x32')],_0x170499[_0xe0bd('0x3d')][_0xe0bd('0x3e')]):'unknown','browserVersion':_0x170499['browser']['version']||_0xe0bd('0x40'),'osName':util[_0xe0bd('0x41')](_0xe0bd('0x3f'),_0x170499['os'][_0xe0bd('0x32')],_0x170499['os']['version']),'osVersion':_0x170499['os']['version'],'deviceModel':_0x170499[_0xe0bd('0x42')][_0xe0bd('0x43')]&&_0x170499[_0xe0bd('0x42')][_0xe0bd('0x44')]?util[_0xe0bd('0x41')](_0xe0bd('0x45'),_0x170499[_0xe0bd('0x42')]['model'],_0x170499[_0xe0bd('0x42')]['vendor'],_0x170499[_0xe0bd('0x42')][_0xe0bd('0x46')]):null,'deviceVendor':_0x170499['device']['vendor'],'deviceType':_0x170499[_0xe0bd('0x42')][_0xe0bd('0x46')],'formData':JSON[_0xe0bd('0x47')](_0x4b3d07)};}exports[_0xe0bd('0x48')]=function(_0x3f4a43,_0x1bd42a){var _0x368549={'include':[{'model':db['Pause'],'as':_0xe0bd('0x49')}]},_0x37f9ea={},_0x2fbe0e={'count':0x0,'rows':[]};var _0x4dcbc6=_[_0xe0bd('0x4a')](db['ChatWebsite'][_0xe0bd('0x4b')],function(_0x159a85){return{'name':_0x159a85['fieldName'],'type':_0x159a85[_0xe0bd('0x46')][_0xe0bd('0x4c')]};});_0x37f9ea['model']=_[_0xe0bd('0x4a')](_0x4dcbc6,_0xe0bd('0x32'));_0x37f9ea[_0xe0bd('0x4d')]=_['keys'](_0x3f4a43[_0xe0bd('0x4d')]);_0x37f9ea[_0xe0bd('0x4e')]=_[_0xe0bd('0x4f')](_0x37f9ea[_0xe0bd('0x43')],_0x37f9ea[_0xe0bd('0x4d')]);_0x368549[_0xe0bd('0x50')]=_[_0xe0bd('0x4f')](_0x37f9ea[_0xe0bd('0x43')],qs[_0xe0bd('0x51')](_0x3f4a43['query']['fields']));_0x368549['attributes']=_0x368549[_0xe0bd('0x50')][_0xe0bd('0x52')]?_0x368549['attributes']:_0x37f9ea[_0xe0bd('0x43')];if(!_0x3f4a43[_0xe0bd('0x4d')][_0xe0bd('0x53')](_0xe0bd('0x54'))){_0x368549[_0xe0bd('0x28')]=qs[_0xe0bd('0x28')](_0x3f4a43[_0xe0bd('0x4d')][_0xe0bd('0x28')]);_0x368549[_0xe0bd('0x26')]=qs[_0xe0bd('0x26')](_0x3f4a43['query'][_0xe0bd('0x26')]);}_0x368549[_0xe0bd('0x55')]=qs[_0xe0bd('0x56')](_0x3f4a43['query'][_0xe0bd('0x56')]);_0x368549[_0xe0bd('0x57')]=qs[_0xe0bd('0x4e')](_[_0xe0bd('0x58')](_0x3f4a43[_0xe0bd('0x4d')],_0x37f9ea[_0xe0bd('0x4e')]),_0x4dcbc6);if(_0x3f4a43[_0xe0bd('0x4d')][_0xe0bd('0x59')]){_0x368549[_0xe0bd('0x57')]=_['merge'](_0x368549[_0xe0bd('0x57')],{'$or':_[_0xe0bd('0x4a')](_0x4dcbc6,function(_0x414e7d){if(_0x414e7d[_0xe0bd('0x46')]!=='VIRTUAL'){var _0x355725={};_0x355725[_0x414e7d[_0xe0bd('0x32')]]={'$like':'%'+_0x3f4a43[_0xe0bd('0x4d')]['filter']+'%'};return _0x355725;}})});}_0x368549=_['merge']({},_0x368549,_0x3f4a43[_0xe0bd('0x5a')]);var _0x2d83ca={'where':_0x368549['where']};return db[_0xe0bd('0x5b')][_0xe0bd('0x29')](_0x2d83ca)[_0xe0bd('0x2d')](function(_0x10ae26){_0x2fbe0e['count']=_0x10ae26;if(_0x3f4a43[_0xe0bd('0x4d')][_0xe0bd('0x5c')]){_0x368549[_0xe0bd('0x5d')]=[{'all':!![]}];}return db[_0xe0bd('0x5b')][_0xe0bd('0x5e')](_0x368549);})[_0xe0bd('0x2d')](function(_0xadef32){_0x2fbe0e['rows']=_0xadef32;return _0x2fbe0e;})[_0xe0bd('0x2d')](respondWithFilteredResult(_0x1bd42a,_0x368549))[_0xe0bd('0x22')](handleError(_0x1bd42a,null));};exports[_0xe0bd('0x5f')]=function(_0x218a17,_0x304ede){var _0x1a2de2={'raw':![],'where':{'id':_0x218a17[_0xe0bd('0x60')]['id']},'include':[{'model':db[_0xe0bd('0x61')],'as':_0xe0bd('0x49')}]},_0x128ad9={};_0x128ad9[_0xe0bd('0x43')]=_[_0xe0bd('0x62')](db[_0xe0bd('0x5b')][_0xe0bd('0x4b')]);_0x128ad9[_0xe0bd('0x4d')]=_[_0xe0bd('0x62')](_0x218a17[_0xe0bd('0x4d')]);_0x128ad9[_0xe0bd('0x4e')]=_[_0xe0bd('0x4f')](_0x128ad9[_0xe0bd('0x43')],_0x128ad9[_0xe0bd('0x4d')]);_0x1a2de2[_0xe0bd('0x50')]=_[_0xe0bd('0x4f')](_0x128ad9['model'],qs['fields'](_0x218a17[_0xe0bd('0x4d')][_0xe0bd('0x51')]));_0x1a2de2[_0xe0bd('0x50')]=_0x1a2de2['attributes']['length']?_0x1a2de2['attributes']:_0x128ad9[_0xe0bd('0x43')];if(_0x218a17[_0xe0bd('0x4d')]['includeAll']){_0x1a2de2[_0xe0bd('0x5d')]=[{'all':!![]}];}_0x1a2de2=_['merge']({},_0x1a2de2,_0x218a17[_0xe0bd('0x5a')]);return db[_0xe0bd('0x5b')][_0xe0bd('0x63')](_0x1a2de2)['then'](handleEntityNotFound(_0x304ede,null))['then'](respondWithResult(_0x304ede,null))['catch'](handleError(_0x304ede,null));};exports[_0xe0bd('0x64')]=function(_0x1c9407,_0xbdf45b){var _0x2b5fe6=null;_0x1c9407[_0xe0bd('0x65')][_0xe0bd('0x66')]['split'](',')[_0xe0bd('0x67')](_0x40a584=>{if(_0x40a584['trim']()!==''&&!wildcardUtils[_0xe0bd('0x68')](_0x40a584[_0xe0bd('0x69')]())){_0x2b5fe6=new APIBadRequestError('\x22'+_0x40a584[_0xe0bd('0x69')]()+_0xe0bd('0x6a'));}});if(_0x2b5fe6){return handleError(_0xbdf45b,null)(_0x2b5fe6);}return db[_0xe0bd('0x5b')][_0xe0bd('0x64')](_0x1c9407[_0xe0bd('0x65')],{})[_0xe0bd('0x2d')](function(_0x50c2e7){var _0x277cca=_0x1c9407[_0xe0bd('0x6b')][_0xe0bd('0x2e')]({'plain':!![]});if(!_0x277cca)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x277cca[_0xe0bd('0x6c')]===_0xe0bd('0x6b')){var _0xa63133=_0x50c2e7[_0xe0bd('0x2e')]({'plain':!![]});var _0x5f238f=_0xe0bd('0x2f');return db[_0xe0bd('0x6d')][_0xe0bd('0x63')]({'where':{'name':_0x5f238f,'userProfileId':_0x277cca['userProfileId']},'raw':!![]})[_0xe0bd('0x2d')](function(_0x1def8a){if(_0x1def8a&&_0x1def8a[_0xe0bd('0x6e')]===0x0){return db['UserProfileResource'][_0xe0bd('0x64')]({'name':_0xa63133['name'],'resourceId':_0xa63133['id'],'type':_0x1def8a['name'],'sectionId':_0x1def8a['id']},{})['then'](function(){return _0x50c2e7;});}else{return _0x50c2e7;}})[_0xe0bd('0x22')](function(_0x21a793){logger[_0xe0bd('0x1d')](_0xe0bd('0x6f'),_0x21a793);throw _0x21a793;});}return _0x50c2e7;})['then'](respondWithResult(_0xbdf45b,0xc9))['catch'](handleError(_0xbdf45b,null));};exports[_0xe0bd('0x70')]=function(_0x374032,_0x3c4928){var _0x246d17=null;_0x374032[_0xe0bd('0x65')][_0xe0bd('0x66')][_0xe0bd('0x39')](',')[_0xe0bd('0x67')](_0x38b0b5=>{if(_0x38b0b5[_0xe0bd('0x69')]()!==''&&!wildcardUtils['testWildcardValidity'](_0x38b0b5[_0xe0bd('0x69')]())){_0x246d17=new APIBadRequestError('\x22'+_0x38b0b5['trim']()+_0xe0bd('0x6a'));}});if(_0x246d17){return handleError(_0x3c4928,null)(_0x246d17);}if(_0x374032[_0xe0bd('0x65')]['id']){delete _0x374032[_0xe0bd('0x65')]['id'];}return db[_0xe0bd('0x5b')][_0xe0bd('0x63')]({'where':{'id':_0x374032[_0xe0bd('0x60')]['id']},'include':[{'model':db[_0xe0bd('0x61')],'as':'mandatoryDispositionPause'}]})[_0xe0bd('0x2d')](handleEntityNotFound(_0x3c4928,null))[_0xe0bd('0x2d')](saveUpdates(_0x374032['body'],null))[_0xe0bd('0x2d')](respondWithResult(_0x3c4928,null))[_0xe0bd('0x22')](handleError(_0x3c4928,null));};exports[_0xe0bd('0x2c')]=function(_0x4fb0cb,_0x5991e5){return db[_0xe0bd('0x5b')][_0xe0bd('0x63')]({'where':{'id':_0x4fb0cb['params']['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x5991e5,null))[_0xe0bd('0x2d')](removeEntity(_0x5991e5,null))['catch'](handleError(_0x5991e5,null));};exports['describe']=function(_0x33cd0f,_0x355b34){return db[_0xe0bd('0x5b')][_0xe0bd('0x71')]()['then'](respondWithResult(_0x355b34,null))[_0xe0bd('0x22')](handleError(_0x355b34,null));};exports['addDisposition']=function(_0x31bf71,_0x373e4c){if(_0x31bf71[_0xe0bd('0x65')]['id']){delete _0x31bf71[_0xe0bd('0x65')]['id'];}return db[_0xe0bd('0x5b')][_0xe0bd('0x63')]({'where':{'id':_0x31bf71[_0xe0bd('0x60')]['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x373e4c,null))[_0xe0bd('0x2d')](function(_0x351f37){if(_0x351f37){_0x31bf71['body'][_0xe0bd('0x72')]=_0x351f37['id'];return db[_0xe0bd('0x73')][_0xe0bd('0x64')](_0x31bf71['body']);}})[_0xe0bd('0x2d')](respondWithResult(_0x373e4c,null))[_0xe0bd('0x22')](handleError(_0x373e4c,null));};exports[_0xe0bd('0x74')]=function(_0x403212,_0xa1e41b){var _0xd263f7={'raw':![],'where':{}};var _0x582a57={};var _0x46b629={'count':0x0,'rows':[]};return db[_0xe0bd('0x5b')][_0xe0bd('0x75')]({'where':{'id':_0x403212[_0xe0bd('0x60')]['id']}})['then'](handleEntityNotFound(_0xa1e41b,null))[_0xe0bd('0x2d')](function(_0x44b6bd){if(_0x44b6bd){_0x582a57[_0xe0bd('0x43')]=_[_0xe0bd('0x62')](db[_0xe0bd('0x73')]['rawAttributes']);_0x582a57[_0xe0bd('0x4d')]=_[_0xe0bd('0x62')](_0x403212[_0xe0bd('0x4d')]);_0x582a57[_0xe0bd('0x4e')]=_[_0xe0bd('0x4f')](_0x582a57[_0xe0bd('0x43')],_0x582a57[_0xe0bd('0x4d')]);_0xd263f7[_0xe0bd('0x50')]=_[_0xe0bd('0x4f')](_0x582a57[_0xe0bd('0x43')],qs[_0xe0bd('0x51')](_0x403212[_0xe0bd('0x4d')][_0xe0bd('0x51')]));_0xd263f7[_0xe0bd('0x50')]=_0xd263f7[_0xe0bd('0x50')][_0xe0bd('0x52')]?_0xd263f7[_0xe0bd('0x50')]:_0x582a57[_0xe0bd('0x43')];if(!_0x403212['query'][_0xe0bd('0x53')](_0xe0bd('0x54'))){_0xd263f7[_0xe0bd('0x28')]=qs['limit'](_0x403212[_0xe0bd('0x4d')][_0xe0bd('0x28')]);_0xd263f7[_0xe0bd('0x26')]=qs[_0xe0bd('0x26')](_0x403212[_0xe0bd('0x4d')][_0xe0bd('0x26')]);}_0xd263f7[_0xe0bd('0x55')]=qs[_0xe0bd('0x56')](_0x403212[_0xe0bd('0x4d')]['sort']);_0xd263f7['where']=qs['filters'](_[_0xe0bd('0x58')](_0x403212[_0xe0bd('0x4d')],_0x582a57[_0xe0bd('0x4e')]));_0xd263f7['where'][_0xe0bd('0x72')]=_0x44b6bd['id'];if(_0x403212[_0xe0bd('0x4d')][_0xe0bd('0x59')]){_0xd263f7[_0xe0bd('0x57')]=_[_0xe0bd('0x76')](_0xd263f7[_0xe0bd('0x57')],{'$or':_[_0xe0bd('0x4a')](_0xd263f7[_0xe0bd('0x50')],function(_0x130d23){var _0xbc95a8={};_0xbc95a8[_0x130d23]={'$like':'%'+_0x403212['query']['filter']+'%'};return _0xbc95a8;})});}_0xd263f7=_[_0xe0bd('0x76')]({},_0xd263f7,_0x403212[_0xe0bd('0x5a')]);return db[_0xe0bd('0x73')][_0xe0bd('0x29')]({'where':_0xd263f7[_0xe0bd('0x57')]})[_0xe0bd('0x2d')](function(_0x1b4aef){_0x46b629[_0xe0bd('0x29')]=_0x1b4aef;if(_0x403212['query'][_0xe0bd('0x5c')]){_0xd263f7[_0xe0bd('0x5d')]=[{'all':!![]}];}return db[_0xe0bd('0x73')][_0xe0bd('0x5e')](_0xd263f7);})[_0xe0bd('0x2d')](function(_0x3dc59d){_0x46b629[_0xe0bd('0x77')]=_0x3dc59d;return _0x46b629;});}})[_0xe0bd('0x2d')](respondWithFilteredResult(_0xa1e41b,_0xd263f7))[_0xe0bd('0x22')](handleError(_0xa1e41b,null));};exports[_0xe0bd('0x78')]=function(_0x44cd09,_0x39c7a6){return db[_0xe0bd('0x5b')][_0xe0bd('0x63')]({'where':{'id':_0x44cd09['params']['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x39c7a6,null))['then'](function(_0x314aa3){if(_0x314aa3){return _0x314aa3[_0xe0bd('0x78')](_0x44cd09['query'][_0xe0bd('0x79')]);}})[_0xe0bd('0x2d')](respondWithStatusCode(_0x39c7a6,null))['catch'](handleError(_0x39c7a6,null));};exports[_0xe0bd('0x7a')]=function(_0x3b4991,_0x5b0f12){if(_0x3b4991[_0xe0bd('0x65')]['id']){delete _0x3b4991[_0xe0bd('0x65')]['id'];}return db['ChatWebsite'][_0xe0bd('0x63')]({'where':{'id':_0x3b4991[_0xe0bd('0x60')]['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x5b0f12,null))[_0xe0bd('0x2d')](function(_0xb3c835){if(_0xb3c835){_0x3b4991[_0xe0bd('0x65')][_0xe0bd('0x72')]=_0xb3c835['id'];return db[_0xe0bd('0x7b')][_0xe0bd('0x64')](_0x3b4991[_0xe0bd('0x65')]);}})[_0xe0bd('0x2d')](respondWithResult(_0x5b0f12,null))[_0xe0bd('0x22')](handleError(_0x5b0f12,null));};exports[_0xe0bd('0x7c')]=function(_0x1c876b,_0x49e544){var _0x3ecbc4={'raw':![],'where':{}};var _0x3ad50a={};var _0x7d8cb4={'count':0x0,'rows':[]};return db[_0xe0bd('0x5b')][_0xe0bd('0x75')]({'where':{'id':_0x1c876b[_0xe0bd('0x60')]['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x49e544,null))[_0xe0bd('0x2d')](function(_0x2720ee){if(_0x2720ee){_0x3ad50a[_0xe0bd('0x43')]=_[_0xe0bd('0x62')](db[_0xe0bd('0x7b')][_0xe0bd('0x4b')]);_0x3ad50a[_0xe0bd('0x4d')]=_['keys'](_0x1c876b[_0xe0bd('0x4d')]);_0x3ad50a['filters']=_[_0xe0bd('0x4f')](_0x3ad50a[_0xe0bd('0x43')],_0x3ad50a[_0xe0bd('0x4d')]);_0x3ecbc4[_0xe0bd('0x50')]=_[_0xe0bd('0x4f')](_0x3ad50a[_0xe0bd('0x43')],qs[_0xe0bd('0x51')](_0x1c876b[_0xe0bd('0x4d')]['fields']));_0x3ecbc4['attributes']=_0x3ecbc4['attributes'][_0xe0bd('0x52')]?_0x3ecbc4['attributes']:_0x3ad50a[_0xe0bd('0x43')];if(!_0x1c876b[_0xe0bd('0x4d')][_0xe0bd('0x53')](_0xe0bd('0x54'))){_0x3ecbc4[_0xe0bd('0x28')]=qs[_0xe0bd('0x28')](_0x1c876b[_0xe0bd('0x4d')][_0xe0bd('0x28')]);_0x3ecbc4[_0xe0bd('0x26')]=qs[_0xe0bd('0x26')](_0x1c876b[_0xe0bd('0x4d')][_0xe0bd('0x26')]);}_0x3ecbc4[_0xe0bd('0x55')]=qs['sort'](_0x1c876b[_0xe0bd('0x4d')]['sort']);_0x3ecbc4[_0xe0bd('0x57')]=qs['filters'](_[_0xe0bd('0x58')](_0x1c876b['query'],_0x3ad50a['filters']));_0x3ecbc4[_0xe0bd('0x57')][_0xe0bd('0x72')]=_0x2720ee['id'];if(_0x1c876b[_0xe0bd('0x4d')][_0xe0bd('0x59')]){_0x3ecbc4['where']=_[_0xe0bd('0x76')](_0x3ecbc4[_0xe0bd('0x57')],{'$or':_['map'](_0x3ecbc4[_0xe0bd('0x50')],function(_0xace155){var _0x41d1c0={};_0x41d1c0[_0xace155]={'$like':'%'+_0x1c876b['query'][_0xe0bd('0x59')]+'%'};return _0x41d1c0;})});}_0x3ecbc4=_[_0xe0bd('0x76')]({},_0x3ecbc4,_0x1c876b[_0xe0bd('0x5a')]);return db['CannedAnswer'][_0xe0bd('0x29')]({'where':_0x3ecbc4['where']})[_0xe0bd('0x2d')](function(_0x187c7b){_0x7d8cb4['count']=_0x187c7b;if(_0x1c876b[_0xe0bd('0x4d')][_0xe0bd('0x5c')]){_0x3ecbc4[_0xe0bd('0x5d')]=[{'all':!![]}];}return db['CannedAnswer'][_0xe0bd('0x5e')](_0x3ecbc4);})[_0xe0bd('0x2d')](function(_0x5abb3f){_0x7d8cb4[_0xe0bd('0x77')]=_0x5abb3f;return _0x7d8cb4;});}})['then'](respondWithFilteredResult(_0x49e544,_0x3ecbc4))[_0xe0bd('0x22')](handleError(_0x49e544,null));};exports[_0xe0bd('0x7d')]=function(_0x2bc645,_0x380798){return db['ChatWebsite'][_0xe0bd('0x63')]({'where':{'id':_0x2bc645['params']['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x380798,null))[_0xe0bd('0x2d')](function(_0x4ed0ef){if(_0x4ed0ef){return _0x4ed0ef[_0xe0bd('0x7d')](_0x2bc645['query'][_0xe0bd('0x79')]);}})[_0xe0bd('0x2d')](respondWithStatusCode(_0x380798,null))[_0xe0bd('0x22')](handleError(_0x380798,null));};exports[_0xe0bd('0x7e')]=function(_0x159e29,_0x33ea54){_0x159e29['body'][_0xe0bd('0x7f')]=_0x159e29['file'][_0xe0bd('0x80')];return db[_0xe0bd('0x5b')]['find']({'where':{'id':_0x159e29[_0xe0bd('0x60')]['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x33ea54,null))[_0xe0bd('0x2d')](saveUpdates(_0x159e29['body'],null))[_0xe0bd('0x2d')](respondWithResult(_0x33ea54,null))[_0xe0bd('0x22')](handleError(_0x33ea54,null));};exports[_0xe0bd('0x81')]=function(_0x5f075a,_0x48c26c){_0x5f075a[_0xe0bd('0x65')][_0xe0bd('0x82')]=_0x5f075a[_0xe0bd('0x83')]['filename'];return db[_0xe0bd('0x5b')][_0xe0bd('0x63')]({'where':{'id':_0x5f075a[_0xe0bd('0x60')]['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x48c26c,null))[_0xe0bd('0x2d')](saveUpdates(_0x5f075a[_0xe0bd('0x65')],null))[_0xe0bd('0x2d')](respondWithResult(_0x48c26c,null))[_0xe0bd('0x22')](handleError(_0x48c26c,null));};exports[_0xe0bd('0x84')]=function(_0xd0b07d,_0x3561f8){_0xd0b07d[_0xe0bd('0x65')]['customerAvatar']=_0xd0b07d[_0xe0bd('0x83')]['filename'];return db['ChatWebsite']['find']({'where':{'id':_0xd0b07d[_0xe0bd('0x60')]['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x3561f8,null))[_0xe0bd('0x2d')](saveUpdates(_0xd0b07d[_0xe0bd('0x65')],null))['then'](respondWithResult(_0x3561f8,null))[_0xe0bd('0x22')](handleError(_0x3561f8,null));};exports['addSystemAvatar']=function(_0x119151,_0x441e45){_0x119151[_0xe0bd('0x65')][_0xe0bd('0x85')]=_0x119151[_0xe0bd('0x83')][_0xe0bd('0x80')];return db[_0xe0bd('0x5b')][_0xe0bd('0x63')]({'where':{'id':_0x119151[_0xe0bd('0x60')]['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x441e45,null))[_0xe0bd('0x2d')](saveUpdates(_0x119151[_0xe0bd('0x65')],null))[_0xe0bd('0x2d')](respondWithResult(_0x441e45,null))['catch'](handleError(_0x441e45,null));};exports[_0xe0bd('0x86')]=function(_0x1b2500,_0x2b54db){var _0x19ac0d=path[_0xe0bd('0x87')](config[_0xe0bd('0x88')],_0xe0bd('0x89'));var _0x148b03={'where':{'id':_0x1b2500[_0xe0bd('0x60')]['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x44e912=![];return require(_0xe0bd('0x8a'))[_0xe0bd('0x8b')]()[_0xe0bd('0x2d')](function(_0x483dcb){if(_0x483dcb){_0x44e912=_0x483dcb['custom'];}})['then'](function(){return db['ChatWebsite'][_0xe0bd('0x63')](_0x148b03);})[_0xe0bd('0x2d')](handleEntityNotFound(_0x2b54db,null))['then'](function(_0x314bef){if(_0x314bef){if(!_['isNil'](_0x314bef[_0xe0bd('0x7f')])){if(fs[_0xe0bd('0x8c')](path[_0xe0bd('0x87')](config[_0xe0bd('0x88')],'server/files/images/logos/',_0x314bef[_0xe0bd('0x7f')]))&&_0x44e912){_0x19ac0d=path['join'](config[_0xe0bd('0x88')],'server/files/images/logos/',_0x314bef[_0xe0bd('0x7f')]);}}return _0x2b54db[_0xe0bd('0x8d')](_0x19ac0d);}})[_0xe0bd('0x22')](handleError(_0x2b54db,null));};exports[_0xe0bd('0x8e')]=function(_0x3f2f36,_0x104749){var _0x1a73d9=path[_0xe0bd('0x87')](config[_0xe0bd('0x88')],_0xe0bd('0x8f'));var _0x57159b={'where':{'id':_0x3f2f36[_0xe0bd('0x60')]['id']},'attributes':['id',_0xe0bd('0x82')],'raw':!![]};return db[_0xe0bd('0x5b')][_0xe0bd('0x63')](_0x57159b)[_0xe0bd('0x2d')](handleEntityNotFound(_0x104749,null))[_0xe0bd('0x2d')](function(_0xb1c1c9){if(_0xb1c1c9){if(!_['isNil'](_0xb1c1c9[_0xe0bd('0x82')])){if(fs[_0xe0bd('0x8c')](path['join'](config[_0xe0bd('0x88')],_0xe0bd('0x90'),_0xb1c1c9[_0xe0bd('0x82')]))){_0x1a73d9=path[_0xe0bd('0x87')](config[_0xe0bd('0x88')],_0xe0bd('0x90'),_0xb1c1c9['agentAvatar']);}}return _0x104749['download'](_0x1a73d9);}})['catch'](handleError(_0x104749,null));};exports['getCustomerAvatar']=function(_0xf0bde2,_0x218705){var _0x40b093=path[_0xe0bd('0x87')](config[_0xe0bd('0x88')],_0xe0bd('0x91'));var _0x27d856={'where':{'id':_0xf0bde2['params']['id']},'attributes':['id',_0xe0bd('0x92'),_0xe0bd('0x93')],'raw':!![]};return db[_0xe0bd('0x5b')]['find'](_0x27d856)['then'](handleEntityNotFound(_0x218705,null))[_0xe0bd('0x2d')](function(_0x44da74){if(_0x44da74){if(!_[_0xe0bd('0x94')](_0x44da74[_0xe0bd('0x92')])){if(fs[_0xe0bd('0x8c')](path[_0xe0bd('0x87')](config[_0xe0bd('0x88')],_0xe0bd('0x90'),_0x44da74[_0xe0bd('0x92')]))&&_0x44da74[_0xe0bd('0x93')]){_0x40b093=path[_0xe0bd('0x87')](config[_0xe0bd('0x88')],_0xe0bd('0x90'),_0x44da74[_0xe0bd('0x92')]);}}return _0x218705[_0xe0bd('0x8d')](_0x40b093);}})[_0xe0bd('0x22')](handleError(_0x218705,null));};exports[_0xe0bd('0x95')]=function(_0x15614d,_0xc07673){var _0x2457e4=path[_0xe0bd('0x87')](config['root'],_0xe0bd('0x96'));var _0x103c0c={'where':{'id':_0x15614d[_0xe0bd('0x60')]['id']},'attributes':['id',_0xe0bd('0x85')],'raw':!![]};return db[_0xe0bd('0x5b')][_0xe0bd('0x63')](_0x103c0c)[_0xe0bd('0x2d')](handleEntityNotFound(_0xc07673,null))[_0xe0bd('0x2d')](function(_0x4ccdea){if(_0x4ccdea){if(!_['isNil'](_0x4ccdea[_0xe0bd('0x85')])){if(fs[_0xe0bd('0x8c')](path['join'](config[_0xe0bd('0x88')],'server/files/images/avatars/',_0x4ccdea[_0xe0bd('0x85')]))){_0x2457e4=path['join'](config['root'],_0xe0bd('0x90'),_0x4ccdea['systemAvatar']);}}return _0xc07673['download'](_0x2457e4);}})[_0xe0bd('0x22')](handleError(_0xc07673,null));};function checkWebsiteInterval(_0x2e8e75){var _0x1a972b=_0x2e8e75[_0xe0bd('0x97')];if(!_0x1a972b){return Promise['resolve'](_0x2e8e75);}var _0x5b06fa=_0x2e8e75['timezone']||undefined;return _0x1a972b['ifTime'](_0x5b06fa)[_0xe0bd('0x2d')](function(_0x375ae2){if(!_0x375ae2){throw new APIOutOfIntervalError();}return _0x2e8e75;});}exports[_0xe0bd('0x98')]=function(_0x19fe79,_0x18cfe9){var _0x50be00={'body':_0x19fe79['body'],'channel':_0xe0bd('0x99')};var _0x38b57d=[];var _0x2a5ec4=[];var _0x3c9c74={};var _0x39b3f1=![];if(_0x19fe79[_0xe0bd('0x65')]['id']){delete _0x19fe79[_0xe0bd('0x65')]['id'];}if(_[_0xe0bd('0x94')](_0x19fe79[_0xe0bd('0x65')]['from'])){throw new APIBadRequestError(_0xe0bd('0x9a'));}if(_['isNil'](_0x19fe79[_0xe0bd('0x65')]['mapKey'])){throw new APIBadRequestError(_0xe0bd('0x9b'));}if(_['isEmpty'](_0x19fe79[_0xe0bd('0x65')]['body'])){throw new APIBadRequestError('Body\x20is\x20mandatory');}var _0x118c84=_0x19fe79['body'][_0xe0bd('0x36')]&&_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0x3c')];return db[_0xe0bd('0x9c')][_0xe0bd('0x71')]()['then'](function(_0x5d4c17){if(!_0x5d4c17){throw new Error(_0xe0bd('0x9d'));}_0x38b57d=Object[_0xe0bd('0x62')](_0x5d4c17)[_0xe0bd('0x59')](function(_0x973670){return![_0xe0bd('0x9e'),_0xe0bd('0x9f')][_0xe0bd('0xa0')](_0x973670);});_0x2a5ec4=Object[_0xe0bd('0x62')](_0x5d4c17)['filter'](function(_0x107b30){return![_0xe0bd('0x9e'),'updatedAt',_0xe0bd('0xa1'),'ListId'][_0xe0bd('0xa0')](_0x107b30);});if(!_[_0xe0bd('0xa0')](_0x2a5ec4,_0x19fe79[_0xe0bd('0x65')]['mapKey'])){throw new APIBadRequestError(_0xe0bd('0xa2')+_0x2a5ec4[_0xe0bd('0x87')](',\x20'));}_0x3c9c74[_0x19fe79['body'][_0xe0bd('0xa3')]]=_0x19fe79[_0xe0bd('0x65')]['from'];})['then'](function(){return db['ChatWebsite'][_0xe0bd('0x63')]({'where':{'id':_0x19fe79[_0xe0bd('0x60')]['id']},'include':[{'model':db['CmList'],'as':_0xe0bd('0xa4'),'include':[{'model':db[_0xe0bd('0x9c')],'as':_0xe0bd('0xa5'),'where':_0x3c9c74,'limit':0x1,'order':[['updatedAt',_0xe0bd('0xa6')]]}]},{'model':db[_0xe0bd('0xa7')],'as':_0xe0bd('0xa8')},{'model':db[_0xe0bd('0x97')],'as':'Interval','include':[{'model':db['Interval'],'as':_0xe0bd('0xa9'),'attributes':['id',_0xe0bd('0xaa')],'raw':!![]}]}]});})[_0xe0bd('0x2d')](function(_0xc98287){if(!_0xc98287){throw new APINotFoundError(util['format'](_0xe0bd('0xab'),_0x19fe79['params']['id']));}if(_0x118c84){return checkWebsiteInterval(_0xc98287);}return _0xc98287;})[_0xe0bd('0x2d')](function(_0x336e25){_0x50be00['account']=_0x336e25;_0x50be00[_0xe0bd('0xac')]=_[_0xe0bd('0xad')](_0x336e25[_0xe0bd('0xa8')],[_0xe0bd('0xae')],[_0xe0bd('0xaf')]);if(_0x50be00[_0xe0bd('0xb0')][_0xe0bd('0xa8')]){delete _0x50be00[_0xe0bd('0xb0')][_0xe0bd('0xa8')];}_0x50be00[_0xe0bd('0xb1')]=_0x336e25[_0xe0bd('0xa4')]||{'id':_0x336e25[_0xe0bd('0xb2')]};if(_0x50be00[_0xe0bd('0xb1')]&&_0x50be00['list'][_0xe0bd('0xa5')][_0xe0bd('0x52')]){return _0x50be00[_0xe0bd('0xb1')][_0xe0bd('0xa5')][0x0];}var _0x2fde95=_[_0xe0bd('0xb3')](_0x19fe79[_0xe0bd('0x65')],{'firstName':_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0xb4')],'ListId':_0x336e25[_0xe0bd('0xb2')]});_0x2fde95[_0x19fe79['body'][_0xe0bd('0xa3')]]=_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0xb4')];return db[_0xe0bd('0x9c')][_0xe0bd('0x64')](_0x2fde95,{'fields':_0x38b57d,'raw':!![]});})[_0xe0bd('0x2d')](function(_0x2e1b76){_0x50be00[_0xe0bd('0xb5')]=_0x2e1b76;var _0x35e9d8=createInteractionObject(_0x19fe79[_0xe0bd('0x60')]['id'],_0x19fe79[_0xe0bd('0x65')],_0x19fe79['headers'],_0x2e1b76);var _0x17e256={'ChatWebsiteId':_0x19fe79['params']['id']};if(_0x19fe79['body'][_0xe0bd('0xb6')]){_0x17e256[_0xe0bd('0xb6')]=_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0xb6')];_0x17e256['closed']=![];return db[_0xe0bd('0xb7')][_0xe0bd('0x63')]({'where':_0x17e256})['then'](function(_0x664087){var _0x3a270a=_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0x36')]&&_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0x3c')];if(_0x664087){_0x39b3f1=!![];return _0x664087;}else if(!_0x3a270a&&_0x664087&&_0x664087[_0xe0bd('0xb8')]){throw new APIConflictError(_0xe0bd('0xb9'));}_0x35e9d8['threadId']=_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0xb6')];_0x35e9d8[_0xe0bd('0xba')]=_0x19fe79['body'][_0xe0bd('0xba')];return db[_0xe0bd('0xb7')][_0xe0bd('0x64')](_0x35e9d8);});}_0x17e256['ContactId']=_0x2e1b76['id'];if(_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0xbb')]&&_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0xbb')]['id']){_0x17e256['id']=_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0xbb')]['id'];return db['ChatInteraction']['find']({'where':_0x17e256})[_0xe0bd('0x2d')](function(_0x479daa){var _0x115b0b=_0x19fe79['body'][_0xe0bd('0x36')]&&_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0x3c')];if(!_0x115b0b&&_0x479daa&&_0x479daa[_0xe0bd('0xb8')]){throw new APIConflictError('Writing\x20on\x20closed\x20interaction');}else if(_0x479daa){_0x39b3f1=!![];return _0x479daa;}else{return db[_0xe0bd('0xb7')][_0xe0bd('0x64')](_0x35e9d8);}});}return db[_0xe0bd('0xb7')][_0xe0bd('0x64')](_0x35e9d8);})[_0xe0bd('0x2d')](function(_0x3409b3){if(!_0x39b3f1){return _0x3409b3;}var _0x3cc1e1={'from':(_0x50be00[_0xe0bd('0xb5')][_0xe0bd('0x3a')]||'')+'\x20'+(_0x50be00[_0xe0bd('0xb5')]['lastName']||'')};if(_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0xb6')]&&_0x19fe79[_0xe0bd('0x65')]['messageId']&&_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0xb6')]!=_0x19fe79[_0xe0bd('0x65')]['messageId']){_0x3cc1e1[_0xe0bd('0xb6')]=_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0xbc')];}return _0x3409b3[_0xe0bd('0x70')](_0x3cc1e1);})[_0xe0bd('0x2d')](function(_0x40484b){_0x50be00[_0xe0bd('0xbb')]=_0x40484b[_0xe0bd('0x2e')]({'plain':!![]});_0x50be00[_0xe0bd('0xbb')][_0xe0bd('0xbd')]=!_0x39b3f1;if(_0x50be00['interaction'][_0xe0bd('0xbd')]){if(_0x50be00[_0xe0bd('0xb0')][_0xe0bd('0xbe')]){_0x50be00[_0xe0bd('0xac')][_0xe0bd('0xbf')]({'id':0x0,'priority':_0x50be00['applications'][_0xe0bd('0x52')]+0x1,'app':_0xe0bd('0xc0'),'appdata':_0xe0bd('0xc1'),'interval':'*,*,*,*'});}}return db['ChatMessage'][_0xe0bd('0x64')]({'body':_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0x65')],'ChatWebsiteId':_0x19fe79[_0xe0bd('0x60')]['id'],'ChatInteractionId':_0x40484b['id'],'direction':'in','ContactId':_0x50be00[_0xe0bd('0xb5')]['id'],'AttachmentId':_0x19fe79[_0xe0bd('0x65')][_0xe0bd('0xc2')]});})[_0xe0bd('0x2d')](function(_0x4cb46d){_0x50be00[_0xe0bd('0x20')]=_0x4cb46d;if(!_0x50be00[_0xe0bd('0xbb')][_0xe0bd('0xc3')]){return;}return db['User'][_0xe0bd('0x63')]({'attributes':['id','name'],'where':{'id':_0x50be00[_0xe0bd('0xbb')][_0xe0bd('0xc3')]}});})[_0xe0bd('0x2d')](function(_0x526648){if(_0x526648){_0x50be00[_0xe0bd('0xac')]['unshift']({'id':0x0,'priority':0x0,'app':_0xe0bd('0xc4'),'appdata':_0x526648[_0xe0bd('0x32')]+','+(_0x50be00[_0xe0bd('0xb0')][_0xe0bd('0xc5')]||0xa),'interval':_0xe0bd('0xc6')});_0x50be00[_0xe0bd('0xc7')]=!![];}if(!_0x50be00[_0xe0bd('0xbb')]['queueId']){return;}return db[_0xe0bd('0xc8')][_0xe0bd('0x63')]({'attributes':['id',_0xe0bd('0x32')],'where':{'id':_0x50be00[_0xe0bd('0xbb')][_0xe0bd('0xc9')]}});})['then'](function(_0x38d729){if(_0x38d729){_0x50be00[_0xe0bd('0xac')]['unshift']({'id':0x0,'priority':0x1,'app':'queue','appdata':_0x38d729[_0xe0bd('0x32')]+','+(_0x50be00[_0xe0bd('0xb0')]['waitForTheAssignedQueue']||0x12c),'interval':_0xe0bd('0xc6')});}return respondWithRpcPromise(_0xe0bd('0xca'),_0xe0bd('0xcb'),_0x50be00);})['then'](function(_0x1dee8a){respondWithRpcPromise(_0xe0bd('0xcc'),'EventManager',{'event':'notify','message':_0x1dee8a},client9002);return _0x1dee8a;})[_0xe0bd('0x2d')](respondWithResult(_0x18cfe9,null))[_0xe0bd('0x22')](APIHandleError(_0x18cfe9));};exports[_0xe0bd('0xcd')]=function(_0x3646e6,_0x53085e){var _0x34b407,_0x5b24e7,_0x307b50;var _0x3c5fdb=[];var _0x19fc0b={};var _0x2093b7=_0x3646e6[_0xe0bd('0xce')]||[];var _0x3525c5=[];var _0x43feb4;return db[_0xe0bd('0x9c')][_0xe0bd('0x71')]()[_0xe0bd('0x2d')](function(_0xafcd0b){if(!_0xafcd0b){throw new db[(_0xe0bd('0xcf'))]['ValidationError']('no\x20available\x20attributes');}_0x3c5fdb=_[_0xe0bd('0xd0')](_[_0xe0bd('0x62')](_0xafcd0b),[_0xe0bd('0x9e'),'updatedAt','CompanyId',_0xe0bd('0xb2')]);if(_0x3646e6[_0xe0bd('0x65')]['id']){delete _0x3646e6[_0xe0bd('0x65')]['id'];}if(_['isNil'](_0x3646e6[_0xe0bd('0x65')][_0xe0bd('0xb4')])){throw _0x53085e[_0xe0bd('0x24')](0x1f4)[_0xe0bd('0x33')](new db[(_0xe0bd('0xcf'))]['ValidationError'](_0xe0bd('0xd1')));}if(_[_0xe0bd('0x94')](_0x3646e6[_0xe0bd('0x65')]['body'])||_0x3646e6[_0xe0bd('0x65')]['body']===''){throw _0x53085e[_0xe0bd('0x24')](0x1f4)[_0xe0bd('0x33')](new db[(_0xe0bd('0xcf'))]['ValidationError']('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0xe0bd('0x94')](_0x3646e6[_0xe0bd('0x65')][_0xe0bd('0xd2')])){throw _0x53085e['status'](0x1f4)['send'](new db[(_0xe0bd('0xcf'))][(_0xe0bd('0xd3'))](_0xe0bd('0xd4')+_0x3c5fdb));}if(!_[_0xe0bd('0xa0')](_0x3c5fdb,_0x3646e6[_0xe0bd('0x65')][_0xe0bd('0xd2')])){throw _0x53085e['status'](0x1f4)[_0xe0bd('0x33')](new db[(_0xe0bd('0xcf'))]['ValidationError'](_0xe0bd('0xd5')+_0x3c5fdb));}_0x19fc0b[_0x3646e6[_0xe0bd('0x65')]['mapKeyOffline']]=_0x3646e6[_0xe0bd('0x65')]['from'];})[_0xe0bd('0x2d')](function(){return db[_0xe0bd('0x5b')][_0xe0bd('0x63')]({'where':{'id':_0x3646e6['params']['id']},'include':[{'model':db[_0xe0bd('0xd6')],'as':_0xe0bd('0xa4')},{'model':db['MailAccount'],'as':_0xe0bd('0xd7')}]});})[_0xe0bd('0x2d')](handleEntityNotFound(_0x53085e,null))[_0xe0bd('0x2d')](function(_0x554b1f){if(_0x554b1f&&_0x554b1f[_0xe0bd('0xa4')]){_0x5b24e7=_0x554b1f;var _0x4e04ea=_[_0xe0bd('0xb3')](_0x3646e6[_0xe0bd('0x65')],{'firstName':_0x3646e6['body'][_0xe0bd('0xb4')],'phone':_0x3646e6['body'][_0xe0bd('0xb4')],'ListId':_0x554b1f[_0xe0bd('0xb2')]});_0x4e04ea[_0x3646e6[_0xe0bd('0x65')][_0xe0bd('0xd2')]]=_0x3646e6[_0xe0bd('0x65')][_0xe0bd('0xb4')];return db[_0xe0bd('0x9c')][_0xe0bd('0xd8')]({'where':_0x19fc0b,'defaults':_0x4e04ea});}})[_0xe0bd('0xd9')](function(_0x55ab5d){if(_0x55ab5d){_0x307b50=_0x55ab5d;var _0x5470a1=fs['readFileSync'](path[_0xe0bd('0x87')](config[_0xe0bd('0x88')],_0xe0bd('0xda')),'utf8');var _0x14bc1b=ejs[_0xe0bd('0xdb')](_0x5470a1,{'body':_[_0xe0bd('0xdc')](_0x3646e6[_0xe0bd('0x65')]['body']),'bodyTitle':_0x5b24e7['offlineMessageBody']});return db[_0xe0bd('0xdd')][_0xe0bd('0x64')]({'body':_0x14bc1b,'plainBody':htmlToText[_0xe0bd('0xde')](_0x14bc1b),'ContactId':_0x55ab5d['id'],'ChatWebsiteId':_0x5b24e7['id']});}})['then'](function(_0x55baa6){_0x43feb4=_0x55baa6;if(_0x2093b7[_0xe0bd('0x52')]){var _0x4b23f0=_0x2093b7[_0xe0bd('0x4a')](function(_0x201618){return{'name':_0x201618[_0xe0bd('0xdf')],'basename':_0x201618[_0xe0bd('0x80')],'type':_0x201618[_0xe0bd('0xe0')],'ChatOfflineMessageId':_0x55baa6['id']};});_0x3525c5=_0x4b23f0['map'](_0x1bf11d=>{var _0x4ee6b6={'filename':_0x1bf11d[_0xe0bd('0x32')],'path':path[_0xe0bd('0x87')](config[_0xe0bd('0x88')],'server',_0xe0bd('0xce'),'attachments','offline-chat',_0x1bf11d[_0xe0bd('0xe1')])};return _0x4ee6b6;});if(!_0x5b24e7['openNewInteraction']){return db[_0xe0bd('0xe2')][_0xe0bd('0xe3')](function(_0x1bda4c){return db[_0xe0bd('0xe4')][_0xe0bd('0xe5')](_0x4b23f0,{'transaction':_0x1bda4c});});}}})[_0xe0bd('0x2d')](function(){if(_0x43feb4){_0x34b407=_0x43feb4;return db['MailAccount'][_0xe0bd('0x75')]({'where':{'service':!![]},'include':[{'model':db[_0xe0bd('0xe6')],'as':_0xe0bd('0xe7'),'raw':!![],'include':[{'model':db[_0xe0bd('0xe8')],'as':_0xe0bd('0xe8'),'raw':!![]}]}]});}})['then'](function(_0x21c58d){if(_0x21c58d&&_0x21c58d['Smtp']&&_0x5b24e7[_0xe0bd('0xe9')]&&_0x5b24e7[_0xe0bd('0xea')]){var _0x557304=_0x21c58d[_0xe0bd('0xeb')]();return respondWithRpcPromise('SendMail',_0xe0bd('0xec'),{'account':_0x557304,'message':{'from':util['format']('\x22%s\x22\x20<%s>',_0x21c58d['name'],_0x21c58d['email']||_0x21c58d[_0xe0bd('0xe7')]['user']),'to':_0x5b24e7[_0xe0bd('0xea')],'subject':_0x5b24e7[_0xe0bd('0xed')],'html':_0x34b407['body'],'attachments':_0x3525c5}},client9003)[_0xe0bd('0x2d')](function(){return _0x34b407;})['catch'](function(_0x257675){logger['error'](_0x257675);});}})[_0xe0bd('0x2d')](function(){if(_0x5b24e7&&_0x5b24e7[_0xe0bd('0xee')]&&_0x5b24e7[_0xe0bd('0xef')]){var _0x38535d=[];if(_0x2093b7['length']){_0x38535d=_0x2093b7[_0xe0bd('0x4a')](function(_0xaabe66){return{'name':_0xaabe66[_0xe0bd('0xdf')],'basename':_0xaabe66['filename'],'type':_0xaabe66[_0xe0bd('0xe0')],'ChatOfflineMessageId':_0x43feb4['id']};});}var _0xe76de7;if(!_[_0xe0bd('0x94')](_0x5b24e7[_0xe0bd('0xf0')])){var _0x61c143=_[_0xe0bd('0x4a')](_0x3646e6[_0xe0bd('0x65')],function(_0x156fbb){return _0x156fbb;});var _0x556f3d=_[_0xe0bd('0xf1')](_0x61c143)[0x0];var _0x279131=_[_0xe0bd('0xf2')](_0x556f3d,function(_0x24e1d1){return _0x24e1d1;});_0xe76de7=_0x279131[0x1][_0x5b24e7['subjectOffline']];}var _0x2d8039={'from':_0x307b50[_0xe0bd('0xf3')],'firstName':_0x307b50[_0xe0bd('0x3a')],'lastName':_0x307b50[_0xe0bd('0xf4')],'mapKey':_0xe0bd('0xf3'),'message':{'from':_0x307b50[_0xe0bd('0xf3')],'to':_0x5b24e7[_0xe0bd('0xd7')]['email'],'cc':'','subject':_[_0xe0bd('0x94')](_0xe76de7)?_0x5b24e7[_0xe0bd('0xed')]:_0xe76de7,'messageId':'','sentAt':new Date(),'attach':_0x38535d[_0xe0bd('0x52')],'attachments':_0x38535d,'originChannel':'Chat','ChatWebsiteId':_0x5b24e7['id'],'ChatOfflineMessageId':_0x34b407['id'],'originTo':_0x5b24e7[_0xe0bd('0xd7')][_0xe0bd('0xf3')]},'body':_0x34b407[_0xe0bd('0x65')]};var _0x50b561={'account':{'id':_0x5b24e7[_0xe0bd('0xef')]},'body':_0x2d8039,'log':'NotifyMailAccount'};return respondWithRpcPromise(_0xe0bd('0xf5'),_0xe0bd('0xf6'),_0x50b561,client9001)[_0xe0bd('0x2d')](function(){return _0x34b407;})['catch'](function(_0x1d8ab0){logger[_0xe0bd('0x1d')](_0x1d8ab0);});}return;})[_0xe0bd('0x2d')](function(){if(_0x34b407){return _0x34b407;}})['then'](respondWithResult(_0x53085e,null))[_0xe0bd('0x22')](function(){for(var _0x4f205e of _0x2093b7){var _0x40beb6=path['join'](config[_0xe0bd('0x88')],_0xe0bd('0xf7'),_0xe0bd('0xce'),_0xe0bd('0xf8'),'offline-chat',_0x4f205e[_0xe0bd('0x80')]);fs_extra[_0xe0bd('0xf9')](_0x40beb6)[_0xe0bd('0x22')](function(_0x6d5511){logger[_0xe0bd('0x1d')](_0xe0bd('0xfa'),_0x40beb6,_0x6d5511);});}});};exports[_0xe0bd('0xfb')]=function(_0x20f77c,_0x1317b0){return db[_0xe0bd('0xb7')]['find']({'where':{'id':_0x20f77c[_0xe0bd('0x60')]['id']}})['then'](handleEntityNotFound(_0x1317b0,null))[_0xe0bd('0x2d')](function(_0x18f36b){if(_0x18f36b){return _0x18f36b[_0xe0bd('0xfb')](_0x20f77c[_0xe0bd('0x65')][_0xe0bd('0x79')],_[_0xe0bd('0xfc')](_0x20f77c[_0xe0bd('0x65')],[_0xe0bd('0x79'),'id'])||{});}})[_0xe0bd('0x2d')](respondWithResult(_0x1317b0,null))[_0xe0bd('0x22')](handleError(_0x1317b0,null));};exports[_0xe0bd('0xfd')]=function(_0x3ea57b,_0xb3ab0d){var _0x476279={'raw':![],'where':{}};var _0x14e08a={};var _0x2bef79={'count':0x0,'rows':[]};return db[_0xe0bd('0x5b')][_0xe0bd('0x75')]({'where':{'id':_0x3ea57b[_0xe0bd('0x60')]['id']}})['then'](handleEntityNotFound(_0xb3ab0d,null))[_0xe0bd('0x2d')](function(_0x489370){if(_0x489370){_0x14e08a[_0xe0bd('0x43')]=_[_0xe0bd('0x62')](db[_0xe0bd('0xb7')][_0xe0bd('0x4b')]);_0x14e08a[_0xe0bd('0x4d')]=_[_0xe0bd('0x62')](_0x3ea57b[_0xe0bd('0x4d')]);_0x14e08a[_0xe0bd('0x4e')]=_[_0xe0bd('0x4f')](_0x14e08a[_0xe0bd('0x43')],_0x14e08a[_0xe0bd('0x4d')]);_0x476279['attributes']=_[_0xe0bd('0x4f')](_0x14e08a['model'],qs[_0xe0bd('0x51')](_0x3ea57b['query'][_0xe0bd('0x51')]));_0x476279[_0xe0bd('0x50')]=_0x476279[_0xe0bd('0x50')][_0xe0bd('0x52')]?_0x476279[_0xe0bd('0x50')]:_0x14e08a['model'];if(!_0x3ea57b[_0xe0bd('0x4d')][_0xe0bd('0x53')]('nolimit')){_0x476279[_0xe0bd('0x28')]=qs[_0xe0bd('0x28')](_0x3ea57b[_0xe0bd('0x4d')][_0xe0bd('0x28')]);_0x476279['offset']=qs[_0xe0bd('0x26')](_0x3ea57b['query'][_0xe0bd('0x26')]);}_0x476279[_0xe0bd('0x55')]=qs[_0xe0bd('0x56')](_0x3ea57b['query'][_0xe0bd('0x56')]);_0x476279[_0xe0bd('0x57')]=qs[_0xe0bd('0x4e')](_['pick'](_0x3ea57b['query'],_0x14e08a[_0xe0bd('0x4e')]));_0x476279[_0xe0bd('0x57')][_0xe0bd('0x72')]=_0x489370['id'];if(_0x3ea57b[_0xe0bd('0x4d')]['filter']){_0x476279['where']=_[_0xe0bd('0x76')](_0x476279[_0xe0bd('0x57')],{'$or':_[_0xe0bd('0x4a')](_0x476279[_0xe0bd('0x50')],function(_0x3134f9){var _0x25f4c8={};_0x25f4c8[_0x3134f9]={'$like':'%'+_0x3ea57b[_0xe0bd('0x4d')][_0xe0bd('0x59')]+'%'};return _0x25f4c8;})});}_0x476279=_[_0xe0bd('0x76')]({},_0x476279,_0x3ea57b[_0xe0bd('0x5a')]);return db['ChatInteraction'][_0xe0bd('0x29')]({'where':_0x476279[_0xe0bd('0x57')]})[_0xe0bd('0x2d')](function(_0x235fad){_0x2bef79[_0xe0bd('0x29')]=_0x235fad;if(_0x3ea57b[_0xe0bd('0x4d')]['includeAll']){_0x476279[_0xe0bd('0x5d')]=[{'model':db['CmContact'],'as':_0xe0bd('0xfe'),'required':![]},{'model':db[_0xe0bd('0xff')],'as':_0xe0bd('0x100'),'attributes':[_0xe0bd('0x32'),'fullname',_0xe0bd('0x101')],'required':![]},{'model':db['Tag'],'as':_0xe0bd('0x102'),'attributes':['id',_0xe0bd('0x32'),'color'],'where':_0x3ea57b[_0xe0bd('0x4d')][_0xe0bd('0x103')]?{'id':_0x3ea57b[_0xe0bd('0x4d')][_0xe0bd('0x103')]}:undefined,'required':_0x3ea57b[_0xe0bd('0x4d')][_0xe0bd('0x103')]?!![]:![]}];}return db[_0xe0bd('0xb7')][_0xe0bd('0x5e')](_0x476279);})[_0xe0bd('0x2d')](function(_0x2706db){_0x2bef79['rows']=_0x2706db;return _0x2bef79;});}})[_0xe0bd('0x2d')](respondWithFilteredResult(_0xb3ab0d,_0x476279))['catch'](handleError(_0xb3ab0d,null));};exports[_0xe0bd('0x104')]=function(_0x4e743b,_0x2b3a14){var _0x441f5a=0x0;var _0x50fabf=0x0;var _0x5753e4=![];var _0x3b305b;var _0x1c8f9b;return db['ChatWebsite'][_0xe0bd('0x63')]({'where':{'id':_0x4e743b['params']['id']},'include':[{'model':db[_0xe0bd('0x97')],'as':_0xe0bd('0x97'),'include':[{'model':db['Interval'],'as':_0xe0bd('0xa9'),'attributes':['id',_0xe0bd('0xaa')]}]}]})[_0xe0bd('0x2d')](handleEntityNotFound(_0x2b3a14,null))[_0xe0bd('0x2d')](function(_0x3ffa4f){if(_0x3ffa4f){_0x3b305b=_0x3ffa4f;return _0x3ffa4f[_0xe0bd('0x105')]({'raw':!![]});}})['then'](function(_0x1270af){if(_0x3b305b){if(_0x1270af){_0x1c8f9b=_0x1270af;}}return require('../../config/license/util')[_0xe0bd('0x8b')]();})[_0xe0bd('0x2d')](function(_0x31fba1){if(_0x31fba1){_0x50fabf=_0x31fba1['virtual'];_0x5753e4=_0x31fba1[_0xe0bd('0x106')];}})[_0xe0bd('0x2d')](function(){return db[_0xe0bd('0xb7')][_0xe0bd('0x29')]({'where':{'closed':![]}});})[_0xe0bd('0x2d')](function(_0x57299b){_0x441f5a=_0x57299b;if(_0x50fabf&&_0x57299b>_0x50fabf){return db[_0xe0bd('0x107')]['findOne']({'where':{'id':0x1}})[_0xe0bd('0x2d')](function(_0xc3ab5e){if(_0xc3ab5e){_0xc3ab5e[_0xe0bd('0x108')](_0xe0bd('0x109'));}});}})[_0xe0bd('0x2d')](function(){var _0x1b73c1=_0x3b305b[_0xe0bd('0x97')];var _0x33bed3=_0x3b305b[_0xe0bd('0x10a')]||undefined;return _0x1b73c1?_0x1b73c1[_0xe0bd('0x10b')](_0x33bed3):!![];})[_0xe0bd('0x2d')](function(_0x10b521){var _0x3b4570=fs['readFileSync'](path['join'](config['root'],_0xe0bd('0x10c')),_0xe0bd('0x10d'));var _0x459ca1=_0xe0bd('0x10e');var _0x46b491=![];var _0x115fda,_0x1c8cde;if(_0x4e743b[_0xe0bd('0x10f')]['referer']){_0x115fda=new URL(_0x4e743b[_0xe0bd('0x10f')]['referer'])[_0xe0bd('0x110')];}else if(_0x4e743b['headers'][_0xe0bd('0x110')]){_0x115fda=new URL(_0x4e743b[_0xe0bd('0x10f')]['origin'])[_0xe0bd('0x110')];}else{_0x115fda='http://localhost:9000';}_0x1c8cde=typeof _0x3b305b[_0xe0bd('0x66')]['split'](',')[_0xe0bd('0x63')](function(_0x213bd7){return wildcardUtils[_0xe0bd('0x111')](_0x213bd7,_0x115fda);})!==_0xe0bd('0x27');var _0x253cd4={'chatVersion':_0x459ca1,'chatWebsiteAddressOrigin':_0x1c8cde?_0x115fda:_0x3b305b[_0xe0bd('0x66')],'remote':_0x3b305b['remote'],'query':querystring['stringify'](_[_0xe0bd('0x76')](_0x3b305b['get']({'plain':!![]}),{'customerIp':_0x4e743b[_0xe0bd('0x10f')][_0xe0bd('0x112')]||_0x4e743b['headers']['x-real-ip']||_0x4e743b['connection'][_0xe0bd('0x113')]||_0x4e743b['ip'],'referer':_0x4e743b[_0xe0bd('0x10f')]['referer'],'openedInteractions':_0x441f5a,'maxInteractions':_0x50fabf,'virtual':_0x5753e4[_0xe0bd('0x114')],'online':_0x10b521,'custom':_0x5753e4,'address':_0x1c8cde?_0x115fda:null}))[_0xe0bd('0x115')](/'/g,'\x5c\x27')};_0x2b3a14[_0xe0bd('0x33')](ejs[_0xe0bd('0xdb')](Mustache[_0xe0bd('0xdb')](_0x3b4570,_0x253cd4),{'proactiveActions':_0x1c8f9b,'alignment':_0x3b305b[_0xe0bd('0x116')],'verticalAlignment':_0x3b305b[_0xe0bd('0x117')],'div_color':_0x3b305b['color'],'labelText':_0x3b305b[_0xe0bd('0x118')],'text_color':_0x3b305b[_0xe0bd('0x119')],'text_button_color':_0x3b305b[_0xe0bd('0x11a')],'button_color':_0x3b305b['color_button'],'background_color':_0x3b305b[_0xe0bd('0x11b')],'hideWhenOffline':_0x3b305b['hideWhenOffline'],'intervalId':_0x3b305b[_0xe0bd('0x11c')],'isDevelopment':_0x46b491,'chatVersion':_0x459ca1}));})[_0xe0bd('0x22')](handleError(_0x2b3a14,null));};exports['addApplications']=function(_0x20edd3,_0x57e9f1){var _0x5c27e9=_0x20edd3[_0xe0bd('0x60')]['id'];var _0x3c16bf=_0x20edd3[_0xe0bd('0x65')];var _0x4b37ff=0xc8;var _0x489e3a=null;return db[_0xe0bd('0xe2')][_0xe0bd('0xe3')]({'isolationLevel':db[_0xe0bd('0xe2')]['Transaction'][_0xe0bd('0x11d')][_0xe0bd('0x11e')]},function(_0x53f214){return db[_0xe0bd('0x5b')][_0xe0bd('0x75')]({'where':{'id':_0x5c27e9},'transaction':_0x53f214})[_0xe0bd('0x2d')](function(_0x39fb7d){if(_0x39fb7d){return db[_0xe0bd('0xa7')][_0xe0bd('0x2c')]({'where':{'ChatWebsiteId':_0x5c27e9},'transaction':_0x53f214})[_0xe0bd('0x2d')](function(){var _0x41176c=_[_0xe0bd('0x4a')](_0x3c16bf,function(_0x2bc236){_0x2bc236[_0xe0bd('0x72')]=_0x5c27e9;return _0x2bc236;});return db[_0xe0bd('0xa7')][_0xe0bd('0xe5')](_0x41176c,{'transaction':_0x53f214});});}else{_0x4b37ff=0x194;_0x489e3a=[];}});})['then'](function(){if(_0x4b37ff!==0x194){return db[_0xe0bd('0xa7')][_0xe0bd('0x11f')]({'where':{'ChatWebsiteId':_0x5c27e9},'order':'priority'})[_0xe0bd('0x2d')](function(_0x51f418){_0x489e3a=_0x51f418;});}})[_0xe0bd('0x22')](function(_0x925f92){_0x4b37ff=0x1f4;logger[_0xe0bd('0x1d')](_0x925f92[_0xe0bd('0x31')]);if(_0x925f92[_0xe0bd('0x32')]){delete _0x925f92[_0xe0bd('0x32')];}_0x489e3a=_0x925f92;})[_0xe0bd('0x120')](function(){if(_0x489e3a===null){_0x57e9f1[_0xe0bd('0x23')](_0x4b37ff);}else{if(_0x4b37ff===0x1f4){_0x57e9f1[_0xe0bd('0x24')](_0x4b37ff)[_0xe0bd('0x33')](_0x489e3a);}else{_0x57e9f1[_0xe0bd('0x24')](_0x4b37ff)[_0xe0bd('0x25')](_0x489e3a);}}});};exports[_0xe0bd('0x121')]=function(_0x2e7353,_0x530975){var _0x417d1e={};var _0x45020f={};var _0x558300;var _0x5eccf4;return db[_0xe0bd('0x5b')][_0xe0bd('0x75')]({'where':{'id':_0x2e7353[_0xe0bd('0x60')]['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x530975,null))[_0xe0bd('0x2d')](function(_0x377002){if(_0x377002){_0x558300=_0x377002;_0x45020f[_0xe0bd('0x43')]=_[_0xe0bd('0x62')](db[_0xe0bd('0xa7')][_0xe0bd('0x4b')]);_0x45020f[_0xe0bd('0x4d')]=_[_0xe0bd('0x62')](_0x2e7353['query']);_0x45020f[_0xe0bd('0x4e')]=_['intersection'](_0x45020f[_0xe0bd('0x43')],_0x45020f[_0xe0bd('0x4d')]);_0x417d1e[_0xe0bd('0x50')]=_[_0xe0bd('0x4f')](_0x45020f[_0xe0bd('0x43')],qs[_0xe0bd('0x51')](_0x2e7353[_0xe0bd('0x4d')][_0xe0bd('0x51')]));_0x417d1e[_0xe0bd('0x50')]=_0x417d1e[_0xe0bd('0x50')]['length']?_0x417d1e[_0xe0bd('0x50')]:_0x45020f['model'];_0x417d1e[_0xe0bd('0x55')]=qs[_0xe0bd('0x56')](_0x2e7353[_0xe0bd('0x4d')][_0xe0bd('0x56')]);_0x417d1e[_0xe0bd('0x57')]=qs[_0xe0bd('0x4e')](_[_0xe0bd('0x58')](_0x2e7353['query'],_0x45020f[_0xe0bd('0x4e')]));if(_0x2e7353['query']['filter']){_0x417d1e['where']=_[_0xe0bd('0x76')](_0x417d1e[_0xe0bd('0x57')],{'$or':_[_0xe0bd('0x4a')](_0x417d1e[_0xe0bd('0x50')],function(_0x5732fe){var _0x1abc67={};_0x1abc67[_0x5732fe]={'$like':'%'+_0x2e7353[_0xe0bd('0x4d')]['filter']+'%'};return _0x1abc67;})});}_0x417d1e=_[_0xe0bd('0x76')]({},_0x417d1e,_0x2e7353[_0xe0bd('0x5a')]);return _0x558300[_0xe0bd('0x121')](_0x417d1e);}})[_0xe0bd('0x2d')](function(_0x7640ce){if(_0x7640ce){_0x5eccf4=_0x7640ce[_0xe0bd('0x52')];if(!_0x2e7353[_0xe0bd('0x4d')][_0xe0bd('0x53')](_0xe0bd('0x54'))){_0x417d1e[_0xe0bd('0x28')]=qs[_0xe0bd('0x28')](_0x2e7353[_0xe0bd('0x4d')][_0xe0bd('0x28')]);_0x417d1e[_0xe0bd('0x26')]=qs[_0xe0bd('0x26')](_0x2e7353[_0xe0bd('0x4d')][_0xe0bd('0x26')]);}return _0x558300[_0xe0bd('0x121')](_0x417d1e);}})[_0xe0bd('0x2d')](function(_0x130145){if(_0x130145){return _0x130145?{'count':_0x5eccf4,'rows':_0x130145}:null;}})[_0xe0bd('0x2d')](respondWithResult(_0x530975,null))[_0xe0bd('0x22')](handleError(_0x530975,null));};exports[_0xe0bd('0x122')]=function(_0x3bacba,_0x2f3c98){return db[_0xe0bd('0x123')][_0xe0bd('0x63')]({'where':{'id':_0x3bacba[_0xe0bd('0x60')]['id']}})['then'](handleEntityNotFound(_0x2f3c98,null))['then'](function(_0x49ece0){if(_0x49ece0){return _0x49ece0[_0xe0bd('0x122')](_0x3bacba['body'][_0xe0bd('0x79')],_[_0xe0bd('0xfc')](_0x3bacba['body'],[_0xe0bd('0x79'),'id'])||{});}})[_0xe0bd('0x2d')](respondWithResult(_0x2f3c98,null))['catch'](handleError(_0x2f3c98,null));};exports['getProactiveActions']=function(_0x4c0c60,_0x17c3d2){var _0x126f4f={};var _0x147484={};var _0x23a461;var _0x344023;return db[_0xe0bd('0x5b')]['findOne']({'where':{'id':_0x4c0c60['params']['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x17c3d2,null))[_0xe0bd('0x2d')](function(_0x23e1df){if(_0x23e1df){_0x23a461=_0x23e1df;_0x147484[_0xe0bd('0x43')]=_[_0xe0bd('0x62')](db[_0xe0bd('0x124')][_0xe0bd('0x4b')]);_0x147484['query']=_[_0xe0bd('0x62')](_0x4c0c60[_0xe0bd('0x4d')]);_0x147484[_0xe0bd('0x4e')]=_[_0xe0bd('0x4f')](_0x147484[_0xe0bd('0x43')],_0x147484[_0xe0bd('0x4d')]);_0x126f4f[_0xe0bd('0x50')]=_['intersection'](_0x147484[_0xe0bd('0x43')],qs['fields'](_0x4c0c60[_0xe0bd('0x4d')][_0xe0bd('0x51')]));_0x126f4f[_0xe0bd('0x50')]=_0x126f4f['attributes'][_0xe0bd('0x52')]?_0x126f4f[_0xe0bd('0x50')]:_0x147484[_0xe0bd('0x43')];_0x126f4f['order']=qs[_0xe0bd('0x56')](_0x4c0c60[_0xe0bd('0x4d')][_0xe0bd('0x56')]);_0x126f4f['where']=qs['filters'](_[_0xe0bd('0x58')](_0x4c0c60[_0xe0bd('0x4d')],_0x147484[_0xe0bd('0x4e')]));if(_0x4c0c60[_0xe0bd('0x4d')][_0xe0bd('0x59')]){_0x126f4f[_0xe0bd('0x57')]=_[_0xe0bd('0x76')](_0x126f4f[_0xe0bd('0x57')],{'$or':_[_0xe0bd('0x4a')](_0x126f4f[_0xe0bd('0x50')],function(_0x13e541){var _0x1eb193={};_0x1eb193[_0x13e541]={'$like':'%'+_0x4c0c60[_0xe0bd('0x4d')]['filter']+'%'};return _0x1eb193;})});}_0x126f4f=_[_0xe0bd('0x76')]({},_0x126f4f,_0x4c0c60['options']);return _0x23a461['getProactiveActions'](_0x126f4f);}})[_0xe0bd('0x2d')](function(_0x14ddf8){if(_0x14ddf8){_0x344023=_0x14ddf8[_0xe0bd('0x52')];if(!_0x4c0c60['query'][_0xe0bd('0x53')](_0xe0bd('0x54'))){_0x126f4f['limit']=qs[_0xe0bd('0x28')](_0x4c0c60[_0xe0bd('0x4d')]['limit']);_0x126f4f[_0xe0bd('0x26')]=qs[_0xe0bd('0x26')](_0x4c0c60[_0xe0bd('0x4d')][_0xe0bd('0x26')]);}return _0x23a461[_0xe0bd('0x105')](_0x126f4f);}})['then'](function(_0x3bcd4a){if(_0x3bcd4a){return _0x3bcd4a?{'count':_0x344023,'rows':_0x3bcd4a}:null;}})[_0xe0bd('0x2d')](respondWithResult(_0x17c3d2,null))[_0xe0bd('0x22')](handleError(_0x17c3d2,null));};exports[_0xe0bd('0x125')]=function(_0xb51896,_0x1daedf){var _0x1214ae=_0xb51896[_0xe0bd('0x4d')][_0xe0bd('0x126')]===_0xe0bd('0x127')?_0xe0bd('0x128'):_0xe0bd('0x129');return db[_0xe0bd('0x5b')][_0xe0bd('0x63')]({'attributes':['id',_0x1214ae],'where':{'id':_0xb51896[_0xe0bd('0x60')]['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x1daedf,null))[_0xe0bd('0x2d')](function(_0x2bcf7b){if(_0x2bcf7b){var _0x362a30=_0x2bcf7b[_0x1214ae];var _0x2d9c32=_0x362a30&&_0x362a30[_0xe0bd('0x12a')]?_0x362a30['items']:[];_0x1daedf['send']({'fromKey':_[_0xe0bd('0x94')](_0x362a30[_0xe0bd('0x12b')])?undefined:_0x362a30[_0xe0bd('0x12b')],'count':_0x2d9c32[_0xe0bd('0x52')],'rows':_0x2d9c32});}})['catch'](handleError(_0x1daedf,null));};exports[_0xe0bd('0x12c')]=function(_0x437d6d,_0x52dc0e){var _0x4e1066={'raw':![],'where':{}};var _0x57273f={};var _0x1f3fe3={'count':0x0,'rows':[]};return db[_0xe0bd('0x5b')]['findOne']({'where':{'id':_0x437d6d[_0xe0bd('0x60')]['id']}})['then'](handleEntityNotFound(_0x52dc0e,null))[_0xe0bd('0x2d')](function(_0xb2a40a){if(_0xb2a40a){_0x57273f['model']=_['keys'](db['ChatOfflineMessage']['rawAttributes']);_0x57273f[_0xe0bd('0x4d')]=_[_0xe0bd('0x62')](_0x437d6d['query']);_0x57273f[_0xe0bd('0x4e')]=_[_0xe0bd('0x4f')](_0x57273f[_0xe0bd('0x43')],_0x57273f['query']);_0x4e1066[_0xe0bd('0x50')]=_[_0xe0bd('0x4f')](_0x57273f[_0xe0bd('0x43')],qs[_0xe0bd('0x51')](_0x437d6d['query'][_0xe0bd('0x51')]));_0x4e1066[_0xe0bd('0x50')]=_0x4e1066[_0xe0bd('0x50')]['length']?_0x4e1066[_0xe0bd('0x50')]:_0x57273f['model'];if(!_0x437d6d[_0xe0bd('0x4d')][_0xe0bd('0x53')]('nolimit')){_0x4e1066['limit']=qs['limit'](_0x437d6d[_0xe0bd('0x4d')][_0xe0bd('0x28')]);_0x4e1066[_0xe0bd('0x26')]=qs[_0xe0bd('0x26')](_0x437d6d[_0xe0bd('0x4d')][_0xe0bd('0x26')]);}_0x4e1066[_0xe0bd('0x55')]=qs[_0xe0bd('0x56')](_0x437d6d['query'][_0xe0bd('0x56')]);_0x4e1066[_0xe0bd('0x57')]=qs[_0xe0bd('0x4e')](_[_0xe0bd('0x58')](_0x437d6d['query'],_0x57273f[_0xe0bd('0x4e')]));_0x4e1066[_0xe0bd('0x57')][_0xe0bd('0x72')]=_0xb2a40a['id'];if(_0x437d6d[_0xe0bd('0x4d')][_0xe0bd('0x59')]){_0x4e1066[_0xe0bd('0x57')]=_[_0xe0bd('0x76')](_0x4e1066[_0xe0bd('0x57')],{'$or':_[_0xe0bd('0x4a')](_0x4e1066[_0xe0bd('0x50')],function(_0x466acd){var _0x337097={};_0x337097[_0x466acd]={'$like':'%'+_0x437d6d[_0xe0bd('0x4d')][_0xe0bd('0x59')]+'%'};return _0x337097;})});}_0x4e1066=_[_0xe0bd('0x76')]({},_0x4e1066,_0x437d6d[_0xe0bd('0x5a')]);return db[_0xe0bd('0xdd')][_0xe0bd('0x29')]({'where':_0x4e1066[_0xe0bd('0x57')]})[_0xe0bd('0x2d')](function(_0x11e6bf){_0x1f3fe3[_0xe0bd('0x29')]=_0x11e6bf;if(_0x437d6d['query'][_0xe0bd('0x5c')]){_0x4e1066[_0xe0bd('0x5d')]=[{'all':!![]}];}else{_0x4e1066[_0xe0bd('0x5d')]=[{'model':db[_0xe0bd('0x9c')],'as':_0xe0bd('0xfe'),'required':![]},{'model':db[_0xe0bd('0xe4')],'as':_0xe0bd('0x12d'),'required':![]}];}return db[_0xe0bd('0xdd')][_0xe0bd('0x5e')](_0x4e1066);})[_0xe0bd('0x2d')](function(_0xda0046){_0x1f3fe3[_0xe0bd('0x77')]=_0xda0046;return _0x1f3fe3;});}})['then'](respondWithFilteredResult(_0x52dc0e,_0x4e1066))[_0xe0bd('0x22')](handleError(_0x52dc0e,null));};exports[_0xe0bd('0x12e')]=function(_0x473a4a,_0x4c814c){return db['ChatWebsite'][_0xe0bd('0x63')]({'where':{'id':_0x473a4a[_0xe0bd('0x60')]['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x4c814c,null))['then'](function(_0x379f73){if(_0x379f73){return _0x379f73[_0xe0bd('0x12e')](_0x473a4a['body'][_0xe0bd('0x79')],_[_0xe0bd('0xfc')](_0x473a4a[_0xe0bd('0x65')],[_0xe0bd('0x79'),'id'])||{})['spread'](function(_0x47d033){for(var _0x10b1bb=0x0;_0x10b1bb<_0x473a4a[_0xe0bd('0x65')][_0xe0bd('0x79')][_0xe0bd('0x52')];_0x10b1bb+=0x1){socket[_0xe0bd('0x12f')](_0xe0bd('0x130'),{'UserId':Number(_0x473a4a['body'][_0xe0bd('0x79')][_0x10b1bb]),'ChatWebsiteId':Number(_0x473a4a['params']['id'])});}return _0x47d033;});}})['then'](respondWithResult(_0x4c814c,null))['catch'](handleError(_0x4c814c,null));};exports[_0xe0bd('0x131')]=function(_0x1fd44b,_0xc62f6f){return db[_0xe0bd('0x5b')][_0xe0bd('0x63')]({'where':{'id':_0x1fd44b[_0xe0bd('0x60')]['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0xc62f6f,null))[_0xe0bd('0x2d')](function(_0x1f3d4a){if(_0x1f3d4a){return _0x1f3d4a[_0xe0bd('0x131')](_0x1fd44b[_0xe0bd('0x4d')][_0xe0bd('0x79')])['then'](function(){if(_['isArray'](_0x1fd44b[_0xe0bd('0x4d')]['ids'])){for(var _0x30d26d=0x0;_0x30d26d<_0x1fd44b[_0xe0bd('0x4d')][_0xe0bd('0x79')][_0xe0bd('0x52')];_0x30d26d+=0x1){socket[_0xe0bd('0x12f')](_0xe0bd('0x132'),{'UserId':Number(_0x1fd44b[_0xe0bd('0x4d')][_0xe0bd('0x79')][_0x30d26d]),'ChatWebsiteId':Number(_0x1fd44b[_0xe0bd('0x60')]['id'])});}}else{socket[_0xe0bd('0x12f')](_0xe0bd('0x132'),{'UserId':Number(_0x1fd44b[_0xe0bd('0x4d')][_0xe0bd('0x79')]),'ChatWebsiteId':Number(_0x1fd44b[_0xe0bd('0x60')]['id'])});}});}})[_0xe0bd('0x2d')](respondWithStatusCode(_0xc62f6f,null))[_0xe0bd('0x22')](handleError(_0xc62f6f,null));};exports[_0xe0bd('0x133')]=function(_0x56d888,_0x13f81b){var _0x22a9bb={};var _0x57364f={};var _0x16f3cd;var _0x35f53d;return db[_0xe0bd('0x5b')]['findOne']({'where':{'id':_0x56d888[_0xe0bd('0x60')]['id']}})[_0xe0bd('0x2d')](handleEntityNotFound(_0x13f81b,null))['then'](function(_0x28d946){if(_0x28d946){_0x16f3cd=_0x28d946;_0x57364f['model']=_[_0xe0bd('0x62')](db[_0xe0bd('0xff')][_0xe0bd('0x4b')]);_0x57364f['query']=_[_0xe0bd('0x62')](_0x56d888['query']);_0x57364f[_0xe0bd('0x4e')]=_[_0xe0bd('0x4f')](_0x57364f[_0xe0bd('0x43')],_0x57364f['query']);_0x22a9bb[_0xe0bd('0x50')]=_['intersection'](_0x57364f[_0xe0bd('0x43')],qs['fields'](_0x56d888[_0xe0bd('0x4d')][_0xe0bd('0x51')]));_0x22a9bb[_0xe0bd('0x50')]=_0x22a9bb['attributes'][_0xe0bd('0x52')]?_0x22a9bb[_0xe0bd('0x50')]:_0x57364f[_0xe0bd('0x43')];_0x22a9bb[_0xe0bd('0x55')]=qs['sort'](_0x56d888['query'][_0xe0bd('0x56')]);_0x22a9bb['where']=qs[_0xe0bd('0x4e')](_[_0xe0bd('0x58')](_0x56d888[_0xe0bd('0x4d')],_0x57364f[_0xe0bd('0x4e')]));if(_0x56d888[_0xe0bd('0x4d')][_0xe0bd('0x59')]){_0x22a9bb[_0xe0bd('0x57')]=_[_0xe0bd('0x76')](_0x22a9bb[_0xe0bd('0x57')],{'$or':_[_0xe0bd('0x4a')](_0x22a9bb[_0xe0bd('0x50')],function(_0x5a11c0){var _0x2b710b={};_0x2b710b[_0x5a11c0]={'$like':'%'+_0x56d888[_0xe0bd('0x4d')][_0xe0bd('0x59')]+'%'};return _0x2b710b;})});}_0x22a9bb=_[_0xe0bd('0x76')]({},_0x22a9bb,_0x56d888[_0xe0bd('0x5a')]);return _0x16f3cd[_0xe0bd('0x133')](_0x22a9bb);}})[_0xe0bd('0x2d')](function(_0x5ad841){if(_0x5ad841){_0x35f53d=_0x5ad841[_0xe0bd('0x52')];if(!_0x56d888[_0xe0bd('0x4d')][_0xe0bd('0x53')](_0xe0bd('0x54'))){_0x22a9bb['limit']=qs[_0xe0bd('0x28')](_0x56d888['query'][_0xe0bd('0x28')]);_0x22a9bb[_0xe0bd('0x26')]=qs['offset'](_0x56d888[_0xe0bd('0x4d')][_0xe0bd('0x26')]);}return _0x16f3cd[_0xe0bd('0x133')](_0x22a9bb);}})['then'](function(_0x25902b){if(_0x25902b){return _0x25902b?{'count':_0x35f53d,'rows':_0x25902b}:null;}})[_0xe0bd('0x2d')](respondWithResult(_0x13f81b,null))[_0xe0bd('0x22')](handleError(_0x13f81b,null));};
\ No newline at end of file
+var _0x3937=['Disposition','getDispositions','findOne','nolimit','pick','removeDispositions','ids','CannedAnswer','findAll','removeAnswers','addLogo','sitepic','file','filename','addAvatar','addCustomerAvatar','addSystemAvatar','systemAvatar','getLogo','root','server/files/images/logos/default_logo.svg','isNil','existsSync','server/files/images/logos/','join','getAvatar','agentAvatar','server/files/images/avatars/','download','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','customerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','Interval','resolve','timezone','ifTime','notify','chat','From\x20is\x20mandatory','MapKey\x20is\x20mandatory','isEmpty','Body\x20is\x20mandatory','customerIp','No\x20available\x20attributes','createdAt','updatedAt','includes','CompanyId','ListId','mapKey','from','CmList','CmContact','Contacts','ChatApplication','Intervals','Chat\x20Website\x20with\x20id\x20%s\x20not\x20found','applications','orderBy','priority','account','Applications','List','list','contact','headers','threadId','closed','ChatInteraction','Writing\x20on\x20closed\x20interaction','externalUrl','ContactId','interaction','messageId','created','autoclose','push','close','unmanaged','*,*,*,*','AttachmentId','UserId','User','unshift','agent','forcedOwnership','queueId','ChatQueue','queue','waitForTheAssignedQueue','Start','EventManager','offline','files','Sequelize','no\x20available\x20attributes','difference','send','from\x20is\x20mandatory','ValidationError','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','fromString','originalname','mimetype','server','attachments','offline-chat','basename','openNewInteraction','transaction','Attachment','bulkCreate','Smtp','CloudProvider','forwardOfflineAddress','getSmtpOptions','SendMail','email','offlineMessageSubject','MailAccountId','subjectOffline','Chat','NotifyMailAccount','notifyMail','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','Contact','Owner','fullname','Tags','color','tag','getSnippet','interval','getProactiveActions','virtual','custom','increment','chatLicenseExceeded','3.13.0','origin','http://localhost:9000','testWebsiteWithWildcard','x-real-ip','connection','remoteAddress','replace','alignment','verticalAlignment','labelText','textColor','textButtonColor','color_button','IntervalId','addApplications','sequelize','ISOLATION_LEVELS','READ_COMMITTED','finally','getApplications','addProactiveActions','getFields','online','onlineForm','items','fromKey','getOfflineMessages','Attachments','spread','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','mustache','path','ejs','lodash','html-to-text','jayson/promise','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../errors/api','APIBadRequestError','APINotFoundError','handleError','./helpers/wildcard-expressions','defaults','redis','localhost','./chatWebsite.socket','register','client','http','request','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','message','ChatWebsite,\x20%s,\x20%s','catch','sendStatus','status','end','json','undefined','count','offset','limit','set','Content-Range','update','then','get','ChatWebsites','UserProfileResource','destroy','stack','name','setUA','user-agent','getResult','cf-connecting-ip','x-forwarded-for','first','split','firstName','lastName','x-real-port','referer','browser','version','format','%s\x20%s','unknown','device','model','vendor','type','index','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','fieldName','key','query','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','filter','merge','VIRTUAL','options','include','rows','show','params','keys','includeAll','create','trim','testWildcardValidity','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','address','forEach','\x22\x20is\x20not\x20a\x20valid\x20wildcard\x20expression','describe','addDisposition','ChatWebsiteId'];(function(_0xbe40ad,_0x44343c){var _0x50fac9=function(_0xdaed07){while(--_0xdaed07){_0xbe40ad['push'](_0xbe40ad['shift']());}};_0x50fac9(++_0x44343c);}(_0x3937,0xbf));var _0x7393=function(_0x499754,_0x45a36f){_0x499754=_0x499754-0x0;var _0x5f11d=_0x3937[_0x499754];return _0x5f11d;};'use strict';var Mustache=require(_0x7393('0x0'));var util=require('util');var path=require(_0x7393('0x1'));var ejs=require(_0x7393('0x2'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x7393('0x3'));var querystring=require('querystring');var htmlToText=require(_0x7393('0x4'));var Redis=require('ioredis');var jayson=require(_0x7393('0x5'));var qs=require(_0x7393('0x6'));var logger=require(_0x7393('0x7'))(_0x7393('0x8'));var config=require(_0x7393('0x9'));var APIBadRequestError=require(_0x7393('0xa'))[_0x7393('0xb')];var APINotFoundError=require(_0x7393('0xa'))[_0x7393('0xc')];var APIOutOfIntervalError=require('../../errors/api')['APIOutOfIntervalError'];var APIHandleError=require(_0x7393('0xa'))[_0x7393('0xd')];var APIConflictError=require(_0x7393('0xa'))['APIConflictError'];var wildcardUtils=require(_0x7393('0xe'));var URL=require('url')['URL'];var db=require('../../mysqldb')['db'];config['redis']=_[_0x7393('0xf')](config[_0x7393('0x10')],{'host':_0x7393('0x11'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x7393('0x10')]));require(_0x7393('0x12'))[_0x7393('0x13')](socket);var client=jayson[_0x7393('0x14')][_0x7393('0x15')]({'port':0x232c});var client9002=jayson[_0x7393('0x14')][_0x7393('0x15')]({'port':0x232a});var client9003=jayson[_0x7393('0x14')][_0x7393('0x15')]({'port':0x232b});var client9001=jayson['client']['http']({'port':0x2329});function respondWithRpcPromise(_0x414c37,_0x5d0d2b,_0x5b91a9,_0x4e7ec6){return new Promise(function(_0x82f5fa,_0x54dc47){var _0x2a1180=_0x4e7ec6||client;return _0x2a1180[_0x7393('0x16')](_0x414c37,_0x5b91a9)['then'](function(_0x459abf){logger['info']('ChatWebsite,\x20%s,\x20%s',_0x5d0d2b,_0x7393('0x17'));logger[_0x7393('0x18')](_0x7393('0x19'),_0x5d0d2b,_0x7393('0x17'),JSON[_0x7393('0x1a')](_0x459abf));if(_0x459abf[_0x7393('0x1b')]){if(_0x459abf[_0x7393('0x1b')][_0x7393('0x1c')]===0x1f4){logger['error']('ChatWebsite,\x20%s,\x20%s',_0x5d0d2b,_0x459abf[_0x7393('0x1b')][_0x7393('0x1d')]);return _0x54dc47(_0x459abf[_0x7393('0x1b')][_0x7393('0x1d')]);}logger[_0x7393('0x1b')]('ChatWebsite,\x20%s,\x20%s',_0x5d0d2b,_0x459abf['error']['message']);return _0x82f5fa(_0x459abf[_0x7393('0x1b')]['message']);}else{logger['info'](_0x7393('0x1e'),_0x5d0d2b,_0x7393('0x17'));_0x82f5fa(_0x459abf['result'][_0x7393('0x1d')]);}})[_0x7393('0x1f')](function(_0x1ac912){logger[_0x7393('0x1b')](_0x7393('0x1e'),_0x5d0d2b,_0x1ac912);_0x54dc47(_0x1ac912);});});}function respondWithStatusCode(_0x2c025f,_0x1b31b8){_0x1b31b8=_0x1b31b8||0xcc;return function(_0x39ddd3){if(_0x39ddd3){return _0x2c025f[_0x7393('0x20')](_0x1b31b8);}return _0x2c025f[_0x7393('0x21')](_0x1b31b8)[_0x7393('0x22')]();};}function respondWithResult(_0x123ab4,_0x19160c){_0x19160c=_0x19160c||0xc8;return function(_0x4e1fea){if(_0x4e1fea){return _0x123ab4[_0x7393('0x21')](_0x19160c)[_0x7393('0x23')](_0x4e1fea);}};}function respondWithFilteredResult(_0x1fea0a,_0x94ae40){return function(_0x1013aa){if(_0x1013aa){var _0xd8dfae=typeof _0x94ae40['offset']===_0x7393('0x24')&&typeof _0x94ae40['limit']===_0x7393('0x24');var _0x53c524=_0x1013aa[_0x7393('0x25')];var _0x3a04dd=_0xd8dfae?0x0:_0x94ae40[_0x7393('0x26')];var _0x2df555=_0xd8dfae?_0x1013aa[_0x7393('0x25')]:_0x94ae40[_0x7393('0x26')]+_0x94ae40[_0x7393('0x27')];var _0x28ff33;if(_0x2df555>=_0x53c524){_0x2df555=_0x53c524;_0x28ff33=0xc8;}else{_0x28ff33=0xce;}_0x1fea0a[_0x7393('0x21')](_0x28ff33);return _0x1fea0a[_0x7393('0x28')](_0x7393('0x29'),_0x3a04dd+'-'+_0x2df555+'/'+_0x53c524)[_0x7393('0x23')](_0x1013aa);}return null;};}function saveUpdates(_0x55ebdd){return function(_0x5d8798){if(_0x5d8798){return _0x5d8798[_0x7393('0x2a')](_0x55ebdd)['then'](function(_0x3cf95d){return _0x3cf95d;});}return null;};}function removeEntity(_0x489f32){return function(_0x3766b4){if(_0x3766b4){return _0x3766b4['destroy']()[_0x7393('0x2b')](function(){var _0x3fe138=_0x3766b4[_0x7393('0x2c')]({'plain':!![]});var _0xf4a37d=_0x7393('0x2d');return db[_0x7393('0x2e')][_0x7393('0x2f')]({'where':{'type':_0xf4a37d,'resourceId':_0x3fe138['id']}})[_0x7393('0x2b')](function(){return _0x3766b4;});})[_0x7393('0x2b')](function(){_0x489f32[_0x7393('0x21')](0xcc)['end']();});}};}function handleEntityNotFound(_0x17e110){return function(_0x4c957d){if(!_0x4c957d){_0x17e110[_0x7393('0x20')](0x194);}return _0x4c957d;};}function handleError(_0x5312ad,_0x1ffbea){_0x1ffbea=_0x1ffbea||0x1f4;return function(_0x461322){logger[_0x7393('0x1b')](_0x461322[_0x7393('0x30')]);if(_0x461322[_0x7393('0x31')]){delete _0x461322['name'];}_0x5312ad[_0x7393('0x21')](_0x1ffbea)['send'](_0x461322);};}function createInteractionObject(_0x434333,_0x1237ae,_0x3cf8e6,_0x26cb6e){var _0x27f469=require('user-agent-parser');var _0x4c82e6=new _0x27f469();var _0x1b5d87=_0x4c82e6[_0x7393('0x32')](_0x3cf8e6[_0x7393('0x33')])[_0x7393('0x34')]();var _0x54872c=_0x1237ae['customerIp'];if(_0x3cf8e6['cf-connecting-ip']){_0x54872c=_0x3cf8e6[_0x7393('0x35')];}else if(_0x3cf8e6[_0x7393('0x36')]){_0x54872c=_[_0x7393('0x37')](_0x3cf8e6[_0x7393('0x36')][_0x7393('0x38')](','));}return{'ContactId':_0x26cb6e['id'],'ChatWebsiteId':_0x434333,'from':(_0x26cb6e[_0x7393('0x39')]||'')+'\x20'+(_0x26cb6e[_0x7393('0x3a')]||''),'customerIp':_0x54872c,'customerPort':_0x3cf8e6[_0x7393('0x3b')]?_0x3cf8e6[_0x7393('0x3b')]:null,'referer':_0x1237ae[_0x7393('0x3c')],'browserName':_0x1b5d87[_0x7393('0x3d')][_0x7393('0x31')]&&_0x1b5d87[_0x7393('0x3d')][_0x7393('0x3e')]?util[_0x7393('0x3f')](_0x7393('0x40'),_0x1b5d87[_0x7393('0x3d')][_0x7393('0x31')],_0x1b5d87[_0x7393('0x3d')][_0x7393('0x3e')]):_0x7393('0x41'),'browserVersion':_0x1b5d87[_0x7393('0x3d')]['version']||_0x7393('0x41'),'osName':util[_0x7393('0x3f')](_0x7393('0x40'),_0x1b5d87['os'][_0x7393('0x31')],_0x1b5d87['os'][_0x7393('0x3e')]),'osVersion':_0x1b5d87['os'][_0x7393('0x3e')],'deviceModel':_0x1b5d87[_0x7393('0x42')][_0x7393('0x43')]&&_0x1b5d87['device']['vendor']?util[_0x7393('0x3f')]('%s\x20%s\x20%s',_0x1b5d87[_0x7393('0x42')][_0x7393('0x43')],_0x1b5d87[_0x7393('0x42')][_0x7393('0x44')],_0x1b5d87[_0x7393('0x42')][_0x7393('0x45')]):null,'deviceVendor':_0x1b5d87['device'][_0x7393('0x44')],'deviceType':_0x1b5d87[_0x7393('0x42')][_0x7393('0x45')],'formData':JSON[_0x7393('0x1a')](_0x1237ae)};}exports[_0x7393('0x46')]=function(_0x5421a5,_0x5bbc1d){var _0x770871={'include':[{'model':db[_0x7393('0x47')],'as':_0x7393('0x48')}]},_0x51a192={},_0x21b358={'count':0x0,'rows':[]};var _0xaef517=_[_0x7393('0x49')](db[_0x7393('0x4a')][_0x7393('0x4b')],function(_0x285f1a){return{'name':_0x285f1a[_0x7393('0x4c')],'type':_0x285f1a[_0x7393('0x45')][_0x7393('0x4d')]};});_0x51a192[_0x7393('0x43')]=_[_0x7393('0x49')](_0xaef517,_0x7393('0x31'));_0x51a192[_0x7393('0x4e')]=_['keys'](_0x5421a5[_0x7393('0x4e')]);_0x51a192[_0x7393('0x4f')]=_[_0x7393('0x50')](_0x51a192[_0x7393('0x43')],_0x51a192['query']);_0x770871[_0x7393('0x51')]=_[_0x7393('0x50')](_0x51a192[_0x7393('0x43')],qs[_0x7393('0x52')](_0x5421a5[_0x7393('0x4e')][_0x7393('0x52')]));_0x770871[_0x7393('0x51')]=_0x770871[_0x7393('0x51')][_0x7393('0x53')]?_0x770871['attributes']:_0x51a192[_0x7393('0x43')];if(!_0x5421a5[_0x7393('0x4e')][_0x7393('0x54')]('nolimit')){_0x770871[_0x7393('0x27')]=qs[_0x7393('0x27')](_0x5421a5['query'][_0x7393('0x27')]);_0x770871['offset']=qs[_0x7393('0x26')](_0x5421a5['query'][_0x7393('0x26')]);}_0x770871[_0x7393('0x55')]=qs['sort'](_0x5421a5[_0x7393('0x4e')][_0x7393('0x56')]);_0x770871[_0x7393('0x57')]=qs[_0x7393('0x4f')](_['pick'](_0x5421a5['query'],_0x51a192['filters']),_0xaef517);if(_0x5421a5[_0x7393('0x4e')][_0x7393('0x58')]){_0x770871[_0x7393('0x57')]=_[_0x7393('0x59')](_0x770871[_0x7393('0x57')],{'$or':_[_0x7393('0x49')](_0xaef517,function(_0x32ad75){if(_0x32ad75[_0x7393('0x45')]!==_0x7393('0x5a')){var _0x27527f={};_0x27527f[_0x32ad75[_0x7393('0x31')]]={'$like':'%'+_0x5421a5[_0x7393('0x4e')][_0x7393('0x58')]+'%'};return _0x27527f;}})});}_0x770871=_[_0x7393('0x59')]({},_0x770871,_0x5421a5[_0x7393('0x5b')]);var _0x95404={'where':_0x770871['where']};return db['ChatWebsite'][_0x7393('0x25')](_0x95404)['then'](function(_0x5e97cd){_0x21b358['count']=_0x5e97cd;if(_0x5421a5[_0x7393('0x4e')]['includeAll']){_0x770871[_0x7393('0x5c')]=[{'all':!![]}];}return db['ChatWebsite']['findAll'](_0x770871);})[_0x7393('0x2b')](function(_0x5e81db){_0x21b358[_0x7393('0x5d')]=_0x5e81db;return _0x21b358;})['then'](respondWithFilteredResult(_0x5bbc1d,_0x770871))[_0x7393('0x1f')](handleError(_0x5bbc1d,null));};exports[_0x7393('0x5e')]=function(_0x1ebcf5,_0x46556c){var _0x4b325a={'raw':![],'where':{'id':_0x1ebcf5[_0x7393('0x5f')]['id']},'include':[{'model':db[_0x7393('0x47')],'as':'mandatoryDispositionPause'}]},_0x12a7e9={};_0x12a7e9[_0x7393('0x43')]=_['keys'](db['ChatWebsite']['rawAttributes']);_0x12a7e9[_0x7393('0x4e')]=_[_0x7393('0x60')](_0x1ebcf5[_0x7393('0x4e')]);_0x12a7e9[_0x7393('0x4f')]=_['intersection'](_0x12a7e9['model'],_0x12a7e9['query']);_0x4b325a[_0x7393('0x51')]=_['intersection'](_0x12a7e9[_0x7393('0x43')],qs[_0x7393('0x52')](_0x1ebcf5[_0x7393('0x4e')][_0x7393('0x52')]));_0x4b325a[_0x7393('0x51')]=_0x4b325a[_0x7393('0x51')]['length']?_0x4b325a[_0x7393('0x51')]:_0x12a7e9[_0x7393('0x43')];if(_0x1ebcf5['query'][_0x7393('0x61')]){_0x4b325a[_0x7393('0x5c')]=[{'all':!![]}];}_0x4b325a=_[_0x7393('0x59')]({},_0x4b325a,_0x1ebcf5[_0x7393('0x5b')]);return db[_0x7393('0x4a')]['find'](_0x4b325a)['then'](handleEntityNotFound(_0x46556c,null))[_0x7393('0x2b')](respondWithResult(_0x46556c,null))[_0x7393('0x1f')](handleError(_0x46556c,null));};exports[_0x7393('0x62')]=function(_0x577a34,_0x22397a){var _0x30be37=null;_0x577a34['body']['address']['split'](',')['forEach'](_0x4b73a5=>{if(_0x4b73a5[_0x7393('0x63')]()!==''&&!wildcardUtils[_0x7393('0x64')](_0x4b73a5[_0x7393('0x63')]())){_0x30be37=new APIBadRequestError('\x22'+_0x4b73a5[_0x7393('0x63')]()+'\x22\x20is\x20not\x20a\x20valid\x20wildcard\x20expression');}});if(_0x30be37){return handleError(_0x22397a,null)(_0x30be37);}return db['ChatWebsite'][_0x7393('0x62')](_0x577a34[_0x7393('0x65')],{})[_0x7393('0x2b')](function(_0x98aac0){var _0x4eeab5=_0x577a34['user'][_0x7393('0x2c')]({'plain':!![]});if(!_0x4eeab5)throw new Error(_0x7393('0x66'));if(_0x4eeab5[_0x7393('0x67')]==='user'){var _0x1a42c8=_0x98aac0['get']({'plain':!![]});var _0x3250b9='ChatWebsites';return db['UserProfileSection'][_0x7393('0x68')]({'where':{'name':_0x3250b9,'userProfileId':_0x4eeab5[_0x7393('0x69')]},'raw':!![]})[_0x7393('0x2b')](function(_0x1d7b59){if(_0x1d7b59&&_0x1d7b59[_0x7393('0x6a')]===0x0){return db[_0x7393('0x2e')]['create']({'name':_0x1a42c8['name'],'resourceId':_0x1a42c8['id'],'type':_0x1d7b59[_0x7393('0x31')],'sectionId':_0x1d7b59['id']},{})[_0x7393('0x2b')](function(){return _0x98aac0;});}else{return _0x98aac0;}})[_0x7393('0x1f')](function(_0x2231fd){logger['error'](_0x7393('0x6b'),_0x2231fd);throw _0x2231fd;});}return _0x98aac0;})[_0x7393('0x2b')](respondWithResult(_0x22397a,0xc9))[_0x7393('0x1f')](handleError(_0x22397a,null));};exports['update']=function(_0x36fa90,_0x28cf8e){var _0x91c550=null;_0x36fa90[_0x7393('0x65')][_0x7393('0x6c')][_0x7393('0x38')](',')[_0x7393('0x6d')](_0x1267f2=>{if(_0x1267f2[_0x7393('0x63')]()!==''&&!wildcardUtils[_0x7393('0x64')](_0x1267f2['trim']())){_0x91c550=new APIBadRequestError('\x22'+_0x1267f2[_0x7393('0x63')]()+_0x7393('0x6e'));}});if(_0x91c550){return handleError(_0x28cf8e,null)(_0x91c550);}if(_0x36fa90[_0x7393('0x65')]['id']){delete _0x36fa90[_0x7393('0x65')]['id'];}return db['ChatWebsite'][_0x7393('0x68')]({'where':{'id':_0x36fa90[_0x7393('0x5f')]['id']},'include':[{'model':db[_0x7393('0x47')],'as':_0x7393('0x48')}]})[_0x7393('0x2b')](handleEntityNotFound(_0x28cf8e,null))[_0x7393('0x2b')](saveUpdates(_0x36fa90[_0x7393('0x65')],null))[_0x7393('0x2b')](respondWithResult(_0x28cf8e,null))[_0x7393('0x1f')](handleError(_0x28cf8e,null));};exports[_0x7393('0x2f')]=function(_0x52e070,_0x5e4ad6){return db['ChatWebsite'][_0x7393('0x68')]({'where':{'id':_0x52e070[_0x7393('0x5f')]['id']}})['then'](handleEntityNotFound(_0x5e4ad6,null))[_0x7393('0x2b')](removeEntity(_0x5e4ad6,null))[_0x7393('0x1f')](handleError(_0x5e4ad6,null));};exports[_0x7393('0x6f')]=function(_0x1ef720,_0x208ea9){return db[_0x7393('0x4a')]['describe']()[_0x7393('0x2b')](respondWithResult(_0x208ea9,null))[_0x7393('0x1f')](handleError(_0x208ea9,null));};exports[_0x7393('0x70')]=function(_0x3cd310,_0x3899ad){if(_0x3cd310[_0x7393('0x65')]['id']){delete _0x3cd310['body']['id'];}return db[_0x7393('0x4a')][_0x7393('0x68')]({'where':{'id':_0x3cd310[_0x7393('0x5f')]['id']}})['then'](handleEntityNotFound(_0x3899ad,null))[_0x7393('0x2b')](function(_0x1bf363){if(_0x1bf363){_0x3cd310[_0x7393('0x65')][_0x7393('0x71')]=_0x1bf363['id'];return db[_0x7393('0x72')][_0x7393('0x62')](_0x3cd310[_0x7393('0x65')]);}})[_0x7393('0x2b')](respondWithResult(_0x3899ad,null))[_0x7393('0x1f')](handleError(_0x3899ad,null));};exports[_0x7393('0x73')]=function(_0x2df731,_0x331f6e){var _0x1415b7={'raw':![],'where':{}};var _0xf66d72={};var _0x4c92df={'count':0x0,'rows':[]};return db[_0x7393('0x4a')][_0x7393('0x74')]({'where':{'id':_0x2df731[_0x7393('0x5f')]['id']}})['then'](handleEntityNotFound(_0x331f6e,null))[_0x7393('0x2b')](function(_0x5588e7){if(_0x5588e7){_0xf66d72[_0x7393('0x43')]=_[_0x7393('0x60')](db['Disposition'][_0x7393('0x4b')]);_0xf66d72[_0x7393('0x4e')]=_[_0x7393('0x60')](_0x2df731[_0x7393('0x4e')]);_0xf66d72['filters']=_[_0x7393('0x50')](_0xf66d72['model'],_0xf66d72[_0x7393('0x4e')]);_0x1415b7[_0x7393('0x51')]=_[_0x7393('0x50')](_0xf66d72['model'],qs['fields'](_0x2df731['query'][_0x7393('0x52')]));_0x1415b7['attributes']=_0x1415b7['attributes'][_0x7393('0x53')]?_0x1415b7[_0x7393('0x51')]:_0xf66d72[_0x7393('0x43')];if(!_0x2df731[_0x7393('0x4e')]['hasOwnProperty'](_0x7393('0x75'))){_0x1415b7[_0x7393('0x27')]=qs[_0x7393('0x27')](_0x2df731['query'][_0x7393('0x27')]);_0x1415b7['offset']=qs[_0x7393('0x26')](_0x2df731[_0x7393('0x4e')][_0x7393('0x26')]);}_0x1415b7[_0x7393('0x55')]=qs[_0x7393('0x56')](_0x2df731[_0x7393('0x4e')][_0x7393('0x56')]);_0x1415b7['where']=qs['filters'](_[_0x7393('0x76')](_0x2df731[_0x7393('0x4e')],_0xf66d72['filters']));_0x1415b7[_0x7393('0x57')]['ChatWebsiteId']=_0x5588e7['id'];if(_0x2df731['query'][_0x7393('0x58')]){_0x1415b7[_0x7393('0x57')]=_['merge'](_0x1415b7[_0x7393('0x57')],{'$or':_[_0x7393('0x49')](_0x1415b7[_0x7393('0x51')],function(_0xb76ab9){var _0x5e9972={};_0x5e9972[_0xb76ab9]={'$like':'%'+_0x2df731['query'][_0x7393('0x58')]+'%'};return _0x5e9972;})});}_0x1415b7=_[_0x7393('0x59')]({},_0x1415b7,_0x2df731[_0x7393('0x5b')]);return db[_0x7393('0x72')]['count']({'where':_0x1415b7[_0x7393('0x57')]})['then'](function(_0x44c390){_0x4c92df[_0x7393('0x25')]=_0x44c390;if(_0x2df731[_0x7393('0x4e')][_0x7393('0x61')]){_0x1415b7[_0x7393('0x5c')]=[{'all':!![]}];}return db[_0x7393('0x72')]['findAll'](_0x1415b7);})[_0x7393('0x2b')](function(_0x1fe9b6){_0x4c92df[_0x7393('0x5d')]=_0x1fe9b6;return _0x4c92df;});}})[_0x7393('0x2b')](respondWithFilteredResult(_0x331f6e,_0x1415b7))[_0x7393('0x1f')](handleError(_0x331f6e,null));};exports[_0x7393('0x77')]=function(_0x4f2ae9,_0x47e69f){return db[_0x7393('0x4a')][_0x7393('0x68')]({'where':{'id':_0x4f2ae9[_0x7393('0x5f')]['id']}})['then'](handleEntityNotFound(_0x47e69f,null))[_0x7393('0x2b')](function(_0x1c5abb){if(_0x1c5abb){return _0x1c5abb[_0x7393('0x77')](_0x4f2ae9['query'][_0x7393('0x78')]);}})[_0x7393('0x2b')](respondWithStatusCode(_0x47e69f,null))[_0x7393('0x1f')](handleError(_0x47e69f,null));};exports['addAnswer']=function(_0x13fd17,_0x13aca1){if(_0x13fd17[_0x7393('0x65')]['id']){delete _0x13fd17[_0x7393('0x65')]['id'];}return db['ChatWebsite'][_0x7393('0x68')]({'where':{'id':_0x13fd17[_0x7393('0x5f')]['id']}})[_0x7393('0x2b')](handleEntityNotFound(_0x13aca1,null))[_0x7393('0x2b')](function(_0x3c9f8a){if(_0x3c9f8a){_0x13fd17[_0x7393('0x65')][_0x7393('0x71')]=_0x3c9f8a['id'];return db['CannedAnswer'][_0x7393('0x62')](_0x13fd17[_0x7393('0x65')]);}})[_0x7393('0x2b')](respondWithResult(_0x13aca1,null))['catch'](handleError(_0x13aca1,null));};exports['getAnswers']=function(_0x34bff8,_0x4298df){var _0xd011bb={'raw':![],'where':{}};var _0x5918a3={};var _0x3507ea={'count':0x0,'rows':[]};return db[_0x7393('0x4a')][_0x7393('0x74')]({'where':{'id':_0x34bff8[_0x7393('0x5f')]['id']}})[_0x7393('0x2b')](handleEntityNotFound(_0x4298df,null))['then'](function(_0x6dcfdf){if(_0x6dcfdf){_0x5918a3[_0x7393('0x43')]=_['keys'](db[_0x7393('0x79')][_0x7393('0x4b')]);_0x5918a3[_0x7393('0x4e')]=_[_0x7393('0x60')](_0x34bff8[_0x7393('0x4e')]);_0x5918a3[_0x7393('0x4f')]=_['intersection'](_0x5918a3[_0x7393('0x43')],_0x5918a3[_0x7393('0x4e')]);_0xd011bb['attributes']=_[_0x7393('0x50')](_0x5918a3[_0x7393('0x43')],qs[_0x7393('0x52')](_0x34bff8[_0x7393('0x4e')][_0x7393('0x52')]));_0xd011bb[_0x7393('0x51')]=_0xd011bb[_0x7393('0x51')][_0x7393('0x53')]?_0xd011bb[_0x7393('0x51')]:_0x5918a3['model'];if(!_0x34bff8[_0x7393('0x4e')]['hasOwnProperty'](_0x7393('0x75'))){_0xd011bb[_0x7393('0x27')]=qs[_0x7393('0x27')](_0x34bff8['query'][_0x7393('0x27')]);_0xd011bb[_0x7393('0x26')]=qs[_0x7393('0x26')](_0x34bff8[_0x7393('0x4e')][_0x7393('0x26')]);}_0xd011bb['order']=qs[_0x7393('0x56')](_0x34bff8[_0x7393('0x4e')][_0x7393('0x56')]);_0xd011bb['where']=qs[_0x7393('0x4f')](_[_0x7393('0x76')](_0x34bff8[_0x7393('0x4e')],_0x5918a3[_0x7393('0x4f')]));_0xd011bb[_0x7393('0x57')][_0x7393('0x71')]=_0x6dcfdf['id'];if(_0x34bff8['query']['filter']){_0xd011bb['where']=_[_0x7393('0x59')](_0xd011bb[_0x7393('0x57')],{'$or':_[_0x7393('0x49')](_0xd011bb[_0x7393('0x51')],function(_0x20d301){var _0x43ef6e={};_0x43ef6e[_0x20d301]={'$like':'%'+_0x34bff8[_0x7393('0x4e')]['filter']+'%'};return _0x43ef6e;})});}_0xd011bb=_['merge']({},_0xd011bb,_0x34bff8['options']);return db['CannedAnswer'][_0x7393('0x25')]({'where':_0xd011bb['where']})[_0x7393('0x2b')](function(_0x324eca){_0x3507ea[_0x7393('0x25')]=_0x324eca;if(_0x34bff8['query'][_0x7393('0x61')]){_0xd011bb[_0x7393('0x5c')]=[{'all':!![]}];}return db[_0x7393('0x79')][_0x7393('0x7a')](_0xd011bb);})[_0x7393('0x2b')](function(_0x5e2312){_0x3507ea[_0x7393('0x5d')]=_0x5e2312;return _0x3507ea;});}})['then'](respondWithFilteredResult(_0x4298df,_0xd011bb))[_0x7393('0x1f')](handleError(_0x4298df,null));};exports[_0x7393('0x7b')]=function(_0x351ba9,_0x2860ec){return db[_0x7393('0x4a')][_0x7393('0x68')]({'where':{'id':_0x351ba9['params']['id']}})['then'](handleEntityNotFound(_0x2860ec,null))[_0x7393('0x2b')](function(_0x2a6a91){if(_0x2a6a91){return _0x2a6a91[_0x7393('0x7b')](_0x351ba9['query']['ids']);}})[_0x7393('0x2b')](respondWithStatusCode(_0x2860ec,null))[_0x7393('0x1f')](handleError(_0x2860ec,null));};exports[_0x7393('0x7c')]=function(_0x4370ac,_0x29243c){_0x4370ac['body'][_0x7393('0x7d')]=_0x4370ac[_0x7393('0x7e')][_0x7393('0x7f')];return db[_0x7393('0x4a')][_0x7393('0x68')]({'where':{'id':_0x4370ac['params']['id']}})['then'](handleEntityNotFound(_0x29243c,null))[_0x7393('0x2b')](saveUpdates(_0x4370ac['body'],null))[_0x7393('0x2b')](respondWithResult(_0x29243c,null))[_0x7393('0x1f')](handleError(_0x29243c,null));};exports[_0x7393('0x80')]=function(_0x38fce1,_0x29add7){_0x38fce1[_0x7393('0x65')]['agentAvatar']=_0x38fce1[_0x7393('0x7e')]['filename'];return db[_0x7393('0x4a')]['find']({'where':{'id':_0x38fce1['params']['id']}})[_0x7393('0x2b')](handleEntityNotFound(_0x29add7,null))['then'](saveUpdates(_0x38fce1[_0x7393('0x65')],null))['then'](respondWithResult(_0x29add7,null))['catch'](handleError(_0x29add7,null));};exports[_0x7393('0x81')]=function(_0x5aa8ad,_0x5239d2){_0x5aa8ad[_0x7393('0x65')]['customerAvatar']=_0x5aa8ad[_0x7393('0x7e')][_0x7393('0x7f')];return db['ChatWebsite'][_0x7393('0x68')]({'where':{'id':_0x5aa8ad[_0x7393('0x5f')]['id']}})[_0x7393('0x2b')](handleEntityNotFound(_0x5239d2,null))[_0x7393('0x2b')](saveUpdates(_0x5aa8ad[_0x7393('0x65')],null))[_0x7393('0x2b')](respondWithResult(_0x5239d2,null))[_0x7393('0x1f')](handleError(_0x5239d2,null));};exports[_0x7393('0x82')]=function(_0x12a1c3,_0xae034b){_0x12a1c3['body'][_0x7393('0x83')]=_0x12a1c3[_0x7393('0x7e')][_0x7393('0x7f')];return db['ChatWebsite'][_0x7393('0x68')]({'where':{'id':_0x12a1c3[_0x7393('0x5f')]['id']}})[_0x7393('0x2b')](handleEntityNotFound(_0xae034b,null))[_0x7393('0x2b')](saveUpdates(_0x12a1c3['body'],null))[_0x7393('0x2b')](respondWithResult(_0xae034b,null))[_0x7393('0x1f')](handleError(_0xae034b,null));};exports[_0x7393('0x84')]=function(_0x2797a0,_0x30ba26){var _0xbe263=path['join'](config[_0x7393('0x85')],_0x7393('0x86'));var _0x815e65={'where':{'id':_0x2797a0['params']['id']},'attributes':['id',_0x7393('0x7d')],'raw':!![]};var _0x3979d3=![];return require('../../config/license/util')['getLicense']()[_0x7393('0x2b')](function(_0x5e82ef){if(_0x5e82ef){_0x3979d3=_0x5e82ef['custom'];}})[_0x7393('0x2b')](function(){return db[_0x7393('0x4a')][_0x7393('0x68')](_0x815e65);})[_0x7393('0x2b')](handleEntityNotFound(_0x30ba26,null))['then'](function(_0x4eba91){if(_0x4eba91){if(!_[_0x7393('0x87')](_0x4eba91[_0x7393('0x7d')])){if(fs[_0x7393('0x88')](path['join'](config[_0x7393('0x85')],_0x7393('0x89'),_0x4eba91[_0x7393('0x7d')]))&&_0x3979d3){_0xbe263=path[_0x7393('0x8a')](config['root'],_0x7393('0x89'),_0x4eba91[_0x7393('0x7d')]);}}return _0x30ba26['download'](_0xbe263);}})['catch'](handleError(_0x30ba26,null));};exports[_0x7393('0x8b')]=function(_0x2df2cd,_0x15f81e){var _0x2f3e8d=path[_0x7393('0x8a')](config[_0x7393('0x85')],'server/files/images/avatars/default_avatar.png');var _0x2ff51a={'where':{'id':_0x2df2cd[_0x7393('0x5f')]['id']},'attributes':['id',_0x7393('0x8c')],'raw':!![]};return db[_0x7393('0x4a')][_0x7393('0x68')](_0x2ff51a)['then'](handleEntityNotFound(_0x15f81e,null))[_0x7393('0x2b')](function(_0x2e98c0){if(_0x2e98c0){if(!_[_0x7393('0x87')](_0x2e98c0[_0x7393('0x8c')])){if(fs[_0x7393('0x88')](path['join'](config[_0x7393('0x85')],_0x7393('0x8d'),_0x2e98c0[_0x7393('0x8c')]))){_0x2f3e8d=path[_0x7393('0x8a')](config[_0x7393('0x85')],'server/files/images/avatars/',_0x2e98c0[_0x7393('0x8c')]);}}return _0x15f81e[_0x7393('0x8e')](_0x2f3e8d);}})[_0x7393('0x1f')](handleError(_0x15f81e,null));};exports['getCustomerAvatar']=function(_0x3c6fb5,_0x381a94){var _0x6eadf9=path[_0x7393('0x8a')](config[_0x7393('0x85')],_0x7393('0x8f'));var _0x115163={'where':{'id':_0x3c6fb5['params']['id']},'attributes':['id','customerAvatar',_0x7393('0x90')],'raw':!![]};return db[_0x7393('0x4a')][_0x7393('0x68')](_0x115163)['then'](handleEntityNotFound(_0x381a94,null))['then'](function(_0x5cf9cf){if(_0x5cf9cf){if(!_[_0x7393('0x87')](_0x5cf9cf[_0x7393('0x91')])){if(fs['existsSync'](path['join'](config[_0x7393('0x85')],_0x7393('0x8d'),_0x5cf9cf[_0x7393('0x91')]))&&_0x5cf9cf['showCustomerAvatar']){_0x6eadf9=path[_0x7393('0x8a')](config[_0x7393('0x85')],_0x7393('0x8d'),_0x5cf9cf[_0x7393('0x91')]);}}return _0x381a94[_0x7393('0x8e')](_0x6eadf9);}})['catch'](handleError(_0x381a94,null));};exports[_0x7393('0x92')]=function(_0x219060,_0x144cfd){var _0x4206cb=path['join'](config[_0x7393('0x85')],_0x7393('0x93'));var _0x6f920c={'where':{'id':_0x219060[_0x7393('0x5f')]['id']},'attributes':['id',_0x7393('0x83')],'raw':!![]};return db[_0x7393('0x4a')]['find'](_0x6f920c)[_0x7393('0x2b')](handleEntityNotFound(_0x144cfd,null))[_0x7393('0x2b')](function(_0x154159){if(_0x154159){if(!_[_0x7393('0x87')](_0x154159[_0x7393('0x83')])){if(fs['existsSync'](path[_0x7393('0x8a')](config['root'],_0x7393('0x8d'),_0x154159[_0x7393('0x83')]))){_0x4206cb=path[_0x7393('0x8a')](config[_0x7393('0x85')],_0x7393('0x8d'),_0x154159[_0x7393('0x83')]);}}return _0x144cfd['download'](_0x4206cb);}})['catch'](handleError(_0x144cfd,null));};function checkWebsiteInterval(_0x101c04){var _0x5ad4f9=_0x101c04[_0x7393('0x94')];if(!_0x5ad4f9){return Promise[_0x7393('0x95')](_0x101c04);}var _0x5171f8=_0x101c04[_0x7393('0x96')]||undefined;return _0x5ad4f9[_0x7393('0x97')](_0x5171f8)[_0x7393('0x2b')](function(_0x119a72){if(!_0x119a72){throw new APIOutOfIntervalError();}return _0x101c04;});}exports[_0x7393('0x98')]=function(_0x58bd7a,_0x46abac){var _0x4579be={'body':_0x58bd7a[_0x7393('0x65')],'channel':_0x7393('0x99')};var _0x68f09d=[];var _0x5c76a0=[];var _0x37fc8b={};var _0x4c931f=![];if(_0x58bd7a[_0x7393('0x65')]['id']){delete _0x58bd7a[_0x7393('0x65')]['id'];}if(_[_0x7393('0x87')](_0x58bd7a[_0x7393('0x65')]['from'])){throw new APIBadRequestError(_0x7393('0x9a'));}if(_[_0x7393('0x87')](_0x58bd7a[_0x7393('0x65')]['mapKey'])){throw new APIBadRequestError(_0x7393('0x9b'));}if(_[_0x7393('0x9c')](_0x58bd7a['body'][_0x7393('0x65')])){throw new APIBadRequestError(_0x7393('0x9d'));}var _0x42b1ba=_0x58bd7a[_0x7393('0x65')][_0x7393('0x9e')]&&_0x58bd7a[_0x7393('0x65')][_0x7393('0x3c')];return db['CmContact'][_0x7393('0x6f')]()['then'](function(_0xbf0cf){if(!_0xbf0cf){throw new Error(_0x7393('0x9f'));}_0x68f09d=Object[_0x7393('0x60')](_0xbf0cf)[_0x7393('0x58')](function(_0x1359a7){return![_0x7393('0xa0'),_0x7393('0xa1')][_0x7393('0xa2')](_0x1359a7);});_0x5c76a0=Object['keys'](_0xbf0cf)[_0x7393('0x58')](function(_0xa17ce7){return![_0x7393('0xa0'),_0x7393('0xa1'),_0x7393('0xa3'),_0x7393('0xa4')][_0x7393('0xa2')](_0xa17ce7);});if(!_[_0x7393('0xa2')](_0x5c76a0,_0x58bd7a['body'][_0x7393('0xa5')])){throw new APIBadRequestError('Invalid\x20MapKey\x20parameter.\x20Allowed\x20values:\x20'+_0x5c76a0[_0x7393('0x8a')](',\x20'));}_0x37fc8b[_0x58bd7a[_0x7393('0x65')][_0x7393('0xa5')]]=_0x58bd7a['body'][_0x7393('0xa6')];})[_0x7393('0x2b')](function(){return db['ChatWebsite']['find']({'where':{'id':_0x58bd7a['params']['id']},'include':[{'model':db[_0x7393('0xa7')],'as':'List','include':[{'model':db[_0x7393('0xa8')],'as':_0x7393('0xa9'),'where':_0x37fc8b,'limit':0x1,'order':[[_0x7393('0xa1'),'DESC']]}]},{'model':db[_0x7393('0xaa')],'as':'Applications'},{'model':db[_0x7393('0x94')],'as':_0x7393('0x94'),'include':[{'model':db['Interval'],'as':_0x7393('0xab'),'attributes':['id','interval'],'raw':!![]}]}]});})[_0x7393('0x2b')](function(_0x22d9c6){if(!_0x22d9c6){throw new APINotFoundError(util['format'](_0x7393('0xac'),_0x58bd7a[_0x7393('0x5f')]['id']));}if(_0x42b1ba){return checkWebsiteInterval(_0x22d9c6);}return _0x22d9c6;})[_0x7393('0x2b')](function(_0x18b47b){_0x4579be['account']=_0x18b47b;_0x4579be[_0x7393('0xad')]=_[_0x7393('0xae')](_0x18b47b['Applications'],[_0x7393('0xaf')],['asc']);if(_0x4579be[_0x7393('0xb0')][_0x7393('0xb1')]){delete _0x4579be[_0x7393('0xb0')][_0x7393('0xb1')];}_0x4579be['list']=_0x18b47b[_0x7393('0xb2')]||{'id':_0x18b47b[_0x7393('0xa4')]};if(_0x4579be[_0x7393('0xb3')]&&_0x4579be['list'][_0x7393('0xa9')]['length']){return _0x4579be[_0x7393('0xb3')][_0x7393('0xa9')][0x0];}var _0x40fc04=_[_0x7393('0xf')](_0x58bd7a[_0x7393('0x65')],{'firstName':_0x58bd7a['body']['from'],'ListId':_0x18b47b[_0x7393('0xa4')]});_0x40fc04[_0x58bd7a['body'][_0x7393('0xa5')]]=_0x58bd7a['body']['from'];return db[_0x7393('0xa8')][_0x7393('0x62')](_0x40fc04,{'fields':_0x68f09d,'raw':!![]});})[_0x7393('0x2b')](function(_0x2dffbb){_0x4579be[_0x7393('0xb4')]=_0x2dffbb;var _0x312654=createInteractionObject(_0x58bd7a['params']['id'],_0x58bd7a[_0x7393('0x65')],_0x58bd7a[_0x7393('0xb5')],_0x2dffbb);var _0x3c2ac8={'ChatWebsiteId':_0x58bd7a[_0x7393('0x5f')]['id']};if(_0x58bd7a[_0x7393('0x65')][_0x7393('0xb6')]){_0x3c2ac8[_0x7393('0xb6')]=_0x58bd7a['body']['threadId'];_0x3c2ac8[_0x7393('0xb7')]=![];return db[_0x7393('0xb8')][_0x7393('0x68')]({'where':_0x3c2ac8})[_0x7393('0x2b')](function(_0x6d491d){var _0x23f06d=_0x58bd7a[_0x7393('0x65')]['customerIp']&&_0x58bd7a[_0x7393('0x65')][_0x7393('0x3c')];if(_0x6d491d){_0x4c931f=!![];return _0x6d491d;}else if(!_0x23f06d&&_0x6d491d&&_0x6d491d[_0x7393('0xb7')]){throw new APIConflictError(_0x7393('0xb9'));}_0x312654[_0x7393('0xb6')]=_0x58bd7a[_0x7393('0x65')][_0x7393('0xb6')];_0x312654[_0x7393('0xba')]=_0x58bd7a[_0x7393('0x65')][_0x7393('0xba')];return db[_0x7393('0xb8')][_0x7393('0x62')](_0x312654);});}_0x3c2ac8[_0x7393('0xbb')]=_0x2dffbb['id'];if(_0x58bd7a[_0x7393('0x65')][_0x7393('0xbc')]&&_0x58bd7a[_0x7393('0x65')][_0x7393('0xbc')]['id']){_0x3c2ac8['id']=_0x58bd7a['body'][_0x7393('0xbc')]['id'];return db['ChatInteraction'][_0x7393('0x68')]({'where':_0x3c2ac8})[_0x7393('0x2b')](function(_0x4899e5){var _0x222918=_0x58bd7a[_0x7393('0x65')]['customerIp']&&_0x58bd7a[_0x7393('0x65')]['referer'];if(!_0x222918&&_0x4899e5&&_0x4899e5[_0x7393('0xb7')]){throw new APIConflictError(_0x7393('0xb9'));}else if(_0x4899e5){_0x4c931f=!![];return _0x4899e5;}else{return db[_0x7393('0xb8')]['create'](_0x312654);}});}return db[_0x7393('0xb8')][_0x7393('0x62')](_0x312654);})[_0x7393('0x2b')](function(_0x1734a1){if(!_0x4c931f){return _0x1734a1;}var _0x415063={'from':(_0x4579be['contact'][_0x7393('0x39')]||'')+'\x20'+(_0x4579be[_0x7393('0xb4')]['lastName']||'')};if(_0x58bd7a[_0x7393('0x65')][_0x7393('0xb6')]&&_0x58bd7a['body'][_0x7393('0xbd')]&&_0x58bd7a[_0x7393('0x65')][_0x7393('0xb6')]!=_0x58bd7a[_0x7393('0x65')]['messageId']){_0x415063['threadId']=_0x58bd7a['body'][_0x7393('0xbd')];}return _0x1734a1['update'](_0x415063);})[_0x7393('0x2b')](function(_0x471a64){_0x4579be['interaction']=_0x471a64[_0x7393('0x2c')]({'plain':!![]});_0x4579be[_0x7393('0xbc')][_0x7393('0xbe')]=!_0x4c931f;if(_0x4579be[_0x7393('0xbc')][_0x7393('0xbe')]){if(_0x4579be[_0x7393('0xb0')][_0x7393('0xbf')]){_0x4579be[_0x7393('0xad')][_0x7393('0xc0')]({'id':0x0,'priority':_0x4579be[_0x7393('0xad')][_0x7393('0x53')]+0x1,'app':_0x7393('0xc1'),'appdata':_0x7393('0xc2'),'interval':_0x7393('0xc3')});}}return db['ChatMessage'][_0x7393('0x62')]({'body':_0x58bd7a['body']['body'],'ChatWebsiteId':_0x58bd7a[_0x7393('0x5f')]['id'],'ChatInteractionId':_0x471a64['id'],'direction':'in','ContactId':_0x4579be[_0x7393('0xb4')]['id'],'AttachmentId':_0x58bd7a[_0x7393('0x65')][_0x7393('0xc4')]});})[_0x7393('0x2b')](function(_0xd0502c){_0x4579be[_0x7393('0x1d')]=_0xd0502c;if(!_0x4579be[_0x7393('0xbc')][_0x7393('0xc5')]){return;}return db[_0x7393('0xc6')][_0x7393('0x68')]({'attributes':['id',_0x7393('0x31')],'where':{'id':_0x4579be[_0x7393('0xbc')][_0x7393('0xc5')]}});})[_0x7393('0x2b')](function(_0x2221b8){if(_0x2221b8){_0x4579be[_0x7393('0xad')][_0x7393('0xc7')]({'id':0x0,'priority':0x0,'app':_0x7393('0xc8'),'appdata':_0x2221b8[_0x7393('0x31')]+','+(_0x4579be[_0x7393('0xb0')]['waitForTheAssignedAgent']||0xa),'interval':'*,*,*,*'});_0x4579be[_0x7393('0xc9')]=!![];}if(!_0x4579be[_0x7393('0xbc')][_0x7393('0xca')]){return;}return db[_0x7393('0xcb')][_0x7393('0x68')]({'attributes':['id',_0x7393('0x31')],'where':{'id':_0x4579be[_0x7393('0xbc')]['queueId']}});})['then'](function(_0x1e9b0b){if(_0x1e9b0b){_0x4579be[_0x7393('0xad')][_0x7393('0xc7')]({'id':0x0,'priority':0x1,'app':_0x7393('0xcc'),'appdata':_0x1e9b0b['name']+','+(_0x4579be['account'][_0x7393('0xcd')]||0x12c),'interval':'*,*,*,*'});}return respondWithRpcPromise(_0x7393('0xce'),'startRouting',_0x4579be);})['then'](function(_0x121410){respondWithRpcPromise('EventManager',_0x7393('0xcf'),{'event':_0x7393('0x98'),'message':_0x121410},client9002);return _0x121410;})[_0x7393('0x2b')](respondWithResult(_0x46abac,null))[_0x7393('0x1f')](APIHandleError(_0x46abac));};exports[_0x7393('0xd0')]=function(_0x295cd9,_0x42c4ff){var _0x3d3500,_0x331711,_0x39caa6;var _0x4d5829=[];var _0x1be05c={};var _0x3d03a2=_0x295cd9[_0x7393('0xd1')]||[];var _0x3dde49=[];var _0x179a7e;return db[_0x7393('0xa8')][_0x7393('0x6f')]()['then'](function(_0x1c138f){if(!_0x1c138f){throw new db[(_0x7393('0xd2'))]['ValidationError'](_0x7393('0xd3'));}_0x4d5829=_[_0x7393('0xd4')](_[_0x7393('0x60')](_0x1c138f),[_0x7393('0xa0'),_0x7393('0xa1'),_0x7393('0xa3'),'ListId']);if(_0x295cd9[_0x7393('0x65')]['id']){delete _0x295cd9[_0x7393('0x65')]['id'];}if(_[_0x7393('0x87')](_0x295cd9[_0x7393('0x65')][_0x7393('0xa6')])){throw _0x42c4ff['status'](0x1f4)[_0x7393('0xd5')](new db[(_0x7393('0xd2'))]['ValidationError'](_0x7393('0xd6')));}if(_[_0x7393('0x87')](_0x295cd9[_0x7393('0x65')][_0x7393('0x65')])||_0x295cd9['body'][_0x7393('0x65')]===''){throw _0x42c4ff['status'](0x1f4)[_0x7393('0xd5')](new db[(_0x7393('0xd2'))][(_0x7393('0xd7'))](_0x7393('0xd8')));}if(_[_0x7393('0x87')](_0x295cd9[_0x7393('0x65')][_0x7393('0xd9')])){throw _0x42c4ff[_0x7393('0x21')](0x1f4)[_0x7393('0xd5')](new db[(_0x7393('0xd2'))][(_0x7393('0xd7'))](_0x7393('0xda')+_0x4d5829));}if(!_[_0x7393('0xa2')](_0x4d5829,_0x295cd9[_0x7393('0x65')][_0x7393('0xd9')])){throw _0x42c4ff[_0x7393('0x21')](0x1f4)[_0x7393('0xd5')](new db[(_0x7393('0xd2'))][(_0x7393('0xd7'))](_0x7393('0xdb')+_0x4d5829));}_0x1be05c[_0x295cd9[_0x7393('0x65')][_0x7393('0xd9')]]=_0x295cd9[_0x7393('0x65')][_0x7393('0xa6')];})[_0x7393('0x2b')](function(){return db[_0x7393('0x4a')][_0x7393('0x68')]({'where':{'id':_0x295cd9['params']['id']},'include':[{'model':db[_0x7393('0xa7')],'as':_0x7393('0xb2')},{'model':db[_0x7393('0xdc')],'as':_0x7393('0xdc')}]});})[_0x7393('0x2b')](handleEntityNotFound(_0x42c4ff,null))[_0x7393('0x2b')](function(_0x10526d){if(_0x10526d&&_0x10526d[_0x7393('0xb2')]){_0x331711=_0x10526d;var _0x4a1fe1=_[_0x7393('0xf')](_0x295cd9[_0x7393('0x65')],{'firstName':_0x295cd9[_0x7393('0x65')][_0x7393('0xa6')],'phone':_0x295cd9['body']['from'],'ListId':_0x10526d[_0x7393('0xa4')]});_0x4a1fe1[_0x295cd9[_0x7393('0x65')]['mapKeyOffline']]=_0x295cd9[_0x7393('0x65')]['from'];return db[_0x7393('0xa8')][_0x7393('0xdd')]({'where':_0x1be05c,'defaults':_0x4a1fe1});}})['spread'](function(_0x3f238d){if(_0x3f238d){_0x39caa6=_0x3f238d;var _0x249698=fs[_0x7393('0xde')](path[_0x7393('0x8a')](config[_0x7393('0x85')],_0x7393('0xdf')),_0x7393('0xe0'));var _0x185a29=ejs[_0x7393('0xe1')](_0x249698,{'body':_[_0x7393('0xe2')](_0x295cd9[_0x7393('0x65')]['body']),'bodyTitle':_0x331711[_0x7393('0xe3')]});return db[_0x7393('0xe4')]['create']({'body':_0x185a29,'plainBody':htmlToText[_0x7393('0xe5')](_0x185a29),'ContactId':_0x3f238d['id'],'ChatWebsiteId':_0x331711['id']});}})[_0x7393('0x2b')](function(_0x2b24eb){_0x179a7e=_0x2b24eb;if(_0x3d03a2[_0x7393('0x53')]){var _0x126a19=_0x3d03a2[_0x7393('0x49')](function(_0x657f32){return{'name':_0x657f32[_0x7393('0xe6')],'basename':_0x657f32['filename'],'type':_0x657f32[_0x7393('0xe7')],'ChatOfflineMessageId':_0x2b24eb['id']};});_0x3dde49=_0x126a19[_0x7393('0x49')](_0x1fb961=>{var _0x5eb01e={'filename':_0x1fb961[_0x7393('0x31')],'path':path[_0x7393('0x8a')](config[_0x7393('0x85')],_0x7393('0xe8'),_0x7393('0xd1'),_0x7393('0xe9'),_0x7393('0xea'),_0x1fb961[_0x7393('0xeb')])};return _0x5eb01e;});if(!_0x331711[_0x7393('0xec')]){return db['sequelize'][_0x7393('0xed')](function(_0xc51685){return db[_0x7393('0xee')][_0x7393('0xef')](_0x126a19,{'transaction':_0xc51685});});}}})[_0x7393('0x2b')](function(){if(_0x179a7e){_0x3d3500=_0x179a7e;return db[_0x7393('0xdc')][_0x7393('0x74')]({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':_0x7393('0xf0'),'raw':!![],'include':[{'model':db['CloudProvider'],'as':_0x7393('0xf1'),'raw':!![]}]}]});}})[_0x7393('0x2b')](function(_0x39bee3){if(_0x39bee3&&_0x39bee3[_0x7393('0xf0')]&&_0x331711['forwardOffline']&&_0x331711[_0x7393('0xf2')]){var _0x3e3a4f=_0x39bee3[_0x7393('0xf3')]();return respondWithRpcPromise(_0x7393('0xf4'),'sendMail',{'account':_0x3e3a4f,'message':{'from':util[_0x7393('0x3f')]('\x22%s\x22\x20<%s>',_0x39bee3[_0x7393('0x31')],_0x39bee3[_0x7393('0xf5')]||_0x39bee3[_0x7393('0xf0')]['user']),'to':_0x331711[_0x7393('0xf2')],'subject':_0x331711[_0x7393('0xf6')],'html':_0x3d3500['body'],'attachments':_0x3dde49}},client9003)[_0x7393('0x2b')](function(){return _0x3d3500;})['catch'](function(_0x4d6da1){logger[_0x7393('0x1b')](_0x4d6da1);});}})[_0x7393('0x2b')](function(){if(_0x331711&&_0x331711[_0x7393('0xec')]&&_0x331711[_0x7393('0xf7')]){var _0x34f0b2=[];if(_0x3d03a2[_0x7393('0x53')]){_0x34f0b2=_0x3d03a2[_0x7393('0x49')](function(_0x3d5873){return{'name':_0x3d5873['originalname'],'basename':_0x3d5873['filename'],'type':_0x3d5873[_0x7393('0xe7')],'ChatOfflineMessageId':_0x179a7e['id']};});}var _0x2e90ad;if(!_['isNil'](_0x331711[_0x7393('0xf8')])){var _0x43fd98=_[_0x7393('0x49')](_0x295cd9['body'],function(_0x2d7051){return _0x2d7051;});var _0x2b52f8=_['toPairsIn'](_0x43fd98)[0x0];var _0x35efd4=_['mapValues'](_0x2b52f8,function(_0x114b45){return _0x114b45;});_0x2e90ad=_0x35efd4[0x1][_0x331711[_0x7393('0xf8')]];}var _0x56fa26={'from':_0x39caa6[_0x7393('0xf5')],'firstName':_0x39caa6[_0x7393('0x39')],'lastName':_0x39caa6[_0x7393('0x3a')],'mapKey':_0x7393('0xf5'),'message':{'from':_0x39caa6['email'],'to':_0x331711[_0x7393('0xdc')][_0x7393('0xf5')],'cc':'','subject':_[_0x7393('0x87')](_0x2e90ad)?_0x331711['offlineMessageSubject']:_0x2e90ad,'messageId':'','sentAt':new Date(),'attach':_0x34f0b2[_0x7393('0x53')],'attachments':_0x34f0b2,'originChannel':_0x7393('0xf9'),'ChatWebsiteId':_0x331711['id'],'ChatOfflineMessageId':_0x3d3500['id'],'originTo':_0x331711['MailAccount']['email']},'body':_0x3d3500[_0x7393('0x65')]};var _0x27f10c={'account':{'id':_0x331711[_0x7393('0xf7')]},'body':_0x56fa26,'log':_0x7393('0xfa')};return respondWithRpcPromise(_0x7393('0xfa'),_0x7393('0xfb'),_0x27f10c,client9001)[_0x7393('0x2b')](function(){return _0x3d3500;})[_0x7393('0x1f')](function(_0x220cd2){logger[_0x7393('0x1b')](_0x220cd2);});}return;})[_0x7393('0x2b')](function(){if(_0x3d3500){return _0x3d3500;}})['then'](respondWithResult(_0x42c4ff,null))[_0x7393('0x1f')](function(){for(var _0x9b2e6 of _0x3d03a2){var _0x2805ee=path[_0x7393('0x8a')](config['root'],_0x7393('0xe8'),_0x7393('0xd1'),_0x7393('0xe9'),_0x7393('0xea'),_0x9b2e6[_0x7393('0x7f')]);fs_extra[_0x7393('0xfc')](_0x2805ee)[_0x7393('0x1f')](function(_0x195b19){logger[_0x7393('0x1b')](_0x7393('0xfd'),_0x2805ee,_0x195b19);});}});};exports['addInteraction']=function(_0x254ebb,_0xdc3e9a){return db[_0x7393('0xb8')][_0x7393('0x68')]({'where':{'id':_0x254ebb[_0x7393('0x5f')]['id']}})[_0x7393('0x2b')](handleEntityNotFound(_0xdc3e9a,null))[_0x7393('0x2b')](function(_0x50ee3b){if(_0x50ee3b){return _0x50ee3b[_0x7393('0xfe')](_0x254ebb[_0x7393('0x65')]['ids'],_[_0x7393('0xff')](_0x254ebb['body'],[_0x7393('0x78'),'id'])||{});}})[_0x7393('0x2b')](respondWithResult(_0xdc3e9a,null))['catch'](handleError(_0xdc3e9a,null));};exports['getInteractions']=function(_0x5b9507,_0x233970){var _0x1db812={'raw':![],'where':{}};var _0xd2c071={};var _0x19c60a={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x5b9507['params']['id']}})['then'](handleEntityNotFound(_0x233970,null))[_0x7393('0x2b')](function(_0x3aa2cb){if(_0x3aa2cb){_0xd2c071[_0x7393('0x43')]=_['keys'](db['ChatInteraction'][_0x7393('0x4b')]);_0xd2c071['query']=_['keys'](_0x5b9507['query']);_0xd2c071[_0x7393('0x4f')]=_[_0x7393('0x50')](_0xd2c071[_0x7393('0x43')],_0xd2c071[_0x7393('0x4e')]);_0x1db812[_0x7393('0x51')]=_[_0x7393('0x50')](_0xd2c071[_0x7393('0x43')],qs['fields'](_0x5b9507['query']['fields']));_0x1db812[_0x7393('0x51')]=_0x1db812[_0x7393('0x51')][_0x7393('0x53')]?_0x1db812['attributes']:_0xd2c071[_0x7393('0x43')];if(!_0x5b9507[_0x7393('0x4e')]['hasOwnProperty']('nolimit')){_0x1db812['limit']=qs[_0x7393('0x27')](_0x5b9507[_0x7393('0x4e')][_0x7393('0x27')]);_0x1db812['offset']=qs['offset'](_0x5b9507[_0x7393('0x4e')][_0x7393('0x26')]);}_0x1db812[_0x7393('0x55')]=qs[_0x7393('0x56')](_0x5b9507[_0x7393('0x4e')][_0x7393('0x56')]);_0x1db812[_0x7393('0x57')]=qs['filters'](_[_0x7393('0x76')](_0x5b9507[_0x7393('0x4e')],_0xd2c071[_0x7393('0x4f')]));_0x1db812[_0x7393('0x57')][_0x7393('0x71')]=_0x3aa2cb['id'];if(_0x5b9507[_0x7393('0x4e')]['filter']){_0x1db812['where']=_[_0x7393('0x59')](_0x1db812[_0x7393('0x57')],{'$or':_['map'](_0x1db812[_0x7393('0x51')],function(_0x1e88e9){var _0x598d1a={};_0x598d1a[_0x1e88e9]={'$like':'%'+_0x5b9507[_0x7393('0x4e')][_0x7393('0x58')]+'%'};return _0x598d1a;})});}_0x1db812=_[_0x7393('0x59')]({},_0x1db812,_0x5b9507[_0x7393('0x5b')]);return db['ChatInteraction']['count']({'where':_0x1db812[_0x7393('0x57')]})[_0x7393('0x2b')](function(_0xcf5c8d){_0x19c60a[_0x7393('0x25')]=_0xcf5c8d;if(_0x5b9507[_0x7393('0x4e')][_0x7393('0x61')]){_0x1db812['include']=[{'model':db[_0x7393('0xa8')],'as':_0x7393('0x100'),'required':![]},{'model':db[_0x7393('0xc6')],'as':_0x7393('0x101'),'attributes':[_0x7393('0x31'),_0x7393('0x102'),'internal'],'required':![]},{'model':db['Tag'],'as':_0x7393('0x103'),'attributes':['id',_0x7393('0x31'),_0x7393('0x104')],'where':_0x5b9507[_0x7393('0x4e')][_0x7393('0x105')]?{'id':_0x5b9507[_0x7393('0x4e')]['tag']}:undefined,'required':_0x5b9507[_0x7393('0x4e')][_0x7393('0x105')]?!![]:![]}];}return db[_0x7393('0xb8')][_0x7393('0x7a')](_0x1db812);})['then'](function(_0x2e0cf0){_0x19c60a[_0x7393('0x5d')]=_0x2e0cf0;return _0x19c60a;});}})['then'](respondWithFilteredResult(_0x233970,_0x1db812))[_0x7393('0x1f')](handleError(_0x233970,null));};exports[_0x7393('0x106')]=function(_0x5ab99b,_0x43dffe){var _0x192a30=0x0;var _0x214777=0x0;var _0xde72cf=![];var _0x365c82;var _0x113a86;return db['ChatWebsite'][_0x7393('0x68')]({'where':{'id':_0x5ab99b[_0x7393('0x5f')]['id']},'include':[{'model':db[_0x7393('0x94')],'as':_0x7393('0x94'),'include':[{'model':db['Interval'],'as':_0x7393('0xab'),'attributes':['id',_0x7393('0x107')]}]}]})[_0x7393('0x2b')](handleEntityNotFound(_0x43dffe,null))['then'](function(_0x1b6281){if(_0x1b6281){_0x365c82=_0x1b6281;return _0x1b6281[_0x7393('0x108')]({'raw':!![]});}})[_0x7393('0x2b')](function(_0x1b7c9f){if(_0x365c82){if(_0x1b7c9f){_0x113a86=_0x1b7c9f;}}return require('../../config/license/util')['getLicense']();})['then'](function(_0x5f04f3){if(_0x5f04f3){_0x214777=_0x5f04f3[_0x7393('0x109')];_0xde72cf=_0x5f04f3[_0x7393('0x10a')];}})[_0x7393('0x2b')](function(){return db['ChatInteraction']['count']({'where':{'closed':![]}});})[_0x7393('0x2b')](function(_0x1f171c){_0x192a30=_0x1f171c;if(_0x214777&&_0x1f171c>_0x214777){return db['License']['findOne']({'where':{'id':0x1}})[_0x7393('0x2b')](function(_0x1da563){if(_0x1da563){_0x1da563[_0x7393('0x10b')](_0x7393('0x10c'));}});}})[_0x7393('0x2b')](function(){var _0x3bd98d=_0x365c82['Interval'];var _0x272699=_0x365c82[_0x7393('0x96')]||undefined;return _0x3bd98d?_0x3bd98d[_0x7393('0x97')](_0x272699):!![];})[_0x7393('0x2b')](function(_0x4c7715){var _0x1e9833=fs['readFileSync'](path[_0x7393('0x8a')](config['root'],'server/files/chat/iframe.ejs'),_0x7393('0xe0'));var _0x5e4497=_0x7393('0x10d');var _0x44a079=![];var _0x4ac243,_0x16a82f;if(_0x5ab99b[_0x7393('0xb5')]['referer']){_0x4ac243=new URL(_0x5ab99b[_0x7393('0xb5')]['referer'])[_0x7393('0x10e')];}else if(_0x5ab99b[_0x7393('0xb5')][_0x7393('0x10e')]){_0x4ac243=new URL(_0x5ab99b[_0x7393('0xb5')]['origin'])['origin'];}else{_0x4ac243=_0x7393('0x10f');}_0x16a82f=typeof _0x365c82[_0x7393('0x6c')][_0x7393('0x38')](',')[_0x7393('0x68')](function(_0x666ef8){return wildcardUtils[_0x7393('0x110')](_0x666ef8,_0x4ac243);})!==_0x7393('0x24');var _0x4dbd53={'chatVersion':_0x5e4497,'chatWebsiteAddressOrigin':_0x16a82f?_0x4ac243:_0x365c82[_0x7393('0x6c')],'remote':_0x365c82['remote'],'query':querystring[_0x7393('0x1a')](_['merge'](_0x365c82[_0x7393('0x2c')]({'plain':!![]}),{'customerIp':_0x5ab99b[_0x7393('0xb5')][_0x7393('0x36')]||_0x5ab99b[_0x7393('0xb5')][_0x7393('0x111')]||_0x5ab99b[_0x7393('0x112')][_0x7393('0x113')]||_0x5ab99b['ip'],'referer':_0x5ab99b[_0x7393('0xb5')][_0x7393('0x3c')],'openedInteractions':_0x192a30,'maxInteractions':_0x214777,'virtual':_0xde72cf['virtual'],'online':_0x4c7715,'custom':_0xde72cf,'address':_0x16a82f?_0x4ac243:null}))[_0x7393('0x114')](/'/g,'\x5c\x27')};_0x43dffe[_0x7393('0xd5')](ejs[_0x7393('0xe1')](Mustache[_0x7393('0xe1')](_0x1e9833,_0x4dbd53),{'proactiveActions':_0x113a86,'alignment':_0x365c82[_0x7393('0x115')],'verticalAlignment':_0x365c82[_0x7393('0x116')],'div_color':_0x365c82[_0x7393('0x104')],'labelText':_0x365c82[_0x7393('0x117')],'text_color':_0x365c82[_0x7393('0x118')],'text_button_color':_0x365c82[_0x7393('0x119')],'button_color':_0x365c82[_0x7393('0x11a')],'background_color':_0x365c82['backgroundColor'],'hideWhenOffline':_0x365c82['hideWhenOffline'],'intervalId':_0x365c82[_0x7393('0x11b')],'isDevelopment':_0x44a079,'chatVersion':_0x5e4497}));})[_0x7393('0x1f')](handleError(_0x43dffe,null));};exports[_0x7393('0x11c')]=function(_0x3d02c2,_0x4d3d25){var _0x3acd09=_0x3d02c2['params']['id'];var _0x355908=_0x3d02c2[_0x7393('0x65')];var _0x1ffdee=0xc8;var _0x3bb1a8=null;return db[_0x7393('0x11d')]['transaction']({'isolationLevel':db[_0x7393('0x11d')]['Transaction'][_0x7393('0x11e')][_0x7393('0x11f')]},function(_0xe7b698){return db[_0x7393('0x4a')][_0x7393('0x74')]({'where':{'id':_0x3acd09},'transaction':_0xe7b698})[_0x7393('0x2b')](function(_0x3fcdd9){if(_0x3fcdd9){return db['ChatApplication']['destroy']({'where':{'ChatWebsiteId':_0x3acd09},'transaction':_0xe7b698})[_0x7393('0x2b')](function(){var _0x40a5ff=_[_0x7393('0x49')](_0x355908,function(_0x4e6969){_0x4e6969[_0x7393('0x71')]=_0x3acd09;return _0x4e6969;});return db[_0x7393('0xaa')][_0x7393('0xef')](_0x40a5ff,{'transaction':_0xe7b698});});}else{_0x1ffdee=0x194;_0x3bb1a8=[];}});})[_0x7393('0x2b')](function(){if(_0x1ffdee!==0x194){return db[_0x7393('0xaa')]['findAndCountAll']({'where':{'ChatWebsiteId':_0x3acd09},'order':_0x7393('0xaf')})[_0x7393('0x2b')](function(_0x121cf2){_0x3bb1a8=_0x121cf2;});}})[_0x7393('0x1f')](function(_0x3bcb2d){_0x1ffdee=0x1f4;logger[_0x7393('0x1b')](_0x3bcb2d[_0x7393('0x30')]);if(_0x3bcb2d['name']){delete _0x3bcb2d[_0x7393('0x31')];}_0x3bb1a8=_0x3bcb2d;})[_0x7393('0x120')](function(){if(_0x3bb1a8===null){_0x4d3d25['sendStatus'](_0x1ffdee);}else{if(_0x1ffdee===0x1f4){_0x4d3d25[_0x7393('0x21')](_0x1ffdee)[_0x7393('0xd5')](_0x3bb1a8);}else{_0x4d3d25[_0x7393('0x21')](_0x1ffdee)[_0x7393('0x23')](_0x3bb1a8);}}});};exports[_0x7393('0x121')]=function(_0x51928e,_0x427792){var _0x33cb05={};var _0x1e01ed={};var _0x36abb5;var _0x3faa5d;return db['ChatWebsite'][_0x7393('0x74')]({'where':{'id':_0x51928e[_0x7393('0x5f')]['id']}})[_0x7393('0x2b')](handleEntityNotFound(_0x427792,null))[_0x7393('0x2b')](function(_0x2c3873){if(_0x2c3873){_0x36abb5=_0x2c3873;_0x1e01ed['model']=_[_0x7393('0x60')](db['ChatApplication'][_0x7393('0x4b')]);_0x1e01ed[_0x7393('0x4e')]=_['keys'](_0x51928e[_0x7393('0x4e')]);_0x1e01ed[_0x7393('0x4f')]=_[_0x7393('0x50')](_0x1e01ed['model'],_0x1e01ed[_0x7393('0x4e')]);_0x33cb05[_0x7393('0x51')]=_[_0x7393('0x50')](_0x1e01ed[_0x7393('0x43')],qs[_0x7393('0x52')](_0x51928e['query']['fields']));_0x33cb05['attributes']=_0x33cb05[_0x7393('0x51')][_0x7393('0x53')]?_0x33cb05['attributes']:_0x1e01ed[_0x7393('0x43')];_0x33cb05[_0x7393('0x55')]=qs[_0x7393('0x56')](_0x51928e[_0x7393('0x4e')][_0x7393('0x56')]);_0x33cb05[_0x7393('0x57')]=qs['filters'](_[_0x7393('0x76')](_0x51928e[_0x7393('0x4e')],_0x1e01ed[_0x7393('0x4f')]));if(_0x51928e[_0x7393('0x4e')][_0x7393('0x58')]){_0x33cb05['where']=_['merge'](_0x33cb05[_0x7393('0x57')],{'$or':_['map'](_0x33cb05[_0x7393('0x51')],function(_0x3d253d){var _0x56e970={};_0x56e970[_0x3d253d]={'$like':'%'+_0x51928e[_0x7393('0x4e')][_0x7393('0x58')]+'%'};return _0x56e970;})});}_0x33cb05=_[_0x7393('0x59')]({},_0x33cb05,_0x51928e[_0x7393('0x5b')]);return _0x36abb5['getApplications'](_0x33cb05);}})[_0x7393('0x2b')](function(_0x30eb48){if(_0x30eb48){_0x3faa5d=_0x30eb48[_0x7393('0x53')];if(!_0x51928e['query']['hasOwnProperty'](_0x7393('0x75'))){_0x33cb05['limit']=qs[_0x7393('0x27')](_0x51928e[_0x7393('0x4e')]['limit']);_0x33cb05['offset']=qs[_0x7393('0x26')](_0x51928e['query'][_0x7393('0x26')]);}return _0x36abb5['getApplications'](_0x33cb05);}})[_0x7393('0x2b')](function(_0x35e64d){if(_0x35e64d){return _0x35e64d?{'count':_0x3faa5d,'rows':_0x35e64d}:null;}})['then'](respondWithResult(_0x427792,null))[_0x7393('0x1f')](handleError(_0x427792,null));};exports[_0x7393('0x122')]=function(_0xc7b807,_0x56f6f0){return db['chatProactiveAction'][_0x7393('0x68')]({'where':{'id':_0xc7b807[_0x7393('0x5f')]['id']}})['then'](handleEntityNotFound(_0x56f6f0,null))[_0x7393('0x2b')](function(_0x36ccc3){if(_0x36ccc3){return _0x36ccc3[_0x7393('0x122')](_0xc7b807[_0x7393('0x65')][_0x7393('0x78')],_[_0x7393('0xff')](_0xc7b807[_0x7393('0x65')],['ids','id'])||{});}})[_0x7393('0x2b')](respondWithResult(_0x56f6f0,null))[_0x7393('0x1f')](handleError(_0x56f6f0,null));};exports[_0x7393('0x108')]=function(_0x1a948e,_0x148dde){var _0x4ff09f={};var _0x37b7de={};var _0x17df9f;var _0x575c3c;return db['ChatWebsite'][_0x7393('0x74')]({'where':{'id':_0x1a948e[_0x7393('0x5f')]['id']}})[_0x7393('0x2b')](handleEntityNotFound(_0x148dde,null))[_0x7393('0x2b')](function(_0x598626){if(_0x598626){_0x17df9f=_0x598626;_0x37b7de['model']=_[_0x7393('0x60')](db['ChatProactiveAction'][_0x7393('0x4b')]);_0x37b7de[_0x7393('0x4e')]=_[_0x7393('0x60')](_0x1a948e[_0x7393('0x4e')]);_0x37b7de[_0x7393('0x4f')]=_['intersection'](_0x37b7de[_0x7393('0x43')],_0x37b7de['query']);_0x4ff09f['attributes']=_[_0x7393('0x50')](_0x37b7de[_0x7393('0x43')],qs[_0x7393('0x52')](_0x1a948e[_0x7393('0x4e')]['fields']));_0x4ff09f['attributes']=_0x4ff09f[_0x7393('0x51')][_0x7393('0x53')]?_0x4ff09f[_0x7393('0x51')]:_0x37b7de[_0x7393('0x43')];_0x4ff09f[_0x7393('0x55')]=qs[_0x7393('0x56')](_0x1a948e['query'][_0x7393('0x56')]);_0x4ff09f[_0x7393('0x57')]=qs[_0x7393('0x4f')](_[_0x7393('0x76')](_0x1a948e[_0x7393('0x4e')],_0x37b7de[_0x7393('0x4f')]));if(_0x1a948e[_0x7393('0x4e')][_0x7393('0x58')]){_0x4ff09f[_0x7393('0x57')]=_[_0x7393('0x59')](_0x4ff09f['where'],{'$or':_[_0x7393('0x49')](_0x4ff09f[_0x7393('0x51')],function(_0x4c6ede){var _0x42e7ee={};_0x42e7ee[_0x4c6ede]={'$like':'%'+_0x1a948e[_0x7393('0x4e')][_0x7393('0x58')]+'%'};return _0x42e7ee;})});}_0x4ff09f=_[_0x7393('0x59')]({},_0x4ff09f,_0x1a948e['options']);return _0x17df9f[_0x7393('0x108')](_0x4ff09f);}})[_0x7393('0x2b')](function(_0x8134d2){if(_0x8134d2){_0x575c3c=_0x8134d2['length'];if(!_0x1a948e['query'][_0x7393('0x54')](_0x7393('0x75'))){_0x4ff09f['limit']=qs['limit'](_0x1a948e[_0x7393('0x4e')][_0x7393('0x27')]);_0x4ff09f[_0x7393('0x26')]=qs['offset'](_0x1a948e[_0x7393('0x4e')][_0x7393('0x26')]);}return _0x17df9f[_0x7393('0x108')](_0x4ff09f);}})[_0x7393('0x2b')](function(_0x4238b0){if(_0x4238b0){return _0x4238b0?{'count':_0x575c3c,'rows':_0x4238b0}:null;}})[_0x7393('0x2b')](respondWithResult(_0x148dde,null))[_0x7393('0x1f')](handleError(_0x148dde,null));};exports[_0x7393('0x123')]=function(_0x55962d,_0xad0f48){var _0x4e84ea=_0x55962d[_0x7393('0x4e')][_0x7393('0x124')]==='false'?'offlineForm':_0x7393('0x125');return db[_0x7393('0x4a')]['find']({'attributes':['id',_0x4e84ea],'where':{'id':_0x55962d[_0x7393('0x5f')]['id']}})[_0x7393('0x2b')](handleEntityNotFound(_0xad0f48,null))[_0x7393('0x2b')](function(_0x2adf75){if(_0x2adf75){var _0x30e98f=_0x2adf75[_0x4e84ea];var _0xe6ba7d=_0x30e98f&&_0x30e98f['items']?_0x30e98f[_0x7393('0x126')]:[];_0xad0f48[_0x7393('0xd5')]({'fromKey':_[_0x7393('0x87')](_0x30e98f['fromKey'])?undefined:_0x30e98f[_0x7393('0x127')],'count':_0xe6ba7d[_0x7393('0x53')],'rows':_0xe6ba7d});}})[_0x7393('0x1f')](handleError(_0xad0f48,null));};exports[_0x7393('0x128')]=function(_0x15667b,_0x2b604f){var _0x3f87d2={'raw':![],'where':{}};var _0x2f91b2={};var _0x292082={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x7393('0x74')]({'where':{'id':_0x15667b[_0x7393('0x5f')]['id']}})[_0x7393('0x2b')](handleEntityNotFound(_0x2b604f,null))[_0x7393('0x2b')](function(_0x528846){if(_0x528846){_0x2f91b2[_0x7393('0x43')]=_[_0x7393('0x60')](db['ChatOfflineMessage'][_0x7393('0x4b')]);_0x2f91b2[_0x7393('0x4e')]=_[_0x7393('0x60')](_0x15667b[_0x7393('0x4e')]);_0x2f91b2[_0x7393('0x4f')]=_[_0x7393('0x50')](_0x2f91b2['model'],_0x2f91b2[_0x7393('0x4e')]);_0x3f87d2['attributes']=_['intersection'](_0x2f91b2['model'],qs['fields'](_0x15667b[_0x7393('0x4e')][_0x7393('0x52')]));_0x3f87d2[_0x7393('0x51')]=_0x3f87d2[_0x7393('0x51')][_0x7393('0x53')]?_0x3f87d2[_0x7393('0x51')]:_0x2f91b2['model'];if(!_0x15667b[_0x7393('0x4e')][_0x7393('0x54')]('nolimit')){_0x3f87d2[_0x7393('0x27')]=qs[_0x7393('0x27')](_0x15667b[_0x7393('0x4e')][_0x7393('0x27')]);_0x3f87d2['offset']=qs['offset'](_0x15667b[_0x7393('0x4e')][_0x7393('0x26')]);}_0x3f87d2[_0x7393('0x55')]=qs[_0x7393('0x56')](_0x15667b[_0x7393('0x4e')]['sort']);_0x3f87d2['where']=qs[_0x7393('0x4f')](_['pick'](_0x15667b['query'],_0x2f91b2[_0x7393('0x4f')]));_0x3f87d2['where'][_0x7393('0x71')]=_0x528846['id'];if(_0x15667b[_0x7393('0x4e')][_0x7393('0x58')]){_0x3f87d2[_0x7393('0x57')]=_['merge'](_0x3f87d2[_0x7393('0x57')],{'$or':_[_0x7393('0x49')](_0x3f87d2[_0x7393('0x51')],function(_0xc2bc07){var _0x5846ee={};_0x5846ee[_0xc2bc07]={'$like':'%'+_0x15667b[_0x7393('0x4e')][_0x7393('0x58')]+'%'};return _0x5846ee;})});}_0x3f87d2=_['merge']({},_0x3f87d2,_0x15667b[_0x7393('0x5b')]);return db[_0x7393('0xe4')][_0x7393('0x25')]({'where':_0x3f87d2[_0x7393('0x57')]})[_0x7393('0x2b')](function(_0x162138){_0x292082[_0x7393('0x25')]=_0x162138;if(_0x15667b[_0x7393('0x4e')][_0x7393('0x61')]){_0x3f87d2['include']=[{'all':!![]}];}else{_0x3f87d2[_0x7393('0x5c')]=[{'model':db['CmContact'],'as':_0x7393('0x100'),'required':![]},{'model':db[_0x7393('0xee')],'as':_0x7393('0x129'),'required':![]}];}return db[_0x7393('0xe4')]['findAll'](_0x3f87d2);})['then'](function(_0x537611){_0x292082[_0x7393('0x5d')]=_0x537611;return _0x292082;});}})['then'](respondWithFilteredResult(_0x2b604f,_0x3f87d2))['catch'](handleError(_0x2b604f,null));};exports['addAgents']=function(_0x530d8a,_0x1e7f3f){return db['ChatWebsite'][_0x7393('0x68')]({'where':{'id':_0x530d8a[_0x7393('0x5f')]['id']}})[_0x7393('0x2b')](handleEntityNotFound(_0x1e7f3f,null))[_0x7393('0x2b')](function(_0x380ff4){if(_0x380ff4){return _0x380ff4['addAgents'](_0x530d8a[_0x7393('0x65')]['ids'],_[_0x7393('0xff')](_0x530d8a['body'],[_0x7393('0x78'),'id'])||{})[_0x7393('0x12a')](function(_0x15b7aa){for(var _0x45bf9d=0x0;_0x45bf9d<_0x530d8a[_0x7393('0x65')][_0x7393('0x78')][_0x7393('0x53')];_0x45bf9d+=0x1){socket[_0x7393('0x12b')](_0x7393('0x12c'),{'UserId':Number(_0x530d8a[_0x7393('0x65')][_0x7393('0x78')][_0x45bf9d]),'ChatWebsiteId':Number(_0x530d8a[_0x7393('0x5f')]['id'])});}return _0x15b7aa;});}})[_0x7393('0x2b')](respondWithResult(_0x1e7f3f,null))[_0x7393('0x1f')](handleError(_0x1e7f3f,null));};exports['removeAgents']=function(_0x40105e,_0x497b02){return db['ChatWebsite'][_0x7393('0x68')]({'where':{'id':_0x40105e['params']['id']}})['then'](handleEntityNotFound(_0x497b02,null))['then'](function(_0x3b54f7){if(_0x3b54f7){return _0x3b54f7[_0x7393('0x12d')](_0x40105e[_0x7393('0x4e')][_0x7393('0x78')])['then'](function(){if(_[_0x7393('0x12e')](_0x40105e['query'][_0x7393('0x78')])){for(var _0xc7739c=0x0;_0xc7739c<_0x40105e[_0x7393('0x4e')][_0x7393('0x78')][_0x7393('0x53')];_0xc7739c+=0x1){socket[_0x7393('0x12b')](_0x7393('0x12f'),{'UserId':Number(_0x40105e['query'][_0x7393('0x78')][_0xc7739c]),'ChatWebsiteId':Number(_0x40105e[_0x7393('0x5f')]['id'])});}}else{socket[_0x7393('0x12b')](_0x7393('0x12f'),{'UserId':Number(_0x40105e[_0x7393('0x4e')]['ids']),'ChatWebsiteId':Number(_0x40105e['params']['id'])});}});}})[_0x7393('0x2b')](respondWithStatusCode(_0x497b02,null))[_0x7393('0x1f')](handleError(_0x497b02,null));};exports['getAgents']=function(_0x188e38,_0xa4d37e){var _0x5e8840={};var _0x33a9fc={};var _0x5441e3;var _0x5e54e6;return db[_0x7393('0x4a')][_0x7393('0x74')]({'where':{'id':_0x188e38[_0x7393('0x5f')]['id']}})[_0x7393('0x2b')](handleEntityNotFound(_0xa4d37e,null))[_0x7393('0x2b')](function(_0x5c86fc){if(_0x5c86fc){_0x5441e3=_0x5c86fc;_0x33a9fc[_0x7393('0x43')]=_[_0x7393('0x60')](db['User']['rawAttributes']);_0x33a9fc[_0x7393('0x4e')]=_[_0x7393('0x60')](_0x188e38[_0x7393('0x4e')]);_0x33a9fc['filters']=_[_0x7393('0x50')](_0x33a9fc[_0x7393('0x43')],_0x33a9fc['query']);_0x5e8840['attributes']=_['intersection'](_0x33a9fc[_0x7393('0x43')],qs[_0x7393('0x52')](_0x188e38['query'][_0x7393('0x52')]));_0x5e8840[_0x7393('0x51')]=_0x5e8840['attributes'][_0x7393('0x53')]?_0x5e8840[_0x7393('0x51')]:_0x33a9fc[_0x7393('0x43')];_0x5e8840[_0x7393('0x55')]=qs[_0x7393('0x56')](_0x188e38[_0x7393('0x4e')]['sort']);_0x5e8840[_0x7393('0x57')]=qs[_0x7393('0x4f')](_[_0x7393('0x76')](_0x188e38[_0x7393('0x4e')],_0x33a9fc[_0x7393('0x4f')]));if(_0x188e38[_0x7393('0x4e')][_0x7393('0x58')]){_0x5e8840[_0x7393('0x57')]=_[_0x7393('0x59')](_0x5e8840[_0x7393('0x57')],{'$or':_['map'](_0x5e8840[_0x7393('0x51')],function(_0x3a39d0){var _0x4b9196={};_0x4b9196[_0x3a39d0]={'$like':'%'+_0x188e38['query'][_0x7393('0x58')]+'%'};return _0x4b9196;})});}_0x5e8840=_[_0x7393('0x59')]({},_0x5e8840,_0x188e38['options']);return _0x5441e3[_0x7393('0x130')](_0x5e8840);}})[_0x7393('0x2b')](function(_0x374f15){if(_0x374f15){_0x5e54e6=_0x374f15[_0x7393('0x53')];if(!_0x188e38[_0x7393('0x4e')]['hasOwnProperty']('nolimit')){_0x5e8840[_0x7393('0x27')]=qs[_0x7393('0x27')](_0x188e38[_0x7393('0x4e')][_0x7393('0x27')]);_0x5e8840[_0x7393('0x26')]=qs['offset'](_0x188e38['query'][_0x7393('0x26')]);}return _0x5441e3[_0x7393('0x130')](_0x5e8840);}})[_0x7393('0x2b')](function(_0x1f61e1){if(_0x1f61e1){return _0x1f61e1?{'count':_0x5e54e6,'rows':_0x1f61e1}:null;}})[_0x7393('0x2b')](respondWithResult(_0xa4d37e,null))[_0x7393('0x1f')](handleError(_0xa4d37e,null));};
\ No newline at end of file