Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 2fe42e6..8bf0970 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6d5e=['orderBy','priority','asc','defaults','customerIp','cf-connecting-ip','headers','x-forwarded-for','first','split','firstName','lastName','x-real-port','browser','format','%s\x20%s','version','unknown','device','vendor','%s\x20%s\x20%s','threadId','ChatInteraction','ContactId','spread','contact','messageId','interaction','created','autoclose','close','unmanaged','*,*,*,*','ChatMessage','AttachmentId','UserId','unshift','agent','waitForTheAssignedAgent','forcedOwnership','startRouting','Start','EventManager','offline','files','mapKeyOffline','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','originalname','mimetype','server','attachments','offline-chat','basename','openNewInteraction','Attachment','bulkCreate','Smtp','forwardOffline','service','host','secure','authentication','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','forwardOfflineAddress','offlineMessageSubject','subjectOffline','toPairsIn','mapValues','NotifyMailAccount','notifyMail','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','User','Owner','internal','Tag','Tags','tag','Command','getSnippet','timezone','iftime\x20%s,%s','interval','iftime\x20%s','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','Intervals','getProactiveActions','custom','License','increment','chatLicenseExceeded','push','all','remote','x-real-ip','remoteAddress','referer','virtual','replace','verticalAlignment','color','textColor','color_button','backgroundColor','sequelize','transaction','Transaction','ISOLATION_LEVELS','READ_COMMITTED','findAndCountAll','getApplications','addProactiveActions','ChatProactiveAction','getFields','online','offlineForm','onlineForm','items','fromKey','getOfflineMessages','Attachments','addAgents','userChatWebsite:save','removeAgents','emit','userChatWebsite:remove','getAgents','bluebird','mustache','util','ejs','fs-extra','querystring','ioredis','../../config/logger','../../mysqldb','redis','localhost','socket.io-emitter','./chatWebsite.socket','register','jayson/promise','client','http','request','then','info','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','message','ChatWebsite,\x20%s,\x20%s','catch','status','end','json','undefined','limit','count','offset','set','Content-Range','update','destroy','get','ChatWebsites','UserProfileResource','sendStatus','stack','name','send','index','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','sort','where','pick','filter','merge','options','include','rows','show','params','length','includeAll','find','create','body','user','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','findOne','nolimit','order','findAll','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','addLogo','sitepic','filename','addAvatar','file','addCustomerAvatar','customerAvatar','addSystemAvatar','getLogo','root','server/files/images/logos/default_logo.svg','../../config/license/util','getLicense','isNil','existsSync','server/files/images/logos/','join','download','getAvatar','server/files/images/avatars/default_avatar.png','agentAvatar','server/files/images/avatars/','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','systemAvatar','notify','setUA','user-agent','getResult','chat','CmContact','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from','Sequelize','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','DESC','ChatApplication','Applications','account','applications','list'];(function(_0x5049e1,_0x4ac87a){var _0x37f162=function(_0x2e06cb){while(--_0x2e06cb){_0x5049e1['push'](_0x5049e1['shift']());}};_0x37f162(++_0x4ac87a);}(_0x6d5e,0x1c6));var _0xe6d5=function(_0x1df8cb,_0x53a66c){_0x1df8cb=_0x1df8cb-0x0;var _0x259a5a=_0x6d5e[_0x1df8cb];return _0x259a5a;};'use strict';var BPromise=require(_0xe6d5('0x0'));var Mustache=require(_0xe6d5('0x1'));var util=require(_0xe6d5('0x2'));var path=require('path');var ejs=require(_0xe6d5('0x3'));var fs=require('fs');var fs_extra=require(_0xe6d5('0x4'));var _=require('lodash');var querystring=require(_0xe6d5('0x5'));var Redis=require(_0xe6d5('0x6'));var qs=require('../../components/parsers/qs');var logger=require(_0xe6d5('0x7'))('api');var config=require('../../config/environment');var db=require(_0xe6d5('0x8'))['db'];config[_0xe6d5('0x9')]=_['defaults'](config['redis'],{'host':_0xe6d5('0xa'),'port':0x18eb});var socket=require(_0xe6d5('0xb'))(new Redis(config[_0xe6d5('0x9')]));require(_0xe6d5('0xc'))[_0xe6d5('0xd')](socket);var jayson=require(_0xe6d5('0xe'));var client=jayson[_0xe6d5('0xf')][_0xe6d5('0x10')]({'port':0x232c});var client9002=jayson[_0xe6d5('0xf')][_0xe6d5('0x10')]({'port':0x232a});var client9003=jayson['client'][_0xe6d5('0x10')]({'port':0x232b});var client9001=jayson[_0xe6d5('0xf')]['http']({'port':0x2329});function respondWithRpcPromise(_0x2990c1,_0x3ad387,_0x35c540,_0x12a715){return new BPromise(function(_0xbb2244,_0x597ca8){var _0x2aa3fa=_0x12a715||client;return _0x2aa3fa[_0xe6d5('0x11')](_0x2990c1,_0x35c540)[_0xe6d5('0x12')](function(_0x2608c6){logger[_0xe6d5('0x13')]('ChatWebsite,\x20%s,\x20%s',_0x3ad387,_0xe6d5('0x14'));logger[_0xe6d5('0x15')](_0xe6d5('0x16'),_0x3ad387,_0xe6d5('0x14'),JSON[_0xe6d5('0x17')](_0x2608c6));if(_0x2608c6[_0xe6d5('0x18')]){if(_0x2608c6[_0xe6d5('0x18')]['code']===0x1f4){logger[_0xe6d5('0x18')]('ChatWebsite,\x20%s,\x20%s',_0x3ad387,_0x2608c6[_0xe6d5('0x18')][_0xe6d5('0x19')]);return _0x597ca8(_0x2608c6[_0xe6d5('0x18')][_0xe6d5('0x19')]);}logger[_0xe6d5('0x18')](_0xe6d5('0x1a'),_0x3ad387,_0x2608c6[_0xe6d5('0x18')]['message']);return _0xbb2244(_0x2608c6['error']['message']);}else{logger[_0xe6d5('0x13')]('ChatWebsite,\x20%s,\x20%s',_0x3ad387,_0xe6d5('0x14'));_0xbb2244(_0x2608c6['result'][_0xe6d5('0x19')]);}})[_0xe6d5('0x1b')](function(_0x56fc13){logger[_0xe6d5('0x18')](_0xe6d5('0x1a'),_0x3ad387,_0x56fc13);_0x597ca8(_0x56fc13);});});}function respondWithStatusCode(_0x1dc1f9,_0x5994c8){_0x5994c8=_0x5994c8||0xcc;return function(_0x39bfe5){if(_0x39bfe5){return _0x1dc1f9['sendStatus'](_0x5994c8);}return _0x1dc1f9[_0xe6d5('0x1c')](_0x5994c8)[_0xe6d5('0x1d')]();};}function respondWithResult(_0x20b724,_0x252b20){_0x252b20=_0x252b20||0xc8;return function(_0x55ee29){if(_0x55ee29){return _0x20b724[_0xe6d5('0x1c')](_0x252b20)[_0xe6d5('0x1e')](_0x55ee29);}};}function respondWithFilteredResult(_0x4cfee6,_0x4d43eb){return function(_0x22fe3c){if(_0x22fe3c){var _0x5a47d9=typeof _0x4d43eb['offset']===_0xe6d5('0x1f')&&typeof _0x4d43eb[_0xe6d5('0x20')]===_0xe6d5('0x1f');var _0x2dd993=_0x22fe3c[_0xe6d5('0x21')];var _0x959852=_0x5a47d9?0x0:_0x4d43eb[_0xe6d5('0x22')];var _0x1a2545=_0x5a47d9?_0x22fe3c[_0xe6d5('0x21')]:_0x4d43eb[_0xe6d5('0x22')]+_0x4d43eb['limit'];var _0x492059;if(_0x1a2545>=_0x2dd993){_0x1a2545=_0x2dd993;_0x492059=0xc8;}else{_0x492059=0xce;}_0x4cfee6[_0xe6d5('0x1c')](_0x492059);return _0x4cfee6[_0xe6d5('0x23')](_0xe6d5('0x24'),_0x959852+'-'+_0x1a2545+'/'+_0x2dd993)[_0xe6d5('0x1e')](_0x22fe3c);}return null;};}function saveUpdates(_0x3cbb06){return function(_0x420c95){if(_0x420c95){return _0x420c95[_0xe6d5('0x25')](_0x3cbb06)['then'](function(_0x233a7e){return _0x233a7e;});}return null;};}function removeEntity(_0x9e90d2){return function(_0x3f400b){if(_0x3f400b){return _0x3f400b[_0xe6d5('0x26')]()[_0xe6d5('0x12')](function(){var _0x2bbd64=_0x3f400b[_0xe6d5('0x27')]({'plain':!![]});var _0x2ca1f5=_0xe6d5('0x28');return db[_0xe6d5('0x29')][_0xe6d5('0x26')]({'where':{'type':_0x2ca1f5,'resourceId':_0x2bbd64['id']}})['then'](function(){return _0x3f400b;});})['then'](function(){_0x9e90d2[_0xe6d5('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x54eb06){return function(_0x5492f3){if(!_0x5492f3){_0x54eb06[_0xe6d5('0x2a')](0x194);}return _0x5492f3;};}function handleError(_0x56dc77,_0xf39a96){_0xf39a96=_0xf39a96||0x1f4;return function(_0x1385a4){logger['error'](_0x1385a4[_0xe6d5('0x2b')]);if(_0x1385a4[_0xe6d5('0x2c')]){delete _0x1385a4[_0xe6d5('0x2c')];}_0x56dc77[_0xe6d5('0x1c')](_0xf39a96)[_0xe6d5('0x2d')](_0x1385a4);};}exports[_0xe6d5('0x2e')]=function(_0x13b049,_0x3bd880){var _0x428db9={'include':[{'model':db[_0xe6d5('0x2f')],'as':_0xe6d5('0x30')}]},_0x46bfeb={},_0x4b5a45={'count':0x0,'rows':[]};var _0x165781=_[_0xe6d5('0x31')](db[_0xe6d5('0x32')][_0xe6d5('0x33')],function(_0x29222c){return{'name':_0x29222c[_0xe6d5('0x34')],'type':_0x29222c[_0xe6d5('0x35')][_0xe6d5('0x36')]};});_0x46bfeb[_0xe6d5('0x37')]=_[_0xe6d5('0x31')](_0x165781,'name');_0x46bfeb[_0xe6d5('0x38')]=_[_0xe6d5('0x39')](_0x13b049[_0xe6d5('0x38')]);_0x46bfeb[_0xe6d5('0x3a')]=_[_0xe6d5('0x3b')](_0x46bfeb[_0xe6d5('0x37')],_0x46bfeb[_0xe6d5('0x38')]);_0x428db9[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x46bfeb[_0xe6d5('0x37')],qs[_0xe6d5('0x3d')](_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x3d')]));_0x428db9[_0xe6d5('0x3c')]=_0x428db9[_0xe6d5('0x3c')]['length']?_0x428db9[_0xe6d5('0x3c')]:_0x46bfeb['model'];if(!_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x3e')]('nolimit')){_0x428db9[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x20')]);_0x428db9['offset']=qs[_0xe6d5('0x22')](_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x22')]);}_0x428db9['order']=qs[_0xe6d5('0x3f')](_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x3f')]);_0x428db9[_0xe6d5('0x40')]=qs['filters'](_[_0xe6d5('0x41')](_0x13b049[_0xe6d5('0x38')],_0x46bfeb[_0xe6d5('0x3a')]),_0x165781);if(_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x42')]){_0x428db9[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0x428db9[_0xe6d5('0x40')],{'$or':_[_0xe6d5('0x31')](_0x165781,function(_0x18cdd9){if(_0x18cdd9[_0xe6d5('0x35')]!=='VIRTUAL'){var _0x263ed6={};_0x263ed6[_0x18cdd9[_0xe6d5('0x2c')]]={'$like':'%'+_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x42')]+'%'};return _0x263ed6;}})});}_0x428db9=_['merge']({},_0x428db9,_0x13b049[_0xe6d5('0x44')]);var _0x484a79={'where':_0x428db9[_0xe6d5('0x40')]};return db[_0xe6d5('0x32')][_0xe6d5('0x21')](_0x484a79)[_0xe6d5('0x12')](function(_0x5eb3a6){_0x4b5a45['count']=_0x5eb3a6;if(_0x13b049['query']['includeAll']){_0x428db9[_0xe6d5('0x45')]=[{'all':!![]}];}return db[_0xe6d5('0x32')]['findAll'](_0x428db9);})[_0xe6d5('0x12')](function(_0x467827){_0x4b5a45[_0xe6d5('0x46')]=_0x467827;return _0x4b5a45;})[_0xe6d5('0x12')](respondWithFilteredResult(_0x3bd880,_0x428db9))[_0xe6d5('0x1b')](handleError(_0x3bd880,null));};exports[_0xe6d5('0x47')]=function(_0x3c09af,_0x5d0fbc){var _0x45e066={'raw':![],'where':{'id':_0x3c09af[_0xe6d5('0x48')]['id']},'include':[{'model':db[_0xe6d5('0x2f')],'as':_0xe6d5('0x30')}]},_0x2bb27d={};_0x2bb27d[_0xe6d5('0x37')]=_[_0xe6d5('0x39')](db[_0xe6d5('0x32')][_0xe6d5('0x33')]);_0x2bb27d[_0xe6d5('0x38')]=_[_0xe6d5('0x39')](_0x3c09af[_0xe6d5('0x38')]);_0x2bb27d[_0xe6d5('0x3a')]=_[_0xe6d5('0x3b')](_0x2bb27d[_0xe6d5('0x37')],_0x2bb27d[_0xe6d5('0x38')]);_0x45e066[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x2bb27d['model'],qs[_0xe6d5('0x3d')](_0x3c09af['query'][_0xe6d5('0x3d')]));_0x45e066['attributes']=_0x45e066[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x45e066['attributes']:_0x2bb27d[_0xe6d5('0x37')];if(_0x3c09af[_0xe6d5('0x38')][_0xe6d5('0x4a')]){_0x45e066[_0xe6d5('0x45')]=[{'all':!![]}];}_0x45e066=_[_0xe6d5('0x43')]({},_0x45e066,_0x3c09af[_0xe6d5('0x44')]);return db['ChatWebsite'][_0xe6d5('0x4b')](_0x45e066)['then'](handleEntityNotFound(_0x5d0fbc,null))[_0xe6d5('0x12')](respondWithResult(_0x5d0fbc,null))[_0xe6d5('0x1b')](handleError(_0x5d0fbc,null));};exports[_0xe6d5('0x4c')]=function(_0x54a916,_0x2af27e){return db[_0xe6d5('0x32')][_0xe6d5('0x4c')](_0x54a916[_0xe6d5('0x4d')],{})['then'](function(_0x4394f0){var _0x27939b=_0x54a916[_0xe6d5('0x4e')][_0xe6d5('0x27')]({'plain':!![]});if(!_0x27939b)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x27939b['role']===_0xe6d5('0x4e')){var _0x4e4391=_0x4394f0[_0xe6d5('0x27')]({'plain':!![]});var _0x28a6cb=_0xe6d5('0x28');return db['UserProfileSection']['find']({'where':{'name':_0x28a6cb,'userProfileId':_0x27939b[_0xe6d5('0x4f')]},'raw':!![]})[_0xe6d5('0x12')](function(_0x23aaba){if(_0x23aaba&&_0x23aaba['autoAssociation']===0x0){return db[_0xe6d5('0x29')][_0xe6d5('0x4c')]({'name':_0x4e4391[_0xe6d5('0x2c')],'resourceId':_0x4e4391['id'],'type':_0x23aaba[_0xe6d5('0x2c')],'sectionId':_0x23aaba['id']},{})[_0xe6d5('0x12')](function(){return _0x4394f0;});}else{return _0x4394f0;}})[_0xe6d5('0x1b')](function(_0xd9052a){logger['error'](_0xe6d5('0x50'),_0xd9052a);throw _0xd9052a;});}return _0x4394f0;})[_0xe6d5('0x12')](respondWithResult(_0x2af27e,0xc9))[_0xe6d5('0x1b')](handleError(_0x2af27e,null));};exports[_0xe6d5('0x25')]=function(_0x2fe88c,_0x1746e3){if(_0x2fe88c[_0xe6d5('0x4d')]['id']){delete _0x2fe88c[_0xe6d5('0x4d')]['id'];}return db[_0xe6d5('0x32')]['find']({'where':{'id':_0x2fe88c[_0xe6d5('0x48')]['id']},'include':[{'model':db[_0xe6d5('0x2f')],'as':_0xe6d5('0x30')}]})[_0xe6d5('0x12')](handleEntityNotFound(_0x1746e3,null))['then'](saveUpdates(_0x2fe88c[_0xe6d5('0x4d')],null))[_0xe6d5('0x12')](respondWithResult(_0x1746e3,null))[_0xe6d5('0x1b')](handleError(_0x1746e3,null));};exports['destroy']=function(_0x3f8dd6,_0x775e8c){return db[_0xe6d5('0x32')][_0xe6d5('0x4b')]({'where':{'id':_0x3f8dd6[_0xe6d5('0x48')]['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x775e8c,null))[_0xe6d5('0x12')](removeEntity(_0x775e8c,null))[_0xe6d5('0x1b')](handleError(_0x775e8c,null));};exports[_0xe6d5('0x51')]=function(_0x229549,_0x2f5934){return db[_0xe6d5('0x32')][_0xe6d5('0x51')]()[_0xe6d5('0x12')](respondWithResult(_0x2f5934,null))['catch'](handleError(_0x2f5934,null));};exports[_0xe6d5('0x52')]=function(_0x4ea32f,_0xc3d5){if(_0x4ea32f[_0xe6d5('0x4d')]['id']){delete _0x4ea32f[_0xe6d5('0x4d')]['id'];}return db['ChatWebsite'][_0xe6d5('0x4b')]({'where':{'id':_0x4ea32f[_0xe6d5('0x48')]['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0xc3d5,null))['then'](function(_0x3dcb7c){if(_0x3dcb7c){_0x4ea32f[_0xe6d5('0x4d')][_0xe6d5('0x53')]=_0x3dcb7c['id'];return db[_0xe6d5('0x54')]['create'](_0x4ea32f['body']);}})[_0xe6d5('0x12')](respondWithResult(_0xc3d5,null))[_0xe6d5('0x1b')](handleError(_0xc3d5,null));};exports[_0xe6d5('0x55')]=function(_0x114e59,_0x41a446){var _0x397cde={'raw':![],'where':{}};var _0x542d41={};var _0x350429={'count':0x0,'rows':[]};return db[_0xe6d5('0x32')][_0xe6d5('0x56')]({'where':{'id':_0x114e59['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x41a446,null))['then'](function(_0x187d41){if(_0x187d41){_0x542d41[_0xe6d5('0x37')]=_[_0xe6d5('0x39')](db['Disposition'][_0xe6d5('0x33')]);_0x542d41['query']=_[_0xe6d5('0x39')](_0x114e59[_0xe6d5('0x38')]);_0x542d41[_0xe6d5('0x3a')]=_['intersection'](_0x542d41['model'],_0x542d41[_0xe6d5('0x38')]);_0x397cde[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x542d41[_0xe6d5('0x37')],qs[_0xe6d5('0x3d')](_0x114e59[_0xe6d5('0x38')]['fields']));_0x397cde[_0xe6d5('0x3c')]=_0x397cde[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x397cde['attributes']:_0x542d41['model'];if(!_0x114e59[_0xe6d5('0x38')]['hasOwnProperty'](_0xe6d5('0x57'))){_0x397cde[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x114e59[_0xe6d5('0x38')][_0xe6d5('0x20')]);_0x397cde[_0xe6d5('0x22')]=qs[_0xe6d5('0x22')](_0x114e59['query'][_0xe6d5('0x22')]);}_0x397cde[_0xe6d5('0x58')]=qs['sort'](_0x114e59[_0xe6d5('0x38')][_0xe6d5('0x3f')]);_0x397cde[_0xe6d5('0x40')]=qs[_0xe6d5('0x3a')](_[_0xe6d5('0x41')](_0x114e59[_0xe6d5('0x38')],_0x542d41[_0xe6d5('0x3a')]));_0x397cde[_0xe6d5('0x40')][_0xe6d5('0x53')]=_0x187d41['id'];if(_0x114e59[_0xe6d5('0x38')][_0xe6d5('0x42')]){_0x397cde[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0x397cde['where'],{'$or':_[_0xe6d5('0x31')](_0x397cde['attributes'],function(_0x537e99){var _0x5760c7={};_0x5760c7[_0x537e99]={'$like':'%'+_0x114e59[_0xe6d5('0x38')]['filter']+'%'};return _0x5760c7;})});}_0x397cde=_[_0xe6d5('0x43')]({},_0x397cde,_0x114e59[_0xe6d5('0x44')]);return db[_0xe6d5('0x54')][_0xe6d5('0x21')]({'where':_0x397cde[_0xe6d5('0x40')]})['then'](function(_0x374875){_0x350429[_0xe6d5('0x21')]=_0x374875;if(_0x114e59[_0xe6d5('0x38')][_0xe6d5('0x4a')]){_0x397cde[_0xe6d5('0x45')]=[{'all':!![]}];}return db[_0xe6d5('0x54')][_0xe6d5('0x59')](_0x397cde);})[_0xe6d5('0x12')](function(_0x5b1a59){_0x350429['rows']=_0x5b1a59;return _0x350429;});}})['then'](respondWithFilteredResult(_0x41a446,_0x397cde))['catch'](handleError(_0x41a446,null));};exports[_0xe6d5('0x5a')]=function(_0x279350,_0x245f66){return db[_0xe6d5('0x32')][_0xe6d5('0x4b')]({'where':{'id':_0x279350[_0xe6d5('0x48')]['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x245f66,null))[_0xe6d5('0x12')](function(_0x2231f4){if(_0x2231f4){return _0x2231f4[_0xe6d5('0x5a')](_0x279350['query'][_0xe6d5('0x5b')]);}})[_0xe6d5('0x12')](respondWithStatusCode(_0x245f66,null))[_0xe6d5('0x1b')](handleError(_0x245f66,null));};exports[_0xe6d5('0x5c')]=function(_0x425afc,_0x19ed45){if(_0x425afc[_0xe6d5('0x4d')]['id']){delete _0x425afc['body']['id'];}return db[_0xe6d5('0x32')][_0xe6d5('0x4b')]({'where':{'id':_0x425afc[_0xe6d5('0x48')]['id']}})['then'](handleEntityNotFound(_0x19ed45,null))[_0xe6d5('0x12')](function(_0x1cac47){if(_0x1cac47){_0x425afc[_0xe6d5('0x4d')][_0xe6d5('0x53')]=_0x1cac47['id'];return db[_0xe6d5('0x5d')][_0xe6d5('0x4c')](_0x425afc[_0xe6d5('0x4d')]);}})['then'](respondWithResult(_0x19ed45,null))[_0xe6d5('0x1b')](handleError(_0x19ed45,null));};exports[_0xe6d5('0x5e')]=function(_0x24f883,_0x1f880b){var _0x172f7d={'raw':![],'where':{}};var _0x544ae5={};var _0x52cb25={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x24f883['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x1f880b,null))[_0xe6d5('0x12')](function(_0x5b5982){if(_0x5b5982){_0x544ae5[_0xe6d5('0x37')]=_[_0xe6d5('0x39')](db[_0xe6d5('0x5d')][_0xe6d5('0x33')]);_0x544ae5[_0xe6d5('0x38')]=_[_0xe6d5('0x39')](_0x24f883[_0xe6d5('0x38')]);_0x544ae5['filters']=_['intersection'](_0x544ae5['model'],_0x544ae5[_0xe6d5('0x38')]);_0x172f7d[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x544ae5['model'],qs[_0xe6d5('0x3d')](_0x24f883['query']['fields']));_0x172f7d[_0xe6d5('0x3c')]=_0x172f7d[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x172f7d[_0xe6d5('0x3c')]:_0x544ae5[_0xe6d5('0x37')];if(!_0x24f883[_0xe6d5('0x38')][_0xe6d5('0x3e')](_0xe6d5('0x57'))){_0x172f7d[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x24f883['query']['limit']);_0x172f7d[_0xe6d5('0x22')]=qs['offset'](_0x24f883['query'][_0xe6d5('0x22')]);}_0x172f7d[_0xe6d5('0x58')]=qs['sort'](_0x24f883[_0xe6d5('0x38')][_0xe6d5('0x3f')]);_0x172f7d[_0xe6d5('0x40')]=qs[_0xe6d5('0x3a')](_[_0xe6d5('0x41')](_0x24f883['query'],_0x544ae5[_0xe6d5('0x3a')]));_0x172f7d[_0xe6d5('0x40')][_0xe6d5('0x53')]=_0x5b5982['id'];if(_0x24f883['query'][_0xe6d5('0x42')]){_0x172f7d[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0x172f7d[_0xe6d5('0x40')],{'$or':_[_0xe6d5('0x31')](_0x172f7d[_0xe6d5('0x3c')],function(_0x3136b2){var _0xcdd2d8={};_0xcdd2d8[_0x3136b2]={'$like':'%'+_0x24f883[_0xe6d5('0x38')]['filter']+'%'};return _0xcdd2d8;})});}_0x172f7d=_[_0xe6d5('0x43')]({},_0x172f7d,_0x24f883[_0xe6d5('0x44')]);return db[_0xe6d5('0x5d')][_0xe6d5('0x21')]({'where':_0x172f7d[_0xe6d5('0x40')]})[_0xe6d5('0x12')](function(_0x50bf10){_0x52cb25[_0xe6d5('0x21')]=_0x50bf10;if(_0x24f883['query'][_0xe6d5('0x4a')]){_0x172f7d[_0xe6d5('0x45')]=[{'all':!![]}];}return db[_0xe6d5('0x5d')][_0xe6d5('0x59')](_0x172f7d);})['then'](function(_0x312c41){_0x52cb25['rows']=_0x312c41;return _0x52cb25;});}})[_0xe6d5('0x12')](respondWithFilteredResult(_0x1f880b,_0x172f7d))[_0xe6d5('0x1b')](handleError(_0x1f880b,null));};exports[_0xe6d5('0x5f')]=function(_0x441dfa,_0xc93e60){return db[_0xe6d5('0x32')]['find']({'where':{'id':_0x441dfa['params']['id']}})['then'](handleEntityNotFound(_0xc93e60,null))[_0xe6d5('0x12')](function(_0x17b6fc){if(_0x17b6fc){return _0x17b6fc[_0xe6d5('0x5f')](_0x441dfa['query'][_0xe6d5('0x5b')]);}})[_0xe6d5('0x12')](respondWithStatusCode(_0xc93e60,null))[_0xe6d5('0x1b')](handleError(_0xc93e60,null));};exports[_0xe6d5('0x60')]=function(_0x163194,_0x247137){_0x163194[_0xe6d5('0x4d')][_0xe6d5('0x61')]=_0x163194['file'][_0xe6d5('0x62')];return db['ChatWebsite'][_0xe6d5('0x4b')]({'where':{'id':_0x163194[_0xe6d5('0x48')]['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x247137,null))[_0xe6d5('0x12')](saveUpdates(_0x163194[_0xe6d5('0x4d')],null))['then'](respondWithResult(_0x247137,null))[_0xe6d5('0x1b')](handleError(_0x247137,null));};exports[_0xe6d5('0x63')]=function(_0x1cb9a6,_0x2a9cdf){_0x1cb9a6['body']['agentAvatar']=_0x1cb9a6[_0xe6d5('0x64')][_0xe6d5('0x62')];return db[_0xe6d5('0x32')][_0xe6d5('0x4b')]({'where':{'id':_0x1cb9a6['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x2a9cdf,null))['then'](saveUpdates(_0x1cb9a6['body'],null))[_0xe6d5('0x12')](respondWithResult(_0x2a9cdf,null))['catch'](handleError(_0x2a9cdf,null));};exports[_0xe6d5('0x65')]=function(_0x1322df,_0x89959e){_0x1322df[_0xe6d5('0x4d')][_0xe6d5('0x66')]=_0x1322df[_0xe6d5('0x64')][_0xe6d5('0x62')];return db['ChatWebsite'][_0xe6d5('0x4b')]({'where':{'id':_0x1322df[_0xe6d5('0x48')]['id']}})['then'](handleEntityNotFound(_0x89959e,null))[_0xe6d5('0x12')](saveUpdates(_0x1322df[_0xe6d5('0x4d')],null))[_0xe6d5('0x12')](respondWithResult(_0x89959e,null))[_0xe6d5('0x1b')](handleError(_0x89959e,null));};exports[_0xe6d5('0x67')]=function(_0x3563b4,_0x44db10){_0x3563b4[_0xe6d5('0x4d')]['systemAvatar']=_0x3563b4['file'][_0xe6d5('0x62')];return db[_0xe6d5('0x32')]['find']({'where':{'id':_0x3563b4[_0xe6d5('0x48')]['id']}})['then'](handleEntityNotFound(_0x44db10,null))['then'](saveUpdates(_0x3563b4[_0xe6d5('0x4d')],null))[_0xe6d5('0x12')](respondWithResult(_0x44db10,null))[_0xe6d5('0x1b')](handleError(_0x44db10,null));};exports[_0xe6d5('0x68')]=function(_0xb3fd24,_0x4e5a47){var _0x32fc7a=path['join'](config[_0xe6d5('0x69')],_0xe6d5('0x6a'));var _0x3bee53={'where':{'id':_0xb3fd24['params']['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x5a9cf6=![];return require(_0xe6d5('0x6b'))[_0xe6d5('0x6c')]()[_0xe6d5('0x12')](function(_0x30f7ea){if(_0x30f7ea){_0x5a9cf6=_0x30f7ea['custom'];}})['then'](function(){return db[_0xe6d5('0x32')][_0xe6d5('0x4b')](_0x3bee53);})[_0xe6d5('0x12')](handleEntityNotFound(_0x4e5a47,null))[_0xe6d5('0x12')](function(_0x5d1ef2){if(_0x5d1ef2){if(!_[_0xe6d5('0x6d')](_0x5d1ef2['sitepic'])){if(fs[_0xe6d5('0x6e')](path['join'](config[_0xe6d5('0x69')],_0xe6d5('0x6f'),_0x5d1ef2[_0xe6d5('0x61')]))&&_0x5a9cf6){_0x32fc7a=path[_0xe6d5('0x70')](config[_0xe6d5('0x69')],_0xe6d5('0x6f'),_0x5d1ef2[_0xe6d5('0x61')]);}}return _0x4e5a47[_0xe6d5('0x71')](_0x32fc7a);}})['catch'](handleError(_0x4e5a47,null));};exports[_0xe6d5('0x72')]=function(_0x91575c,_0x21de5e){var _0x25cb74=path[_0xe6d5('0x70')](config[_0xe6d5('0x69')],_0xe6d5('0x73'));var _0x542622={'where':{'id':_0x91575c['params']['id']},'attributes':['id',_0xe6d5('0x74')],'raw':!![]};return db[_0xe6d5('0x32')][_0xe6d5('0x4b')](_0x542622)['then'](handleEntityNotFound(_0x21de5e,null))[_0xe6d5('0x12')](function(_0x19b838){if(_0x19b838){if(!_['isNil'](_0x19b838[_0xe6d5('0x74')])){if(fs[_0xe6d5('0x6e')](path['join'](config[_0xe6d5('0x69')],'server/files/images/avatars/',_0x19b838[_0xe6d5('0x74')]))){_0x25cb74=path[_0xe6d5('0x70')](config[_0xe6d5('0x69')],'server/files/images/avatars/',_0x19b838[_0xe6d5('0x74')]);}}return _0x21de5e[_0xe6d5('0x71')](_0x25cb74);}})[_0xe6d5('0x1b')](handleError(_0x21de5e,null));};exports['getCustomerAvatar']=function(_0x68ce9a,_0x482759){var _0xb8c059=path['join'](config['root'],'server/files/images/avatars/customer_avatar.png');var _0x5ac945={'where':{'id':_0x68ce9a[_0xe6d5('0x48')]['id']},'attributes':['id',_0xe6d5('0x66'),'showCustomerAvatar'],'raw':!![]};return db[_0xe6d5('0x32')]['find'](_0x5ac945)['then'](handleEntityNotFound(_0x482759,null))[_0xe6d5('0x12')](function(_0x50f161){if(_0x50f161){if(!_[_0xe6d5('0x6d')](_0x50f161[_0xe6d5('0x66')])){if(fs['existsSync'](path[_0xe6d5('0x70')](config['root'],_0xe6d5('0x75'),_0x50f161[_0xe6d5('0x66')]))&&_0x50f161[_0xe6d5('0x76')]){_0xb8c059=path[_0xe6d5('0x70')](config[_0xe6d5('0x69')],'server/files/images/avatars/',_0x50f161[_0xe6d5('0x66')]);}}return _0x482759[_0xe6d5('0x71')](_0xb8c059);}})[_0xe6d5('0x1b')](handleError(_0x482759,null));};exports[_0xe6d5('0x77')]=function(_0x2d0e81,_0x1de4c8){var _0x1fd736=path[_0xe6d5('0x70')](config['root'],_0xe6d5('0x78'));var _0x5c4589={'where':{'id':_0x2d0e81[_0xe6d5('0x48')]['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db[_0xe6d5('0x32')][_0xe6d5('0x4b')](_0x5c4589)[_0xe6d5('0x12')](handleEntityNotFound(_0x1de4c8,null))['then'](function(_0x159d06){if(_0x159d06){if(!_['isNil'](_0x159d06[_0xe6d5('0x79')])){if(fs['existsSync'](path['join'](config[_0xe6d5('0x69')],_0xe6d5('0x75'),_0x159d06['systemAvatar']))){_0x1fd736=path['join'](config['root'],_0xe6d5('0x75'),_0x159d06[_0xe6d5('0x79')]);}}return _0x1de4c8[_0xe6d5('0x71')](_0x1fd736);}})['catch'](handleError(_0x1de4c8,null));};exports[_0xe6d5('0x7a')]=function(_0xa459e8,_0x11ed51){var _0x24c259=require('user-agent-parser');var _0xc907f1=new _0x24c259();var _0x1baac1=_0xc907f1[_0xe6d5('0x7b')](_0xa459e8['headers'][_0xe6d5('0x7c')])[_0xe6d5('0x7d')]();var _0x142e0b={'body':_0xa459e8[_0xe6d5('0x4d')],'channel':_0xe6d5('0x7e')};var _0x239e6b=[];var _0x2b98d9=[];var _0x51ba37={};var _0x344051=![];return db[_0xe6d5('0x7f')][_0xe6d5('0x51')]()[_0xe6d5('0x12')](function(_0x46b661){if(!_0x46b661){throw new db['Sequelize'][(_0xe6d5('0x80'))](_0xe6d5('0x81'));}_0x239e6b=_[_0xe6d5('0x82')](_[_0xe6d5('0x39')](_0x46b661),[_0xe6d5('0x83'),'updatedAt']);_0x2b98d9=_['difference'](_[_0xe6d5('0x39')](_0x46b661),[_0xe6d5('0x83'),_0xe6d5('0x84'),_0xe6d5('0x85'),_0xe6d5('0x86')]);if(_0xa459e8[_0xe6d5('0x4d')]['id']){delete _0xa459e8['body']['id'];}if(_[_0xe6d5('0x6d')](_0xa459e8['body'][_0xe6d5('0x87')])){throw new db[(_0xe6d5('0x88'))][(_0xe6d5('0x80'))](_0xe6d5('0x89'));}if(_[_0xe6d5('0x6d')](_0xa459e8[_0xe6d5('0x4d')]['body'])||_0xa459e8['body'][_0xe6d5('0x4d')]===''){throw new db[(_0xe6d5('0x88'))]['ValidationError'](_0xe6d5('0x8a'));}if(_['isNil'](_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x8b')])){throw new db['Sequelize'][(_0xe6d5('0x80'))](_0xe6d5('0x8c')+_0x2b98d9);}if(!_[_0xe6d5('0x8d')](_0x2b98d9,_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x8b')])){throw new db['Sequelize'][(_0xe6d5('0x80'))](_0xe6d5('0x8e')+_0x2b98d9);}_0x51ba37[_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x8b')]]=_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x87')];})[_0xe6d5('0x12')](function(){return db[_0xe6d5('0x32')]['find']({'where':{'id':_0xa459e8['params']['id']},'include':[{'model':db[_0xe6d5('0x8f')],'as':_0xe6d5('0x90'),'include':[{'model':db[_0xe6d5('0x7f')],'as':_0xe6d5('0x91'),'where':_0x51ba37,'limit':0x1,'order':[['updatedAt',_0xe6d5('0x92')]]}]},{'model':db[_0xe6d5('0x93')],'as':_0xe6d5('0x94')}]});})['then'](handleEntityNotFound(_0x11ed51,null))[_0xe6d5('0x12')](function(_0x2370d0){if(_0x2370d0&&_0x2370d0[_0xe6d5('0x90')]){_0x142e0b[_0xe6d5('0x95')]=_0x2370d0;_0x142e0b[_0xe6d5('0x96')]=_0x2370d0[_0xe6d5('0x94')];_0x142e0b[_0xe6d5('0x97')]=_0x2370d0[_0xe6d5('0x90')];_0x142e0b[_0xe6d5('0x96')]=_[_0xe6d5('0x98')](_0x142e0b[_0xe6d5('0x96')],[_0xe6d5('0x99')],[_0xe6d5('0x9a')]);if(_0x142e0b['account'][_0xe6d5('0x94')]){delete _0x142e0b['account'][_0xe6d5('0x94')];}if(_0x142e0b[_0xe6d5('0x95')][_0xe6d5('0x90')]&&_0x142e0b[_0xe6d5('0x95')][_0xe6d5('0x90')][_0xe6d5('0x91')][_0xe6d5('0x49')]){return _0x142e0b[_0xe6d5('0x95')][_0xe6d5('0x90')][_0xe6d5('0x91')][0x0];}var _0x2ed970=_[_0xe6d5('0x9b')](_0xa459e8[_0xe6d5('0x4d')],{'firstName':_0xa459e8[_0xe6d5('0x4d')]['from'],'ListId':_0x2370d0[_0xe6d5('0x86')]});_0x2ed970[_0xa459e8['body'][_0xe6d5('0x8b')]]=_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x87')];return db[_0xe6d5('0x7f')][_0xe6d5('0x4c')](_0x2ed970,{'fields':_0x239e6b,'raw':!![]});}})['then'](handleEntityNotFound(_0x11ed51,null))[_0xe6d5('0x12')](function(_0x5225ce){_0x142e0b['contact']=_0x5225ce;var _0x4695d9=_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x9c')];if(_0xa459e8['headers']['cf-connecting-ip']){_0x4695d9=_0xa459e8['headers'][_0xe6d5('0x9d')];}else if(_0xa459e8[_0xe6d5('0x9e')][_0xe6d5('0x9f')]){_0x4695d9=_[_0xe6d5('0xa0')](_0xa459e8['headers'][_0xe6d5('0x9f')][_0xe6d5('0xa1')](','));}if(_0x5225ce){var _0x1343ba={'ContactId':_0x5225ce['id'],'ChatWebsiteId':_0xa459e8[_0xe6d5('0x48')]['id'],'from':(_0x5225ce[_0xe6d5('0xa2')]||'')+'\x20'+(_0x5225ce[_0xe6d5('0xa3')]||''),'customerIp':_0x4695d9,'customerPort':_0xa459e8[_0xe6d5('0x9e')][_0xe6d5('0xa4')]?_0xa459e8['headers'][_0xe6d5('0xa4')]:null,'referer':_0xa459e8[_0xe6d5('0x4d')]['referer'],'browserName':_0x1baac1[_0xe6d5('0xa5')][_0xe6d5('0x2c')]&&_0x1baac1[_0xe6d5('0xa5')]['version']?util[_0xe6d5('0xa6')](_0xe6d5('0xa7'),_0x1baac1[_0xe6d5('0xa5')]['name'],_0x1baac1[_0xe6d5('0xa5')]['version']):'unknown','browserVersion':_0x1baac1['browser'][_0xe6d5('0xa8')]||_0xe6d5('0xa9'),'osName':util[_0xe6d5('0xa6')](_0xe6d5('0xa7'),_0x1baac1['os'][_0xe6d5('0x2c')],_0x1baac1['os'][_0xe6d5('0xa8')]),'osVersion':_0x1baac1['os'][_0xe6d5('0xa8')],'deviceModel':_0x1baac1[_0xe6d5('0xaa')][_0xe6d5('0x37')]&&_0x1baac1[_0xe6d5('0xaa')][_0xe6d5('0xab')]?util[_0xe6d5('0xa6')](_0xe6d5('0xac'),_0x1baac1['device'][_0xe6d5('0x37')],_0x1baac1[_0xe6d5('0xaa')][_0xe6d5('0xab')],_0x1baac1[_0xe6d5('0xaa')][_0xe6d5('0x35')]):null,'deviceVendor':_0x1baac1[_0xe6d5('0xaa')][_0xe6d5('0xab')],'deviceType':_0x1baac1[_0xe6d5('0xaa')][_0xe6d5('0x35')],'formData':JSON[_0xe6d5('0x17')](_0xa459e8[_0xe6d5('0x4d')])};var _0x5ab6a2={'ChatWebsiteId':_0xa459e8['params']['id'],'closed':![]};if(_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xad')]){_0x5ab6a2['threadId']=_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xad')];return db[_0xe6d5('0xae')][_0xe6d5('0x4b')]({'where':_0x5ab6a2})[_0xe6d5('0x12')](function(_0xc8320f){if(_0xc8320f){return[_0xc8320f,![]];}_0x1343ba[_0xe6d5('0xad')]=_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xad')];_0x1343ba['externalUrl']=_0xa459e8[_0xe6d5('0x4d')]['externalUrl'];return db[_0xe6d5('0xae')][_0xe6d5('0x4c')](_0x1343ba)['then'](function(_0x3af1b1){return[_0x3af1b1,!![]];});});}_0x5ab6a2[_0xe6d5('0xaf')]=_0x5225ce['id'];if(_0xa459e8[_0xe6d5('0x4d')]['interaction']&&_0xa459e8['body']['interaction']['id']){_0x5ab6a2['id']=_0xa459e8['body']['interaction']['id'];return db[_0xe6d5('0xae')][_0xe6d5('0x4b')]({'where':_0x5ab6a2})['then'](function(_0x3585b5){if(_0x3585b5){return[_0x3585b5,![]];}return db['ChatInteraction']['create'](_0x1343ba)[_0xe6d5('0x12')](function(_0x40edab){return[_0x40edab,!![]];});});}return db['ChatInteraction'][_0xe6d5('0x4c')](_0x1343ba)[_0xe6d5('0x12')](function(_0x3c6248){return[_0x3c6248,!![]];});}})[_0xe6d5('0xb0')](function(_0x3eaa1d,_0x207f02){if(_0x3eaa1d){_0x344051=_0x207f02;if(!_0x207f02){var _0x2c2808={'from':(_0x142e0b[_0xe6d5('0xb1')][_0xe6d5('0xa2')]||'')+'\x20'+(_0x142e0b[_0xe6d5('0xb1')]['lastName']||'')};if(_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xad')]&&_0xa459e8['body'][_0xe6d5('0xb2')]&&_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xad')]!=_0xa459e8['body']['messageId']){_0x2c2808[_0xe6d5('0xad')]=_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xb2')];}return _0x3eaa1d[_0xe6d5('0x25')](_0x2c2808);}else{return _0x3eaa1d;}}})[_0xe6d5('0x12')](function(_0x389229){_0x142e0b[_0xe6d5('0xb3')]=_0x389229[_0xe6d5('0x27')]({'plain':!![]});_0x142e0b[_0xe6d5('0xb3')][_0xe6d5('0xb4')]=_0x344051;if(_0x142e0b['interaction'][_0xe6d5('0xb4')]){if(_0x142e0b['account'][_0xe6d5('0xb5')]){_0x142e0b[_0xe6d5('0x96')]['push']({'id':0x0,'priority':_0x142e0b['applications'][_0xe6d5('0x49')]+0x1,'app':_0xe6d5('0xb6'),'appdata':_0xe6d5('0xb7'),'interval':_0xe6d5('0xb8')});}}return db[_0xe6d5('0xb9')][_0xe6d5('0x4c')]({'body':_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x4d')],'ChatWebsiteId':_0xa459e8['params']['id'],'ChatInteractionId':_0x389229['id'],'direction':'in','ContactId':_0x142e0b[_0xe6d5('0xb1')]['id'],'AttachmentId':_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xba')]});})['then'](function(_0x2f28c8){_0x142e0b[_0xe6d5('0x19')]=_0x2f28c8;if(_0x142e0b[_0xe6d5('0xb3')]['UserId']){return db['User'][_0xe6d5('0x4b')]({'attributes':['id',_0xe6d5('0x2c')],'where':{'id':_0x142e0b[_0xe6d5('0xb3')][_0xe6d5('0xbb')]}})[_0xe6d5('0x12')](function(_0xda9ce){if(_0xda9ce){_0x142e0b[_0xe6d5('0x96')][_0xe6d5('0xbc')]({'id':0x0,'priority':0x0,'app':_0xe6d5('0xbd'),'appdata':_0xda9ce['name']+','+(_0x142e0b[_0xe6d5('0x95')][_0xe6d5('0xbe')]||0xa),'interval':'*,*,*,*'});_0x142e0b[_0xe6d5('0xbf')]=!![];}return respondWithRpcPromise('Start',_0xe6d5('0xc0'),_0x142e0b);});}return respondWithRpcPromise(_0xe6d5('0xc1'),_0xe6d5('0xc0'),_0x142e0b);})[_0xe6d5('0x12')](function(_0x3119a2){respondWithRpcPromise(_0xe6d5('0xc2'),_0xe6d5('0xc2'),{'event':_0xe6d5('0x7a'),'message':_0x3119a2},client9002);return _0x3119a2;})[_0xe6d5('0x12')](respondWithResult(_0x11ed51,null))[_0xe6d5('0x1b')](handleError(_0x11ed51,null));};exports[_0xe6d5('0xc3')]=function(_0x382273,_0x44b2ac){var _0x2afa44,_0x5a0731,_0x3afa7f;var _0x5bbb4c=[];var _0x559317={};var _0x3ec330=_0x382273[_0xe6d5('0xc4')]||[];var _0x53346d=[];var _0x59f592;return db[_0xe6d5('0x7f')][_0xe6d5('0x51')]()['then'](function(_0x21bfb6){if(!_0x21bfb6){throw new db[(_0xe6d5('0x88'))][(_0xe6d5('0x80'))](_0xe6d5('0x81'));}_0x5bbb4c=_[_0xe6d5('0x82')](_[_0xe6d5('0x39')](_0x21bfb6),[_0xe6d5('0x83'),'updatedAt','CompanyId',_0xe6d5('0x86')]);if(_0x382273[_0xe6d5('0x4d')]['id']){delete _0x382273[_0xe6d5('0x4d')]['id'];}if(_['isNil'](_0x382273[_0xe6d5('0x4d')]['from'])){throw _0x44b2ac[_0xe6d5('0x1c')](0x1f4)[_0xe6d5('0x2d')](new db[(_0xe6d5('0x88'))][(_0xe6d5('0x80'))]('from\x20is\x20mandatory'));}if(_[_0xe6d5('0x6d')](_0x382273[_0xe6d5('0x4d')]['body'])||_0x382273[_0xe6d5('0x4d')][_0xe6d5('0x4d')]===''){throw _0x44b2ac[_0xe6d5('0x1c')](0x1f4)[_0xe6d5('0x2d')](new db[(_0xe6d5('0x88'))]['ValidationError'](_0xe6d5('0x8a')));}if(_[_0xe6d5('0x6d')](_0x382273[_0xe6d5('0x4d')][_0xe6d5('0xc5')])){throw _0x44b2ac[_0xe6d5('0x1c')](0x1f4)['send'](new db[(_0xe6d5('0x88'))]['ValidationError']('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x5bbb4c));}if(!_['includes'](_0x5bbb4c,_0x382273[_0xe6d5('0x4d')]['mapKeyOffline'])){throw _0x44b2ac[_0xe6d5('0x1c')](0x1f4)[_0xe6d5('0x2d')](new db['Sequelize'][(_0xe6d5('0x80'))]('mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x5bbb4c));}_0x559317[_0x382273['body']['mapKeyOffline']]=_0x382273[_0xe6d5('0x4d')][_0xe6d5('0x87')];})[_0xe6d5('0x12')](function(){return db['ChatWebsite'][_0xe6d5('0x4b')]({'where':{'id':_0x382273[_0xe6d5('0x48')]['id']},'include':[{'model':db[_0xe6d5('0x8f')],'as':'List'},{'model':db[_0xe6d5('0xc6')],'as':_0xe6d5('0xc6')}]});})[_0xe6d5('0x12')](handleEntityNotFound(_0x44b2ac,null))[_0xe6d5('0x12')](function(_0x5a81dc){if(_0x5a81dc&&_0x5a81dc['List']){_0x5a0731=_0x5a81dc;var _0x1222d7=_[_0xe6d5('0x9b')](_0x382273[_0xe6d5('0x4d')],{'firstName':_0x382273[_0xe6d5('0x4d')][_0xe6d5('0x87')],'phone':_0x382273['body'][_0xe6d5('0x87')],'ListId':_0x5a81dc[_0xe6d5('0x86')]});_0x1222d7[_0x382273['body'][_0xe6d5('0xc5')]]=_0x382273[_0xe6d5('0x4d')][_0xe6d5('0x87')];return db[_0xe6d5('0x7f')][_0xe6d5('0xc7')]({'where':_0x559317,'defaults':_0x1222d7});}})['spread'](function(_0x57efa2){if(_0x57efa2){_0x3afa7f=_0x57efa2;var _0x242cec=fs[_0xe6d5('0xc8')](path[_0xe6d5('0x70')](config[_0xe6d5('0x69')],_0xe6d5('0xc9')),_0xe6d5('0xca'));var _0x3700d4=ejs[_0xe6d5('0xcb')](_0x242cec,{'body':_[_0xe6d5('0xcc')](_0x382273['body'][_0xe6d5('0x4d')]),'bodyTitle':_0x5a0731[_0xe6d5('0xcd')]});return db[_0xe6d5('0xce')][_0xe6d5('0x4c')]({'body':_0x3700d4,'ContactId':_0x57efa2['id'],'ChatWebsiteId':_0x5a0731['id']});}})[_0xe6d5('0x12')](function(_0x4e975e){_0x59f592=_0x4e975e;if(_0x3ec330['length']){var _0x435de7=_0x3ec330[_0xe6d5('0x31')](function(_0x194221){return{'name':_0x194221[_0xe6d5('0xcf')],'basename':_0x194221['filename'],'type':_0x194221[_0xe6d5('0xd0')],'ChatOfflineMessageId':_0x4e975e['id']};});_0x53346d=_0x435de7[_0xe6d5('0x31')](_0x52a2a9=>{var _0x2862ed={'filename':_0x52a2a9[_0xe6d5('0x2c')],'path':path[_0xe6d5('0x70')](config[_0xe6d5('0x69')],_0xe6d5('0xd1'),_0xe6d5('0xc4'),_0xe6d5('0xd2'),_0xe6d5('0xd3'),_0x52a2a9[_0xe6d5('0xd4')])};return _0x2862ed;});if(!_0x5a0731[_0xe6d5('0xd5')]){return db['sequelize']['transaction'](function(_0x119ac8){return db[_0xe6d5('0xd6')][_0xe6d5('0xd7')](_0x435de7,{'transaction':_0x119ac8});});}}})[_0xe6d5('0x12')](function(){if(_0x59f592){_0x2afa44=_0x59f592;return db[_0xe6d5('0xc6')][_0xe6d5('0x56')]({'where':{'active':!![]},'include':[{'model':db['MailServerOut'],'as':_0xe6d5('0xd8'),'raw':!![]}]});}})[_0xe6d5('0x12')](function(_0xc9bd67){if(_0xc9bd67&&_0xc9bd67[_0xe6d5('0xd8')]&&_0x5a0731[_0xe6d5('0xd9')]&&_0x5a0731['forwardOfflineAddress']){var _0x268687={'tls':{'rejectUnauthorized':![]}};if(_0xc9bd67['Smtp']['service']){_0x268687[_0xe6d5('0xda')]=_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0xda')];}else{_0x268687[_0xe6d5('0xdb')]=_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0xdb')];_0x268687['port']=_0xc9bd67[_0xe6d5('0xd8')]['port'];_0x268687[_0xe6d5('0xdc')]=_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0xdc')];}if(_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0xdd')]){_0x268687[_0xe6d5('0xde')]={'user':_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0x4e')],'pass':_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0xdf')]};}return respondWithRpcPromise(_0xe6d5('0xe0'),_0xe6d5('0xe1'),{'account':_0x268687,'message':{'from':util[_0xe6d5('0xa6')](_0xe6d5('0xe2'),_0xc9bd67['name'],_0xc9bd67[_0xe6d5('0xe3')]||_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0x4e')]),'to':_0x5a0731[_0xe6d5('0xe4')],'subject':_0x5a0731[_0xe6d5('0xe5')],'html':_0x2afa44[_0xe6d5('0x4d')],'attachments':_0x53346d}},client9003)[_0xe6d5('0x12')](function(){return _0x2afa44;})[_0xe6d5('0x1b')](function(_0x1ef33e){console[_0xe6d5('0x18')](_0x1ef33e);});}})[_0xe6d5('0x12')](function(){if(_0x5a0731&&_0x5a0731[_0xe6d5('0xd5')]&&_0x5a0731['MailAccountId']){var _0x189cb7=[];if(_0x3ec330[_0xe6d5('0x49')]){_0x189cb7=_0x3ec330[_0xe6d5('0x31')](function(_0x4c3487){return{'name':_0x4c3487[_0xe6d5('0xcf')],'basename':_0x4c3487[_0xe6d5('0x62')],'type':_0x4c3487[_0xe6d5('0xd0')],'ChatOfflineMessageId':_0x59f592['id']};});}var _0x2f010f;if(!_[_0xe6d5('0x6d')](_0x5a0731[_0xe6d5('0xe6')])){var _0x1bcfa3=_['map'](_0x382273[_0xe6d5('0x4d')],function(_0x1bfa28){return _0x1bfa28;});var _0x52c7ca=_[_0xe6d5('0xe7')](_0x1bcfa3)[0x0];var _0x508b14=_[_0xe6d5('0xe8')](_0x52c7ca,function(_0x5cf3e4){return _0x5cf3e4;});_0x2f010f=_0x508b14[0x1][_0x5a0731[_0xe6d5('0xe6')]];}var _0x28249a={'from':_0x3afa7f[_0xe6d5('0xe3')],'firstName':_0x3afa7f['firstName'],'lastName':_0x3afa7f['lastName'],'mapKey':'email','message':{'from':_0x3afa7f[_0xe6d5('0xe3')],'to':_0x5a0731[_0xe6d5('0xc6')]['email'],'cc':'','subject':_[_0xe6d5('0x6d')](_0x2f010f)?_0x5a0731[_0xe6d5('0xe5')]:_0x2f010f,'messageId':'','sentAt':new Date(),'attach':_0x189cb7['length'],'attachments':_0x189cb7,'originChannel':'Chat','ChatWebsiteId':_0x5a0731['id'],'ChatOfflineMessageId':_0x2afa44['id'],'originTo':_0x5a0731[_0xe6d5('0xc6')][_0xe6d5('0xe3')]},'body':_0x2afa44[_0xe6d5('0x4d')]};var _0x3df306={'account':{'id':_0x5a0731['MailAccountId']},'body':_0x28249a,'log':_0xe6d5('0xe9')};return respondWithRpcPromise(_0xe6d5('0xe9'),_0xe6d5('0xea'),_0x3df306,client9001)[_0xe6d5('0x12')](function(){return _0x2afa44;})[_0xe6d5('0x1b')](function(_0x360de2){console[_0xe6d5('0x18')](_0x360de2);});}return;})[_0xe6d5('0x12')](function(){if(_0x2afa44){return _0x2afa44;}})[_0xe6d5('0x12')](respondWithResult(_0x44b2ac,null))[_0xe6d5('0x1b')](function(_0x3fa56a){console['error'](_0xe6d5('0x1b'),_0x3fa56a);for(var _0x163ea2 of _0x3ec330){var _0x46a7e2=path['join'](config['root'],'server',_0xe6d5('0xc4'),_0xe6d5('0xd2'),_0xe6d5('0xd3'),_0x163ea2['filename']);fs_extra[_0xe6d5('0xeb')](_0x46a7e2)[_0xe6d5('0x1b')](function(_0x412658){console[_0xe6d5('0x18')](_0xe6d5('0xec'),_0x46a7e2,_0x412658);});}});};exports[_0xe6d5('0xed')]=function(_0x287821,_0x1059d8){return db[_0xe6d5('0xae')][_0xe6d5('0x4b')]({'where':{'id':_0x287821['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x1059d8,null))['then'](function(_0xf576c8){if(_0xf576c8){return _0xf576c8['addInteraction'](_0x287821[_0xe6d5('0x4d')][_0xe6d5('0x5b')],_[_0xe6d5('0xee')](_0x287821['body'],[_0xe6d5('0x5b'),'id'])||{});}})[_0xe6d5('0x12')](respondWithResult(_0x1059d8,null))[_0xe6d5('0x1b')](handleError(_0x1059d8,null));};exports[_0xe6d5('0xef')]=function(_0x4e37f0,_0x4a71a2){var _0xa93669={'raw':![],'where':{}};var _0x167930={};var _0x48e6d1={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x4e37f0['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x4a71a2,null))[_0xe6d5('0x12')](function(_0x5cb442){if(_0x5cb442){_0x167930['model']=_['keys'](db[_0xe6d5('0xae')][_0xe6d5('0x33')]);_0x167930['query']=_['keys'](_0x4e37f0[_0xe6d5('0x38')]);_0x167930[_0xe6d5('0x3a')]=_[_0xe6d5('0x3b')](_0x167930[_0xe6d5('0x37')],_0x167930[_0xe6d5('0x38')]);_0xa93669[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x167930['model'],qs[_0xe6d5('0x3d')](_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0x3d')]));_0xa93669[_0xe6d5('0x3c')]=_0xa93669[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0xa93669['attributes']:_0x167930[_0xe6d5('0x37')];if(!_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0x3e')](_0xe6d5('0x57'))){_0xa93669[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0x20')]);_0xa93669['offset']=qs['offset'](_0x4e37f0[_0xe6d5('0x38')]['offset']);}_0xa93669[_0xe6d5('0x58')]=qs[_0xe6d5('0x3f')](_0x4e37f0[_0xe6d5('0x38')]['sort']);_0xa93669['where']=qs['filters'](_[_0xe6d5('0x41')](_0x4e37f0[_0xe6d5('0x38')],_0x167930[_0xe6d5('0x3a')]));_0xa93669[_0xe6d5('0x40')][_0xe6d5('0x53')]=_0x5cb442['id'];if(_0x4e37f0[_0xe6d5('0x38')]['filter']){_0xa93669[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0xa93669[_0xe6d5('0x40')],{'$or':_[_0xe6d5('0x31')](_0xa93669[_0xe6d5('0x3c')],function(_0x5a90a2){var _0x467de9={};_0x467de9[_0x5a90a2]={'$like':'%'+_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0x42')]+'%'};return _0x467de9;})});}_0xa93669=_[_0xe6d5('0x43')]({},_0xa93669,_0x4e37f0[_0xe6d5('0x44')]);return db[_0xe6d5('0xae')]['count']({'where':_0xa93669[_0xe6d5('0x40')]})[_0xe6d5('0x12')](function(_0xabcac7){_0x48e6d1['count']=_0xabcac7;if(_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0x4a')]){_0xa93669['include']=[{'model':db[_0xe6d5('0x7f')],'as':_0xe6d5('0xf0'),'required':![]},{'model':db[_0xe6d5('0xf1')],'as':_0xe6d5('0xf2'),'attributes':[_0xe6d5('0x2c'),'fullname',_0xe6d5('0xf3')],'required':![]},{'model':db[_0xe6d5('0xf4')],'as':_0xe6d5('0xf5'),'attributes':['id',_0xe6d5('0x2c'),'color'],'where':_0x4e37f0['query']['tag']?{'id':_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0xf6')]}:undefined,'required':_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0xf6')]?!![]:![]}];}return db[_0xe6d5('0xae')][_0xe6d5('0x59')](_0xa93669);})[_0xe6d5('0x12')](function(_0x36337d){_0x48e6d1['rows']=_0x36337d;return _0x48e6d1;});}})[_0xe6d5('0x12')](respondWithFilteredResult(_0x4a71a2,_0xa93669))[_0xe6d5('0x1b')](handleError(_0x4a71a2,null));};function iftimePromise(_0x2a501d,_0x48142a){return respondWithRpcPromise(_0xe6d5('0xf7'),_0xe6d5('0xf8'),{'command':_0x48142a[_0xe6d5('0xf9')]?util['format'](_0xe6d5('0xfa'),_0x2a501d[_0xe6d5('0xfb')],_0x48142a[_0xe6d5('0xf9')]):util[_0xe6d5('0xa6')](_0xe6d5('0xfc'),_0x2a501d[_0xe6d5('0xfb')])},client9002)['then'](function(_0x5dd782){var _0x42d4bc=_0x5dd782&&_0x5dd782[_0xe6d5('0xfd')](_0xe6d5('0xfe'))>=0x0?!![]:![];logger['info'](_0xe6d5('0xff'),_0x48142a['id'],_0x2a501d['id'],_0x2a501d[_0xe6d5('0xfb')],_0x42d4bc?_0xe6d5('0x100'):_0xe6d5('0x101'),_0x48142a['timezone']?_0x48142a[_0xe6d5('0xf9')]:_0xe6d5('0x102'));return _0x42d4bc;})[_0xe6d5('0x1b')](function(_0x4bff2c){logger[_0xe6d5('0x18')](_0xe6d5('0xff'),_0x48142a['id'],_0x2a501d['id'],_0x2a501d[_0xe6d5('0xfb')],util[_0xe6d5('0x103')](_0x4bff2c,{'showHidden':![],'depth':null}),_0x48142a[_0xe6d5('0xf9')]?_0x48142a[_0xe6d5('0xf9')]:_0xe6d5('0x102'));return![];});}exports['getSnippet']=function(_0xc134a6,_0xcaac11){var _0x4e6549=0x0;var _0x353942=0x0;var _0x7d2d79=![];var _0x41b535;var _0x53b53a;return db['ChatWebsite'][_0xe6d5('0x4b')]({'where':{'id':_0xc134a6[_0xe6d5('0x48')]['id']},'include':[{'model':db[_0xe6d5('0x104')],'as':_0xe6d5('0x104'),'include':[{'model':db[_0xe6d5('0x104')],'as':_0xe6d5('0x105'),'attributes':['id',_0xe6d5('0xfb')],'raw':!![]}]}]})[_0xe6d5('0x12')](handleEntityNotFound(_0xcaac11,null))[_0xe6d5('0x12')](function(_0xce13d2){if(_0xce13d2){_0x41b535=_0xce13d2;return _0xce13d2[_0xe6d5('0x106')]({'raw':!![]});}})[_0xe6d5('0x12')](function(_0x1c55e4){if(_0x41b535){if(_0x1c55e4){_0x53b53a=_0x1c55e4;}}return require('../../config/license/util')[_0xe6d5('0x6c')]();})['then'](function(_0x2774d7){if(_0x2774d7){_0x353942=_0x2774d7['virtual'];_0x7d2d79=_0x2774d7[_0xe6d5('0x107')];}})[_0xe6d5('0x12')](function(){return db[_0xe6d5('0xae')][_0xe6d5('0x21')]({'where':{'closed':![]}});})['then'](function(_0x1b9376){_0x4e6549=_0x1b9376;if(_0x353942&&_0x1b9376>_0x353942){return db[_0xe6d5('0x108')][_0xe6d5('0x56')]({'where':{'id':0x1}})[_0xe6d5('0x12')](function(_0x48556a){if(_0x48556a){_0x48556a[_0xe6d5('0x109')](_0xe6d5('0x10a'));}});}})[_0xe6d5('0x12')](function(){if(_0x41b535[_0xe6d5('0x104')]&&_0x41b535['Interval'][_0xe6d5('0x105')]){var _0x925f22=[];for(var _0xca2705=0x0;_0xca2705<_0x41b535['Interval']['Intervals']['length'];_0xca2705++){var _0x20e2a1=_0x41b535[_0xe6d5('0x104')][_0xe6d5('0x105')][_0xca2705]['get']({'plain':!![]});_0x925f22[_0xe6d5('0x10b')](iftimePromise(_0x20e2a1,_0x41b535));}return BPromise[_0xe6d5('0x10c')](_0x925f22)['then'](function(_0x83faf){return _['some'](_0x83faf);});}else{return!![];}})[_0xe6d5('0x12')](function(_0x1cf712){var _0x4b426f=fs[_0xe6d5('0xc8')](path['join'](config[_0xe6d5('0x69')],'server/files/chat/iframe.ejs'),_0xe6d5('0xca'));var _0x48cb34={'remote':_0x41b535[_0xe6d5('0x10d')],'query':querystring[_0xe6d5('0x17')](_[_0xe6d5('0x43')](_0x41b535[_0xe6d5('0x27')]({'plain':!![]}),{'customerIp':_0xc134a6[_0xe6d5('0x9e')][_0xe6d5('0x9f')]||_0xc134a6[_0xe6d5('0x9e')][_0xe6d5('0x10e')]||_0xc134a6['connection'][_0xe6d5('0x10f')]||_0xc134a6['ip'],'referer':_0xc134a6['headers'][_0xe6d5('0x110')],'openedInteractions':_0x4e6549,'maxInteractions':_0x353942,'virtual':_0x7d2d79[_0xe6d5('0x111')],'online':_0x1cf712,'custom':_0x7d2d79}))[_0xe6d5('0x112')](/'/g,'\x5c\x27')};_0xcaac11[_0xe6d5('0x2d')](ejs[_0xe6d5('0xcb')](Mustache[_0xe6d5('0xcb')](_0x4b426f,_0x48cb34),{'proactiveActions':_0x53b53a,'alignment':_0x41b535['alignment'],'verticalAlignment':_0x41b535[_0xe6d5('0x113')],'div_color':_0x41b535[_0xe6d5('0x114')],'text_color':_0x41b535[_0xe6d5('0x115')],'button_color':_0x41b535[_0xe6d5('0x116')],'background_color':_0x41b535[_0xe6d5('0x117')]}));})[_0xe6d5('0x1b')](handleError(_0xcaac11,null));};exports['addApplications']=function(_0x314d26,_0x112e36){var _0x3e5a2c=_0x314d26['params']['id'];var _0x1181dd=_0x314d26[_0xe6d5('0x4d')];var _0x37a533=0xc8;var _0x2df312=null;return db[_0xe6d5('0x118')][_0xe6d5('0x119')]({'isolationLevel':db[_0xe6d5('0x118')][_0xe6d5('0x11a')][_0xe6d5('0x11b')][_0xe6d5('0x11c')]},function(_0x4d5071){return db[_0xe6d5('0x32')][_0xe6d5('0x56')]({'where':{'id':_0x3e5a2c},'transaction':_0x4d5071})[_0xe6d5('0x12')](function(_0x641d0e){if(_0x641d0e){return db['ChatApplication']['destroy']({'where':{'ChatWebsiteId':_0x3e5a2c},'transaction':_0x4d5071})[_0xe6d5('0x12')](function(){var _0x523010=_[_0xe6d5('0x31')](_0x1181dd,function(_0x4c061e){_0x4c061e['ChatWebsiteId']=_0x3e5a2c;return _0x4c061e;});return db[_0xe6d5('0x93')][_0xe6d5('0xd7')](_0x523010,{'transaction':_0x4d5071});});}else{_0x37a533=0x194;_0x2df312=[];}});})[_0xe6d5('0x12')](function(){if(_0x37a533!==0x194){return db[_0xe6d5('0x93')][_0xe6d5('0x11d')]({'where':{'ChatWebsiteId':_0x3e5a2c},'order':_0xe6d5('0x99')})[_0xe6d5('0x12')](function(_0x10c334){_0x2df312=_0x10c334;});}})[_0xe6d5('0x1b')](function(_0x40b12b){_0x37a533=0x1f4;logger[_0xe6d5('0x18')](_0x40b12b[_0xe6d5('0x2b')]);if(_0x40b12b[_0xe6d5('0x2c')]){delete _0x40b12b[_0xe6d5('0x2c')];}_0x2df312=_0x40b12b;})['finally'](function(){if(_0x2df312===null){_0x112e36[_0xe6d5('0x2a')](_0x37a533);}else{if(_0x37a533===0x1f4){_0x112e36['status'](_0x37a533)[_0xe6d5('0x2d')](_0x2df312);}else{_0x112e36['status'](_0x37a533)[_0xe6d5('0x1e')](_0x2df312);}}});};exports['getApplications']=function(_0x532576,_0x2aeecc){var _0x9d6f43={};var _0x3c00b4={};var _0x37a0c6;var _0x110112;return db['ChatWebsite']['findOne']({'where':{'id':_0x532576['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x2aeecc,null))[_0xe6d5('0x12')](function(_0x5bdcfb){if(_0x5bdcfb){_0x37a0c6=_0x5bdcfb;_0x3c00b4['model']=_[_0xe6d5('0x39')](db['ChatApplication'][_0xe6d5('0x33')]);_0x3c00b4[_0xe6d5('0x38')]=_[_0xe6d5('0x39')](_0x532576['query']);_0x3c00b4['filters']=_[_0xe6d5('0x3b')](_0x3c00b4[_0xe6d5('0x37')],_0x3c00b4[_0xe6d5('0x38')]);_0x9d6f43['attributes']=_[_0xe6d5('0x3b')](_0x3c00b4[_0xe6d5('0x37')],qs['fields'](_0x532576[_0xe6d5('0x38')]['fields']));_0x9d6f43[_0xe6d5('0x3c')]=_0x9d6f43[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x9d6f43['attributes']:_0x3c00b4[_0xe6d5('0x37')];_0x9d6f43[_0xe6d5('0x58')]=qs[_0xe6d5('0x3f')](_0x532576[_0xe6d5('0x38')]['sort']);_0x9d6f43['where']=qs['filters'](_[_0xe6d5('0x41')](_0x532576[_0xe6d5('0x38')],_0x3c00b4[_0xe6d5('0x3a')]));if(_0x532576[_0xe6d5('0x38')][_0xe6d5('0x42')]){_0x9d6f43['where']=_[_0xe6d5('0x43')](_0x9d6f43[_0xe6d5('0x40')],{'$or':_[_0xe6d5('0x31')](_0x9d6f43[_0xe6d5('0x3c')],function(_0x35e75c){var _0x40008f={};_0x40008f[_0x35e75c]={'$like':'%'+_0x532576['query'][_0xe6d5('0x42')]+'%'};return _0x40008f;})});}_0x9d6f43=_[_0xe6d5('0x43')]({},_0x9d6f43,_0x532576['options']);return _0x37a0c6[_0xe6d5('0x11e')](_0x9d6f43);}})['then'](function(_0x5de5c3){if(_0x5de5c3){_0x110112=_0x5de5c3[_0xe6d5('0x49')];if(!_0x532576['query'][_0xe6d5('0x3e')]('nolimit')){_0x9d6f43[_0xe6d5('0x20')]=qs['limit'](_0x532576[_0xe6d5('0x38')][_0xe6d5('0x20')]);_0x9d6f43[_0xe6d5('0x22')]=qs['offset'](_0x532576['query'][_0xe6d5('0x22')]);}return _0x37a0c6[_0xe6d5('0x11e')](_0x9d6f43);}})['then'](function(_0x220ba4){if(_0x220ba4){return _0x220ba4?{'count':_0x110112,'rows':_0x220ba4}:null;}})[_0xe6d5('0x12')](respondWithResult(_0x2aeecc,null))[_0xe6d5('0x1b')](handleError(_0x2aeecc,null));};exports[_0xe6d5('0x11f')]=function(_0x1dc1b9,_0x33f79b){return db['chatProactiveAction'][_0xe6d5('0x4b')]({'where':{'id':_0x1dc1b9['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x33f79b,null))[_0xe6d5('0x12')](function(_0x5aae74){if(_0x5aae74){return _0x5aae74[_0xe6d5('0x11f')](_0x1dc1b9[_0xe6d5('0x4d')][_0xe6d5('0x5b')],_[_0xe6d5('0xee')](_0x1dc1b9[_0xe6d5('0x4d')],['ids','id'])||{});}})['then'](respondWithResult(_0x33f79b,null))[_0xe6d5('0x1b')](handleError(_0x33f79b,null));};exports[_0xe6d5('0x106')]=function(_0x51e8e0,_0x347941){var _0x44742c={};var _0x565d91={};var _0x1bbb12;var _0x1fb768;return db[_0xe6d5('0x32')][_0xe6d5('0x56')]({'where':{'id':_0x51e8e0[_0xe6d5('0x48')]['id']}})['then'](handleEntityNotFound(_0x347941,null))[_0xe6d5('0x12')](function(_0x16a757){if(_0x16a757){_0x1bbb12=_0x16a757;_0x565d91[_0xe6d5('0x37')]=_[_0xe6d5('0x39')](db[_0xe6d5('0x120')][_0xe6d5('0x33')]);_0x565d91[_0xe6d5('0x38')]=_[_0xe6d5('0x39')](_0x51e8e0[_0xe6d5('0x38')]);_0x565d91[_0xe6d5('0x3a')]=_[_0xe6d5('0x3b')](_0x565d91['model'],_0x565d91[_0xe6d5('0x38')]);_0x44742c[_0xe6d5('0x3c')]=_['intersection'](_0x565d91[_0xe6d5('0x37')],qs[_0xe6d5('0x3d')](_0x51e8e0[_0xe6d5('0x38')][_0xe6d5('0x3d')]));_0x44742c[_0xe6d5('0x3c')]=_0x44742c[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x44742c[_0xe6d5('0x3c')]:_0x565d91['model'];_0x44742c['order']=qs[_0xe6d5('0x3f')](_0x51e8e0[_0xe6d5('0x38')][_0xe6d5('0x3f')]);_0x44742c[_0xe6d5('0x40')]=qs[_0xe6d5('0x3a')](_[_0xe6d5('0x41')](_0x51e8e0[_0xe6d5('0x38')],_0x565d91[_0xe6d5('0x3a')]));if(_0x51e8e0[_0xe6d5('0x38')][_0xe6d5('0x42')]){_0x44742c[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0x44742c[_0xe6d5('0x40')],{'$or':_[_0xe6d5('0x31')](_0x44742c['attributes'],function(_0x5eb7d2){var _0x1cd8d9={};_0x1cd8d9[_0x5eb7d2]={'$like':'%'+_0x51e8e0[_0xe6d5('0x38')]['filter']+'%'};return _0x1cd8d9;})});}_0x44742c=_[_0xe6d5('0x43')]({},_0x44742c,_0x51e8e0[_0xe6d5('0x44')]);return _0x1bbb12[_0xe6d5('0x106')](_0x44742c);}})[_0xe6d5('0x12')](function(_0x2caac6){if(_0x2caac6){_0x1fb768=_0x2caac6['length'];if(!_0x51e8e0[_0xe6d5('0x38')]['hasOwnProperty'](_0xe6d5('0x57'))){_0x44742c[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x51e8e0['query'][_0xe6d5('0x20')]);_0x44742c['offset']=qs[_0xe6d5('0x22')](_0x51e8e0[_0xe6d5('0x38')][_0xe6d5('0x22')]);}return _0x1bbb12['getProactiveActions'](_0x44742c);}})[_0xe6d5('0x12')](function(_0x457986){if(_0x457986){return _0x457986?{'count':_0x1fb768,'rows':_0x457986}:null;}})['then'](respondWithResult(_0x347941,null))[_0xe6d5('0x1b')](handleError(_0x347941,null));};exports[_0xe6d5('0x121')]=function(_0x3dac80,_0x3e047b){var _0x4af1b7=_0x3dac80[_0xe6d5('0x38')][_0xe6d5('0x122')]==='false'?_0xe6d5('0x123'):_0xe6d5('0x124');return db[_0xe6d5('0x32')][_0xe6d5('0x4b')]({'attributes':['id',_0x4af1b7],'where':{'id':_0x3dac80['params']['id']}})['then'](handleEntityNotFound(_0x3e047b,null))[_0xe6d5('0x12')](function(_0x2d4387){if(_0x2d4387){var _0x4eef56=_0x2d4387[_0x4af1b7];var _0x2f01bd=_0x4eef56&&_0x4eef56[_0xe6d5('0x125')]?_0x4eef56[_0xe6d5('0x125')]:[];_0x3e047b[_0xe6d5('0x2d')]({'fromKey':_[_0xe6d5('0x6d')](_0x4eef56[_0xe6d5('0x126')])?undefined:_0x4eef56[_0xe6d5('0x126')],'count':_0x2f01bd[_0xe6d5('0x49')],'rows':_0x2f01bd});}})['catch'](handleError(_0x3e047b,null));};exports[_0xe6d5('0x127')]=function(_0x542886,_0x52a4f2){var _0x5032d5={'raw':![],'where':{}};var _0x4cf54b={};var _0x37f332={'count':0x0,'rows':[]};return db['ChatWebsite'][_0xe6d5('0x56')]({'where':{'id':_0x542886['params']['id']}})['then'](handleEntityNotFound(_0x52a4f2,null))[_0xe6d5('0x12')](function(_0x3de61e){if(_0x3de61e){_0x4cf54b[_0xe6d5('0x37')]=_[_0xe6d5('0x39')](db['ChatOfflineMessage'][_0xe6d5('0x33')]);_0x4cf54b['query']=_['keys'](_0x542886[_0xe6d5('0x38')]);_0x4cf54b['filters']=_[_0xe6d5('0x3b')](_0x4cf54b[_0xe6d5('0x37')],_0x4cf54b[_0xe6d5('0x38')]);_0x5032d5[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x4cf54b[_0xe6d5('0x37')],qs[_0xe6d5('0x3d')](_0x542886['query']['fields']));_0x5032d5[_0xe6d5('0x3c')]=_0x5032d5[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x5032d5['attributes']:_0x4cf54b['model'];if(!_0x542886[_0xe6d5('0x38')][_0xe6d5('0x3e')](_0xe6d5('0x57'))){_0x5032d5[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x542886[_0xe6d5('0x38')][_0xe6d5('0x20')]);_0x5032d5['offset']=qs[_0xe6d5('0x22')](_0x542886[_0xe6d5('0x38')]['offset']);}_0x5032d5['order']=qs[_0xe6d5('0x3f')](_0x542886[_0xe6d5('0x38')][_0xe6d5('0x3f')]);_0x5032d5[_0xe6d5('0x40')]=qs['filters'](_['pick'](_0x542886[_0xe6d5('0x38')],_0x4cf54b[_0xe6d5('0x3a')]));_0x5032d5[_0xe6d5('0x40')][_0xe6d5('0x53')]=_0x3de61e['id'];if(_0x542886['query']['filter']){_0x5032d5[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0x5032d5[_0xe6d5('0x40')],{'$or':_['map'](_0x5032d5[_0xe6d5('0x3c')],function(_0x4f1884){var _0x5d85b3={};_0x5d85b3[_0x4f1884]={'$like':'%'+_0x542886[_0xe6d5('0x38')][_0xe6d5('0x42')]+'%'};return _0x5d85b3;})});}_0x5032d5=_['merge']({},_0x5032d5,_0x542886[_0xe6d5('0x44')]);return db['ChatOfflineMessage'][_0xe6d5('0x21')]({'where':_0x5032d5[_0xe6d5('0x40')]})['then'](function(_0x59a39e){_0x37f332[_0xe6d5('0x21')]=_0x59a39e;if(_0x542886[_0xe6d5('0x38')][_0xe6d5('0x4a')]){_0x5032d5[_0xe6d5('0x45')]=[{'all':!![]}];}else{_0x5032d5[_0xe6d5('0x45')]=[{'model':db[_0xe6d5('0x7f')],'as':_0xe6d5('0xf0'),'required':![]},{'model':db['Attachment'],'as':_0xe6d5('0x128'),'required':![]}];}return db[_0xe6d5('0xce')]['findAll'](_0x5032d5);})[_0xe6d5('0x12')](function(_0x557c2b){_0x37f332[_0xe6d5('0x46')]=_0x557c2b;return _0x37f332;});}})[_0xe6d5('0x12')](respondWithFilteredResult(_0x52a4f2,_0x5032d5))['catch'](handleError(_0x52a4f2,null));};exports[_0xe6d5('0x129')]=function(_0x3cc878,_0x443401){return db[_0xe6d5('0x32')][_0xe6d5('0x4b')]({'where':{'id':_0x3cc878['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x443401,null))['then'](function(_0x30e12a){if(_0x30e12a){return _0x30e12a[_0xe6d5('0x129')](_0x3cc878[_0xe6d5('0x4d')][_0xe6d5('0x5b')],_[_0xe6d5('0xee')](_0x3cc878[_0xe6d5('0x4d')],['ids','id'])||{})[_0xe6d5('0xb0')](function(_0x5176f5){for(var _0x4a471e=0x0;_0x4a471e<_0x3cc878['body'][_0xe6d5('0x5b')]['length'];_0x4a471e+=0x1){socket['emit'](_0xe6d5('0x12a'),{'UserId':Number(_0x3cc878[_0xe6d5('0x4d')]['ids'][_0x4a471e]),'ChatWebsiteId':Number(_0x3cc878['params']['id'])});}return _0x5176f5;});}})[_0xe6d5('0x12')](respondWithResult(_0x443401,null))[_0xe6d5('0x1b')](handleError(_0x443401,null));};exports[_0xe6d5('0x12b')]=function(_0x2380be,_0x3017ad){return db['ChatWebsite'][_0xe6d5('0x4b')]({'where':{'id':_0x2380be[_0xe6d5('0x48')]['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x3017ad,null))[_0xe6d5('0x12')](function(_0x1d56c9){if(_0x1d56c9){return _0x1d56c9['removeAgents'](_0x2380be[_0xe6d5('0x38')]['ids'])['then'](function(){if(_['isArray'](_0x2380be[_0xe6d5('0x38')][_0xe6d5('0x5b')])){for(var _0x2344a4=0x0;_0x2344a4<_0x2380be[_0xe6d5('0x38')][_0xe6d5('0x5b')][_0xe6d5('0x49')];_0x2344a4+=0x1){socket[_0xe6d5('0x12c')](_0xe6d5('0x12d'),{'UserId':Number(_0x2380be[_0xe6d5('0x38')]['ids'][_0x2344a4]),'ChatWebsiteId':Number(_0x2380be[_0xe6d5('0x48')]['id'])});}}else{socket[_0xe6d5('0x12c')](_0xe6d5('0x12d'),{'UserId':Number(_0x2380be['query'][_0xe6d5('0x5b')]),'ChatWebsiteId':Number(_0x2380be['params']['id'])});}});}})['then'](respondWithStatusCode(_0x3017ad,null))[_0xe6d5('0x1b')](handleError(_0x3017ad,null));};exports['getAgents']=function(_0x142614,_0x364f6c){var _0x49cf06={};var _0x585ea5={};var _0x5558ff;var _0x2fe752;return db['ChatWebsite'][_0xe6d5('0x56')]({'where':{'id':_0x142614['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x364f6c,null))['then'](function(_0x577e55){if(_0x577e55){_0x5558ff=_0x577e55;_0x585ea5[_0xe6d5('0x37')]=_[_0xe6d5('0x39')](db['User'][_0xe6d5('0x33')]);_0x585ea5[_0xe6d5('0x38')]=_['keys'](_0x142614[_0xe6d5('0x38')]);_0x585ea5[_0xe6d5('0x3a')]=_[_0xe6d5('0x3b')](_0x585ea5['model'],_0x585ea5[_0xe6d5('0x38')]);_0x49cf06[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x585ea5[_0xe6d5('0x37')],qs[_0xe6d5('0x3d')](_0x142614[_0xe6d5('0x38')][_0xe6d5('0x3d')]));_0x49cf06[_0xe6d5('0x3c')]=_0x49cf06[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x49cf06['attributes']:_0x585ea5[_0xe6d5('0x37')];_0x49cf06['order']=qs[_0xe6d5('0x3f')](_0x142614[_0xe6d5('0x38')][_0xe6d5('0x3f')]);_0x49cf06[_0xe6d5('0x40')]=qs[_0xe6d5('0x3a')](_[_0xe6d5('0x41')](_0x142614['query'],_0x585ea5['filters']));if(_0x142614[_0xe6d5('0x38')][_0xe6d5('0x42')]){_0x49cf06[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0x49cf06[_0xe6d5('0x40')],{'$or':_['map'](_0x49cf06[_0xe6d5('0x3c')],function(_0x38fb0a){var _0x355d03={};_0x355d03[_0x38fb0a]={'$like':'%'+_0x142614[_0xe6d5('0x38')][_0xe6d5('0x42')]+'%'};return _0x355d03;})});}_0x49cf06=_['merge']({},_0x49cf06,_0x142614[_0xe6d5('0x44')]);return _0x5558ff[_0xe6d5('0x12e')](_0x49cf06);}})[_0xe6d5('0x12')](function(_0x4d9e8e){if(_0x4d9e8e){_0x2fe752=_0x4d9e8e['length'];if(!_0x142614[_0xe6d5('0x38')][_0xe6d5('0x3e')](_0xe6d5('0x57'))){_0x49cf06[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x142614[_0xe6d5('0x38')][_0xe6d5('0x20')]);_0x49cf06['offset']=qs[_0xe6d5('0x22')](_0x142614[_0xe6d5('0x38')][_0xe6d5('0x22')]);}return _0x5558ff[_0xe6d5('0x12e')](_0x49cf06);}})[_0xe6d5('0x12')](function(_0x22de41){if(_0x22de41){return _0x22de41?{'count':_0x2fe752,'rows':_0x22de41}:null;}})[_0xe6d5('0x12')](respondWithResult(_0x364f6c,null))[_0xe6d5('0x1b')](handleError(_0x364f6c,null));};
\ No newline at end of file
+var _0x48bd=['file','filename','addAvatar','addCustomerAvatar','customerAvatar','addSystemAvatar','join','root','../../config/license/util','getLicense','custom','isNil','existsSync','server/files/images/logos/','agentAvatar','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','download','getSystemAvatar','server/files/images/avatars/system_avatar.png','systemAvatar','notify','chat','CmContact','Sequelize','ValidationError','difference','createdAt','updatedAt','CompanyId','from','mapKey','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','List','DESC','ChatApplication','Applications','Interval','Chat\x20Website\x20with\x20id\x20%s\x20not\x20found','account','applications','priority','asc','Contacts','defaults','ListId','contact','headers','threadId','ChatInteraction','ContactId','interaction','messageId','created','autoclose','push','unmanaged','ChatMessage','AttachmentId','UserId','unshift','agent','waitForTheAssignedAgent','queueId','queue','waitForTheAssignedQueue','*,*,*,*','startRouting','EventManager','files','no\x20available\x20attributes','from\x20is\x20mandatory','mapKeyOffline','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','render','toPairs','offlineMessageBody','ChatOfflineMessage','fromString','server','attachments','offline-chat','openNewInteraction','transaction','Attachment','bulkCreate','MailServerOut','Smtp','CloudProvider','forwardOffline','forwardOfflineAddress','SendMail','\x22%s\x22\x20<%s>','email','originalname','subjectOffline','mapValues','offlineMessageSubject','Chat','NotifyMailAccount','notifyMail','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','User','Owner','fullname','internal','Tag','color','tag','getProactiveActions','virtual','increment','chatLicenseExceeded','server/files/chat/iframe.ejs','origin','remote','x-real-ip','connection','remoteAddress','replace','alignment','verticalAlignment','labelText','color_button','hideWhenOffline','addApplications','sequelize','Transaction','ISOLATION_LEVELS','READ_COMMITTED','finally','getApplications','addProactiveActions','chatProactiveAction','ChatProactiveAction','getFields','online','offlineForm','items','fromKey','getOfflineMessages','Contact','Attachments','addAgents','spread','emit','removeAgents','userChatWebsite:remove','getAgents','ejs','fs-extra','lodash','html-to-text','ioredis','url','../../config/logger','api','../../errors/api','APIOutOfIntervalError','APINotFoundError','redis','localhost','./chatWebsite.socket','register','client','http','then','info','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','code','ChatWebsite,\x20%s,\x20%s','error','message','catch','status','json','offset','undefined','limit','count','set','update','ChatWebsites','UserProfileResource','destroy','end','sendStatus','stack','name','send','Command','timezone','format','iftime\x20%s,%s','interval','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','OFFLINE','No\x20timezone','inspect','map','Intervals','get','all','some','user-agent-parser','setUA','user-agent','getResult','customerIp','cf-connecting-ip','x-forwarded-for','first','split','firstName','lastName','x-real-port','browser','version','%s\x20%s','unknown','device','model','vendor','%s\x20%s\x20%s','type','Pause','mandatoryDispositionPause','ChatWebsite','rawAttributes','fieldName','key','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','options','includeAll','include','findAll','rows','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','ChatWebsiteId','Disposition','getDispositions','findOne','removeDispositions','ids','addAnswer','getAnswers','CannedAnswer','removeAnswers','addLogo','sitepic'];(function(_0x180328,_0x23697){var _0x55867=function(_0x4aa213){while(--_0x4aa213){_0x180328['push'](_0x180328['shift']());}};_0x55867(++_0x23697);}(_0x48bd,0xa0));var _0xd48b=function(_0xb3cada,_0xcc3214){_0xb3cada=_0xb3cada-0x0;var _0x43774a=_0x48bd[_0xb3cada];return _0x43774a;};'use strict';var Mustache=require('mustache');var util=require('util');var path=require('path');var ejs=require(_0xd48b('0x0'));var fs=require('fs');var fs_extra=require(_0xd48b('0x1'));var _=require(_0xd48b('0x2'));var querystring=require('querystring');var htmlToText=require(_0xd48b('0x3'));var Redis=require(_0xd48b('0x4'));var jayson=require('jayson/promise');var url=require(_0xd48b('0x5'));var qs=require('../../components/parsers/qs');var logger=require(_0xd48b('0x6'))(_0xd48b('0x7'));var config=require('../../config/environment');var APIOutOfIntervalError=require(_0xd48b('0x8'))[_0xd48b('0x9')];var APINotFoundError=require(_0xd48b('0x8'))[_0xd48b('0xa')];var APIHandleError=require('../../errors/api')['handleError'];var db=require('../../mysqldb')['db'];config['redis']=_['defaults'](config[_0xd48b('0xb')],{'host':_0xd48b('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xd48b('0xb')]));require(_0xd48b('0xd'))[_0xd48b('0xe')](socket);var client=jayson[_0xd48b('0xf')][_0xd48b('0x10')]({'port':0x232c});var client9002=jayson[_0xd48b('0xf')][_0xd48b('0x10')]({'port':0x232a});var client9003=jayson[_0xd48b('0xf')][_0xd48b('0x10')]({'port':0x232b});var client9001=jayson[_0xd48b('0xf')]['http']({'port':0x2329});function respondWithRpcPromise(_0x2132fe,_0x314c38,_0x4dd7de,_0x4fd250){return new Promise(function(_0x10e1e4,_0x50b998){var _0x3523cd=_0x4fd250||client;return _0x3523cd['request'](_0x2132fe,_0x4dd7de)[_0xd48b('0x11')](function(_0x18a13b){logger[_0xd48b('0x12')]('ChatWebsite,\x20%s,\x20%s',_0x314c38,_0xd48b('0x13'));logger[_0xd48b('0x14')](_0xd48b('0x15'),_0x314c38,_0xd48b('0x13'),JSON[_0xd48b('0x16')](_0x18a13b));if(_0x18a13b['error']){if(_0x18a13b['error'][_0xd48b('0x17')]===0x1f4){logger['error'](_0xd48b('0x18'),_0x314c38,_0x18a13b[_0xd48b('0x19')]['message']);return _0x50b998(_0x18a13b['error'][_0xd48b('0x1a')]);}logger[_0xd48b('0x19')]('ChatWebsite,\x20%s,\x20%s',_0x314c38,_0x18a13b[_0xd48b('0x19')][_0xd48b('0x1a')]);return _0x10e1e4(_0x18a13b['error']['message']);}else{logger[_0xd48b('0x12')]('ChatWebsite,\x20%s,\x20%s',_0x314c38,_0xd48b('0x13'));_0x10e1e4(_0x18a13b['result'][_0xd48b('0x1a')]);}})[_0xd48b('0x1b')](function(_0xca6ab9){logger[_0xd48b('0x19')](_0xd48b('0x18'),_0x314c38,_0xca6ab9);_0x50b998(_0xca6ab9);});});}function respondWithStatusCode(_0x36c0b3,_0x3c69eb){_0x3c69eb=_0x3c69eb||0xcc;return function(_0x3e2455){if(_0x3e2455){return _0x36c0b3['sendStatus'](_0x3c69eb);}return _0x36c0b3[_0xd48b('0x1c')](_0x3c69eb)['end']();};}function respondWithResult(_0x105c3c,_0x5ec7c1){_0x5ec7c1=_0x5ec7c1||0xc8;return function(_0x3d7d69){if(_0x3d7d69){return _0x105c3c[_0xd48b('0x1c')](_0x5ec7c1)[_0xd48b('0x1d')](_0x3d7d69);}};}function respondWithFilteredResult(_0x479943,_0x476ac5){return function(_0x12e3c5){if(_0x12e3c5){var _0x2cdcdc=typeof _0x476ac5[_0xd48b('0x1e')]===_0xd48b('0x1f')&&typeof _0x476ac5[_0xd48b('0x20')]===_0xd48b('0x1f');var _0x553062=_0x12e3c5[_0xd48b('0x21')];var _0x1fe24b=_0x2cdcdc?0x0:_0x476ac5[_0xd48b('0x1e')];var _0xa66eb9=_0x2cdcdc?_0x12e3c5['count']:_0x476ac5[_0xd48b('0x1e')]+_0x476ac5[_0xd48b('0x20')];var _0x3c677e;if(_0xa66eb9>=_0x553062){_0xa66eb9=_0x553062;_0x3c677e=0xc8;}else{_0x3c677e=0xce;}_0x479943[_0xd48b('0x1c')](_0x3c677e);return _0x479943[_0xd48b('0x22')]('Content-Range',_0x1fe24b+'-'+_0xa66eb9+'/'+_0x553062)[_0xd48b('0x1d')](_0x12e3c5);}return null;};}function saveUpdates(_0x39deb1){return function(_0x346283){if(_0x346283){return _0x346283[_0xd48b('0x23')](_0x39deb1)[_0xd48b('0x11')](function(_0x1ebe58){return _0x1ebe58;});}return null;};}function removeEntity(_0x5a7998){return function(_0x393ad7){if(_0x393ad7){return _0x393ad7['destroy']()['then'](function(){var _0x148334=_0x393ad7['get']({'plain':!![]});var _0x5dc0ef=_0xd48b('0x24');return db[_0xd48b('0x25')][_0xd48b('0x26')]({'where':{'type':_0x5dc0ef,'resourceId':_0x148334['id']}})[_0xd48b('0x11')](function(){return _0x393ad7;});})[_0xd48b('0x11')](function(){_0x5a7998[_0xd48b('0x1c')](0xcc)[_0xd48b('0x27')]();});}};}function handleEntityNotFound(_0x28cd8e){return function(_0x3cf33a){if(!_0x3cf33a){_0x28cd8e[_0xd48b('0x28')](0x194);}return _0x3cf33a;};}function handleError(_0x309e72,_0x22174a){_0x22174a=_0x22174a||0x1f4;return function(_0x15bd0e){logger[_0xd48b('0x19')](_0x15bd0e[_0xd48b('0x29')]);if(_0x15bd0e[_0xd48b('0x2a')]){delete _0x15bd0e['name'];}_0x309e72[_0xd48b('0x1c')](_0x22174a)[_0xd48b('0x2b')](_0x15bd0e);};}function iftimePromise(_0x1efd03,_0x107f91){return respondWithRpcPromise(_0xd48b('0x2c'),'getSnippet',{'command':_0x107f91[_0xd48b('0x2d')]?util[_0xd48b('0x2e')](_0xd48b('0x2f'),_0x1efd03[_0xd48b('0x30')],_0x107f91[_0xd48b('0x2d')]):util['format']('iftime\x20%s',_0x1efd03[_0xd48b('0x30')])},client9002)[_0xd48b('0x11')](function(_0x383d76){var _0x45a0df=_0x383d76&&_0x383d76[_0xd48b('0x31')](_0xd48b('0x32'))>=0x0?!![]:![];logger[_0xd48b('0x12')](_0xd48b('0x33'),_0x107f91['id'],_0x1efd03['id'],_0x1efd03[_0xd48b('0x30')],_0x45a0df?'ONLINE':_0xd48b('0x34'),_0x107f91['timezone']?_0x107f91[_0xd48b('0x2d')]:_0xd48b('0x35'));return _0x45a0df;})[_0xd48b('0x1b')](function(_0x1b7f0f){logger['error'](_0xd48b('0x33'),_0x107f91['id'],_0x1efd03['id'],_0x1efd03[_0xd48b('0x30')],util[_0xd48b('0x36')](_0x1b7f0f,{'showHidden':![],'depth':null}),_0x107f91[_0xd48b('0x2d')]?_0x107f91['timezone']:_0xd48b('0x35'));return![];});}function checkWebsiteIntervals(_0x5ae8b1){var _0x5e1cb4=_[_0xd48b('0x37')](_0x5ae8b1['Interval'][_0xd48b('0x38')],function(_0x50dba5){var _0x20b4cf=_0x50dba5[_0xd48b('0x39')]({'plain':!![]});return iftimePromise(_0x20b4cf,_0x5ae8b1);});return Promise[_0xd48b('0x3a')](_0x5e1cb4)[_0xd48b('0x11')](function(_0x44f7c9){return _[_0xd48b('0x3b')](_0x44f7c9);});}function createInteractionObject(_0x20f717,_0x1f069f,_0x5a71e7,_0x10a9ea){var _0x4d470a=require(_0xd48b('0x3c'));var _0x4f5e18=new _0x4d470a();var _0x467b66=_0x4f5e18[_0xd48b('0x3d')](_0x5a71e7[_0xd48b('0x3e')])[_0xd48b('0x3f')]();var _0xd75c90=_0x1f069f[_0xd48b('0x40')];if(_0x5a71e7[_0xd48b('0x41')]){_0xd75c90=_0x5a71e7['cf-connecting-ip'];}else if(_0x5a71e7[_0xd48b('0x42')]){_0xd75c90=_[_0xd48b('0x43')](_0x5a71e7[_0xd48b('0x42')][_0xd48b('0x44')](','));}return{'ContactId':_0x10a9ea['id'],'ChatWebsiteId':_0x20f717,'from':(_0x10a9ea[_0xd48b('0x45')]||'')+'\x20'+(_0x10a9ea[_0xd48b('0x46')]||''),'customerIp':_0xd75c90,'customerPort':_0x5a71e7[_0xd48b('0x47')]?_0x5a71e7[_0xd48b('0x47')]:null,'referer':_0x1f069f['referer'],'browserName':_0x467b66[_0xd48b('0x48')][_0xd48b('0x2a')]&&_0x467b66[_0xd48b('0x48')][_0xd48b('0x49')]?util[_0xd48b('0x2e')](_0xd48b('0x4a'),_0x467b66[_0xd48b('0x48')][_0xd48b('0x2a')],_0x467b66['browser']['version']):_0xd48b('0x4b'),'browserVersion':_0x467b66[_0xd48b('0x48')]['version']||_0xd48b('0x4b'),'osName':util[_0xd48b('0x2e')](_0xd48b('0x4a'),_0x467b66['os'][_0xd48b('0x2a')],_0x467b66['os'][_0xd48b('0x49')]),'osVersion':_0x467b66['os'][_0xd48b('0x49')],'deviceModel':_0x467b66[_0xd48b('0x4c')][_0xd48b('0x4d')]&&_0x467b66['device'][_0xd48b('0x4e')]?util['format'](_0xd48b('0x4f'),_0x467b66[_0xd48b('0x4c')]['model'],_0x467b66['device'][_0xd48b('0x4e')],_0x467b66[_0xd48b('0x4c')][_0xd48b('0x50')]):null,'deviceVendor':_0x467b66[_0xd48b('0x4c')][_0xd48b('0x4e')],'deviceType':_0x467b66[_0xd48b('0x4c')][_0xd48b('0x50')],'formData':JSON['stringify'](_0x1f069f)};}exports['index']=function(_0x1d56c1,_0x202b00){var _0x360f38={'include':[{'model':db[_0xd48b('0x51')],'as':_0xd48b('0x52')}]},_0x1d9666={},_0x57ed82={'count':0x0,'rows':[]};var _0x54f526=_[_0xd48b('0x37')](db[_0xd48b('0x53')][_0xd48b('0x54')],function(_0x2e0b94){return{'name':_0x2e0b94[_0xd48b('0x55')],'type':_0x2e0b94[_0xd48b('0x50')][_0xd48b('0x56')]};});_0x1d9666['model']=_[_0xd48b('0x37')](_0x54f526,'name');_0x1d9666[_0xd48b('0x57')]=_[_0xd48b('0x58')](_0x1d56c1[_0xd48b('0x57')]);_0x1d9666['filters']=_[_0xd48b('0x59')](_0x1d9666[_0xd48b('0x4d')],_0x1d9666[_0xd48b('0x57')]);_0x360f38[_0xd48b('0x5a')]=_[_0xd48b('0x59')](_0x1d9666[_0xd48b('0x4d')],qs['fields'](_0x1d56c1[_0xd48b('0x57')][_0xd48b('0x5b')]));_0x360f38[_0xd48b('0x5a')]=_0x360f38['attributes'][_0xd48b('0x5c')]?_0x360f38['attributes']:_0x1d9666[_0xd48b('0x4d')];if(!_0x1d56c1[_0xd48b('0x57')][_0xd48b('0x5d')](_0xd48b('0x5e'))){_0x360f38[_0xd48b('0x20')]=qs[_0xd48b('0x20')](_0x1d56c1[_0xd48b('0x57')]['limit']);_0x360f38[_0xd48b('0x1e')]=qs[_0xd48b('0x1e')](_0x1d56c1[_0xd48b('0x57')][_0xd48b('0x1e')]);}_0x360f38[_0xd48b('0x5f')]=qs[_0xd48b('0x60')](_0x1d56c1[_0xd48b('0x57')][_0xd48b('0x60')]);_0x360f38[_0xd48b('0x61')]=qs[_0xd48b('0x62')](_[_0xd48b('0x63')](_0x1d56c1[_0xd48b('0x57')],_0x1d9666['filters']),_0x54f526);if(_0x1d56c1['query'][_0xd48b('0x64')]){_0x360f38['where']=_[_0xd48b('0x65')](_0x360f38['where'],{'$or':_[_0xd48b('0x37')](_0x54f526,function(_0xf449c0){if(_0xf449c0[_0xd48b('0x50')]!=='VIRTUAL'){var _0x4acea1={};_0x4acea1[_0xf449c0[_0xd48b('0x2a')]]={'$like':'%'+_0x1d56c1['query'][_0xd48b('0x64')]+'%'};return _0x4acea1;}})});}_0x360f38=_['merge']({},_0x360f38,_0x1d56c1[_0xd48b('0x66')]);var _0x17f370={'where':_0x360f38[_0xd48b('0x61')]};return db['ChatWebsite'][_0xd48b('0x21')](_0x17f370)[_0xd48b('0x11')](function(_0x1272ef){_0x57ed82[_0xd48b('0x21')]=_0x1272ef;if(_0x1d56c1[_0xd48b('0x57')][_0xd48b('0x67')]){_0x360f38[_0xd48b('0x68')]=[{'all':!![]}];}return db[_0xd48b('0x53')][_0xd48b('0x69')](_0x360f38);})[_0xd48b('0x11')](function(_0x713520){_0x57ed82[_0xd48b('0x6a')]=_0x713520;return _0x57ed82;})[_0xd48b('0x11')](respondWithFilteredResult(_0x202b00,_0x360f38))['catch'](handleError(_0x202b00,null));};exports['show']=function(_0x37a685,_0x134520){var _0x41fbdf={'raw':![],'where':{'id':_0x37a685['params']['id']},'include':[{'model':db['Pause'],'as':_0xd48b('0x52')}]},_0x2b1c07={};_0x2b1c07[_0xd48b('0x4d')]=_['keys'](db['ChatWebsite']['rawAttributes']);_0x2b1c07[_0xd48b('0x57')]=_[_0xd48b('0x58')](_0x37a685['query']);_0x2b1c07['filters']=_[_0xd48b('0x59')](_0x2b1c07[_0xd48b('0x4d')],_0x2b1c07[_0xd48b('0x57')]);_0x41fbdf['attributes']=_[_0xd48b('0x59')](_0x2b1c07[_0xd48b('0x4d')],qs['fields'](_0x37a685[_0xd48b('0x57')][_0xd48b('0x5b')]));_0x41fbdf[_0xd48b('0x5a')]=_0x41fbdf[_0xd48b('0x5a')]['length']?_0x41fbdf[_0xd48b('0x5a')]:_0x2b1c07[_0xd48b('0x4d')];if(_0x37a685['query']['includeAll']){_0x41fbdf[_0xd48b('0x68')]=[{'all':!![]}];}_0x41fbdf=_[_0xd48b('0x65')]({},_0x41fbdf,_0x37a685[_0xd48b('0x66')]);return db['ChatWebsite'][_0xd48b('0x6b')](_0x41fbdf)[_0xd48b('0x11')](handleEntityNotFound(_0x134520,null))[_0xd48b('0x11')](respondWithResult(_0x134520,null))['catch'](handleError(_0x134520,null));};exports[_0xd48b('0x6c')]=function(_0x351332,_0x2b35b5){return db[_0xd48b('0x53')][_0xd48b('0x6c')](_0x351332[_0xd48b('0x6d')],{})['then'](function(_0x3e4e06){var _0x52f5f9=_0x351332[_0xd48b('0x6e')][_0xd48b('0x39')]({'plain':!![]});if(!_0x52f5f9)throw new Error(_0xd48b('0x6f'));if(_0x52f5f9['role']===_0xd48b('0x6e')){var _0xcc11db=_0x3e4e06['get']({'plain':!![]});var _0x589584='ChatWebsites';return db[_0xd48b('0x70')]['find']({'where':{'name':_0x589584,'userProfileId':_0x52f5f9[_0xd48b('0x71')]},'raw':!![]})[_0xd48b('0x11')](function(_0x4b7362){if(_0x4b7362&&_0x4b7362[_0xd48b('0x72')]===0x0){return db[_0xd48b('0x25')][_0xd48b('0x6c')]({'name':_0xcc11db[_0xd48b('0x2a')],'resourceId':_0xcc11db['id'],'type':_0x4b7362['name'],'sectionId':_0x4b7362['id']},{})[_0xd48b('0x11')](function(){return _0x3e4e06;});}else{return _0x3e4e06;}})[_0xd48b('0x1b')](function(_0x5b8b74){logger[_0xd48b('0x19')](_0xd48b('0x73'),_0x5b8b74);throw _0x5b8b74;});}return _0x3e4e06;})['then'](respondWithResult(_0x2b35b5,0xc9))[_0xd48b('0x1b')](handleError(_0x2b35b5,null));};exports[_0xd48b('0x23')]=function(_0x14b918,_0x56153d){if(_0x14b918[_0xd48b('0x6d')]['id']){delete _0x14b918[_0xd48b('0x6d')]['id'];}return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'where':{'id':_0x14b918[_0xd48b('0x74')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]})[_0xd48b('0x11')](handleEntityNotFound(_0x56153d,null))[_0xd48b('0x11')](saveUpdates(_0x14b918[_0xd48b('0x6d')],null))[_0xd48b('0x11')](respondWithResult(_0x56153d,null))[_0xd48b('0x1b')](handleError(_0x56153d,null));};exports['destroy']=function(_0x138883,_0x40070e){return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'where':{'id':_0x138883[_0xd48b('0x74')]['id']}})['then'](handleEntityNotFound(_0x40070e,null))[_0xd48b('0x11')](removeEntity(_0x40070e,null))[_0xd48b('0x1b')](handleError(_0x40070e,null));};exports[_0xd48b('0x75')]=function(_0x5396c7,_0x43d2d3){return db[_0xd48b('0x53')][_0xd48b('0x75')]()[_0xd48b('0x11')](respondWithResult(_0x43d2d3,null))[_0xd48b('0x1b')](handleError(_0x43d2d3,null));};exports['addDisposition']=function(_0x3e47b4,_0x57f5e0){if(_0x3e47b4[_0xd48b('0x6d')]['id']){delete _0x3e47b4[_0xd48b('0x6d')]['id'];}return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'where':{'id':_0x3e47b4[_0xd48b('0x74')]['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x57f5e0,null))[_0xd48b('0x11')](function(_0x18f423){if(_0x18f423){_0x3e47b4[_0xd48b('0x6d')][_0xd48b('0x76')]=_0x18f423['id'];return db[_0xd48b('0x77')][_0xd48b('0x6c')](_0x3e47b4[_0xd48b('0x6d')]);}})[_0xd48b('0x11')](respondWithResult(_0x57f5e0,null))['catch'](handleError(_0x57f5e0,null));};exports[_0xd48b('0x78')]=function(_0x1952e3,_0x1e3b69){var _0x4c8972={'raw':![],'where':{}};var _0x37fc06={};var _0x3f4c95={'count':0x0,'rows':[]};return db[_0xd48b('0x53')][_0xd48b('0x79')]({'where':{'id':_0x1952e3[_0xd48b('0x74')]['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x1e3b69,null))[_0xd48b('0x11')](function(_0x4ede92){if(_0x4ede92){_0x37fc06['model']=_[_0xd48b('0x58')](db[_0xd48b('0x77')]['rawAttributes']);_0x37fc06[_0xd48b('0x57')]=_[_0xd48b('0x58')](_0x1952e3[_0xd48b('0x57')]);_0x37fc06['filters']=_[_0xd48b('0x59')](_0x37fc06[_0xd48b('0x4d')],_0x37fc06[_0xd48b('0x57')]);_0x4c8972[_0xd48b('0x5a')]=_['intersection'](_0x37fc06[_0xd48b('0x4d')],qs[_0xd48b('0x5b')](_0x1952e3[_0xd48b('0x57')]['fields']));_0x4c8972[_0xd48b('0x5a')]=_0x4c8972[_0xd48b('0x5a')]['length']?_0x4c8972[_0xd48b('0x5a')]:_0x37fc06['model'];if(!_0x1952e3[_0xd48b('0x57')][_0xd48b('0x5d')](_0xd48b('0x5e'))){_0x4c8972[_0xd48b('0x20')]=qs[_0xd48b('0x20')](_0x1952e3[_0xd48b('0x57')][_0xd48b('0x20')]);_0x4c8972[_0xd48b('0x1e')]=qs[_0xd48b('0x1e')](_0x1952e3[_0xd48b('0x57')][_0xd48b('0x1e')]);}_0x4c8972[_0xd48b('0x5f')]=qs[_0xd48b('0x60')](_0x1952e3['query'][_0xd48b('0x60')]);_0x4c8972[_0xd48b('0x61')]=qs[_0xd48b('0x62')](_[_0xd48b('0x63')](_0x1952e3[_0xd48b('0x57')],_0x37fc06[_0xd48b('0x62')]));_0x4c8972[_0xd48b('0x61')][_0xd48b('0x76')]=_0x4ede92['id'];if(_0x1952e3[_0xd48b('0x57')][_0xd48b('0x64')]){_0x4c8972['where']=_['merge'](_0x4c8972[_0xd48b('0x61')],{'$or':_[_0xd48b('0x37')](_0x4c8972[_0xd48b('0x5a')],function(_0x5fcae2){var _0x37c527={};_0x37c527[_0x5fcae2]={'$like':'%'+_0x1952e3['query'][_0xd48b('0x64')]+'%'};return _0x37c527;})});}_0x4c8972=_[_0xd48b('0x65')]({},_0x4c8972,_0x1952e3[_0xd48b('0x66')]);return db[_0xd48b('0x77')][_0xd48b('0x21')]({'where':_0x4c8972[_0xd48b('0x61')]})[_0xd48b('0x11')](function(_0xf9c1aa){_0x3f4c95[_0xd48b('0x21')]=_0xf9c1aa;if(_0x1952e3[_0xd48b('0x57')][_0xd48b('0x67')]){_0x4c8972[_0xd48b('0x68')]=[{'all':!![]}];}return db[_0xd48b('0x77')][_0xd48b('0x69')](_0x4c8972);})[_0xd48b('0x11')](function(_0x311b32){_0x3f4c95['rows']=_0x311b32;return _0x3f4c95;});}})[_0xd48b('0x11')](respondWithFilteredResult(_0x1e3b69,_0x4c8972))[_0xd48b('0x1b')](handleError(_0x1e3b69,null));};exports[_0xd48b('0x7a')]=function(_0x5b3425,_0x24b23f){return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'where':{'id':_0x5b3425[_0xd48b('0x74')]['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x24b23f,null))[_0xd48b('0x11')](function(_0x429046){if(_0x429046){return _0x429046['removeDispositions'](_0x5b3425[_0xd48b('0x57')][_0xd48b('0x7b')]);}})[_0xd48b('0x11')](respondWithStatusCode(_0x24b23f,null))[_0xd48b('0x1b')](handleError(_0x24b23f,null));};exports[_0xd48b('0x7c')]=function(_0x464177,_0x54ddcb){if(_0x464177[_0xd48b('0x6d')]['id']){delete _0x464177['body']['id'];}return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'where':{'id':_0x464177['params']['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x54ddcb,null))[_0xd48b('0x11')](function(_0x2399ca){if(_0x2399ca){_0x464177['body']['ChatWebsiteId']=_0x2399ca['id'];return db['CannedAnswer']['create'](_0x464177['body']);}})[_0xd48b('0x11')](respondWithResult(_0x54ddcb,null))[_0xd48b('0x1b')](handleError(_0x54ddcb,null));};exports[_0xd48b('0x7d')]=function(_0x515d84,_0x375652){var _0x5903ed={'raw':![],'where':{}};var _0x56b543={};var _0x559a5e={'count':0x0,'rows':[]};return db[_0xd48b('0x53')][_0xd48b('0x79')]({'where':{'id':_0x515d84[_0xd48b('0x74')]['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x375652,null))[_0xd48b('0x11')](function(_0xb594c0){if(_0xb594c0){_0x56b543[_0xd48b('0x4d')]=_['keys'](db[_0xd48b('0x7e')]['rawAttributes']);_0x56b543['query']=_['keys'](_0x515d84[_0xd48b('0x57')]);_0x56b543[_0xd48b('0x62')]=_[_0xd48b('0x59')](_0x56b543['model'],_0x56b543[_0xd48b('0x57')]);_0x5903ed[_0xd48b('0x5a')]=_[_0xd48b('0x59')](_0x56b543[_0xd48b('0x4d')],qs[_0xd48b('0x5b')](_0x515d84[_0xd48b('0x57')][_0xd48b('0x5b')]));_0x5903ed[_0xd48b('0x5a')]=_0x5903ed[_0xd48b('0x5a')]['length']?_0x5903ed[_0xd48b('0x5a')]:_0x56b543[_0xd48b('0x4d')];if(!_0x515d84[_0xd48b('0x57')]['hasOwnProperty'](_0xd48b('0x5e'))){_0x5903ed[_0xd48b('0x20')]=qs[_0xd48b('0x20')](_0x515d84['query'][_0xd48b('0x20')]);_0x5903ed[_0xd48b('0x1e')]=qs[_0xd48b('0x1e')](_0x515d84[_0xd48b('0x57')][_0xd48b('0x1e')]);}_0x5903ed[_0xd48b('0x5f')]=qs[_0xd48b('0x60')](_0x515d84[_0xd48b('0x57')][_0xd48b('0x60')]);_0x5903ed['where']=qs[_0xd48b('0x62')](_['pick'](_0x515d84[_0xd48b('0x57')],_0x56b543[_0xd48b('0x62')]));_0x5903ed[_0xd48b('0x61')][_0xd48b('0x76')]=_0xb594c0['id'];if(_0x515d84['query']['filter']){_0x5903ed[_0xd48b('0x61')]=_[_0xd48b('0x65')](_0x5903ed[_0xd48b('0x61')],{'$or':_['map'](_0x5903ed[_0xd48b('0x5a')],function(_0x29d0ef){var _0xa957fb={};_0xa957fb[_0x29d0ef]={'$like':'%'+_0x515d84[_0xd48b('0x57')]['filter']+'%'};return _0xa957fb;})});}_0x5903ed=_[_0xd48b('0x65')]({},_0x5903ed,_0x515d84[_0xd48b('0x66')]);return db['CannedAnswer'][_0xd48b('0x21')]({'where':_0x5903ed[_0xd48b('0x61')]})['then'](function(_0x1b1d68){_0x559a5e[_0xd48b('0x21')]=_0x1b1d68;if(_0x515d84[_0xd48b('0x57')][_0xd48b('0x67')]){_0x5903ed[_0xd48b('0x68')]=[{'all':!![]}];}return db[_0xd48b('0x7e')][_0xd48b('0x69')](_0x5903ed);})[_0xd48b('0x11')](function(_0x4e05df){_0x559a5e[_0xd48b('0x6a')]=_0x4e05df;return _0x559a5e;});}})[_0xd48b('0x11')](respondWithFilteredResult(_0x375652,_0x5903ed))[_0xd48b('0x1b')](handleError(_0x375652,null));};exports[_0xd48b('0x7f')]=function(_0x3a434f,_0x2f367b){return db['ChatWebsite']['find']({'where':{'id':_0x3a434f['params']['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x2f367b,null))['then'](function(_0xbbb85c){if(_0xbbb85c){return _0xbbb85c[_0xd48b('0x7f')](_0x3a434f[_0xd48b('0x57')][_0xd48b('0x7b')]);}})[_0xd48b('0x11')](respondWithStatusCode(_0x2f367b,null))[_0xd48b('0x1b')](handleError(_0x2f367b,null));};exports[_0xd48b('0x80')]=function(_0x52616f,_0x10cc61){_0x52616f[_0xd48b('0x6d')][_0xd48b('0x81')]=_0x52616f[_0xd48b('0x82')][_0xd48b('0x83')];return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'where':{'id':_0x52616f['params']['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x10cc61,null))[_0xd48b('0x11')](saveUpdates(_0x52616f[_0xd48b('0x6d')],null))[_0xd48b('0x11')](respondWithResult(_0x10cc61,null))[_0xd48b('0x1b')](handleError(_0x10cc61,null));};exports[_0xd48b('0x84')]=function(_0x4deaac,_0x4a855a){_0x4deaac[_0xd48b('0x6d')]['agentAvatar']=_0x4deaac[_0xd48b('0x82')]['filename'];return db['ChatWebsite'][_0xd48b('0x6b')]({'where':{'id':_0x4deaac[_0xd48b('0x74')]['id']}})['then'](handleEntityNotFound(_0x4a855a,null))[_0xd48b('0x11')](saveUpdates(_0x4deaac['body'],null))[_0xd48b('0x11')](respondWithResult(_0x4a855a,null))[_0xd48b('0x1b')](handleError(_0x4a855a,null));};exports[_0xd48b('0x85')]=function(_0x30f296,_0x3cf637){_0x30f296['body'][_0xd48b('0x86')]=_0x30f296[_0xd48b('0x82')][_0xd48b('0x83')];return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'where':{'id':_0x30f296[_0xd48b('0x74')]['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x3cf637,null))[_0xd48b('0x11')](saveUpdates(_0x30f296['body'],null))[_0xd48b('0x11')](respondWithResult(_0x3cf637,null))[_0xd48b('0x1b')](handleError(_0x3cf637,null));};exports[_0xd48b('0x87')]=function(_0x120d21,_0x390b3e){_0x120d21[_0xd48b('0x6d')]['systemAvatar']=_0x120d21[_0xd48b('0x82')][_0xd48b('0x83')];return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'where':{'id':_0x120d21[_0xd48b('0x74')]['id']}})['then'](handleEntityNotFound(_0x390b3e,null))[_0xd48b('0x11')](saveUpdates(_0x120d21[_0xd48b('0x6d')],null))['then'](respondWithResult(_0x390b3e,null))[_0xd48b('0x1b')](handleError(_0x390b3e,null));};exports['getLogo']=function(_0x1f23d8,_0xaabafc){var _0x41c247=path[_0xd48b('0x88')](config[_0xd48b('0x89')],'server/files/images/logos/default_logo.svg');var _0x8c95d2={'where':{'id':_0x1f23d8[_0xd48b('0x74')]['id']},'attributes':['id',_0xd48b('0x81')],'raw':!![]};var _0x3db349=![];return require(_0xd48b('0x8a'))[_0xd48b('0x8b')]()[_0xd48b('0x11')](function(_0x323a9c){if(_0x323a9c){_0x3db349=_0x323a9c[_0xd48b('0x8c')];}})[_0xd48b('0x11')](function(){return db[_0xd48b('0x53')][_0xd48b('0x6b')](_0x8c95d2);})[_0xd48b('0x11')](handleEntityNotFound(_0xaabafc,null))[_0xd48b('0x11')](function(_0x26ec33){if(_0x26ec33){if(!_[_0xd48b('0x8d')](_0x26ec33[_0xd48b('0x81')])){if(fs[_0xd48b('0x8e')](path[_0xd48b('0x88')](config[_0xd48b('0x89')],_0xd48b('0x8f'),_0x26ec33[_0xd48b('0x81')]))&&_0x3db349){_0x41c247=path[_0xd48b('0x88')](config[_0xd48b('0x89')],_0xd48b('0x8f'),_0x26ec33[_0xd48b('0x81')]);}}return _0xaabafc['download'](_0x41c247);}})[_0xd48b('0x1b')](handleError(_0xaabafc,null));};exports['getAvatar']=function(_0x5af935,_0x493927){var _0x525504=path[_0xd48b('0x88')](config[_0xd48b('0x89')],'server/files/images/avatars/default_avatar.png');var _0x46ee86={'where':{'id':_0x5af935[_0xd48b('0x74')]['id']},'attributes':['id',_0xd48b('0x90')],'raw':!![]};return db[_0xd48b('0x53')][_0xd48b('0x6b')](_0x46ee86)['then'](handleEntityNotFound(_0x493927,null))[_0xd48b('0x11')](function(_0x43ec32){if(_0x43ec32){if(!_[_0xd48b('0x8d')](_0x43ec32['agentAvatar'])){if(fs[_0xd48b('0x8e')](path[_0xd48b('0x88')](config[_0xd48b('0x89')],_0xd48b('0x91'),_0x43ec32[_0xd48b('0x90')]))){_0x525504=path[_0xd48b('0x88')](config['root'],'server/files/images/avatars/',_0x43ec32[_0xd48b('0x90')]);}}return _0x493927['download'](_0x525504);}})[_0xd48b('0x1b')](handleError(_0x493927,null));};exports[_0xd48b('0x92')]=function(_0x4bbaed,_0x5e9911){var _0x4ca6b9=path[_0xd48b('0x88')](config[_0xd48b('0x89')],_0xd48b('0x93'));var _0x4a3df7={'where':{'id':_0x4bbaed[_0xd48b('0x74')]['id']},'attributes':['id',_0xd48b('0x86'),_0xd48b('0x94')],'raw':!![]};return db['ChatWebsite'][_0xd48b('0x6b')](_0x4a3df7)[_0xd48b('0x11')](handleEntityNotFound(_0x5e9911,null))[_0xd48b('0x11')](function(_0x2bc4b6){if(_0x2bc4b6){if(!_[_0xd48b('0x8d')](_0x2bc4b6[_0xd48b('0x86')])){if(fs['existsSync'](path[_0xd48b('0x88')](config[_0xd48b('0x89')],'server/files/images/avatars/',_0x2bc4b6[_0xd48b('0x86')]))&&_0x2bc4b6[_0xd48b('0x94')]){_0x4ca6b9=path[_0xd48b('0x88')](config[_0xd48b('0x89')],_0xd48b('0x91'),_0x2bc4b6[_0xd48b('0x86')]);}}return _0x5e9911[_0xd48b('0x95')](_0x4ca6b9);}})[_0xd48b('0x1b')](handleError(_0x5e9911,null));};exports[_0xd48b('0x96')]=function(_0x3fe82c,_0x1a38d1){var _0x3723a5=path['join'](config[_0xd48b('0x89')],_0xd48b('0x97'));var _0x383b66={'where':{'id':_0x3fe82c[_0xd48b('0x74')]['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db[_0xd48b('0x53')][_0xd48b('0x6b')](_0x383b66)[_0xd48b('0x11')](handleEntityNotFound(_0x1a38d1,null))['then'](function(_0xeb1adc){if(_0xeb1adc){if(!_[_0xd48b('0x8d')](_0xeb1adc[_0xd48b('0x98')])){if(fs[_0xd48b('0x8e')](path[_0xd48b('0x88')](config[_0xd48b('0x89')],_0xd48b('0x91'),_0xeb1adc[_0xd48b('0x98')]))){_0x3723a5=path[_0xd48b('0x88')](config[_0xd48b('0x89')],_0xd48b('0x91'),_0xeb1adc['systemAvatar']);}}return _0x1a38d1[_0xd48b('0x95')](_0x3723a5);}})['catch'](handleError(_0x1a38d1,null));};exports[_0xd48b('0x99')]=function(_0x103120,_0xbc33f3){var _0x4b94fe={'body':_0x103120[_0xd48b('0x6d')],'channel':_0xd48b('0x9a')};var _0x492cf9=[];var _0x4dfcef=[];var _0x1fe144={};var _0x2b2120=![];return db[_0xd48b('0x9b')][_0xd48b('0x75')]()[_0xd48b('0x11')](function(_0x47bfda){if(!_0x47bfda){throw new db[(_0xd48b('0x9c'))][(_0xd48b('0x9d'))]('no\x20available\x20attributes');}_0x492cf9=_[_0xd48b('0x9e')](_[_0xd48b('0x58')](_0x47bfda),[_0xd48b('0x9f'),_0xd48b('0xa0')]);_0x4dfcef=_[_0xd48b('0x9e')](_[_0xd48b('0x58')](_0x47bfda),[_0xd48b('0x9f'),_0xd48b('0xa0'),_0xd48b('0xa1'),'ListId']);if(_0x103120[_0xd48b('0x6d')]['id']){delete _0x103120[_0xd48b('0x6d')]['id'];}if(_[_0xd48b('0x8d')](_0x103120[_0xd48b('0x6d')][_0xd48b('0xa2')])){throw new db['Sequelize'][(_0xd48b('0x9d'))]('from\x20is\x20mandatory');}if(_[_0xd48b('0x8d')](_0x103120[_0xd48b('0x6d')][_0xd48b('0x6d')])||_0x103120[_0xd48b('0x6d')][_0xd48b('0x6d')]===''){throw new db[(_0xd48b('0x9c'))][(_0xd48b('0x9d'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0xd48b('0x8d')](_0x103120['body'][_0xd48b('0xa3')])){throw new db[(_0xd48b('0x9c'))]['ValidationError']('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4dfcef);}if(!_[_0xd48b('0xa4')](_0x4dfcef,_0x103120[_0xd48b('0x6d')][_0xd48b('0xa3')])){throw new db['Sequelize'][(_0xd48b('0x9d'))](_0xd48b('0xa5')+_0x4dfcef);}_0x1fe144[_0x103120[_0xd48b('0x6d')]['mapKey']]=_0x103120[_0xd48b('0x6d')][_0xd48b('0xa2')];})[_0xd48b('0x11')](function(){return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'where':{'id':_0x103120[_0xd48b('0x74')]['id']},'include':[{'model':db['CmList'],'as':_0xd48b('0xa6'),'include':[{'model':db['CmContact'],'as':'Contacts','where':_0x1fe144,'limit':0x1,'order':[['updatedAt',_0xd48b('0xa7')]]}]},{'model':db[_0xd48b('0xa8')],'as':_0xd48b('0xa9')},{'model':db[_0xd48b('0xaa')],'as':_0xd48b('0xaa'),'include':[{'model':db['Interval'],'as':_0xd48b('0x38'),'attributes':['id',_0xd48b('0x30')],'raw':!![]}]}]});})['then'](function(_0x366a12){if(!_0x366a12)throw new APINotFoundError(util[_0xd48b('0x2e')](_0xd48b('0xab'),_0x103120[_0xd48b('0x74')]['id']));if(!_0x366a12[_0xd48b('0xaa')]||!_0x366a12[_0xd48b('0xaa')][_0xd48b('0x38')])return[_0x366a12,!![]];return[_0x366a12,checkWebsiteIntervals(_0x366a12)];})['spread'](function(_0x2f6203,_0x5c9b28){if(!_0x5c9b28)throw new APIOutOfIntervalError();if(!_0x2f6203[_0xd48b('0xa6')])return;_0x4b94fe[_0xd48b('0xac')]=_0x2f6203;_0x4b94fe['list']=_0x2f6203[_0xd48b('0xa6')];_0x4b94fe[_0xd48b('0xad')]=_['orderBy'](_0x2f6203[_0xd48b('0xa9')],[_0xd48b('0xae')],[_0xd48b('0xaf')]);if(_0x4b94fe[_0xd48b('0xac')][_0xd48b('0xa9')]){delete _0x4b94fe[_0xd48b('0xac')][_0xd48b('0xa9')];}if(_0x4b94fe[_0xd48b('0xac')][_0xd48b('0xa6')]&&_0x4b94fe[_0xd48b('0xac')][_0xd48b('0xa6')][_0xd48b('0xb0')]['length']){return _0x4b94fe[_0xd48b('0xac')][_0xd48b('0xa6')][_0xd48b('0xb0')][0x0];}var _0x33b1f4=_[_0xd48b('0xb1')](_0x103120[_0xd48b('0x6d')],{'firstName':_0x103120[_0xd48b('0x6d')][_0xd48b('0xa2')],'ListId':_0x2f6203[_0xd48b('0xb2')]});_0x33b1f4[_0x103120[_0xd48b('0x6d')][_0xd48b('0xa3')]]=_0x103120[_0xd48b('0x6d')][_0xd48b('0xa2')];return db[_0xd48b('0x9b')]['create'](_0x33b1f4,{'fields':_0x492cf9,'raw':!![]});})[_0xd48b('0x11')](function(_0x5f4400){_0x4b94fe[_0xd48b('0xb3')]=_0x5f4400;var _0x36df0d=createInteractionObject(_0x103120['params']['id'],_0x103120[_0xd48b('0x6d')],_0x103120[_0xd48b('0xb4')],_0x5f4400);var _0x31d3c6={'ChatWebsiteId':_0x103120[_0xd48b('0x74')]['id'],'closed':![]};if(_0x103120[_0xd48b('0x6d')][_0xd48b('0xb5')]){_0x31d3c6[_0xd48b('0xb5')]=_0x103120[_0xd48b('0x6d')][_0xd48b('0xb5')];return db[_0xd48b('0xb6')][_0xd48b('0x6b')]({'where':_0x31d3c6})[_0xd48b('0x11')](function(_0x4ed236){if(_0x4ed236){_0x2b2120=!![];return _0x4ed236;}_0x36df0d[_0xd48b('0xb5')]=_0x103120[_0xd48b('0x6d')]['threadId'];_0x36df0d['externalUrl']=_0x103120[_0xd48b('0x6d')]['externalUrl'];return db[_0xd48b('0xb6')]['create'](_0x36df0d);});}_0x31d3c6[_0xd48b('0xb7')]=_0x5f4400['id'];if(_0x103120[_0xd48b('0x6d')][_0xd48b('0xb8')]&&_0x103120[_0xd48b('0x6d')][_0xd48b('0xb8')]['id']){_0x31d3c6['id']=_0x103120[_0xd48b('0x6d')]['interaction']['id'];return db[_0xd48b('0xb6')][_0xd48b('0x6b')]({'where':_0x31d3c6})[_0xd48b('0x11')](function(_0x32635f){if(_0x32635f){_0x2b2120=!![];return _0x32635f;}return db[_0xd48b('0xb6')]['create'](_0x36df0d);});}return db[_0xd48b('0xb6')][_0xd48b('0x6c')](_0x36df0d);})[_0xd48b('0x11')](function(_0x27bb82){if(!_0x2b2120)return _0x27bb82;var _0x12c8ed={'from':(_0x4b94fe[_0xd48b('0xb3')][_0xd48b('0x45')]||'')+'\x20'+(_0x4b94fe[_0xd48b('0xb3')]['lastName']||'')};if(_0x103120[_0xd48b('0x6d')][_0xd48b('0xb5')]&&_0x103120['body'][_0xd48b('0xb9')]&&_0x103120['body']['threadId']!=_0x103120[_0xd48b('0x6d')][_0xd48b('0xb9')]){_0x12c8ed['threadId']=_0x103120[_0xd48b('0x6d')]['messageId'];}return _0x27bb82[_0xd48b('0x23')](_0x12c8ed);})['then'](function(_0x1d626b){_0x4b94fe[_0xd48b('0xb8')]=_0x1d626b[_0xd48b('0x39')]({'plain':!![]});_0x4b94fe[_0xd48b('0xb8')][_0xd48b('0xba')]=!_0x2b2120;if(_0x4b94fe[_0xd48b('0xb8')][_0xd48b('0xba')]){if(_0x4b94fe['account'][_0xd48b('0xbb')]){_0x4b94fe[_0xd48b('0xad')][_0xd48b('0xbc')]({'id':0x0,'priority':_0x4b94fe[_0xd48b('0xad')]['length']+0x1,'app':'close','appdata':_0xd48b('0xbd'),'interval':'*,*,*,*'});}}return db[_0xd48b('0xbe')][_0xd48b('0x6c')]({'body':_0x103120[_0xd48b('0x6d')]['body'],'ChatWebsiteId':_0x103120[_0xd48b('0x74')]['id'],'ChatInteractionId':_0x1d626b['id'],'direction':'in','ContactId':_0x4b94fe['contact']['id'],'AttachmentId':_0x103120[_0xd48b('0x6d')][_0xd48b('0xbf')]});})[_0xd48b('0x11')](function(_0x49ec36){_0x4b94fe[_0xd48b('0x1a')]=_0x49ec36;if(!_0x4b94fe['interaction'][_0xd48b('0xc0')]){return;}return db['User'][_0xd48b('0x6b')]({'attributes':['id','name'],'where':{'id':_0x4b94fe[_0xd48b('0xb8')]['UserId']}});})[_0xd48b('0x11')](function(_0x56e94a){if(_0x56e94a){_0x4b94fe[_0xd48b('0xad')][_0xd48b('0xc1')]({'id':0x0,'priority':0x0,'app':_0xd48b('0xc2'),'appdata':_0x56e94a['name']+','+(_0x4b94fe['account'][_0xd48b('0xc3')]||0xa),'interval':'*,*,*,*'});_0x4b94fe['forcedOwnership']=!![];}if(!_0x4b94fe[_0xd48b('0xb8')]['queueId']){return;}return db['ChatQueue']['find']({'attributes':['id','name'],'where':{'id':_0x4b94fe[_0xd48b('0xb8')][_0xd48b('0xc4')]}});})['then'](function(_0x1fce74){if(_0x1fce74){_0x4b94fe[_0xd48b('0xad')][_0xd48b('0xc1')]({'id':0x0,'priority':0x1,'app':_0xd48b('0xc5'),'appdata':_0x1fce74['name']+','+(_0x4b94fe['account'][_0xd48b('0xc6')]||0x12c),'interval':_0xd48b('0xc7')});}return respondWithRpcPromise('Start',_0xd48b('0xc8'),_0x4b94fe);})[_0xd48b('0x11')](function(_0x3dc8ae){respondWithRpcPromise(_0xd48b('0xc9'),_0xd48b('0xc9'),{'event':_0xd48b('0x99'),'message':_0x3dc8ae},client9002);return _0x3dc8ae;})['then'](respondWithResult(_0xbc33f3,null))['catch'](APIHandleError(_0xbc33f3));};exports['offline']=function(_0x5dd0c2,_0x186e9b){var _0x1a9471,_0x4f0028,_0x4650b7;var _0xf70d24=[];var _0x3f7ed0={};var _0x1d1f19=_0x5dd0c2[_0xd48b('0xca')]||[];var _0xde15bb=[];var _0x3f0402;return db['CmContact'][_0xd48b('0x75')]()['then'](function(_0x3f43a7){if(!_0x3f43a7){throw new db[(_0xd48b('0x9c'))][(_0xd48b('0x9d'))](_0xd48b('0xcb'));}_0xf70d24=_[_0xd48b('0x9e')](_['keys'](_0x3f43a7),[_0xd48b('0x9f'),_0xd48b('0xa0'),_0xd48b('0xa1'),_0xd48b('0xb2')]);if(_0x5dd0c2['body']['id']){delete _0x5dd0c2[_0xd48b('0x6d')]['id'];}if(_['isNil'](_0x5dd0c2['body'][_0xd48b('0xa2')])){throw _0x186e9b[_0xd48b('0x1c')](0x1f4)[_0xd48b('0x2b')](new db[(_0xd48b('0x9c'))][(_0xd48b('0x9d'))](_0xd48b('0xcc')));}if(_['isNil'](_0x5dd0c2[_0xd48b('0x6d')]['body'])||_0x5dd0c2['body'][_0xd48b('0x6d')]===''){throw _0x186e9b[_0xd48b('0x1c')](0x1f4)[_0xd48b('0x2b')](new db[(_0xd48b('0x9c'))][(_0xd48b('0x9d'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0xd48b('0x8d')](_0x5dd0c2['body']['mapKeyOffline'])){throw _0x186e9b[_0xd48b('0x1c')](0x1f4)['send'](new db[(_0xd48b('0x9c'))]['ValidationError']('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0xf70d24));}if(!_[_0xd48b('0xa4')](_0xf70d24,_0x5dd0c2[_0xd48b('0x6d')][_0xd48b('0xcd')])){throw _0x186e9b[_0xd48b('0x1c')](0x1f4)[_0xd48b('0x2b')](new db[(_0xd48b('0x9c'))]['ValidationError'](_0xd48b('0xce')+_0xf70d24));}_0x3f7ed0[_0x5dd0c2['body'][_0xd48b('0xcd')]]=_0x5dd0c2[_0xd48b('0x6d')][_0xd48b('0xa2')];})[_0xd48b('0x11')](function(){return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'where':{'id':_0x5dd0c2[_0xd48b('0x74')]['id']},'include':[{'model':db[_0xd48b('0xcf')],'as':_0xd48b('0xa6')},{'model':db[_0xd48b('0xd0')],'as':_0xd48b('0xd0')}]});})[_0xd48b('0x11')](handleEntityNotFound(_0x186e9b,null))[_0xd48b('0x11')](function(_0x83c837){if(_0x83c837&&_0x83c837[_0xd48b('0xa6')]){_0x4f0028=_0x83c837;var _0x366b9f=_[_0xd48b('0xb1')](_0x5dd0c2[_0xd48b('0x6d')],{'firstName':_0x5dd0c2[_0xd48b('0x6d')][_0xd48b('0xa2')],'phone':_0x5dd0c2[_0xd48b('0x6d')][_0xd48b('0xa2')],'ListId':_0x83c837[_0xd48b('0xb2')]});_0x366b9f[_0x5dd0c2['body'][_0xd48b('0xcd')]]=_0x5dd0c2[_0xd48b('0x6d')]['from'];return db[_0xd48b('0x9b')][_0xd48b('0xd1')]({'where':_0x3f7ed0,'defaults':_0x366b9f});}})['spread'](function(_0x39e4d1){if(_0x39e4d1){_0x4650b7=_0x39e4d1;var _0x29b2e5=fs[_0xd48b('0xd2')](path[_0xd48b('0x88')](config[_0xd48b('0x89')],_0xd48b('0xd3')),'utf8');var _0x3c3954=ejs[_0xd48b('0xd4')](_0x29b2e5,{'body':_[_0xd48b('0xd5')](_0x5dd0c2[_0xd48b('0x6d')]['body']),'bodyTitle':_0x4f0028[_0xd48b('0xd6')]});return db[_0xd48b('0xd7')][_0xd48b('0x6c')]({'body':_0x3c3954,'plainBody':htmlToText[_0xd48b('0xd8')](_0x3c3954),'ContactId':_0x39e4d1['id'],'ChatWebsiteId':_0x4f0028['id']});}})[_0xd48b('0x11')](function(_0x369d15){_0x3f0402=_0x369d15;if(_0x1d1f19[_0xd48b('0x5c')]){var _0x52c920=_0x1d1f19[_0xd48b('0x37')](function(_0x1a084b){return{'name':_0x1a084b['originalname'],'basename':_0x1a084b['filename'],'type':_0x1a084b['mimetype'],'ChatOfflineMessageId':_0x369d15['id']};});_0xde15bb=_0x52c920[_0xd48b('0x37')](_0x160c89=>{var _0x4d7883={'filename':_0x160c89[_0xd48b('0x2a')],'path':path[_0xd48b('0x88')](config['root'],_0xd48b('0xd9'),'files',_0xd48b('0xda'),_0xd48b('0xdb'),_0x160c89['basename'])};return _0x4d7883;});if(!_0x4f0028[_0xd48b('0xdc')]){return db['sequelize'][_0xd48b('0xdd')](function(_0x46f806){return db[_0xd48b('0xde')][_0xd48b('0xdf')](_0x52c920,{'transaction':_0x46f806});});}}})[_0xd48b('0x11')](function(){if(_0x3f0402){_0x1a9471=_0x3f0402;return db[_0xd48b('0xd0')][_0xd48b('0x79')]({'where':{'service':!![]},'include':[{'model':db[_0xd48b('0xe0')],'as':_0xd48b('0xe1'),'raw':!![],'include':[{'model':db[_0xd48b('0xe2')],'as':'CloudProvider','raw':!![]}]}]});}})[_0xd48b('0x11')](function(_0x1949e2){if(_0x1949e2&&_0x1949e2['Smtp']&&_0x4f0028[_0xd48b('0xe3')]&&_0x4f0028[_0xd48b('0xe4')]){var _0x62c640=_0x1949e2['getSmtpOptions']();return respondWithRpcPromise(_0xd48b('0xe5'),'sendMail',{'account':_0x62c640,'message':{'from':util[_0xd48b('0x2e')](_0xd48b('0xe6'),_0x1949e2[_0xd48b('0x2a')],_0x1949e2[_0xd48b('0xe7')]||_0x1949e2['Smtp'][_0xd48b('0x6e')]),'to':_0x4f0028[_0xd48b('0xe4')],'subject':_0x4f0028['offlineMessageSubject'],'html':_0x1a9471[_0xd48b('0x6d')],'attachments':_0xde15bb}},client9003)[_0xd48b('0x11')](function(){return _0x1a9471;})[_0xd48b('0x1b')](function(_0x24a887){logger[_0xd48b('0x19')](_0x24a887);});}})[_0xd48b('0x11')](function(){if(_0x4f0028&&_0x4f0028['openNewInteraction']&&_0x4f0028['MailAccountId']){var _0x521d2e=[];if(_0x1d1f19['length']){_0x521d2e=_0x1d1f19[_0xd48b('0x37')](function(_0xa7d8a2){return{'name':_0xa7d8a2[_0xd48b('0xe8')],'basename':_0xa7d8a2[_0xd48b('0x83')],'type':_0xa7d8a2['mimetype'],'ChatOfflineMessageId':_0x3f0402['id']};});}var _0x6ce85a;if(!_[_0xd48b('0x8d')](_0x4f0028[_0xd48b('0xe9')])){var _0x134626=_[_0xd48b('0x37')](_0x5dd0c2[_0xd48b('0x6d')],function(_0x59e8cb){return _0x59e8cb;});var _0x27d71d=_['toPairsIn'](_0x134626)[0x0];var _0x1008f5=_[_0xd48b('0xea')](_0x27d71d,function(_0x45e944){return _0x45e944;});_0x6ce85a=_0x1008f5[0x1][_0x4f0028['subjectOffline']];}var _0x36494c={'from':_0x4650b7[_0xd48b('0xe7')],'firstName':_0x4650b7['firstName'],'lastName':_0x4650b7[_0xd48b('0x46')],'mapKey':'email','message':{'from':_0x4650b7[_0xd48b('0xe7')],'to':_0x4f0028[_0xd48b('0xd0')][_0xd48b('0xe7')],'cc':'','subject':_[_0xd48b('0x8d')](_0x6ce85a)?_0x4f0028[_0xd48b('0xeb')]:_0x6ce85a,'messageId':'','sentAt':new Date(),'attach':_0x521d2e[_0xd48b('0x5c')],'attachments':_0x521d2e,'originChannel':_0xd48b('0xec'),'ChatWebsiteId':_0x4f0028['id'],'ChatOfflineMessageId':_0x1a9471['id'],'originTo':_0x4f0028[_0xd48b('0xd0')][_0xd48b('0xe7')]},'body':_0x1a9471[_0xd48b('0x6d')]};var _0x4b54ab={'account':{'id':_0x4f0028['MailAccountId']},'body':_0x36494c,'log':_0xd48b('0xed')};return respondWithRpcPromise(_0xd48b('0xed'),_0xd48b('0xee'),_0x4b54ab,client9001)['then'](function(){return _0x1a9471;})[_0xd48b('0x1b')](function(_0x3f1ed){logger['error'](_0x3f1ed);});}return;})['then'](function(){if(_0x1a9471){return _0x1a9471;}})[_0xd48b('0x11')](respondWithResult(_0x186e9b,null))[_0xd48b('0x1b')](function(){for(var _0x2884a2 of _0x1d1f19){var _0x30c7e5=path[_0xd48b('0x88')](config[_0xd48b('0x89')],_0xd48b('0xd9'),_0xd48b('0xca'),_0xd48b('0xda'),_0xd48b('0xdb'),_0x2884a2['filename']);fs_extra[_0xd48b('0xef')](_0x30c7e5)[_0xd48b('0x1b')](function(_0x3e4972){logger[_0xd48b('0x19')](_0xd48b('0xf0'),_0x30c7e5,_0x3e4972);});}});};exports['addInteraction']=function(_0x25baf3,_0x32c47b){return db['ChatInteraction']['find']({'where':{'id':_0x25baf3[_0xd48b('0x74')]['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x32c47b,null))[_0xd48b('0x11')](function(_0x28bb41){if(_0x28bb41){return _0x28bb41[_0xd48b('0xf1')](_0x25baf3[_0xd48b('0x6d')][_0xd48b('0x7b')],_[_0xd48b('0xf2')](_0x25baf3[_0xd48b('0x6d')],[_0xd48b('0x7b'),'id'])||{});}})[_0xd48b('0x11')](respondWithResult(_0x32c47b,null))[_0xd48b('0x1b')](handleError(_0x32c47b,null));};exports['getInteractions']=function(_0x126d7f,_0x268c2f){var _0x704231={'raw':![],'where':{}};var _0x3c3c74={};var _0x410c3f={'count':0x0,'rows':[]};return db[_0xd48b('0x53')]['findOne']({'where':{'id':_0x126d7f[_0xd48b('0x74')]['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x268c2f,null))[_0xd48b('0x11')](function(_0x55018e){if(_0x55018e){_0x3c3c74[_0xd48b('0x4d')]=_['keys'](db[_0xd48b('0xb6')][_0xd48b('0x54')]);_0x3c3c74['query']=_[_0xd48b('0x58')](_0x126d7f[_0xd48b('0x57')]);_0x3c3c74[_0xd48b('0x62')]=_[_0xd48b('0x59')](_0x3c3c74[_0xd48b('0x4d')],_0x3c3c74['query']);_0x704231[_0xd48b('0x5a')]=_[_0xd48b('0x59')](_0x3c3c74[_0xd48b('0x4d')],qs['fields'](_0x126d7f['query']['fields']));_0x704231['attributes']=_0x704231[_0xd48b('0x5a')][_0xd48b('0x5c')]?_0x704231[_0xd48b('0x5a')]:_0x3c3c74[_0xd48b('0x4d')];if(!_0x126d7f[_0xd48b('0x57')][_0xd48b('0x5d')](_0xd48b('0x5e'))){_0x704231[_0xd48b('0x20')]=qs[_0xd48b('0x20')](_0x126d7f[_0xd48b('0x57')][_0xd48b('0x20')]);_0x704231[_0xd48b('0x1e')]=qs[_0xd48b('0x1e')](_0x126d7f[_0xd48b('0x57')][_0xd48b('0x1e')]);}_0x704231[_0xd48b('0x5f')]=qs[_0xd48b('0x60')](_0x126d7f['query'][_0xd48b('0x60')]);_0x704231[_0xd48b('0x61')]=qs[_0xd48b('0x62')](_['pick'](_0x126d7f['query'],_0x3c3c74[_0xd48b('0x62')]));_0x704231[_0xd48b('0x61')][_0xd48b('0x76')]=_0x55018e['id'];if(_0x126d7f[_0xd48b('0x57')][_0xd48b('0x64')]){_0x704231['where']=_[_0xd48b('0x65')](_0x704231['where'],{'$or':_['map'](_0x704231[_0xd48b('0x5a')],function(_0x5402e6){var _0x17ced4={};_0x17ced4[_0x5402e6]={'$like':'%'+_0x126d7f[_0xd48b('0x57')][_0xd48b('0x64')]+'%'};return _0x17ced4;})});}_0x704231=_[_0xd48b('0x65')]({},_0x704231,_0x126d7f[_0xd48b('0x66')]);return db[_0xd48b('0xb6')][_0xd48b('0x21')]({'where':_0x704231[_0xd48b('0x61')]})[_0xd48b('0x11')](function(_0x39ce8b){_0x410c3f[_0xd48b('0x21')]=_0x39ce8b;if(_0x126d7f['query'][_0xd48b('0x67')]){_0x704231['include']=[{'model':db[_0xd48b('0x9b')],'as':'Contact','required':![]},{'model':db[_0xd48b('0xf3')],'as':_0xd48b('0xf4'),'attributes':[_0xd48b('0x2a'),_0xd48b('0xf5'),_0xd48b('0xf6')],'required':![]},{'model':db[_0xd48b('0xf7')],'as':'Tags','attributes':['id',_0xd48b('0x2a'),_0xd48b('0xf8')],'where':_0x126d7f[_0xd48b('0x57')][_0xd48b('0xf9')]?{'id':_0x126d7f['query']['tag']}:undefined,'required':_0x126d7f['query'][_0xd48b('0xf9')]?!![]:![]}];}return db[_0xd48b('0xb6')]['findAll'](_0x704231);})[_0xd48b('0x11')](function(_0x51f017){_0x410c3f[_0xd48b('0x6a')]=_0x51f017;return _0x410c3f;});}})[_0xd48b('0x11')](respondWithFilteredResult(_0x268c2f,_0x704231))[_0xd48b('0x1b')](handleError(_0x268c2f,null));};exports['getSnippet']=function(_0x53cbe6,_0x30a167){var _0x52b1a2=0x0;var _0x267c83=0x0;var _0x5bcb38=![];var _0x127fed;var _0x3a8d18;return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'where':{'id':_0x53cbe6['params']['id']},'include':[{'model':db['Interval'],'as':_0xd48b('0xaa'),'include':[{'model':db[_0xd48b('0xaa')],'as':_0xd48b('0x38'),'attributes':['id',_0xd48b('0x30')]}]}]})['then'](handleEntityNotFound(_0x30a167,null))[_0xd48b('0x11')](function(_0xda67ea){if(_0xda67ea){_0x127fed=_0xda67ea;return _0xda67ea[_0xd48b('0xfa')]({'raw':!![]});}})[_0xd48b('0x11')](function(_0x4a0e60){if(_0x127fed){if(_0x4a0e60){_0x3a8d18=_0x4a0e60;}}return require(_0xd48b('0x8a'))['getLicense']();})[_0xd48b('0x11')](function(_0xa81f35){if(_0xa81f35){_0x267c83=_0xa81f35[_0xd48b('0xfb')];_0x5bcb38=_0xa81f35[_0xd48b('0x8c')];}})[_0xd48b('0x11')](function(){return db[_0xd48b('0xb6')][_0xd48b('0x21')]({'where':{'closed':![]}});})['then'](function(_0x797442){_0x52b1a2=_0x797442;if(_0x267c83&&_0x797442>_0x267c83){return db['License'][_0xd48b('0x79')]({'where':{'id':0x1}})[_0xd48b('0x11')](function(_0x5b4956){if(_0x5b4956){_0x5b4956[_0xd48b('0xfc')](_0xd48b('0xfd'));}});}})['then'](function(){if(!_0x127fed[_0xd48b('0xaa')]||!_0x127fed['Interval']['Intervals'])return!![];return checkWebsiteIntervals(_0x127fed);})[_0xd48b('0x11')](function(_0x591bfd){var _0x1eeffa=fs[_0xd48b('0xd2')](path[_0xd48b('0x88')](config['root'],_0xd48b('0xfe')),'utf8');var _0x16bda9=new url['URL'](_0x127fed['address'])[_0xd48b('0xff')];var _0x33b6e3='3.5.0';var _0x29b297=![];var _0x229543={'chatVersion':_0x33b6e3,'chatWebsiteAddressOrigin':_0x16bda9,'remote':_0x127fed[_0xd48b('0x100')],'query':querystring[_0xd48b('0x16')](_[_0xd48b('0x65')](_0x127fed['get']({'plain':!![]}),{'customerIp':_0x53cbe6[_0xd48b('0xb4')][_0xd48b('0x42')]||_0x53cbe6['headers'][_0xd48b('0x101')]||_0x53cbe6[_0xd48b('0x102')][_0xd48b('0x103')]||_0x53cbe6['ip'],'referer':_0x53cbe6[_0xd48b('0xb4')]['referer'],'openedInteractions':_0x52b1a2,'maxInteractions':_0x267c83,'virtual':_0x5bcb38['virtual'],'online':_0x591bfd,'custom':_0x5bcb38}))[_0xd48b('0x104')](/'/g,'\x5c\x27')};_0x30a167[_0xd48b('0x2b')](ejs[_0xd48b('0xd4')](Mustache[_0xd48b('0xd4')](_0x1eeffa,_0x229543),{'proactiveActions':_0x3a8d18,'alignment':_0x127fed[_0xd48b('0x105')],'verticalAlignment':_0x127fed[_0xd48b('0x106')],'div_color':_0x127fed[_0xd48b('0xf8')],'labelText':_0x127fed[_0xd48b('0x107')],'text_color':_0x127fed['textColor'],'text_button_color':_0x127fed['textButtonColor'],'button_color':_0x127fed[_0xd48b('0x108')],'background_color':_0x127fed['backgroundColor'],'hideWhenOffline':_0x127fed[_0xd48b('0x109')],'intervalId':_0x127fed['IntervalId'],'isDevelopment':_0x29b297,'chatVersion':_0x33b6e3}));})[_0xd48b('0x1b')](handleError(_0x30a167,null));};exports[_0xd48b('0x10a')]=function(_0x11c8b4,_0x9e2b76){var _0x38ac72=_0x11c8b4[_0xd48b('0x74')]['id'];var _0x578317=_0x11c8b4[_0xd48b('0x6d')];var _0x517626=0xc8;var _0x16dfe9=null;return db[_0xd48b('0x10b')]['transaction']({'isolationLevel':db[_0xd48b('0x10b')][_0xd48b('0x10c')][_0xd48b('0x10d')][_0xd48b('0x10e')]},function(_0x271976){return db[_0xd48b('0x53')][_0xd48b('0x79')]({'where':{'id':_0x38ac72},'transaction':_0x271976})[_0xd48b('0x11')](function(_0x518e23){if(_0x518e23){return db[_0xd48b('0xa8')][_0xd48b('0x26')]({'where':{'ChatWebsiteId':_0x38ac72},'transaction':_0x271976})[_0xd48b('0x11')](function(){var _0x51938f=_['map'](_0x578317,function(_0x57d4ce){_0x57d4ce['ChatWebsiteId']=_0x38ac72;return _0x57d4ce;});return db[_0xd48b('0xa8')][_0xd48b('0xdf')](_0x51938f,{'transaction':_0x271976});});}else{_0x517626=0x194;_0x16dfe9=[];}});})[_0xd48b('0x11')](function(){if(_0x517626!==0x194){return db[_0xd48b('0xa8')]['findAndCountAll']({'where':{'ChatWebsiteId':_0x38ac72},'order':_0xd48b('0xae')})[_0xd48b('0x11')](function(_0x1b59e8){_0x16dfe9=_0x1b59e8;});}})[_0xd48b('0x1b')](function(_0x562996){_0x517626=0x1f4;logger[_0xd48b('0x19')](_0x562996[_0xd48b('0x29')]);if(_0x562996['name']){delete _0x562996[_0xd48b('0x2a')];}_0x16dfe9=_0x562996;})[_0xd48b('0x10f')](function(){if(_0x16dfe9===null){_0x9e2b76[_0xd48b('0x28')](_0x517626);}else{if(_0x517626===0x1f4){_0x9e2b76['status'](_0x517626)[_0xd48b('0x2b')](_0x16dfe9);}else{_0x9e2b76[_0xd48b('0x1c')](_0x517626)[_0xd48b('0x1d')](_0x16dfe9);}}});};exports[_0xd48b('0x110')]=function(_0x40415d,_0xae45be){var _0x4872b5={};var _0x1c86c4={};var _0x3e2992;var _0x7a6598;return db[_0xd48b('0x53')][_0xd48b('0x79')]({'where':{'id':_0x40415d[_0xd48b('0x74')]['id']}})['then'](handleEntityNotFound(_0xae45be,null))[_0xd48b('0x11')](function(_0x2afbe0){if(_0x2afbe0){_0x3e2992=_0x2afbe0;_0x1c86c4[_0xd48b('0x4d')]=_['keys'](db[_0xd48b('0xa8')][_0xd48b('0x54')]);_0x1c86c4['query']=_[_0xd48b('0x58')](_0x40415d['query']);_0x1c86c4[_0xd48b('0x62')]=_[_0xd48b('0x59')](_0x1c86c4[_0xd48b('0x4d')],_0x1c86c4[_0xd48b('0x57')]);_0x4872b5[_0xd48b('0x5a')]=_['intersection'](_0x1c86c4[_0xd48b('0x4d')],qs[_0xd48b('0x5b')](_0x40415d[_0xd48b('0x57')][_0xd48b('0x5b')]));_0x4872b5[_0xd48b('0x5a')]=_0x4872b5['attributes']['length']?_0x4872b5['attributes']:_0x1c86c4['model'];_0x4872b5['order']=qs['sort'](_0x40415d[_0xd48b('0x57')]['sort']);_0x4872b5[_0xd48b('0x61')]=qs[_0xd48b('0x62')](_[_0xd48b('0x63')](_0x40415d[_0xd48b('0x57')],_0x1c86c4[_0xd48b('0x62')]));if(_0x40415d[_0xd48b('0x57')][_0xd48b('0x64')]){_0x4872b5[_0xd48b('0x61')]=_[_0xd48b('0x65')](_0x4872b5[_0xd48b('0x61')],{'$or':_[_0xd48b('0x37')](_0x4872b5[_0xd48b('0x5a')],function(_0x46a298){var _0x1bf49d={};_0x1bf49d[_0x46a298]={'$like':'%'+_0x40415d['query'][_0xd48b('0x64')]+'%'};return _0x1bf49d;})});}_0x4872b5=_[_0xd48b('0x65')]({},_0x4872b5,_0x40415d['options']);return _0x3e2992['getApplications'](_0x4872b5);}})[_0xd48b('0x11')](function(_0x420b70){if(_0x420b70){_0x7a6598=_0x420b70[_0xd48b('0x5c')];if(!_0x40415d[_0xd48b('0x57')][_0xd48b('0x5d')](_0xd48b('0x5e'))){_0x4872b5[_0xd48b('0x20')]=qs[_0xd48b('0x20')](_0x40415d[_0xd48b('0x57')][_0xd48b('0x20')]);_0x4872b5['offset']=qs['offset'](_0x40415d[_0xd48b('0x57')][_0xd48b('0x1e')]);}return _0x3e2992[_0xd48b('0x110')](_0x4872b5);}})[_0xd48b('0x11')](function(_0x44d277){if(_0x44d277){return _0x44d277?{'count':_0x7a6598,'rows':_0x44d277}:null;}})[_0xd48b('0x11')](respondWithResult(_0xae45be,null))['catch'](handleError(_0xae45be,null));};exports[_0xd48b('0x111')]=function(_0x10d413,_0x478b61){return db[_0xd48b('0x112')]['find']({'where':{'id':_0x10d413['params']['id']}})['then'](handleEntityNotFound(_0x478b61,null))[_0xd48b('0x11')](function(_0x555a35){if(_0x555a35){return _0x555a35[_0xd48b('0x111')](_0x10d413[_0xd48b('0x6d')]['ids'],_[_0xd48b('0xf2')](_0x10d413[_0xd48b('0x6d')],[_0xd48b('0x7b'),'id'])||{});}})[_0xd48b('0x11')](respondWithResult(_0x478b61,null))['catch'](handleError(_0x478b61,null));};exports[_0xd48b('0xfa')]=function(_0x580b28,_0x374806){var _0x30f30f={};var _0x270336={};var _0x2b0809;var _0x5dd3c4;return db[_0xd48b('0x53')][_0xd48b('0x79')]({'where':{'id':_0x580b28[_0xd48b('0x74')]['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x374806,null))[_0xd48b('0x11')](function(_0x559b1b){if(_0x559b1b){_0x2b0809=_0x559b1b;_0x270336['model']=_['keys'](db[_0xd48b('0x113')][_0xd48b('0x54')]);_0x270336[_0xd48b('0x57')]=_[_0xd48b('0x58')](_0x580b28[_0xd48b('0x57')]);_0x270336[_0xd48b('0x62')]=_[_0xd48b('0x59')](_0x270336['model'],_0x270336[_0xd48b('0x57')]);_0x30f30f['attributes']=_[_0xd48b('0x59')](_0x270336['model'],qs[_0xd48b('0x5b')](_0x580b28[_0xd48b('0x57')][_0xd48b('0x5b')]));_0x30f30f[_0xd48b('0x5a')]=_0x30f30f['attributes'][_0xd48b('0x5c')]?_0x30f30f[_0xd48b('0x5a')]:_0x270336['model'];_0x30f30f[_0xd48b('0x5f')]=qs[_0xd48b('0x60')](_0x580b28[_0xd48b('0x57')][_0xd48b('0x60')]);_0x30f30f[_0xd48b('0x61')]=qs['filters'](_[_0xd48b('0x63')](_0x580b28[_0xd48b('0x57')],_0x270336[_0xd48b('0x62')]));if(_0x580b28['query'][_0xd48b('0x64')]){_0x30f30f[_0xd48b('0x61')]=_[_0xd48b('0x65')](_0x30f30f[_0xd48b('0x61')],{'$or':_[_0xd48b('0x37')](_0x30f30f[_0xd48b('0x5a')],function(_0x19c909){var _0x3a4977={};_0x3a4977[_0x19c909]={'$like':'%'+_0x580b28[_0xd48b('0x57')][_0xd48b('0x64')]+'%'};return _0x3a4977;})});}_0x30f30f=_[_0xd48b('0x65')]({},_0x30f30f,_0x580b28[_0xd48b('0x66')]);return _0x2b0809[_0xd48b('0xfa')](_0x30f30f);}})[_0xd48b('0x11')](function(_0xda5e6){if(_0xda5e6){_0x5dd3c4=_0xda5e6[_0xd48b('0x5c')];if(!_0x580b28[_0xd48b('0x57')]['hasOwnProperty'](_0xd48b('0x5e'))){_0x30f30f['limit']=qs['limit'](_0x580b28['query']['limit']);_0x30f30f[_0xd48b('0x1e')]=qs['offset'](_0x580b28[_0xd48b('0x57')][_0xd48b('0x1e')]);}return _0x2b0809[_0xd48b('0xfa')](_0x30f30f);}})[_0xd48b('0x11')](function(_0x525eb8){if(_0x525eb8){return _0x525eb8?{'count':_0x5dd3c4,'rows':_0x525eb8}:null;}})[_0xd48b('0x11')](respondWithResult(_0x374806,null))[_0xd48b('0x1b')](handleError(_0x374806,null));};exports[_0xd48b('0x114')]=function(_0x431987,_0x51ddf9){var _0x4007d9=_0x431987[_0xd48b('0x57')][_0xd48b('0x115')]==='false'?_0xd48b('0x116'):'onlineForm';return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'attributes':['id',_0x4007d9],'where':{'id':_0x431987[_0xd48b('0x74')]['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x51ddf9,null))[_0xd48b('0x11')](function(_0x416750){if(_0x416750){var _0x524295=_0x416750[_0x4007d9];var _0x375a2d=_0x524295&&_0x524295[_0xd48b('0x117')]?_0x524295[_0xd48b('0x117')]:[];_0x51ddf9[_0xd48b('0x2b')]({'fromKey':_[_0xd48b('0x8d')](_0x524295['fromKey'])?undefined:_0x524295[_0xd48b('0x118')],'count':_0x375a2d[_0xd48b('0x5c')],'rows':_0x375a2d});}})['catch'](handleError(_0x51ddf9,null));};exports[_0xd48b('0x119')]=function(_0x1dad19,_0x4a861e){var _0x169273={'raw':![],'where':{}};var _0x4c5721={};var _0x541689={'count':0x0,'rows':[]};return db[_0xd48b('0x53')][_0xd48b('0x79')]({'where':{'id':_0x1dad19[_0xd48b('0x74')]['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x4a861e,null))['then'](function(_0x3925b1){if(_0x3925b1){_0x4c5721[_0xd48b('0x4d')]=_[_0xd48b('0x58')](db[_0xd48b('0xd7')][_0xd48b('0x54')]);_0x4c5721[_0xd48b('0x57')]=_[_0xd48b('0x58')](_0x1dad19['query']);_0x4c5721[_0xd48b('0x62')]=_[_0xd48b('0x59')](_0x4c5721[_0xd48b('0x4d')],_0x4c5721[_0xd48b('0x57')]);_0x169273['attributes']=_[_0xd48b('0x59')](_0x4c5721[_0xd48b('0x4d')],qs[_0xd48b('0x5b')](_0x1dad19[_0xd48b('0x57')]['fields']));_0x169273['attributes']=_0x169273['attributes'][_0xd48b('0x5c')]?_0x169273[_0xd48b('0x5a')]:_0x4c5721[_0xd48b('0x4d')];if(!_0x1dad19[_0xd48b('0x57')][_0xd48b('0x5d')](_0xd48b('0x5e'))){_0x169273[_0xd48b('0x20')]=qs['limit'](_0x1dad19[_0xd48b('0x57')]['limit']);_0x169273[_0xd48b('0x1e')]=qs[_0xd48b('0x1e')](_0x1dad19['query'][_0xd48b('0x1e')]);}_0x169273[_0xd48b('0x5f')]=qs['sort'](_0x1dad19[_0xd48b('0x57')][_0xd48b('0x60')]);_0x169273['where']=qs['filters'](_[_0xd48b('0x63')](_0x1dad19[_0xd48b('0x57')],_0x4c5721[_0xd48b('0x62')]));_0x169273[_0xd48b('0x61')][_0xd48b('0x76')]=_0x3925b1['id'];if(_0x1dad19['query'][_0xd48b('0x64')]){_0x169273[_0xd48b('0x61')]=_['merge'](_0x169273[_0xd48b('0x61')],{'$or':_[_0xd48b('0x37')](_0x169273['attributes'],function(_0x40d8cb){var _0x30883e={};_0x30883e[_0x40d8cb]={'$like':'%'+_0x1dad19[_0xd48b('0x57')][_0xd48b('0x64')]+'%'};return _0x30883e;})});}_0x169273=_[_0xd48b('0x65')]({},_0x169273,_0x1dad19[_0xd48b('0x66')]);return db[_0xd48b('0xd7')]['count']({'where':_0x169273[_0xd48b('0x61')]})['then'](function(_0x57e7ab){_0x541689[_0xd48b('0x21')]=_0x57e7ab;if(_0x1dad19['query']['includeAll']){_0x169273[_0xd48b('0x68')]=[{'all':!![]}];}else{_0x169273[_0xd48b('0x68')]=[{'model':db[_0xd48b('0x9b')],'as':_0xd48b('0x11a'),'required':![]},{'model':db[_0xd48b('0xde')],'as':_0xd48b('0x11b'),'required':![]}];}return db[_0xd48b('0xd7')][_0xd48b('0x69')](_0x169273);})[_0xd48b('0x11')](function(_0x418932){_0x541689[_0xd48b('0x6a')]=_0x418932;return _0x541689;});}})['then'](respondWithFilteredResult(_0x4a861e,_0x169273))[_0xd48b('0x1b')](handleError(_0x4a861e,null));};exports[_0xd48b('0x11c')]=function(_0x52a208,_0x38d5ce){return db['ChatWebsite'][_0xd48b('0x6b')]({'where':{'id':_0x52a208['params']['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x38d5ce,null))['then'](function(_0x4a563d){if(_0x4a563d){return _0x4a563d[_0xd48b('0x11c')](_0x52a208[_0xd48b('0x6d')]['ids'],_['omit'](_0x52a208[_0xd48b('0x6d')],[_0xd48b('0x7b'),'id'])||{})[_0xd48b('0x11d')](function(_0x271603){for(var _0x2f1fbd=0x0;_0x2f1fbd<_0x52a208[_0xd48b('0x6d')]['ids'][_0xd48b('0x5c')];_0x2f1fbd+=0x1){socket[_0xd48b('0x11e')]('userChatWebsite:save',{'UserId':Number(_0x52a208[_0xd48b('0x6d')][_0xd48b('0x7b')][_0x2f1fbd]),'ChatWebsiteId':Number(_0x52a208[_0xd48b('0x74')]['id'])});}return _0x271603;});}})[_0xd48b('0x11')](respondWithResult(_0x38d5ce,null))[_0xd48b('0x1b')](handleError(_0x38d5ce,null));};exports[_0xd48b('0x11f')]=function(_0x45369f,_0x165bd6){return db[_0xd48b('0x53')][_0xd48b('0x6b')]({'where':{'id':_0x45369f[_0xd48b('0x74')]['id']}})[_0xd48b('0x11')](handleEntityNotFound(_0x165bd6,null))['then'](function(_0x4f2432){if(_0x4f2432){return _0x4f2432[_0xd48b('0x11f')](_0x45369f[_0xd48b('0x57')][_0xd48b('0x7b')])['then'](function(){if(_['isArray'](_0x45369f[_0xd48b('0x57')][_0xd48b('0x7b')])){for(var _0x229127=0x0;_0x229127<_0x45369f[_0xd48b('0x57')][_0xd48b('0x7b')]['length'];_0x229127+=0x1){socket['emit']('userChatWebsite:remove',{'UserId':Number(_0x45369f['query'][_0xd48b('0x7b')][_0x229127]),'ChatWebsiteId':Number(_0x45369f[_0xd48b('0x74')]['id'])});}}else{socket[_0xd48b('0x11e')](_0xd48b('0x120'),{'UserId':Number(_0x45369f[_0xd48b('0x57')][_0xd48b('0x7b')]),'ChatWebsiteId':Number(_0x45369f[_0xd48b('0x74')]['id'])});}});}})[_0xd48b('0x11')](respondWithStatusCode(_0x165bd6,null))[_0xd48b('0x1b')](handleError(_0x165bd6,null));};exports['getAgents']=function(_0x12561d,_0x161c98){var _0x2b12b6={};var _0x403f5e={};var _0x2232e9;var _0x1713c3;return db['ChatWebsite'][_0xd48b('0x79')]({'where':{'id':_0x12561d[_0xd48b('0x74')]['id']}})['then'](handleEntityNotFound(_0x161c98,null))[_0xd48b('0x11')](function(_0x4e84bf){if(_0x4e84bf){_0x2232e9=_0x4e84bf;_0x403f5e[_0xd48b('0x4d')]=_[_0xd48b('0x58')](db['User'][_0xd48b('0x54')]);_0x403f5e[_0xd48b('0x57')]=_[_0xd48b('0x58')](_0x12561d[_0xd48b('0x57')]);_0x403f5e[_0xd48b('0x62')]=_[_0xd48b('0x59')](_0x403f5e[_0xd48b('0x4d')],_0x403f5e[_0xd48b('0x57')]);_0x2b12b6[_0xd48b('0x5a')]=_['intersection'](_0x403f5e['model'],qs['fields'](_0x12561d[_0xd48b('0x57')]['fields']));_0x2b12b6[_0xd48b('0x5a')]=_0x2b12b6[_0xd48b('0x5a')][_0xd48b('0x5c')]?_0x2b12b6[_0xd48b('0x5a')]:_0x403f5e[_0xd48b('0x4d')];_0x2b12b6['order']=qs[_0xd48b('0x60')](_0x12561d[_0xd48b('0x57')][_0xd48b('0x60')]);_0x2b12b6[_0xd48b('0x61')]=qs[_0xd48b('0x62')](_[_0xd48b('0x63')](_0x12561d['query'],_0x403f5e[_0xd48b('0x62')]));if(_0x12561d[_0xd48b('0x57')][_0xd48b('0x64')]){_0x2b12b6[_0xd48b('0x61')]=_['merge'](_0x2b12b6[_0xd48b('0x61')],{'$or':_['map'](_0x2b12b6['attributes'],function(_0x1adda3){var _0x151e05={};_0x151e05[_0x1adda3]={'$like':'%'+_0x12561d[_0xd48b('0x57')][_0xd48b('0x64')]+'%'};return _0x151e05;})});}_0x2b12b6=_['merge']({},_0x2b12b6,_0x12561d[_0xd48b('0x66')]);return _0x2232e9[_0xd48b('0x121')](_0x2b12b6);}})[_0xd48b('0x11')](function(_0x3957d8){if(_0x3957d8){_0x1713c3=_0x3957d8[_0xd48b('0x5c')];if(!_0x12561d[_0xd48b('0x57')][_0xd48b('0x5d')](_0xd48b('0x5e'))){_0x2b12b6[_0xd48b('0x20')]=qs[_0xd48b('0x20')](_0x12561d[_0xd48b('0x57')][_0xd48b('0x20')]);_0x2b12b6[_0xd48b('0x1e')]=qs[_0xd48b('0x1e')](_0x12561d[_0xd48b('0x57')]['offset']);}return _0x2232e9['getAgents'](_0x2b12b6);}})[_0xd48b('0x11')](function(_0x8b998c){if(_0x8b998c){return _0x8b998c?{'count':_0x1713c3,'rows':_0x8b998c}:null;}})[_0xd48b('0x11')](respondWithResult(_0x161c98,null))[_0xd48b('0x1b')](handleError(_0x161c98,null));};
\ No newline at end of file