Built motion from commit 994c64e1.|2.6.1
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 41b89d3..b565c66 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7123=['Intervals','getProactiveActions','virtual','License','increment','chatLicenseExceeded','all','some','server/files/chat/iframe.js','remote','x-real-ip','connection','remoteAddress','replace','alignment','verticalAlignment','color','textColor','sequelize','transaction','findAndCountAll','getApplications','addProactiveActions','false','offlineForm','onlineForm','items','fromKey','getOfflineMessages','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','defaults','localhost','socket.io-emitter','./chatWebsite.socket','register','jayson/promise','client','http','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end','json','limit','set','Content-Range','apply','reject','save','destroy','get','ChatWebsites','UserProfileResource','stack','name','send','index','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','fieldName','type','key','model','keys','query','filters','attributes','intersection','fields','nolimit','offset','order','sort','pick','filter','merge','where','options','count','includeAll','include','rows','show','length','find','create','body','user','role','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','addDisposition','Disposition','findOne','hasOwnProperty','ChatWebsiteId','findAll','ids','addAnswer','CannedAnswer','removeAnswers','addLogo','sitepic','filename','addAvatar','addCustomerAvatar','customerAvatar','file','systemAvatar','getLogo','root','server/files/images/logos/default_logo.svg','../../config/license/util','getLicense','custom','isNil','existsSync','join','server/files/images/logos/','getAvatar','agentAvatar','server/files/images/avatars/','download','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','notify','user-agent-parser','setUA','headers','getResult','chat','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','Contacts','ChatApplication','List','applications','Applications','list','orderBy','priority','asc','account','contact','customerIp','cf-connecting-ip','x-forwarded-for','split','firstName','x-real-port','referer','browser','version','format','unknown','%s\x20%s','device','%s\x20%s\x20%s','vendor','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','lastName','messageId','update','created','autoclose','push','close','*,*,*,*','ChatMessage','UserId','User','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','MailAccount','MailServerOut','Smtp','forwardOfflineAddress','service','host','port','secure','authentication','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','omit','getInteractions','Contact','Owner','fullname','internal','Tag','Tags','tag','getSnippet','timezone','iftime\x20%s,%s','interval','iftime\x20%s','indexOf','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval'];(function(_0x2134b7,_0x1eb5e2){var _0x6c5914=function(_0x1da201){while(--_0x1da201){_0x2134b7['push'](_0x2134b7['shift']());}};_0x6c5914(++_0x1eb5e2);}(_0x7123,0x14d));var _0x3712=function(_0x168f22,_0x85324b){_0x168f22=_0x168f22-0x0;var _0x350c95=_0x7123[_0x168f22];return _0x350c95;};'use strict';var pdf=require(_0x3712('0x0'));var emlformat=require(_0x3712('0x1'));var rimraf=require(_0x3712('0x2'));var zipdir=require(_0x3712('0x3'));var jsonpatch=require(_0x3712('0x4'));var rp=require(_0x3712('0x5'));var moment=require(_0x3712('0x6'));var BPromise=require('bluebird');var Mustache=require(_0x3712('0x7'));var util=require(_0x3712('0x8'));var path=require(_0x3712('0x9'));var sox=require(_0x3712('0xa'));var csv=require(_0x3712('0xb'));var ejs=require(_0x3712('0xc'));var fs=require('fs');var _=require(_0x3712('0xd'));var squel=require('squel');var crypto=require(_0x3712('0xe'));var jsforce=require(_0x3712('0xf'));var deskjs=require('desk.js');var toCsv=require(_0x3712('0xb'));var querystring=require('querystring');var Papa=require(_0x3712('0x10'));var Redis=require(_0x3712('0x11'));var authService=require(_0x3712('0x12'));var qs=require(_0x3712('0x13'));var as=require(_0x3712('0x14'));var hardwareService=require(_0x3712('0x15'));var logger=require(_0x3712('0x16'))(_0x3712('0x17'));var utils=require(_0x3712('0x18'));var config=require(_0x3712('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0x3712('0x1a'))['db'];config['redis']=_[_0x3712('0x1b')](config['redis'],{'host':_0x3712('0x1c'),'port':0x18eb});var socket=require(_0x3712('0x1d'))(new Redis(config['redis']));require(_0x3712('0x1e'))[_0x3712('0x1f')](socket);var jayson=require(_0x3712('0x20'));var client=jayson['client']['http']({'port':0x232c});var client9002=jayson[_0x3712('0x21')][_0x3712('0x22')]({'port':0x232a});var client9003=jayson[_0x3712('0x21')][_0x3712('0x22')]({'port':0x232b});function respondWithRpcPromise(_0x2949f4,_0xf51798,_0x349e1f,_0x73f7ad){return new BPromise(function(_0x429178,_0x301900){var _0x457b46=_0x73f7ad||client;return _0x457b46[_0x3712('0x23')](_0x2949f4,_0x349e1f)[_0x3712('0x24')](function(_0x3d6900){logger[_0x3712('0x25')](_0x3712('0x26'),_0xf51798,_0x3712('0x27'));logger['debug'](_0x3712('0x28'),_0xf51798,_0x3712('0x27'),JSON[_0x3712('0x29')](_0x3d6900));if(_0x3d6900[_0x3712('0x2a')]){if(_0x3d6900[_0x3712('0x2a')][_0x3712('0x2b')]===0x1f4){logger[_0x3712('0x2a')](_0x3712('0x26'),_0xf51798,_0x3d6900['error'][_0x3712('0x2c')]);return _0x301900(_0x3d6900[_0x3712('0x2a')][_0x3712('0x2c')]);}logger[_0x3712('0x2a')]('ChatWebsite,\x20%s,\x20%s',_0xf51798,_0x3d6900[_0x3712('0x2a')][_0x3712('0x2c')]);return _0x429178(_0x3d6900[_0x3712('0x2a')][_0x3712('0x2c')]);}else{logger[_0x3712('0x25')]('ChatWebsite,\x20%s,\x20%s',_0xf51798,_0x3712('0x27'));_0x429178(_0x3d6900[_0x3712('0x2d')][_0x3712('0x2c')]);}})[_0x3712('0x2e')](function(_0x4c4d19){logger['error'](_0x3712('0x26'),_0xf51798,_0x4c4d19);_0x301900(_0x4c4d19);});});}function respondWithStatusCode(_0x5cce0d,_0x53987e){_0x53987e=_0x53987e||0xcc;return function(_0x4edc7e){if(_0x4edc7e){return _0x5cce0d[_0x3712('0x2f')](_0x53987e);}return _0x5cce0d[_0x3712('0x30')](_0x53987e)[_0x3712('0x31')]();};}function respondWithResult(_0x5bcdba,_0x21db7d){_0x21db7d=_0x21db7d||0xc8;return function(_0x2445a7){if(_0x2445a7){return _0x5bcdba['status'](_0x21db7d)[_0x3712('0x32')](_0x2445a7);}};}function respondWithFilteredResult(_0x29ed7d,_0x295bc0){return function(_0xbc105){if(_0xbc105){var _0x4ea307=_0xbc105['count'],_0x2bf505=_0x295bc0['offset'],_0x1d7f2f=_0x295bc0['offset']+_0x295bc0[_0x3712('0x33')],_0x44a0b3;if(_0x1d7f2f>=_0x4ea307){_0x1d7f2f=_0x4ea307;_0x44a0b3=0xc8;}else{_0x44a0b3=0xce;}_0x29ed7d[_0x3712('0x30')](_0x44a0b3);return _0x29ed7d[_0x3712('0x34')](_0x3712('0x35'),_0x2bf505+'-'+_0x1d7f2f+'/'+_0x4ea307)['json'](_0xbc105);}return null;};}function patchUpdates(_0xef8343){return function(_0x17c115){try{jsonpatch[_0x3712('0x36')](_0x17c115,_0xef8343,!![]);}catch(_0x57359b){return BPromise[_0x3712('0x37')](_0x57359b);}return _0x17c115[_0x3712('0x38')]();};}function saveUpdates(_0x43522e,_0x160cdc){return function(_0x35610b){if(_0x35610b){return _0x35610b['update'](_0x43522e)['then'](function(_0x379d49){return _0x379d49;});}return null;};}function removeEntity(_0x2bd69c,_0x50b069){return function(_0x166a14){if(_0x166a14){return _0x166a14[_0x3712('0x39')]()[_0x3712('0x24')](function(){var _0x2c5041=_0x166a14[_0x3712('0x3a')]({'plain':!![]});var _0x5f306f=_0x3712('0x3b');return db[_0x3712('0x3c')][_0x3712('0x39')]({'where':{'type':_0x5f306f,'resourceId':_0x2c5041['id']}})[_0x3712('0x24')](function(){return _0x166a14;});})['then'](function(){_0x2bd69c[_0x3712('0x30')](0xcc)[_0x3712('0x31')]();});}};}function handleEntityNotFound(_0x17592b,_0x18d0bc){return function(_0x55e4cc){if(!_0x55e4cc){_0x17592b['sendStatus'](0x194);}return _0x55e4cc;};}function handleError(_0x558d20,_0x413e63){_0x413e63=_0x413e63||0x1f4;return function(_0x4e90bd){logger[_0x3712('0x2a')](_0x4e90bd[_0x3712('0x3d')]);if(_0x4e90bd['name']){delete _0x4e90bd[_0x3712('0x3e')];}_0x558d20['status'](_0x413e63)[_0x3712('0x3f')](_0x4e90bd);};}exports[_0x3712('0x40')]=function(_0x51d8d9,_0x37225f){var _0x1ac76b={'include':[{'model':db[_0x3712('0x41')],'as':_0x3712('0x42')}]},_0x157352={},_0x2df318={'count':0x0,'rows':[]};var _0x31f744=_[_0x3712('0x43')](db[_0x3712('0x44')][_0x3712('0x45')],function(_0x526785){return{'name':_0x526785[_0x3712('0x46')],'type':_0x526785[_0x3712('0x47')][_0x3712('0x48')]};});_0x157352[_0x3712('0x49')]=_[_0x3712('0x43')](_0x31f744,_0x3712('0x3e'));_0x157352['query']=_[_0x3712('0x4a')](_0x51d8d9[_0x3712('0x4b')]);_0x157352[_0x3712('0x4c')]=_['intersection'](_0x157352[_0x3712('0x49')],_0x157352['query']);_0x1ac76b[_0x3712('0x4d')]=_[_0x3712('0x4e')](_0x157352[_0x3712('0x49')],qs[_0x3712('0x4f')](_0x51d8d9[_0x3712('0x4b')]['fields']));_0x1ac76b['attributes']=_0x1ac76b[_0x3712('0x4d')]['length']?_0x1ac76b[_0x3712('0x4d')]:_0x157352[_0x3712('0x49')];if(!_0x51d8d9['query']['hasOwnProperty'](_0x3712('0x50'))){_0x1ac76b[_0x3712('0x33')]=qs[_0x3712('0x33')](_0x51d8d9[_0x3712('0x4b')][_0x3712('0x33')]);_0x1ac76b['offset']=qs[_0x3712('0x51')](_0x51d8d9[_0x3712('0x4b')][_0x3712('0x51')]);}_0x1ac76b[_0x3712('0x52')]=qs[_0x3712('0x53')](_0x51d8d9['query'][_0x3712('0x53')]);_0x1ac76b['where']=qs[_0x3712('0x4c')](_[_0x3712('0x54')](_0x51d8d9[_0x3712('0x4b')],_0x157352[_0x3712('0x4c')]),_0x31f744);if(_0x51d8d9[_0x3712('0x4b')][_0x3712('0x55')]){_0x1ac76b['where']=_[_0x3712('0x56')](_0x1ac76b[_0x3712('0x57')],{'$or':_['map'](_0x31f744,function(_0xb5a3f2){if(_0xb5a3f2[_0x3712('0x47')]!=='VIRTUAL'){var _0x1f7378={};_0x1f7378[_0xb5a3f2[_0x3712('0x3e')]]={'$like':'%'+_0x51d8d9[_0x3712('0x4b')]['filter']+'%'};return _0x1f7378;}})});}_0x1ac76b=_['merge']({},_0x1ac76b,_0x51d8d9[_0x3712('0x58')]);var _0x10adc1={'where':_0x1ac76b[_0x3712('0x57')]};return db[_0x3712('0x44')][_0x3712('0x59')](_0x10adc1)['then'](function(_0x3d6fa9){_0x2df318[_0x3712('0x59')]=_0x3d6fa9;if(_0x51d8d9[_0x3712('0x4b')][_0x3712('0x5a')]){_0x1ac76b[_0x3712('0x5b')]=[{'all':!![]}];}return db[_0x3712('0x44')]['findAll'](_0x1ac76b);})[_0x3712('0x24')](function(_0x2d3e94){_0x2df318[_0x3712('0x5c')]=_0x2d3e94;return _0x2df318;})[_0x3712('0x24')](respondWithFilteredResult(_0x37225f,_0x1ac76b))['catch'](handleError(_0x37225f,null));};exports[_0x3712('0x5d')]=function(_0x2b7ede,_0x12c697){var _0x250546={'raw':![],'where':{'id':_0x2b7ede['params']['id']},'include':[{'model':db[_0x3712('0x41')],'as':_0x3712('0x42')}]},_0xbf3195={};_0xbf3195[_0x3712('0x49')]=_['keys'](db['ChatWebsite'][_0x3712('0x45')]);_0xbf3195[_0x3712('0x4b')]=_[_0x3712('0x4a')](_0x2b7ede[_0x3712('0x4b')]);_0xbf3195[_0x3712('0x4c')]=_[_0x3712('0x4e')](_0xbf3195[_0x3712('0x49')],_0xbf3195[_0x3712('0x4b')]);_0x250546[_0x3712('0x4d')]=_[_0x3712('0x4e')](_0xbf3195[_0x3712('0x49')],qs['fields'](_0x2b7ede['query']['fields']));_0x250546[_0x3712('0x4d')]=_0x250546[_0x3712('0x4d')][_0x3712('0x5e')]?_0x250546[_0x3712('0x4d')]:_0xbf3195[_0x3712('0x49')];if(_0x2b7ede['query'][_0x3712('0x5a')]){_0x250546[_0x3712('0x5b')]=[{'all':!![]}];}_0x250546=_['merge']({},_0x250546,_0x2b7ede[_0x3712('0x58')]);return db['ChatWebsite'][_0x3712('0x5f')](_0x250546)['then'](handleEntityNotFound(_0x12c697,null))[_0x3712('0x24')](respondWithResult(_0x12c697,null))[_0x3712('0x2e')](handleError(_0x12c697,null));};exports['create']=function(_0x2fe7e9,_0x5a46e0){return db[_0x3712('0x44')][_0x3712('0x60')](_0x2fe7e9[_0x3712('0x61')],{})[_0x3712('0x24')](function(_0x4c4fed){var _0x348b31=_0x2fe7e9[_0x3712('0x62')][_0x3712('0x3a')]({'plain':!![]});if(!_0x348b31)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x348b31[_0x3712('0x63')]===_0x3712('0x62')){var _0xccc8c1=_0x4c4fed[_0x3712('0x3a')]({'plain':!![]});var _0x305144='ChatWebsites';return db['UserProfileSection'][_0x3712('0x5f')]({'where':{'name':_0x305144,'userProfileId':_0x348b31['userProfileId']},'raw':!![]})['then'](function(_0x3d9099){if(_0x3d9099&&_0x3d9099[_0x3712('0x64')]===0x0){return db[_0x3712('0x3c')][_0x3712('0x60')]({'name':_0xccc8c1['name'],'resourceId':_0xccc8c1['id'],'type':_0x3d9099[_0x3712('0x3e')],'sectionId':_0x3d9099['id']},{})[_0x3712('0x24')](function(){return _0x4c4fed;});}else{return _0x4c4fed;}})['catch'](function(_0x9afafb){logger['error'](_0x3712('0x65'),_0x9afafb);throw _0x9afafb;});}return _0x4c4fed;})['then'](respondWithResult(_0x5a46e0,0xc9))[_0x3712('0x2e')](handleError(_0x5a46e0,null));};exports['update']=function(_0x177147,_0x379711){if(_0x177147['body']['id']){delete _0x177147[_0x3712('0x61')]['id'];}return db[_0x3712('0x44')][_0x3712('0x5f')]({'where':{'id':_0x177147[_0x3712('0x66')]['id']},'include':[{'model':db[_0x3712('0x41')],'as':'mandatoryDispositionPause'}]})['then'](handleEntityNotFound(_0x379711,null))[_0x3712('0x24')](saveUpdates(_0x177147['body'],null))['then'](respondWithResult(_0x379711,null))[_0x3712('0x2e')](handleError(_0x379711,null));};exports['destroy']=function(_0x5e7fc6,_0x4de815){return db[_0x3712('0x44')][_0x3712('0x5f')]({'where':{'id':_0x5e7fc6[_0x3712('0x66')]['id']}})['then'](handleEntityNotFound(_0x4de815,null))['then'](removeEntity(_0x4de815,null))[_0x3712('0x2e')](handleError(_0x4de815,null));};exports[_0x3712('0x67')]=function(_0x3a55f5,_0x4fefae){return db['ChatWebsite'][_0x3712('0x67')]()[_0x3712('0x24')](respondWithResult(_0x4fefae,null))[_0x3712('0x2e')](handleError(_0x4fefae,null));};exports[_0x3712('0x68')]=function(_0x5d2ed6,_0x3ca61,_0x218881){if(_0x5d2ed6['body']['id']){delete _0x5d2ed6[_0x3712('0x61')]['id'];}return db['ChatWebsite'][_0x3712('0x5f')]({'where':{'id':_0x5d2ed6[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x3ca61,null))['then'](function(_0x515a91){if(_0x515a91){_0x5d2ed6[_0x3712('0x61')]['ChatWebsiteId']=_0x515a91['id'];return db[_0x3712('0x69')][_0x3712('0x60')](_0x5d2ed6[_0x3712('0x61')]);}})[_0x3712('0x24')](respondWithResult(_0x3ca61,null))['catch'](handleError(_0x3ca61,null));};exports['getDispositions']=function(_0x46554d,_0x3753b1,_0x1d98df){var _0x166fdb={'raw':![],'where':{}};var _0x2bf062={};var _0x3e0626={'count':0x0,'rows':[]};return db[_0x3712('0x44')][_0x3712('0x6a')]({'where':{'id':_0x46554d[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x3753b1,null))[_0x3712('0x24')](function(_0x3be2ce){if(_0x3be2ce){_0x2bf062[_0x3712('0x49')]=_[_0x3712('0x4a')](db[_0x3712('0x69')][_0x3712('0x45')]);_0x2bf062[_0x3712('0x4b')]=_[_0x3712('0x4a')](_0x46554d[_0x3712('0x4b')]);_0x2bf062[_0x3712('0x4c')]=_[_0x3712('0x4e')](_0x2bf062['model'],_0x2bf062[_0x3712('0x4b')]);_0x166fdb['attributes']=_['intersection'](_0x2bf062[_0x3712('0x49')],qs[_0x3712('0x4f')](_0x46554d[_0x3712('0x4b')]['fields']));_0x166fdb[_0x3712('0x4d')]=_0x166fdb[_0x3712('0x4d')][_0x3712('0x5e')]?_0x166fdb['attributes']:_0x2bf062[_0x3712('0x49')];if(!_0x46554d[_0x3712('0x4b')][_0x3712('0x6b')](_0x3712('0x50'))){_0x166fdb[_0x3712('0x33')]=qs['limit'](_0x46554d[_0x3712('0x4b')][_0x3712('0x33')]);_0x166fdb['offset']=qs[_0x3712('0x51')](_0x46554d[_0x3712('0x4b')]['offset']);}_0x166fdb[_0x3712('0x52')]=qs[_0x3712('0x53')](_0x46554d['query'][_0x3712('0x53')]);_0x166fdb[_0x3712('0x57')]=qs['filters'](_[_0x3712('0x54')](_0x46554d[_0x3712('0x4b')],_0x2bf062[_0x3712('0x4c')]));_0x166fdb[_0x3712('0x57')][_0x3712('0x6c')]=_0x3be2ce['id'];if(_0x46554d[_0x3712('0x4b')][_0x3712('0x55')]){_0x166fdb[_0x3712('0x57')]=_['merge'](_0x166fdb[_0x3712('0x57')],{'$or':_[_0x3712('0x43')](_0x166fdb[_0x3712('0x4d')],function(_0x117429){var _0x48fc7d={};_0x48fc7d[_0x117429]={'$like':'%'+_0x46554d[_0x3712('0x4b')][_0x3712('0x55')]+'%'};return _0x48fc7d;})});}_0x166fdb=_[_0x3712('0x56')]({},_0x166fdb,_0x46554d[_0x3712('0x58')]);return db[_0x3712('0x69')][_0x3712('0x59')]({'where':_0x166fdb[_0x3712('0x57')]})[_0x3712('0x24')](function(_0x3395b8){_0x3e0626['count']=_0x3395b8;if(_0x46554d['query'][_0x3712('0x5a')]){_0x166fdb[_0x3712('0x5b')]=[{'all':!![]}];}return db[_0x3712('0x69')][_0x3712('0x6d')](_0x166fdb);})[_0x3712('0x24')](function(_0x596cc2){_0x3e0626[_0x3712('0x5c')]=_0x596cc2;return _0x3e0626;});}})[_0x3712('0x24')](respondWithFilteredResult(_0x3753b1,_0x166fdb))[_0x3712('0x2e')](handleError(_0x3753b1,null));};exports['removeDispositions']=function(_0x1ee3f3,_0x27477e,_0x264e93){return db[_0x3712('0x44')][_0x3712('0x5f')]({'where':{'id':_0x1ee3f3[_0x3712('0x66')]['id']}})['then'](handleEntityNotFound(_0x27477e,null))[_0x3712('0x24')](function(_0x568e36){if(_0x568e36){return _0x568e36['removeDispositions'](_0x1ee3f3[_0x3712('0x4b')][_0x3712('0x6e')]);}})[_0x3712('0x24')](respondWithStatusCode(_0x27477e,null))[_0x3712('0x2e')](handleError(_0x27477e,null));};exports[_0x3712('0x6f')]=function(_0x195840,_0x31100f,_0x1f3cd3){if(_0x195840['body']['id']){delete _0x195840[_0x3712('0x61')]['id'];}return db[_0x3712('0x44')][_0x3712('0x5f')]({'where':{'id':_0x195840[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x31100f,null))[_0x3712('0x24')](function(_0x3c9672){if(_0x3c9672){_0x195840[_0x3712('0x61')][_0x3712('0x6c')]=_0x3c9672['id'];return db[_0x3712('0x70')][_0x3712('0x60')](_0x195840[_0x3712('0x61')]);}})[_0x3712('0x24')](respondWithResult(_0x31100f,null))[_0x3712('0x2e')](handleError(_0x31100f,null));};exports['getAnswers']=function(_0x40c74e,_0x5d99b8,_0x5eb7d1){var _0x238f55={'raw':![],'where':{}};var _0x42d5cf={};var _0x1b19de={'count':0x0,'rows':[]};return db[_0x3712('0x44')]['findOne']({'where':{'id':_0x40c74e['params']['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x5d99b8,null))[_0x3712('0x24')](function(_0x316aee){if(_0x316aee){_0x42d5cf[_0x3712('0x49')]=_[_0x3712('0x4a')](db[_0x3712('0x70')]['rawAttributes']);_0x42d5cf[_0x3712('0x4b')]=_[_0x3712('0x4a')](_0x40c74e[_0x3712('0x4b')]);_0x42d5cf[_0x3712('0x4c')]=_['intersection'](_0x42d5cf[_0x3712('0x49')],_0x42d5cf[_0x3712('0x4b')]);_0x238f55[_0x3712('0x4d')]=_['intersection'](_0x42d5cf[_0x3712('0x49')],qs['fields'](_0x40c74e['query']['fields']));_0x238f55['attributes']=_0x238f55['attributes'][_0x3712('0x5e')]?_0x238f55['attributes']:_0x42d5cf[_0x3712('0x49')];if(!_0x40c74e[_0x3712('0x4b')][_0x3712('0x6b')](_0x3712('0x50'))){_0x238f55['limit']=qs[_0x3712('0x33')](_0x40c74e[_0x3712('0x4b')]['limit']);_0x238f55['offset']=qs[_0x3712('0x51')](_0x40c74e['query'][_0x3712('0x51')]);}_0x238f55[_0x3712('0x52')]=qs[_0x3712('0x53')](_0x40c74e[_0x3712('0x4b')][_0x3712('0x53')]);_0x238f55[_0x3712('0x57')]=qs['filters'](_[_0x3712('0x54')](_0x40c74e[_0x3712('0x4b')],_0x42d5cf['filters']));_0x238f55['where'][_0x3712('0x6c')]=_0x316aee['id'];if(_0x40c74e[_0x3712('0x4b')][_0x3712('0x55')]){_0x238f55[_0x3712('0x57')]=_[_0x3712('0x56')](_0x238f55[_0x3712('0x57')],{'$or':_['map'](_0x238f55[_0x3712('0x4d')],function(_0x566da0){var _0x1c4d59={};_0x1c4d59[_0x566da0]={'$like':'%'+_0x40c74e[_0x3712('0x4b')]['filter']+'%'};return _0x1c4d59;})});}_0x238f55=_[_0x3712('0x56')]({},_0x238f55,_0x40c74e[_0x3712('0x58')]);return db[_0x3712('0x70')][_0x3712('0x59')]({'where':_0x238f55[_0x3712('0x57')]})[_0x3712('0x24')](function(_0x181f23){_0x1b19de[_0x3712('0x59')]=_0x181f23;if(_0x40c74e['query'][_0x3712('0x5a')]){_0x238f55[_0x3712('0x5b')]=[{'all':!![]}];}return db['CannedAnswer'][_0x3712('0x6d')](_0x238f55);})['then'](function(_0x502069){_0x1b19de[_0x3712('0x5c')]=_0x502069;return _0x1b19de;});}})[_0x3712('0x24')](respondWithFilteredResult(_0x5d99b8,_0x238f55))[_0x3712('0x2e')](handleError(_0x5d99b8,null));};exports[_0x3712('0x71')]=function(_0x28eb82,_0x315a60,_0x3fa151){return db[_0x3712('0x44')][_0x3712('0x5f')]({'where':{'id':_0x28eb82[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x315a60,null))[_0x3712('0x24')](function(_0x209da9){if(_0x209da9){return _0x209da9[_0x3712('0x71')](_0x28eb82['query'][_0x3712('0x6e')]);}})[_0x3712('0x24')](respondWithStatusCode(_0x315a60,null))[_0x3712('0x2e')](handleError(_0x315a60,null));};exports[_0x3712('0x72')]=function(_0x1c9817,_0xbf3221,_0x2d16a1){_0x1c9817['body'][_0x3712('0x73')]=_0x1c9817['file'][_0x3712('0x74')];return db[_0x3712('0x44')]['find']({'where':{'id':_0x1c9817[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0xbf3221,null))['then'](saveUpdates(_0x1c9817[_0x3712('0x61')],null))['then'](respondWithResult(_0xbf3221,null))[_0x3712('0x2e')](handleError(_0xbf3221,null));};exports[_0x3712('0x75')]=function(_0x2837fc,_0x1a8499,_0x25bfda){_0x2837fc[_0x3712('0x61')]['agentAvatar']=_0x2837fc['file']['filename'];return db['ChatWebsite']['find']({'where':{'id':_0x2837fc[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x1a8499,null))[_0x3712('0x24')](saveUpdates(_0x2837fc[_0x3712('0x61')],null))[_0x3712('0x24')](respondWithResult(_0x1a8499,null))[_0x3712('0x2e')](handleError(_0x1a8499,null));};exports[_0x3712('0x76')]=function(_0x3e7ad2,_0x387dea,_0x4c8280){_0x3e7ad2['body'][_0x3712('0x77')]=_0x3e7ad2[_0x3712('0x78')]['filename'];return db[_0x3712('0x44')][_0x3712('0x5f')]({'where':{'id':_0x3e7ad2['params']['id']}})['then'](handleEntityNotFound(_0x387dea,null))['then'](saveUpdates(_0x3e7ad2['body'],null))[_0x3712('0x24')](respondWithResult(_0x387dea,null))['catch'](handleError(_0x387dea,null));};exports['addSystemAvatar']=function(_0x9e47fa,_0x448f1e,_0x329c77){_0x9e47fa['body'][_0x3712('0x79')]=_0x9e47fa['file'][_0x3712('0x74')];return db[_0x3712('0x44')]['find']({'where':{'id':_0x9e47fa[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x448f1e,null))['then'](saveUpdates(_0x9e47fa[_0x3712('0x61')],null))[_0x3712('0x24')](respondWithResult(_0x448f1e,null))[_0x3712('0x2e')](handleError(_0x448f1e,null));};exports[_0x3712('0x7a')]=function(_0xbd71c,_0x1d3a80,_0x2ffa84){var _0x2876c9=path['join'](config[_0x3712('0x7b')],_0x3712('0x7c'));var _0x1e694b={'where':{'id':_0xbd71c[_0x3712('0x66')]['id']},'attributes':['id',_0x3712('0x73')],'raw':!![]};var _0x1a0f09=![];return require(_0x3712('0x7d'))[_0x3712('0x7e')]()[_0x3712('0x24')](function(_0x3c0ead){if(_0x3c0ead){_0x1a0f09=_0x3c0ead[_0x3712('0x7f')];}})[_0x3712('0x24')](function(){return db[_0x3712('0x44')][_0x3712('0x5f')](_0x1e694b);})[_0x3712('0x24')](handleEntityNotFound(_0x1d3a80,null))[_0x3712('0x24')](function(_0x2309a0){if(_0x2309a0){if(!_[_0x3712('0x80')](_0x2309a0[_0x3712('0x73')])){if(fs[_0x3712('0x81')](path[_0x3712('0x82')](config[_0x3712('0x7b')],_0x3712('0x83'),_0x2309a0[_0x3712('0x73')]))&&_0x1a0f09){_0x2876c9=path[_0x3712('0x82')](config[_0x3712('0x7b')],_0x3712('0x83'),_0x2309a0['sitepic']);}}return _0x1d3a80['download'](_0x2876c9);}})[_0x3712('0x2e')](handleError(_0x1d3a80,null));};exports[_0x3712('0x84')]=function(_0xea193c,_0x1d6e7b,_0x3c4181){var _0x42bf94=path['join'](config['root'],'server/files/images/avatars/default_avatar.png');var _0x2bb9ae={'where':{'id':_0xea193c[_0x3712('0x66')]['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db[_0x3712('0x44')][_0x3712('0x5f')](_0x2bb9ae)[_0x3712('0x24')](handleEntityNotFound(_0x1d6e7b,null))[_0x3712('0x24')](function(_0x536742){if(_0x536742){if(!_[_0x3712('0x80')](_0x536742[_0x3712('0x85')])){if(fs[_0x3712('0x81')](path['join'](config[_0x3712('0x7b')],_0x3712('0x86'),_0x536742[_0x3712('0x85')]))){_0x42bf94=path[_0x3712('0x82')](config[_0x3712('0x7b')],_0x3712('0x86'),_0x536742[_0x3712('0x85')]);}}return _0x1d6e7b[_0x3712('0x87')](_0x42bf94);}})[_0x3712('0x2e')](handleError(_0x1d6e7b,null));};exports[_0x3712('0x88')]=function(_0x1f1996,_0x8e102a,_0x43e2f3){var _0x181a21=path[_0x3712('0x82')](config['root'],_0x3712('0x89'));var _0x4277bb={'where':{'id':_0x1f1996[_0x3712('0x66')]['id']},'attributes':['id',_0x3712('0x77'),_0x3712('0x8a')],'raw':!![]};return db[_0x3712('0x44')][_0x3712('0x5f')](_0x4277bb)[_0x3712('0x24')](handleEntityNotFound(_0x8e102a,null))[_0x3712('0x24')](function(_0xeffe16){if(_0xeffe16){if(!_[_0x3712('0x80')](_0xeffe16[_0x3712('0x77')])){if(fs['existsSync'](path[_0x3712('0x82')](config[_0x3712('0x7b')],'server/files/images/avatars/',_0xeffe16[_0x3712('0x77')]))&&_0xeffe16[_0x3712('0x8a')]){_0x181a21=path[_0x3712('0x82')](config['root'],_0x3712('0x86'),_0xeffe16[_0x3712('0x77')]);}}return _0x8e102a[_0x3712('0x87')](_0x181a21);}})[_0x3712('0x2e')](handleError(_0x8e102a,null));};exports[_0x3712('0x8b')]=function(_0x18452d,_0x5b1ffb,_0x508001){var _0x365cd1=path['join'](config[_0x3712('0x7b')],_0x3712('0x8c'));var _0x5f2f6e={'where':{'id':_0x18452d[_0x3712('0x66')]['id']},'attributes':['id',_0x3712('0x79')],'raw':!![]};return db[_0x3712('0x44')][_0x3712('0x5f')](_0x5f2f6e)[_0x3712('0x24')](handleEntityNotFound(_0x5b1ffb,null))[_0x3712('0x24')](function(_0x58b463){if(_0x58b463){if(!_[_0x3712('0x80')](_0x58b463[_0x3712('0x79')])){if(fs[_0x3712('0x81')](path[_0x3712('0x82')](config[_0x3712('0x7b')],'server/files/images/avatars/',_0x58b463[_0x3712('0x79')]))){_0x365cd1=path[_0x3712('0x82')](config[_0x3712('0x7b')],_0x3712('0x86'),_0x58b463[_0x3712('0x79')]);}}return _0x5b1ffb[_0x3712('0x87')](_0x365cd1);}})[_0x3712('0x2e')](handleError(_0x5b1ffb,null));};exports[_0x3712('0x8d')]=function(_0x2ed5e8,_0x964f80,_0x4352a1){var _0x438c48=require(_0x3712('0x8e'));var _0x53f091=new _0x438c48();var _0x1c92e9=_0x53f091[_0x3712('0x8f')](_0x2ed5e8[_0x3712('0x90')]['user-agent'])[_0x3712('0x91')]();var _0x111d5b={'body':_0x2ed5e8['body'],'channel':_0x3712('0x92')};var _0x357756=[];var _0x18cab5=[];var _0x24eb77={};var _0x205ebd=![];return db[_0x3712('0x93')]['describe']()['then'](function(_0x14ab34){if(!_0x14ab34){throw new db[(_0x3712('0x94'))][(_0x3712('0x95'))](_0x3712('0x96'));}_0x357756=_[_0x3712('0x97')](_[_0x3712('0x4a')](_0x14ab34),[_0x3712('0x98'),_0x3712('0x99')]);_0x18cab5=_['difference'](_[_0x3712('0x4a')](_0x14ab34),[_0x3712('0x98'),_0x3712('0x99'),_0x3712('0x9a'),_0x3712('0x9b')]);if(_0x2ed5e8['body']['id']){delete _0x2ed5e8[_0x3712('0x61')]['id'];}if(_['isNil'](_0x2ed5e8[_0x3712('0x61')][_0x3712('0x9c')])){throw new db[(_0x3712('0x94'))][(_0x3712('0x95'))](_0x3712('0x9d'));}if(_[_0x3712('0x80')](_0x2ed5e8[_0x3712('0x61')][_0x3712('0x61')])||_0x2ed5e8[_0x3712('0x61')]['body']===''){throw new db[(_0x3712('0x94'))][(_0x3712('0x95'))](_0x3712('0x9e'));}if(_[_0x3712('0x80')](_0x2ed5e8['body'][_0x3712('0x9f')])){throw new db[(_0x3712('0x94'))][(_0x3712('0x95'))](_0x3712('0xa0')+_0x18cab5);}if(!_['includes'](_0x18cab5,_0x2ed5e8[_0x3712('0x61')][_0x3712('0x9f')])){throw new db[(_0x3712('0x94'))]['ValidationError'](_0x3712('0xa1')+_0x18cab5);}_0x24eb77[_0x2ed5e8[_0x3712('0x61')][_0x3712('0x9f')]]=_0x2ed5e8[_0x3712('0x61')][_0x3712('0x9c')];})[_0x3712('0x24')](function(){return db['ChatWebsite'][_0x3712('0x5f')]({'where':{'id':_0x2ed5e8[_0x3712('0x66')]['id']},'include':[{'model':db['CmList'],'as':'List','include':[{'model':db[_0x3712('0x93')],'as':_0x3712('0xa2'),'where':_0x24eb77,'limit':0x1,'order':[['updatedAt','DESC']]}]},{'model':db[_0x3712('0xa3')],'as':'Applications'}]});})[_0x3712('0x24')](handleEntityNotFound(_0x964f80,null))['then'](function(_0x257791){if(_0x257791&&_0x257791[_0x3712('0xa4')]){_0x111d5b['account']=_0x257791;_0x111d5b[_0x3712('0xa5')]=_0x257791[_0x3712('0xa6')];_0x111d5b[_0x3712('0xa7')]=_0x257791[_0x3712('0xa4')];_0x111d5b['applications']=_[_0x3712('0xa8')](_0x111d5b[_0x3712('0xa5')],[_0x3712('0xa9')],[_0x3712('0xaa')]);if(_0x111d5b['account'][_0x3712('0xa6')]){delete _0x111d5b['account']['Applications'];}if(_0x111d5b[_0x3712('0xab')]['List']&&_0x111d5b['account'][_0x3712('0xa4')][_0x3712('0xa2')][_0x3712('0x5e')]){return _0x111d5b[_0x3712('0xab')][_0x3712('0xa4')]['Contacts'][0x0];}var _0x166618=_[_0x3712('0x1b')](_0x2ed5e8[_0x3712('0x61')],{'firstName':_0x2ed5e8[_0x3712('0x61')][_0x3712('0x9c')],'ListId':_0x257791[_0x3712('0x9b')]});_0x166618[_0x2ed5e8[_0x3712('0x61')][_0x3712('0x9f')]]=_0x2ed5e8[_0x3712('0x61')][_0x3712('0x9c')];return db[_0x3712('0x93')][_0x3712('0x60')](_0x166618,{'fields':_0x357756,'raw':!![]});}})[_0x3712('0x24')](handleEntityNotFound(_0x964f80,null))[_0x3712('0x24')](function(_0x5b1310){_0x111d5b[_0x3712('0xac')]=_0x5b1310;var _0x14db52=_0x2ed5e8[_0x3712('0x61')][_0x3712('0xad')];if(_0x2ed5e8[_0x3712('0x90')][_0x3712('0xae')]){_0x14db52=_0x2ed5e8[_0x3712('0x90')][_0x3712('0xae')];}else if(_0x2ed5e8[_0x3712('0x90')]['x-forwarded-for']){_0x14db52=_['first'](_0x2ed5e8[_0x3712('0x90')][_0x3712('0xaf')][_0x3712('0xb0')](','));}if(_0x5b1310){var _0xd8ab9e={'ContactId':_0x5b1310['id'],'ChatWebsiteId':_0x2ed5e8[_0x3712('0x66')]['id'],'from':(_0x5b1310[_0x3712('0xb1')]||'')+'\x20'+(_0x5b1310['lastName']||''),'customerIp':_0x14db52,'customerPort':_0x2ed5e8['headers'][_0x3712('0xb2')]?_0x2ed5e8[_0x3712('0x90')][_0x3712('0xb2')]:null,'referer':_0x2ed5e8[_0x3712('0x61')][_0x3712('0xb3')],'browserName':_0x1c92e9['browser'][_0x3712('0x3e')]&&_0x1c92e9[_0x3712('0xb4')][_0x3712('0xb5')]?util[_0x3712('0xb6')]('%s\x20%s',_0x1c92e9[_0x3712('0xb4')][_0x3712('0x3e')],_0x1c92e9['browser']['version']):'unknown','browserVersion':_0x1c92e9[_0x3712('0xb4')][_0x3712('0xb5')]||_0x3712('0xb7'),'osName':util[_0x3712('0xb6')](_0x3712('0xb8'),_0x1c92e9['os'][_0x3712('0x3e')],_0x1c92e9['os'][_0x3712('0xb5')]),'osVersion':_0x1c92e9['os'][_0x3712('0xb5')],'deviceModel':_0x1c92e9[_0x3712('0xb9')]['model']&&_0x1c92e9['device']['vendor']?util[_0x3712('0xb6')](_0x3712('0xba'),_0x1c92e9[_0x3712('0xb9')][_0x3712('0x49')],_0x1c92e9[_0x3712('0xb9')][_0x3712('0xbb')],_0x1c92e9['device'][_0x3712('0x47')]):null,'deviceVendor':_0x1c92e9[_0x3712('0xb9')][_0x3712('0xbb')],'deviceType':_0x1c92e9[_0x3712('0xb9')]['type'],'formData':JSON['stringify'](_0x2ed5e8[_0x3712('0x61')])};var _0x1ba247={'ChatWebsiteId':_0x2ed5e8['params']['id'],'closed':![]};if(_0x2ed5e8['body'][_0x3712('0xbc')]){_0x1ba247[_0x3712('0xbc')]=_0x2ed5e8[_0x3712('0x61')][_0x3712('0xbc')];return db[_0x3712('0xbd')][_0x3712('0x5f')]({'where':_0x1ba247})['then'](function(_0x403760){if(_0x403760){return[_0x403760,![]];}_0xd8ab9e[_0x3712('0xbc')]=_0x2ed5e8[_0x3712('0x61')]['threadId'];_0xd8ab9e[_0x3712('0xbe')]=_0x2ed5e8[_0x3712('0x61')][_0x3712('0xbe')];return db[_0x3712('0xbd')]['create'](_0xd8ab9e)[_0x3712('0x24')](function(_0xaf242e){return[_0xaf242e,!![]];});});}_0x1ba247[_0x3712('0xbf')]=_0x5b1310['id'];if(_0x2ed5e8['body'][_0x3712('0xc0')]&&_0x2ed5e8['body']['interaction']['id']){_0x1ba247['id']=_0x2ed5e8[_0x3712('0x61')][_0x3712('0xc0')]['id'];return db[_0x3712('0xbd')]['find']({'where':_0x1ba247})['then'](function(_0x450f3d){if(_0x450f3d){return[_0x450f3d,![]];}return db[_0x3712('0xbd')]['create'](_0xd8ab9e)['then'](function(_0x145281){return[_0x145281,!![]];});});}return db['ChatInteraction'][_0x3712('0x60')](_0xd8ab9e)[_0x3712('0x24')](function(_0x10a9ef){return[_0x10a9ef,!![]];});}})[_0x3712('0xc1')](function(_0x2cc8ca,_0x4c33ff){if(_0x2cc8ca){_0x205ebd=_0x4c33ff;if(!_0x4c33ff){var _0x568f6e={'from':(_0x111d5b[_0x3712('0xac')]['firstName']||'')+'\x20'+(_0x111d5b[_0x3712('0xac')][_0x3712('0xc2')]||'')};if(_0x2ed5e8['body'][_0x3712('0xbc')]&&_0x2ed5e8[_0x3712('0x61')][_0x3712('0xc3')]&&_0x2ed5e8['body'][_0x3712('0xbc')]!=_0x2ed5e8[_0x3712('0x61')]['messageId']){_0x568f6e['threadId']=_0x2ed5e8[_0x3712('0x61')][_0x3712('0xc3')];}return _0x2cc8ca[_0x3712('0xc4')](_0x568f6e);}else{return _0x2cc8ca;}}})[_0x3712('0x24')](function(_0x3f1665){_0x111d5b[_0x3712('0xc0')]=_0x3f1665[_0x3712('0x3a')]({'plain':!![]});_0x111d5b[_0x3712('0xc0')][_0x3712('0xc5')]=_0x205ebd;if(_0x111d5b[_0x3712('0xc0')][_0x3712('0xc5')]){if(_0x111d5b['account'][_0x3712('0xc6')]){_0x111d5b[_0x3712('0xa5')][_0x3712('0xc7')]({'id':0x0,'priority':_0x111d5b[_0x3712('0xa5')][_0x3712('0x5e')]+0x1,'app':_0x3712('0xc8'),'appdata':'unmanaged','interval':_0x3712('0xc9')});}}return db[_0x3712('0xca')][_0x3712('0x60')]({'body':_0x2ed5e8['body']['body'],'ChatWebsiteId':_0x2ed5e8[_0x3712('0x66')]['id'],'ChatInteractionId':_0x3f1665['id'],'direction':'in','ContactId':_0x111d5b[_0x3712('0xac')]['id'],'AttachmentId':_0x2ed5e8[_0x3712('0x61')]['AttachmentId']});})['then'](function(_0x24d1ab){_0x111d5b[_0x3712('0x2c')]=_0x24d1ab;if(_0x111d5b['interaction'][_0x3712('0xcb')]){return db[_0x3712('0xcc')]['find']({'attributes':['id','name'],'where':{'id':_0x111d5b[_0x3712('0xc0')][_0x3712('0xcb')]}})[_0x3712('0x24')](function(_0x25a953){if(_0x25a953){_0x111d5b['applications'][_0x3712('0xcd')]({'id':0x0,'priority':0x0,'app':_0x3712('0xce'),'appdata':_0x25a953['name']+','+(_0x111d5b[_0x3712('0xab')][_0x3712('0xcf')]||0xa),'interval':_0x3712('0xc9')});_0x111d5b[_0x3712('0xd0')]=!![];}return respondWithRpcPromise(_0x3712('0xd1'),_0x3712('0xd2'),_0x111d5b);});}return respondWithRpcPromise('Start','startRouting',_0x111d5b);})[_0x3712('0x24')](function(_0x13d96d){respondWithRpcPromise(_0x3712('0xd3'),'EventManager',{'event':'notify','message':_0x13d96d},client9002);return _0x13d96d;})[_0x3712('0x24')](respondWithResult(_0x964f80,null))[_0x3712('0x2e')](handleError(_0x964f80,null));};exports['offline']=function(_0x153bbc,_0x3677f8,_0x473dd1){var _0x4a24da,_0x3cf25c,_0x218ea1;var _0x32440d=[];var _0x290ca8=[];var _0x7f0d64={};return db[_0x3712('0x93')]['describe']()[_0x3712('0x24')](function(_0x111e0b){if(!_0x111e0b){throw new db[(_0x3712('0x94'))][(_0x3712('0x95'))]('no\x20available\x20attributes');}_0x290ca8=_['difference'](_['keys'](_0x111e0b),[_0x3712('0x98'),'updatedAt']);_0x32440d=_[_0x3712('0x97')](_[_0x3712('0x4a')](_0x111e0b),[_0x3712('0x98'),_0x3712('0x99'),_0x3712('0x9a'),_0x3712('0x9b')]);if(_0x153bbc[_0x3712('0x61')]['id']){delete _0x153bbc['body']['id'];}if(_[_0x3712('0x80')](_0x153bbc[_0x3712('0x61')][_0x3712('0x9c')])){throw _0x3677f8[_0x3712('0x30')](0x1f4)[_0x3712('0x3f')](new db['Sequelize'][(_0x3712('0x95'))](_0x3712('0x9d')));}if(_['isNil'](_0x153bbc[_0x3712('0x61')][_0x3712('0x61')])||_0x153bbc[_0x3712('0x61')]['body']===''){throw _0x3677f8[_0x3712('0x30')](0x1f4)[_0x3712('0x3f')](new db[(_0x3712('0x94'))]['ValidationError'](_0x3712('0x9e')));}if(_[_0x3712('0x80')](_0x153bbc[_0x3712('0x61')][_0x3712('0xd4')])){throw _0x3677f8['status'](0x1f4)[_0x3712('0x3f')](new db['Sequelize'][(_0x3712('0x95'))](_0x3712('0xd5')+_0x32440d));}if(!_[_0x3712('0xd6')](_0x32440d,_0x153bbc['body']['mapKeyOffline'])){throw _0x3677f8[_0x3712('0x30')](0x1f4)[_0x3712('0x3f')](new db[(_0x3712('0x94'))][(_0x3712('0x95'))](_0x3712('0xd7')+_0x32440d));}_0x7f0d64[_0x153bbc[_0x3712('0x61')][_0x3712('0xd4')]]=_0x153bbc[_0x3712('0x61')][_0x3712('0x9c')];})[_0x3712('0x24')](function(){return db['ChatWebsite']['find']({'where':{'id':_0x153bbc['params']['id']},'include':[{'model':db[_0x3712('0xd8')],'as':_0x3712('0xa4')}]});})[_0x3712('0x24')](handleEntityNotFound(_0x3677f8,null))[_0x3712('0x24')](function(_0x200796){if(_0x200796&&_0x200796['List']){_0x3cf25c=_0x200796;var _0x5f9a59=_[_0x3712('0x1b')](_0x153bbc[_0x3712('0x61')],{'firstName':_0x153bbc['body'][_0x3712('0x9c')],'phone':_0x153bbc['body'][_0x3712('0x9c')],'ListId':_0x200796[_0x3712('0x9b')]});_0x5f9a59[_0x153bbc[_0x3712('0x61')][_0x3712('0xd4')]]=_0x153bbc[_0x3712('0x61')][_0x3712('0x9c')];return db['CmContact']['findOrCreate']({'where':_0x7f0d64,'defaults':_0x5f9a59});}})[_0x3712('0xc1')](function(_0x515a8c){if(_0x515a8c){_0x218ea1=_0x515a8c;var _0x258fe8=fs[_0x3712('0xd9')](path['join'](config[_0x3712('0x7b')],_0x3712('0xda')),_0x3712('0xdb'));var _0x48d2b8=ejs[_0x3712('0xdc')](_0x258fe8,{'body':_[_0x3712('0xdd')](_0x153bbc[_0x3712('0x61')][_0x3712('0x61')]),'bodyTitle':_0x3cf25c[_0x3712('0xde')]});return db[_0x3712('0xdf')]['create']({'body':_0x48d2b8,'ContactId':_0x515a8c['id'],'ChatWebsiteId':_0x3cf25c['id']});}})[_0x3712('0x24')](function(_0x1a14d7){if(_0x1a14d7){_0x4a24da=_0x1a14d7;return db[_0x3712('0xe0')][_0x3712('0x6a')]({'where':{'service':!![]},'include':[{'model':db[_0x3712('0xe1')],'as':'Smtp','raw':!![]}]});}})[_0x3712('0x24')](function(_0x36a617){if(_0x36a617&&_0x36a617[_0x3712('0xe2')]&&_0x3cf25c[_0x3712('0xe3')]){var _0x5015a0={'tls':{'rejectUnauthorized':![]}};if(_0x36a617['Smtp']['service']){_0x5015a0[_0x3712('0xe4')]=_0x36a617['Smtp'][_0x3712('0xe4')];}else{_0x5015a0[_0x3712('0xe5')]=_0x36a617['Smtp'][_0x3712('0xe5')];_0x5015a0[_0x3712('0xe6')]=_0x36a617[_0x3712('0xe2')][_0x3712('0xe6')];_0x5015a0[_0x3712('0xe7')]=_0x36a617[_0x3712('0xe2')][_0x3712('0xe7')];}if(_0x36a617['Smtp'][_0x3712('0xe8')]){_0x5015a0[_0x3712('0xe9')]={'user':_0x36a617['Smtp'][_0x3712('0x62')],'pass':_0x36a617[_0x3712('0xe2')][_0x3712('0xea')]};}return respondWithRpcPromise(_0x3712('0xeb'),_0x3712('0xec'),{'account':_0x5015a0,'message':{'from':util[_0x3712('0xb6')](_0x3712('0xed'),_0x36a617[_0x3712('0x3e')],_0x36a617[_0x3712('0xee')]||_0x36a617['Smtp'][_0x3712('0x62')]),'to':_0x3cf25c['forwardOfflineAddress'],'subject':_0x3cf25c[_0x3712('0xef')],'text':_0x4a24da[_0x3712('0x61')]}},client9003)['then'](function(){return _0x4a24da;})[_0x3712('0x2e')](function(_0x986661){console[_0x3712('0x2a')](_0x986661);});}})['then'](function(){if(_0x4a24da){return _0x4a24da;}})['then'](respondWithResult(_0x3677f8,null))[_0x3712('0x2e')](handleError(_0x3677f8,null));};exports['addInteraction']=function(_0x19f5f6,_0x50ad79,_0x2678a3){return db[_0x3712('0xbd')]['find']({'where':{'id':_0x19f5f6[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x50ad79,null))[_0x3712('0x24')](function(_0x144444){if(_0x144444){return _0x144444['addInteraction'](_0x19f5f6[_0x3712('0x61')][_0x3712('0x6e')],_[_0x3712('0xf0')](_0x19f5f6['body'],[_0x3712('0x6e'),'id'])||{});}})[_0x3712('0x24')](respondWithResult(_0x50ad79,null))[_0x3712('0x2e')](handleError(_0x50ad79,null));};exports[_0x3712('0xf1')]=function(_0x89f24b,_0x5b4715,_0x44764d){var _0x3413e4={'raw':![],'where':{}};var _0x477a5d={};var _0x23b263={'count':0x0,'rows':[]};return db[_0x3712('0x44')]['findOne']({'where':{'id':_0x89f24b[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x5b4715,null))['then'](function(_0x25aa1f){if(_0x25aa1f){_0x477a5d[_0x3712('0x49')]=_[_0x3712('0x4a')](db['ChatInteraction'][_0x3712('0x45')]);_0x477a5d['query']=_[_0x3712('0x4a')](_0x89f24b[_0x3712('0x4b')]);_0x477a5d[_0x3712('0x4c')]=_[_0x3712('0x4e')](_0x477a5d[_0x3712('0x49')],_0x477a5d['query']);_0x3413e4[_0x3712('0x4d')]=_[_0x3712('0x4e')](_0x477a5d[_0x3712('0x49')],qs[_0x3712('0x4f')](_0x89f24b['query'][_0x3712('0x4f')]));_0x3413e4[_0x3712('0x4d')]=_0x3413e4[_0x3712('0x4d')][_0x3712('0x5e')]?_0x3413e4['attributes']:_0x477a5d[_0x3712('0x49')];if(!_0x89f24b[_0x3712('0x4b')][_0x3712('0x6b')](_0x3712('0x50'))){_0x3413e4[_0x3712('0x33')]=qs[_0x3712('0x33')](_0x89f24b[_0x3712('0x4b')][_0x3712('0x33')]);_0x3413e4[_0x3712('0x51')]=qs[_0x3712('0x51')](_0x89f24b[_0x3712('0x4b')][_0x3712('0x51')]);}_0x3413e4[_0x3712('0x52')]=qs[_0x3712('0x53')](_0x89f24b['query'][_0x3712('0x53')]);_0x3413e4[_0x3712('0x57')]=qs[_0x3712('0x4c')](_['pick'](_0x89f24b[_0x3712('0x4b')],_0x477a5d[_0x3712('0x4c')]));_0x3413e4[_0x3712('0x57')][_0x3712('0x6c')]=_0x25aa1f['id'];if(_0x89f24b['query']['filter']){_0x3413e4['where']=_['merge'](_0x3413e4[_0x3712('0x57')],{'$or':_[_0x3712('0x43')](_0x3413e4[_0x3712('0x4d')],function(_0xc9c1ff){var _0x2369b2={};_0x2369b2[_0xc9c1ff]={'$like':'%'+_0x89f24b[_0x3712('0x4b')][_0x3712('0x55')]+'%'};return _0x2369b2;})});}_0x3413e4=_[_0x3712('0x56')]({},_0x3413e4,_0x89f24b[_0x3712('0x58')]);return db[_0x3712('0xbd')]['count']({'where':_0x3413e4[_0x3712('0x57')]})[_0x3712('0x24')](function(_0x232ab2){_0x23b263[_0x3712('0x59')]=_0x232ab2;if(_0x89f24b[_0x3712('0x4b')][_0x3712('0x5a')]){_0x3413e4[_0x3712('0x5b')]=[{'model':db['CmContact'],'as':_0x3712('0xf2'),'required':![]},{'model':db[_0x3712('0xcc')],'as':_0x3712('0xf3'),'attributes':[_0x3712('0x3e'),_0x3712('0xf4'),_0x3712('0xf5')],'required':![]},{'model':db[_0x3712('0xf6')],'as':_0x3712('0xf7'),'attributes':['id',_0x3712('0x3e'),'color'],'where':_0x89f24b['query'][_0x3712('0xf8')]?{'id':_0x89f24b['query']['tag']}:undefined,'required':_0x89f24b['query']['tag']?!![]:![]}];}return db[_0x3712('0xbd')][_0x3712('0x6d')](_0x3413e4);})[_0x3712('0x24')](function(_0x507e9f){_0x23b263[_0x3712('0x5c')]=_0x507e9f;return _0x23b263;});}})[_0x3712('0x24')](respondWithFilteredResult(_0x5b4715,_0x3413e4))[_0x3712('0x2e')](handleError(_0x5b4715,null));};function iftimePromise(_0x3f89d0,_0x43e43a){return respondWithRpcPromise('Command',_0x3712('0xf9'),{'command':_0x43e43a[_0x3712('0xfa')]?util[_0x3712('0xb6')](_0x3712('0xfb'),_0x3f89d0[_0x3712('0xfc')],_0x43e43a['timezone']):util[_0x3712('0xb6')](_0x3712('0xfd'),_0x3f89d0[_0x3712('0xfc')])},client9002)['then'](function(_0x12cf5f){var _0x1e51f9=_0x12cf5f&&_0x12cf5f[_0x3712('0xfe')]('true')>=0x0?!![]:![];logger[_0x3712('0x25')](_0x3712('0xff'),_0x43e43a['id'],_0x3f89d0['id'],_0x3f89d0[_0x3712('0xfc')],_0x1e51f9?_0x3712('0x100'):_0x3712('0x101'),_0x43e43a['timezone']?_0x43e43a[_0x3712('0xfa')]:_0x3712('0x102'));return _0x1e51f9;})['catch'](function(_0x22c993){logger[_0x3712('0x2a')](_0x3712('0xff'),_0x43e43a['id'],_0x3f89d0['id'],_0x3f89d0[_0x3712('0xfc')],util[_0x3712('0x103')](_0x22c993,{'showHidden':![],'depth':null}),_0x43e43a[_0x3712('0xfa')]?_0x43e43a[_0x3712('0xfa')]:'No\x20timezone');return![];});}exports[_0x3712('0xf9')]=function(_0x3ac6b4,_0x578864,_0x1232b4){var _0x5159f4=0x0;var _0xe7beee=0x0;var _0x2626d2=![];var _0x55ba1f;var _0x50022e;return db['ChatWebsite']['find']({'where':{'id':_0x3ac6b4['params']['id']},'include':[{'model':db[_0x3712('0x104')],'as':_0x3712('0x104'),'include':[{'model':db[_0x3712('0x104')],'as':_0x3712('0x105'),'attributes':['id',_0x3712('0xfc')],'raw':!![]}]}]})[_0x3712('0x24')](handleEntityNotFound(_0x578864,null))['then'](function(_0x4d645c){if(_0x4d645c){_0x55ba1f=_0x4d645c;return _0x4d645c[_0x3712('0x106')]({'raw':!![]});}})[_0x3712('0x24')](function(_0x2cea2a){if(_0x55ba1f){if(_0x2cea2a){_0x50022e=_0x2cea2a;}}return require(_0x3712('0x7d'))[_0x3712('0x7e')]();})[_0x3712('0x24')](function(_0x2300ef){if(_0x2300ef){_0xe7beee=_0x2300ef[_0x3712('0x107')];_0x2626d2=_0x2300ef[_0x3712('0x7f')];}})[_0x3712('0x24')](function(){return db['ChatInteraction']['count']({'where':{'closed':![]}});})[_0x3712('0x24')](function(_0x1cc60b){_0x5159f4=_0x1cc60b;if(_0xe7beee&&_0x1cc60b>_0xe7beee){return db[_0x3712('0x108')][_0x3712('0x6a')]({'where':{'id':0x1}})[_0x3712('0x24')](function(_0x4f17f2){if(_0x4f17f2){_0x4f17f2[_0x3712('0x109')](_0x3712('0x10a'));}});}})[_0x3712('0x24')](function(){if(_0x55ba1f['Interval']&&_0x55ba1f[_0x3712('0x104')]['Intervals']){var _0x4d21f4=[];for(var _0x1213a9=0x0;_0x1213a9<_0x55ba1f[_0x3712('0x104')][_0x3712('0x105')][_0x3712('0x5e')];_0x1213a9++){var _0xbb9a71=_0x55ba1f[_0x3712('0x104')][_0x3712('0x105')][_0x1213a9][_0x3712('0x3a')]({'plain':!![]});_0x4d21f4[_0x3712('0xc7')](iftimePromise(_0xbb9a71,_0x55ba1f));}return BPromise[_0x3712('0x10b')](_0x4d21f4)['then'](function(_0x5cbfc4){return _[_0x3712('0x10c')](_0x5cbfc4);});}else{return!![];}})[_0x3712('0x24')](function(_0x3a068c){var _0x314c02=fs['readFileSync'](path[_0x3712('0x82')](config[_0x3712('0x7b')],_0x3712('0x10d')),_0x3712('0xdb'));var _0x5be4c7={'remote':_0x55ba1f[_0x3712('0x10e')],'query':querystring[_0x3712('0x29')](_[_0x3712('0x56')](_0x55ba1f[_0x3712('0x3a')]({'plain':!![]}),{'customerIp':_0x3ac6b4[_0x3712('0x90')][_0x3712('0xaf')]||_0x3ac6b4[_0x3712('0x90')][_0x3712('0x10f')]||_0x3ac6b4[_0x3712('0x110')][_0x3712('0x111')]||_0x3ac6b4['ip'],'referer':_0x3ac6b4['headers'][_0x3712('0xb3')],'openedInteractions':_0x5159f4,'maxInteractions':_0xe7beee,'virtual':_0x2626d2['virtual'],'online':_0x3a068c,'custom':_0x2626d2}))[_0x3712('0x112')](/'/g,'\x5c\x27')};_0x578864[_0x3712('0x3f')](ejs[_0x3712('0xdc')](Mustache[_0x3712('0xdc')](_0x314c02,_0x5be4c7),{'proactiveActions':_0x50022e,'alignment':_0x55ba1f[_0x3712('0x113')],'verticalAlignment':_0x55ba1f[_0x3712('0x114')],'div_color':_0x55ba1f[_0x3712('0x115')],'text_color':_0x55ba1f[_0x3712('0x116')]}));})[_0x3712('0x2e')](handleError(_0x578864,null));};exports['addApplications']=function(_0x36bcf3,_0x4c76ad,_0x43cc9b){return db[_0x3712('0x44')][_0x3712('0x6a')]({'where':{'id':_0x36bcf3['params']['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x4c76ad,null))[_0x3712('0x24')](function(_0x11695a){if(_0x11695a){return db[_0x3712('0x117')][_0x3712('0x118')](function(_0x4906ec){return db[_0x3712('0xa3')][_0x3712('0x39')]({'where':{'ChatWebsiteId':_0x36bcf3[_0x3712('0x66')]['id']},'transaction':_0x4906ec})['then'](function(_0x5a8ed0){var _0x157148=_[_0x3712('0x43')](_0x36bcf3[_0x3712('0x61')],function(_0x1ffd77){_0x1ffd77[_0x3712('0x6c')]=_0x36bcf3[_0x3712('0x66')]['id'];return _0x1ffd77;});return db['ChatApplication']['bulkCreate'](_0x157148,{'transaction':_0x4906ec});});})[_0x3712('0x24')](function(){return db[_0x3712('0xa3')][_0x3712('0x119')]({'where':{'ChatWebsiteId':_0x36bcf3[_0x3712('0x66')]['id']},'order':_0x3712('0xa9')});});}})['then'](respondWithResult(_0x4c76ad,null))[_0x3712('0x2e')](handleError(_0x4c76ad,null));};exports[_0x3712('0x11a')]=function(_0x521b4d,_0xed0d2d,_0x30dafb){var _0x3bce67={};var _0x194c3a={};var _0xc69cd9;var _0x338f51;return db[_0x3712('0x44')]['findOne']({'where':{'id':_0x521b4d[_0x3712('0x66')]['id']}})['then'](handleEntityNotFound(_0xed0d2d,null))[_0x3712('0x24')](function(_0x54421b){if(_0x54421b){_0xc69cd9=_0x54421b;_0x194c3a['model']=_[_0x3712('0x4a')](db[_0x3712('0xa3')][_0x3712('0x45')]);_0x194c3a[_0x3712('0x4b')]=_[_0x3712('0x4a')](_0x521b4d[_0x3712('0x4b')]);_0x194c3a['filters']=_[_0x3712('0x4e')](_0x194c3a[_0x3712('0x49')],_0x194c3a[_0x3712('0x4b')]);_0x3bce67[_0x3712('0x4d')]=_[_0x3712('0x4e')](_0x194c3a[_0x3712('0x49')],qs[_0x3712('0x4f')](_0x521b4d[_0x3712('0x4b')][_0x3712('0x4f')]));_0x3bce67[_0x3712('0x4d')]=_0x3bce67['attributes'][_0x3712('0x5e')]?_0x3bce67['attributes']:_0x194c3a[_0x3712('0x49')];_0x3bce67[_0x3712('0x52')]=qs[_0x3712('0x53')](_0x521b4d[_0x3712('0x4b')]['sort']);_0x3bce67[_0x3712('0x57')]=qs[_0x3712('0x4c')](_[_0x3712('0x54')](_0x521b4d[_0x3712('0x4b')],_0x194c3a['filters']));if(_0x521b4d[_0x3712('0x4b')]['filter']){_0x3bce67[_0x3712('0x57')]=_['merge'](_0x3bce67[_0x3712('0x57')],{'$or':_[_0x3712('0x43')](_0x3bce67['attributes'],function(_0x269c21){var _0x40d58c={};_0x40d58c[_0x269c21]={'$like':'%'+_0x521b4d['query']['filter']+'%'};return _0x40d58c;})});}_0x3bce67=_[_0x3712('0x56')]({},_0x3bce67,_0x521b4d[_0x3712('0x58')]);return _0xc69cd9[_0x3712('0x11a')](_0x3bce67);}})[_0x3712('0x24')](function(_0x42acd1){if(_0x42acd1){_0x338f51=_0x42acd1[_0x3712('0x5e')];if(!_0x521b4d[_0x3712('0x4b')][_0x3712('0x6b')](_0x3712('0x50'))){_0x3bce67[_0x3712('0x33')]=qs[_0x3712('0x33')](_0x521b4d['query']['limit']);_0x3bce67['offset']=qs['offset'](_0x521b4d[_0x3712('0x4b')]['offset']);}return _0xc69cd9['getApplications'](_0x3bce67);}})[_0x3712('0x24')](function(_0x2aae62){if(_0x2aae62){return _0x2aae62?{'count':_0x338f51,'rows':_0x2aae62}:null;}})[_0x3712('0x24')](respondWithResult(_0xed0d2d,null))['catch'](handleError(_0xed0d2d,null));};exports[_0x3712('0x11b')]=function(_0x54c411,_0x5c2577,_0x1c0f2f){return db['chatProactiveAction']['find']({'where':{'id':_0x54c411['params']['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x5c2577,null))[_0x3712('0x24')](function(_0x3a4e5f){if(_0x3a4e5f){return _0x3a4e5f[_0x3712('0x11b')](_0x54c411[_0x3712('0x61')][_0x3712('0x6e')],_[_0x3712('0xf0')](_0x54c411['body'],[_0x3712('0x6e'),'id'])||{});}})[_0x3712('0x24')](respondWithResult(_0x5c2577,null))['catch'](handleError(_0x5c2577,null));};exports[_0x3712('0x106')]=function(_0x33fdcb,_0x4937ab,_0x5be102){var _0x5cc955={};var _0x4019e0={};var _0x5f476f;var _0x37764b;return db[_0x3712('0x44')][_0x3712('0x6a')]({'where':{'id':_0x33fdcb['params']['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x4937ab,null))[_0x3712('0x24')](function(_0x1fef63){if(_0x1fef63){_0x5f476f=_0x1fef63;_0x4019e0[_0x3712('0x49')]=_[_0x3712('0x4a')](db['ChatProactiveAction'][_0x3712('0x45')]);_0x4019e0['query']=_['keys'](_0x33fdcb[_0x3712('0x4b')]);_0x4019e0[_0x3712('0x4c')]=_[_0x3712('0x4e')](_0x4019e0[_0x3712('0x49')],_0x4019e0[_0x3712('0x4b')]);_0x5cc955['attributes']=_['intersection'](_0x4019e0[_0x3712('0x49')],qs['fields'](_0x33fdcb[_0x3712('0x4b')][_0x3712('0x4f')]));_0x5cc955[_0x3712('0x4d')]=_0x5cc955['attributes'][_0x3712('0x5e')]?_0x5cc955[_0x3712('0x4d')]:_0x4019e0[_0x3712('0x49')];_0x5cc955[_0x3712('0x52')]=qs[_0x3712('0x53')](_0x33fdcb[_0x3712('0x4b')][_0x3712('0x53')]);_0x5cc955[_0x3712('0x57')]=qs[_0x3712('0x4c')](_[_0x3712('0x54')](_0x33fdcb['query'],_0x4019e0[_0x3712('0x4c')]));if(_0x33fdcb['query'][_0x3712('0x55')]){_0x5cc955['where']=_[_0x3712('0x56')](_0x5cc955[_0x3712('0x57')],{'$or':_[_0x3712('0x43')](_0x5cc955['attributes'],function(_0x8c6e26){var _0x2f6ed7={};_0x2f6ed7[_0x8c6e26]={'$like':'%'+_0x33fdcb[_0x3712('0x4b')][_0x3712('0x55')]+'%'};return _0x2f6ed7;})});}_0x5cc955=_['merge']({},_0x5cc955,_0x33fdcb[_0x3712('0x58')]);return _0x5f476f['getProactiveActions'](_0x5cc955);}})[_0x3712('0x24')](function(_0x56cac7){if(_0x56cac7){_0x37764b=_0x56cac7['length'];if(!_0x33fdcb[_0x3712('0x4b')][_0x3712('0x6b')](_0x3712('0x50'))){_0x5cc955['limit']=qs[_0x3712('0x33')](_0x33fdcb[_0x3712('0x4b')]['limit']);_0x5cc955[_0x3712('0x51')]=qs[_0x3712('0x51')](_0x33fdcb[_0x3712('0x4b')]['offset']);}return _0x5f476f[_0x3712('0x106')](_0x5cc955);}})[_0x3712('0x24')](function(_0x461962){if(_0x461962){return _0x461962?{'count':_0x37764b,'rows':_0x461962}:null;}})[_0x3712('0x24')](respondWithResult(_0x4937ab,null))[_0x3712('0x2e')](handleError(_0x4937ab,null));};exports['getFields']=function(_0x3f7a1e,_0x58bb82,_0x3a9991){var _0x464029=_0x3f7a1e['query']['online']===_0x3712('0x11c')?_0x3712('0x11d'):_0x3712('0x11e');return db[_0x3712('0x44')][_0x3712('0x5f')]({'attributes':['id',_0x464029],'where':{'id':_0x3f7a1e[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x58bb82,null))[_0x3712('0x24')](function(_0x5964ff){if(_0x5964ff){var _0x132185=_0x5964ff[_0x464029];var _0x488091=_0x132185&&_0x132185['items']?_0x132185[_0x3712('0x11f')]:[];_0x58bb82[_0x3712('0x3f')]({'fromKey':_['isNil'](_0x132185['fromKey'])?undefined:_0x132185[_0x3712('0x120')],'count':_0x488091[_0x3712('0x5e')],'rows':_0x488091});}})[_0x3712('0x2e')](handleError(_0x58bb82,null));};exports[_0x3712('0x121')]=function(_0x195a30,_0x3d559c,_0x136141){var _0x5eaab6={'raw':![],'where':{}};var _0x3e77cc={};var _0x4247c2={'count':0x0,'rows':[]};return db[_0x3712('0x44')][_0x3712('0x6a')]({'where':{'id':_0x195a30[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x3d559c,null))[_0x3712('0x24')](function(_0x2f09be){if(_0x2f09be){_0x3e77cc['model']=_['keys'](db[_0x3712('0xdf')][_0x3712('0x45')]);_0x3e77cc[_0x3712('0x4b')]=_[_0x3712('0x4a')](_0x195a30[_0x3712('0x4b')]);_0x3e77cc['filters']=_['intersection'](_0x3e77cc[_0x3712('0x49')],_0x3e77cc[_0x3712('0x4b')]);_0x5eaab6[_0x3712('0x4d')]=_[_0x3712('0x4e')](_0x3e77cc['model'],qs['fields'](_0x195a30[_0x3712('0x4b')][_0x3712('0x4f')]));_0x5eaab6['attributes']=_0x5eaab6[_0x3712('0x4d')]['length']?_0x5eaab6['attributes']:_0x3e77cc['model'];if(!_0x195a30['query'][_0x3712('0x6b')]('nolimit')){_0x5eaab6[_0x3712('0x33')]=qs[_0x3712('0x33')](_0x195a30['query'][_0x3712('0x33')]);_0x5eaab6[_0x3712('0x51')]=qs[_0x3712('0x51')](_0x195a30[_0x3712('0x4b')][_0x3712('0x51')]);}_0x5eaab6['order']=qs[_0x3712('0x53')](_0x195a30[_0x3712('0x4b')][_0x3712('0x53')]);_0x5eaab6[_0x3712('0x57')]=qs['filters'](_['pick'](_0x195a30[_0x3712('0x4b')],_0x3e77cc[_0x3712('0x4c')]));_0x5eaab6[_0x3712('0x57')][_0x3712('0x6c')]=_0x2f09be['id'];if(_0x195a30['query'][_0x3712('0x55')]){_0x5eaab6[_0x3712('0x57')]=_[_0x3712('0x56')](_0x5eaab6['where'],{'$or':_[_0x3712('0x43')](_0x5eaab6[_0x3712('0x4d')],function(_0x3b4b82){var _0x4b286a={};_0x4b286a[_0x3b4b82]={'$like':'%'+_0x195a30[_0x3712('0x4b')][_0x3712('0x55')]+'%'};return _0x4b286a;})});}_0x5eaab6=_['merge']({},_0x5eaab6,_0x195a30[_0x3712('0x58')]);return db[_0x3712('0xdf')][_0x3712('0x59')]({'where':_0x5eaab6[_0x3712('0x57')]})['then'](function(_0x5f02a0){_0x4247c2[_0x3712('0x59')]=_0x5f02a0;if(_0x195a30[_0x3712('0x4b')][_0x3712('0x5a')]){_0x5eaab6[_0x3712('0x5b')]=[{'all':!![]}];}else{_0x5eaab6[_0x3712('0x5b')]=[{'model':db[_0x3712('0x93')],'as':_0x3712('0xf2'),'required':![]}];}return db[_0x3712('0xdf')][_0x3712('0x6d')](_0x5eaab6);})['then'](function(_0x3ba0b1){_0x4247c2[_0x3712('0x5c')]=_0x3ba0b1;return _0x4247c2;});}})[_0x3712('0x24')](respondWithFilteredResult(_0x3d559c,_0x5eaab6))[_0x3712('0x2e')](handleError(_0x3d559c,null));};exports[_0x3712('0x122')]=function(_0x515aa3,_0x5124ad,_0x2bcd3e){return db[_0x3712('0x44')][_0x3712('0x5f')]({'where':{'id':_0x515aa3[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x5124ad,null))['then'](function(_0x1e07f7){if(_0x1e07f7){return _0x1e07f7[_0x3712('0x122')](_0x515aa3['body']['ids'],_[_0x3712('0xf0')](_0x515aa3[_0x3712('0x61')],[_0x3712('0x6e'),'id'])||{})[_0x3712('0xc1')](function(_0x104324){for(var _0x467c52=0x0;_0x467c52<_0x515aa3[_0x3712('0x61')]['ids'][_0x3712('0x5e')];_0x467c52+=0x1){socket[_0x3712('0x123')](_0x3712('0x124'),{'UserId':_0x515aa3[_0x3712('0x61')][_0x3712('0x6e')][_0x467c52],'ChatWebsiteId':_0x515aa3[_0x3712('0x66')]['id']});}return _0x104324;});}})[_0x3712('0x24')](respondWithResult(_0x5124ad,null))['catch'](handleError(_0x5124ad,null));};exports[_0x3712('0x125')]=function(_0x381353,_0x3a8fd7,_0x55f7d6){return db['ChatWebsite'][_0x3712('0x5f')]({'where':{'id':_0x381353[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x3a8fd7,null))[_0x3712('0x24')](function(_0x5e898f){if(_0x5e898f){return _0x5e898f[_0x3712('0x125')](_0x381353[_0x3712('0x4b')][_0x3712('0x6e')])['then'](function(){if(_[_0x3712('0x126')](_0x381353[_0x3712('0x4b')][_0x3712('0x6e')])){for(var _0x33f110=0x0;_0x33f110<_0x381353[_0x3712('0x4b')][_0x3712('0x6e')][_0x3712('0x5e')];_0x33f110+=0x1){socket[_0x3712('0x123')](_0x3712('0x127'),{'UserId':Number(_0x381353[_0x3712('0x4b')][_0x3712('0x6e')][_0x33f110]),'ChatWebsiteId':Number(_0x381353[_0x3712('0x66')]['id'])});}}else{socket[_0x3712('0x123')](_0x3712('0x127'),{'UserId':Number(_0x381353[_0x3712('0x4b')][_0x3712('0x6e')]),'ChatWebsiteId':Number(_0x381353[_0x3712('0x66')]['id'])});}});}})[_0x3712('0x24')](respondWithStatusCode(_0x3a8fd7,null))['catch'](handleError(_0x3a8fd7,null));};exports[_0x3712('0x128')]=function(_0x450147,_0x539af9,_0x3aba7c){var _0x327478={};var _0x4b3be3={};var _0x4c1497;var _0x4d8119;return db[_0x3712('0x44')][_0x3712('0x6a')]({'where':{'id':_0x450147[_0x3712('0x66')]['id']}})[_0x3712('0x24')](handleEntityNotFound(_0x539af9,null))[_0x3712('0x24')](function(_0x1fe273){if(_0x1fe273){_0x4c1497=_0x1fe273;_0x4b3be3[_0x3712('0x49')]=_[_0x3712('0x4a')](db[_0x3712('0xcc')][_0x3712('0x45')]);_0x4b3be3[_0x3712('0x4b')]=_[_0x3712('0x4a')](_0x450147[_0x3712('0x4b')]);_0x4b3be3[_0x3712('0x4c')]=_[_0x3712('0x4e')](_0x4b3be3[_0x3712('0x49')],_0x4b3be3[_0x3712('0x4b')]);_0x327478[_0x3712('0x4d')]=_[_0x3712('0x4e')](_0x4b3be3[_0x3712('0x49')],qs[_0x3712('0x4f')](_0x450147[_0x3712('0x4b')][_0x3712('0x4f')]));_0x327478[_0x3712('0x4d')]=_0x327478['attributes']['length']?_0x327478[_0x3712('0x4d')]:_0x4b3be3[_0x3712('0x49')];_0x327478[_0x3712('0x52')]=qs['sort'](_0x450147[_0x3712('0x4b')][_0x3712('0x53')]);_0x327478[_0x3712('0x57')]=qs[_0x3712('0x4c')](_['pick'](_0x450147[_0x3712('0x4b')],_0x4b3be3[_0x3712('0x4c')]));if(_0x450147[_0x3712('0x4b')]['filter']){_0x327478[_0x3712('0x57')]=_[_0x3712('0x56')](_0x327478[_0x3712('0x57')],{'$or':_[_0x3712('0x43')](_0x327478[_0x3712('0x4d')],function(_0x25e9e8){var _0x5012e4={};_0x5012e4[_0x25e9e8]={'$like':'%'+_0x450147[_0x3712('0x4b')][_0x3712('0x55')]+'%'};return _0x5012e4;})});}_0x327478=_['merge']({},_0x327478,_0x450147['options']);return _0x4c1497[_0x3712('0x128')](_0x327478);}})[_0x3712('0x24')](function(_0x5b83bc){if(_0x5b83bc){_0x4d8119=_0x5b83bc['length'];if(!_0x450147[_0x3712('0x4b')][_0x3712('0x6b')](_0x3712('0x50'))){_0x327478[_0x3712('0x33')]=qs[_0x3712('0x33')](_0x450147['query'][_0x3712('0x33')]);_0x327478[_0x3712('0x51')]=qs[_0x3712('0x51')](_0x450147[_0x3712('0x4b')][_0x3712('0x51')]);}return _0x4c1497[_0x3712('0x128')](_0x327478);}})[_0x3712('0x24')](function(_0x13d496){if(_0x13d496){return _0x13d496?{'count':_0x4d8119,'rows':_0x13d496}:null;}})[_0x3712('0x24')](respondWithResult(_0x539af9,null))[_0x3712('0x2e')](handleError(_0x539af9,null));};
\ No newline at end of file
+var _0x9541=['priority','asc','Contacts','customerIp','cf-connecting-ip','x-forwarded-for','first','split','firstName','lastName','x-real-port','referer','browser','version','format','%s\x20%s','unknown','device','vendor','%s\x20%s\x20%s','threadId','ChatInteraction','externalUrl','interaction','contact','messageId','created','push','unmanaged','*,*,*,*','ChatMessage','UserId','User','unshift','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','offline','files','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','spread','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','offlineMessageBody','ChatOfflineMessage','fromString','originalname','mimetype','server','attachments','offline-chat','basename','openNewInteraction','sequelize','transaction','Attachment','bulkCreate','CloudProvider','Smtp','forwardOfflineAddress','getSmtpOptions','sendMail','email','MailAccountId','subjectOffline','toPairsIn','mapValues','Chat','NotifyMailAccount','notifyMail','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','getInteractions','Contact','Owner','fullname','internal','Tag','Tags','tag','Command','getSnippet','iftime\x20%s,%s','interval','timezone','iftime\x20%s','indexOf','true','ONLINE','No\x20timezone','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','Interval','Intervals','getProactiveActions','custom','License','chatLicenseExceeded','all','some','server/files/chat/iframe.ejs','remote','x-real-ip','connection','remoteAddress','virtual','replace','alignment','verticalAlignment','color','textButtonColor','color_button','backgroundColor','hideWhenOffline','IntervalId','addApplications','READ_COMMITTED','ChatApplication','findAndCountAll','stack','finally','getApplications','addProactiveActions','chatProactiveAction','omit','ChatProactiveAction','getFields','online','false','onlineForm','items','fromKey','Attachments','addAgents','userChatWebsite:save','removeAgents','userChatWebsite:remove','emit','getAgents','bluebird','util','path','ejs','fs-extra','lodash','querystring','../../config/logger','api','../../config/environment','defaults','localhost','socket.io-emitter','redis','register','html-to-text','jayson/promise','client','http','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','sendStatus','status','json','offset','undefined','limit','count','Content-Range','update','destroy','get','ChatWebsites','UserProfileResource','end','name','send','index','mandatoryDispositionPause','map','ChatWebsite','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','include','findAll','rows','catch','show','params','rawAttributes','keys','includeAll','find','create','body','user','role','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Pause','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','findOne','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','pick','removeAnswers','addLogo','sitepic','file','filename','addAvatar','agentAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','../../config/license/util','getLicense','isNil','existsSync','server/files/images/logos/','getAvatar','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','showCustomerAvatar','download','notify','user-agent-parser','setUA','headers','user-agent','getResult','chat','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','CompanyId','ListId','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','from','CmList','CmContact','updatedAt','Applications','account','List','applications','orderBy'];(function(_0x3a91dc,_0x2bff89){var _0x7afc54=function(_0x22c926){while(--_0x22c926){_0x3a91dc['push'](_0x3a91dc['shift']());}};_0x7afc54(++_0x2bff89);}(_0x9541,0x93));var _0x1954=function(_0x354a12,_0x5eb2fd){_0x354a12=_0x354a12-0x0;var _0x4ea479=_0x9541[_0x354a12];return _0x4ea479;};'use strict';var BPromise=require(_0x1954('0x0'));var Mustache=require('mustache');var util=require(_0x1954('0x1'));var path=require(_0x1954('0x2'));var ejs=require(_0x1954('0x3'));var fs=require('fs');var fs_extra=require(_0x1954('0x4'));var _=require(_0x1954('0x5'));var querystring=require(_0x1954('0x6'));var Redis=require('ioredis');var qs=require('../../components/parsers/qs');var logger=require(_0x1954('0x7'))(_0x1954('0x8'));var config=require(_0x1954('0x9'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x1954('0xa')](config['redis'],{'host':_0x1954('0xb'),'port':0x18eb});var socket=require(_0x1954('0xc'))(new Redis(config[_0x1954('0xd')]));require('./chatWebsite.socket')[_0x1954('0xe')](socket);var htmlToText=require(_0x1954('0xf'));var jayson=require(_0x1954('0x10'));var client=jayson[_0x1954('0x11')][_0x1954('0x12')]({'port':0x232c});var client9002=jayson[_0x1954('0x11')][_0x1954('0x12')]({'port':0x232a});var client9003=jayson[_0x1954('0x11')][_0x1954('0x12')]({'port':0x232b});var client9001=jayson[_0x1954('0x11')]['http']({'port':0x2329});function respondWithRpcPromise(_0x4ebfe2,_0x1fc312,_0x146cfa,_0x13a8bf){return new BPromise(function(_0x3db792,_0x2dd2ed){var _0x3cbc48=_0x13a8bf||client;return _0x3cbc48['request'](_0x4ebfe2,_0x146cfa)[_0x1954('0x13')](function(_0x41b4b2){logger[_0x1954('0x14')](_0x1954('0x15'),_0x1fc312,_0x1954('0x16'));logger[_0x1954('0x17')](_0x1954('0x18'),_0x1fc312,'request\x20sent',JSON[_0x1954('0x19')](_0x41b4b2));if(_0x41b4b2[_0x1954('0x1a')]){if(_0x41b4b2[_0x1954('0x1a')][_0x1954('0x1b')]===0x1f4){logger[_0x1954('0x1a')](_0x1954('0x15'),_0x1fc312,_0x41b4b2[_0x1954('0x1a')][_0x1954('0x1c')]);return _0x2dd2ed(_0x41b4b2[_0x1954('0x1a')]['message']);}logger['error'](_0x1954('0x15'),_0x1fc312,_0x41b4b2[_0x1954('0x1a')][_0x1954('0x1c')]);return _0x3db792(_0x41b4b2[_0x1954('0x1a')][_0x1954('0x1c')]);}else{logger['info']('ChatWebsite,\x20%s,\x20%s',_0x1fc312,'request\x20sent');_0x3db792(_0x41b4b2[_0x1954('0x1d')]['message']);}})['catch'](function(_0x4bbf55){logger[_0x1954('0x1a')](_0x1954('0x15'),_0x1fc312,_0x4bbf55);_0x2dd2ed(_0x4bbf55);});});}function respondWithStatusCode(_0x5e01ed,_0x127767){_0x127767=_0x127767||0xcc;return function(_0x42361c){if(_0x42361c){return _0x5e01ed[_0x1954('0x1e')](_0x127767);}return _0x5e01ed[_0x1954('0x1f')](_0x127767)['end']();};}function respondWithResult(_0x5d297b,_0x37f21f){_0x37f21f=_0x37f21f||0xc8;return function(_0x36abf9){if(_0x36abf9){return _0x5d297b[_0x1954('0x1f')](_0x37f21f)[_0x1954('0x20')](_0x36abf9);}};}function respondWithFilteredResult(_0x160c4c,_0x51f36e){return function(_0x491149){if(_0x491149){var _0x2a5d53=typeof _0x51f36e[_0x1954('0x21')]===_0x1954('0x22')&&typeof _0x51f36e[_0x1954('0x23')]===_0x1954('0x22');var _0xe23b0f=_0x491149['count'];var _0x1c9c26=_0x2a5d53?0x0:_0x51f36e['offset'];var _0x50a035=_0x2a5d53?_0x491149[_0x1954('0x24')]:_0x51f36e[_0x1954('0x21')]+_0x51f36e[_0x1954('0x23')];var _0x1808b9;if(_0x50a035>=_0xe23b0f){_0x50a035=_0xe23b0f;_0x1808b9=0xc8;}else{_0x1808b9=0xce;}_0x160c4c[_0x1954('0x1f')](_0x1808b9);return _0x160c4c['set'](_0x1954('0x25'),_0x1c9c26+'-'+_0x50a035+'/'+_0xe23b0f)[_0x1954('0x20')](_0x491149);}return null;};}function saveUpdates(_0xfd9d1e){return function(_0x28ff07){if(_0x28ff07){return _0x28ff07[_0x1954('0x26')](_0xfd9d1e)['then'](function(_0xf5ad69){return _0xf5ad69;});}return null;};}function removeEntity(_0x47f473){return function(_0x3a987c){if(_0x3a987c){return _0x3a987c[_0x1954('0x27')]()[_0x1954('0x13')](function(){var _0x18601a=_0x3a987c[_0x1954('0x28')]({'plain':!![]});var _0xfc59c7=_0x1954('0x29');return db[_0x1954('0x2a')]['destroy']({'where':{'type':_0xfc59c7,'resourceId':_0x18601a['id']}})[_0x1954('0x13')](function(){return _0x3a987c;});})[_0x1954('0x13')](function(){_0x47f473['status'](0xcc)[_0x1954('0x2b')]();});}};}function handleEntityNotFound(_0x2002a0){return function(_0x326e22){if(!_0x326e22){_0x2002a0['sendStatus'](0x194);}return _0x326e22;};}function handleError(_0x26078c,_0x5217c4){_0x5217c4=_0x5217c4||0x1f4;return function(_0xba2071){logger[_0x1954('0x1a')](_0xba2071['stack']);if(_0xba2071[_0x1954('0x2c')]){delete _0xba2071['name'];}_0x26078c['status'](_0x5217c4)[_0x1954('0x2d')](_0xba2071);};}exports[_0x1954('0x2e')]=function(_0x4fd4d5,_0x4fc39a){var _0x5a2fa8={'include':[{'model':db['Pause'],'as':_0x1954('0x2f')}]},_0x26ec80={},_0x4c84b2={'count':0x0,'rows':[]};var _0x544d3f=_[_0x1954('0x30')](db[_0x1954('0x31')]['rawAttributes'],function(_0x4f9f2f){return{'name':_0x4f9f2f['fieldName'],'type':_0x4f9f2f[_0x1954('0x32')][_0x1954('0x33')]};});_0x26ec80[_0x1954('0x34')]=_['map'](_0x544d3f,_0x1954('0x2c'));_0x26ec80[_0x1954('0x35')]=_['keys'](_0x4fd4d5[_0x1954('0x35')]);_0x26ec80[_0x1954('0x36')]=_[_0x1954('0x37')](_0x26ec80[_0x1954('0x34')],_0x26ec80[_0x1954('0x35')]);_0x5a2fa8[_0x1954('0x38')]=_[_0x1954('0x37')](_0x26ec80[_0x1954('0x34')],qs['fields'](_0x4fd4d5[_0x1954('0x35')][_0x1954('0x39')]));_0x5a2fa8[_0x1954('0x38')]=_0x5a2fa8[_0x1954('0x38')][_0x1954('0x3a')]?_0x5a2fa8[_0x1954('0x38')]:_0x26ec80[_0x1954('0x34')];if(!_0x4fd4d5['query'][_0x1954('0x3b')](_0x1954('0x3c'))){_0x5a2fa8['limit']=qs[_0x1954('0x23')](_0x4fd4d5['query']['limit']);_0x5a2fa8[_0x1954('0x21')]=qs[_0x1954('0x21')](_0x4fd4d5[_0x1954('0x35')][_0x1954('0x21')]);}_0x5a2fa8[_0x1954('0x3d')]=qs[_0x1954('0x3e')](_0x4fd4d5[_0x1954('0x35')][_0x1954('0x3e')]);_0x5a2fa8[_0x1954('0x3f')]=qs[_0x1954('0x36')](_['pick'](_0x4fd4d5[_0x1954('0x35')],_0x26ec80[_0x1954('0x36')]),_0x544d3f);if(_0x4fd4d5['query'][_0x1954('0x40')]){_0x5a2fa8[_0x1954('0x3f')]=_[_0x1954('0x41')](_0x5a2fa8[_0x1954('0x3f')],{'$or':_[_0x1954('0x30')](_0x544d3f,function(_0x56ee4c){if(_0x56ee4c[_0x1954('0x32')]!==_0x1954('0x42')){var _0x560389={};_0x560389[_0x56ee4c[_0x1954('0x2c')]]={'$like':'%'+_0x4fd4d5['query'][_0x1954('0x40')]+'%'};return _0x560389;}})});}_0x5a2fa8=_[_0x1954('0x41')]({},_0x5a2fa8,_0x4fd4d5[_0x1954('0x43')]);var _0x15137b={'where':_0x5a2fa8['where']};return db[_0x1954('0x31')][_0x1954('0x24')](_0x15137b)[_0x1954('0x13')](function(_0x1dfb2){_0x4c84b2[_0x1954('0x24')]=_0x1dfb2;if(_0x4fd4d5['query']['includeAll']){_0x5a2fa8[_0x1954('0x44')]=[{'all':!![]}];}return db[_0x1954('0x31')][_0x1954('0x45')](_0x5a2fa8);})['then'](function(_0x4f649c){_0x4c84b2[_0x1954('0x46')]=_0x4f649c;return _0x4c84b2;})[_0x1954('0x13')](respondWithFilteredResult(_0x4fc39a,_0x5a2fa8))[_0x1954('0x47')](handleError(_0x4fc39a,null));};exports[_0x1954('0x48')]=function(_0x3f9e74,_0x4c6c7b){var _0x2b566d={'raw':![],'where':{'id':_0x3f9e74[_0x1954('0x49')]['id']},'include':[{'model':db['Pause'],'as':_0x1954('0x2f')}]},_0x239b79={};_0x239b79[_0x1954('0x34')]=_['keys'](db[_0x1954('0x31')][_0x1954('0x4a')]);_0x239b79[_0x1954('0x35')]=_[_0x1954('0x4b')](_0x3f9e74[_0x1954('0x35')]);_0x239b79['filters']=_[_0x1954('0x37')](_0x239b79[_0x1954('0x34')],_0x239b79['query']);_0x2b566d['attributes']=_[_0x1954('0x37')](_0x239b79[_0x1954('0x34')],qs['fields'](_0x3f9e74[_0x1954('0x35')][_0x1954('0x39')]));_0x2b566d[_0x1954('0x38')]=_0x2b566d[_0x1954('0x38')][_0x1954('0x3a')]?_0x2b566d['attributes']:_0x239b79[_0x1954('0x34')];if(_0x3f9e74[_0x1954('0x35')][_0x1954('0x4c')]){_0x2b566d[_0x1954('0x44')]=[{'all':!![]}];}_0x2b566d=_[_0x1954('0x41')]({},_0x2b566d,_0x3f9e74[_0x1954('0x43')]);return db['ChatWebsite'][_0x1954('0x4d')](_0x2b566d)[_0x1954('0x13')](handleEntityNotFound(_0x4c6c7b,null))['then'](respondWithResult(_0x4c6c7b,null))[_0x1954('0x47')](handleError(_0x4c6c7b,null));};exports['create']=function(_0x160896,_0x44c990){return db['ChatWebsite'][_0x1954('0x4e')](_0x160896[_0x1954('0x4f')],{})['then'](function(_0x482531){var _0x37cdf6=_0x160896[_0x1954('0x50')][_0x1954('0x28')]({'plain':!![]});if(!_0x37cdf6)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x37cdf6[_0x1954('0x51')]===_0x1954('0x50')){var _0x24dd14=_0x482531[_0x1954('0x28')]({'plain':!![]});var _0x444486='ChatWebsites';return db['UserProfileSection']['find']({'where':{'name':_0x444486,'userProfileId':_0x37cdf6['userProfileId']},'raw':!![]})[_0x1954('0x13')](function(_0x57d0cb){if(_0x57d0cb&&_0x57d0cb[_0x1954('0x52')]===0x0){return db[_0x1954('0x2a')][_0x1954('0x4e')]({'name':_0x24dd14['name'],'resourceId':_0x24dd14['id'],'type':_0x57d0cb['name'],'sectionId':_0x57d0cb['id']},{})['then'](function(){return _0x482531;});}else{return _0x482531;}})[_0x1954('0x47')](function(_0x2ec570){logger[_0x1954('0x1a')](_0x1954('0x53'),_0x2ec570);throw _0x2ec570;});}return _0x482531;})[_0x1954('0x13')](respondWithResult(_0x44c990,0xc9))[_0x1954('0x47')](handleError(_0x44c990,null));};exports['update']=function(_0x2cac6e,_0x4394c7){if(_0x2cac6e[_0x1954('0x4f')]['id']){delete _0x2cac6e[_0x1954('0x4f')]['id'];}return db[_0x1954('0x31')]['find']({'where':{'id':_0x2cac6e[_0x1954('0x49')]['id']},'include':[{'model':db[_0x1954('0x54')],'as':_0x1954('0x2f')}]})[_0x1954('0x13')](handleEntityNotFound(_0x4394c7,null))[_0x1954('0x13')](saveUpdates(_0x2cac6e['body'],null))['then'](respondWithResult(_0x4394c7,null))[_0x1954('0x47')](handleError(_0x4394c7,null));};exports['destroy']=function(_0x1de4be,_0x3f4574){return db[_0x1954('0x31')][_0x1954('0x4d')]({'where':{'id':_0x1de4be[_0x1954('0x49')]['id']}})['then'](handleEntityNotFound(_0x3f4574,null))[_0x1954('0x13')](removeEntity(_0x3f4574,null))[_0x1954('0x47')](handleError(_0x3f4574,null));};exports[_0x1954('0x55')]=function(_0x396107,_0x326781){return db[_0x1954('0x31')][_0x1954('0x55')]()['then'](respondWithResult(_0x326781,null))[_0x1954('0x47')](handleError(_0x326781,null));};exports[_0x1954('0x56')]=function(_0x43b229,_0x3a6b1a){if(_0x43b229['body']['id']){delete _0x43b229['body']['id'];}return db[_0x1954('0x31')][_0x1954('0x4d')]({'where':{'id':_0x43b229[_0x1954('0x49')]['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x3a6b1a,null))[_0x1954('0x13')](function(_0x348b1b){if(_0x348b1b){_0x43b229[_0x1954('0x4f')][_0x1954('0x57')]=_0x348b1b['id'];return db[_0x1954('0x58')][_0x1954('0x4e')](_0x43b229['body']);}})[_0x1954('0x13')](respondWithResult(_0x3a6b1a,null))[_0x1954('0x47')](handleError(_0x3a6b1a,null));};exports[_0x1954('0x59')]=function(_0x3016fc,_0x7b03d){var _0x156c8b={'raw':![],'where':{}};var _0x1e7b56={};var _0x4292ea={'count':0x0,'rows':[]};return db[_0x1954('0x31')][_0x1954('0x5a')]({'where':{'id':_0x3016fc[_0x1954('0x49')]['id']}})['then'](handleEntityNotFound(_0x7b03d,null))[_0x1954('0x13')](function(_0x1ae722){if(_0x1ae722){_0x1e7b56[_0x1954('0x34')]=_[_0x1954('0x4b')](db[_0x1954('0x58')][_0x1954('0x4a')]);_0x1e7b56['query']=_['keys'](_0x3016fc[_0x1954('0x35')]);_0x1e7b56[_0x1954('0x36')]=_[_0x1954('0x37')](_0x1e7b56[_0x1954('0x34')],_0x1e7b56[_0x1954('0x35')]);_0x156c8b['attributes']=_['intersection'](_0x1e7b56[_0x1954('0x34')],qs[_0x1954('0x39')](_0x3016fc[_0x1954('0x35')]['fields']));_0x156c8b[_0x1954('0x38')]=_0x156c8b[_0x1954('0x38')]['length']?_0x156c8b[_0x1954('0x38')]:_0x1e7b56['model'];if(!_0x3016fc['query'][_0x1954('0x3b')](_0x1954('0x3c'))){_0x156c8b[_0x1954('0x23')]=qs[_0x1954('0x23')](_0x3016fc['query'][_0x1954('0x23')]);_0x156c8b[_0x1954('0x21')]=qs['offset'](_0x3016fc[_0x1954('0x35')][_0x1954('0x21')]);}_0x156c8b[_0x1954('0x3d')]=qs[_0x1954('0x3e')](_0x3016fc['query']['sort']);_0x156c8b['where']=qs['filters'](_['pick'](_0x3016fc[_0x1954('0x35')],_0x1e7b56[_0x1954('0x36')]));_0x156c8b[_0x1954('0x3f')][_0x1954('0x57')]=_0x1ae722['id'];if(_0x3016fc[_0x1954('0x35')][_0x1954('0x40')]){_0x156c8b[_0x1954('0x3f')]=_[_0x1954('0x41')](_0x156c8b[_0x1954('0x3f')],{'$or':_[_0x1954('0x30')](_0x156c8b[_0x1954('0x38')],function(_0x2206df){var _0x31f839={};_0x31f839[_0x2206df]={'$like':'%'+_0x3016fc[_0x1954('0x35')][_0x1954('0x40')]+'%'};return _0x31f839;})});}_0x156c8b=_[_0x1954('0x41')]({},_0x156c8b,_0x3016fc['options']);return db[_0x1954('0x58')]['count']({'where':_0x156c8b[_0x1954('0x3f')]})[_0x1954('0x13')](function(_0x4ac47b){_0x4292ea[_0x1954('0x24')]=_0x4ac47b;if(_0x3016fc['query']['includeAll']){_0x156c8b[_0x1954('0x44')]=[{'all':!![]}];}return db[_0x1954('0x58')][_0x1954('0x45')](_0x156c8b);})[_0x1954('0x13')](function(_0x588465){_0x4292ea['rows']=_0x588465;return _0x4292ea;});}})[_0x1954('0x13')](respondWithFilteredResult(_0x7b03d,_0x156c8b))[_0x1954('0x47')](handleError(_0x7b03d,null));};exports['removeDispositions']=function(_0x4bfaef,_0x359eba){return db['ChatWebsite'][_0x1954('0x4d')]({'where':{'id':_0x4bfaef[_0x1954('0x49')]['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x359eba,null))[_0x1954('0x13')](function(_0xb482c8){if(_0xb482c8){return _0xb482c8[_0x1954('0x5b')](_0x4bfaef[_0x1954('0x35')][_0x1954('0x5c')]);}})['then'](respondWithStatusCode(_0x359eba,null))[_0x1954('0x47')](handleError(_0x359eba,null));};exports[_0x1954('0x5d')]=function(_0x15d70c,_0x3ee231){if(_0x15d70c[_0x1954('0x4f')]['id']){delete _0x15d70c[_0x1954('0x4f')]['id'];}return db[_0x1954('0x31')][_0x1954('0x4d')]({'where':{'id':_0x15d70c[_0x1954('0x49')]['id']}})['then'](handleEntityNotFound(_0x3ee231,null))[_0x1954('0x13')](function(_0x2b1bd3){if(_0x2b1bd3){_0x15d70c[_0x1954('0x4f')][_0x1954('0x57')]=_0x2b1bd3['id'];return db[_0x1954('0x5e')]['create'](_0x15d70c[_0x1954('0x4f')]);}})[_0x1954('0x13')](respondWithResult(_0x3ee231,null))[_0x1954('0x47')](handleError(_0x3ee231,null));};exports[_0x1954('0x5f')]=function(_0x41a9ce,_0x3cc327){var _0x4225c4={'raw':![],'where':{}};var _0xb0c420={};var _0x4dbdc4={'count':0x0,'rows':[]};return db[_0x1954('0x31')]['findOne']({'where':{'id':_0x41a9ce[_0x1954('0x49')]['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x3cc327,null))[_0x1954('0x13')](function(_0x33f177){if(_0x33f177){_0xb0c420[_0x1954('0x34')]=_['keys'](db[_0x1954('0x5e')][_0x1954('0x4a')]);_0xb0c420[_0x1954('0x35')]=_[_0x1954('0x4b')](_0x41a9ce[_0x1954('0x35')]);_0xb0c420[_0x1954('0x36')]=_[_0x1954('0x37')](_0xb0c420[_0x1954('0x34')],_0xb0c420['query']);_0x4225c4[_0x1954('0x38')]=_[_0x1954('0x37')](_0xb0c420['model'],qs[_0x1954('0x39')](_0x41a9ce[_0x1954('0x35')]['fields']));_0x4225c4['attributes']=_0x4225c4[_0x1954('0x38')]['length']?_0x4225c4[_0x1954('0x38')]:_0xb0c420[_0x1954('0x34')];if(!_0x41a9ce[_0x1954('0x35')]['hasOwnProperty'](_0x1954('0x3c'))){_0x4225c4[_0x1954('0x23')]=qs[_0x1954('0x23')](_0x41a9ce['query'][_0x1954('0x23')]);_0x4225c4[_0x1954('0x21')]=qs[_0x1954('0x21')](_0x41a9ce[_0x1954('0x35')][_0x1954('0x21')]);}_0x4225c4[_0x1954('0x3d')]=qs[_0x1954('0x3e')](_0x41a9ce['query']['sort']);_0x4225c4['where']=qs['filters'](_[_0x1954('0x60')](_0x41a9ce[_0x1954('0x35')],_0xb0c420[_0x1954('0x36')]));_0x4225c4[_0x1954('0x3f')][_0x1954('0x57')]=_0x33f177['id'];if(_0x41a9ce['query'][_0x1954('0x40')]){_0x4225c4['where']=_['merge'](_0x4225c4['where'],{'$or':_['map'](_0x4225c4[_0x1954('0x38')],function(_0x5be33d){var _0x155537={};_0x155537[_0x5be33d]={'$like':'%'+_0x41a9ce[_0x1954('0x35')][_0x1954('0x40')]+'%'};return _0x155537;})});}_0x4225c4=_['merge']({},_0x4225c4,_0x41a9ce[_0x1954('0x43')]);return db[_0x1954('0x5e')]['count']({'where':_0x4225c4[_0x1954('0x3f')]})[_0x1954('0x13')](function(_0x5ce214){_0x4dbdc4[_0x1954('0x24')]=_0x5ce214;if(_0x41a9ce[_0x1954('0x35')][_0x1954('0x4c')]){_0x4225c4[_0x1954('0x44')]=[{'all':!![]}];}return db[_0x1954('0x5e')]['findAll'](_0x4225c4);})[_0x1954('0x13')](function(_0x5096c4){_0x4dbdc4[_0x1954('0x46')]=_0x5096c4;return _0x4dbdc4;});}})[_0x1954('0x13')](respondWithFilteredResult(_0x3cc327,_0x4225c4))[_0x1954('0x47')](handleError(_0x3cc327,null));};exports[_0x1954('0x61')]=function(_0x2e3114,_0x50e02a){return db['ChatWebsite'][_0x1954('0x4d')]({'where':{'id':_0x2e3114[_0x1954('0x49')]['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x50e02a,null))['then'](function(_0x1de67d){if(_0x1de67d){return _0x1de67d[_0x1954('0x61')](_0x2e3114[_0x1954('0x35')][_0x1954('0x5c')]);}})[_0x1954('0x13')](respondWithStatusCode(_0x50e02a,null))[_0x1954('0x47')](handleError(_0x50e02a,null));};exports[_0x1954('0x62')]=function(_0x5e6048,_0x3c41d2){_0x5e6048[_0x1954('0x4f')][_0x1954('0x63')]=_0x5e6048[_0x1954('0x64')][_0x1954('0x65')];return db[_0x1954('0x31')][_0x1954('0x4d')]({'where':{'id':_0x5e6048[_0x1954('0x49')]['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x3c41d2,null))['then'](saveUpdates(_0x5e6048['body'],null))[_0x1954('0x13')](respondWithResult(_0x3c41d2,null))[_0x1954('0x47')](handleError(_0x3c41d2,null));};exports[_0x1954('0x66')]=function(_0xed2010,_0x1c06cb){_0xed2010[_0x1954('0x4f')][_0x1954('0x67')]=_0xed2010['file'][_0x1954('0x65')];return db[_0x1954('0x31')][_0x1954('0x4d')]({'where':{'id':_0xed2010['params']['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x1c06cb,null))[_0x1954('0x13')](saveUpdates(_0xed2010['body'],null))['then'](respondWithResult(_0x1c06cb,null))[_0x1954('0x47')](handleError(_0x1c06cb,null));};exports['addCustomerAvatar']=function(_0x1c6da0,_0x4b7203){_0x1c6da0[_0x1954('0x4f')][_0x1954('0x68')]=_0x1c6da0['file'][_0x1954('0x65')];return db['ChatWebsite'][_0x1954('0x4d')]({'where':{'id':_0x1c6da0['params']['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x4b7203,null))[_0x1954('0x13')](saveUpdates(_0x1c6da0[_0x1954('0x4f')],null))[_0x1954('0x13')](respondWithResult(_0x4b7203,null))[_0x1954('0x47')](handleError(_0x4b7203,null));};exports[_0x1954('0x69')]=function(_0x2fa668,_0x3c667a){_0x2fa668[_0x1954('0x4f')][_0x1954('0x6a')]=_0x2fa668[_0x1954('0x64')][_0x1954('0x65')];return db[_0x1954('0x31')][_0x1954('0x4d')]({'where':{'id':_0x2fa668[_0x1954('0x49')]['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x3c667a,null))[_0x1954('0x13')](saveUpdates(_0x2fa668[_0x1954('0x4f')],null))[_0x1954('0x13')](respondWithResult(_0x3c667a,null))['catch'](handleError(_0x3c667a,null));};exports[_0x1954('0x6b')]=function(_0x1db80a,_0x421aff){var _0xca8ef=path[_0x1954('0x6c')](config[_0x1954('0x6d')],'server/files/images/logos/default_logo.svg');var _0x53994f={'where':{'id':_0x1db80a[_0x1954('0x49')]['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x3f93b7=![];return require(_0x1954('0x6e'))[_0x1954('0x6f')]()[_0x1954('0x13')](function(_0x20f3dd){if(_0x20f3dd){_0x3f93b7=_0x20f3dd['custom'];}})['then'](function(){return db[_0x1954('0x31')][_0x1954('0x4d')](_0x53994f);})[_0x1954('0x13')](handleEntityNotFound(_0x421aff,null))[_0x1954('0x13')](function(_0x400403){if(_0x400403){if(!_[_0x1954('0x70')](_0x400403['sitepic'])){if(fs[_0x1954('0x71')](path[_0x1954('0x6c')](config['root'],_0x1954('0x72'),_0x400403[_0x1954('0x63')]))&&_0x3f93b7){_0xca8ef=path['join'](config[_0x1954('0x6d')],'server/files/images/logos/',_0x400403[_0x1954('0x63')]);}}return _0x421aff['download'](_0xca8ef);}})[_0x1954('0x47')](handleError(_0x421aff,null));};exports[_0x1954('0x73')]=function(_0xc15b47,_0x2d6587){var _0x2dd865=path[_0x1954('0x6c')](config[_0x1954('0x6d')],_0x1954('0x74'));var _0x5125d6={'where':{'id':_0xc15b47[_0x1954('0x49')]['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db[_0x1954('0x31')][_0x1954('0x4d')](_0x5125d6)[_0x1954('0x13')](handleEntityNotFound(_0x2d6587,null))[_0x1954('0x13')](function(_0x4b6261){if(_0x4b6261){if(!_[_0x1954('0x70')](_0x4b6261[_0x1954('0x67')])){if(fs[_0x1954('0x71')](path[_0x1954('0x6c')](config[_0x1954('0x6d')],_0x1954('0x75'),_0x4b6261[_0x1954('0x67')]))){_0x2dd865=path[_0x1954('0x6c')](config[_0x1954('0x6d')],_0x1954('0x75'),_0x4b6261[_0x1954('0x67')]);}}return _0x2d6587['download'](_0x2dd865);}})['catch'](handleError(_0x2d6587,null));};exports['getCustomerAvatar']=function(_0x5d0546,_0x200c60){var _0x1f0eb0=path[_0x1954('0x6c')](config[_0x1954('0x6d')],'server/files/images/avatars/customer_avatar.png');var _0x520b41={'where':{'id':_0x5d0546[_0x1954('0x49')]['id']},'attributes':['id',_0x1954('0x68'),_0x1954('0x76')],'raw':!![]};return db['ChatWebsite'][_0x1954('0x4d')](_0x520b41)[_0x1954('0x13')](handleEntityNotFound(_0x200c60,null))[_0x1954('0x13')](function(_0x53aab2){if(_0x53aab2){if(!_[_0x1954('0x70')](_0x53aab2[_0x1954('0x68')])){if(fs[_0x1954('0x71')](path[_0x1954('0x6c')](config['root'],_0x1954('0x75'),_0x53aab2[_0x1954('0x68')]))&&_0x53aab2['showCustomerAvatar']){_0x1f0eb0=path[_0x1954('0x6c')](config['root'],_0x1954('0x75'),_0x53aab2[_0x1954('0x68')]);}}return _0x200c60[_0x1954('0x77')](_0x1f0eb0);}})['catch'](handleError(_0x200c60,null));};exports['getSystemAvatar']=function(_0x3e1f90,_0x2f852d){var _0x430d13=path[_0x1954('0x6c')](config['root'],'server/files/images/avatars/system_avatar.png');var _0x8b0d2c={'where':{'id':_0x3e1f90[_0x1954('0x49')]['id']},'attributes':['id',_0x1954('0x6a')],'raw':!![]};return db[_0x1954('0x31')][_0x1954('0x4d')](_0x8b0d2c)[_0x1954('0x13')](handleEntityNotFound(_0x2f852d,null))['then'](function(_0x5a65ab){if(_0x5a65ab){if(!_[_0x1954('0x70')](_0x5a65ab[_0x1954('0x6a')])){if(fs[_0x1954('0x71')](path[_0x1954('0x6c')](config[_0x1954('0x6d')],_0x1954('0x75'),_0x5a65ab[_0x1954('0x6a')]))){_0x430d13=path[_0x1954('0x6c')](config[_0x1954('0x6d')],_0x1954('0x75'),_0x5a65ab[_0x1954('0x6a')]);}}return _0x2f852d[_0x1954('0x77')](_0x430d13);}})[_0x1954('0x47')](handleError(_0x2f852d,null));};exports[_0x1954('0x78')]=function(_0x338316,_0x243204){var _0x2cabde=require(_0x1954('0x79'));var _0x54fb33=new _0x2cabde();var _0x2bb000=_0x54fb33[_0x1954('0x7a')](_0x338316[_0x1954('0x7b')][_0x1954('0x7c')])[_0x1954('0x7d')]();var _0x232759={'body':_0x338316[_0x1954('0x4f')],'channel':_0x1954('0x7e')};var _0x4c4f79=[];var _0x20668f=[];var _0x46225a={};var _0x596d1d=![];return db['CmContact'][_0x1954('0x55')]()[_0x1954('0x13')](function(_0x18a302){if(!_0x18a302){throw new db[(_0x1954('0x7f'))][(_0x1954('0x80'))](_0x1954('0x81'));}_0x4c4f79=_[_0x1954('0x82')](_[_0x1954('0x4b')](_0x18a302),[_0x1954('0x83'),'updatedAt']);_0x20668f=_[_0x1954('0x82')](_[_0x1954('0x4b')](_0x18a302),[_0x1954('0x83'),'updatedAt',_0x1954('0x84'),_0x1954('0x85')]);if(_0x338316[_0x1954('0x4f')]['id']){delete _0x338316[_0x1954('0x4f')]['id'];}if(_[_0x1954('0x70')](_0x338316['body']['from'])){throw new db['Sequelize'][(_0x1954('0x80'))](_0x1954('0x86'));}if(_[_0x1954('0x70')](_0x338316[_0x1954('0x4f')][_0x1954('0x4f')])||_0x338316[_0x1954('0x4f')][_0x1954('0x4f')]===''){throw new db['Sequelize'][(_0x1954('0x80'))](_0x1954('0x87'));}if(_[_0x1954('0x70')](_0x338316[_0x1954('0x4f')][_0x1954('0x88')])){throw new db[(_0x1954('0x7f'))][(_0x1954('0x80'))](_0x1954('0x89')+_0x20668f);}if(!_[_0x1954('0x8a')](_0x20668f,_0x338316[_0x1954('0x4f')][_0x1954('0x88')])){throw new db[(_0x1954('0x7f'))]['ValidationError'](_0x1954('0x8b')+_0x20668f);}_0x46225a[_0x338316[_0x1954('0x4f')][_0x1954('0x88')]]=_0x338316[_0x1954('0x4f')][_0x1954('0x8c')];})['then'](function(){return db[_0x1954('0x31')][_0x1954('0x4d')]({'where':{'id':_0x338316[_0x1954('0x49')]['id']},'include':[{'model':db[_0x1954('0x8d')],'as':'List','include':[{'model':db[_0x1954('0x8e')],'as':'Contacts','where':_0x46225a,'limit':0x1,'order':[[_0x1954('0x8f'),'DESC']]}]},{'model':db['ChatApplication'],'as':_0x1954('0x90')}]});})[_0x1954('0x13')](handleEntityNotFound(_0x243204,null))[_0x1954('0x13')](function(_0xfaa8f3){if(_0xfaa8f3&&_0xfaa8f3['List']){_0x232759[_0x1954('0x91')]=_0xfaa8f3;_0x232759['applications']=_0xfaa8f3[_0x1954('0x90')];_0x232759['list']=_0xfaa8f3[_0x1954('0x92')];_0x232759[_0x1954('0x93')]=_[_0x1954('0x94')](_0x232759[_0x1954('0x93')],[_0x1954('0x95')],[_0x1954('0x96')]);if(_0x232759[_0x1954('0x91')][_0x1954('0x90')]){delete _0x232759[_0x1954('0x91')][_0x1954('0x90')];}if(_0x232759[_0x1954('0x91')]['List']&&_0x232759['account'][_0x1954('0x92')][_0x1954('0x97')][_0x1954('0x3a')]){return _0x232759[_0x1954('0x91')]['List']['Contacts'][0x0];}var _0x3ca68d=_[_0x1954('0xa')](_0x338316['body'],{'firstName':_0x338316[_0x1954('0x4f')]['from'],'ListId':_0xfaa8f3['ListId']});_0x3ca68d[_0x338316[_0x1954('0x4f')][_0x1954('0x88')]]=_0x338316[_0x1954('0x4f')][_0x1954('0x8c')];return db[_0x1954('0x8e')]['create'](_0x3ca68d,{'fields':_0x4c4f79,'raw':!![]});}})[_0x1954('0x13')](handleEntityNotFound(_0x243204,null))['then'](function(_0x1c9f51){_0x232759['contact']=_0x1c9f51;var _0xddf3ac=_0x338316[_0x1954('0x4f')][_0x1954('0x98')];if(_0x338316['headers']['cf-connecting-ip']){_0xddf3ac=_0x338316[_0x1954('0x7b')][_0x1954('0x99')];}else if(_0x338316[_0x1954('0x7b')][_0x1954('0x9a')]){_0xddf3ac=_[_0x1954('0x9b')](_0x338316[_0x1954('0x7b')]['x-forwarded-for'][_0x1954('0x9c')](','));}if(_0x1c9f51){var _0x352b24={'ContactId':_0x1c9f51['id'],'ChatWebsiteId':_0x338316[_0x1954('0x49')]['id'],'from':(_0x1c9f51[_0x1954('0x9d')]||'')+'\x20'+(_0x1c9f51[_0x1954('0x9e')]||''),'customerIp':_0xddf3ac,'customerPort':_0x338316['headers']['x-real-port']?_0x338316[_0x1954('0x7b')][_0x1954('0x9f')]:null,'referer':_0x338316['body'][_0x1954('0xa0')],'browserName':_0x2bb000[_0x1954('0xa1')][_0x1954('0x2c')]&&_0x2bb000[_0x1954('0xa1')][_0x1954('0xa2')]?util[_0x1954('0xa3')](_0x1954('0xa4'),_0x2bb000[_0x1954('0xa1')][_0x1954('0x2c')],_0x2bb000[_0x1954('0xa1')][_0x1954('0xa2')]):_0x1954('0xa5'),'browserVersion':_0x2bb000['browser'][_0x1954('0xa2')]||_0x1954('0xa5'),'osName':util[_0x1954('0xa3')](_0x1954('0xa4'),_0x2bb000['os']['name'],_0x2bb000['os']['version']),'osVersion':_0x2bb000['os']['version'],'deviceModel':_0x2bb000[_0x1954('0xa6')][_0x1954('0x34')]&&_0x2bb000[_0x1954('0xa6')][_0x1954('0xa7')]?util[_0x1954('0xa3')](_0x1954('0xa8'),_0x2bb000[_0x1954('0xa6')][_0x1954('0x34')],_0x2bb000['device'][_0x1954('0xa7')],_0x2bb000[_0x1954('0xa6')][_0x1954('0x32')]):null,'deviceVendor':_0x2bb000['device'][_0x1954('0xa7')],'deviceType':_0x2bb000[_0x1954('0xa6')]['type'],'formData':JSON[_0x1954('0x19')](_0x338316[_0x1954('0x4f')])};var _0x42ac44={'ChatWebsiteId':_0x338316[_0x1954('0x49')]['id'],'closed':![]};if(_0x338316[_0x1954('0x4f')][_0x1954('0xa9')]){_0x42ac44['threadId']=_0x338316[_0x1954('0x4f')]['threadId'];return db[_0x1954('0xaa')][_0x1954('0x4d')]({'where':_0x42ac44})['then'](function(_0x462ade){if(_0x462ade){return[_0x462ade,![]];}_0x352b24[_0x1954('0xa9')]=_0x338316[_0x1954('0x4f')][_0x1954('0xa9')];_0x352b24[_0x1954('0xab')]=_0x338316[_0x1954('0x4f')][_0x1954('0xab')];return db[_0x1954('0xaa')]['create'](_0x352b24)[_0x1954('0x13')](function(_0x1b11b1){return[_0x1b11b1,!![]];});});}_0x42ac44['ContactId']=_0x1c9f51['id'];if(_0x338316['body']['interaction']&&_0x338316[_0x1954('0x4f')][_0x1954('0xac')]['id']){_0x42ac44['id']=_0x338316[_0x1954('0x4f')][_0x1954('0xac')]['id'];return db['ChatInteraction'][_0x1954('0x4d')]({'where':_0x42ac44})[_0x1954('0x13')](function(_0x268bf6){if(_0x268bf6){return[_0x268bf6,![]];}return db[_0x1954('0xaa')][_0x1954('0x4e')](_0x352b24)[_0x1954('0x13')](function(_0x283c2f){return[_0x283c2f,!![]];});});}return db[_0x1954('0xaa')]['create'](_0x352b24)[_0x1954('0x13')](function(_0xd7780e){return[_0xd7780e,!![]];});}})['spread'](function(_0x3a956e,_0x419f87){if(_0x3a956e){_0x596d1d=_0x419f87;if(!_0x419f87){var _0x52bf28={'from':(_0x232759[_0x1954('0xad')][_0x1954('0x9d')]||'')+'\x20'+(_0x232759['contact'][_0x1954('0x9e')]||'')};if(_0x338316[_0x1954('0x4f')][_0x1954('0xa9')]&&_0x338316[_0x1954('0x4f')][_0x1954('0xae')]&&_0x338316[_0x1954('0x4f')][_0x1954('0xa9')]!=_0x338316['body'][_0x1954('0xae')]){_0x52bf28['threadId']=_0x338316['body'][_0x1954('0xae')];}return _0x3a956e[_0x1954('0x26')](_0x52bf28);}else{return _0x3a956e;}}})[_0x1954('0x13')](function(_0x3302f5){_0x232759[_0x1954('0xac')]=_0x3302f5[_0x1954('0x28')]({'plain':!![]});_0x232759['interaction']['created']=_0x596d1d;if(_0x232759[_0x1954('0xac')][_0x1954('0xaf')]){if(_0x232759['account']['autoclose']){_0x232759[_0x1954('0x93')][_0x1954('0xb0')]({'id':0x0,'priority':_0x232759[_0x1954('0x93')][_0x1954('0x3a')]+0x1,'app':'close','appdata':_0x1954('0xb1'),'interval':_0x1954('0xb2')});}}return db[_0x1954('0xb3')][_0x1954('0x4e')]({'body':_0x338316[_0x1954('0x4f')][_0x1954('0x4f')],'ChatWebsiteId':_0x338316[_0x1954('0x49')]['id'],'ChatInteractionId':_0x3302f5['id'],'direction':'in','ContactId':_0x232759['contact']['id'],'AttachmentId':_0x338316[_0x1954('0x4f')]['AttachmentId']});})[_0x1954('0x13')](function(_0x536dfe){_0x232759[_0x1954('0x1c')]=_0x536dfe;if(_0x232759['interaction'][_0x1954('0xb4')]){return db[_0x1954('0xb5')][_0x1954('0x4d')]({'attributes':['id',_0x1954('0x2c')],'where':{'id':_0x232759[_0x1954('0xac')][_0x1954('0xb4')]}})[_0x1954('0x13')](function(_0xae5053){if(_0xae5053){_0x232759[_0x1954('0x93')][_0x1954('0xb6')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0xae5053['name']+','+(_0x232759[_0x1954('0x91')][_0x1954('0xb7')]||0xa),'interval':_0x1954('0xb2')});_0x232759[_0x1954('0xb8')]=!![];}return respondWithRpcPromise(_0x1954('0xb9'),_0x1954('0xba'),_0x232759);});}return respondWithRpcPromise(_0x1954('0xb9'),_0x1954('0xba'),_0x232759);})[_0x1954('0x13')](function(_0x558cf6){respondWithRpcPromise(_0x1954('0xbb'),_0x1954('0xbb'),{'event':'notify','message':_0x558cf6},client9002);return _0x558cf6;})['then'](respondWithResult(_0x243204,null))[_0x1954('0x47')](handleError(_0x243204,null));};exports[_0x1954('0xbc')]=function(_0x5ef57a,_0x193edc){var _0x25a597,_0x298344,_0x56096e;var _0x2f5493=[];var _0x21687d={};var _0x156d75=_0x5ef57a[_0x1954('0xbd')]||[];var _0x3d8e29=[];var _0x49a4f6;return db[_0x1954('0x8e')][_0x1954('0x55')]()[_0x1954('0x13')](function(_0x479ec6){if(!_0x479ec6){throw new db[(_0x1954('0x7f'))]['ValidationError'](_0x1954('0x81'));}_0x2f5493=_[_0x1954('0x82')](_[_0x1954('0x4b')](_0x479ec6),[_0x1954('0x83'),'updatedAt',_0x1954('0x84'),'ListId']);if(_0x5ef57a[_0x1954('0x4f')]['id']){delete _0x5ef57a[_0x1954('0x4f')]['id'];}if(_[_0x1954('0x70')](_0x5ef57a['body'][_0x1954('0x8c')])){throw _0x193edc[_0x1954('0x1f')](0x1f4)[_0x1954('0x2d')](new db[(_0x1954('0x7f'))][(_0x1954('0x80'))](_0x1954('0x86')));}if(_[_0x1954('0x70')](_0x5ef57a[_0x1954('0x4f')][_0x1954('0x4f')])||_0x5ef57a[_0x1954('0x4f')][_0x1954('0x4f')]===''){throw _0x193edc[_0x1954('0x1f')](0x1f4)[_0x1954('0x2d')](new db['Sequelize'][(_0x1954('0x80'))](_0x1954('0x87')));}if(_[_0x1954('0x70')](_0x5ef57a[_0x1954('0x4f')][_0x1954('0xbe')])){throw _0x193edc[_0x1954('0x1f')](0x1f4)[_0x1954('0x2d')](new db[(_0x1954('0x7f'))][(_0x1954('0x80'))](_0x1954('0xbf')+_0x2f5493));}if(!_['includes'](_0x2f5493,_0x5ef57a[_0x1954('0x4f')][_0x1954('0xbe')])){throw _0x193edc[_0x1954('0x1f')](0x1f4)[_0x1954('0x2d')](new db['Sequelize'][(_0x1954('0x80'))](_0x1954('0xc0')+_0x2f5493));}_0x21687d[_0x5ef57a[_0x1954('0x4f')]['mapKeyOffline']]=_0x5ef57a['body']['from'];})[_0x1954('0x13')](function(){return db['ChatWebsite'][_0x1954('0x4d')]({'where':{'id':_0x5ef57a['params']['id']},'include':[{'model':db[_0x1954('0x8d')],'as':_0x1954('0x92')},{'model':db[_0x1954('0xc1')],'as':_0x1954('0xc1')}]});})[_0x1954('0x13')](handleEntityNotFound(_0x193edc,null))[_0x1954('0x13')](function(_0x4bb22a){if(_0x4bb22a&&_0x4bb22a['List']){_0x298344=_0x4bb22a;var _0x3695de=_[_0x1954('0xa')](_0x5ef57a[_0x1954('0x4f')],{'firstName':_0x5ef57a['body'][_0x1954('0x8c')],'phone':_0x5ef57a[_0x1954('0x4f')][_0x1954('0x8c')],'ListId':_0x4bb22a[_0x1954('0x85')]});_0x3695de[_0x5ef57a[_0x1954('0x4f')]['mapKeyOffline']]=_0x5ef57a[_0x1954('0x4f')][_0x1954('0x8c')];return db[_0x1954('0x8e')][_0x1954('0xc2')]({'where':_0x21687d,'defaults':_0x3695de});}})[_0x1954('0xc3')](function(_0x440b35){if(_0x440b35){_0x56096e=_0x440b35;var _0x3e65e2=fs[_0x1954('0xc4')](path[_0x1954('0x6c')](config[_0x1954('0x6d')],_0x1954('0xc5')),_0x1954('0xc6'));var _0x3f6136=ejs[_0x1954('0xc7')](_0x3e65e2,{'body':_['toPairs'](_0x5ef57a['body'][_0x1954('0x4f')]),'bodyTitle':_0x298344[_0x1954('0xc8')]});return db[_0x1954('0xc9')][_0x1954('0x4e')]({'body':_0x3f6136,'plainBody':htmlToText[_0x1954('0xca')](_0x3f6136),'ContactId':_0x440b35['id'],'ChatWebsiteId':_0x298344['id']});}})[_0x1954('0x13')](function(_0x370689){_0x49a4f6=_0x370689;if(_0x156d75[_0x1954('0x3a')]){var _0x4ab082=_0x156d75[_0x1954('0x30')](function(_0x35f27e){return{'name':_0x35f27e[_0x1954('0xcb')],'basename':_0x35f27e['filename'],'type':_0x35f27e[_0x1954('0xcc')],'ChatOfflineMessageId':_0x370689['id']};});_0x3d8e29=_0x4ab082[_0x1954('0x30')](_0x36fe86=>{var _0x1113a9={'filename':_0x36fe86[_0x1954('0x2c')],'path':path[_0x1954('0x6c')](config['root'],_0x1954('0xcd'),_0x1954('0xbd'),_0x1954('0xce'),_0x1954('0xcf'),_0x36fe86[_0x1954('0xd0')])};return _0x1113a9;});if(!_0x298344[_0x1954('0xd1')]){return db[_0x1954('0xd2')][_0x1954('0xd3')](function(_0x4c1a6f){return db[_0x1954('0xd4')][_0x1954('0xd5')](_0x4ab082,{'transaction':_0x4c1a6f});});}}})[_0x1954('0x13')](function(){if(_0x49a4f6){_0x25a597=_0x49a4f6;return db['MailAccount'][_0x1954('0x5a')]({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':'Smtp','raw':!![],'include':[{'model':db['CloudProvider'],'as':_0x1954('0xd6'),'raw':!![]}]}]});}})[_0x1954('0x13')](function(_0x175e3f){if(_0x175e3f&&_0x175e3f[_0x1954('0xd7')]&&_0x298344['forwardOffline']&&_0x298344[_0x1954('0xd8')]){var _0x8e0aeb=_0x175e3f[_0x1954('0xd9')]();return respondWithRpcPromise('SendMail',_0x1954('0xda'),{'account':_0x8e0aeb,'message':{'from':util[_0x1954('0xa3')]('\x22%s\x22\x20<%s>',_0x175e3f[_0x1954('0x2c')],_0x175e3f[_0x1954('0xdb')]||_0x175e3f[_0x1954('0xd7')]['user']),'to':_0x298344[_0x1954('0xd8')],'subject':_0x298344['offlineMessageSubject'],'html':_0x25a597[_0x1954('0x4f')],'attachments':_0x3d8e29}},client9003)[_0x1954('0x13')](function(){return _0x25a597;})[_0x1954('0x47')](function(_0x5c4799){logger[_0x1954('0x1a')](_0x5c4799);});}})[_0x1954('0x13')](function(){if(_0x298344&&_0x298344[_0x1954('0xd1')]&&_0x298344[_0x1954('0xdc')]){var _0x3d4613=[];if(_0x156d75['length']){_0x3d4613=_0x156d75[_0x1954('0x30')](function(_0x330ba0){return{'name':_0x330ba0[_0x1954('0xcb')],'basename':_0x330ba0[_0x1954('0x65')],'type':_0x330ba0[_0x1954('0xcc')],'ChatOfflineMessageId':_0x49a4f6['id']};});}var _0x3831f5;if(!_[_0x1954('0x70')](_0x298344[_0x1954('0xdd')])){var _0x250106=_[_0x1954('0x30')](_0x5ef57a['body'],function(_0x2de311){return _0x2de311;});var _0x5d994c=_[_0x1954('0xde')](_0x250106)[0x0];var _0x4cfbb0=_[_0x1954('0xdf')](_0x5d994c,function(_0x28f2ed){return _0x28f2ed;});_0x3831f5=_0x4cfbb0[0x1][_0x298344['subjectOffline']];}var _0x28cb18={'from':_0x56096e[_0x1954('0xdb')],'firstName':_0x56096e[_0x1954('0x9d')],'lastName':_0x56096e[_0x1954('0x9e')],'mapKey':_0x1954('0xdb'),'message':{'from':_0x56096e[_0x1954('0xdb')],'to':_0x298344[_0x1954('0xc1')][_0x1954('0xdb')],'cc':'','subject':_[_0x1954('0x70')](_0x3831f5)?_0x298344['offlineMessageSubject']:_0x3831f5,'messageId':'','sentAt':new Date(),'attach':_0x3d4613[_0x1954('0x3a')],'attachments':_0x3d4613,'originChannel':_0x1954('0xe0'),'ChatWebsiteId':_0x298344['id'],'ChatOfflineMessageId':_0x25a597['id'],'originTo':_0x298344['MailAccount'][_0x1954('0xdb')]},'body':_0x25a597[_0x1954('0x4f')]};var _0x4fe02c={'account':{'id':_0x298344[_0x1954('0xdc')]},'body':_0x28cb18,'log':_0x1954('0xe1')};return respondWithRpcPromise(_0x1954('0xe1'),_0x1954('0xe2'),_0x4fe02c,client9001)[_0x1954('0x13')](function(){return _0x25a597;})['catch'](function(_0x10d598){logger[_0x1954('0x1a')](_0x10d598);});}return;})[_0x1954('0x13')](function(){if(_0x25a597){return _0x25a597;}})[_0x1954('0x13')](respondWithResult(_0x193edc,null))['catch'](function(_0x2143f7){logger[_0x1954('0x1a')](_0x1954('0x47'),_0x2143f7);for(var _0x2ea338 of _0x156d75){var _0x1b0134=path[_0x1954('0x6c')](config['root'],'server',_0x1954('0xbd'),_0x1954('0xce'),_0x1954('0xcf'),_0x2ea338[_0x1954('0x65')]);fs_extra[_0x1954('0xe3')](_0x1b0134)[_0x1954('0x47')](function(_0x50a32f){logger[_0x1954('0x1a')](_0x1954('0xe4'),_0x1b0134,_0x50a32f);});}});};exports['addInteraction']=function(_0x830324,_0x38679b){return db['ChatInteraction'][_0x1954('0x4d')]({'where':{'id':_0x830324['params']['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x38679b,null))[_0x1954('0x13')](function(_0x5c7730){if(_0x5c7730){return _0x5c7730[_0x1954('0xe5')](_0x830324[_0x1954('0x4f')][_0x1954('0x5c')],_['omit'](_0x830324[_0x1954('0x4f')],[_0x1954('0x5c'),'id'])||{});}})[_0x1954('0x13')](respondWithResult(_0x38679b,null))[_0x1954('0x47')](handleError(_0x38679b,null));};exports[_0x1954('0xe6')]=function(_0x589e4c,_0x362613){var _0x44c349={'raw':![],'where':{}};var _0xdb47c={};var _0x1354b1={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x589e4c[_0x1954('0x49')]['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x362613,null))['then'](function(_0x4bb3d4){if(_0x4bb3d4){_0xdb47c[_0x1954('0x34')]=_[_0x1954('0x4b')](db[_0x1954('0xaa')]['rawAttributes']);_0xdb47c['query']=_[_0x1954('0x4b')](_0x589e4c[_0x1954('0x35')]);_0xdb47c[_0x1954('0x36')]=_[_0x1954('0x37')](_0xdb47c['model'],_0xdb47c['query']);_0x44c349[_0x1954('0x38')]=_[_0x1954('0x37')](_0xdb47c[_0x1954('0x34')],qs['fields'](_0x589e4c[_0x1954('0x35')]['fields']));_0x44c349['attributes']=_0x44c349[_0x1954('0x38')][_0x1954('0x3a')]?_0x44c349[_0x1954('0x38')]:_0xdb47c[_0x1954('0x34')];if(!_0x589e4c['query'][_0x1954('0x3b')](_0x1954('0x3c'))){_0x44c349['limit']=qs[_0x1954('0x23')](_0x589e4c[_0x1954('0x35')][_0x1954('0x23')]);_0x44c349[_0x1954('0x21')]=qs[_0x1954('0x21')](_0x589e4c['query'][_0x1954('0x21')]);}_0x44c349[_0x1954('0x3d')]=qs[_0x1954('0x3e')](_0x589e4c[_0x1954('0x35')][_0x1954('0x3e')]);_0x44c349[_0x1954('0x3f')]=qs[_0x1954('0x36')](_['pick'](_0x589e4c[_0x1954('0x35')],_0xdb47c[_0x1954('0x36')]));_0x44c349['where']['ChatWebsiteId']=_0x4bb3d4['id'];if(_0x589e4c[_0x1954('0x35')]['filter']){_0x44c349[_0x1954('0x3f')]=_[_0x1954('0x41')](_0x44c349[_0x1954('0x3f')],{'$or':_['map'](_0x44c349[_0x1954('0x38')],function(_0x3a854f){var _0xb34b4a={};_0xb34b4a[_0x3a854f]={'$like':'%'+_0x589e4c[_0x1954('0x35')]['filter']+'%'};return _0xb34b4a;})});}_0x44c349=_[_0x1954('0x41')]({},_0x44c349,_0x589e4c[_0x1954('0x43')]);return db[_0x1954('0xaa')][_0x1954('0x24')]({'where':_0x44c349['where']})[_0x1954('0x13')](function(_0x5b9a80){_0x1354b1[_0x1954('0x24')]=_0x5b9a80;if(_0x589e4c[_0x1954('0x35')]['includeAll']){_0x44c349['include']=[{'model':db[_0x1954('0x8e')],'as':_0x1954('0xe7'),'required':![]},{'model':db[_0x1954('0xb5')],'as':_0x1954('0xe8'),'attributes':[_0x1954('0x2c'),_0x1954('0xe9'),_0x1954('0xea')],'required':![]},{'model':db[_0x1954('0xeb')],'as':_0x1954('0xec'),'attributes':['id',_0x1954('0x2c'),'color'],'where':_0x589e4c[_0x1954('0x35')][_0x1954('0xed')]?{'id':_0x589e4c['query']['tag']}:undefined,'required':_0x589e4c[_0x1954('0x35')][_0x1954('0xed')]?!![]:![]}];}return db[_0x1954('0xaa')][_0x1954('0x45')](_0x44c349);})[_0x1954('0x13')](function(_0x26d756){_0x1354b1[_0x1954('0x46')]=_0x26d756;return _0x1354b1;});}})[_0x1954('0x13')](respondWithFilteredResult(_0x362613,_0x44c349))[_0x1954('0x47')](handleError(_0x362613,null));};function iftimePromise(_0x28317a,_0x35b30c){return respondWithRpcPromise(_0x1954('0xee'),_0x1954('0xef'),{'command':_0x35b30c['timezone']?util[_0x1954('0xa3')](_0x1954('0xf0'),_0x28317a[_0x1954('0xf1')],_0x35b30c[_0x1954('0xf2')]):util[_0x1954('0xa3')](_0x1954('0xf3'),_0x28317a['interval'])},client9002)[_0x1954('0x13')](function(_0x218e4e){var _0x23f847=_0x218e4e&&_0x218e4e[_0x1954('0xf4')](_0x1954('0xf5'))>=0x0?!![]:![];logger[_0x1954('0x14')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x35b30c['id'],_0x28317a['id'],_0x28317a[_0x1954('0xf1')],_0x23f847?_0x1954('0xf6'):'OFFLINE',_0x35b30c[_0x1954('0xf2')]?_0x35b30c[_0x1954('0xf2')]:_0x1954('0xf7'));return _0x23f847;})[_0x1954('0x47')](function(_0x29d6f8){logger['error'](_0x1954('0xf8'),_0x35b30c['id'],_0x28317a['id'],_0x28317a[_0x1954('0xf1')],util['inspect'](_0x29d6f8,{'showHidden':![],'depth':null}),_0x35b30c[_0x1954('0xf2')]?_0x35b30c['timezone']:_0x1954('0xf7'));return![];});}exports[_0x1954('0xef')]=function(_0x1e59cc,_0x3c251f){var _0x385d9f=0x0;var _0x4ce9b7=0x0;var _0x43f264=![];var _0x80ca92;var _0xddaa6b;return db[_0x1954('0x31')][_0x1954('0x4d')]({'where':{'id':_0x1e59cc[_0x1954('0x49')]['id']},'include':[{'model':db[_0x1954('0xf9')],'as':_0x1954('0xf9'),'include':[{'model':db[_0x1954('0xf9')],'as':_0x1954('0xfa'),'attributes':['id',_0x1954('0xf1')],'raw':!![]}]}]})['then'](handleEntityNotFound(_0x3c251f,null))[_0x1954('0x13')](function(_0x585e9b){if(_0x585e9b){_0x80ca92=_0x585e9b;return _0x585e9b[_0x1954('0xfb')]({'raw':!![]});}})[_0x1954('0x13')](function(_0x405994){if(_0x80ca92){if(_0x405994){_0xddaa6b=_0x405994;}}return require(_0x1954('0x6e'))[_0x1954('0x6f')]();})['then'](function(_0x120da1){if(_0x120da1){_0x4ce9b7=_0x120da1['virtual'];_0x43f264=_0x120da1[_0x1954('0xfc')];}})[_0x1954('0x13')](function(){return db[_0x1954('0xaa')][_0x1954('0x24')]({'where':{'closed':![]}});})['then'](function(_0x44c14b){_0x385d9f=_0x44c14b;if(_0x4ce9b7&&_0x44c14b>_0x4ce9b7){return db[_0x1954('0xfd')][_0x1954('0x5a')]({'where':{'id':0x1}})['then'](function(_0x20f5d8){if(_0x20f5d8){_0x20f5d8['increment'](_0x1954('0xfe'));}});}})[_0x1954('0x13')](function(){if(_0x80ca92[_0x1954('0xf9')]&&_0x80ca92[_0x1954('0xf9')][_0x1954('0xfa')]){var _0x314b70=[];for(var _0x2be35d=0x0;_0x2be35d<_0x80ca92[_0x1954('0xf9')][_0x1954('0xfa')]['length'];_0x2be35d++){var _0x3667e5=_0x80ca92[_0x1954('0xf9')][_0x1954('0xfa')][_0x2be35d][_0x1954('0x28')]({'plain':!![]});_0x314b70[_0x1954('0xb0')](iftimePromise(_0x3667e5,_0x80ca92));}return BPromise[_0x1954('0xff')](_0x314b70)[_0x1954('0x13')](function(_0xd3d533){return _[_0x1954('0x100')](_0xd3d533);});}else{return!![];}})[_0x1954('0x13')](function(_0x1ab43f){var _0xca964a=fs[_0x1954('0xc4')](path['join'](config[_0x1954('0x6d')],_0x1954('0x101')),'utf8');var _0x549cbe={'remote':_0x80ca92[_0x1954('0x102')],'query':querystring['stringify'](_[_0x1954('0x41')](_0x80ca92[_0x1954('0x28')]({'plain':!![]}),{'customerIp':_0x1e59cc[_0x1954('0x7b')][_0x1954('0x9a')]||_0x1e59cc[_0x1954('0x7b')][_0x1954('0x103')]||_0x1e59cc[_0x1954('0x104')][_0x1954('0x105')]||_0x1e59cc['ip'],'referer':_0x1e59cc[_0x1954('0x7b')][_0x1954('0xa0')],'openedInteractions':_0x385d9f,'maxInteractions':_0x4ce9b7,'virtual':_0x43f264[_0x1954('0x106')],'online':_0x1ab43f,'custom':_0x43f264}))[_0x1954('0x107')](/'/g,'\x5c\x27')};_0x3c251f[_0x1954('0x2d')](ejs[_0x1954('0xc7')](Mustache[_0x1954('0xc7')](_0xca964a,_0x549cbe),{'proactiveActions':_0xddaa6b,'alignment':_0x80ca92[_0x1954('0x108')],'verticalAlignment':_0x80ca92[_0x1954('0x109')],'div_color':_0x80ca92[_0x1954('0x10a')],'labelText':_0x80ca92['labelText'],'text_color':_0x80ca92['textColor'],'text_button_color':_0x80ca92[_0x1954('0x10b')],'button_color':_0x80ca92[_0x1954('0x10c')],'background_color':_0x80ca92[_0x1954('0x10d')],'hideWhenOffline':_0x80ca92[_0x1954('0x10e')],'interval':_0x80ca92[_0x1954('0x10f')]}));})[_0x1954('0x47')](handleError(_0x3c251f,null));};exports[_0x1954('0x110')]=function(_0x4f4c7a,_0x415210){var _0x2ab852=_0x4f4c7a[_0x1954('0x49')]['id'];var _0x4c95c2=_0x4f4c7a[_0x1954('0x4f')];var _0x9a8839=0xc8;var _0x3f2f87=null;return db[_0x1954('0xd2')][_0x1954('0xd3')]({'isolationLevel':db[_0x1954('0xd2')]['Transaction']['ISOLATION_LEVELS'][_0x1954('0x111')]},function(_0x5bc8f8){return db[_0x1954('0x31')][_0x1954('0x5a')]({'where':{'id':_0x2ab852},'transaction':_0x5bc8f8})[_0x1954('0x13')](function(_0x27febc){if(_0x27febc){return db['ChatApplication'][_0x1954('0x27')]({'where':{'ChatWebsiteId':_0x2ab852},'transaction':_0x5bc8f8})[_0x1954('0x13')](function(){var _0x503bfd=_['map'](_0x4c95c2,function(_0x479080){_0x479080[_0x1954('0x57')]=_0x2ab852;return _0x479080;});return db['ChatApplication'][_0x1954('0xd5')](_0x503bfd,{'transaction':_0x5bc8f8});});}else{_0x9a8839=0x194;_0x3f2f87=[];}});})[_0x1954('0x13')](function(){if(_0x9a8839!==0x194){return db[_0x1954('0x112')][_0x1954('0x113')]({'where':{'ChatWebsiteId':_0x2ab852},'order':_0x1954('0x95')})[_0x1954('0x13')](function(_0x3aade3){_0x3f2f87=_0x3aade3;});}})[_0x1954('0x47')](function(_0x43f729){_0x9a8839=0x1f4;logger['error'](_0x43f729[_0x1954('0x114')]);if(_0x43f729[_0x1954('0x2c')]){delete _0x43f729[_0x1954('0x2c')];}_0x3f2f87=_0x43f729;})[_0x1954('0x115')](function(){if(_0x3f2f87===null){_0x415210[_0x1954('0x1e')](_0x9a8839);}else{if(_0x9a8839===0x1f4){_0x415210['status'](_0x9a8839)[_0x1954('0x2d')](_0x3f2f87);}else{_0x415210[_0x1954('0x1f')](_0x9a8839)['json'](_0x3f2f87);}}});};exports[_0x1954('0x116')]=function(_0xd32798,_0x47c942){var _0x18c1ca={};var _0x399297={};var _0x5aaa4f;var _0x1e6a03;return db['ChatWebsite'][_0x1954('0x5a')]({'where':{'id':_0xd32798[_0x1954('0x49')]['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x47c942,null))[_0x1954('0x13')](function(_0x137a7a){if(_0x137a7a){_0x5aaa4f=_0x137a7a;_0x399297['model']=_['keys'](db[_0x1954('0x112')][_0x1954('0x4a')]);_0x399297[_0x1954('0x35')]=_[_0x1954('0x4b')](_0xd32798[_0x1954('0x35')]);_0x399297[_0x1954('0x36')]=_[_0x1954('0x37')](_0x399297[_0x1954('0x34')],_0x399297[_0x1954('0x35')]);_0x18c1ca[_0x1954('0x38')]=_[_0x1954('0x37')](_0x399297[_0x1954('0x34')],qs['fields'](_0xd32798[_0x1954('0x35')][_0x1954('0x39')]));_0x18c1ca[_0x1954('0x38')]=_0x18c1ca[_0x1954('0x38')][_0x1954('0x3a')]?_0x18c1ca[_0x1954('0x38')]:_0x399297[_0x1954('0x34')];_0x18c1ca['order']=qs[_0x1954('0x3e')](_0xd32798[_0x1954('0x35')]['sort']);_0x18c1ca['where']=qs[_0x1954('0x36')](_[_0x1954('0x60')](_0xd32798['query'],_0x399297[_0x1954('0x36')]));if(_0xd32798[_0x1954('0x35')][_0x1954('0x40')]){_0x18c1ca['where']=_[_0x1954('0x41')](_0x18c1ca[_0x1954('0x3f')],{'$or':_[_0x1954('0x30')](_0x18c1ca[_0x1954('0x38')],function(_0x359673){var _0x13652c={};_0x13652c[_0x359673]={'$like':'%'+_0xd32798[_0x1954('0x35')][_0x1954('0x40')]+'%'};return _0x13652c;})});}_0x18c1ca=_[_0x1954('0x41')]({},_0x18c1ca,_0xd32798[_0x1954('0x43')]);return _0x5aaa4f[_0x1954('0x116')](_0x18c1ca);}})['then'](function(_0x57a11f){if(_0x57a11f){_0x1e6a03=_0x57a11f[_0x1954('0x3a')];if(!_0xd32798['query'][_0x1954('0x3b')]('nolimit')){_0x18c1ca[_0x1954('0x23')]=qs[_0x1954('0x23')](_0xd32798['query']['limit']);_0x18c1ca[_0x1954('0x21')]=qs[_0x1954('0x21')](_0xd32798[_0x1954('0x35')][_0x1954('0x21')]);}return _0x5aaa4f['getApplications'](_0x18c1ca);}})[_0x1954('0x13')](function(_0x3b51cb){if(_0x3b51cb){return _0x3b51cb?{'count':_0x1e6a03,'rows':_0x3b51cb}:null;}})['then'](respondWithResult(_0x47c942,null))['catch'](handleError(_0x47c942,null));};exports[_0x1954('0x117')]=function(_0x5a4a43,_0x3318cf){return db[_0x1954('0x118')]['find']({'where':{'id':_0x5a4a43[_0x1954('0x49')]['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x3318cf,null))[_0x1954('0x13')](function(_0x529173){if(_0x529173){return _0x529173['addProactiveActions'](_0x5a4a43['body'][_0x1954('0x5c')],_[_0x1954('0x119')](_0x5a4a43[_0x1954('0x4f')],[_0x1954('0x5c'),'id'])||{});}})['then'](respondWithResult(_0x3318cf,null))[_0x1954('0x47')](handleError(_0x3318cf,null));};exports[_0x1954('0xfb')]=function(_0x4ea665,_0x543d67){var _0x46c2a0={};var _0xead347={};var _0x167064;var _0x5596f7;return db[_0x1954('0x31')][_0x1954('0x5a')]({'where':{'id':_0x4ea665['params']['id']}})['then'](handleEntityNotFound(_0x543d67,null))['then'](function(_0x1740e3){if(_0x1740e3){_0x167064=_0x1740e3;_0xead347[_0x1954('0x34')]=_['keys'](db[_0x1954('0x11a')]['rawAttributes']);_0xead347['query']=_[_0x1954('0x4b')](_0x4ea665[_0x1954('0x35')]);_0xead347['filters']=_[_0x1954('0x37')](_0xead347[_0x1954('0x34')],_0xead347[_0x1954('0x35')]);_0x46c2a0[_0x1954('0x38')]=_[_0x1954('0x37')](_0xead347['model'],qs[_0x1954('0x39')](_0x4ea665[_0x1954('0x35')][_0x1954('0x39')]));_0x46c2a0[_0x1954('0x38')]=_0x46c2a0[_0x1954('0x38')]['length']?_0x46c2a0[_0x1954('0x38')]:_0xead347['model'];_0x46c2a0[_0x1954('0x3d')]=qs['sort'](_0x4ea665[_0x1954('0x35')][_0x1954('0x3e')]);_0x46c2a0[_0x1954('0x3f')]=qs[_0x1954('0x36')](_['pick'](_0x4ea665[_0x1954('0x35')],_0xead347[_0x1954('0x36')]));if(_0x4ea665[_0x1954('0x35')][_0x1954('0x40')]){_0x46c2a0['where']=_[_0x1954('0x41')](_0x46c2a0[_0x1954('0x3f')],{'$or':_['map'](_0x46c2a0[_0x1954('0x38')],function(_0x212930){var _0x4ba24d={};_0x4ba24d[_0x212930]={'$like':'%'+_0x4ea665[_0x1954('0x35')]['filter']+'%'};return _0x4ba24d;})});}_0x46c2a0=_[_0x1954('0x41')]({},_0x46c2a0,_0x4ea665[_0x1954('0x43')]);return _0x167064[_0x1954('0xfb')](_0x46c2a0);}})[_0x1954('0x13')](function(_0x82944e){if(_0x82944e){_0x5596f7=_0x82944e[_0x1954('0x3a')];if(!_0x4ea665[_0x1954('0x35')][_0x1954('0x3b')]('nolimit')){_0x46c2a0[_0x1954('0x23')]=qs[_0x1954('0x23')](_0x4ea665[_0x1954('0x35')][_0x1954('0x23')]);_0x46c2a0[_0x1954('0x21')]=qs['offset'](_0x4ea665[_0x1954('0x35')]['offset']);}return _0x167064[_0x1954('0xfb')](_0x46c2a0);}})[_0x1954('0x13')](function(_0x4a4310){if(_0x4a4310){return _0x4a4310?{'count':_0x5596f7,'rows':_0x4a4310}:null;}})[_0x1954('0x13')](respondWithResult(_0x543d67,null))[_0x1954('0x47')](handleError(_0x543d67,null));};exports[_0x1954('0x11b')]=function(_0x2f2ae,_0x114d2f){var _0x505688=_0x2f2ae[_0x1954('0x35')][_0x1954('0x11c')]===_0x1954('0x11d')?'offlineForm':_0x1954('0x11e');return db[_0x1954('0x31')][_0x1954('0x4d')]({'attributes':['id',_0x505688],'where':{'id':_0x2f2ae[_0x1954('0x49')]['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x114d2f,null))[_0x1954('0x13')](function(_0x50d18b){if(_0x50d18b){var _0x48af1d=_0x50d18b[_0x505688];var _0x5bf99b=_0x48af1d&&_0x48af1d[_0x1954('0x11f')]?_0x48af1d[_0x1954('0x11f')]:[];_0x114d2f[_0x1954('0x2d')]({'fromKey':_[_0x1954('0x70')](_0x48af1d[_0x1954('0x120')])?undefined:_0x48af1d[_0x1954('0x120')],'count':_0x5bf99b['length'],'rows':_0x5bf99b});}})[_0x1954('0x47')](handleError(_0x114d2f,null));};exports['getOfflineMessages']=function(_0x45616d,_0x2fd1db){var _0x3daf6a={'raw':![],'where':{}};var _0x410457={};var _0x166220={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x1954('0x5a')]({'where':{'id':_0x45616d[_0x1954('0x49')]['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x2fd1db,null))[_0x1954('0x13')](function(_0x155fd3){if(_0x155fd3){_0x410457[_0x1954('0x34')]=_['keys'](db[_0x1954('0xc9')][_0x1954('0x4a')]);_0x410457[_0x1954('0x35')]=_[_0x1954('0x4b')](_0x45616d[_0x1954('0x35')]);_0x410457[_0x1954('0x36')]=_['intersection'](_0x410457[_0x1954('0x34')],_0x410457[_0x1954('0x35')]);_0x3daf6a[_0x1954('0x38')]=_[_0x1954('0x37')](_0x410457[_0x1954('0x34')],qs[_0x1954('0x39')](_0x45616d['query']['fields']));_0x3daf6a[_0x1954('0x38')]=_0x3daf6a['attributes'][_0x1954('0x3a')]?_0x3daf6a[_0x1954('0x38')]:_0x410457[_0x1954('0x34')];if(!_0x45616d[_0x1954('0x35')][_0x1954('0x3b')](_0x1954('0x3c'))){_0x3daf6a[_0x1954('0x23')]=qs[_0x1954('0x23')](_0x45616d[_0x1954('0x35')][_0x1954('0x23')]);_0x3daf6a[_0x1954('0x21')]=qs[_0x1954('0x21')](_0x45616d[_0x1954('0x35')][_0x1954('0x21')]);}_0x3daf6a[_0x1954('0x3d')]=qs[_0x1954('0x3e')](_0x45616d['query']['sort']);_0x3daf6a[_0x1954('0x3f')]=qs[_0x1954('0x36')](_[_0x1954('0x60')](_0x45616d[_0x1954('0x35')],_0x410457[_0x1954('0x36')]));_0x3daf6a['where']['ChatWebsiteId']=_0x155fd3['id'];if(_0x45616d[_0x1954('0x35')][_0x1954('0x40')]){_0x3daf6a[_0x1954('0x3f')]=_[_0x1954('0x41')](_0x3daf6a[_0x1954('0x3f')],{'$or':_[_0x1954('0x30')](_0x3daf6a[_0x1954('0x38')],function(_0x51a486){var _0x1acb4b={};_0x1acb4b[_0x51a486]={'$like':'%'+_0x45616d[_0x1954('0x35')][_0x1954('0x40')]+'%'};return _0x1acb4b;})});}_0x3daf6a=_['merge']({},_0x3daf6a,_0x45616d[_0x1954('0x43')]);return db[_0x1954('0xc9')][_0x1954('0x24')]({'where':_0x3daf6a[_0x1954('0x3f')]})['then'](function(_0x3e231a){_0x166220[_0x1954('0x24')]=_0x3e231a;if(_0x45616d['query'][_0x1954('0x4c')]){_0x3daf6a[_0x1954('0x44')]=[{'all':!![]}];}else{_0x3daf6a[_0x1954('0x44')]=[{'model':db[_0x1954('0x8e')],'as':'Contact','required':![]},{'model':db[_0x1954('0xd4')],'as':_0x1954('0x121'),'required':![]}];}return db['ChatOfflineMessage'][_0x1954('0x45')](_0x3daf6a);})[_0x1954('0x13')](function(_0x5a49f4){_0x166220[_0x1954('0x46')]=_0x5a49f4;return _0x166220;});}})['then'](respondWithFilteredResult(_0x2fd1db,_0x3daf6a))['catch'](handleError(_0x2fd1db,null));};exports[_0x1954('0x122')]=function(_0x5cc756,_0x14dc4f){return db['ChatWebsite']['find']({'where':{'id':_0x5cc756[_0x1954('0x49')]['id']}})[_0x1954('0x13')](handleEntityNotFound(_0x14dc4f,null))[_0x1954('0x13')](function(_0x145c3a){if(_0x145c3a){return _0x145c3a[_0x1954('0x122')](_0x5cc756[_0x1954('0x4f')]['ids'],_[_0x1954('0x119')](_0x5cc756[_0x1954('0x4f')],['ids','id'])||{})[_0x1954('0xc3')](function(_0x27e581){for(var _0xc0c45c=0x0;_0xc0c45c<_0x5cc756[_0x1954('0x4f')][_0x1954('0x5c')]['length'];_0xc0c45c+=0x1){socket['emit'](_0x1954('0x123'),{'UserId':Number(_0x5cc756[_0x1954('0x4f')][_0x1954('0x5c')][_0xc0c45c]),'ChatWebsiteId':Number(_0x5cc756[_0x1954('0x49')]['id'])});}return _0x27e581;});}})[_0x1954('0x13')](respondWithResult(_0x14dc4f,null))[_0x1954('0x47')](handleError(_0x14dc4f,null));};exports[_0x1954('0x124')]=function(_0x484f6a,_0x171c41){return db['ChatWebsite'][_0x1954('0x4d')]({'where':{'id':_0x484f6a[_0x1954('0x49')]['id']}})['then'](handleEntityNotFound(_0x171c41,null))[_0x1954('0x13')](function(_0x2699e0){if(_0x2699e0){return _0x2699e0['removeAgents'](_0x484f6a[_0x1954('0x35')]['ids'])[_0x1954('0x13')](function(){if(_['isArray'](_0x484f6a[_0x1954('0x35')][_0x1954('0x5c')])){for(var _0x345d2f=0x0;_0x345d2f<_0x484f6a[_0x1954('0x35')][_0x1954('0x5c')]['length'];_0x345d2f+=0x1){socket['emit'](_0x1954('0x125'),{'UserId':Number(_0x484f6a['query'][_0x1954('0x5c')][_0x345d2f]),'ChatWebsiteId':Number(_0x484f6a[_0x1954('0x49')]['id'])});}}else{socket[_0x1954('0x126')](_0x1954('0x125'),{'UserId':Number(_0x484f6a[_0x1954('0x35')][_0x1954('0x5c')]),'ChatWebsiteId':Number(_0x484f6a[_0x1954('0x49')]['id'])});}});}})['then'](respondWithStatusCode(_0x171c41,null))['catch'](handleError(_0x171c41,null));};exports[_0x1954('0x127')]=function(_0x171ab5,_0x5c7b5d){var _0x48748d={};var _0x269b38={};var _0x5324bd;var _0x1c2764;return db['ChatWebsite'][_0x1954('0x5a')]({'where':{'id':_0x171ab5['params']['id']}})['then'](handleEntityNotFound(_0x5c7b5d,null))[_0x1954('0x13')](function(_0x18bfa1){if(_0x18bfa1){_0x5324bd=_0x18bfa1;_0x269b38[_0x1954('0x34')]=_[_0x1954('0x4b')](db[_0x1954('0xb5')][_0x1954('0x4a')]);_0x269b38[_0x1954('0x35')]=_['keys'](_0x171ab5[_0x1954('0x35')]);_0x269b38[_0x1954('0x36')]=_[_0x1954('0x37')](_0x269b38[_0x1954('0x34')],_0x269b38['query']);_0x48748d[_0x1954('0x38')]=_['intersection'](_0x269b38[_0x1954('0x34')],qs[_0x1954('0x39')](_0x171ab5[_0x1954('0x35')]['fields']));_0x48748d[_0x1954('0x38')]=_0x48748d[_0x1954('0x38')]['length']?_0x48748d[_0x1954('0x38')]:_0x269b38['model'];_0x48748d[_0x1954('0x3d')]=qs[_0x1954('0x3e')](_0x171ab5[_0x1954('0x35')][_0x1954('0x3e')]);_0x48748d[_0x1954('0x3f')]=qs['filters'](_[_0x1954('0x60')](_0x171ab5[_0x1954('0x35')],_0x269b38['filters']));if(_0x171ab5[_0x1954('0x35')][_0x1954('0x40')]){_0x48748d[_0x1954('0x3f')]=_[_0x1954('0x41')](_0x48748d['where'],{'$or':_[_0x1954('0x30')](_0x48748d['attributes'],function(_0x326d2b){var _0x59de5d={};_0x59de5d[_0x326d2b]={'$like':'%'+_0x171ab5['query'][_0x1954('0x40')]+'%'};return _0x59de5d;})});}_0x48748d=_[_0x1954('0x41')]({},_0x48748d,_0x171ab5[_0x1954('0x43')]);return _0x5324bd[_0x1954('0x127')](_0x48748d);}})['then'](function(_0x451093){if(_0x451093){_0x1c2764=_0x451093['length'];if(!_0x171ab5[_0x1954('0x35')]['hasOwnProperty'](_0x1954('0x3c'))){_0x48748d['limit']=qs[_0x1954('0x23')](_0x171ab5[_0x1954('0x35')][_0x1954('0x23')]);_0x48748d['offset']=qs['offset'](_0x171ab5['query'][_0x1954('0x21')]);}return _0x5324bd[_0x1954('0x127')](_0x48748d);}})[_0x1954('0x13')](function(_0x5884c7){if(_0x5884c7){return _0x5884c7?{'count':_0x1c2764,'rows':_0x5884c7}:null;}})[_0x1954('0x13')](respondWithResult(_0x5c7b5d,null))[_0x1954('0x47')](handleError(_0x5c7b5d,null));};
\ No newline at end of file