Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 9759d47..c70cc2c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x11f1=['getInteractions','Contact','User','Owner','internal','Tag','color','tag','timezone','interval','iftime\x20%s','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','Intervals','getProactiveActions','virtual','License','increment','push','all','some','server/files/chat/iframe.js','stringify','x-forwarded-for','x-real-ip','connection','alignment','verticalAlignment','addApplications','transaction','ChatApplication','bulkCreate','findAndCountAll','getApplications','chatProactiveAction','addProactiveActions','online','false','offlineForm','onlineForm','items','fromKey','ChatOfflineMessage','addAgents','emit','userChatWebsite:save','userChatWebsite:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./chatWebsite.socket','register','jayson/promise','client','http','test','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','reject','save','update','destroy','get','ChatWebsites','stack','name','send','index','mandatoryDispositionPause','rawAttributes','fieldName','type','map','query','filters','model','attributes','length','nolimit','order','sort','where','pick','merge','VIRTUAL','ChatWebsite','count','includeAll','include','rows','catch','show','params','Pause','keys','intersection','fields','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','ChatWebsiteId','Disposition','getDispositions','hasOwnProperty','removeDispositions','ids','addAnswer','CannedAnswer','filter','findAll','removeAnswers','sitepic','file','filename','agentAvatar','addCustomerAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','join','server/files/images/logos/default_logo.png','../../config/license/util','getLicense','custom','isNil','existsSync','root','server/files/images/logos/','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','download','getSystemAvatar','notify','user-agent-parser','setUA','headers','user-agent','chat','CmContact','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from','from\x20is\x20mandatory','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','DESC','Applications','account','applications','priority','asc','cf-connecting-ip','first','x-real-port','referer','browser','version','format','%s\x20%s','unknown','device','%s\x20%s\x20%s','vendor','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','firstName','contact','messageId','created','autoclose','*,*,*,*','ChatMessage','UserId','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','defaults','findOrCreate','readFileSync','utf8','render','toPairs','offlineMessageBody','MailAccount','findOne','MailServerOut','Smtp','forwardOfflineAddress','service','host','port','secure','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','addInteraction','omit'];(function(_0x5327da,_0xb7d219){var _0x46c142=function(_0x145cbc){while(--_0x145cbc){_0x5327da['push'](_0x5327da['shift']());}};_0x46c142(++_0xb7d219);}(_0x11f1,0x155));var _0x111f=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x11f1[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x111f('0x0'));var rimraf=require(_0x111f('0x1'));var zipdir=require(_0x111f('0x2'));var jsonpatch=require(_0x111f('0x3'));var rp=require(_0x111f('0x4'));var moment=require(_0x111f('0x5'));var BPromise=require(_0x111f('0x6'));var Mustache=require(_0x111f('0x7'));var util=require(_0x111f('0x8'));var path=require(_0x111f('0x9'));var sox=require(_0x111f('0xa'));var csv=require(_0x111f('0xb'));var ejs=require(_0x111f('0xc'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0x111f('0xd'));var jsforce=require(_0x111f('0xe'));var deskjs=require(_0x111f('0xf'));var toCsv=require(_0x111f('0xb'));var querystring=require('querystring');var Papa=require(_0x111f('0x10'));var Redis=require('ioredis');var authService=require(_0x111f('0x11'));var qs=require(_0x111f('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x111f('0x13'))(_0x111f('0x14'));var utils=require(_0x111f('0x15'));var config=require(_0x111f('0x16'));var db=require(_0x111f('0x17'))['db'];config[_0x111f('0x18')]=_['defaults'](config[_0x111f('0x18')],{'host':_0x111f('0x19'),'port':0x18eb});var socket=require(_0x111f('0x1a'))(new Redis(config[_0x111f('0x18')]));require(_0x111f('0x1b'))[_0x111f('0x1c')](socket);var jayson=require(_0x111f('0x1d'));var client=jayson[_0x111f('0x1e')][_0x111f('0x1f')]({'port':0x232c});var client9002=jayson['client'][_0x111f('0x1f')]({'port':0x232a});var client9003=jayson['client'][_0x111f('0x1f')]({'port':0x232b});function checkPasswordPattern(_0x4ef14e,_0x296e98,_0x411fd5){if(_0x411fd5){var _0x1e70d3=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x1e70d3[_0x111f('0x20')](_0x296e98)){return _0x4ef14e;}else{throw new db[(_0x111f('0x21'))][(_0x111f('0x22'))](_0x111f('0x23'));}}else{return _0x4ef14e;}}function respondWithRpcPromise(_0x357892,_0x2b9289,_0x12ab00,_0x27d3d6){return new BPromise(function(_0x2198c3,_0x15d0b3){var _0x293a31=_0x27d3d6||client;return _0x293a31[_0x111f('0x24')](_0x357892,_0x12ab00)[_0x111f('0x25')](function(_0x4433a5){logger[_0x111f('0x26')](_0x111f('0x27'),_0x2b9289,_0x111f('0x28'));logger[_0x111f('0x29')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x2b9289,_0x111f('0x28'),JSON['stringify'](_0x4433a5));if(_0x4433a5['error']){if(_0x4433a5[_0x111f('0x2a')][_0x111f('0x2b')]===0x1f4){logger[_0x111f('0x2a')](_0x111f('0x27'),_0x2b9289,_0x4433a5[_0x111f('0x2a')]['message']);return _0x15d0b3(_0x4433a5['error'][_0x111f('0x2c')]);}logger[_0x111f('0x2a')](_0x111f('0x27'),_0x2b9289,_0x4433a5[_0x111f('0x2a')][_0x111f('0x2c')]);return _0x2198c3(_0x4433a5[_0x111f('0x2a')]['message']);}else{logger[_0x111f('0x26')]('ChatWebsite,\x20%s,\x20%s',_0x2b9289,_0x111f('0x28'));_0x2198c3(_0x4433a5[_0x111f('0x2d')][_0x111f('0x2c')]);}})['catch'](function(_0x131257){logger[_0x111f('0x2a')]('ChatWebsite,\x20%s,\x20%s',_0x2b9289,_0x131257);_0x15d0b3(_0x131257);});});}function respondWithStatusCode(_0x40f509,_0x3520bb){_0x3520bb=_0x3520bb||0xcc;return function(_0x37d261){if(_0x37d261){return _0x40f509[_0x111f('0x2e')](_0x3520bb);}return _0x40f509[_0x111f('0x2f')](_0x3520bb)[_0x111f('0x30')]();};}function respondWithResult(_0x5c86c2,_0x578a39){_0x578a39=_0x578a39||0xc8;return function(_0x35f4f9){if(_0x35f4f9){return _0x5c86c2[_0x111f('0x2f')](_0x578a39)[_0x111f('0x31')](_0x35f4f9);}};}function respondWithFilteredResult(_0x140cff,_0x5a3320){return function(_0x1e587e){if(_0x1e587e){var _0x320387=_0x1e587e['count'],_0xad0ee7=_0x5a3320[_0x111f('0x32')],_0x8c2cfe=_0x5a3320[_0x111f('0x32')]+_0x5a3320[_0x111f('0x33')],_0x4b4e7e;if(_0x8c2cfe>=_0x320387){_0x8c2cfe=_0x320387;_0x4b4e7e=0xc8;}else{_0x4b4e7e=0xce;}_0x140cff['status'](_0x4b4e7e);return _0x140cff[_0x111f('0x34')](_0x111f('0x35'),_0xad0ee7+'-'+_0x8c2cfe+'/'+_0x320387)['json'](_0x1e587e);}return null;};}function patchUpdates(_0x300d69){return function(_0x34698a){try{jsonpatch[_0x111f('0x36')](_0x34698a,_0x300d69,!![]);}catch(_0x279ad8){return BPromise[_0x111f('0x37')](_0x279ad8);}return _0x34698a[_0x111f('0x38')]();};}function saveUpdates(_0x4495d8,_0x564347){return function(_0xcc7d12){if(_0xcc7d12){return _0xcc7d12[_0x111f('0x39')](_0x4495d8)[_0x111f('0x25')](function(_0x209ae9){return _0x209ae9;});}return null;};}function removeEntity(_0x545abf,_0x1d60bd){return function(_0x3a6ded){if(_0x3a6ded){return _0x3a6ded[_0x111f('0x3a')]()[_0x111f('0x25')](function(){var _0x44d970=_0x3a6ded[_0x111f('0x3b')]({'plain':!![]});var _0xddb61a=_0x111f('0x3c');return db['UserProfileResource'][_0x111f('0x3a')]({'where':{'type':_0xddb61a,'resourceId':_0x44d970['id']}})[_0x111f('0x25')](function(){return _0x3a6ded;});})[_0x111f('0x25')](function(){_0x545abf[_0x111f('0x2f')](0xcc)[_0x111f('0x30')]();});}};}function handleEntityNotFound(_0x10d4cb,_0x34b493){return function(_0xfabe20){if(!_0xfabe20){_0x10d4cb[_0x111f('0x2e')](0x194);}return _0xfabe20;};}function handleError(_0x496be7,_0x1e5279){_0x1e5279=_0x1e5279||0x1f4;return function(_0x24faca){logger[_0x111f('0x2a')](_0x24faca[_0x111f('0x3d')]);if(_0x24faca[_0x111f('0x3e')]){delete _0x24faca['name'];}_0x496be7['status'](_0x1e5279)[_0x111f('0x3f')](_0x24faca);};}exports[_0x111f('0x40')]=function(_0xb8bfd7,_0x4f04a3){var _0x49f5e2={'include':[{'model':db['Pause'],'as':_0x111f('0x41')}]},_0x4e0209={},_0x4095b4={'count':0x0,'rows':[]};var _0x18e2b7=_['map'](db['ChatWebsite'][_0x111f('0x42')],function(_0x139b21){return{'name':_0x139b21[_0x111f('0x43')],'type':_0x139b21[_0x111f('0x44')]['key']};});_0x4e0209['model']=_[_0x111f('0x45')](_0x18e2b7,_0x111f('0x3e'));_0x4e0209['query']=_['keys'](_0xb8bfd7[_0x111f('0x46')]);_0x4e0209[_0x111f('0x47')]=_['intersection'](_0x4e0209[_0x111f('0x48')],_0x4e0209[_0x111f('0x46')]);_0x49f5e2[_0x111f('0x49')]=_['intersection'](_0x4e0209[_0x111f('0x48')],qs['fields'](_0xb8bfd7[_0x111f('0x46')]['fields']));_0x49f5e2[_0x111f('0x49')]=_0x49f5e2['attributes'][_0x111f('0x4a')]?_0x49f5e2['attributes']:_0x4e0209[_0x111f('0x48')];if(!_0xb8bfd7[_0x111f('0x46')]['hasOwnProperty'](_0x111f('0x4b'))){_0x49f5e2['limit']=qs[_0x111f('0x33')](_0xb8bfd7[_0x111f('0x46')][_0x111f('0x33')]);_0x49f5e2[_0x111f('0x32')]=qs[_0x111f('0x32')](_0xb8bfd7[_0x111f('0x46')]['offset']);}_0x49f5e2[_0x111f('0x4c')]=qs[_0x111f('0x4d')](_0xb8bfd7[_0x111f('0x46')][_0x111f('0x4d')]);_0x49f5e2[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0xb8bfd7[_0x111f('0x46')],_0x4e0209['filters']));if(_0xb8bfd7[_0x111f('0x46')]['filter']){_0x49f5e2['where']=_[_0x111f('0x50')](_0x49f5e2['where'],{'$or':_['map'](_0x18e2b7,function(_0x190ad7){if(_0x190ad7['type']!==_0x111f('0x51')){var _0x965192={};_0x965192[_0x190ad7[_0x111f('0x3e')]]={'$like':'%'+_0xb8bfd7['query']['filter']+'%'};return _0x965192;}})});}_0x49f5e2=_[_0x111f('0x50')]({},_0x49f5e2,_0xb8bfd7['options']);var _0x43a3a8={'where':_0x49f5e2[_0x111f('0x4e')]};return db[_0x111f('0x52')]['count'](_0x43a3a8)[_0x111f('0x25')](function(_0x1e008f){_0x4095b4[_0x111f('0x53')]=_0x1e008f;if(_0xb8bfd7[_0x111f('0x46')][_0x111f('0x54')]){_0x49f5e2[_0x111f('0x55')]=[{'all':!![]}];}return db[_0x111f('0x52')]['findAll'](_0x49f5e2);})[_0x111f('0x25')](function(_0x2c8b30){_0x4095b4[_0x111f('0x56')]=_0x2c8b30;return _0x4095b4;})['then'](respondWithFilteredResult(_0x4f04a3,_0x49f5e2))[_0x111f('0x57')](handleError(_0x4f04a3,null));};exports[_0x111f('0x58')]=function(_0x17a37a,_0x11dd5e){var _0xac4a93={'raw':![],'where':{'id':_0x17a37a[_0x111f('0x59')]['id']},'include':[{'model':db[_0x111f('0x5a')],'as':_0x111f('0x41')}]},_0x3ca6c8={};_0x3ca6c8[_0x111f('0x48')]=_[_0x111f('0x5b')](db['ChatWebsite'][_0x111f('0x42')]);_0x3ca6c8[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x17a37a[_0x111f('0x46')]);_0x3ca6c8[_0x111f('0x47')]=_['intersection'](_0x3ca6c8['model'],_0x3ca6c8[_0x111f('0x46')]);_0xac4a93['attributes']=_[_0x111f('0x5c')](_0x3ca6c8[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x17a37a[_0x111f('0x46')][_0x111f('0x5d')]));_0xac4a93[_0x111f('0x49')]=_0xac4a93[_0x111f('0x49')]['length']?_0xac4a93[_0x111f('0x49')]:_0x3ca6c8[_0x111f('0x48')];if(_0x17a37a[_0x111f('0x46')][_0x111f('0x54')]){_0xac4a93[_0x111f('0x55')]=[{'all':!![]}];}_0xac4a93=_[_0x111f('0x50')]({},_0xac4a93,_0x17a37a[_0x111f('0x5e')]);return db[_0x111f('0x52')]['find'](_0xac4a93)[_0x111f('0x25')](handleEntityNotFound(_0x11dd5e,null))[_0x111f('0x25')](respondWithResult(_0x11dd5e,null))[_0x111f('0x57')](handleError(_0x11dd5e,null));};exports[_0x111f('0x5f')]=function(_0x1be243,_0x102ce5){return db[_0x111f('0x52')][_0x111f('0x5f')](_0x1be243[_0x111f('0x60')],{})[_0x111f('0x25')](function(_0x7b6d2e){var _0x12b0d4=_0x1be243[_0x111f('0x61')][_0x111f('0x3b')]({'plain':!![]});if(!_0x12b0d4)throw new Error(_0x111f('0x62'));if(_0x12b0d4[_0x111f('0x63')]==='user'){var _0x4f1700=_0x7b6d2e[_0x111f('0x3b')]({'plain':!![]});var _0x5c0ba8=_0x111f('0x3c');return db[_0x111f('0x64')][_0x111f('0x65')]({'where':{'name':_0x5c0ba8,'userProfileId':_0x12b0d4[_0x111f('0x66')]},'raw':!![]})[_0x111f('0x25')](function(_0x14bf55){if(_0x14bf55&&_0x14bf55[_0x111f('0x67')]===0x0){return db[_0x111f('0x68')][_0x111f('0x5f')]({'name':_0x4f1700[_0x111f('0x3e')],'resourceId':_0x4f1700['id'],'type':_0x14bf55[_0x111f('0x3e')],'sectionId':_0x14bf55['id']},{})[_0x111f('0x25')](function(){return _0x7b6d2e;});}else{return _0x7b6d2e;}})[_0x111f('0x57')](function(_0x15e819){logger[_0x111f('0x2a')](_0x111f('0x69'),_0x15e819);throw _0x15e819;});}return _0x7b6d2e;})['then'](respondWithResult(_0x102ce5,0xc9))[_0x111f('0x57')](handleError(_0x102ce5,null));};exports['update']=function(_0xe193e,_0x501125){if(_0xe193e[_0x111f('0x60')]['id']){delete _0xe193e['body']['id'];}return db['ChatWebsite'][_0x111f('0x65')]({'where':{'id':_0xe193e[_0x111f('0x59')]['id']},'include':[{'model':db[_0x111f('0x5a')],'as':_0x111f('0x41')}]})['then'](handleEntityNotFound(_0x501125,null))[_0x111f('0x25')](saveUpdates(_0xe193e[_0x111f('0x60')],null))['then'](respondWithResult(_0x501125,null))[_0x111f('0x57')](handleError(_0x501125,null));};exports[_0x111f('0x3a')]=function(_0x4c9354,_0x1b82ef){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x4c9354[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x1b82ef,null))[_0x111f('0x25')](removeEntity(_0x1b82ef,null))[_0x111f('0x57')](handleError(_0x1b82ef,null));};exports[_0x111f('0x6a')]=function(_0x3c8b53,_0x1635ef){return db[_0x111f('0x52')][_0x111f('0x6a')]()[_0x111f('0x25')](respondWithResult(_0x1635ef,null))[_0x111f('0x57')](handleError(_0x1635ef,null));};exports['addDisposition']=function(_0x50ee6e,_0x41054a,_0x2b7f8c){if(_0x50ee6e[_0x111f('0x60')]['id']){delete _0x50ee6e['body']['id'];}return db['ChatWebsite']['find']({'where':{'id':_0x50ee6e['params']['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x41054a,null))[_0x111f('0x25')](function(_0x5b49fe){if(_0x5b49fe){_0x50ee6e[_0x111f('0x60')][_0x111f('0x6b')]=_0x5b49fe['id'];return db[_0x111f('0x6c')][_0x111f('0x5f')](_0x50ee6e[_0x111f('0x60')]);}})[_0x111f('0x25')](respondWithResult(_0x41054a,null))[_0x111f('0x57')](handleError(_0x41054a,null));};exports[_0x111f('0x6d')]=function(_0x8b6c13,_0x2ccec1,_0x3df3f2){var _0x1becd2={'raw':![],'where':{}};var _0x3af9a8={};var _0xeb9353={'count':0x0,'rows':[]};return db[_0x111f('0x52')]['findOne']({'where':{'id':_0x8b6c13[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x2ccec1,null))['then'](function(_0x40a8d5){if(_0x40a8d5){_0x3af9a8[_0x111f('0x48')]=_[_0x111f('0x5b')](db[_0x111f('0x6c')][_0x111f('0x42')]);_0x3af9a8['query']=_[_0x111f('0x5b')](_0x8b6c13[_0x111f('0x46')]);_0x3af9a8[_0x111f('0x47')]=_[_0x111f('0x5c')](_0x3af9a8[_0x111f('0x48')],_0x3af9a8['query']);_0x1becd2['attributes']=_['intersection'](_0x3af9a8[_0x111f('0x48')],qs['fields'](_0x8b6c13[_0x111f('0x46')][_0x111f('0x5d')]));_0x1becd2[_0x111f('0x49')]=_0x1becd2['attributes']['length']?_0x1becd2['attributes']:_0x3af9a8['model'];if(!_0x8b6c13[_0x111f('0x46')][_0x111f('0x6e')]('nolimit')){_0x1becd2['limit']=qs[_0x111f('0x33')](_0x8b6c13[_0x111f('0x46')][_0x111f('0x33')]);_0x1becd2[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x8b6c13[_0x111f('0x46')][_0x111f('0x32')]);}_0x1becd2[_0x111f('0x4c')]=qs['sort'](_0x8b6c13[_0x111f('0x46')][_0x111f('0x4d')]);_0x1becd2[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x8b6c13[_0x111f('0x46')],_0x3af9a8[_0x111f('0x47')]));_0x1becd2[_0x111f('0x4e')][_0x111f('0x6b')]=_0x40a8d5['id'];if(_0x8b6c13[_0x111f('0x46')]['filter']){_0x1becd2['where']=_[_0x111f('0x50')](_0x1becd2['where'],{'$or':_[_0x111f('0x45')](_0x1becd2[_0x111f('0x49')],function(_0x13ac34){var _0x4aae13={};_0x4aae13[_0x13ac34]={'$like':'%'+_0x8b6c13[_0x111f('0x46')]['filter']+'%'};return _0x4aae13;})});}_0x1becd2=_['merge']({},_0x1becd2,_0x8b6c13[_0x111f('0x5e')]);return db[_0x111f('0x6c')][_0x111f('0x53')]({'where':_0x1becd2[_0x111f('0x4e')]})[_0x111f('0x25')](function(_0x2e5102){_0xeb9353[_0x111f('0x53')]=_0x2e5102;if(_0x8b6c13[_0x111f('0x46')][_0x111f('0x54')]){_0x1becd2['include']=[{'all':!![]}];}return db[_0x111f('0x6c')]['findAll'](_0x1becd2);})['then'](function(_0x1254b4){_0xeb9353[_0x111f('0x56')]=_0x1254b4;return _0xeb9353;});}})[_0x111f('0x25')](respondWithFilteredResult(_0x2ccec1,_0x1becd2))['catch'](handleError(_0x2ccec1,null));};exports[_0x111f('0x6f')]=function(_0x5c4c0d,_0x25b3d6,_0x3ba80b){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x5c4c0d[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x25b3d6,null))[_0x111f('0x25')](function(_0x5699a4){if(_0x5699a4){return _0x5699a4[_0x111f('0x6f')](_0x5c4c0d['query'][_0x111f('0x70')]);}})[_0x111f('0x25')](respondWithStatusCode(_0x25b3d6,null))['catch'](handleError(_0x25b3d6,null));};exports[_0x111f('0x71')]=function(_0x229752,_0x333239,_0x582132){if(_0x229752[_0x111f('0x60')]['id']){delete _0x229752['body']['id'];}return db[_0x111f('0x52')]['find']({'where':{'id':_0x229752[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x333239,null))[_0x111f('0x25')](function(_0x5211f8){if(_0x5211f8){_0x229752[_0x111f('0x60')][_0x111f('0x6b')]=_0x5211f8['id'];return db[_0x111f('0x72')][_0x111f('0x5f')](_0x229752[_0x111f('0x60')]);}})[_0x111f('0x25')](respondWithResult(_0x333239,null))[_0x111f('0x57')](handleError(_0x333239,null));};exports['getAnswers']=function(_0x41a0f8,_0x22662b,_0x6942a){var _0x2c0869={'raw':![],'where':{}};var _0x21be68={};var _0x201528={'count':0x0,'rows':[]};return db[_0x111f('0x52')]['findOne']({'where':{'id':_0x41a0f8[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x22662b,null))[_0x111f('0x25')](function(_0x259870){if(_0x259870){_0x21be68[_0x111f('0x48')]=_['keys'](db[_0x111f('0x72')][_0x111f('0x42')]);_0x21be68['query']=_[_0x111f('0x5b')](_0x41a0f8[_0x111f('0x46')]);_0x21be68[_0x111f('0x47')]=_[_0x111f('0x5c')](_0x21be68[_0x111f('0x48')],_0x21be68[_0x111f('0x46')]);_0x2c0869[_0x111f('0x49')]=_['intersection'](_0x21be68[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x41a0f8[_0x111f('0x46')][_0x111f('0x5d')]));_0x2c0869[_0x111f('0x49')]=_0x2c0869['attributes'][_0x111f('0x4a')]?_0x2c0869[_0x111f('0x49')]:_0x21be68[_0x111f('0x48')];if(!_0x41a0f8['query'][_0x111f('0x6e')]('nolimit')){_0x2c0869[_0x111f('0x33')]=qs[_0x111f('0x33')](_0x41a0f8[_0x111f('0x46')][_0x111f('0x33')]);_0x2c0869[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x41a0f8['query']['offset']);}_0x2c0869[_0x111f('0x4c')]=qs[_0x111f('0x4d')](_0x41a0f8[_0x111f('0x46')][_0x111f('0x4d')]);_0x2c0869[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x41a0f8[_0x111f('0x46')],_0x21be68['filters']));_0x2c0869[_0x111f('0x4e')][_0x111f('0x6b')]=_0x259870['id'];if(_0x41a0f8[_0x111f('0x46')]['filter']){_0x2c0869[_0x111f('0x4e')]=_[_0x111f('0x50')](_0x2c0869[_0x111f('0x4e')],{'$or':_['map'](_0x2c0869['attributes'],function(_0x2f2744){var _0x3d6f9b={};_0x3d6f9b[_0x2f2744]={'$like':'%'+_0x41a0f8[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x3d6f9b;})});}_0x2c0869=_[_0x111f('0x50')]({},_0x2c0869,_0x41a0f8['options']);return db['CannedAnswer'][_0x111f('0x53')]({'where':_0x2c0869[_0x111f('0x4e')]})['then'](function(_0x444251){_0x201528['count']=_0x444251;if(_0x41a0f8[_0x111f('0x46')][_0x111f('0x54')]){_0x2c0869[_0x111f('0x55')]=[{'all':!![]}];}return db[_0x111f('0x72')][_0x111f('0x74')](_0x2c0869);})[_0x111f('0x25')](function(_0x426625){_0x201528[_0x111f('0x56')]=_0x426625;return _0x201528;});}})[_0x111f('0x25')](respondWithFilteredResult(_0x22662b,_0x2c0869))['catch'](handleError(_0x22662b,null));};exports[_0x111f('0x75')]=function(_0x1997c0,_0x4b45c2,_0x222c4b){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x1997c0[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x4b45c2,null))['then'](function(_0x392380){if(_0x392380){return _0x392380[_0x111f('0x75')](_0x1997c0[_0x111f('0x46')][_0x111f('0x70')]);}})[_0x111f('0x25')](respondWithStatusCode(_0x4b45c2,null))[_0x111f('0x57')](handleError(_0x4b45c2,null));};exports['addLogo']=function(_0x3caec3,_0x3aeef9,_0x587cd2){_0x3caec3['body'][_0x111f('0x76')]=_0x3caec3[_0x111f('0x77')][_0x111f('0x78')];return db['ChatWebsite'][_0x111f('0x65')]({'where':{'id':_0x3caec3[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x3aeef9,null))[_0x111f('0x25')](saveUpdates(_0x3caec3['body'],null))[_0x111f('0x25')](respondWithResult(_0x3aeef9,null))[_0x111f('0x57')](handleError(_0x3aeef9,null));};exports['addAvatar']=function(_0x5b1e6f,_0x58657f,_0x3874a9){_0x5b1e6f[_0x111f('0x60')][_0x111f('0x79')]=_0x5b1e6f[_0x111f('0x77')]['filename'];return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x5b1e6f['params']['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x58657f,null))[_0x111f('0x25')](saveUpdates(_0x5b1e6f['body'],null))[_0x111f('0x25')](respondWithResult(_0x58657f,null))[_0x111f('0x57')](handleError(_0x58657f,null));};exports[_0x111f('0x7a')]=function(_0x4d8cf2,_0x1eb294,_0xce005d){_0x4d8cf2[_0x111f('0x60')][_0x111f('0x7b')]=_0x4d8cf2['file'][_0x111f('0x78')];return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x4d8cf2['params']['id']}})['then'](handleEntityNotFound(_0x1eb294,null))[_0x111f('0x25')](saveUpdates(_0x4d8cf2[_0x111f('0x60')],null))[_0x111f('0x25')](respondWithResult(_0x1eb294,null))['catch'](handleError(_0x1eb294,null));};exports[_0x111f('0x7c')]=function(_0x202576,_0x428b40,_0x19ff3a){_0x202576[_0x111f('0x60')][_0x111f('0x7d')]=_0x202576[_0x111f('0x77')][_0x111f('0x78')];return db[_0x111f('0x52')]['find']({'where':{'id':_0x202576[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x428b40,null))[_0x111f('0x25')](saveUpdates(_0x202576['body'],null))['then'](respondWithResult(_0x428b40,null))['catch'](handleError(_0x428b40,null));};exports[_0x111f('0x7e')]=function(_0x25789a,_0x5444af,_0x1de9c0){var _0x19185e=path[_0x111f('0x7f')](config['root'],_0x111f('0x80'));var _0x4c0a14={'where':{'id':_0x25789a[_0x111f('0x59')]['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x3c4d18=![];return require(_0x111f('0x81'))[_0x111f('0x82')]()[_0x111f('0x25')](function(_0x19548c){if(_0x19548c){_0x3c4d18=_0x19548c[_0x111f('0x83')];}})[_0x111f('0x25')](function(){return db[_0x111f('0x52')][_0x111f('0x65')](_0x4c0a14);})[_0x111f('0x25')](handleEntityNotFound(_0x5444af,null))[_0x111f('0x25')](function(_0x5b2c07){if(_0x5b2c07){if(!_[_0x111f('0x84')](_0x5b2c07['sitepic'])){if(fs[_0x111f('0x85')](path[_0x111f('0x7f')](config[_0x111f('0x86')],'server/files/images/logos/',_0x5b2c07[_0x111f('0x76')]))&&_0x3c4d18){_0x19185e=path[_0x111f('0x7f')](config['root'],_0x111f('0x87'),_0x5b2c07['sitepic']);}}return _0x5444af['download'](_0x19185e);}})['catch'](handleError(_0x5444af,null));};exports['getAvatar']=function(_0x32ed7a,_0x4131f8,_0x54e6a1){var _0x142dcd=path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x88'));var _0x2d9475={'where':{'id':_0x32ed7a[_0x111f('0x59')]['id']},'attributes':['id',_0x111f('0x79')],'raw':!![]};return db[_0x111f('0x52')][_0x111f('0x65')](_0x2d9475)[_0x111f('0x25')](handleEntityNotFound(_0x4131f8,null))[_0x111f('0x25')](function(_0x513871){if(_0x513871){if(!_[_0x111f('0x84')](_0x513871[_0x111f('0x79')])){if(fs[_0x111f('0x85')](path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x513871['agentAvatar']))){_0x142dcd=path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x513871[_0x111f('0x79')]);}}return _0x4131f8['download'](_0x142dcd);}})[_0x111f('0x57')](handleError(_0x4131f8,null));};exports[_0x111f('0x8a')]=function(_0x18fdb9,_0xd3698f,_0x59d2a1){var _0x1a6a07=path[_0x111f('0x7f')](config['root'],_0x111f('0x8b'));var _0x594a3c={'where':{'id':_0x18fdb9[_0x111f('0x59')]['id']},'attributes':['id','customerAvatar',_0x111f('0x8c')],'raw':!![]};return db[_0x111f('0x52')][_0x111f('0x65')](_0x594a3c)[_0x111f('0x25')](handleEntityNotFound(_0xd3698f,null))[_0x111f('0x25')](function(_0x4af0f2){if(_0x4af0f2){if(!_[_0x111f('0x84')](_0x4af0f2[_0x111f('0x7b')])){if(fs[_0x111f('0x85')](path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x4af0f2[_0x111f('0x7b')]))&&_0x4af0f2[_0x111f('0x8c')]){_0x1a6a07=path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x4af0f2[_0x111f('0x7b')]);}}return _0xd3698f[_0x111f('0x8d')](_0x1a6a07);}})[_0x111f('0x57')](handleError(_0xd3698f,null));};exports[_0x111f('0x8e')]=function(_0x7d8ed8,_0x148fe3,_0x279862){var _0x8d2cbc=path[_0x111f('0x7f')](config['root'],'server/files/images/avatars/system_avatar.png');var _0x5579fc={'where':{'id':_0x7d8ed8[_0x111f('0x59')]['id']},'attributes':['id',_0x111f('0x7d')],'raw':!![]};return db[_0x111f('0x52')]['find'](_0x5579fc)[_0x111f('0x25')](handleEntityNotFound(_0x148fe3,null))[_0x111f('0x25')](function(_0x539089){if(_0x539089){if(!_[_0x111f('0x84')](_0x539089['systemAvatar'])){if(fs['existsSync'](path[_0x111f('0x7f')](config['root'],_0x111f('0x89'),_0x539089[_0x111f('0x7d')]))){_0x8d2cbc=path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x539089[_0x111f('0x7d')]);}}return _0x148fe3[_0x111f('0x8d')](_0x8d2cbc);}})[_0x111f('0x57')](handleError(_0x148fe3,null));};exports[_0x111f('0x8f')]=function(_0x500949,_0x36a51a,_0x2be27d){var _0x16aef9=require(_0x111f('0x90'));var _0x1aeab8=new _0x16aef9();var _0x1e78d6=_0x1aeab8[_0x111f('0x91')](_0x500949[_0x111f('0x92')][_0x111f('0x93')])['getResult']();var _0x213bc6={'body':_0x500949[_0x111f('0x60')],'channel':_0x111f('0x94')};var _0x442bab=[];var _0x483197=[];var _0x91ceb2={};var _0x16459c=![];return db[_0x111f('0x95')][_0x111f('0x6a')]()['then'](function(_0xcbe2e3){if(!_0xcbe2e3){throw new db[(_0x111f('0x21'))]['ValidationError'](_0x111f('0x96'));}_0x442bab=_[_0x111f('0x97')](_[_0x111f('0x5b')](_0xcbe2e3),[_0x111f('0x98'),_0x111f('0x99')]);_0x483197=_['difference'](_[_0x111f('0x5b')](_0xcbe2e3),[_0x111f('0x98'),_0x111f('0x99'),_0x111f('0x9a'),_0x111f('0x9b')]);if(_0x500949[_0x111f('0x60')]['id']){delete _0x500949[_0x111f('0x60')]['id'];}if(_[_0x111f('0x84')](_0x500949[_0x111f('0x60')][_0x111f('0x9c')])){throw new db[(_0x111f('0x21'))]['ValidationError'](_0x111f('0x9d'));}if(_[_0x111f('0x84')](_0x500949[_0x111f('0x60')][_0x111f('0x60')])||_0x500949[_0x111f('0x60')]['body']===''){throw new db[(_0x111f('0x21'))]['ValidationError']('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_['isNil'](_0x500949[_0x111f('0x60')][_0x111f('0x9e')])){throw new db[(_0x111f('0x21'))][(_0x111f('0x22'))](_0x111f('0x9f')+_0x483197);}if(!_[_0x111f('0xa0')](_0x483197,_0x500949['body'][_0x111f('0x9e')])){throw new db['Sequelize'][(_0x111f('0x22'))](_0x111f('0xa1')+_0x483197);}_0x91ceb2[_0x500949['body']['mapKey']]=_0x500949[_0x111f('0x60')]['from'];})[_0x111f('0x25')](function(){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x500949[_0x111f('0x59')]['id']},'include':[{'model':db[_0x111f('0xa2')],'as':_0x111f('0xa3'),'include':[{'model':db['CmContact'],'as':_0x111f('0xa4'),'where':_0x91ceb2,'limit':0x1,'order':[[_0x111f('0x99'),_0x111f('0xa5')]]}]},{'model':db['ChatApplication'],'as':_0x111f('0xa6')}]});})[_0x111f('0x25')](handleEntityNotFound(_0x36a51a,null))[_0x111f('0x25')](function(_0x54e24e){if(_0x54e24e&&_0x54e24e[_0x111f('0xa3')]){_0x213bc6[_0x111f('0xa7')]=_0x54e24e;_0x213bc6['applications']=_0x54e24e[_0x111f('0xa6')];_0x213bc6['list']=_0x54e24e[_0x111f('0xa3')];_0x213bc6[_0x111f('0xa8')]=_['orderBy'](_0x213bc6[_0x111f('0xa8')],[_0x111f('0xa9')],[_0x111f('0xaa')]);if(_0x213bc6['account'][_0x111f('0xa6')]){delete _0x213bc6['account']['Applications'];}if(_0x213bc6[_0x111f('0xa7')][_0x111f('0xa3')]&&_0x213bc6[_0x111f('0xa7')][_0x111f('0xa3')][_0x111f('0xa4')][_0x111f('0x4a')]){return _0x213bc6['account'][_0x111f('0xa3')][_0x111f('0xa4')][0x0];}var _0x43f798=_['defaults'](_0x500949[_0x111f('0x60')],{'firstName':_0x500949[_0x111f('0x60')][_0x111f('0x9c')],'ListId':_0x54e24e[_0x111f('0x9b')]});_0x43f798[_0x500949[_0x111f('0x60')][_0x111f('0x9e')]]=_0x500949[_0x111f('0x60')]['from'];return db['CmContact'][_0x111f('0x5f')](_0x43f798,{'fields':_0x442bab,'raw':!![]});}})[_0x111f('0x25')](handleEntityNotFound(_0x36a51a,null))[_0x111f('0x25')](function(_0x2ff9d1){_0x213bc6['contact']=_0x2ff9d1;var _0x2b6d8f=_0x500949['body']['customerIp'];if(_0x500949[_0x111f('0x92')][_0x111f('0xab')]){_0x2b6d8f=_0x500949[_0x111f('0x92')][_0x111f('0xab')];}else if(_0x500949['headers']['x-forwarded-for']){_0x2b6d8f=_[_0x111f('0xac')](_0x500949[_0x111f('0x92')]['x-forwarded-for']['split'](','));}if(_0x2ff9d1){var _0x29fd80={'ContactId':_0x2ff9d1['id'],'ChatWebsiteId':_0x500949[_0x111f('0x59')]['id'],'from':(_0x2ff9d1['firstName']||'')+'\x20'+(_0x2ff9d1['lastName']||''),'customerIp':_0x2b6d8f,'customerPort':_0x500949[_0x111f('0x92')][_0x111f('0xad')]?_0x500949[_0x111f('0x92')]['x-real-port']:null,'referer':_0x500949[_0x111f('0x60')][_0x111f('0xae')],'browserName':_0x1e78d6[_0x111f('0xaf')]['name']&&_0x1e78d6[_0x111f('0xaf')][_0x111f('0xb0')]?util[_0x111f('0xb1')](_0x111f('0xb2'),_0x1e78d6[_0x111f('0xaf')][_0x111f('0x3e')],_0x1e78d6[_0x111f('0xaf')]['version']):_0x111f('0xb3'),'browserVersion':_0x1e78d6[_0x111f('0xaf')]['version']||_0x111f('0xb3'),'osName':util[_0x111f('0xb1')](_0x111f('0xb2'),_0x1e78d6['os'][_0x111f('0x3e')],_0x1e78d6['os'][_0x111f('0xb0')]),'osVersion':_0x1e78d6['os']['version'],'deviceModel':_0x1e78d6[_0x111f('0xb4')]['model']&&_0x1e78d6[_0x111f('0xb4')]['vendor']?util[_0x111f('0xb1')](_0x111f('0xb5'),_0x1e78d6[_0x111f('0xb4')][_0x111f('0x48')],_0x1e78d6[_0x111f('0xb4')][_0x111f('0xb6')],_0x1e78d6[_0x111f('0xb4')][_0x111f('0x44')]):null,'deviceVendor':_0x1e78d6[_0x111f('0xb4')][_0x111f('0xb6')],'deviceType':_0x1e78d6[_0x111f('0xb4')]['type'],'formData':JSON['stringify'](_0x500949[_0x111f('0x60')])};var _0xbe839e={'ChatWebsiteId':_0x500949['params']['id'],'closed':![]};if(_0x500949[_0x111f('0x60')][_0x111f('0xb7')]){_0xbe839e[_0x111f('0xb7')]=_0x500949[_0x111f('0x60')][_0x111f('0xb7')];return db[_0x111f('0xb8')]['find']({'where':_0xbe839e})[_0x111f('0x25')](function(_0x2db594){if(_0x2db594){return[_0x2db594,![]];}_0x29fd80[_0x111f('0xb7')]=_0x500949[_0x111f('0x60')][_0x111f('0xb7')];_0x29fd80[_0x111f('0xb9')]=_0x500949[_0x111f('0x60')]['externalUrl'];return db[_0x111f('0xb8')][_0x111f('0x5f')](_0x29fd80)[_0x111f('0x25')](function(_0x573cf8){return[_0x573cf8,!![]];});});}_0xbe839e[_0x111f('0xba')]=_0x2ff9d1['id'];if(_0x500949[_0x111f('0x60')][_0x111f('0xbb')]&&_0x500949[_0x111f('0x60')]['interaction']['id']){_0xbe839e['id']=_0x500949[_0x111f('0x60')][_0x111f('0xbb')]['id'];return db[_0x111f('0xb8')][_0x111f('0x65')]({'where':_0xbe839e})['then'](function(_0x227391){if(_0x227391){return[_0x227391,![]];}return db['ChatInteraction'][_0x111f('0x5f')](_0x29fd80)[_0x111f('0x25')](function(_0x1ec50d){return[_0x1ec50d,!![]];});});}return db[_0x111f('0xb8')]['create'](_0x29fd80)[_0x111f('0x25')](function(_0x5db274){return[_0x5db274,!![]];});}})[_0x111f('0xbc')](function(_0x18d9a1,_0x2bddca){if(_0x18d9a1){_0x16459c=_0x2bddca;if(!_0x2bddca){var _0x4fc016={'from':(_0x213bc6['contact'][_0x111f('0xbd')]||'')+'\x20'+(_0x213bc6[_0x111f('0xbe')]['lastName']||'')};if(_0x500949[_0x111f('0x60')][_0x111f('0xb7')]&&_0x500949[_0x111f('0x60')][_0x111f('0xbf')]&&_0x500949['body']['threadId']!=_0x500949['body'][_0x111f('0xbf')]){_0x4fc016[_0x111f('0xb7')]=_0x500949[_0x111f('0x60')][_0x111f('0xbf')];}return _0x18d9a1[_0x111f('0x39')](_0x4fc016);}else{return _0x18d9a1;}}})[_0x111f('0x25')](function(_0x5ec6f4){_0x213bc6[_0x111f('0xbb')]=_0x5ec6f4[_0x111f('0x3b')]({'plain':!![]});_0x213bc6[_0x111f('0xbb')][_0x111f('0xc0')]=_0x16459c;if(_0x213bc6['interaction'][_0x111f('0xc0')]){if(_0x213bc6[_0x111f('0xa7')][_0x111f('0xc1')]){_0x213bc6['applications']['push']({'id':0x0,'priority':_0x213bc6['applications'][_0x111f('0x4a')]+0x1,'app':'close','appdata':'unmanaged','interval':_0x111f('0xc2')});}}return db[_0x111f('0xc3')][_0x111f('0x5f')]({'body':_0x500949[_0x111f('0x60')]['body'],'ChatWebsiteId':_0x500949[_0x111f('0x59')]['id'],'ChatInteractionId':_0x5ec6f4['id'],'direction':'in','ContactId':_0x213bc6[_0x111f('0xbe')]['id'],'AttachmentId':_0x500949[_0x111f('0x60')]['AttachmentId']});})[_0x111f('0x25')](function(_0xcfe194){_0x213bc6[_0x111f('0x2c')]=_0xcfe194;if(_0x213bc6['interaction']['UserId']){return db['User']['find']({'attributes':['id',_0x111f('0x3e')],'where':{'id':_0x213bc6[_0x111f('0xbb')][_0x111f('0xc4')]}})['then'](function(_0x1d4625){if(_0x1d4625){_0x213bc6[_0x111f('0xa8')][_0x111f('0xc5')]({'id':0x0,'priority':0x0,'app':_0x111f('0xc6'),'appdata':_0x1d4625[_0x111f('0x3e')]+','+(_0x213bc6[_0x111f('0xa7')][_0x111f('0xc7')]||0xa),'interval':_0x111f('0xc2')});_0x213bc6[_0x111f('0xc8')]=!![];}return respondWithRpcPromise(_0x111f('0xc9'),_0x111f('0xca'),_0x213bc6);});}return respondWithRpcPromise(_0x111f('0xc9'),'startRouting',_0x213bc6);})[_0x111f('0x25')](function(_0x1fca61){respondWithRpcPromise(_0x111f('0xcb'),_0x111f('0xcb'),{'event':_0x111f('0x8f'),'message':_0x1fca61},client9002);return _0x1fca61;})[_0x111f('0x25')](respondWithResult(_0x36a51a,null))['catch'](handleError(_0x36a51a,null));};exports['offline']=function(_0x1fdf5f,_0x103227,_0x2f1787){var _0x489f1f,_0x506099,_0x347b17;var _0x3dd51c=[];var _0x57c1c0=[];var _0x44445a={};return db[_0x111f('0x95')][_0x111f('0x6a')]()[_0x111f('0x25')](function(_0x5b5f5e){if(!_0x5b5f5e){throw new db[(_0x111f('0x21'))]['ValidationError']('no\x20available\x20attributes');}_0x57c1c0=_[_0x111f('0x97')](_['keys'](_0x5b5f5e),[_0x111f('0x98'),_0x111f('0x99')]);_0x3dd51c=_[_0x111f('0x97')](_[_0x111f('0x5b')](_0x5b5f5e),[_0x111f('0x98'),'updatedAt','CompanyId',_0x111f('0x9b')]);if(_0x1fdf5f[_0x111f('0x60')]['id']){delete _0x1fdf5f[_0x111f('0x60')]['id'];}if(_['isNil'](_0x1fdf5f['body'][_0x111f('0x9c')])){throw _0x103227[_0x111f('0x2f')](0x1f4)[_0x111f('0x3f')](new db[(_0x111f('0x21'))][(_0x111f('0x22'))](_0x111f('0x9d')));}if(_[_0x111f('0x84')](_0x1fdf5f[_0x111f('0x60')][_0x111f('0x60')])||_0x1fdf5f[_0x111f('0x60')][_0x111f('0x60')]===''){throw _0x103227[_0x111f('0x2f')](0x1f4)['send'](new db[(_0x111f('0x21'))][(_0x111f('0x22'))](_0x111f('0xcc')));}if(_[_0x111f('0x84')](_0x1fdf5f[_0x111f('0x60')][_0x111f('0xcd')])){throw _0x103227[_0x111f('0x2f')](0x1f4)[_0x111f('0x3f')](new db[(_0x111f('0x21'))]['ValidationError'](_0x111f('0xce')+_0x3dd51c));}if(!_[_0x111f('0xa0')](_0x3dd51c,_0x1fdf5f[_0x111f('0x60')][_0x111f('0xcd')])){throw _0x103227[_0x111f('0x2f')](0x1f4)[_0x111f('0x3f')](new db['Sequelize'][(_0x111f('0x22'))](_0x111f('0xcf')+_0x3dd51c));}_0x44445a[_0x1fdf5f['body'][_0x111f('0xcd')]]=_0x1fdf5f[_0x111f('0x60')][_0x111f('0x9c')];})[_0x111f('0x25')](function(){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x1fdf5f[_0x111f('0x59')]['id']},'include':[{'model':db['CmList'],'as':_0x111f('0xa3')}]});})[_0x111f('0x25')](handleEntityNotFound(_0x103227,null))[_0x111f('0x25')](function(_0x11c478){if(_0x11c478&&_0x11c478[_0x111f('0xa3')]){_0x506099=_0x11c478;var _0x1bd0d6=_[_0x111f('0xd0')](_0x1fdf5f[_0x111f('0x60')],{'firstName':_0x1fdf5f[_0x111f('0x60')][_0x111f('0x9c')],'phone':_0x1fdf5f[_0x111f('0x60')]['from'],'ListId':_0x11c478[_0x111f('0x9b')]});_0x1bd0d6[_0x1fdf5f['body'][_0x111f('0xcd')]]=_0x1fdf5f[_0x111f('0x60')][_0x111f('0x9c')];return db[_0x111f('0x95')][_0x111f('0xd1')]({'where':_0x44445a,'defaults':_0x1bd0d6});}})[_0x111f('0xbc')](function(_0x3d03ec){if(_0x3d03ec){_0x347b17=_0x3d03ec;var _0x5e80a8=fs[_0x111f('0xd2')](path['join'](config['root'],'server/files/templates/chatOfflineMessage.ejs'),_0x111f('0xd3'));var _0x5a48f6=ejs[_0x111f('0xd4')](_0x5e80a8,{'body':_[_0x111f('0xd5')](_0x1fdf5f[_0x111f('0x60')]['body']),'bodyTitle':_0x506099[_0x111f('0xd6')]});return db['ChatOfflineMessage'][_0x111f('0x5f')]({'body':_0x5a48f6,'ContactId':_0x3d03ec['id'],'ChatWebsiteId':_0x506099['id']});}})['then'](function(_0xfa9928){if(_0xfa9928){_0x489f1f=_0xfa9928;return db[_0x111f('0xd7')][_0x111f('0xd8')]({'where':{'service':!![]},'include':[{'model':db[_0x111f('0xd9')],'as':_0x111f('0xda'),'raw':!![]}]});}})[_0x111f('0x25')](function(_0x37b61e){if(_0x37b61e&&_0x37b61e[_0x111f('0xda')]&&_0x506099[_0x111f('0xdb')]){var _0x36e810={'tls':{'rejectUnauthorized':![]}};if(_0x37b61e[_0x111f('0xda')]['service']){_0x36e810[_0x111f('0xdc')]=_0x37b61e[_0x111f('0xda')][_0x111f('0xdc')];}else{_0x36e810[_0x111f('0xdd')]=_0x37b61e[_0x111f('0xda')][_0x111f('0xdd')];_0x36e810[_0x111f('0xde')]=_0x37b61e[_0x111f('0xda')][_0x111f('0xde')];_0x36e810['secure']=_0x37b61e['Smtp'][_0x111f('0xdf')];}if(_0x37b61e[_0x111f('0xda')]['authentication']){_0x36e810[_0x111f('0xe0')]={'user':_0x37b61e[_0x111f('0xda')][_0x111f('0x61')],'pass':_0x37b61e[_0x111f('0xda')][_0x111f('0xe1')]};}return respondWithRpcPromise(_0x111f('0xe2'),_0x111f('0xe3'),{'account':_0x36e810,'message':{'from':util[_0x111f('0xb1')](_0x111f('0xe4'),_0x37b61e[_0x111f('0x3e')],_0x37b61e[_0x111f('0xe5')]||_0x37b61e[_0x111f('0xda')][_0x111f('0x61')]),'to':_0x506099[_0x111f('0xdb')],'subject':_0x506099[_0x111f('0xe6')],'text':_0x489f1f[_0x111f('0x60')]}},client9003)[_0x111f('0x25')](function(){return _0x489f1f;})[_0x111f('0x57')](function(_0x3036ae){console[_0x111f('0x2a')](_0x3036ae);});}})[_0x111f('0x25')](function(){if(_0x489f1f){return _0x489f1f;}})[_0x111f('0x25')](respondWithResult(_0x103227,null))[_0x111f('0x57')](handleError(_0x103227,null));};exports[_0x111f('0xe7')]=function(_0x14c2cd,_0x1a531d,_0xf7b1fc){return db['ChatInteraction']['find']({'where':{'id':_0x14c2cd[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x1a531d,null))[_0x111f('0x25')](function(_0x4c49e9){if(_0x4c49e9){return _0x4c49e9[_0x111f('0xe7')](_0x14c2cd[_0x111f('0x60')]['ids'],_[_0x111f('0xe8')](_0x14c2cd['body'],[_0x111f('0x70'),'id'])||{});}})[_0x111f('0x25')](respondWithResult(_0x1a531d,null))[_0x111f('0x57')](handleError(_0x1a531d,null));};exports[_0x111f('0xe9')]=function(_0x5a84a0,_0xa63817,_0x55028a){var _0x3a99e7={'raw':![],'where':{}};var _0xe8a28f={};var _0x4a08bd={'count':0x0,'rows':[]};return db[_0x111f('0x52')][_0x111f('0xd8')]({'where':{'id':_0x5a84a0[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0xa63817,null))[_0x111f('0x25')](function(_0x1960a2){if(_0x1960a2){_0xe8a28f[_0x111f('0x48')]=_['keys'](db['ChatInteraction'][_0x111f('0x42')]);_0xe8a28f[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x5a84a0[_0x111f('0x46')]);_0xe8a28f[_0x111f('0x47')]=_[_0x111f('0x5c')](_0xe8a28f['model'],_0xe8a28f['query']);_0x3a99e7[_0x111f('0x49')]=_['intersection'](_0xe8a28f[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x5a84a0[_0x111f('0x46')][_0x111f('0x5d')]));_0x3a99e7['attributes']=_0x3a99e7[_0x111f('0x49')]['length']?_0x3a99e7['attributes']:_0xe8a28f[_0x111f('0x48')];if(!_0x5a84a0[_0x111f('0x46')][_0x111f('0x6e')](_0x111f('0x4b'))){_0x3a99e7[_0x111f('0x33')]=qs[_0x111f('0x33')](_0x5a84a0[_0x111f('0x46')][_0x111f('0x33')]);_0x3a99e7[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x5a84a0[_0x111f('0x46')][_0x111f('0x32')]);}_0x3a99e7[_0x111f('0x4c')]=qs['sort'](_0x5a84a0[_0x111f('0x46')]['sort']);_0x3a99e7[_0x111f('0x4e')]=qs['filters'](_['pick'](_0x5a84a0['query'],_0xe8a28f[_0x111f('0x47')]));_0x3a99e7[_0x111f('0x4e')][_0x111f('0x6b')]=_0x1960a2['id'];if(_0x5a84a0[_0x111f('0x46')][_0x111f('0x73')]){_0x3a99e7[_0x111f('0x4e')]=_['merge'](_0x3a99e7[_0x111f('0x4e')],{'$or':_[_0x111f('0x45')](_0x3a99e7[_0x111f('0x49')],function(_0xb2762d){var _0x512fbb={};_0x512fbb[_0xb2762d]={'$like':'%'+_0x5a84a0[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x512fbb;})});}_0x3a99e7=_[_0x111f('0x50')]({},_0x3a99e7,_0x5a84a0['options']);return db[_0x111f('0xb8')][_0x111f('0x53')]({'where':_0x3a99e7[_0x111f('0x4e')]})['then'](function(_0x58a277){_0x4a08bd['count']=_0x58a277;if(_0x5a84a0[_0x111f('0x46')][_0x111f('0x54')]){_0x3a99e7[_0x111f('0x55')]=[{'model':db[_0x111f('0x95')],'as':_0x111f('0xea'),'required':![]},{'model':db[_0x111f('0xeb')],'as':_0x111f('0xec'),'attributes':[_0x111f('0x3e'),'fullname',_0x111f('0xed')],'required':![]},{'model':db[_0x111f('0xee')],'as':'Tags','attributes':['id','name',_0x111f('0xef')],'where':_0x5a84a0[_0x111f('0x46')]['tag']?{'id':_0x5a84a0['query'][_0x111f('0xf0')]}:undefined,'required':_0x5a84a0[_0x111f('0x46')]['tag']?!![]:![]}];}return db[_0x111f('0xb8')][_0x111f('0x74')](_0x3a99e7);})['then'](function(_0x20f724){_0x4a08bd[_0x111f('0x56')]=_0x20f724;return _0x4a08bd;});}})['then'](respondWithFilteredResult(_0xa63817,_0x3a99e7))[_0x111f('0x57')](handleError(_0xa63817,null));};function iftimePromise(_0x161139,_0x279c5b){return respondWithRpcPromise('Command','getSnippet',{'command':_0x279c5b[_0x111f('0xf1')]?util[_0x111f('0xb1')]('iftime\x20%s,%s',_0x161139[_0x111f('0xf2')],_0x279c5b[_0x111f('0xf1')]):util[_0x111f('0xb1')](_0x111f('0xf3'),_0x161139[_0x111f('0xf2')])},client9002)['then'](function(_0x13cbd4){var _0xca5f7=_0x13cbd4&&_0x13cbd4[_0x111f('0xf4')](_0x111f('0xf5'))>=0x0?!![]:![];logger[_0x111f('0x26')](_0x111f('0xf6'),_0x279c5b['id'],_0x161139['id'],_0x161139[_0x111f('0xf2')],_0xca5f7?_0x111f('0xf7'):_0x111f('0xf8'),_0x279c5b[_0x111f('0xf1')]?_0x279c5b[_0x111f('0xf1')]:_0x111f('0xf9'));return _0xca5f7;})[_0x111f('0x57')](function(_0x12408b){logger[_0x111f('0x2a')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x279c5b['id'],_0x161139['id'],_0x161139[_0x111f('0xf2')],util[_0x111f('0xfa')](_0x12408b,{'showHidden':![],'depth':null}),_0x279c5b[_0x111f('0xf1')]?_0x279c5b[_0x111f('0xf1')]:_0x111f('0xf9'));return![];});}exports['getSnippet']=function(_0x4d5c65,_0x5603ba,_0xa528f8){var _0x39d2be=0x0;var _0x54c0b1=0x0;var _0x213570=![];var _0x317933;var _0xd4495e;return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x4d5c65[_0x111f('0x59')]['id']},'include':[{'model':db[_0x111f('0xfb')],'as':_0x111f('0xfb'),'include':[{'model':db['Interval'],'as':_0x111f('0xfc'),'attributes':['id',_0x111f('0xf2')],'raw':!![]}]}]})[_0x111f('0x25')](handleEntityNotFound(_0x5603ba,null))['then'](function(_0x1e09e7){if(_0x1e09e7){_0x317933=_0x1e09e7;return _0x1e09e7[_0x111f('0xfd')]({'raw':!![]});}})[_0x111f('0x25')](function(_0x25a764){if(_0x317933){if(_0x25a764){_0xd4495e=_0x25a764;}}return require('../../config/license/util')[_0x111f('0x82')]();})['then'](function(_0x1b471a){if(_0x1b471a){_0x54c0b1=_0x1b471a[_0x111f('0xfe')];_0x213570=_0x1b471a[_0x111f('0x83')];}})[_0x111f('0x25')](function(){return db[_0x111f('0xb8')][_0x111f('0x53')]({'where':{'closed':![]}});})[_0x111f('0x25')](function(_0x968278){_0x39d2be=_0x968278;if(_0x54c0b1&&_0x968278>_0x54c0b1){return db[_0x111f('0xff')][_0x111f('0xd8')]({'where':{'id':0x1}})['then'](function(_0x4ee2b2){if(_0x4ee2b2){_0x4ee2b2[_0x111f('0x100')]('chatLicenseExceeded');}});}})[_0x111f('0x25')](function(){if(_0x317933[_0x111f('0xfb')]&&_0x317933[_0x111f('0xfb')][_0x111f('0xfc')]){var _0x2ac058=[];for(var _0x257020=0x0;_0x257020<_0x317933['Interval']['Intervals']['length'];_0x257020++){var _0x4a4687=_0x317933[_0x111f('0xfb')][_0x111f('0xfc')][_0x257020][_0x111f('0x3b')]({'plain':!![]});_0x2ac058[_0x111f('0x101')](iftimePromise(_0x4a4687,_0x317933));}return BPromise[_0x111f('0x102')](_0x2ac058)[_0x111f('0x25')](function(_0x3887dc){return _[_0x111f('0x103')](_0x3887dc);});}else{return!![];}})[_0x111f('0x25')](function(_0x5130e6){var _0x236140=fs['readFileSync'](path['join'](config[_0x111f('0x86')],_0x111f('0x104')),_0x111f('0xd3'));var _0x45cb99={'remote':_0x317933['remote'],'query':querystring[_0x111f('0x105')](_[_0x111f('0x50')](_0x317933[_0x111f('0x3b')]({'plain':!![]}),{'customerIp':_0x4d5c65[_0x111f('0x92')][_0x111f('0x106')]||_0x4d5c65[_0x111f('0x92')][_0x111f('0x107')]||_0x4d5c65[_0x111f('0x108')]['remoteAddress']||_0x4d5c65['ip'],'referer':_0x4d5c65[_0x111f('0x92')][_0x111f('0xae')],'openedInteractions':_0x39d2be,'maxInteractions':_0x54c0b1,'virtual':_0x213570['virtual'],'online':_0x5130e6,'custom':_0x213570}))['replace'](/'/g,'\x5c\x27')};_0x5603ba['send'](ejs['render'](Mustache['render'](_0x236140,_0x45cb99),{'proactiveActions':_0xd4495e,'alignment':_0x317933[_0x111f('0x109')],'verticalAlignment':_0x317933[_0x111f('0x10a')],'div_color':_0x317933[_0x111f('0xef')],'text_color':_0x317933['textColor']}));})[_0x111f('0x57')](handleError(_0x5603ba,null));};exports[_0x111f('0x10b')]=function(_0x14fba6,_0x363bfe,_0x38a347){return db['ChatWebsite'][_0x111f('0xd8')]({'where':{'id':_0x14fba6[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x363bfe,null))['then'](function(_0x5a46a2){if(_0x5a46a2){return db['sequelize'][_0x111f('0x10c')](function(_0x528038){return db['ChatApplication'][_0x111f('0x3a')]({'where':{'ChatWebsiteId':_0x14fba6[_0x111f('0x59')]['id']},'transaction':_0x528038})['then'](function(_0xb2fc2c){var _0x3a8f2f=_[_0x111f('0x45')](_0x14fba6['body'],function(_0x2030b0){_0x2030b0[_0x111f('0x6b')]=_0x14fba6[_0x111f('0x59')]['id'];return _0x2030b0;});return db[_0x111f('0x10d')][_0x111f('0x10e')](_0x3a8f2f,{'transaction':_0x528038});});})[_0x111f('0x25')](function(){return db[_0x111f('0x10d')][_0x111f('0x10f')]({'where':{'ChatWebsiteId':_0x14fba6['params']['id']},'order':_0x111f('0xa9')});});}})[_0x111f('0x25')](respondWithResult(_0x363bfe,null))[_0x111f('0x57')](handleError(_0x363bfe,null));};exports[_0x111f('0x110')]=function(_0x323ebf,_0x12e53f,_0x338ff5){var _0x50a4d4={};var _0xc38494={};var _0x53580d;var _0x127476;return db[_0x111f('0x52')][_0x111f('0xd8')]({'where':{'id':_0x323ebf[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x12e53f,null))[_0x111f('0x25')](function(_0x54f1a0){if(_0x54f1a0){_0x53580d=_0x54f1a0;_0xc38494[_0x111f('0x48')]=_['keys'](db['ChatApplication'][_0x111f('0x42')]);_0xc38494[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x323ebf[_0x111f('0x46')]);_0xc38494['filters']=_['intersection'](_0xc38494[_0x111f('0x48')],_0xc38494[_0x111f('0x46')]);_0x50a4d4[_0x111f('0x49')]=_[_0x111f('0x5c')](_0xc38494[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x323ebf['query']['fields']));_0x50a4d4['attributes']=_0x50a4d4[_0x111f('0x49')][_0x111f('0x4a')]?_0x50a4d4['attributes']:_0xc38494[_0x111f('0x48')];_0x50a4d4[_0x111f('0x4c')]=qs[_0x111f('0x4d')](_0x323ebf[_0x111f('0x46')][_0x111f('0x4d')]);_0x50a4d4['where']=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x323ebf[_0x111f('0x46')],_0xc38494[_0x111f('0x47')]));if(_0x323ebf[_0x111f('0x46')][_0x111f('0x73')]){_0x50a4d4[_0x111f('0x4e')]=_[_0x111f('0x50')](_0x50a4d4[_0x111f('0x4e')],{'$or':_[_0x111f('0x45')](_0x50a4d4['attributes'],function(_0x267901){var _0x4f1d99={};_0x4f1d99[_0x267901]={'$like':'%'+_0x323ebf['query'][_0x111f('0x73')]+'%'};return _0x4f1d99;})});}_0x50a4d4=_[_0x111f('0x50')]({},_0x50a4d4,_0x323ebf[_0x111f('0x5e')]);return _0x53580d['getApplications'](_0x50a4d4);}})[_0x111f('0x25')](function(_0x4e6ea6){if(_0x4e6ea6){_0x127476=_0x4e6ea6[_0x111f('0x4a')];if(!_0x323ebf['query'][_0x111f('0x6e')]('nolimit')){_0x50a4d4[_0x111f('0x33')]=qs[_0x111f('0x33')](_0x323ebf[_0x111f('0x46')]['limit']);_0x50a4d4[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x323ebf[_0x111f('0x46')]['offset']);}return _0x53580d['getApplications'](_0x50a4d4);}})[_0x111f('0x25')](function(_0x2ede1c){if(_0x2ede1c){return _0x2ede1c?{'count':_0x127476,'rows':_0x2ede1c}:null;}})[_0x111f('0x25')](respondWithResult(_0x12e53f,null))['catch'](handleError(_0x12e53f,null));};exports['addProactiveActions']=function(_0x36b00e,_0x281b77,_0x34bc51){return db[_0x111f('0x111')][_0x111f('0x65')]({'where':{'id':_0x36b00e[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x281b77,null))[_0x111f('0x25')](function(_0x5b9f56){if(_0x5b9f56){return _0x5b9f56[_0x111f('0x112')](_0x36b00e[_0x111f('0x60')]['ids'],_[_0x111f('0xe8')](_0x36b00e[_0x111f('0x60')],[_0x111f('0x70'),'id'])||{});}})[_0x111f('0x25')](respondWithResult(_0x281b77,null))['catch'](handleError(_0x281b77,null));};exports[_0x111f('0xfd')]=function(_0x2b7760,_0x171271,_0x2c1aec){var _0x5a6d6a={};var _0x5dbc0e={};var _0x111c11;var _0x47d1d5;return db[_0x111f('0x52')]['findOne']({'where':{'id':_0x2b7760[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x171271,null))[_0x111f('0x25')](function(_0x31112d){if(_0x31112d){_0x111c11=_0x31112d;_0x5dbc0e['model']=_[_0x111f('0x5b')](db['ChatProactiveAction']['rawAttributes']);_0x5dbc0e[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x2b7760[_0x111f('0x46')]);_0x5dbc0e['filters']=_['intersection'](_0x5dbc0e['model'],_0x5dbc0e[_0x111f('0x46')]);_0x5a6d6a[_0x111f('0x49')]=_[_0x111f('0x5c')](_0x5dbc0e['model'],qs['fields'](_0x2b7760['query'][_0x111f('0x5d')]));_0x5a6d6a['attributes']=_0x5a6d6a[_0x111f('0x49')]['length']?_0x5a6d6a[_0x111f('0x49')]:_0x5dbc0e[_0x111f('0x48')];_0x5a6d6a['order']=qs['sort'](_0x2b7760['query'][_0x111f('0x4d')]);_0x5a6d6a[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x2b7760[_0x111f('0x46')],_0x5dbc0e['filters']));if(_0x2b7760['query']['filter']){_0x5a6d6a[_0x111f('0x4e')]=_['merge'](_0x5a6d6a[_0x111f('0x4e')],{'$or':_[_0x111f('0x45')](_0x5a6d6a[_0x111f('0x49')],function(_0xadc0ae){var _0x2a0bd6={};_0x2a0bd6[_0xadc0ae]={'$like':'%'+_0x2b7760[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x2a0bd6;})});}_0x5a6d6a=_['merge']({},_0x5a6d6a,_0x2b7760[_0x111f('0x5e')]);return _0x111c11['getProactiveActions'](_0x5a6d6a);}})[_0x111f('0x25')](function(_0x2c7397){if(_0x2c7397){_0x47d1d5=_0x2c7397[_0x111f('0x4a')];if(!_0x2b7760[_0x111f('0x46')][_0x111f('0x6e')](_0x111f('0x4b'))){_0x5a6d6a['limit']=qs[_0x111f('0x33')](_0x2b7760[_0x111f('0x46')]['limit']);_0x5a6d6a[_0x111f('0x32')]=qs['offset'](_0x2b7760[_0x111f('0x46')][_0x111f('0x32')]);}return _0x111c11[_0x111f('0xfd')](_0x5a6d6a);}})[_0x111f('0x25')](function(_0x310ebd){if(_0x310ebd){return _0x310ebd?{'count':_0x47d1d5,'rows':_0x310ebd}:null;}})[_0x111f('0x25')](respondWithResult(_0x171271,null))[_0x111f('0x57')](handleError(_0x171271,null));};exports['getFields']=function(_0xc181d1,_0x5f4b15,_0x3cd12e){var _0x51ad5=_0xc181d1[_0x111f('0x46')][_0x111f('0x113')]===_0x111f('0x114')?_0x111f('0x115'):_0x111f('0x116');return db[_0x111f('0x52')]['find']({'attributes':['id',_0x51ad5],'where':{'id':_0xc181d1[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x5f4b15,null))[_0x111f('0x25')](function(_0x505398){if(_0x505398){var _0x232927=_0x505398[_0x51ad5];var _0x43348f=_0x232927&&_0x232927[_0x111f('0x117')]?_0x232927[_0x111f('0x117')]:[];_0x5f4b15[_0x111f('0x3f')]({'fromKey':_[_0x111f('0x84')](_0x232927[_0x111f('0x118')])?undefined:_0x232927['fromKey'],'count':_0x43348f[_0x111f('0x4a')],'rows':_0x43348f});}})[_0x111f('0x57')](handleError(_0x5f4b15,null));};exports['getOfflineMessages']=function(_0x5a79dd,_0x13f9e2,_0x1ff8e9){var _0x15fceb={'raw':![],'where':{}};var _0x177146={};var _0xd73d20={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x111f('0xd8')]({'where':{'id':_0x5a79dd['params']['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x13f9e2,null))['then'](function(_0x523a1e){if(_0x523a1e){_0x177146[_0x111f('0x48')]=_[_0x111f('0x5b')](db[_0x111f('0x119')][_0x111f('0x42')]);_0x177146[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x5a79dd[_0x111f('0x46')]);_0x177146[_0x111f('0x47')]=_[_0x111f('0x5c')](_0x177146[_0x111f('0x48')],_0x177146[_0x111f('0x46')]);_0x15fceb[_0x111f('0x49')]=_[_0x111f('0x5c')](_0x177146[_0x111f('0x48')],qs['fields'](_0x5a79dd[_0x111f('0x46')][_0x111f('0x5d')]));_0x15fceb[_0x111f('0x49')]=_0x15fceb['attributes']['length']?_0x15fceb['attributes']:_0x177146[_0x111f('0x48')];if(!_0x5a79dd[_0x111f('0x46')]['hasOwnProperty'](_0x111f('0x4b'))){_0x15fceb['limit']=qs[_0x111f('0x33')](_0x5a79dd['query'][_0x111f('0x33')]);_0x15fceb[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x5a79dd['query'][_0x111f('0x32')]);}_0x15fceb[_0x111f('0x4c')]=qs[_0x111f('0x4d')](_0x5a79dd[_0x111f('0x46')][_0x111f('0x4d')]);_0x15fceb['where']=qs['filters'](_['pick'](_0x5a79dd['query'],_0x177146[_0x111f('0x47')]));_0x15fceb['where'][_0x111f('0x6b')]=_0x523a1e['id'];if(_0x5a79dd[_0x111f('0x46')]['filter']){_0x15fceb['where']=_[_0x111f('0x50')](_0x15fceb[_0x111f('0x4e')],{'$or':_[_0x111f('0x45')](_0x15fceb[_0x111f('0x49')],function(_0x5be102){var _0x218be9={};_0x218be9[_0x5be102]={'$like':'%'+_0x5a79dd[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x218be9;})});}_0x15fceb=_[_0x111f('0x50')]({},_0x15fceb,_0x5a79dd[_0x111f('0x5e')]);return db['ChatOfflineMessage'][_0x111f('0x53')]({'where':_0x15fceb[_0x111f('0x4e')]})[_0x111f('0x25')](function(_0x211421){_0xd73d20['count']=_0x211421;if(_0x5a79dd[_0x111f('0x46')][_0x111f('0x54')]){_0x15fceb[_0x111f('0x55')]=[{'all':!![]}];}else{_0x15fceb['include']=[{'model':db[_0x111f('0x95')],'as':_0x111f('0xea'),'required':![]}];}return db['ChatOfflineMessage'][_0x111f('0x74')](_0x15fceb);})[_0x111f('0x25')](function(_0x35f237){_0xd73d20[_0x111f('0x56')]=_0x35f237;return _0xd73d20;});}})['then'](respondWithFilteredResult(_0x13f9e2,_0x15fceb))[_0x111f('0x57')](handleError(_0x13f9e2,null));};exports[_0x111f('0x11a')]=function(_0x59f90f,_0x3fabb4,_0x55f535){return db[_0x111f('0x52')]['find']({'where':{'id':_0x59f90f[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x3fabb4,null))['then'](function(_0x544e64){if(_0x544e64){return _0x544e64[_0x111f('0x11a')](_0x59f90f['body'][_0x111f('0x70')],_['omit'](_0x59f90f[_0x111f('0x60')],[_0x111f('0x70'),'id'])||{})[_0x111f('0xbc')](function(_0x4e31e8){for(var _0xf6b279=0x0;_0xf6b279<_0x59f90f[_0x111f('0x60')][_0x111f('0x70')][_0x111f('0x4a')];_0xf6b279+=0x1){socket[_0x111f('0x11b')](_0x111f('0x11c'),{'UserId':_0x59f90f[_0x111f('0x60')][_0x111f('0x70')][_0xf6b279],'ChatWebsiteId':_0x59f90f[_0x111f('0x59')]['id']});}return _0x4e31e8;});}})[_0x111f('0x25')](respondWithResult(_0x3fabb4,null))[_0x111f('0x57')](handleError(_0x3fabb4,null));};exports['removeAgents']=function(_0x20d9f5,_0x40e0ed,_0x7d61ab){return db['ChatWebsite']['find']({'where':{'id':_0x20d9f5[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x40e0ed,null))['then'](function(_0x3d0202){if(_0x3d0202){return _0x3d0202['removeAgents'](_0x20d9f5[_0x111f('0x46')][_0x111f('0x70')])[_0x111f('0x25')](function(){if(_['isArray'](_0x20d9f5[_0x111f('0x46')][_0x111f('0x70')])){for(var _0x3e460b=0x0;_0x3e460b<_0x20d9f5[_0x111f('0x46')][_0x111f('0x70')]['length'];_0x3e460b+=0x1){socket[_0x111f('0x11b')](_0x111f('0x11d'),{'UserId':Number(_0x20d9f5[_0x111f('0x46')]['ids'][_0x3e460b]),'ChatWebsiteId':Number(_0x20d9f5[_0x111f('0x59')]['id'])});}}else{socket[_0x111f('0x11b')](_0x111f('0x11d'),{'UserId':Number(_0x20d9f5[_0x111f('0x46')][_0x111f('0x70')]),'ChatWebsiteId':Number(_0x20d9f5[_0x111f('0x59')]['id'])});}});}})[_0x111f('0x25')](respondWithStatusCode(_0x40e0ed,null))[_0x111f('0x57')](handleError(_0x40e0ed,null));};exports[_0x111f('0x11e')]=function(_0x2134c8,_0x7e36f6,_0x4784b2){var _0x46bf50={};var _0x993fde={};var _0x4555be;var _0x5b2601;return db[_0x111f('0x52')]['findOne']({'where':{'id':_0x2134c8[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x7e36f6,null))[_0x111f('0x25')](function(_0x5da68c){if(_0x5da68c){_0x4555be=_0x5da68c;_0x993fde['model']=_['keys'](db[_0x111f('0xeb')][_0x111f('0x42')]);_0x993fde[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x2134c8[_0x111f('0x46')]);_0x993fde[_0x111f('0x47')]=_[_0x111f('0x5c')](_0x993fde[_0x111f('0x48')],_0x993fde[_0x111f('0x46')]);_0x46bf50[_0x111f('0x49')]=_[_0x111f('0x5c')](_0x993fde[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x2134c8[_0x111f('0x46')][_0x111f('0x5d')]));_0x46bf50['attributes']=_0x46bf50[_0x111f('0x49')][_0x111f('0x4a')]?_0x46bf50['attributes']:_0x993fde[_0x111f('0x48')];_0x46bf50['order']=qs[_0x111f('0x4d')](_0x2134c8[_0x111f('0x46')][_0x111f('0x4d')]);_0x46bf50[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x2134c8[_0x111f('0x46')],_0x993fde['filters']));if(_0x2134c8['query'][_0x111f('0x73')]){_0x46bf50[_0x111f('0x4e')]=_['merge'](_0x46bf50[_0x111f('0x4e')],{'$or':_['map'](_0x46bf50[_0x111f('0x49')],function(_0x777234){var _0x397fc3={};_0x397fc3[_0x777234]={'$like':'%'+_0x2134c8[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x397fc3;})});}_0x46bf50=_[_0x111f('0x50')]({},_0x46bf50,_0x2134c8[_0x111f('0x5e')]);return _0x4555be[_0x111f('0x11e')](_0x46bf50);}})[_0x111f('0x25')](function(_0x1f97c8){if(_0x1f97c8){_0x5b2601=_0x1f97c8[_0x111f('0x4a')];if(!_0x2134c8[_0x111f('0x46')][_0x111f('0x6e')](_0x111f('0x4b'))){_0x46bf50[_0x111f('0x33')]=qs[_0x111f('0x33')](_0x2134c8[_0x111f('0x46')]['limit']);_0x46bf50[_0x111f('0x32')]=qs['offset'](_0x2134c8[_0x111f('0x46')][_0x111f('0x32')]);}return _0x4555be[_0x111f('0x11e')](_0x46bf50);}})[_0x111f('0x25')](function(_0x4c1464){if(_0x4c1464){return _0x4c1464?{'count':_0x5b2601,'rows':_0x4c1464}:null;}})[_0x111f('0x25')](respondWithResult(_0x7e36f6,null))[_0x111f('0x57')](handleError(_0x7e36f6,null));};
\ No newline at end of file
+var _0xdfcc=['ChatApplication','Applications','account','applications','list','orderBy','priority','asc','ListId','contact','headers','cf-connecting-ip','x-forwarded-for','first','split','firstName','x-real-port','referer','browser','version','format','%s\x20%s','unknown','device','%s\x20%s\x20%s','threadId','externalUrl','ChatInteraction','ContactId','interaction','messageId','push','close','ChatMessage','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','Start','startRouting','EventManager','notify','offline','files','CompanyId','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','fromString','originalname','mimetype','attachments','offline-chat','openNewInteraction','sequelize','transaction','Attachment','bulkCreate','MailServerOut','Smtp','CloudProvider','forwardOfflineAddress','getSmtpOptions','SendMail','sendMail','\x22%s\x22\x20<%s>','email','MailAccountId','subjectOffline','toPairsIn','mapValues','lastName','NotifyMailAccount','notifyMail','server','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','Owner','fullname','internal','Tags','color','tag','Command','getSnippet','timezone','iftime\x20%s,%s','interval','iftime\x20%s','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','Intervals','getProactiveActions','virtual','all','some','server/files/chat/iframe.ejs','remote','alignment','verticalAlignment','labelText','color_button','backgroundColor','hideWhenOffline','READ_COMMITTED','findAndCountAll','finally','getApplications','addProactiveActions','ChatProactiveAction','offlineForm','onlineForm','items','fromKey','getOfflineMessages','Attachments','addAgents','emit','userChatWebsite:save','removeAgents','userChatWebsite:remove','getAgents','bluebird','mustache','util','ejs','fs-extra','lodash','ioredis','../../config/environment','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./chatWebsite.socket','html-to-text','jayson/promise','client','http','then','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','catch','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','update','destroy','get','UserProfileResource','stack','name','send','index','Pause','mandatoryDispositionPause','map','rawAttributes','fieldName','type','key','query','keys','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','ChatWebsite','includeAll','include','findAll','rows','params','find','create','body','user','role','ChatWebsites','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ChatWebsiteId','getDispositions','Disposition','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','findOne','removeAnswers','addLogo','sitepic','filename','addAvatar','agentAvatar','file','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','../../config/license/util','getLicense','custom','isNil','existsSync','server/files/images/logos/','download','getAvatar','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','customerAvatar','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','user-agent-parser','setUA','user-agent','getResult','CmContact','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','from','Sequelize','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','DESC'];(function(_0xc5330c,_0x5d92d7){var _0x384e3f=function(_0x5e5a45){while(--_0x5e5a45){_0xc5330c['push'](_0xc5330c['shift']());}};_0x384e3f(++_0x5d92d7);}(_0xdfcc,0x8d));var _0xcdfc=function(_0x466247,_0x5d69e3){_0x466247=_0x466247-0x0;var _0x4b352e=_0xdfcc[_0x466247];return _0x4b352e;};'use strict';var BPromise=require(_0xcdfc('0x0'));var Mustache=require(_0xcdfc('0x1'));var util=require(_0xcdfc('0x2'));var path=require('path');var ejs=require(_0xcdfc('0x3'));var fs=require('fs');var fs_extra=require(_0xcdfc('0x4'));var _=require(_0xcdfc('0x5'));var querystring=require('querystring');var Redis=require(_0xcdfc('0x6'));var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')('api');var config=require(_0xcdfc('0x7'));var db=require(_0xcdfc('0x8'))['db'];config['redis']=_[_0xcdfc('0x9')](config[_0xcdfc('0xa')],{'host':_0xcdfc('0xb'),'port':0x18eb});var socket=require(_0xcdfc('0xc'))(new Redis(config['redis']));require(_0xcdfc('0xd'))['register'](socket);var htmlToText=require(_0xcdfc('0xe'));var jayson=require(_0xcdfc('0xf'));var client=jayson[_0xcdfc('0x10')][_0xcdfc('0x11')]({'port':0x232c});var client9002=jayson[_0xcdfc('0x10')][_0xcdfc('0x11')]({'port':0x232a});var client9003=jayson['client']['http']({'port':0x232b});var client9001=jayson[_0xcdfc('0x10')][_0xcdfc('0x11')]({'port':0x2329});function respondWithRpcPromise(_0x59015f,_0x3b4b35,_0x358805,_0x5b278d){return new BPromise(function(_0x23ed41,_0x29e684){var _0x73baa6=_0x5b278d||client;return _0x73baa6['request'](_0x59015f,_0x358805)[_0xcdfc('0x12')](function(_0xb5a56a){logger['info'](_0xcdfc('0x13'),_0x3b4b35,_0xcdfc('0x14'));logger[_0xcdfc('0x15')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x3b4b35,_0xcdfc('0x14'),JSON[_0xcdfc('0x16')](_0xb5a56a));if(_0xb5a56a['error']){if(_0xb5a56a[_0xcdfc('0x17')][_0xcdfc('0x18')]===0x1f4){logger['error'](_0xcdfc('0x13'),_0x3b4b35,_0xb5a56a[_0xcdfc('0x17')][_0xcdfc('0x19')]);return _0x29e684(_0xb5a56a['error'][_0xcdfc('0x19')]);}logger[_0xcdfc('0x17')]('ChatWebsite,\x20%s,\x20%s',_0x3b4b35,_0xb5a56a[_0xcdfc('0x17')][_0xcdfc('0x19')]);return _0x23ed41(_0xb5a56a[_0xcdfc('0x17')][_0xcdfc('0x19')]);}else{logger[_0xcdfc('0x1a')](_0xcdfc('0x13'),_0x3b4b35,'request\x20sent');_0x23ed41(_0xb5a56a[_0xcdfc('0x1b')]['message']);}})[_0xcdfc('0x1c')](function(_0x23d000){logger[_0xcdfc('0x17')](_0xcdfc('0x13'),_0x3b4b35,_0x23d000);_0x29e684(_0x23d000);});});}function respondWithStatusCode(_0x4e58ce,_0x183ada){_0x183ada=_0x183ada||0xcc;return function(_0x1949df){if(_0x1949df){return _0x4e58ce[_0xcdfc('0x1d')](_0x183ada);}return _0x4e58ce[_0xcdfc('0x1e')](_0x183ada)[_0xcdfc('0x1f')]();};}function respondWithResult(_0x458587,_0x101ba0){_0x101ba0=_0x101ba0||0xc8;return function(_0x3bdd7f){if(_0x3bdd7f){return _0x458587[_0xcdfc('0x1e')](_0x101ba0)[_0xcdfc('0x20')](_0x3bdd7f);}};}function respondWithFilteredResult(_0x44ab0b,_0x48ab9b){return function(_0x323fd5){if(_0x323fd5){var _0x4f922c=typeof _0x48ab9b[_0xcdfc('0x21')]===_0xcdfc('0x22')&&typeof _0x48ab9b[_0xcdfc('0x23')]===_0xcdfc('0x22');var _0x1de322=_0x323fd5[_0xcdfc('0x24')];var _0x3ef346=_0x4f922c?0x0:_0x48ab9b['offset'];var _0x48827a=_0x4f922c?_0x323fd5[_0xcdfc('0x24')]:_0x48ab9b[_0xcdfc('0x21')]+_0x48ab9b[_0xcdfc('0x23')];var _0xaf2735;if(_0x48827a>=_0x1de322){_0x48827a=_0x1de322;_0xaf2735=0xc8;}else{_0xaf2735=0xce;}_0x44ab0b['status'](_0xaf2735);return _0x44ab0b[_0xcdfc('0x25')](_0xcdfc('0x26'),_0x3ef346+'-'+_0x48827a+'/'+_0x1de322)['json'](_0x323fd5);}return null;};}function saveUpdates(_0x5b19e2){return function(_0x29cc4e){if(_0x29cc4e){return _0x29cc4e[_0xcdfc('0x27')](_0x5b19e2)[_0xcdfc('0x12')](function(_0x4b56c4){return _0x4b56c4;});}return null;};}function removeEntity(_0x411229){return function(_0x209ca7){if(_0x209ca7){return _0x209ca7[_0xcdfc('0x28')]()[_0xcdfc('0x12')](function(){var _0x481f3f=_0x209ca7[_0xcdfc('0x29')]({'plain':!![]});var _0x51c461='ChatWebsites';return db[_0xcdfc('0x2a')][_0xcdfc('0x28')]({'where':{'type':_0x51c461,'resourceId':_0x481f3f['id']}})['then'](function(){return _0x209ca7;});})['then'](function(){_0x411229[_0xcdfc('0x1e')](0xcc)['end']();});}};}function handleEntityNotFound(_0x64f1e2){return function(_0x3bd0f6){if(!_0x3bd0f6){_0x64f1e2[_0xcdfc('0x1d')](0x194);}return _0x3bd0f6;};}function handleError(_0x5cabd5,_0x40ab45){_0x40ab45=_0x40ab45||0x1f4;return function(_0x36e0b3){logger[_0xcdfc('0x17')](_0x36e0b3[_0xcdfc('0x2b')]);if(_0x36e0b3[_0xcdfc('0x2c')]){delete _0x36e0b3['name'];}_0x5cabd5[_0xcdfc('0x1e')](_0x40ab45)[_0xcdfc('0x2d')](_0x36e0b3);};}exports[_0xcdfc('0x2e')]=function(_0x152bfb,_0x408c28){var _0x44eb1a={'include':[{'model':db[_0xcdfc('0x2f')],'as':_0xcdfc('0x30')}]},_0x22237e={},_0x417490={'count':0x0,'rows':[]};var _0xaa9d1=_[_0xcdfc('0x31')](db['ChatWebsite'][_0xcdfc('0x32')],function(_0xcb460){return{'name':_0xcb460[_0xcdfc('0x33')],'type':_0xcb460[_0xcdfc('0x34')][_0xcdfc('0x35')]};});_0x22237e['model']=_[_0xcdfc('0x31')](_0xaa9d1,_0xcdfc('0x2c'));_0x22237e[_0xcdfc('0x36')]=_[_0xcdfc('0x37')](_0x152bfb[_0xcdfc('0x36')]);_0x22237e['filters']=_[_0xcdfc('0x38')](_0x22237e[_0xcdfc('0x39')],_0x22237e['query']);_0x44eb1a[_0xcdfc('0x3a')]=_[_0xcdfc('0x38')](_0x22237e[_0xcdfc('0x39')],qs[_0xcdfc('0x3b')](_0x152bfb['query']['fields']));_0x44eb1a['attributes']=_0x44eb1a[_0xcdfc('0x3a')][_0xcdfc('0x3c')]?_0x44eb1a['attributes']:_0x22237e[_0xcdfc('0x39')];if(!_0x152bfb[_0xcdfc('0x36')][_0xcdfc('0x3d')](_0xcdfc('0x3e'))){_0x44eb1a['limit']=qs[_0xcdfc('0x23')](_0x152bfb['query'][_0xcdfc('0x23')]);_0x44eb1a[_0xcdfc('0x21')]=qs[_0xcdfc('0x21')](_0x152bfb[_0xcdfc('0x36')]['offset']);}_0x44eb1a[_0xcdfc('0x3f')]=qs[_0xcdfc('0x40')](_0x152bfb['query']['sort']);_0x44eb1a[_0xcdfc('0x41')]=qs[_0xcdfc('0x42')](_[_0xcdfc('0x43')](_0x152bfb['query'],_0x22237e[_0xcdfc('0x42')]),_0xaa9d1);if(_0x152bfb[_0xcdfc('0x36')][_0xcdfc('0x44')]){_0x44eb1a[_0xcdfc('0x41')]=_[_0xcdfc('0x45')](_0x44eb1a[_0xcdfc('0x41')],{'$or':_['map'](_0xaa9d1,function(_0x2ae779){if(_0x2ae779['type']!==_0xcdfc('0x46')){var _0x3ab33b={};_0x3ab33b[_0x2ae779['name']]={'$like':'%'+_0x152bfb['query'][_0xcdfc('0x44')]+'%'};return _0x3ab33b;}})});}_0x44eb1a=_[_0xcdfc('0x45')]({},_0x44eb1a,_0x152bfb[_0xcdfc('0x47')]);var _0x23095e={'where':_0x44eb1a[_0xcdfc('0x41')]};return db[_0xcdfc('0x48')]['count'](_0x23095e)[_0xcdfc('0x12')](function(_0x2497f8){_0x417490[_0xcdfc('0x24')]=_0x2497f8;if(_0x152bfb[_0xcdfc('0x36')][_0xcdfc('0x49')]){_0x44eb1a[_0xcdfc('0x4a')]=[{'all':!![]}];}return db[_0xcdfc('0x48')][_0xcdfc('0x4b')](_0x44eb1a);})[_0xcdfc('0x12')](function(_0x47ac7a){_0x417490[_0xcdfc('0x4c')]=_0x47ac7a;return _0x417490;})[_0xcdfc('0x12')](respondWithFilteredResult(_0x408c28,_0x44eb1a))[_0xcdfc('0x1c')](handleError(_0x408c28,null));};exports['show']=function(_0x505f23,_0x1c3098){var _0x5b70b1={'raw':![],'where':{'id':_0x505f23[_0xcdfc('0x4d')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x70a97c={};_0x70a97c[_0xcdfc('0x39')]=_[_0xcdfc('0x37')](db[_0xcdfc('0x48')][_0xcdfc('0x32')]);_0x70a97c[_0xcdfc('0x36')]=_[_0xcdfc('0x37')](_0x505f23[_0xcdfc('0x36')]);_0x70a97c['filters']=_[_0xcdfc('0x38')](_0x70a97c[_0xcdfc('0x39')],_0x70a97c['query']);_0x5b70b1[_0xcdfc('0x3a')]=_[_0xcdfc('0x38')](_0x70a97c[_0xcdfc('0x39')],qs[_0xcdfc('0x3b')](_0x505f23[_0xcdfc('0x36')][_0xcdfc('0x3b')]));_0x5b70b1['attributes']=_0x5b70b1['attributes']['length']?_0x5b70b1[_0xcdfc('0x3a')]:_0x70a97c['model'];if(_0x505f23['query']['includeAll']){_0x5b70b1[_0xcdfc('0x4a')]=[{'all':!![]}];}_0x5b70b1=_['merge']({},_0x5b70b1,_0x505f23[_0xcdfc('0x47')]);return db['ChatWebsite'][_0xcdfc('0x4e')](_0x5b70b1)[_0xcdfc('0x12')](handleEntityNotFound(_0x1c3098,null))[_0xcdfc('0x12')](respondWithResult(_0x1c3098,null))[_0xcdfc('0x1c')](handleError(_0x1c3098,null));};exports[_0xcdfc('0x4f')]=function(_0x3df36f,_0x51ae7a){return db[_0xcdfc('0x48')]['create'](_0x3df36f[_0xcdfc('0x50')],{})[_0xcdfc('0x12')](function(_0x5bdb66){var _0x42d18e=_0x3df36f[_0xcdfc('0x51')][_0xcdfc('0x29')]({'plain':!![]});if(!_0x42d18e)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x42d18e[_0xcdfc('0x52')]===_0xcdfc('0x51')){var _0x2ac221=_0x5bdb66['get']({'plain':!![]});var _0x3a0e10=_0xcdfc('0x53');return db['UserProfileSection'][_0xcdfc('0x4e')]({'where':{'name':_0x3a0e10,'userProfileId':_0x42d18e['userProfileId']},'raw':!![]})[_0xcdfc('0x12')](function(_0x3af18b){if(_0x3af18b&&_0x3af18b['autoAssociation']===0x0){return db[_0xcdfc('0x2a')][_0xcdfc('0x4f')]({'name':_0x2ac221[_0xcdfc('0x2c')],'resourceId':_0x2ac221['id'],'type':_0x3af18b[_0xcdfc('0x2c')],'sectionId':_0x3af18b['id']},{})[_0xcdfc('0x12')](function(){return _0x5bdb66;});}else{return _0x5bdb66;}})['catch'](function(_0x554f79){logger[_0xcdfc('0x17')](_0xcdfc('0x54'),_0x554f79);throw _0x554f79;});}return _0x5bdb66;})[_0xcdfc('0x12')](respondWithResult(_0x51ae7a,0xc9))[_0xcdfc('0x1c')](handleError(_0x51ae7a,null));};exports['update']=function(_0x1ff2a9,_0x20e0d7){if(_0x1ff2a9[_0xcdfc('0x50')]['id']){delete _0x1ff2a9['body']['id'];}return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0x1ff2a9['params']['id']},'include':[{'model':db[_0xcdfc('0x2f')],'as':_0xcdfc('0x30')}]})['then'](handleEntityNotFound(_0x20e0d7,null))['then'](saveUpdates(_0x1ff2a9[_0xcdfc('0x50')],null))['then'](respondWithResult(_0x20e0d7,null))[_0xcdfc('0x1c')](handleError(_0x20e0d7,null));};exports['destroy']=function(_0x4b2969,_0x35c7e2){return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0x4b2969[_0xcdfc('0x4d')]['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x35c7e2,null))[_0xcdfc('0x12')](removeEntity(_0x35c7e2,null))['catch'](handleError(_0x35c7e2,null));};exports[_0xcdfc('0x55')]=function(_0x3ba224,_0x5bf1a8){return db[_0xcdfc('0x48')][_0xcdfc('0x55')]()['then'](respondWithResult(_0x5bf1a8,null))[_0xcdfc('0x1c')](handleError(_0x5bf1a8,null));};exports[_0xcdfc('0x56')]=function(_0x276de4,_0x16c78e){if(_0x276de4[_0xcdfc('0x50')]['id']){delete _0x276de4['body']['id'];}return db['ChatWebsite'][_0xcdfc('0x4e')]({'where':{'id':_0x276de4[_0xcdfc('0x4d')]['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x16c78e,null))[_0xcdfc('0x12')](function(_0x25ff18){if(_0x25ff18){_0x276de4[_0xcdfc('0x50')][_0xcdfc('0x57')]=_0x25ff18['id'];return db['Disposition'][_0xcdfc('0x4f')](_0x276de4['body']);}})[_0xcdfc('0x12')](respondWithResult(_0x16c78e,null))[_0xcdfc('0x1c')](handleError(_0x16c78e,null));};exports[_0xcdfc('0x58')]=function(_0x52a68e,_0xbf824){var _0xe469af={'raw':![],'where':{}};var _0x19bfd9={};var _0x26fa56={'count':0x0,'rows':[]};return db[_0xcdfc('0x48')]['findOne']({'where':{'id':_0x52a68e['params']['id']}})['then'](handleEntityNotFound(_0xbf824,null))['then'](function(_0x3d453c){if(_0x3d453c){_0x19bfd9[_0xcdfc('0x39')]=_[_0xcdfc('0x37')](db[_0xcdfc('0x59')][_0xcdfc('0x32')]);_0x19bfd9[_0xcdfc('0x36')]=_[_0xcdfc('0x37')](_0x52a68e[_0xcdfc('0x36')]);_0x19bfd9[_0xcdfc('0x42')]=_[_0xcdfc('0x38')](_0x19bfd9[_0xcdfc('0x39')],_0x19bfd9[_0xcdfc('0x36')]);_0xe469af[_0xcdfc('0x3a')]=_[_0xcdfc('0x38')](_0x19bfd9[_0xcdfc('0x39')],qs[_0xcdfc('0x3b')](_0x52a68e[_0xcdfc('0x36')][_0xcdfc('0x3b')]));_0xe469af['attributes']=_0xe469af[_0xcdfc('0x3a')][_0xcdfc('0x3c')]?_0xe469af[_0xcdfc('0x3a')]:_0x19bfd9['model'];if(!_0x52a68e[_0xcdfc('0x36')][_0xcdfc('0x3d')](_0xcdfc('0x3e'))){_0xe469af[_0xcdfc('0x23')]=qs[_0xcdfc('0x23')](_0x52a68e[_0xcdfc('0x36')][_0xcdfc('0x23')]);_0xe469af[_0xcdfc('0x21')]=qs[_0xcdfc('0x21')](_0x52a68e[_0xcdfc('0x36')][_0xcdfc('0x21')]);}_0xe469af['order']=qs[_0xcdfc('0x40')](_0x52a68e[_0xcdfc('0x36')][_0xcdfc('0x40')]);_0xe469af[_0xcdfc('0x41')]=qs['filters'](_[_0xcdfc('0x43')](_0x52a68e[_0xcdfc('0x36')],_0x19bfd9[_0xcdfc('0x42')]));_0xe469af['where'][_0xcdfc('0x57')]=_0x3d453c['id'];if(_0x52a68e['query'][_0xcdfc('0x44')]){_0xe469af[_0xcdfc('0x41')]=_[_0xcdfc('0x45')](_0xe469af[_0xcdfc('0x41')],{'$or':_[_0xcdfc('0x31')](_0xe469af['attributes'],function(_0xfb250b){var _0x469cb6={};_0x469cb6[_0xfb250b]={'$like':'%'+_0x52a68e[_0xcdfc('0x36')]['filter']+'%'};return _0x469cb6;})});}_0xe469af=_[_0xcdfc('0x45')]({},_0xe469af,_0x52a68e[_0xcdfc('0x47')]);return db[_0xcdfc('0x59')][_0xcdfc('0x24')]({'where':_0xe469af['where']})[_0xcdfc('0x12')](function(_0x2deb5c){_0x26fa56[_0xcdfc('0x24')]=_0x2deb5c;if(_0x52a68e[_0xcdfc('0x36')][_0xcdfc('0x49')]){_0xe469af[_0xcdfc('0x4a')]=[{'all':!![]}];}return db[_0xcdfc('0x59')]['findAll'](_0xe469af);})['then'](function(_0x37fe10){_0x26fa56[_0xcdfc('0x4c')]=_0x37fe10;return _0x26fa56;});}})[_0xcdfc('0x12')](respondWithFilteredResult(_0xbf824,_0xe469af))['catch'](handleError(_0xbf824,null));};exports['removeDispositions']=function(_0x5d5a5a,_0x5e79ce){return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0x5d5a5a[_0xcdfc('0x4d')]['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x5e79ce,null))[_0xcdfc('0x12')](function(_0x2aa393){if(_0x2aa393){return _0x2aa393[_0xcdfc('0x5a')](_0x5d5a5a[_0xcdfc('0x36')][_0xcdfc('0x5b')]);}})[_0xcdfc('0x12')](respondWithStatusCode(_0x5e79ce,null))[_0xcdfc('0x1c')](handleError(_0x5e79ce,null));};exports[_0xcdfc('0x5c')]=function(_0x320cd0,_0x2ef9b9){if(_0x320cd0[_0xcdfc('0x50')]['id']){delete _0x320cd0[_0xcdfc('0x50')]['id'];}return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0x320cd0['params']['id']}})['then'](handleEntityNotFound(_0x2ef9b9,null))[_0xcdfc('0x12')](function(_0x35acfd){if(_0x35acfd){_0x320cd0['body'][_0xcdfc('0x57')]=_0x35acfd['id'];return db[_0xcdfc('0x5d')]['create'](_0x320cd0[_0xcdfc('0x50')]);}})[_0xcdfc('0x12')](respondWithResult(_0x2ef9b9,null))[_0xcdfc('0x1c')](handleError(_0x2ef9b9,null));};exports[_0xcdfc('0x5e')]=function(_0x54603e,_0x296c41){var _0x2591db={'raw':![],'where':{}};var _0x39f2b7={};var _0xc55f5a={'count':0x0,'rows':[]};return db[_0xcdfc('0x48')][_0xcdfc('0x5f')]({'where':{'id':_0x54603e[_0xcdfc('0x4d')]['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x296c41,null))['then'](function(_0x3c3a0d){if(_0x3c3a0d){_0x39f2b7[_0xcdfc('0x39')]=_[_0xcdfc('0x37')](db[_0xcdfc('0x5d')][_0xcdfc('0x32')]);_0x39f2b7['query']=_['keys'](_0x54603e[_0xcdfc('0x36')]);_0x39f2b7[_0xcdfc('0x42')]=_[_0xcdfc('0x38')](_0x39f2b7[_0xcdfc('0x39')],_0x39f2b7[_0xcdfc('0x36')]);_0x2591db[_0xcdfc('0x3a')]=_[_0xcdfc('0x38')](_0x39f2b7[_0xcdfc('0x39')],qs[_0xcdfc('0x3b')](_0x54603e[_0xcdfc('0x36')][_0xcdfc('0x3b')]));_0x2591db[_0xcdfc('0x3a')]=_0x2591db['attributes']['length']?_0x2591db[_0xcdfc('0x3a')]:_0x39f2b7[_0xcdfc('0x39')];if(!_0x54603e['query']['hasOwnProperty']('nolimit')){_0x2591db[_0xcdfc('0x23')]=qs[_0xcdfc('0x23')](_0x54603e[_0xcdfc('0x36')]['limit']);_0x2591db[_0xcdfc('0x21')]=qs[_0xcdfc('0x21')](_0x54603e[_0xcdfc('0x36')][_0xcdfc('0x21')]);}_0x2591db[_0xcdfc('0x3f')]=qs[_0xcdfc('0x40')](_0x54603e['query'][_0xcdfc('0x40')]);_0x2591db['where']=qs[_0xcdfc('0x42')](_[_0xcdfc('0x43')](_0x54603e[_0xcdfc('0x36')],_0x39f2b7[_0xcdfc('0x42')]));_0x2591db[_0xcdfc('0x41')][_0xcdfc('0x57')]=_0x3c3a0d['id'];if(_0x54603e[_0xcdfc('0x36')][_0xcdfc('0x44')]){_0x2591db[_0xcdfc('0x41')]=_[_0xcdfc('0x45')](_0x2591db[_0xcdfc('0x41')],{'$or':_[_0xcdfc('0x31')](_0x2591db[_0xcdfc('0x3a')],function(_0x246f15){var _0x564ca7={};_0x564ca7[_0x246f15]={'$like':'%'+_0x54603e[_0xcdfc('0x36')][_0xcdfc('0x44')]+'%'};return _0x564ca7;})});}_0x2591db=_[_0xcdfc('0x45')]({},_0x2591db,_0x54603e[_0xcdfc('0x47')]);return db[_0xcdfc('0x5d')][_0xcdfc('0x24')]({'where':_0x2591db[_0xcdfc('0x41')]})[_0xcdfc('0x12')](function(_0x36cdb6){_0xc55f5a[_0xcdfc('0x24')]=_0x36cdb6;if(_0x54603e[_0xcdfc('0x36')][_0xcdfc('0x49')]){_0x2591db[_0xcdfc('0x4a')]=[{'all':!![]}];}return db[_0xcdfc('0x5d')][_0xcdfc('0x4b')](_0x2591db);})[_0xcdfc('0x12')](function(_0x1ce233){_0xc55f5a['rows']=_0x1ce233;return _0xc55f5a;});}})[_0xcdfc('0x12')](respondWithFilteredResult(_0x296c41,_0x2591db))[_0xcdfc('0x1c')](handleError(_0x296c41,null));};exports[_0xcdfc('0x60')]=function(_0x58d2e8,_0x21fc8c){return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0x58d2e8[_0xcdfc('0x4d')]['id']}})['then'](handleEntityNotFound(_0x21fc8c,null))['then'](function(_0x289342){if(_0x289342){return _0x289342[_0xcdfc('0x60')](_0x58d2e8[_0xcdfc('0x36')]['ids']);}})[_0xcdfc('0x12')](respondWithStatusCode(_0x21fc8c,null))['catch'](handleError(_0x21fc8c,null));};exports[_0xcdfc('0x61')]=function(_0x4fd3cd,_0x14641d){_0x4fd3cd[_0xcdfc('0x50')][_0xcdfc('0x62')]=_0x4fd3cd['file'][_0xcdfc('0x63')];return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0x4fd3cd[_0xcdfc('0x4d')]['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x14641d,null))[_0xcdfc('0x12')](saveUpdates(_0x4fd3cd[_0xcdfc('0x50')],null))[_0xcdfc('0x12')](respondWithResult(_0x14641d,null))[_0xcdfc('0x1c')](handleError(_0x14641d,null));};exports[_0xcdfc('0x64')]=function(_0x35dcc6,_0x1f092f){_0x35dcc6['body'][_0xcdfc('0x65')]=_0x35dcc6[_0xcdfc('0x66')][_0xcdfc('0x63')];return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0x35dcc6['params']['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x1f092f,null))[_0xcdfc('0x12')](saveUpdates(_0x35dcc6[_0xcdfc('0x50')],null))[_0xcdfc('0x12')](respondWithResult(_0x1f092f,null))[_0xcdfc('0x1c')](handleError(_0x1f092f,null));};exports['addCustomerAvatar']=function(_0xf06fdb,_0x284832){_0xf06fdb[_0xcdfc('0x50')]['customerAvatar']=_0xf06fdb[_0xcdfc('0x66')][_0xcdfc('0x63')];return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0xf06fdb[_0xcdfc('0x4d')]['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x284832,null))['then'](saveUpdates(_0xf06fdb[_0xcdfc('0x50')],null))[_0xcdfc('0x12')](respondWithResult(_0x284832,null))[_0xcdfc('0x1c')](handleError(_0x284832,null));};exports[_0xcdfc('0x67')]=function(_0xd1a7f3,_0x4ba51e){_0xd1a7f3[_0xcdfc('0x50')][_0xcdfc('0x68')]=_0xd1a7f3['file'][_0xcdfc('0x63')];return db[_0xcdfc('0x48')]['find']({'where':{'id':_0xd1a7f3[_0xcdfc('0x4d')]['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x4ba51e,null))[_0xcdfc('0x12')](saveUpdates(_0xd1a7f3[_0xcdfc('0x50')],null))['then'](respondWithResult(_0x4ba51e,null))['catch'](handleError(_0x4ba51e,null));};exports[_0xcdfc('0x69')]=function(_0x3119c3,_0x5a6af2){var _0xc56a9=path[_0xcdfc('0x6a')](config[_0xcdfc('0x6b')],_0xcdfc('0x6c'));var _0x912cb5={'where':{'id':_0x3119c3['params']['id']},'attributes':['id',_0xcdfc('0x62')],'raw':!![]};var _0x11289a=![];return require(_0xcdfc('0x6d'))[_0xcdfc('0x6e')]()[_0xcdfc('0x12')](function(_0x1b65ad){if(_0x1b65ad){_0x11289a=_0x1b65ad[_0xcdfc('0x6f')];}})[_0xcdfc('0x12')](function(){return db[_0xcdfc('0x48')][_0xcdfc('0x4e')](_0x912cb5);})[_0xcdfc('0x12')](handleEntityNotFound(_0x5a6af2,null))[_0xcdfc('0x12')](function(_0x5001e5){if(_0x5001e5){if(!_[_0xcdfc('0x70')](_0x5001e5[_0xcdfc('0x62')])){if(fs[_0xcdfc('0x71')](path[_0xcdfc('0x6a')](config[_0xcdfc('0x6b')],_0xcdfc('0x72'),_0x5001e5[_0xcdfc('0x62')]))&&_0x11289a){_0xc56a9=path[_0xcdfc('0x6a')](config[_0xcdfc('0x6b')],_0xcdfc('0x72'),_0x5001e5[_0xcdfc('0x62')]);}}return _0x5a6af2[_0xcdfc('0x73')](_0xc56a9);}})['catch'](handleError(_0x5a6af2,null));};exports[_0xcdfc('0x74')]=function(_0x498149,_0x3d3c9e){var _0x209d6a=path['join'](config[_0xcdfc('0x6b')],_0xcdfc('0x75'));var _0x467a04={'where':{'id':_0x498149[_0xcdfc('0x4d')]['id']},'attributes':['id',_0xcdfc('0x65')],'raw':!![]};return db[_0xcdfc('0x48')][_0xcdfc('0x4e')](_0x467a04)[_0xcdfc('0x12')](handleEntityNotFound(_0x3d3c9e,null))[_0xcdfc('0x12')](function(_0x470cf2){if(_0x470cf2){if(!_[_0xcdfc('0x70')](_0x470cf2['agentAvatar'])){if(fs[_0xcdfc('0x71')](path['join'](config[_0xcdfc('0x6b')],_0xcdfc('0x76'),_0x470cf2[_0xcdfc('0x65')]))){_0x209d6a=path['join'](config[_0xcdfc('0x6b')],'server/files/images/avatars/',_0x470cf2[_0xcdfc('0x65')]);}}return _0x3d3c9e[_0xcdfc('0x73')](_0x209d6a);}})[_0xcdfc('0x1c')](handleError(_0x3d3c9e,null));};exports[_0xcdfc('0x77')]=function(_0x16d8dc,_0x9a2bc1){var _0x140cfb=path[_0xcdfc('0x6a')](config['root'],_0xcdfc('0x78'));var _0x33ba2b={'where':{'id':_0x16d8dc[_0xcdfc('0x4d')]['id']},'attributes':['id',_0xcdfc('0x79'),_0xcdfc('0x7a')],'raw':!![]};return db[_0xcdfc('0x48')][_0xcdfc('0x4e')](_0x33ba2b)[_0xcdfc('0x12')](handleEntityNotFound(_0x9a2bc1,null))[_0xcdfc('0x12')](function(_0x57eae5){if(_0x57eae5){if(!_[_0xcdfc('0x70')](_0x57eae5[_0xcdfc('0x79')])){if(fs[_0xcdfc('0x71')](path['join'](config[_0xcdfc('0x6b')],_0xcdfc('0x76'),_0x57eae5[_0xcdfc('0x79')]))&&_0x57eae5['showCustomerAvatar']){_0x140cfb=path['join'](config['root'],'server/files/images/avatars/',_0x57eae5[_0xcdfc('0x79')]);}}return _0x9a2bc1[_0xcdfc('0x73')](_0x140cfb);}})[_0xcdfc('0x1c')](handleError(_0x9a2bc1,null));};exports[_0xcdfc('0x7b')]=function(_0x3bf250,_0x24a513){var _0xafc8ba=path[_0xcdfc('0x6a')](config['root'],_0xcdfc('0x7c'));var _0x2fc6ea={'where':{'id':_0x3bf250[_0xcdfc('0x4d')]['id']},'attributes':['id',_0xcdfc('0x68')],'raw':!![]};return db[_0xcdfc('0x48')][_0xcdfc('0x4e')](_0x2fc6ea)[_0xcdfc('0x12')](handleEntityNotFound(_0x24a513,null))['then'](function(_0x1464b5){if(_0x1464b5){if(!_['isNil'](_0x1464b5['systemAvatar'])){if(fs['existsSync'](path[_0xcdfc('0x6a')](config[_0xcdfc('0x6b')],_0xcdfc('0x76'),_0x1464b5[_0xcdfc('0x68')]))){_0xafc8ba=path[_0xcdfc('0x6a')](config[_0xcdfc('0x6b')],_0xcdfc('0x76'),_0x1464b5[_0xcdfc('0x68')]);}}return _0x24a513[_0xcdfc('0x73')](_0xafc8ba);}})[_0xcdfc('0x1c')](handleError(_0x24a513,null));};exports['notify']=function(_0x38da3c,_0x2a6316){var _0x1cf486=require(_0xcdfc('0x7d'));var _0x2ca53a=new _0x1cf486();var _0x5a5a7c=_0x2ca53a[_0xcdfc('0x7e')](_0x38da3c['headers'][_0xcdfc('0x7f')])[_0xcdfc('0x80')]();var _0x448d04={'body':_0x38da3c['body'],'channel':'chat'};var _0x195c7c=[];var _0x4ea3b7=[];var _0xaba22={};var _0x47527a=![];return db[_0xcdfc('0x81')][_0xcdfc('0x55')]()[_0xcdfc('0x12')](function(_0x296a1b){if(!_0x296a1b){throw new db['Sequelize'][(_0xcdfc('0x82'))](_0xcdfc('0x83'));}_0x195c7c=_[_0xcdfc('0x84')](_[_0xcdfc('0x37')](_0x296a1b),['createdAt','updatedAt']);_0x4ea3b7=_[_0xcdfc('0x84')](_[_0xcdfc('0x37')](_0x296a1b),[_0xcdfc('0x85'),_0xcdfc('0x86'),'CompanyId','ListId']);if(_0x38da3c['body']['id']){delete _0x38da3c[_0xcdfc('0x50')]['id'];}if(_[_0xcdfc('0x70')](_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0x87')])){throw new db[(_0xcdfc('0x88'))][(_0xcdfc('0x82'))](_0xcdfc('0x89'));}if(_['isNil'](_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0x50')])||_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0x50')]===''){throw new db['Sequelize']['ValidationError'](_0xcdfc('0x8a'));}if(_[_0xcdfc('0x70')](_0x38da3c['body'][_0xcdfc('0x8b')])){throw new db[(_0xcdfc('0x88'))][(_0xcdfc('0x82'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4ea3b7);}if(!_[_0xcdfc('0x8c')](_0x4ea3b7,_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0x8b')])){throw new db[(_0xcdfc('0x88'))][(_0xcdfc('0x82'))](_0xcdfc('0x8d')+_0x4ea3b7);}_0xaba22[_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0x8b')]]=_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0x87')];})['then'](function(){return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0x38da3c[_0xcdfc('0x4d')]['id']},'include':[{'model':db[_0xcdfc('0x8e')],'as':_0xcdfc('0x8f'),'include':[{'model':db[_0xcdfc('0x81')],'as':_0xcdfc('0x90'),'where':_0xaba22,'limit':0x1,'order':[[_0xcdfc('0x86'),_0xcdfc('0x91')]]}]},{'model':db[_0xcdfc('0x92')],'as':_0xcdfc('0x93')}]});})[_0xcdfc('0x12')](handleEntityNotFound(_0x2a6316,null))[_0xcdfc('0x12')](function(_0xb650d3){if(_0xb650d3&&_0xb650d3[_0xcdfc('0x8f')]){_0x448d04[_0xcdfc('0x94')]=_0xb650d3;_0x448d04[_0xcdfc('0x95')]=_0xb650d3[_0xcdfc('0x93')];_0x448d04[_0xcdfc('0x96')]=_0xb650d3[_0xcdfc('0x8f')];_0x448d04['applications']=_[_0xcdfc('0x97')](_0x448d04[_0xcdfc('0x95')],[_0xcdfc('0x98')],[_0xcdfc('0x99')]);if(_0x448d04[_0xcdfc('0x94')][_0xcdfc('0x93')]){delete _0x448d04[_0xcdfc('0x94')][_0xcdfc('0x93')];}if(_0x448d04[_0xcdfc('0x94')][_0xcdfc('0x8f')]&&_0x448d04['account'][_0xcdfc('0x8f')]['Contacts'][_0xcdfc('0x3c')]){return _0x448d04['account'][_0xcdfc('0x8f')][_0xcdfc('0x90')][0x0];}var _0x121e29=_[_0xcdfc('0x9')](_0x38da3c['body'],{'firstName':_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0x87')],'ListId':_0xb650d3[_0xcdfc('0x9a')]});_0x121e29[_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0x8b')]]=_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0x87')];return db[_0xcdfc('0x81')][_0xcdfc('0x4f')](_0x121e29,{'fields':_0x195c7c,'raw':!![]});}})[_0xcdfc('0x12')](handleEntityNotFound(_0x2a6316,null))[_0xcdfc('0x12')](function(_0x5d642f){_0x448d04[_0xcdfc('0x9b')]=_0x5d642f;var _0x214fbe=_0x38da3c['body']['customerIp'];if(_0x38da3c[_0xcdfc('0x9c')][_0xcdfc('0x9d')]){_0x214fbe=_0x38da3c[_0xcdfc('0x9c')][_0xcdfc('0x9d')];}else if(_0x38da3c[_0xcdfc('0x9c')][_0xcdfc('0x9e')]){_0x214fbe=_[_0xcdfc('0x9f')](_0x38da3c[_0xcdfc('0x9c')][_0xcdfc('0x9e')][_0xcdfc('0xa0')](','));}if(_0x5d642f){var _0x59afb5={'ContactId':_0x5d642f['id'],'ChatWebsiteId':_0x38da3c['params']['id'],'from':(_0x5d642f[_0xcdfc('0xa1')]||'')+'\x20'+(_0x5d642f['lastName']||''),'customerIp':_0x214fbe,'customerPort':_0x38da3c[_0xcdfc('0x9c')][_0xcdfc('0xa2')]?_0x38da3c[_0xcdfc('0x9c')][_0xcdfc('0xa2')]:null,'referer':_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0xa3')],'browserName':_0x5a5a7c[_0xcdfc('0xa4')][_0xcdfc('0x2c')]&&_0x5a5a7c[_0xcdfc('0xa4')][_0xcdfc('0xa5')]?util[_0xcdfc('0xa6')](_0xcdfc('0xa7'),_0x5a5a7c[_0xcdfc('0xa4')]['name'],_0x5a5a7c[_0xcdfc('0xa4')][_0xcdfc('0xa5')]):_0xcdfc('0xa8'),'browserVersion':_0x5a5a7c[_0xcdfc('0xa4')]['version']||'unknown','osName':util[_0xcdfc('0xa6')](_0xcdfc('0xa7'),_0x5a5a7c['os'][_0xcdfc('0x2c')],_0x5a5a7c['os'][_0xcdfc('0xa5')]),'osVersion':_0x5a5a7c['os']['version'],'deviceModel':_0x5a5a7c[_0xcdfc('0xa9')]['model']&&_0x5a5a7c[_0xcdfc('0xa9')]['vendor']?util[_0xcdfc('0xa6')](_0xcdfc('0xaa'),_0x5a5a7c['device'][_0xcdfc('0x39')],_0x5a5a7c[_0xcdfc('0xa9')]['vendor'],_0x5a5a7c[_0xcdfc('0xa9')][_0xcdfc('0x34')]):null,'deviceVendor':_0x5a5a7c[_0xcdfc('0xa9')]['vendor'],'deviceType':_0x5a5a7c[_0xcdfc('0xa9')]['type'],'formData':JSON[_0xcdfc('0x16')](_0x38da3c[_0xcdfc('0x50')])};var _0x41b7a9={'ChatWebsiteId':_0x38da3c[_0xcdfc('0x4d')]['id'],'closed':![]};if(_0x38da3c[_0xcdfc('0x50')]['threadId']){_0x41b7a9[_0xcdfc('0xab')]=_0x38da3c['body']['threadId'];return db['ChatInteraction']['find']({'where':_0x41b7a9})[_0xcdfc('0x12')](function(_0x2026e4){if(_0x2026e4){return[_0x2026e4,![]];}_0x59afb5[_0xcdfc('0xab')]=_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0xab')];_0x59afb5[_0xcdfc('0xac')]=_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0xac')];return db[_0xcdfc('0xad')][_0xcdfc('0x4f')](_0x59afb5)[_0xcdfc('0x12')](function(_0x1e9cf5){return[_0x1e9cf5,!![]];});});}_0x41b7a9[_0xcdfc('0xae')]=_0x5d642f['id'];if(_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0xaf')]&&_0x38da3c[_0xcdfc('0x50')]['interaction']['id']){_0x41b7a9['id']=_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0xaf')]['id'];return db[_0xcdfc('0xad')][_0xcdfc('0x4e')]({'where':_0x41b7a9})[_0xcdfc('0x12')](function(_0x227b90){if(_0x227b90){return[_0x227b90,![]];}return db[_0xcdfc('0xad')]['create'](_0x59afb5)[_0xcdfc('0x12')](function(_0x264c62){return[_0x264c62,!![]];});});}return db[_0xcdfc('0xad')]['create'](_0x59afb5)[_0xcdfc('0x12')](function(_0x9fa5d7){return[_0x9fa5d7,!![]];});}})['spread'](function(_0xcd5af4,_0x56e6a6){if(_0xcd5af4){_0x47527a=_0x56e6a6;if(!_0x56e6a6){var _0x2d16a3={'from':(_0x448d04[_0xcdfc('0x9b')][_0xcdfc('0xa1')]||'')+'\x20'+(_0x448d04['contact']['lastName']||'')};if(_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0xab')]&&_0x38da3c['body'][_0xcdfc('0xb0')]&&_0x38da3c['body'][_0xcdfc('0xab')]!=_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0xb0')]){_0x2d16a3[_0xcdfc('0xab')]=_0x38da3c['body']['messageId'];}return _0xcd5af4[_0xcdfc('0x27')](_0x2d16a3);}else{return _0xcd5af4;}}})[_0xcdfc('0x12')](function(_0x5a1ada){_0x448d04[_0xcdfc('0xaf')]=_0x5a1ada[_0xcdfc('0x29')]({'plain':!![]});_0x448d04[_0xcdfc('0xaf')]['created']=_0x47527a;if(_0x448d04[_0xcdfc('0xaf')]['created']){if(_0x448d04[_0xcdfc('0x94')]['autoclose']){_0x448d04[_0xcdfc('0x95')][_0xcdfc('0xb1')]({'id':0x0,'priority':_0x448d04[_0xcdfc('0x95')][_0xcdfc('0x3c')]+0x1,'app':_0xcdfc('0xb2'),'appdata':'unmanaged','interval':'*,*,*,*'});}}return db[_0xcdfc('0xb3')]['create']({'body':_0x38da3c['body'][_0xcdfc('0x50')],'ChatWebsiteId':_0x38da3c[_0xcdfc('0x4d')]['id'],'ChatInteractionId':_0x5a1ada['id'],'direction':'in','ContactId':_0x448d04[_0xcdfc('0x9b')]['id'],'AttachmentId':_0x38da3c[_0xcdfc('0x50')][_0xcdfc('0xb4')]});})[_0xcdfc('0x12')](function(_0x4502ab){_0x448d04[_0xcdfc('0x19')]=_0x4502ab;if(_0x448d04[_0xcdfc('0xaf')][_0xcdfc('0xb5')]){return db[_0xcdfc('0xb6')][_0xcdfc('0x4e')]({'attributes':['id',_0xcdfc('0x2c')],'where':{'id':_0x448d04['interaction'][_0xcdfc('0xb5')]}})[_0xcdfc('0x12')](function(_0x50bcf9){if(_0x50bcf9){_0x448d04[_0xcdfc('0x95')][_0xcdfc('0xb7')]({'id':0x0,'priority':0x0,'app':_0xcdfc('0xb8'),'appdata':_0x50bcf9[_0xcdfc('0x2c')]+','+(_0x448d04[_0xcdfc('0x94')][_0xcdfc('0xb9')]||0xa),'interval':_0xcdfc('0xba')});_0x448d04[_0xcdfc('0xbb')]=!![];}return respondWithRpcPromise(_0xcdfc('0xbc'),'startRouting',_0x448d04);});}return respondWithRpcPromise(_0xcdfc('0xbc'),_0xcdfc('0xbd'),_0x448d04);})[_0xcdfc('0x12')](function(_0x3605cf){respondWithRpcPromise(_0xcdfc('0xbe'),_0xcdfc('0xbe'),{'event':_0xcdfc('0xbf'),'message':_0x3605cf},client9002);return _0x3605cf;})[_0xcdfc('0x12')](respondWithResult(_0x2a6316,null))[_0xcdfc('0x1c')](handleError(_0x2a6316,null));};exports[_0xcdfc('0xc0')]=function(_0x21b044,_0x3efe8e){var _0x1453b3,_0x4e2c33,_0x461bb1;var _0x214f27=[];var _0x35ec82={};var _0xafb73c=_0x21b044[_0xcdfc('0xc1')]||[];var _0x161f6e=[];var _0x3fd92a;return db[_0xcdfc('0x81')][_0xcdfc('0x55')]()[_0xcdfc('0x12')](function(_0x1d8196){if(!_0x1d8196){throw new db[(_0xcdfc('0x88'))][(_0xcdfc('0x82'))](_0xcdfc('0x83'));}_0x214f27=_[_0xcdfc('0x84')](_[_0xcdfc('0x37')](_0x1d8196),[_0xcdfc('0x85'),_0xcdfc('0x86'),_0xcdfc('0xc2'),_0xcdfc('0x9a')]);if(_0x21b044[_0xcdfc('0x50')]['id']){delete _0x21b044[_0xcdfc('0x50')]['id'];}if(_[_0xcdfc('0x70')](_0x21b044['body'][_0xcdfc('0x87')])){throw _0x3efe8e['status'](0x1f4)[_0xcdfc('0x2d')](new db[(_0xcdfc('0x88'))]['ValidationError']('from\x20is\x20mandatory'));}if(_[_0xcdfc('0x70')](_0x21b044[_0xcdfc('0x50')][_0xcdfc('0x50')])||_0x21b044[_0xcdfc('0x50')][_0xcdfc('0x50')]===''){throw _0x3efe8e[_0xcdfc('0x1e')](0x1f4)['send'](new db['Sequelize'][(_0xcdfc('0x82'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_['isNil'](_0x21b044[_0xcdfc('0x50')][_0xcdfc('0xc3')])){throw _0x3efe8e[_0xcdfc('0x1e')](0x1f4)[_0xcdfc('0x2d')](new db[(_0xcdfc('0x88'))][(_0xcdfc('0x82'))](_0xcdfc('0xc4')+_0x214f27));}if(!_[_0xcdfc('0x8c')](_0x214f27,_0x21b044[_0xcdfc('0x50')][_0xcdfc('0xc3')])){throw _0x3efe8e[_0xcdfc('0x1e')](0x1f4)[_0xcdfc('0x2d')](new db['Sequelize'][(_0xcdfc('0x82'))](_0xcdfc('0xc5')+_0x214f27));}_0x35ec82[_0x21b044[_0xcdfc('0x50')][_0xcdfc('0xc3')]]=_0x21b044[_0xcdfc('0x50')]['from'];})[_0xcdfc('0x12')](function(){return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0x21b044[_0xcdfc('0x4d')]['id']},'include':[{'model':db['CmList'],'as':'List'},{'model':db[_0xcdfc('0xc6')],'as':_0xcdfc('0xc6')}]});})['then'](handleEntityNotFound(_0x3efe8e,null))[_0xcdfc('0x12')](function(_0x4b2f41){if(_0x4b2f41&&_0x4b2f41[_0xcdfc('0x8f')]){_0x4e2c33=_0x4b2f41;var _0x4d9e7d=_[_0xcdfc('0x9')](_0x21b044[_0xcdfc('0x50')],{'firstName':_0x21b044['body'][_0xcdfc('0x87')],'phone':_0x21b044[_0xcdfc('0x50')]['from'],'ListId':_0x4b2f41[_0xcdfc('0x9a')]});_0x4d9e7d[_0x21b044[_0xcdfc('0x50')][_0xcdfc('0xc3')]]=_0x21b044['body'][_0xcdfc('0x87')];return db['CmContact']['findOrCreate']({'where':_0x35ec82,'defaults':_0x4d9e7d});}})['spread'](function(_0x5dccf6){if(_0x5dccf6){_0x461bb1=_0x5dccf6;var _0xeeb30b=fs[_0xcdfc('0xc7')](path[_0xcdfc('0x6a')](config[_0xcdfc('0x6b')],_0xcdfc('0xc8')),_0xcdfc('0xc9'));var _0x228331=ejs[_0xcdfc('0xca')](_0xeeb30b,{'body':_[_0xcdfc('0xcb')](_0x21b044['body']['body']),'bodyTitle':_0x4e2c33[_0xcdfc('0xcc')]});return db[_0xcdfc('0xcd')]['create']({'body':_0x228331,'plainBody':htmlToText[_0xcdfc('0xce')](_0x228331),'ContactId':_0x5dccf6['id'],'ChatWebsiteId':_0x4e2c33['id']});}})[_0xcdfc('0x12')](function(_0x561238){_0x3fd92a=_0x561238;if(_0xafb73c[_0xcdfc('0x3c')]){var _0x29cf0c=_0xafb73c[_0xcdfc('0x31')](function(_0x420242){return{'name':_0x420242[_0xcdfc('0xcf')],'basename':_0x420242[_0xcdfc('0x63')],'type':_0x420242[_0xcdfc('0xd0')],'ChatOfflineMessageId':_0x561238['id']};});_0x161f6e=_0x29cf0c[_0xcdfc('0x31')](_0x1c5f6c=>{var _0x2a3383={'filename':_0x1c5f6c[_0xcdfc('0x2c')],'path':path[_0xcdfc('0x6a')](config[_0xcdfc('0x6b')],'server','files',_0xcdfc('0xd1'),_0xcdfc('0xd2'),_0x1c5f6c['basename'])};return _0x2a3383;});if(!_0x4e2c33[_0xcdfc('0xd3')]){return db[_0xcdfc('0xd4')][_0xcdfc('0xd5')](function(_0x207bcd){return db[_0xcdfc('0xd6')][_0xcdfc('0xd7')](_0x29cf0c,{'transaction':_0x207bcd});});}}})[_0xcdfc('0x12')](function(){if(_0x3fd92a){_0x1453b3=_0x3fd92a;return db['MailAccount'][_0xcdfc('0x5f')]({'where':{'service':!![]},'include':[{'model':db[_0xcdfc('0xd8')],'as':_0xcdfc('0xd9'),'raw':!![],'include':[{'model':db['CloudProvider'],'as':_0xcdfc('0xda'),'raw':!![]}]}]});}})['then'](function(_0x407703){if(_0x407703&&_0x407703[_0xcdfc('0xd9')]&&_0x4e2c33['forwardOffline']&&_0x4e2c33[_0xcdfc('0xdb')]){var _0x398370=_0x407703[_0xcdfc('0xdc')]();return respondWithRpcPromise(_0xcdfc('0xdd'),_0xcdfc('0xde'),{'account':_0x398370,'message':{'from':util[_0xcdfc('0xa6')](_0xcdfc('0xdf'),_0x407703['name'],_0x407703[_0xcdfc('0xe0')]||_0x407703[_0xcdfc('0xd9')][_0xcdfc('0x51')]),'to':_0x4e2c33[_0xcdfc('0xdb')],'subject':_0x4e2c33['offlineMessageSubject'],'html':_0x1453b3[_0xcdfc('0x50')],'attachments':_0x161f6e}},client9003)[_0xcdfc('0x12')](function(){return _0x1453b3;})['catch'](function(_0x50494e){logger['error'](_0x50494e);});}})[_0xcdfc('0x12')](function(){if(_0x4e2c33&&_0x4e2c33['openNewInteraction']&&_0x4e2c33[_0xcdfc('0xe1')]){var _0x1887a4=[];if(_0xafb73c[_0xcdfc('0x3c')]){_0x1887a4=_0xafb73c[_0xcdfc('0x31')](function(_0x1fa778){return{'name':_0x1fa778['originalname'],'basename':_0x1fa778[_0xcdfc('0x63')],'type':_0x1fa778[_0xcdfc('0xd0')],'ChatOfflineMessageId':_0x3fd92a['id']};});}var _0x3a783d;if(!_[_0xcdfc('0x70')](_0x4e2c33[_0xcdfc('0xe2')])){var _0x1bf615=_['map'](_0x21b044[_0xcdfc('0x50')],function(_0x499aa4){return _0x499aa4;});var _0x3a2aa5=_[_0xcdfc('0xe3')](_0x1bf615)[0x0];var _0xc61178=_[_0xcdfc('0xe4')](_0x3a2aa5,function(_0x3df18d){return _0x3df18d;});_0x3a783d=_0xc61178[0x1][_0x4e2c33[_0xcdfc('0xe2')]];}var _0x4a23f2={'from':_0x461bb1[_0xcdfc('0xe0')],'firstName':_0x461bb1[_0xcdfc('0xa1')],'lastName':_0x461bb1[_0xcdfc('0xe5')],'mapKey':_0xcdfc('0xe0'),'message':{'from':_0x461bb1[_0xcdfc('0xe0')],'to':_0x4e2c33[_0xcdfc('0xc6')][_0xcdfc('0xe0')],'cc':'','subject':_['isNil'](_0x3a783d)?_0x4e2c33['offlineMessageSubject']:_0x3a783d,'messageId':'','sentAt':new Date(),'attach':_0x1887a4[_0xcdfc('0x3c')],'attachments':_0x1887a4,'originChannel':'Chat','ChatWebsiteId':_0x4e2c33['id'],'ChatOfflineMessageId':_0x1453b3['id'],'originTo':_0x4e2c33['MailAccount'][_0xcdfc('0xe0')]},'body':_0x1453b3[_0xcdfc('0x50')]};var _0x18ef51={'account':{'id':_0x4e2c33['MailAccountId']},'body':_0x4a23f2,'log':_0xcdfc('0xe6')};return respondWithRpcPromise(_0xcdfc('0xe6'),_0xcdfc('0xe7'),_0x18ef51,client9001)[_0xcdfc('0x12')](function(){return _0x1453b3;})['catch'](function(_0xa33c21){logger['error'](_0xa33c21);});}return;})[_0xcdfc('0x12')](function(){if(_0x1453b3){return _0x1453b3;}})[_0xcdfc('0x12')](respondWithResult(_0x3efe8e,null))['catch'](function(_0x322f31){logger[_0xcdfc('0x17')]('catch',_0x322f31);for(var _0x55fce8 of _0xafb73c){var _0x4d3c5c=path[_0xcdfc('0x6a')](config[_0xcdfc('0x6b')],_0xcdfc('0xe8'),_0xcdfc('0xc1'),_0xcdfc('0xd1'),_0xcdfc('0xd2'),_0x55fce8[_0xcdfc('0x63')]);fs_extra['remove'](_0x4d3c5c)[_0xcdfc('0x1c')](function(_0x212305){logger['error'](_0xcdfc('0xe9'),_0x4d3c5c,_0x212305);});}});};exports[_0xcdfc('0xea')]=function(_0x31ab1e,_0x4fbb88){return db[_0xcdfc('0xad')][_0xcdfc('0x4e')]({'where':{'id':_0x31ab1e[_0xcdfc('0x4d')]['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x4fbb88,null))['then'](function(_0x1dc6c6){if(_0x1dc6c6){return _0x1dc6c6[_0xcdfc('0xea')](_0x31ab1e[_0xcdfc('0x50')]['ids'],_[_0xcdfc('0xeb')](_0x31ab1e[_0xcdfc('0x50')],[_0xcdfc('0x5b'),'id'])||{});}})[_0xcdfc('0x12')](respondWithResult(_0x4fbb88,null))[_0xcdfc('0x1c')](handleError(_0x4fbb88,null));};exports[_0xcdfc('0xec')]=function(_0x582bde,_0x32c2b4){var _0x44ff41={'raw':![],'where':{}};var _0x47d410={};var _0x3fc4e9={'count':0x0,'rows':[]};return db[_0xcdfc('0x48')][_0xcdfc('0x5f')]({'where':{'id':_0x582bde['params']['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x32c2b4,null))['then'](function(_0x3b8f12){if(_0x3b8f12){_0x47d410[_0xcdfc('0x39')]=_[_0xcdfc('0x37')](db[_0xcdfc('0xad')][_0xcdfc('0x32')]);_0x47d410[_0xcdfc('0x36')]=_['keys'](_0x582bde[_0xcdfc('0x36')]);_0x47d410['filters']=_[_0xcdfc('0x38')](_0x47d410[_0xcdfc('0x39')],_0x47d410[_0xcdfc('0x36')]);_0x44ff41[_0xcdfc('0x3a')]=_[_0xcdfc('0x38')](_0x47d410['model'],qs['fields'](_0x582bde['query'][_0xcdfc('0x3b')]));_0x44ff41[_0xcdfc('0x3a')]=_0x44ff41['attributes']['length']?_0x44ff41[_0xcdfc('0x3a')]:_0x47d410[_0xcdfc('0x39')];if(!_0x582bde['query'][_0xcdfc('0x3d')](_0xcdfc('0x3e'))){_0x44ff41[_0xcdfc('0x23')]=qs[_0xcdfc('0x23')](_0x582bde[_0xcdfc('0x36')]['limit']);_0x44ff41[_0xcdfc('0x21')]=qs['offset'](_0x582bde[_0xcdfc('0x36')]['offset']);}_0x44ff41[_0xcdfc('0x3f')]=qs[_0xcdfc('0x40')](_0x582bde[_0xcdfc('0x36')]['sort']);_0x44ff41[_0xcdfc('0x41')]=qs[_0xcdfc('0x42')](_['pick'](_0x582bde[_0xcdfc('0x36')],_0x47d410['filters']));_0x44ff41[_0xcdfc('0x41')][_0xcdfc('0x57')]=_0x3b8f12['id'];if(_0x582bde[_0xcdfc('0x36')][_0xcdfc('0x44')]){_0x44ff41['where']=_[_0xcdfc('0x45')](_0x44ff41[_0xcdfc('0x41')],{'$or':_[_0xcdfc('0x31')](_0x44ff41[_0xcdfc('0x3a')],function(_0x54b85d){var _0x495a7a={};_0x495a7a[_0x54b85d]={'$like':'%'+_0x582bde[_0xcdfc('0x36')][_0xcdfc('0x44')]+'%'};return _0x495a7a;})});}_0x44ff41=_[_0xcdfc('0x45')]({},_0x44ff41,_0x582bde['options']);return db[_0xcdfc('0xad')][_0xcdfc('0x24')]({'where':_0x44ff41['where']})[_0xcdfc('0x12')](function(_0x1f36ca){_0x3fc4e9[_0xcdfc('0x24')]=_0x1f36ca;if(_0x582bde[_0xcdfc('0x36')][_0xcdfc('0x49')]){_0x44ff41['include']=[{'model':db[_0xcdfc('0x81')],'as':_0xcdfc('0xed'),'required':![]},{'model':db['User'],'as':_0xcdfc('0xee'),'attributes':['name',_0xcdfc('0xef'),_0xcdfc('0xf0')],'required':![]},{'model':db['Tag'],'as':_0xcdfc('0xf1'),'attributes':['id','name',_0xcdfc('0xf2')],'where':_0x582bde[_0xcdfc('0x36')][_0xcdfc('0xf3')]?{'id':_0x582bde[_0xcdfc('0x36')][_0xcdfc('0xf3')]}:undefined,'required':_0x582bde['query'][_0xcdfc('0xf3')]?!![]:![]}];}return db[_0xcdfc('0xad')][_0xcdfc('0x4b')](_0x44ff41);})['then'](function(_0x2a6a17){_0x3fc4e9[_0xcdfc('0x4c')]=_0x2a6a17;return _0x3fc4e9;});}})[_0xcdfc('0x12')](respondWithFilteredResult(_0x32c2b4,_0x44ff41))[_0xcdfc('0x1c')](handleError(_0x32c2b4,null));};function iftimePromise(_0x51ed4a,_0x3b9edc){return respondWithRpcPromise(_0xcdfc('0xf4'),_0xcdfc('0xf5'),{'command':_0x3b9edc[_0xcdfc('0xf6')]?util[_0xcdfc('0xa6')](_0xcdfc('0xf7'),_0x51ed4a[_0xcdfc('0xf8')],_0x3b9edc[_0xcdfc('0xf6')]):util[_0xcdfc('0xa6')](_0xcdfc('0xf9'),_0x51ed4a[_0xcdfc('0xf8')])},client9002)['then'](function(_0x550273){var _0x1c3c76=_0x550273&&_0x550273['indexOf']('true')>=0x0?!![]:![];logger[_0xcdfc('0x1a')](_0xcdfc('0xfa'),_0x3b9edc['id'],_0x51ed4a['id'],_0x51ed4a[_0xcdfc('0xf8')],_0x1c3c76?_0xcdfc('0xfb'):_0xcdfc('0xfc'),_0x3b9edc[_0xcdfc('0xf6')]?_0x3b9edc[_0xcdfc('0xf6')]:_0xcdfc('0xfd'));return _0x1c3c76;})['catch'](function(_0x65d2ac){logger[_0xcdfc('0x17')](_0xcdfc('0xfa'),_0x3b9edc['id'],_0x51ed4a['id'],_0x51ed4a[_0xcdfc('0xf8')],util[_0xcdfc('0xfe')](_0x65d2ac,{'showHidden':![],'depth':null}),_0x3b9edc['timezone']?_0x3b9edc[_0xcdfc('0xf6')]:_0xcdfc('0xfd'));return![];});}exports['getSnippet']=function(_0xa234c1,_0x3c1e20){var _0x4810c3=0x0;var _0x5bf0b7=0x0;var _0x41a932=![];var _0x5eaf96;var _0x4b928e;return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0xa234c1[_0xcdfc('0x4d')]['id']},'include':[{'model':db[_0xcdfc('0xff')],'as':_0xcdfc('0xff'),'include':[{'model':db['Interval'],'as':_0xcdfc('0x100'),'attributes':['id',_0xcdfc('0xf8')],'raw':!![]}]}]})[_0xcdfc('0x12')](handleEntityNotFound(_0x3c1e20,null))[_0xcdfc('0x12')](function(_0x29a782){if(_0x29a782){_0x5eaf96=_0x29a782;return _0x29a782[_0xcdfc('0x101')]({'raw':!![]});}})[_0xcdfc('0x12')](function(_0x46dc2c){if(_0x5eaf96){if(_0x46dc2c){_0x4b928e=_0x46dc2c;}}return require(_0xcdfc('0x6d'))[_0xcdfc('0x6e')]();})[_0xcdfc('0x12')](function(_0x9bae64){if(_0x9bae64){_0x5bf0b7=_0x9bae64[_0xcdfc('0x102')];_0x41a932=_0x9bae64[_0xcdfc('0x6f')];}})[_0xcdfc('0x12')](function(){return db[_0xcdfc('0xad')][_0xcdfc('0x24')]({'where':{'closed':![]}});})[_0xcdfc('0x12')](function(_0x13d934){_0x4810c3=_0x13d934;if(_0x5bf0b7&&_0x13d934>_0x5bf0b7){return db['License'][_0xcdfc('0x5f')]({'where':{'id':0x1}})[_0xcdfc('0x12')](function(_0x4f095b){if(_0x4f095b){_0x4f095b['increment']('chatLicenseExceeded');}});}})[_0xcdfc('0x12')](function(){if(_0x5eaf96[_0xcdfc('0xff')]&&_0x5eaf96['Interval'][_0xcdfc('0x100')]){var _0x2fac3f=[];for(var _0x23fe1b=0x0;_0x23fe1b<_0x5eaf96[_0xcdfc('0xff')][_0xcdfc('0x100')]['length'];_0x23fe1b++){var _0x5a0ef5=_0x5eaf96['Interval'][_0xcdfc('0x100')][_0x23fe1b]['get']({'plain':!![]});_0x2fac3f['push'](iftimePromise(_0x5a0ef5,_0x5eaf96));}return BPromise[_0xcdfc('0x103')](_0x2fac3f)[_0xcdfc('0x12')](function(_0x1c8d04){return _[_0xcdfc('0x104')](_0x1c8d04);});}else{return!![];}})['then'](function(_0xb0d88b){var _0x3ac9e5=fs['readFileSync'](path[_0xcdfc('0x6a')](config[_0xcdfc('0x6b')],_0xcdfc('0x105')),_0xcdfc('0xc9'));var _0x40f0c4={'remote':_0x5eaf96[_0xcdfc('0x106')],'query':querystring[_0xcdfc('0x16')](_['merge'](_0x5eaf96['get']({'plain':!![]}),{'customerIp':_0xa234c1[_0xcdfc('0x9c')][_0xcdfc('0x9e')]||_0xa234c1['headers']['x-real-ip']||_0xa234c1['connection']['remoteAddress']||_0xa234c1['ip'],'referer':_0xa234c1[_0xcdfc('0x9c')]['referer'],'openedInteractions':_0x4810c3,'maxInteractions':_0x5bf0b7,'virtual':_0x41a932[_0xcdfc('0x102')],'online':_0xb0d88b,'custom':_0x41a932}))['replace'](/'/g,'\x5c\x27')};_0x3c1e20[_0xcdfc('0x2d')](ejs['render'](Mustache['render'](_0x3ac9e5,_0x40f0c4),{'proactiveActions':_0x4b928e,'alignment':_0x5eaf96[_0xcdfc('0x107')],'verticalAlignment':_0x5eaf96[_0xcdfc('0x108')],'div_color':_0x5eaf96['color'],'labelText':_0x5eaf96[_0xcdfc('0x109')],'text_color':_0x5eaf96['textColor'],'button_color':_0x5eaf96[_0xcdfc('0x10a')],'background_color':_0x5eaf96[_0xcdfc('0x10b')],'hideWhenOffline':_0x5eaf96[_0xcdfc('0x10c')],'interval':_0x5eaf96['IntervalId']}));})[_0xcdfc('0x1c')](handleError(_0x3c1e20,null));};exports['addApplications']=function(_0x177a8c,_0x59767f){var _0x452fe0=_0x177a8c['params']['id'];var _0x12f733=_0x177a8c[_0xcdfc('0x50')];var _0x404e70=0xc8;var _0x1ba33d=null;return db[_0xcdfc('0xd4')][_0xcdfc('0xd5')]({'isolationLevel':db[_0xcdfc('0xd4')]['Transaction']['ISOLATION_LEVELS'][_0xcdfc('0x10d')]},function(_0x424338){return db[_0xcdfc('0x48')][_0xcdfc('0x5f')]({'where':{'id':_0x452fe0},'transaction':_0x424338})[_0xcdfc('0x12')](function(_0x111bc7){if(_0x111bc7){return db['ChatApplication'][_0xcdfc('0x28')]({'where':{'ChatWebsiteId':_0x452fe0},'transaction':_0x424338})['then'](function(){var _0x4c80c4=_[_0xcdfc('0x31')](_0x12f733,function(_0x482ad8){_0x482ad8[_0xcdfc('0x57')]=_0x452fe0;return _0x482ad8;});return db[_0xcdfc('0x92')][_0xcdfc('0xd7')](_0x4c80c4,{'transaction':_0x424338});});}else{_0x404e70=0x194;_0x1ba33d=[];}});})['then'](function(){if(_0x404e70!==0x194){return db['ChatApplication'][_0xcdfc('0x10e')]({'where':{'ChatWebsiteId':_0x452fe0},'order':_0xcdfc('0x98')})[_0xcdfc('0x12')](function(_0x1175ba){_0x1ba33d=_0x1175ba;});}})[_0xcdfc('0x1c')](function(_0x51d4e2){_0x404e70=0x1f4;logger[_0xcdfc('0x17')](_0x51d4e2[_0xcdfc('0x2b')]);if(_0x51d4e2['name']){delete _0x51d4e2[_0xcdfc('0x2c')];}_0x1ba33d=_0x51d4e2;})[_0xcdfc('0x10f')](function(){if(_0x1ba33d===null){_0x59767f[_0xcdfc('0x1d')](_0x404e70);}else{if(_0x404e70===0x1f4){_0x59767f[_0xcdfc('0x1e')](_0x404e70)[_0xcdfc('0x2d')](_0x1ba33d);}else{_0x59767f[_0xcdfc('0x1e')](_0x404e70)['json'](_0x1ba33d);}}});};exports['getApplications']=function(_0x4e09ec,_0x5d40d5){var _0x3dd5df={};var _0x3798cb={};var _0x2ada8e;var _0x1ed11b;return db['ChatWebsite'][_0xcdfc('0x5f')]({'where':{'id':_0x4e09ec[_0xcdfc('0x4d')]['id']}})['then'](handleEntityNotFound(_0x5d40d5,null))[_0xcdfc('0x12')](function(_0xfeca92){if(_0xfeca92){_0x2ada8e=_0xfeca92;_0x3798cb[_0xcdfc('0x39')]=_[_0xcdfc('0x37')](db[_0xcdfc('0x92')][_0xcdfc('0x32')]);_0x3798cb[_0xcdfc('0x36')]=_[_0xcdfc('0x37')](_0x4e09ec[_0xcdfc('0x36')]);_0x3798cb[_0xcdfc('0x42')]=_['intersection'](_0x3798cb[_0xcdfc('0x39')],_0x3798cb[_0xcdfc('0x36')]);_0x3dd5df[_0xcdfc('0x3a')]=_[_0xcdfc('0x38')](_0x3798cb[_0xcdfc('0x39')],qs[_0xcdfc('0x3b')](_0x4e09ec[_0xcdfc('0x36')]['fields']));_0x3dd5df[_0xcdfc('0x3a')]=_0x3dd5df[_0xcdfc('0x3a')]['length']?_0x3dd5df[_0xcdfc('0x3a')]:_0x3798cb[_0xcdfc('0x39')];_0x3dd5df[_0xcdfc('0x3f')]=qs[_0xcdfc('0x40')](_0x4e09ec[_0xcdfc('0x36')][_0xcdfc('0x40')]);_0x3dd5df[_0xcdfc('0x41')]=qs[_0xcdfc('0x42')](_[_0xcdfc('0x43')](_0x4e09ec[_0xcdfc('0x36')],_0x3798cb[_0xcdfc('0x42')]));if(_0x4e09ec[_0xcdfc('0x36')][_0xcdfc('0x44')]){_0x3dd5df[_0xcdfc('0x41')]=_[_0xcdfc('0x45')](_0x3dd5df[_0xcdfc('0x41')],{'$or':_[_0xcdfc('0x31')](_0x3dd5df[_0xcdfc('0x3a')],function(_0x8d0f64){var _0x18da0c={};_0x18da0c[_0x8d0f64]={'$like':'%'+_0x4e09ec[_0xcdfc('0x36')][_0xcdfc('0x44')]+'%'};return _0x18da0c;})});}_0x3dd5df=_['merge']({},_0x3dd5df,_0x4e09ec[_0xcdfc('0x47')]);return _0x2ada8e[_0xcdfc('0x110')](_0x3dd5df);}})[_0xcdfc('0x12')](function(_0x3838d2){if(_0x3838d2){_0x1ed11b=_0x3838d2[_0xcdfc('0x3c')];if(!_0x4e09ec[_0xcdfc('0x36')][_0xcdfc('0x3d')](_0xcdfc('0x3e'))){_0x3dd5df[_0xcdfc('0x23')]=qs[_0xcdfc('0x23')](_0x4e09ec[_0xcdfc('0x36')][_0xcdfc('0x23')]);_0x3dd5df[_0xcdfc('0x21')]=qs[_0xcdfc('0x21')](_0x4e09ec[_0xcdfc('0x36')][_0xcdfc('0x21')]);}return _0x2ada8e[_0xcdfc('0x110')](_0x3dd5df);}})['then'](function(_0x149a29){if(_0x149a29){return _0x149a29?{'count':_0x1ed11b,'rows':_0x149a29}:null;}})['then'](respondWithResult(_0x5d40d5,null))[_0xcdfc('0x1c')](handleError(_0x5d40d5,null));};exports[_0xcdfc('0x111')]=function(_0x3f1fe1,_0x59e5fe){return db['chatProactiveAction'][_0xcdfc('0x4e')]({'where':{'id':_0x3f1fe1[_0xcdfc('0x4d')]['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x59e5fe,null))[_0xcdfc('0x12')](function(_0x3eefa9){if(_0x3eefa9){return _0x3eefa9[_0xcdfc('0x111')](_0x3f1fe1[_0xcdfc('0x50')]['ids'],_[_0xcdfc('0xeb')](_0x3f1fe1[_0xcdfc('0x50')],[_0xcdfc('0x5b'),'id'])||{});}})[_0xcdfc('0x12')](respondWithResult(_0x59e5fe,null))['catch'](handleError(_0x59e5fe,null));};exports[_0xcdfc('0x101')]=function(_0x1c6437,_0x2644f5){var _0x396ebc={};var _0x23b706={};var _0x224911;var _0x10f3b5;return db['ChatWebsite'][_0xcdfc('0x5f')]({'where':{'id':_0x1c6437['params']['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x2644f5,null))[_0xcdfc('0x12')](function(_0x8577a1){if(_0x8577a1){_0x224911=_0x8577a1;_0x23b706['model']=_[_0xcdfc('0x37')](db[_0xcdfc('0x112')]['rawAttributes']);_0x23b706[_0xcdfc('0x36')]=_['keys'](_0x1c6437[_0xcdfc('0x36')]);_0x23b706[_0xcdfc('0x42')]=_[_0xcdfc('0x38')](_0x23b706[_0xcdfc('0x39')],_0x23b706[_0xcdfc('0x36')]);_0x396ebc[_0xcdfc('0x3a')]=_[_0xcdfc('0x38')](_0x23b706[_0xcdfc('0x39')],qs[_0xcdfc('0x3b')](_0x1c6437[_0xcdfc('0x36')][_0xcdfc('0x3b')]));_0x396ebc[_0xcdfc('0x3a')]=_0x396ebc[_0xcdfc('0x3a')][_0xcdfc('0x3c')]?_0x396ebc[_0xcdfc('0x3a')]:_0x23b706['model'];_0x396ebc[_0xcdfc('0x3f')]=qs[_0xcdfc('0x40')](_0x1c6437['query']['sort']);_0x396ebc[_0xcdfc('0x41')]=qs['filters'](_[_0xcdfc('0x43')](_0x1c6437[_0xcdfc('0x36')],_0x23b706[_0xcdfc('0x42')]));if(_0x1c6437[_0xcdfc('0x36')][_0xcdfc('0x44')]){_0x396ebc[_0xcdfc('0x41')]=_['merge'](_0x396ebc['where'],{'$or':_[_0xcdfc('0x31')](_0x396ebc[_0xcdfc('0x3a')],function(_0xed7fa5){var _0x1b755e={};_0x1b755e[_0xed7fa5]={'$like':'%'+_0x1c6437[_0xcdfc('0x36')][_0xcdfc('0x44')]+'%'};return _0x1b755e;})});}_0x396ebc=_[_0xcdfc('0x45')]({},_0x396ebc,_0x1c6437[_0xcdfc('0x47')]);return _0x224911['getProactiveActions'](_0x396ebc);}})[_0xcdfc('0x12')](function(_0x31b1ff){if(_0x31b1ff){_0x10f3b5=_0x31b1ff[_0xcdfc('0x3c')];if(!_0x1c6437['query'][_0xcdfc('0x3d')](_0xcdfc('0x3e'))){_0x396ebc['limit']=qs[_0xcdfc('0x23')](_0x1c6437[_0xcdfc('0x36')]['limit']);_0x396ebc[_0xcdfc('0x21')]=qs['offset'](_0x1c6437[_0xcdfc('0x36')][_0xcdfc('0x21')]);}return _0x224911[_0xcdfc('0x101')](_0x396ebc);}})['then'](function(_0x2f531c){if(_0x2f531c){return _0x2f531c?{'count':_0x10f3b5,'rows':_0x2f531c}:null;}})[_0xcdfc('0x12')](respondWithResult(_0x2644f5,null))[_0xcdfc('0x1c')](handleError(_0x2644f5,null));};exports['getFields']=function(_0x5b1c80,_0x573f04){var _0x2f14a1=_0x5b1c80[_0xcdfc('0x36')]['online']==='false'?_0xcdfc('0x113'):_0xcdfc('0x114');return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'attributes':['id',_0x2f14a1],'where':{'id':_0x5b1c80[_0xcdfc('0x4d')]['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x573f04,null))[_0xcdfc('0x12')](function(_0x107e5b){if(_0x107e5b){var _0x12dd11=_0x107e5b[_0x2f14a1];var _0x128b95=_0x12dd11&&_0x12dd11[_0xcdfc('0x115')]?_0x12dd11[_0xcdfc('0x115')]:[];_0x573f04[_0xcdfc('0x2d')]({'fromKey':_[_0xcdfc('0x70')](_0x12dd11[_0xcdfc('0x116')])?undefined:_0x12dd11[_0xcdfc('0x116')],'count':_0x128b95['length'],'rows':_0x128b95});}})[_0xcdfc('0x1c')](handleError(_0x573f04,null));};exports[_0xcdfc('0x117')]=function(_0x3cdf84,_0x4a3c92){var _0x50b878={'raw':![],'where':{}};var _0x349f38={};var _0x3dff4f={'count':0x0,'rows':[]};return db['ChatWebsite'][_0xcdfc('0x5f')]({'where':{'id':_0x3cdf84[_0xcdfc('0x4d')]['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x4a3c92,null))['then'](function(_0x1ddc7d){if(_0x1ddc7d){_0x349f38[_0xcdfc('0x39')]=_[_0xcdfc('0x37')](db[_0xcdfc('0xcd')][_0xcdfc('0x32')]);_0x349f38[_0xcdfc('0x36')]=_[_0xcdfc('0x37')](_0x3cdf84[_0xcdfc('0x36')]);_0x349f38[_0xcdfc('0x42')]=_[_0xcdfc('0x38')](_0x349f38[_0xcdfc('0x39')],_0x349f38[_0xcdfc('0x36')]);_0x50b878[_0xcdfc('0x3a')]=_[_0xcdfc('0x38')](_0x349f38[_0xcdfc('0x39')],qs['fields'](_0x3cdf84[_0xcdfc('0x36')][_0xcdfc('0x3b')]));_0x50b878[_0xcdfc('0x3a')]=_0x50b878[_0xcdfc('0x3a')][_0xcdfc('0x3c')]?_0x50b878['attributes']:_0x349f38[_0xcdfc('0x39')];if(!_0x3cdf84[_0xcdfc('0x36')][_0xcdfc('0x3d')](_0xcdfc('0x3e'))){_0x50b878[_0xcdfc('0x23')]=qs[_0xcdfc('0x23')](_0x3cdf84[_0xcdfc('0x36')][_0xcdfc('0x23')]);_0x50b878['offset']=qs[_0xcdfc('0x21')](_0x3cdf84[_0xcdfc('0x36')]['offset']);}_0x50b878[_0xcdfc('0x3f')]=qs[_0xcdfc('0x40')](_0x3cdf84[_0xcdfc('0x36')]['sort']);_0x50b878['where']=qs[_0xcdfc('0x42')](_[_0xcdfc('0x43')](_0x3cdf84[_0xcdfc('0x36')],_0x349f38[_0xcdfc('0x42')]));_0x50b878['where'][_0xcdfc('0x57')]=_0x1ddc7d['id'];if(_0x3cdf84[_0xcdfc('0x36')][_0xcdfc('0x44')]){_0x50b878[_0xcdfc('0x41')]=_['merge'](_0x50b878[_0xcdfc('0x41')],{'$or':_[_0xcdfc('0x31')](_0x50b878[_0xcdfc('0x3a')],function(_0x111896){var _0x36d586={};_0x36d586[_0x111896]={'$like':'%'+_0x3cdf84[_0xcdfc('0x36')][_0xcdfc('0x44')]+'%'};return _0x36d586;})});}_0x50b878=_[_0xcdfc('0x45')]({},_0x50b878,_0x3cdf84[_0xcdfc('0x47')]);return db['ChatOfflineMessage'][_0xcdfc('0x24')]({'where':_0x50b878[_0xcdfc('0x41')]})[_0xcdfc('0x12')](function(_0x113678){_0x3dff4f['count']=_0x113678;if(_0x3cdf84['query'][_0xcdfc('0x49')]){_0x50b878[_0xcdfc('0x4a')]=[{'all':!![]}];}else{_0x50b878[_0xcdfc('0x4a')]=[{'model':db[_0xcdfc('0x81')],'as':'Contact','required':![]},{'model':db[_0xcdfc('0xd6')],'as':_0xcdfc('0x118'),'required':![]}];}return db[_0xcdfc('0xcd')]['findAll'](_0x50b878);})[_0xcdfc('0x12')](function(_0x3bee29){_0x3dff4f[_0xcdfc('0x4c')]=_0x3bee29;return _0x3dff4f;});}})[_0xcdfc('0x12')](respondWithFilteredResult(_0x4a3c92,_0x50b878))[_0xcdfc('0x1c')](handleError(_0x4a3c92,null));};exports[_0xcdfc('0x119')]=function(_0x2f448d,_0x5323d2){return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0x2f448d[_0xcdfc('0x4d')]['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x5323d2,null))[_0xcdfc('0x12')](function(_0x2473da){if(_0x2473da){return _0x2473da[_0xcdfc('0x119')](_0x2f448d[_0xcdfc('0x50')][_0xcdfc('0x5b')],_[_0xcdfc('0xeb')](_0x2f448d['body'],[_0xcdfc('0x5b'),'id'])||{})['spread'](function(_0x1cee7f){for(var _0x9a516e=0x0;_0x9a516e<_0x2f448d[_0xcdfc('0x50')]['ids'][_0xcdfc('0x3c')];_0x9a516e+=0x1){socket[_0xcdfc('0x11a')](_0xcdfc('0x11b'),{'UserId':Number(_0x2f448d[_0xcdfc('0x50')][_0xcdfc('0x5b')][_0x9a516e]),'ChatWebsiteId':Number(_0x2f448d[_0xcdfc('0x4d')]['id'])});}return _0x1cee7f;});}})[_0xcdfc('0x12')](respondWithResult(_0x5323d2,null))[_0xcdfc('0x1c')](handleError(_0x5323d2,null));};exports[_0xcdfc('0x11c')]=function(_0x51dc6a,_0x24c3ba){return db[_0xcdfc('0x48')][_0xcdfc('0x4e')]({'where':{'id':_0x51dc6a['params']['id']}})[_0xcdfc('0x12')](handleEntityNotFound(_0x24c3ba,null))['then'](function(_0x3e0173){if(_0x3e0173){return _0x3e0173[_0xcdfc('0x11c')](_0x51dc6a[_0xcdfc('0x36')][_0xcdfc('0x5b')])[_0xcdfc('0x12')](function(){if(_['isArray'](_0x51dc6a[_0xcdfc('0x36')][_0xcdfc('0x5b')])){for(var _0x4bdfa2=0x0;_0x4bdfa2<_0x51dc6a[_0xcdfc('0x36')][_0xcdfc('0x5b')]['length'];_0x4bdfa2+=0x1){socket[_0xcdfc('0x11a')]('userChatWebsite:remove',{'UserId':Number(_0x51dc6a[_0xcdfc('0x36')][_0xcdfc('0x5b')][_0x4bdfa2]),'ChatWebsiteId':Number(_0x51dc6a['params']['id'])});}}else{socket[_0xcdfc('0x11a')](_0xcdfc('0x11d'),{'UserId':Number(_0x51dc6a['query'][_0xcdfc('0x5b')]),'ChatWebsiteId':Number(_0x51dc6a[_0xcdfc('0x4d')]['id'])});}});}})['then'](respondWithStatusCode(_0x24c3ba,null))[_0xcdfc('0x1c')](handleError(_0x24c3ba,null));};exports['getAgents']=function(_0x1fb5c0,_0x45bab0){var _0x135c32={};var _0x21178c={};var _0x23b930;var _0x47daa0;return db[_0xcdfc('0x48')][_0xcdfc('0x5f')]({'where':{'id':_0x1fb5c0[_0xcdfc('0x4d')]['id']}})['then'](handleEntityNotFound(_0x45bab0,null))['then'](function(_0x45fdaa){if(_0x45fdaa){_0x23b930=_0x45fdaa;_0x21178c[_0xcdfc('0x39')]=_[_0xcdfc('0x37')](db['User'][_0xcdfc('0x32')]);_0x21178c[_0xcdfc('0x36')]=_['keys'](_0x1fb5c0[_0xcdfc('0x36')]);_0x21178c['filters']=_['intersection'](_0x21178c[_0xcdfc('0x39')],_0x21178c[_0xcdfc('0x36')]);_0x135c32[_0xcdfc('0x3a')]=_[_0xcdfc('0x38')](_0x21178c[_0xcdfc('0x39')],qs[_0xcdfc('0x3b')](_0x1fb5c0[_0xcdfc('0x36')][_0xcdfc('0x3b')]));_0x135c32[_0xcdfc('0x3a')]=_0x135c32[_0xcdfc('0x3a')][_0xcdfc('0x3c')]?_0x135c32[_0xcdfc('0x3a')]:_0x21178c[_0xcdfc('0x39')];_0x135c32[_0xcdfc('0x3f')]=qs[_0xcdfc('0x40')](_0x1fb5c0['query']['sort']);_0x135c32[_0xcdfc('0x41')]=qs['filters'](_[_0xcdfc('0x43')](_0x1fb5c0['query'],_0x21178c[_0xcdfc('0x42')]));if(_0x1fb5c0[_0xcdfc('0x36')][_0xcdfc('0x44')]){_0x135c32[_0xcdfc('0x41')]=_[_0xcdfc('0x45')](_0x135c32[_0xcdfc('0x41')],{'$or':_[_0xcdfc('0x31')](_0x135c32['attributes'],function(_0x50f034){var _0x63e9d1={};_0x63e9d1[_0x50f034]={'$like':'%'+_0x1fb5c0[_0xcdfc('0x36')][_0xcdfc('0x44')]+'%'};return _0x63e9d1;})});}_0x135c32=_['merge']({},_0x135c32,_0x1fb5c0[_0xcdfc('0x47')]);return _0x23b930[_0xcdfc('0x11e')](_0x135c32);}})[_0xcdfc('0x12')](function(_0x51e922){if(_0x51e922){_0x47daa0=_0x51e922[_0xcdfc('0x3c')];if(!_0x1fb5c0[_0xcdfc('0x36')]['hasOwnProperty']('nolimit')){_0x135c32['limit']=qs[_0xcdfc('0x23')](_0x1fb5c0[_0xcdfc('0x36')]['limit']);_0x135c32[_0xcdfc('0x21')]=qs['offset'](_0x1fb5c0[_0xcdfc('0x36')][_0xcdfc('0x21')]);}return _0x23b930[_0xcdfc('0x11e')](_0x135c32);}})[_0xcdfc('0x12')](function(_0x2f577a){if(_0x2f577a){return _0x2f577a?{'count':_0x47daa0,'rows':_0x2f577a}:null;}})['then'](respondWithResult(_0x45bab0,null))[_0xcdfc('0x1c')](handleError(_0x45bab0,null));};
\ No newline at end of file