Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 379ea8b..aecc4e0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf030=['x-real-ip','connection','replace','alignment','color','labelText','textButtonColor','color_button','backgroundColor','Transaction','ISOLATION_LEVELS','READ_COMMITTED','findAndCountAll','getApplications','addProactiveActions','chatProactiveAction','getFields','online','false','offlineForm','items','fromKey','getOfflineMessages','Attachments','addAgents','userChatWebsite:save','removeAgents','emit','userChatWebsite:remove','getAgents','mustache','util','path','ejs','fs-extra','lodash','querystring','../../components/parsers/qs','../../config/logger','api','redis','localhost','socket.io-emitter','register','html-to-text','jayson/promise','http','client','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','json','undefined','limit','count','offset','set','Content-Range','update','destroy','ChatWebsites','UserProfileResource','end','stack','name','send','index','mandatoryDispositionPause','map','ChatWebsite','fieldName','type','key','model','keys','query','filters','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','includeAll','findAll','rows','show','Pause','rawAttributes','intersection','find','create','user','role','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','findOne','length','include','removeDispositions','ids','addAnswer','CannedAnswer','removeAnswers','addLogo','sitepic','file','filename','addAvatar','addCustomerAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','getLicense','isNil','existsSync','server/files/images/logos/','download','getAvatar','server/files/images/avatars/default_avatar.png','agentAvatar','server/files/images/avatars/','server/files/images/avatars/customer_avatar.png','customerAvatar','showCustomerAvatar','server/files/images/avatars/system_avatar.png','notify','user-agent-parser','headers','getResult','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','ListId','from','body\x20is\x20mandatory\x20and\x20not\x20empty','Sequelize','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','mapKey','CmList','List','CmContact','Contacts','ChatApplication','Applications','account','applications','list','orderBy','priority','asc','defaults','cf-connecting-ip','first','x-forwarded-for','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','spread','contact','messageId','get','created','autoclose','push','close','ChatMessage','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','Start','startRouting','EventManager','offline','files','CompanyId','from\x20is\x20mandatory','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','findOrCreate','readFileSync','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','fromString','originalname','mimetype','server','sequelize','transaction','Attachment','bulkCreate','MailAccount','MailServerOut','CloudProvider','Smtp','forwardOffline','forwardOfflineAddress','SendMail','sendMail','\x22%s\x22\x20<%s>','email','openNewInteraction','MailAccountId','subjectOffline','toPairsIn','mapValues','Chat','NotifyMailAccount','notifyMail','attachments','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','fullname','internal','Tag','Tags','tag','Command','getSnippet','timezone','interval','iftime\x20%s','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','inspect','No\x20timezone','Interval','Intervals','getProactiveActions','../../config/license/util','custom','License','increment','chatLicenseExceeded','server/files/chat/iframe.ejs','remote'];(function(_0xd7a30,_0x5890d2){var _0x445a54=function(_0x3506df){while(--_0x3506df){_0xd7a30['push'](_0xd7a30['shift']());}};_0x445a54(++_0x5890d2);}(_0xf030,0x146));var _0x0f03=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xf030[_0x321bb2];return _0x9c12ed;};'use strict';var BPromise=require('bluebird');var Mustache=require(_0x0f03('0x0'));var util=require(_0x0f03('0x1'));var path=require(_0x0f03('0x2'));var ejs=require(_0x0f03('0x3'));var fs=require('fs');var fs_extra=require(_0x0f03('0x4'));var _=require(_0x0f03('0x5'));var querystring=require(_0x0f03('0x6'));var Redis=require('ioredis');var qs=require(_0x0f03('0x7'));var logger=require(_0x0f03('0x8'))(_0x0f03('0x9'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config['redis']=_['defaults'](config[_0x0f03('0xa')],{'host':_0x0f03('0xb'),'port':0x18eb});var socket=require(_0x0f03('0xc'))(new Redis(config[_0x0f03('0xa')]));require('./chatWebsite.socket')[_0x0f03('0xd')](socket);var htmlToText=require(_0x0f03('0xe'));var jayson=require(_0x0f03('0xf'));var client=jayson['client'][_0x0f03('0x10')]({'port':0x232c});var client9002=jayson[_0x0f03('0x11')][_0x0f03('0x10')]({'port':0x232a});var client9003=jayson[_0x0f03('0x11')][_0x0f03('0x10')]({'port':0x232b});var client9001=jayson[_0x0f03('0x11')][_0x0f03('0x10')]({'port':0x2329});function respondWithRpcPromise(_0x5e30b4,_0x232bcf,_0x479e37,_0x1a5354){return new BPromise(function(_0x50583c,_0x407e4f){var _0xe6e1a9=_0x1a5354||client;return _0xe6e1a9['request'](_0x5e30b4,_0x479e37)[_0x0f03('0x12')](function(_0x4aaf8d){logger[_0x0f03('0x13')](_0x0f03('0x14'),_0x232bcf,_0x0f03('0x15'));logger[_0x0f03('0x16')](_0x0f03('0x17'),_0x232bcf,'request\x20sent',JSON[_0x0f03('0x18')](_0x4aaf8d));if(_0x4aaf8d[_0x0f03('0x19')]){if(_0x4aaf8d[_0x0f03('0x19')][_0x0f03('0x1a')]===0x1f4){logger[_0x0f03('0x19')](_0x0f03('0x14'),_0x232bcf,_0x4aaf8d[_0x0f03('0x19')]['message']);return _0x407e4f(_0x4aaf8d[_0x0f03('0x19')]['message']);}logger['error'](_0x0f03('0x14'),_0x232bcf,_0x4aaf8d[_0x0f03('0x19')][_0x0f03('0x1b')]);return _0x50583c(_0x4aaf8d['error']['message']);}else{logger[_0x0f03('0x13')]('ChatWebsite,\x20%s,\x20%s',_0x232bcf,_0x0f03('0x15'));_0x50583c(_0x4aaf8d[_0x0f03('0x1c')][_0x0f03('0x1b')]);}})[_0x0f03('0x1d')](function(_0x1c3b59){logger[_0x0f03('0x19')](_0x0f03('0x14'),_0x232bcf,_0x1c3b59);_0x407e4f(_0x1c3b59);});});}function respondWithStatusCode(_0x16a0a2,_0x14ade4){_0x14ade4=_0x14ade4||0xcc;return function(_0x4fb7ca){if(_0x4fb7ca){return _0x16a0a2[_0x0f03('0x1e')](_0x14ade4);}return _0x16a0a2['status'](_0x14ade4)['end']();};}function respondWithResult(_0x99a3c0,_0x332e73){_0x332e73=_0x332e73||0xc8;return function(_0x2a9063){if(_0x2a9063){return _0x99a3c0[_0x0f03('0x1f')](_0x332e73)[_0x0f03('0x20')](_0x2a9063);}};}function respondWithFilteredResult(_0x198a70,_0x160216){return function(_0x573108){if(_0x573108){var _0x3d9c4f=typeof _0x160216['offset']===_0x0f03('0x21')&&typeof _0x160216[_0x0f03('0x22')]===_0x0f03('0x21');var _0x385135=_0x573108[_0x0f03('0x23')];var _0x59e7b9=_0x3d9c4f?0x0:_0x160216[_0x0f03('0x24')];var _0xa208a5=_0x3d9c4f?_0x573108[_0x0f03('0x23')]:_0x160216[_0x0f03('0x24')]+_0x160216[_0x0f03('0x22')];var _0x5625b0;if(_0xa208a5>=_0x385135){_0xa208a5=_0x385135;_0x5625b0=0xc8;}else{_0x5625b0=0xce;}_0x198a70[_0x0f03('0x1f')](_0x5625b0);return _0x198a70[_0x0f03('0x25')](_0x0f03('0x26'),_0x59e7b9+'-'+_0xa208a5+'/'+_0x385135)['json'](_0x573108);}return null;};}function saveUpdates(_0x27a486){return function(_0x35babf){if(_0x35babf){return _0x35babf[_0x0f03('0x27')](_0x27a486)['then'](function(_0x59bb60){return _0x59bb60;});}return null;};}function removeEntity(_0x4bce32){return function(_0x4ee15d){if(_0x4ee15d){return _0x4ee15d[_0x0f03('0x28')]()[_0x0f03('0x12')](function(){var _0x1240b6=_0x4ee15d['get']({'plain':!![]});var _0xfecd3e=_0x0f03('0x29');return db[_0x0f03('0x2a')]['destroy']({'where':{'type':_0xfecd3e,'resourceId':_0x1240b6['id']}})['then'](function(){return _0x4ee15d;});})[_0x0f03('0x12')](function(){_0x4bce32[_0x0f03('0x1f')](0xcc)[_0x0f03('0x2b')]();});}};}function handleEntityNotFound(_0x282fa7){return function(_0x540065){if(!_0x540065){_0x282fa7[_0x0f03('0x1e')](0x194);}return _0x540065;};}function handleError(_0x5a9c3b,_0x293eb0){_0x293eb0=_0x293eb0||0x1f4;return function(_0x4cad99){logger['error'](_0x4cad99[_0x0f03('0x2c')]);if(_0x4cad99['name']){delete _0x4cad99[_0x0f03('0x2d')];}_0x5a9c3b['status'](_0x293eb0)[_0x0f03('0x2e')](_0x4cad99);};}exports[_0x0f03('0x2f')]=function(_0x1882e1,_0x1aa90a){var _0x4e57c5={'include':[{'model':db['Pause'],'as':_0x0f03('0x30')}]},_0x2c921c={},_0x24f044={'count':0x0,'rows':[]};var _0x5c1dfb=_[_0x0f03('0x31')](db[_0x0f03('0x32')]['rawAttributes'],function(_0x393070){return{'name':_0x393070[_0x0f03('0x33')],'type':_0x393070[_0x0f03('0x34')][_0x0f03('0x35')]};});_0x2c921c[_0x0f03('0x36')]=_[_0x0f03('0x31')](_0x5c1dfb,_0x0f03('0x2d'));_0x2c921c['query']=_[_0x0f03('0x37')](_0x1882e1[_0x0f03('0x38')]);_0x2c921c[_0x0f03('0x39')]=_['intersection'](_0x2c921c[_0x0f03('0x36')],_0x2c921c[_0x0f03('0x38')]);_0x4e57c5[_0x0f03('0x3a')]=_['intersection'](_0x2c921c[_0x0f03('0x36')],qs[_0x0f03('0x3b')](_0x1882e1[_0x0f03('0x38')][_0x0f03('0x3b')]));_0x4e57c5['attributes']=_0x4e57c5[_0x0f03('0x3a')]['length']?_0x4e57c5[_0x0f03('0x3a')]:_0x2c921c[_0x0f03('0x36')];if(!_0x1882e1[_0x0f03('0x38')][_0x0f03('0x3c')](_0x0f03('0x3d'))){_0x4e57c5[_0x0f03('0x22')]=qs['limit'](_0x1882e1['query'][_0x0f03('0x22')]);_0x4e57c5[_0x0f03('0x24')]=qs[_0x0f03('0x24')](_0x1882e1[_0x0f03('0x38')][_0x0f03('0x24')]);}_0x4e57c5[_0x0f03('0x3e')]=qs[_0x0f03('0x3f')](_0x1882e1[_0x0f03('0x38')][_0x0f03('0x3f')]);_0x4e57c5[_0x0f03('0x40')]=qs[_0x0f03('0x39')](_[_0x0f03('0x41')](_0x1882e1['query'],_0x2c921c[_0x0f03('0x39')]),_0x5c1dfb);if(_0x1882e1['query'][_0x0f03('0x42')]){_0x4e57c5[_0x0f03('0x40')]=_[_0x0f03('0x43')](_0x4e57c5[_0x0f03('0x40')],{'$or':_['map'](_0x5c1dfb,function(_0x34cd18){if(_0x34cd18[_0x0f03('0x34')]!=='VIRTUAL'){var _0x1030d6={};_0x1030d6[_0x34cd18[_0x0f03('0x2d')]]={'$like':'%'+_0x1882e1[_0x0f03('0x38')]['filter']+'%'};return _0x1030d6;}})});}_0x4e57c5=_['merge']({},_0x4e57c5,_0x1882e1[_0x0f03('0x44')]);var _0x279291={'where':_0x4e57c5[_0x0f03('0x40')]};return db[_0x0f03('0x32')]['count'](_0x279291)[_0x0f03('0x12')](function(_0x250a05){_0x24f044['count']=_0x250a05;if(_0x1882e1[_0x0f03('0x38')][_0x0f03('0x45')]){_0x4e57c5['include']=[{'all':!![]}];}return db['ChatWebsite'][_0x0f03('0x46')](_0x4e57c5);})[_0x0f03('0x12')](function(_0x32073a){_0x24f044[_0x0f03('0x47')]=_0x32073a;return _0x24f044;})[_0x0f03('0x12')](respondWithFilteredResult(_0x1aa90a,_0x4e57c5))[_0x0f03('0x1d')](handleError(_0x1aa90a,null));};exports[_0x0f03('0x48')]=function(_0x16a0d5,_0x37d7dd){var _0x2e6771={'raw':![],'where':{'id':_0x16a0d5['params']['id']},'include':[{'model':db[_0x0f03('0x49')],'as':'mandatoryDispositionPause'}]},_0x4dc994={};_0x4dc994[_0x0f03('0x36')]=_[_0x0f03('0x37')](db['ChatWebsite'][_0x0f03('0x4a')]);_0x4dc994[_0x0f03('0x38')]=_[_0x0f03('0x37')](_0x16a0d5[_0x0f03('0x38')]);_0x4dc994['filters']=_[_0x0f03('0x4b')](_0x4dc994[_0x0f03('0x36')],_0x4dc994[_0x0f03('0x38')]);_0x2e6771['attributes']=_[_0x0f03('0x4b')](_0x4dc994['model'],qs[_0x0f03('0x3b')](_0x16a0d5['query'][_0x0f03('0x3b')]));_0x2e6771[_0x0f03('0x3a')]=_0x2e6771[_0x0f03('0x3a')]['length']?_0x2e6771[_0x0f03('0x3a')]:_0x4dc994[_0x0f03('0x36')];if(_0x16a0d5[_0x0f03('0x38')][_0x0f03('0x45')]){_0x2e6771['include']=[{'all':!![]}];}_0x2e6771=_[_0x0f03('0x43')]({},_0x2e6771,_0x16a0d5[_0x0f03('0x44')]);return db['ChatWebsite'][_0x0f03('0x4c')](_0x2e6771)['then'](handleEntityNotFound(_0x37d7dd,null))[_0x0f03('0x12')](respondWithResult(_0x37d7dd,null))['catch'](handleError(_0x37d7dd,null));};exports['create']=function(_0x40b72f,_0x873d83){return db['ChatWebsite'][_0x0f03('0x4d')](_0x40b72f['body'],{})['then'](function(_0x5b3d16){var _0x4a1cac=_0x40b72f[_0x0f03('0x4e')]['get']({'plain':!![]});if(!_0x4a1cac)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4a1cac[_0x0f03('0x4f')]===_0x0f03('0x4e')){var _0x5e2c2d=_0x5b3d16['get']({'plain':!![]});var _0x360993=_0x0f03('0x29');return db[_0x0f03('0x50')][_0x0f03('0x4c')]({'where':{'name':_0x360993,'userProfileId':_0x4a1cac[_0x0f03('0x51')]},'raw':!![]})['then'](function(_0x2ed190){if(_0x2ed190&&_0x2ed190['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0x5e2c2d[_0x0f03('0x2d')],'resourceId':_0x5e2c2d['id'],'type':_0x2ed190[_0x0f03('0x2d')],'sectionId':_0x2ed190['id']},{})['then'](function(){return _0x5b3d16;});}else{return _0x5b3d16;}})[_0x0f03('0x1d')](function(_0x12685f){logger['error'](_0x0f03('0x52'),_0x12685f);throw _0x12685f;});}return _0x5b3d16;})['then'](respondWithResult(_0x873d83,0xc9))[_0x0f03('0x1d')](handleError(_0x873d83,null));};exports['update']=function(_0x3975d3,_0x1def90){if(_0x3975d3[_0x0f03('0x53')]['id']){delete _0x3975d3[_0x0f03('0x53')]['id'];}return db[_0x0f03('0x32')][_0x0f03('0x4c')]({'where':{'id':_0x3975d3[_0x0f03('0x54')]['id']},'include':[{'model':db['Pause'],'as':_0x0f03('0x30')}]})[_0x0f03('0x12')](handleEntityNotFound(_0x1def90,null))[_0x0f03('0x12')](saveUpdates(_0x3975d3[_0x0f03('0x53')],null))[_0x0f03('0x12')](respondWithResult(_0x1def90,null))['catch'](handleError(_0x1def90,null));};exports[_0x0f03('0x28')]=function(_0x4727bc,_0x59e83c){return db[_0x0f03('0x32')][_0x0f03('0x4c')]({'where':{'id':_0x4727bc[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x59e83c,null))[_0x0f03('0x12')](removeEntity(_0x59e83c,null))['catch'](handleError(_0x59e83c,null));};exports[_0x0f03('0x55')]=function(_0x201022,_0x5d48d8){return db[_0x0f03('0x32')]['describe']()[_0x0f03('0x12')](respondWithResult(_0x5d48d8,null))[_0x0f03('0x1d')](handleError(_0x5d48d8,null));};exports[_0x0f03('0x56')]=function(_0x195d85,_0x5cdb2d){if(_0x195d85[_0x0f03('0x53')]['id']){delete _0x195d85[_0x0f03('0x53')]['id'];}return db[_0x0f03('0x32')][_0x0f03('0x4c')]({'where':{'id':_0x195d85['params']['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x5cdb2d,null))['then'](function(_0x2f6cd8){if(_0x2f6cd8){_0x195d85[_0x0f03('0x53')][_0x0f03('0x57')]=_0x2f6cd8['id'];return db[_0x0f03('0x58')][_0x0f03('0x4d')](_0x195d85[_0x0f03('0x53')]);}})[_0x0f03('0x12')](respondWithResult(_0x5cdb2d,null))[_0x0f03('0x1d')](handleError(_0x5cdb2d,null));};exports[_0x0f03('0x59')]=function(_0x350f81,_0x5370ba){var _0x3ee2f3={'raw':![],'where':{}};var _0x10471f={};var _0x1a9efc={'count':0x0,'rows':[]};return db[_0x0f03('0x32')][_0x0f03('0x5a')]({'where':{'id':_0x350f81[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x5370ba,null))[_0x0f03('0x12')](function(_0xf9e016){if(_0xf9e016){_0x10471f['model']=_[_0x0f03('0x37')](db[_0x0f03('0x58')]['rawAttributes']);_0x10471f['query']=_['keys'](_0x350f81[_0x0f03('0x38')]);_0x10471f[_0x0f03('0x39')]=_[_0x0f03('0x4b')](_0x10471f[_0x0f03('0x36')],_0x10471f[_0x0f03('0x38')]);_0x3ee2f3[_0x0f03('0x3a')]=_[_0x0f03('0x4b')](_0x10471f[_0x0f03('0x36')],qs[_0x0f03('0x3b')](_0x350f81['query'][_0x0f03('0x3b')]));_0x3ee2f3['attributes']=_0x3ee2f3['attributes'][_0x0f03('0x5b')]?_0x3ee2f3[_0x0f03('0x3a')]:_0x10471f[_0x0f03('0x36')];if(!_0x350f81[_0x0f03('0x38')][_0x0f03('0x3c')](_0x0f03('0x3d'))){_0x3ee2f3[_0x0f03('0x22')]=qs['limit'](_0x350f81[_0x0f03('0x38')][_0x0f03('0x22')]);_0x3ee2f3[_0x0f03('0x24')]=qs[_0x0f03('0x24')](_0x350f81[_0x0f03('0x38')][_0x0f03('0x24')]);}_0x3ee2f3[_0x0f03('0x3e')]=qs[_0x0f03('0x3f')](_0x350f81[_0x0f03('0x38')]['sort']);_0x3ee2f3[_0x0f03('0x40')]=qs[_0x0f03('0x39')](_[_0x0f03('0x41')](_0x350f81[_0x0f03('0x38')],_0x10471f[_0x0f03('0x39')]));_0x3ee2f3[_0x0f03('0x40')][_0x0f03('0x57')]=_0xf9e016['id'];if(_0x350f81[_0x0f03('0x38')][_0x0f03('0x42')]){_0x3ee2f3['where']=_['merge'](_0x3ee2f3[_0x0f03('0x40')],{'$or':_[_0x0f03('0x31')](_0x3ee2f3[_0x0f03('0x3a')],function(_0xbbb4ef){var _0x5cb1a2={};_0x5cb1a2[_0xbbb4ef]={'$like':'%'+_0x350f81['query'][_0x0f03('0x42')]+'%'};return _0x5cb1a2;})});}_0x3ee2f3=_[_0x0f03('0x43')]({},_0x3ee2f3,_0x350f81[_0x0f03('0x44')]);return db[_0x0f03('0x58')][_0x0f03('0x23')]({'where':_0x3ee2f3[_0x0f03('0x40')]})['then'](function(_0x16818c){_0x1a9efc[_0x0f03('0x23')]=_0x16818c;if(_0x350f81[_0x0f03('0x38')][_0x0f03('0x45')]){_0x3ee2f3[_0x0f03('0x5c')]=[{'all':!![]}];}return db[_0x0f03('0x58')][_0x0f03('0x46')](_0x3ee2f3);})[_0x0f03('0x12')](function(_0xca49bd){_0x1a9efc[_0x0f03('0x47')]=_0xca49bd;return _0x1a9efc;});}})['then'](respondWithFilteredResult(_0x5370ba,_0x3ee2f3))[_0x0f03('0x1d')](handleError(_0x5370ba,null));};exports[_0x0f03('0x5d')]=function(_0x2cbb57,_0x393916){return db[_0x0f03('0x32')][_0x0f03('0x4c')]({'where':{'id':_0x2cbb57['params']['id']}})['then'](handleEntityNotFound(_0x393916,null))[_0x0f03('0x12')](function(_0x275ef0){if(_0x275ef0){return _0x275ef0['removeDispositions'](_0x2cbb57['query'][_0x0f03('0x5e')]);}})[_0x0f03('0x12')](respondWithStatusCode(_0x393916,null))[_0x0f03('0x1d')](handleError(_0x393916,null));};exports[_0x0f03('0x5f')]=function(_0x69646c,_0x1048f3){if(_0x69646c['body']['id']){delete _0x69646c[_0x0f03('0x53')]['id'];}return db[_0x0f03('0x32')][_0x0f03('0x4c')]({'where':{'id':_0x69646c[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x1048f3,null))[_0x0f03('0x12')](function(_0x56541b){if(_0x56541b){_0x69646c['body']['ChatWebsiteId']=_0x56541b['id'];return db[_0x0f03('0x60')][_0x0f03('0x4d')](_0x69646c[_0x0f03('0x53')]);}})[_0x0f03('0x12')](respondWithResult(_0x1048f3,null))[_0x0f03('0x1d')](handleError(_0x1048f3,null));};exports['getAnswers']=function(_0x25666b,_0x357c00){var _0x42d822={'raw':![],'where':{}};var _0x3f5e6a={};var _0x237a0f={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x0f03('0x5a')]({'where':{'id':_0x25666b[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x357c00,null))[_0x0f03('0x12')](function(_0x20ecd2){if(_0x20ecd2){_0x3f5e6a[_0x0f03('0x36')]=_[_0x0f03('0x37')](db[_0x0f03('0x60')][_0x0f03('0x4a')]);_0x3f5e6a[_0x0f03('0x38')]=_['keys'](_0x25666b[_0x0f03('0x38')]);_0x3f5e6a[_0x0f03('0x39')]=_[_0x0f03('0x4b')](_0x3f5e6a[_0x0f03('0x36')],_0x3f5e6a[_0x0f03('0x38')]);_0x42d822[_0x0f03('0x3a')]=_[_0x0f03('0x4b')](_0x3f5e6a[_0x0f03('0x36')],qs[_0x0f03('0x3b')](_0x25666b[_0x0f03('0x38')][_0x0f03('0x3b')]));_0x42d822[_0x0f03('0x3a')]=_0x42d822[_0x0f03('0x3a')][_0x0f03('0x5b')]?_0x42d822['attributes']:_0x3f5e6a[_0x0f03('0x36')];if(!_0x25666b[_0x0f03('0x38')]['hasOwnProperty']('nolimit')){_0x42d822[_0x0f03('0x22')]=qs[_0x0f03('0x22')](_0x25666b[_0x0f03('0x38')][_0x0f03('0x22')]);_0x42d822['offset']=qs[_0x0f03('0x24')](_0x25666b['query'][_0x0f03('0x24')]);}_0x42d822[_0x0f03('0x3e')]=qs[_0x0f03('0x3f')](_0x25666b[_0x0f03('0x38')][_0x0f03('0x3f')]);_0x42d822['where']=qs[_0x0f03('0x39')](_[_0x0f03('0x41')](_0x25666b[_0x0f03('0x38')],_0x3f5e6a[_0x0f03('0x39')]));_0x42d822[_0x0f03('0x40')][_0x0f03('0x57')]=_0x20ecd2['id'];if(_0x25666b[_0x0f03('0x38')][_0x0f03('0x42')]){_0x42d822['where']=_[_0x0f03('0x43')](_0x42d822[_0x0f03('0x40')],{'$or':_[_0x0f03('0x31')](_0x42d822[_0x0f03('0x3a')],function(_0xd03fc8){var _0x5c4e62={};_0x5c4e62[_0xd03fc8]={'$like':'%'+_0x25666b[_0x0f03('0x38')][_0x0f03('0x42')]+'%'};return _0x5c4e62;})});}_0x42d822=_[_0x0f03('0x43')]({},_0x42d822,_0x25666b['options']);return db[_0x0f03('0x60')][_0x0f03('0x23')]({'where':_0x42d822['where']})[_0x0f03('0x12')](function(_0x118599){_0x237a0f[_0x0f03('0x23')]=_0x118599;if(_0x25666b[_0x0f03('0x38')][_0x0f03('0x45')]){_0x42d822[_0x0f03('0x5c')]=[{'all':!![]}];}return db[_0x0f03('0x60')][_0x0f03('0x46')](_0x42d822);})[_0x0f03('0x12')](function(_0x5dffc3){_0x237a0f[_0x0f03('0x47')]=_0x5dffc3;return _0x237a0f;});}})[_0x0f03('0x12')](respondWithFilteredResult(_0x357c00,_0x42d822))[_0x0f03('0x1d')](handleError(_0x357c00,null));};exports[_0x0f03('0x61')]=function(_0x1530c1,_0x393d97){return db['ChatWebsite'][_0x0f03('0x4c')]({'where':{'id':_0x1530c1['params']['id']}})['then'](handleEntityNotFound(_0x393d97,null))['then'](function(_0x359a87){if(_0x359a87){return _0x359a87[_0x0f03('0x61')](_0x1530c1['query'][_0x0f03('0x5e')]);}})['then'](respondWithStatusCode(_0x393d97,null))[_0x0f03('0x1d')](handleError(_0x393d97,null));};exports[_0x0f03('0x62')]=function(_0x36e100,_0x28301b){_0x36e100[_0x0f03('0x53')][_0x0f03('0x63')]=_0x36e100[_0x0f03('0x64')][_0x0f03('0x65')];return db['ChatWebsite'][_0x0f03('0x4c')]({'where':{'id':_0x36e100[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x28301b,null))[_0x0f03('0x12')](saveUpdates(_0x36e100[_0x0f03('0x53')],null))['then'](respondWithResult(_0x28301b,null))[_0x0f03('0x1d')](handleError(_0x28301b,null));};exports[_0x0f03('0x66')]=function(_0x22b08e,_0x2476ae){_0x22b08e[_0x0f03('0x53')]['agentAvatar']=_0x22b08e[_0x0f03('0x64')][_0x0f03('0x65')];return db[_0x0f03('0x32')][_0x0f03('0x4c')]({'where':{'id':_0x22b08e[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x2476ae,null))[_0x0f03('0x12')](saveUpdates(_0x22b08e[_0x0f03('0x53')],null))[_0x0f03('0x12')](respondWithResult(_0x2476ae,null))[_0x0f03('0x1d')](handleError(_0x2476ae,null));};exports[_0x0f03('0x67')]=function(_0x464ef7,_0x372efd){_0x464ef7[_0x0f03('0x53')]['customerAvatar']=_0x464ef7['file'][_0x0f03('0x65')];return db['ChatWebsite'][_0x0f03('0x4c')]({'where':{'id':_0x464ef7[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x372efd,null))[_0x0f03('0x12')](saveUpdates(_0x464ef7[_0x0f03('0x53')],null))[_0x0f03('0x12')](respondWithResult(_0x372efd,null))['catch'](handleError(_0x372efd,null));};exports[_0x0f03('0x68')]=function(_0x213552,_0x4a6f4b){_0x213552[_0x0f03('0x53')][_0x0f03('0x69')]=_0x213552['file'][_0x0f03('0x65')];return db[_0x0f03('0x32')][_0x0f03('0x4c')]({'where':{'id':_0x213552[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x4a6f4b,null))[_0x0f03('0x12')](saveUpdates(_0x213552[_0x0f03('0x53')],null))[_0x0f03('0x12')](respondWithResult(_0x4a6f4b,null))[_0x0f03('0x1d')](handleError(_0x4a6f4b,null));};exports[_0x0f03('0x6a')]=function(_0xae11c9,_0x404e89){var _0x3dec4b=path[_0x0f03('0x6b')](config[_0x0f03('0x6c')],_0x0f03('0x6d'));var _0x5a0282={'where':{'id':_0xae11c9[_0x0f03('0x54')]['id']},'attributes':['id',_0x0f03('0x63')],'raw':!![]};var _0x37a3b0=![];return require('../../config/license/util')[_0x0f03('0x6e')]()[_0x0f03('0x12')](function(_0x4dd5bb){if(_0x4dd5bb){_0x37a3b0=_0x4dd5bb['custom'];}})['then'](function(){return db['ChatWebsite'][_0x0f03('0x4c')](_0x5a0282);})[_0x0f03('0x12')](handleEntityNotFound(_0x404e89,null))[_0x0f03('0x12')](function(_0x342024){if(_0x342024){if(!_[_0x0f03('0x6f')](_0x342024['sitepic'])){if(fs[_0x0f03('0x70')](path[_0x0f03('0x6b')](config[_0x0f03('0x6c')],_0x0f03('0x71'),_0x342024[_0x0f03('0x63')]))&&_0x37a3b0){_0x3dec4b=path[_0x0f03('0x6b')](config[_0x0f03('0x6c')],_0x0f03('0x71'),_0x342024[_0x0f03('0x63')]);}}return _0x404e89[_0x0f03('0x72')](_0x3dec4b);}})['catch'](handleError(_0x404e89,null));};exports[_0x0f03('0x73')]=function(_0x324b3c,_0x2081ae){var _0x1b6701=path[_0x0f03('0x6b')](config[_0x0f03('0x6c')],_0x0f03('0x74'));var _0x5bf171={'where':{'id':_0x324b3c[_0x0f03('0x54')]['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db['ChatWebsite'][_0x0f03('0x4c')](_0x5bf171)[_0x0f03('0x12')](handleEntityNotFound(_0x2081ae,null))[_0x0f03('0x12')](function(_0x2b1c98){if(_0x2b1c98){if(!_[_0x0f03('0x6f')](_0x2b1c98[_0x0f03('0x75')])){if(fs['existsSync'](path['join'](config['root'],_0x0f03('0x76'),_0x2b1c98[_0x0f03('0x75')]))){_0x1b6701=path[_0x0f03('0x6b')](config['root'],'server/files/images/avatars/',_0x2b1c98[_0x0f03('0x75')]);}}return _0x2081ae[_0x0f03('0x72')](_0x1b6701);}})['catch'](handleError(_0x2081ae,null));};exports['getCustomerAvatar']=function(_0x3ff93b,_0x226a2a){var _0xb3e145=path[_0x0f03('0x6b')](config[_0x0f03('0x6c')],_0x0f03('0x77'));var _0x338612={'where':{'id':_0x3ff93b['params']['id']},'attributes':['id',_0x0f03('0x78'),_0x0f03('0x79')],'raw':!![]};return db[_0x0f03('0x32')][_0x0f03('0x4c')](_0x338612)[_0x0f03('0x12')](handleEntityNotFound(_0x226a2a,null))[_0x0f03('0x12')](function(_0x5c0e77){if(_0x5c0e77){if(!_[_0x0f03('0x6f')](_0x5c0e77[_0x0f03('0x78')])){if(fs[_0x0f03('0x70')](path[_0x0f03('0x6b')](config[_0x0f03('0x6c')],_0x0f03('0x76'),_0x5c0e77[_0x0f03('0x78')]))&&_0x5c0e77[_0x0f03('0x79')]){_0xb3e145=path['join'](config['root'],_0x0f03('0x76'),_0x5c0e77['customerAvatar']);}}return _0x226a2a[_0x0f03('0x72')](_0xb3e145);}})['catch'](handleError(_0x226a2a,null));};exports['getSystemAvatar']=function(_0x4cf3fd,_0x1db07d){var _0x563e12=path[_0x0f03('0x6b')](config['root'],_0x0f03('0x7a'));var _0x3c0242={'where':{'id':_0x4cf3fd[_0x0f03('0x54')]['id']},'attributes':['id',_0x0f03('0x69')],'raw':!![]};return db['ChatWebsite'][_0x0f03('0x4c')](_0x3c0242)[_0x0f03('0x12')](handleEntityNotFound(_0x1db07d,null))['then'](function(_0x50ae47){if(_0x50ae47){if(!_[_0x0f03('0x6f')](_0x50ae47['systemAvatar'])){if(fs[_0x0f03('0x70')](path['join'](config[_0x0f03('0x6c')],_0x0f03('0x76'),_0x50ae47[_0x0f03('0x69')]))){_0x563e12=path['join'](config[_0x0f03('0x6c')],_0x0f03('0x76'),_0x50ae47[_0x0f03('0x69')]);}}return _0x1db07d['download'](_0x563e12);}})[_0x0f03('0x1d')](handleError(_0x1db07d,null));};exports[_0x0f03('0x7b')]=function(_0x4a4ddd,_0xba6618){var _0xa714b9=require(_0x0f03('0x7c'));var _0x3cb807=new _0xa714b9();var _0xf78c61=_0x3cb807['setUA'](_0x4a4ddd[_0x0f03('0x7d')]['user-agent'])[_0x0f03('0x7e')]();var _0x285516={'body':_0x4a4ddd['body'],'channel':'chat'};var _0x306a8b=[];var _0xece18c=[];var _0x16a9ee={};var _0x5488ab=![];return db['CmContact']['describe']()['then'](function(_0x512ca2){if(!_0x512ca2){throw new db['Sequelize'][(_0x0f03('0x7f'))](_0x0f03('0x80'));}_0x306a8b=_[_0x0f03('0x81')](_['keys'](_0x512ca2),[_0x0f03('0x82'),_0x0f03('0x83')]);_0xece18c=_['difference'](_[_0x0f03('0x37')](_0x512ca2),[_0x0f03('0x82'),_0x0f03('0x83'),'CompanyId',_0x0f03('0x84')]);if(_0x4a4ddd[_0x0f03('0x53')]['id']){delete _0x4a4ddd[_0x0f03('0x53')]['id'];}if(_[_0x0f03('0x6f')](_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0x85')])){throw new db['Sequelize'][(_0x0f03('0x7f'))]('from\x20is\x20mandatory');}if(_[_0x0f03('0x6f')](_0x4a4ddd[_0x0f03('0x53')]['body'])||_0x4a4ddd[_0x0f03('0x53')]['body']===''){throw new db['Sequelize']['ValidationError'](_0x0f03('0x86'));}if(_[_0x0f03('0x6f')](_0x4a4ddd['body']['mapKey'])){throw new db[(_0x0f03('0x87'))][(_0x0f03('0x7f'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0xece18c);}if(!_[_0x0f03('0x88')](_0xece18c,_0x4a4ddd[_0x0f03('0x53')]['mapKey'])){throw new db[(_0x0f03('0x87'))][(_0x0f03('0x7f'))](_0x0f03('0x89')+_0xece18c);}_0x16a9ee[_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0x8a')]]=_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0x85')];})[_0x0f03('0x12')](function(){return db[_0x0f03('0x32')][_0x0f03('0x4c')]({'where':{'id':_0x4a4ddd[_0x0f03('0x54')]['id']},'include':[{'model':db[_0x0f03('0x8b')],'as':_0x0f03('0x8c'),'include':[{'model':db[_0x0f03('0x8d')],'as':_0x0f03('0x8e'),'where':_0x16a9ee,'limit':0x1,'order':[['updatedAt','DESC']]}]},{'model':db[_0x0f03('0x8f')],'as':_0x0f03('0x90')}]});})['then'](handleEntityNotFound(_0xba6618,null))[_0x0f03('0x12')](function(_0xb16edd){if(_0xb16edd&&_0xb16edd[_0x0f03('0x8c')]){_0x285516[_0x0f03('0x91')]=_0xb16edd;_0x285516[_0x0f03('0x92')]=_0xb16edd['Applications'];_0x285516[_0x0f03('0x93')]=_0xb16edd[_0x0f03('0x8c')];_0x285516[_0x0f03('0x92')]=_[_0x0f03('0x94')](_0x285516['applications'],[_0x0f03('0x95')],[_0x0f03('0x96')]);if(_0x285516[_0x0f03('0x91')][_0x0f03('0x90')]){delete _0x285516['account'][_0x0f03('0x90')];}if(_0x285516['account']['List']&&_0x285516['account'][_0x0f03('0x8c')][_0x0f03('0x8e')][_0x0f03('0x5b')]){return _0x285516['account'][_0x0f03('0x8c')][_0x0f03('0x8e')][0x0];}var _0x4ac0d8=_[_0x0f03('0x97')](_0x4a4ddd[_0x0f03('0x53')],{'firstName':_0x4a4ddd['body'][_0x0f03('0x85')],'ListId':_0xb16edd['ListId']});_0x4ac0d8[_0x4a4ddd['body']['mapKey']]=_0x4a4ddd['body'][_0x0f03('0x85')];return db['CmContact']['create'](_0x4ac0d8,{'fields':_0x306a8b,'raw':!![]});}})[_0x0f03('0x12')](handleEntityNotFound(_0xba6618,null))[_0x0f03('0x12')](function(_0x3e2863){_0x285516['contact']=_0x3e2863;var _0x2b0071=_0x4a4ddd[_0x0f03('0x53')]['customerIp'];if(_0x4a4ddd['headers'][_0x0f03('0x98')]){_0x2b0071=_0x4a4ddd[_0x0f03('0x7d')][_0x0f03('0x98')];}else if(_0x4a4ddd[_0x0f03('0x7d')]['x-forwarded-for']){_0x2b0071=_[_0x0f03('0x99')](_0x4a4ddd['headers'][_0x0f03('0x9a')][_0x0f03('0x9b')](','));}if(_0x3e2863){var _0x4413a7={'ContactId':_0x3e2863['id'],'ChatWebsiteId':_0x4a4ddd['params']['id'],'from':(_0x3e2863[_0x0f03('0x9c')]||'')+'\x20'+(_0x3e2863[_0x0f03('0x9d')]||''),'customerIp':_0x2b0071,'customerPort':_0x4a4ddd[_0x0f03('0x7d')]['x-real-port']?_0x4a4ddd[_0x0f03('0x7d')][_0x0f03('0x9e')]:null,'referer':_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0x9f')],'browserName':_0xf78c61[_0x0f03('0xa0')][_0x0f03('0x2d')]&&_0xf78c61[_0x0f03('0xa0')][_0x0f03('0xa1')]?util[_0x0f03('0xa2')](_0x0f03('0xa3'),_0xf78c61[_0x0f03('0xa0')][_0x0f03('0x2d')],_0xf78c61['browser']['version']):_0x0f03('0xa4'),'browserVersion':_0xf78c61[_0x0f03('0xa0')][_0x0f03('0xa1')]||'unknown','osName':util['format'](_0x0f03('0xa3'),_0xf78c61['os']['name'],_0xf78c61['os'][_0x0f03('0xa1')]),'osVersion':_0xf78c61['os'][_0x0f03('0xa1')],'deviceModel':_0xf78c61[_0x0f03('0xa5')]['model']&&_0xf78c61[_0x0f03('0xa5')][_0x0f03('0xa6')]?util[_0x0f03('0xa2')](_0x0f03('0xa7'),_0xf78c61[_0x0f03('0xa5')][_0x0f03('0x36')],_0xf78c61['device'][_0x0f03('0xa6')],_0xf78c61['device'][_0x0f03('0x34')]):null,'deviceVendor':_0xf78c61['device'][_0x0f03('0xa6')],'deviceType':_0xf78c61[_0x0f03('0xa5')]['type'],'formData':JSON['stringify'](_0x4a4ddd[_0x0f03('0x53')])};var _0x1d97fc={'ChatWebsiteId':_0x4a4ddd[_0x0f03('0x54')]['id'],'closed':![]};if(_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0xa8')]){_0x1d97fc[_0x0f03('0xa8')]=_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0xa8')];return db[_0x0f03('0xa9')]['find']({'where':_0x1d97fc})['then'](function(_0x546db4){if(_0x546db4){return[_0x546db4,![]];}_0x4413a7['threadId']=_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0xa8')];_0x4413a7[_0x0f03('0xaa')]=_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0xaa')];return db[_0x0f03('0xa9')][_0x0f03('0x4d')](_0x4413a7)['then'](function(_0x3057f1){return[_0x3057f1,!![]];});});}_0x1d97fc['ContactId']=_0x3e2863['id'];if(_0x4a4ddd['body'][_0x0f03('0xab')]&&_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0xab')]['id']){_0x1d97fc['id']=_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0xab')]['id'];return db[_0x0f03('0xa9')][_0x0f03('0x4c')]({'where':_0x1d97fc})[_0x0f03('0x12')](function(_0x501b9e){if(_0x501b9e){return[_0x501b9e,![]];}return db[_0x0f03('0xa9')]['create'](_0x4413a7)[_0x0f03('0x12')](function(_0x2455b0){return[_0x2455b0,!![]];});});}return db['ChatInteraction']['create'](_0x4413a7)[_0x0f03('0x12')](function(_0x39bae8){return[_0x39bae8,!![]];});}})[_0x0f03('0xac')](function(_0xcfe684,_0x48c5dd){if(_0xcfe684){_0x5488ab=_0x48c5dd;if(!_0x48c5dd){var _0x3164d1={'from':(_0x285516['contact'][_0x0f03('0x9c')]||'')+'\x20'+(_0x285516[_0x0f03('0xad')][_0x0f03('0x9d')]||'')};if(_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0xa8')]&&_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0xae')]&&_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0xa8')]!=_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0xae')]){_0x3164d1[_0x0f03('0xa8')]=_0x4a4ddd[_0x0f03('0x53')]['messageId'];}return _0xcfe684[_0x0f03('0x27')](_0x3164d1);}else{return _0xcfe684;}}})[_0x0f03('0x12')](function(_0x57f1fc){_0x285516[_0x0f03('0xab')]=_0x57f1fc[_0x0f03('0xaf')]({'plain':!![]});_0x285516[_0x0f03('0xab')][_0x0f03('0xb0')]=_0x5488ab;if(_0x285516[_0x0f03('0xab')]['created']){if(_0x285516['account'][_0x0f03('0xb1')]){_0x285516[_0x0f03('0x92')][_0x0f03('0xb2')]({'id':0x0,'priority':_0x285516[_0x0f03('0x92')][_0x0f03('0x5b')]+0x1,'app':_0x0f03('0xb3'),'appdata':'unmanaged','interval':'*,*,*,*'});}}return db[_0x0f03('0xb4')][_0x0f03('0x4d')]({'body':_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0x53')],'ChatWebsiteId':_0x4a4ddd[_0x0f03('0x54')]['id'],'ChatInteractionId':_0x57f1fc['id'],'direction':'in','ContactId':_0x285516[_0x0f03('0xad')]['id'],'AttachmentId':_0x4a4ddd[_0x0f03('0x53')][_0x0f03('0xb5')]});})[_0x0f03('0x12')](function(_0x16a7f8){_0x285516[_0x0f03('0x1b')]=_0x16a7f8;if(_0x285516[_0x0f03('0xab')][_0x0f03('0xb6')]){return db[_0x0f03('0xb7')][_0x0f03('0x4c')]({'attributes':['id',_0x0f03('0x2d')],'where':{'id':_0x285516['interaction']['UserId']}})['then'](function(_0x18c051){if(_0x18c051){_0x285516[_0x0f03('0x92')][_0x0f03('0xb8')]({'id':0x0,'priority':0x0,'app':_0x0f03('0xb9'),'appdata':_0x18c051[_0x0f03('0x2d')]+','+(_0x285516[_0x0f03('0x91')][_0x0f03('0xba')]||0xa),'interval':_0x0f03('0xbb')});_0x285516[_0x0f03('0xbc')]=!![];}return respondWithRpcPromise(_0x0f03('0xbd'),_0x0f03('0xbe'),_0x285516);});}return respondWithRpcPromise(_0x0f03('0xbd'),_0x0f03('0xbe'),_0x285516);})[_0x0f03('0x12')](function(_0xff62e2){respondWithRpcPromise(_0x0f03('0xbf'),_0x0f03('0xbf'),{'event':'notify','message':_0xff62e2},client9002);return _0xff62e2;})[_0x0f03('0x12')](respondWithResult(_0xba6618,null))[_0x0f03('0x1d')](handleError(_0xba6618,null));};exports[_0x0f03('0xc0')]=function(_0x50efe6,_0x45aaf8){var _0x4bb59a,_0x5ae0e1,_0x29fcee;var _0x24aba3=[];var _0x592299={};var _0x3f729c=_0x50efe6[_0x0f03('0xc1')]||[];var _0x34ff5e=[];var _0x19e4c6;return db[_0x0f03('0x8d')]['describe']()['then'](function(_0x3727cf){if(!_0x3727cf){throw new db['Sequelize'][(_0x0f03('0x7f'))](_0x0f03('0x80'));}_0x24aba3=_[_0x0f03('0x81')](_[_0x0f03('0x37')](_0x3727cf),[_0x0f03('0x82'),_0x0f03('0x83'),_0x0f03('0xc2'),_0x0f03('0x84')]);if(_0x50efe6[_0x0f03('0x53')]['id']){delete _0x50efe6['body']['id'];}if(_[_0x0f03('0x6f')](_0x50efe6['body'][_0x0f03('0x85')])){throw _0x45aaf8[_0x0f03('0x1f')](0x1f4)[_0x0f03('0x2e')](new db[(_0x0f03('0x87'))][(_0x0f03('0x7f'))](_0x0f03('0xc3')));}if(_['isNil'](_0x50efe6[_0x0f03('0x53')]['body'])||_0x50efe6[_0x0f03('0x53')][_0x0f03('0x53')]===''){throw _0x45aaf8[_0x0f03('0x1f')](0x1f4)[_0x0f03('0x2e')](new db[(_0x0f03('0x87'))][(_0x0f03('0x7f'))](_0x0f03('0x86')));}if(_[_0x0f03('0x6f')](_0x50efe6[_0x0f03('0x53')]['mapKeyOffline'])){throw _0x45aaf8['status'](0x1f4)[_0x0f03('0x2e')](new db[(_0x0f03('0x87'))][(_0x0f03('0x7f'))](_0x0f03('0xc4')+_0x24aba3));}if(!_[_0x0f03('0x88')](_0x24aba3,_0x50efe6['body'][_0x0f03('0xc5')])){throw _0x45aaf8[_0x0f03('0x1f')](0x1f4)[_0x0f03('0x2e')](new db['Sequelize'][(_0x0f03('0x7f'))](_0x0f03('0xc6')+_0x24aba3));}_0x592299[_0x50efe6[_0x0f03('0x53')][_0x0f03('0xc5')]]=_0x50efe6[_0x0f03('0x53')]['from'];})[_0x0f03('0x12')](function(){return db[_0x0f03('0x32')]['find']({'where':{'id':_0x50efe6[_0x0f03('0x54')]['id']},'include':[{'model':db[_0x0f03('0x8b')],'as':_0x0f03('0x8c')},{'model':db['MailAccount'],'as':'MailAccount'}]});})['then'](handleEntityNotFound(_0x45aaf8,null))[_0x0f03('0x12')](function(_0x570062){if(_0x570062&&_0x570062[_0x0f03('0x8c')]){_0x5ae0e1=_0x570062;var _0x705adf=_[_0x0f03('0x97')](_0x50efe6[_0x0f03('0x53')],{'firstName':_0x50efe6[_0x0f03('0x53')]['from'],'phone':_0x50efe6[_0x0f03('0x53')][_0x0f03('0x85')],'ListId':_0x570062[_0x0f03('0x84')]});_0x705adf[_0x50efe6[_0x0f03('0x53')][_0x0f03('0xc5')]]=_0x50efe6['body'][_0x0f03('0x85')];return db['CmContact'][_0x0f03('0xc7')]({'where':_0x592299,'defaults':_0x705adf});}})[_0x0f03('0xac')](function(_0x503376){if(_0x503376){_0x29fcee=_0x503376;var _0x5a50d0=fs[_0x0f03('0xc8')](path[_0x0f03('0x6b')](config[_0x0f03('0x6c')],'server/files/templates/chatOfflineMessage.ejs'),_0x0f03('0xc9'));var _0x150c8c=ejs[_0x0f03('0xca')](_0x5a50d0,{'body':_[_0x0f03('0xcb')](_0x50efe6[_0x0f03('0x53')]['body']),'bodyTitle':_0x5ae0e1[_0x0f03('0xcc')]});return db[_0x0f03('0xcd')]['create']({'body':_0x150c8c,'plainBody':htmlToText[_0x0f03('0xce')](_0x150c8c),'ContactId':_0x503376['id'],'ChatWebsiteId':_0x5ae0e1['id']});}})[_0x0f03('0x12')](function(_0x55eeb8){_0x19e4c6=_0x55eeb8;if(_0x3f729c[_0x0f03('0x5b')]){var _0x4ee558=_0x3f729c[_0x0f03('0x31')](function(_0x5ecd68){return{'name':_0x5ecd68[_0x0f03('0xcf')],'basename':_0x5ecd68[_0x0f03('0x65')],'type':_0x5ecd68[_0x0f03('0xd0')],'ChatOfflineMessageId':_0x55eeb8['id']};});_0x34ff5e=_0x4ee558[_0x0f03('0x31')](_0x5f1ce7=>{var _0x2087a2={'filename':_0x5f1ce7[_0x0f03('0x2d')],'path':path[_0x0f03('0x6b')](config[_0x0f03('0x6c')],_0x0f03('0xd1'),'files','attachments','offline-chat',_0x5f1ce7['basename'])};return _0x2087a2;});if(!_0x5ae0e1['openNewInteraction']){return db[_0x0f03('0xd2')][_0x0f03('0xd3')](function(_0x4f6826){return db[_0x0f03('0xd4')][_0x0f03('0xd5')](_0x4ee558,{'transaction':_0x4f6826});});}}})[_0x0f03('0x12')](function(){if(_0x19e4c6){_0x4bb59a=_0x19e4c6;return db[_0x0f03('0xd6')][_0x0f03('0x5a')]({'where':{'service':!![]},'include':[{'model':db[_0x0f03('0xd7')],'as':'Smtp','raw':!![],'include':[{'model':db[_0x0f03('0xd8')],'as':_0x0f03('0xd8'),'raw':!![]}]}]});}})[_0x0f03('0x12')](function(_0x46c8cf){if(_0x46c8cf&&_0x46c8cf[_0x0f03('0xd9')]&&_0x5ae0e1[_0x0f03('0xda')]&&_0x5ae0e1[_0x0f03('0xdb')]){var _0x25155f=_0x46c8cf['getSmtpOptions']();return respondWithRpcPromise(_0x0f03('0xdc'),_0x0f03('0xdd'),{'account':_0x25155f,'message':{'from':util[_0x0f03('0xa2')](_0x0f03('0xde'),_0x46c8cf[_0x0f03('0x2d')],_0x46c8cf[_0x0f03('0xdf')]||_0x46c8cf[_0x0f03('0xd9')][_0x0f03('0x4e')]),'to':_0x5ae0e1['forwardOfflineAddress'],'subject':_0x5ae0e1['offlineMessageSubject'],'html':_0x4bb59a[_0x0f03('0x53')],'attachments':_0x34ff5e}},client9003)['then'](function(){return _0x4bb59a;})[_0x0f03('0x1d')](function(_0x30c05b){logger[_0x0f03('0x19')](_0x30c05b);});}})['then'](function(){if(_0x5ae0e1&&_0x5ae0e1[_0x0f03('0xe0')]&&_0x5ae0e1[_0x0f03('0xe1')]){var _0x32ac3f=[];if(_0x3f729c[_0x0f03('0x5b')]){_0x32ac3f=_0x3f729c['map'](function(_0x237748){return{'name':_0x237748[_0x0f03('0xcf')],'basename':_0x237748[_0x0f03('0x65')],'type':_0x237748[_0x0f03('0xd0')],'ChatOfflineMessageId':_0x19e4c6['id']};});}var _0x2cbea8;if(!_[_0x0f03('0x6f')](_0x5ae0e1[_0x0f03('0xe2')])){var _0x57badb=_[_0x0f03('0x31')](_0x50efe6[_0x0f03('0x53')],function(_0x91e075){return _0x91e075;});var _0x3c24a7=_[_0x0f03('0xe3')](_0x57badb)[0x0];var _0x28e1b5=_[_0x0f03('0xe4')](_0x3c24a7,function(_0x1c7ff2){return _0x1c7ff2;});_0x2cbea8=_0x28e1b5[0x1][_0x5ae0e1[_0x0f03('0xe2')]];}var _0x1dd855={'from':_0x29fcee['email'],'firstName':_0x29fcee['firstName'],'lastName':_0x29fcee[_0x0f03('0x9d')],'mapKey':_0x0f03('0xdf'),'message':{'from':_0x29fcee[_0x0f03('0xdf')],'to':_0x5ae0e1[_0x0f03('0xd6')]['email'],'cc':'','subject':_[_0x0f03('0x6f')](_0x2cbea8)?_0x5ae0e1['offlineMessageSubject']:_0x2cbea8,'messageId':'','sentAt':new Date(),'attach':_0x32ac3f[_0x0f03('0x5b')],'attachments':_0x32ac3f,'originChannel':_0x0f03('0xe5'),'ChatWebsiteId':_0x5ae0e1['id'],'ChatOfflineMessageId':_0x4bb59a['id'],'originTo':_0x5ae0e1[_0x0f03('0xd6')][_0x0f03('0xdf')]},'body':_0x4bb59a[_0x0f03('0x53')]};var _0x57170f={'account':{'id':_0x5ae0e1[_0x0f03('0xe1')]},'body':_0x1dd855,'log':_0x0f03('0xe6')};return respondWithRpcPromise(_0x0f03('0xe6'),_0x0f03('0xe7'),_0x57170f,client9001)[_0x0f03('0x12')](function(){return _0x4bb59a;})[_0x0f03('0x1d')](function(_0x144f3b){logger[_0x0f03('0x19')](_0x144f3b);});}return;})[_0x0f03('0x12')](function(){if(_0x4bb59a){return _0x4bb59a;}})['then'](respondWithResult(_0x45aaf8,null))['catch'](function(_0x369764){logger[_0x0f03('0x19')]('catch',_0x369764);for(var _0x4428e6 of _0x3f729c){var _0x3d657d=path['join'](config[_0x0f03('0x6c')],'server',_0x0f03('0xc1'),_0x0f03('0xe8'),'offline-chat',_0x4428e6[_0x0f03('0x65')]);fs_extra[_0x0f03('0xe9')](_0x3d657d)[_0x0f03('0x1d')](function(_0x3a483c){logger[_0x0f03('0x19')](_0x0f03('0xea'),_0x3d657d,_0x3a483c);});}});};exports['addInteraction']=function(_0x4fbfd3,_0x2f13e2){return db[_0x0f03('0xa9')][_0x0f03('0x4c')]({'where':{'id':_0x4fbfd3[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x2f13e2,null))['then'](function(_0x1a72d3){if(_0x1a72d3){return _0x1a72d3[_0x0f03('0xeb')](_0x4fbfd3[_0x0f03('0x53')][_0x0f03('0x5e')],_[_0x0f03('0xec')](_0x4fbfd3[_0x0f03('0x53')],[_0x0f03('0x5e'),'id'])||{});}})['then'](respondWithResult(_0x2f13e2,null))[_0x0f03('0x1d')](handleError(_0x2f13e2,null));};exports[_0x0f03('0xed')]=function(_0x3778e9,_0x5d718d){var _0x564845={'raw':![],'where':{}};var _0x56f6c8={};var _0x3932ab={'count':0x0,'rows':[]};return db[_0x0f03('0x32')][_0x0f03('0x5a')]({'where':{'id':_0x3778e9['params']['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x5d718d,null))[_0x0f03('0x12')](function(_0x2bb09b){if(_0x2bb09b){_0x56f6c8['model']=_['keys'](db[_0x0f03('0xa9')][_0x0f03('0x4a')]);_0x56f6c8[_0x0f03('0x38')]=_[_0x0f03('0x37')](_0x3778e9[_0x0f03('0x38')]);_0x56f6c8['filters']=_[_0x0f03('0x4b')](_0x56f6c8[_0x0f03('0x36')],_0x56f6c8['query']);_0x564845[_0x0f03('0x3a')]=_[_0x0f03('0x4b')](_0x56f6c8['model'],qs['fields'](_0x3778e9[_0x0f03('0x38')][_0x0f03('0x3b')]));_0x564845[_0x0f03('0x3a')]=_0x564845[_0x0f03('0x3a')][_0x0f03('0x5b')]?_0x564845[_0x0f03('0x3a')]:_0x56f6c8['model'];if(!_0x3778e9['query']['hasOwnProperty'](_0x0f03('0x3d'))){_0x564845[_0x0f03('0x22')]=qs[_0x0f03('0x22')](_0x3778e9[_0x0f03('0x38')][_0x0f03('0x22')]);_0x564845[_0x0f03('0x24')]=qs[_0x0f03('0x24')](_0x3778e9['query'][_0x0f03('0x24')]);}_0x564845[_0x0f03('0x3e')]=qs[_0x0f03('0x3f')](_0x3778e9['query']['sort']);_0x564845['where']=qs[_0x0f03('0x39')](_[_0x0f03('0x41')](_0x3778e9[_0x0f03('0x38')],_0x56f6c8[_0x0f03('0x39')]));_0x564845[_0x0f03('0x40')][_0x0f03('0x57')]=_0x2bb09b['id'];if(_0x3778e9[_0x0f03('0x38')][_0x0f03('0x42')]){_0x564845['where']=_['merge'](_0x564845[_0x0f03('0x40')],{'$or':_[_0x0f03('0x31')](_0x564845['attributes'],function(_0x589728){var _0x350a8f={};_0x350a8f[_0x589728]={'$like':'%'+_0x3778e9[_0x0f03('0x38')][_0x0f03('0x42')]+'%'};return _0x350a8f;})});}_0x564845=_[_0x0f03('0x43')]({},_0x564845,_0x3778e9[_0x0f03('0x44')]);return db[_0x0f03('0xa9')][_0x0f03('0x23')]({'where':_0x564845[_0x0f03('0x40')]})['then'](function(_0x59ba45){_0x3932ab[_0x0f03('0x23')]=_0x59ba45;if(_0x3778e9[_0x0f03('0x38')]['includeAll']){_0x564845[_0x0f03('0x5c')]=[{'model':db[_0x0f03('0x8d')],'as':_0x0f03('0xee'),'required':![]},{'model':db['User'],'as':'Owner','attributes':['name',_0x0f03('0xef'),_0x0f03('0xf0')],'required':![]},{'model':db[_0x0f03('0xf1')],'as':_0x0f03('0xf2'),'attributes':['id',_0x0f03('0x2d'),'color'],'where':_0x3778e9['query'][_0x0f03('0xf3')]?{'id':_0x3778e9['query']['tag']}:undefined,'required':_0x3778e9[_0x0f03('0x38')]['tag']?!![]:![]}];}return db['ChatInteraction']['findAll'](_0x564845);})[_0x0f03('0x12')](function(_0x3f2624){_0x3932ab[_0x0f03('0x47')]=_0x3f2624;return _0x3932ab;});}})[_0x0f03('0x12')](respondWithFilteredResult(_0x5d718d,_0x564845))[_0x0f03('0x1d')](handleError(_0x5d718d,null));};function iftimePromise(_0x33cf5a,_0x53e1d8){return respondWithRpcPromise(_0x0f03('0xf4'),_0x0f03('0xf5'),{'command':_0x53e1d8[_0x0f03('0xf6')]?util[_0x0f03('0xa2')]('iftime\x20%s,%s',_0x33cf5a[_0x0f03('0xf7')],_0x53e1d8[_0x0f03('0xf6')]):util[_0x0f03('0xa2')](_0x0f03('0xf8'),_0x33cf5a[_0x0f03('0xf7')])},client9002)[_0x0f03('0x12')](function(_0x286871){var _0x222d2f=_0x286871&&_0x286871[_0x0f03('0xf9')](_0x0f03('0xfa'))>=0x0?!![]:![];logger['info'](_0x0f03('0xfb'),_0x53e1d8['id'],_0x33cf5a['id'],_0x33cf5a[_0x0f03('0xf7')],_0x222d2f?_0x0f03('0xfc'):_0x0f03('0xfd'),_0x53e1d8[_0x0f03('0xf6')]?_0x53e1d8[_0x0f03('0xf6')]:'No\x20timezone');return _0x222d2f;})['catch'](function(_0x4a300a){logger['error'](_0x0f03('0xfb'),_0x53e1d8['id'],_0x33cf5a['id'],_0x33cf5a[_0x0f03('0xf7')],util[_0x0f03('0xfe')](_0x4a300a,{'showHidden':![],'depth':null}),_0x53e1d8[_0x0f03('0xf6')]?_0x53e1d8[_0x0f03('0xf6')]:_0x0f03('0xff'));return![];});}exports[_0x0f03('0xf5')]=function(_0x413290,_0x2032b0){var _0x3e640e=0x0;var _0x1d882f=0x0;var _0x460161=![];var _0x515fb0;var _0x5a4245;return db[_0x0f03('0x32')][_0x0f03('0x4c')]({'where':{'id':_0x413290[_0x0f03('0x54')]['id']},'include':[{'model':db[_0x0f03('0x100')],'as':_0x0f03('0x100'),'include':[{'model':db[_0x0f03('0x100')],'as':_0x0f03('0x101'),'attributes':['id',_0x0f03('0xf7')],'raw':!![]}]}]})['then'](handleEntityNotFound(_0x2032b0,null))['then'](function(_0xee4012){if(_0xee4012){_0x515fb0=_0xee4012;return _0xee4012[_0x0f03('0x102')]({'raw':!![]});}})[_0x0f03('0x12')](function(_0x5a5f0b){if(_0x515fb0){if(_0x5a5f0b){_0x5a4245=_0x5a5f0b;}}return require(_0x0f03('0x103'))[_0x0f03('0x6e')]();})[_0x0f03('0x12')](function(_0x585bf9){if(_0x585bf9){_0x1d882f=_0x585bf9['virtual'];_0x460161=_0x585bf9[_0x0f03('0x104')];}})['then'](function(){return db[_0x0f03('0xa9')]['count']({'where':{'closed':![]}});})['then'](function(_0x1df2fd){_0x3e640e=_0x1df2fd;if(_0x1d882f&&_0x1df2fd>_0x1d882f){return db[_0x0f03('0x105')]['findOne']({'where':{'id':0x1}})[_0x0f03('0x12')](function(_0x4ab119){if(_0x4ab119){_0x4ab119[_0x0f03('0x106')](_0x0f03('0x107'));}});}})[_0x0f03('0x12')](function(){if(_0x515fb0[_0x0f03('0x100')]&&_0x515fb0['Interval'][_0x0f03('0x101')]){var _0x6e1d7b=[];for(var _0x32a4eb=0x0;_0x32a4eb<_0x515fb0['Interval']['Intervals'][_0x0f03('0x5b')];_0x32a4eb++){var _0x8c33a9=_0x515fb0[_0x0f03('0x100')]['Intervals'][_0x32a4eb][_0x0f03('0xaf')]({'plain':!![]});_0x6e1d7b[_0x0f03('0xb2')](iftimePromise(_0x8c33a9,_0x515fb0));}return BPromise['all'](_0x6e1d7b)['then'](function(_0x34e78a){return _['some'](_0x34e78a);});}else{return!![];}})[_0x0f03('0x12')](function(_0x34f085){var _0x4175d0=fs[_0x0f03('0xc8')](path[_0x0f03('0x6b')](config[_0x0f03('0x6c')],_0x0f03('0x108')),_0x0f03('0xc9'));var _0x30239c={'remote':_0x515fb0[_0x0f03('0x109')],'query':querystring['stringify'](_['merge'](_0x515fb0[_0x0f03('0xaf')]({'plain':!![]}),{'customerIp':_0x413290[_0x0f03('0x7d')][_0x0f03('0x9a')]||_0x413290['headers'][_0x0f03('0x10a')]||_0x413290[_0x0f03('0x10b')]['remoteAddress']||_0x413290['ip'],'referer':_0x413290[_0x0f03('0x7d')]['referer'],'openedInteractions':_0x3e640e,'maxInteractions':_0x1d882f,'virtual':_0x460161['virtual'],'online':_0x34f085,'custom':_0x460161}))[_0x0f03('0x10c')](/'/g,'\x5c\x27')};_0x2032b0['send'](ejs['render'](Mustache[_0x0f03('0xca')](_0x4175d0,_0x30239c),{'proactiveActions':_0x5a4245,'alignment':_0x515fb0[_0x0f03('0x10d')],'verticalAlignment':_0x515fb0['verticalAlignment'],'div_color':_0x515fb0[_0x0f03('0x10e')],'labelText':_0x515fb0[_0x0f03('0x10f')],'text_color':_0x515fb0['textColor'],'text_button_color':_0x515fb0[_0x0f03('0x110')],'button_color':_0x515fb0[_0x0f03('0x111')],'background_color':_0x515fb0[_0x0f03('0x112')],'hideWhenOffline':_0x515fb0['hideWhenOffline'],'interval':_0x515fb0['IntervalId']}));})[_0x0f03('0x1d')](handleError(_0x2032b0,null));};exports['addApplications']=function(_0xb69bff,_0x4805a7){var _0x341a69=_0xb69bff[_0x0f03('0x54')]['id'];var _0x26ce88=_0xb69bff[_0x0f03('0x53')];var _0x596e8c=0xc8;var _0x30d1c7=null;return db['sequelize']['transaction']({'isolationLevel':db['sequelize'][_0x0f03('0x113')][_0x0f03('0x114')][_0x0f03('0x115')]},function(_0x5df22b){return db['ChatWebsite'][_0x0f03('0x5a')]({'where':{'id':_0x341a69},'transaction':_0x5df22b})['then'](function(_0x4e3f32){if(_0x4e3f32){return db[_0x0f03('0x8f')][_0x0f03('0x28')]({'where':{'ChatWebsiteId':_0x341a69},'transaction':_0x5df22b})[_0x0f03('0x12')](function(){var _0x10d4e1=_[_0x0f03('0x31')](_0x26ce88,function(_0xdb4bf){_0xdb4bf[_0x0f03('0x57')]=_0x341a69;return _0xdb4bf;});return db[_0x0f03('0x8f')][_0x0f03('0xd5')](_0x10d4e1,{'transaction':_0x5df22b});});}else{_0x596e8c=0x194;_0x30d1c7=[];}});})[_0x0f03('0x12')](function(){if(_0x596e8c!==0x194){return db[_0x0f03('0x8f')][_0x0f03('0x116')]({'where':{'ChatWebsiteId':_0x341a69},'order':'priority'})[_0x0f03('0x12')](function(_0x128cb8){_0x30d1c7=_0x128cb8;});}})['catch'](function(_0x2a6e1c){_0x596e8c=0x1f4;logger[_0x0f03('0x19')](_0x2a6e1c[_0x0f03('0x2c')]);if(_0x2a6e1c[_0x0f03('0x2d')]){delete _0x2a6e1c[_0x0f03('0x2d')];}_0x30d1c7=_0x2a6e1c;})['finally'](function(){if(_0x30d1c7===null){_0x4805a7['sendStatus'](_0x596e8c);}else{if(_0x596e8c===0x1f4){_0x4805a7[_0x0f03('0x1f')](_0x596e8c)[_0x0f03('0x2e')](_0x30d1c7);}else{_0x4805a7[_0x0f03('0x1f')](_0x596e8c)[_0x0f03('0x20')](_0x30d1c7);}}});};exports[_0x0f03('0x117')]=function(_0x2f37ee,_0x279872){var _0x39967f={};var _0x93007b={};var _0x52e29b;var _0x416512;return db['ChatWebsite'][_0x0f03('0x5a')]({'where':{'id':_0x2f37ee[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x279872,null))['then'](function(_0x3a5107){if(_0x3a5107){_0x52e29b=_0x3a5107;_0x93007b['model']=_[_0x0f03('0x37')](db['ChatApplication'][_0x0f03('0x4a')]);_0x93007b[_0x0f03('0x38')]=_['keys'](_0x2f37ee[_0x0f03('0x38')]);_0x93007b[_0x0f03('0x39')]=_[_0x0f03('0x4b')](_0x93007b[_0x0f03('0x36')],_0x93007b[_0x0f03('0x38')]);_0x39967f['attributes']=_['intersection'](_0x93007b[_0x0f03('0x36')],qs[_0x0f03('0x3b')](_0x2f37ee[_0x0f03('0x38')][_0x0f03('0x3b')]));_0x39967f[_0x0f03('0x3a')]=_0x39967f['attributes'][_0x0f03('0x5b')]?_0x39967f[_0x0f03('0x3a')]:_0x93007b[_0x0f03('0x36')];_0x39967f[_0x0f03('0x3e')]=qs['sort'](_0x2f37ee['query'][_0x0f03('0x3f')]);_0x39967f['where']=qs['filters'](_[_0x0f03('0x41')](_0x2f37ee[_0x0f03('0x38')],_0x93007b[_0x0f03('0x39')]));if(_0x2f37ee[_0x0f03('0x38')][_0x0f03('0x42')]){_0x39967f[_0x0f03('0x40')]=_[_0x0f03('0x43')](_0x39967f['where'],{'$or':_[_0x0f03('0x31')](_0x39967f['attributes'],function(_0x5cba97){var _0x2997f3={};_0x2997f3[_0x5cba97]={'$like':'%'+_0x2f37ee[_0x0f03('0x38')][_0x0f03('0x42')]+'%'};return _0x2997f3;})});}_0x39967f=_[_0x0f03('0x43')]({},_0x39967f,_0x2f37ee[_0x0f03('0x44')]);return _0x52e29b[_0x0f03('0x117')](_0x39967f);}})['then'](function(_0x1bd23f){if(_0x1bd23f){_0x416512=_0x1bd23f[_0x0f03('0x5b')];if(!_0x2f37ee[_0x0f03('0x38')][_0x0f03('0x3c')]('nolimit')){_0x39967f[_0x0f03('0x22')]=qs[_0x0f03('0x22')](_0x2f37ee[_0x0f03('0x38')][_0x0f03('0x22')]);_0x39967f[_0x0f03('0x24')]=qs[_0x0f03('0x24')](_0x2f37ee[_0x0f03('0x38')][_0x0f03('0x24')]);}return _0x52e29b[_0x0f03('0x117')](_0x39967f);}})[_0x0f03('0x12')](function(_0x3d248c){if(_0x3d248c){return _0x3d248c?{'count':_0x416512,'rows':_0x3d248c}:null;}})[_0x0f03('0x12')](respondWithResult(_0x279872,null))[_0x0f03('0x1d')](handleError(_0x279872,null));};exports[_0x0f03('0x118')]=function(_0x220a1f,_0x536cc5){return db[_0x0f03('0x119')][_0x0f03('0x4c')]({'where':{'id':_0x220a1f['params']['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x536cc5,null))[_0x0f03('0x12')](function(_0x186392){if(_0x186392){return _0x186392[_0x0f03('0x118')](_0x220a1f['body']['ids'],_[_0x0f03('0xec')](_0x220a1f[_0x0f03('0x53')],[_0x0f03('0x5e'),'id'])||{});}})['then'](respondWithResult(_0x536cc5,null))[_0x0f03('0x1d')](handleError(_0x536cc5,null));};exports['getProactiveActions']=function(_0x42686b,_0x1d70c5){var _0x14604a={};var _0x43067a={};var _0x535508;var _0x4eaf7f;return db[_0x0f03('0x32')][_0x0f03('0x5a')]({'where':{'id':_0x42686b[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x1d70c5,null))[_0x0f03('0x12')](function(_0x46cf06){if(_0x46cf06){_0x535508=_0x46cf06;_0x43067a[_0x0f03('0x36')]=_[_0x0f03('0x37')](db['ChatProactiveAction']['rawAttributes']);_0x43067a[_0x0f03('0x38')]=_['keys'](_0x42686b[_0x0f03('0x38')]);_0x43067a[_0x0f03('0x39')]=_[_0x0f03('0x4b')](_0x43067a[_0x0f03('0x36')],_0x43067a[_0x0f03('0x38')]);_0x14604a[_0x0f03('0x3a')]=_[_0x0f03('0x4b')](_0x43067a[_0x0f03('0x36')],qs[_0x0f03('0x3b')](_0x42686b[_0x0f03('0x38')][_0x0f03('0x3b')]));_0x14604a['attributes']=_0x14604a[_0x0f03('0x3a')][_0x0f03('0x5b')]?_0x14604a[_0x0f03('0x3a')]:_0x43067a[_0x0f03('0x36')];_0x14604a[_0x0f03('0x3e')]=qs[_0x0f03('0x3f')](_0x42686b[_0x0f03('0x38')][_0x0f03('0x3f')]);_0x14604a[_0x0f03('0x40')]=qs['filters'](_[_0x0f03('0x41')](_0x42686b[_0x0f03('0x38')],_0x43067a[_0x0f03('0x39')]));if(_0x42686b['query'][_0x0f03('0x42')]){_0x14604a[_0x0f03('0x40')]=_['merge'](_0x14604a['where'],{'$or':_[_0x0f03('0x31')](_0x14604a['attributes'],function(_0x6dcd31){var _0x408ecd={};_0x408ecd[_0x6dcd31]={'$like':'%'+_0x42686b['query'][_0x0f03('0x42')]+'%'};return _0x408ecd;})});}_0x14604a=_[_0x0f03('0x43')]({},_0x14604a,_0x42686b[_0x0f03('0x44')]);return _0x535508['getProactiveActions'](_0x14604a);}})[_0x0f03('0x12')](function(_0x10960f){if(_0x10960f){_0x4eaf7f=_0x10960f[_0x0f03('0x5b')];if(!_0x42686b[_0x0f03('0x38')][_0x0f03('0x3c')](_0x0f03('0x3d'))){_0x14604a[_0x0f03('0x22')]=qs['limit'](_0x42686b[_0x0f03('0x38')][_0x0f03('0x22')]);_0x14604a['offset']=qs[_0x0f03('0x24')](_0x42686b['query'][_0x0f03('0x24')]);}return _0x535508[_0x0f03('0x102')](_0x14604a);}})[_0x0f03('0x12')](function(_0x117f95){if(_0x117f95){return _0x117f95?{'count':_0x4eaf7f,'rows':_0x117f95}:null;}})[_0x0f03('0x12')](respondWithResult(_0x1d70c5,null))['catch'](handleError(_0x1d70c5,null));};exports[_0x0f03('0x11a')]=function(_0x26876a,_0x1b6226){var _0x2f20de=_0x26876a[_0x0f03('0x38')][_0x0f03('0x11b')]===_0x0f03('0x11c')?_0x0f03('0x11d'):'onlineForm';return db['ChatWebsite'][_0x0f03('0x4c')]({'attributes':['id',_0x2f20de],'where':{'id':_0x26876a[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x1b6226,null))[_0x0f03('0x12')](function(_0x586e26){if(_0x586e26){var _0x3f8af8=_0x586e26[_0x2f20de];var _0x32cfd2=_0x3f8af8&&_0x3f8af8['items']?_0x3f8af8[_0x0f03('0x11e')]:[];_0x1b6226[_0x0f03('0x2e')]({'fromKey':_['isNil'](_0x3f8af8['fromKey'])?undefined:_0x3f8af8[_0x0f03('0x11f')],'count':_0x32cfd2[_0x0f03('0x5b')],'rows':_0x32cfd2});}})[_0x0f03('0x1d')](handleError(_0x1b6226,null));};exports[_0x0f03('0x120')]=function(_0x2b9096,_0x5678a6){var _0x123fd2={'raw':![],'where':{}};var _0x4e0b0d={};var _0x2fe36e={'count':0x0,'rows':[]};return db[_0x0f03('0x32')]['findOne']({'where':{'id':_0x2b9096[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x5678a6,null))['then'](function(_0x51880e){if(_0x51880e){_0x4e0b0d[_0x0f03('0x36')]=_[_0x0f03('0x37')](db['ChatOfflineMessage']['rawAttributes']);_0x4e0b0d['query']=_[_0x0f03('0x37')](_0x2b9096[_0x0f03('0x38')]);_0x4e0b0d[_0x0f03('0x39')]=_[_0x0f03('0x4b')](_0x4e0b0d[_0x0f03('0x36')],_0x4e0b0d['query']);_0x123fd2[_0x0f03('0x3a')]=_[_0x0f03('0x4b')](_0x4e0b0d[_0x0f03('0x36')],qs[_0x0f03('0x3b')](_0x2b9096[_0x0f03('0x38')]['fields']));_0x123fd2['attributes']=_0x123fd2[_0x0f03('0x3a')][_0x0f03('0x5b')]?_0x123fd2[_0x0f03('0x3a')]:_0x4e0b0d['model'];if(!_0x2b9096[_0x0f03('0x38')]['hasOwnProperty']('nolimit')){_0x123fd2[_0x0f03('0x22')]=qs[_0x0f03('0x22')](_0x2b9096[_0x0f03('0x38')][_0x0f03('0x22')]);_0x123fd2[_0x0f03('0x24')]=qs[_0x0f03('0x24')](_0x2b9096['query']['offset']);}_0x123fd2['order']=qs[_0x0f03('0x3f')](_0x2b9096[_0x0f03('0x38')][_0x0f03('0x3f')]);_0x123fd2['where']=qs['filters'](_[_0x0f03('0x41')](_0x2b9096[_0x0f03('0x38')],_0x4e0b0d[_0x0f03('0x39')]));_0x123fd2[_0x0f03('0x40')]['ChatWebsiteId']=_0x51880e['id'];if(_0x2b9096[_0x0f03('0x38')]['filter']){_0x123fd2[_0x0f03('0x40')]=_[_0x0f03('0x43')](_0x123fd2[_0x0f03('0x40')],{'$or':_[_0x0f03('0x31')](_0x123fd2['attributes'],function(_0x127840){var _0x4c5c3c={};_0x4c5c3c[_0x127840]={'$like':'%'+_0x2b9096[_0x0f03('0x38')][_0x0f03('0x42')]+'%'};return _0x4c5c3c;})});}_0x123fd2=_[_0x0f03('0x43')]({},_0x123fd2,_0x2b9096[_0x0f03('0x44')]);return db[_0x0f03('0xcd')]['count']({'where':_0x123fd2[_0x0f03('0x40')]})[_0x0f03('0x12')](function(_0x191dbe){_0x2fe36e[_0x0f03('0x23')]=_0x191dbe;if(_0x2b9096['query']['includeAll']){_0x123fd2[_0x0f03('0x5c')]=[{'all':!![]}];}else{_0x123fd2[_0x0f03('0x5c')]=[{'model':db['CmContact'],'as':_0x0f03('0xee'),'required':![]},{'model':db[_0x0f03('0xd4')],'as':_0x0f03('0x121'),'required':![]}];}return db['ChatOfflineMessage']['findAll'](_0x123fd2);})[_0x0f03('0x12')](function(_0x10c01e){_0x2fe36e[_0x0f03('0x47')]=_0x10c01e;return _0x2fe36e;});}})[_0x0f03('0x12')](respondWithFilteredResult(_0x5678a6,_0x123fd2))[_0x0f03('0x1d')](handleError(_0x5678a6,null));};exports[_0x0f03('0x122')]=function(_0x19c259,_0x5e0609){return db['ChatWebsite']['find']({'where':{'id':_0x19c259[_0x0f03('0x54')]['id']}})['then'](handleEntityNotFound(_0x5e0609,null))[_0x0f03('0x12')](function(_0x188e96){if(_0x188e96){return _0x188e96[_0x0f03('0x122')](_0x19c259[_0x0f03('0x53')]['ids'],_['omit'](_0x19c259[_0x0f03('0x53')],[_0x0f03('0x5e'),'id'])||{})[_0x0f03('0xac')](function(_0x42387d){for(var _0x58157a=0x0;_0x58157a<_0x19c259[_0x0f03('0x53')][_0x0f03('0x5e')][_0x0f03('0x5b')];_0x58157a+=0x1){socket['emit'](_0x0f03('0x123'),{'UserId':Number(_0x19c259[_0x0f03('0x53')][_0x0f03('0x5e')][_0x58157a]),'ChatWebsiteId':Number(_0x19c259['params']['id'])});}return _0x42387d;});}})['then'](respondWithResult(_0x5e0609,null))[_0x0f03('0x1d')](handleError(_0x5e0609,null));};exports[_0x0f03('0x124')]=function(_0x4e95bb,_0x1cdc8b){return db[_0x0f03('0x32')][_0x0f03('0x4c')]({'where':{'id':_0x4e95bb[_0x0f03('0x54')]['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x1cdc8b,null))[_0x0f03('0x12')](function(_0x5dfb8a){if(_0x5dfb8a){return _0x5dfb8a['removeAgents'](_0x4e95bb[_0x0f03('0x38')][_0x0f03('0x5e')])[_0x0f03('0x12')](function(){if(_['isArray'](_0x4e95bb[_0x0f03('0x38')][_0x0f03('0x5e')])){for(var _0x4048c9=0x0;_0x4048c9<_0x4e95bb[_0x0f03('0x38')][_0x0f03('0x5e')][_0x0f03('0x5b')];_0x4048c9+=0x1){socket[_0x0f03('0x125')](_0x0f03('0x126'),{'UserId':Number(_0x4e95bb[_0x0f03('0x38')][_0x0f03('0x5e')][_0x4048c9]),'ChatWebsiteId':Number(_0x4e95bb[_0x0f03('0x54')]['id'])});}}else{socket['emit'](_0x0f03('0x126'),{'UserId':Number(_0x4e95bb[_0x0f03('0x38')][_0x0f03('0x5e')]),'ChatWebsiteId':Number(_0x4e95bb[_0x0f03('0x54')]['id'])});}});}})[_0x0f03('0x12')](respondWithStatusCode(_0x1cdc8b,null))[_0x0f03('0x1d')](handleError(_0x1cdc8b,null));};exports[_0x0f03('0x127')]=function(_0x49161b,_0x1e4925){var _0x4196dc={};var _0x136af5={};var _0x33b1ae;var _0xe26ec1;return db[_0x0f03('0x32')][_0x0f03('0x5a')]({'where':{'id':_0x49161b['params']['id']}})[_0x0f03('0x12')](handleEntityNotFound(_0x1e4925,null))[_0x0f03('0x12')](function(_0x4e924e){if(_0x4e924e){_0x33b1ae=_0x4e924e;_0x136af5[_0x0f03('0x36')]=_['keys'](db['User'][_0x0f03('0x4a')]);_0x136af5[_0x0f03('0x38')]=_[_0x0f03('0x37')](_0x49161b[_0x0f03('0x38')]);_0x136af5[_0x0f03('0x39')]=_[_0x0f03('0x4b')](_0x136af5[_0x0f03('0x36')],_0x136af5[_0x0f03('0x38')]);_0x4196dc['attributes']=_[_0x0f03('0x4b')](_0x136af5[_0x0f03('0x36')],qs[_0x0f03('0x3b')](_0x49161b['query'][_0x0f03('0x3b')]));_0x4196dc[_0x0f03('0x3a')]=_0x4196dc[_0x0f03('0x3a')][_0x0f03('0x5b')]?_0x4196dc[_0x0f03('0x3a')]:_0x136af5[_0x0f03('0x36')];_0x4196dc['order']=qs[_0x0f03('0x3f')](_0x49161b[_0x0f03('0x38')][_0x0f03('0x3f')]);_0x4196dc['where']=qs[_0x0f03('0x39')](_[_0x0f03('0x41')](_0x49161b[_0x0f03('0x38')],_0x136af5[_0x0f03('0x39')]));if(_0x49161b['query']['filter']){_0x4196dc[_0x0f03('0x40')]=_[_0x0f03('0x43')](_0x4196dc[_0x0f03('0x40')],{'$or':_[_0x0f03('0x31')](_0x4196dc[_0x0f03('0x3a')],function(_0x20b66e){var _0x4fdc94={};_0x4fdc94[_0x20b66e]={'$like':'%'+_0x49161b[_0x0f03('0x38')][_0x0f03('0x42')]+'%'};return _0x4fdc94;})});}_0x4196dc=_[_0x0f03('0x43')]({},_0x4196dc,_0x49161b[_0x0f03('0x44')]);return _0x33b1ae[_0x0f03('0x127')](_0x4196dc);}})[_0x0f03('0x12')](function(_0x3ed121){if(_0x3ed121){_0xe26ec1=_0x3ed121[_0x0f03('0x5b')];if(!_0x49161b['query'][_0x0f03('0x3c')](_0x0f03('0x3d'))){_0x4196dc[_0x0f03('0x22')]=qs[_0x0f03('0x22')](_0x49161b['query'][_0x0f03('0x22')]);_0x4196dc[_0x0f03('0x24')]=qs[_0x0f03('0x24')](_0x49161b[_0x0f03('0x38')][_0x0f03('0x24')]);}return _0x33b1ae['getAgents'](_0x4196dc);}})[_0x0f03('0x12')](function(_0x1eba5a){if(_0x1eba5a){return _0x1eba5a?{'count':_0xe26ec1,'rows':_0x1eba5a}:null;}})[_0x0f03('0x12')](respondWithResult(_0x1e4925,null))[_0x0f03('0x1d')](handleError(_0x1e4925,null));};
\ No newline at end of file
+var _0xc404=['server','offline-chat','basename','openNewInteraction','transaction','MailServerOut','Smtp','CloudProvider','forwardOffline','forwardOfflineAddress','getSmtpOptions','SendMail','sendMail','email','offlineMessageSubject','MailAccountId','originalname','subjectOffline','mapValues','Chat','NotifyMailAccount','notifyMail','attachments','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','getInteractions','Contact','Owner','Tag','Tags','color','tag','Command','getSnippet','iftime\x20%s,%s','interval','timezone','ONLINE','OFFLINE','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','Interval','Intervals','getProactiveActions','virtual','License','increment','server/files/chat/iframe.ejs','address','origin','remote','x-real-ip','connection','remoteAddress','alignment','labelText','backgroundColor','addApplications','sequelize','Transaction','ISOLATION_LEVELS','READ_COMMITTED','bulkCreate','json','getApplications','addProactiveActions','chatProactiveAction','omit','ChatProactiveAction','getFields','online','false','offlineForm','items','fromKey','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','bluebird','mustache','path','ejs','lodash','../../components/parsers/qs','../../config/logger','api','url','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./chatWebsite.socket','client','http','then','info','ChatWebsite,\x20%s,\x20%s','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','status','end','offset','undefined','count','limit','set','Content-Range','update','ChatWebsites','UserProfileResource','destroy','sendStatus','stack','name','send','index','Pause','map','ChatWebsite','fieldName','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','pick','VIRTUAL','options','includeAll','include','findAll','rows','show','params','rawAttributes','merge','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','get','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ChatWebsiteId','Disposition','findOne','order','filter','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','sitepic','file','filename','addAvatar','agentAvatar','customerAvatar','systemAvatar','getLogo','join','root','getLicense','custom','isNil','existsSync','server/files/images/logos/','download','getAvatar','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','getSystemAvatar','notify','headers','user-agent','getResult','chat','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','from','List','CmContact','ChatApplication','account','applications','Applications','list','orderBy','priority','customerIp','cf-connecting-ip','x-forwarded-for','first','split','firstName','x-real-port','referer','browser','version','format','%s\x20%s','unknown','device','vendor','type','threadId','externalUrl','ContactId','interaction','ChatInteraction','spread','contact','lastName','messageId','created','autoclose','close','unmanaged','*,*,*,*','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','offline','files','from\x20is\x20mandatory','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','offlineMessageBody','ChatOfflineMessage','fromString','mimetype'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xc404,0x16d));var _0x4c40=function(_0x1705a7,_0xe1db5){_0x1705a7=_0x1705a7-0x0;var _0x58d379=_0xc404[_0x1705a7];return _0x58d379;};'use strict';var BPromise=require(_0x4c40('0x0'));var Mustache=require(_0x4c40('0x1'));var util=require('util');var path=require(_0x4c40('0x2'));var ejs=require(_0x4c40('0x3'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x4c40('0x4'));var querystring=require('querystring');var Redis=require('ioredis');var qs=require(_0x4c40('0x5'));var logger=require(_0x4c40('0x6'))(_0x4c40('0x7'));var config=require('../../config/environment');var url=require(_0x4c40('0x8'));var db=require(_0x4c40('0x9'))['db'];config['redis']=_[_0x4c40('0xa')](config[_0x4c40('0xb')],{'host':_0x4c40('0xc'),'port':0x18eb});var socket=require(_0x4c40('0xd'))(new Redis(config[_0x4c40('0xb')]));require(_0x4c40('0xe'))['register'](socket);var htmlToText=require('html-to-text');var jayson=require('jayson/promise');var client=jayson[_0x4c40('0xf')][_0x4c40('0x10')]({'port':0x232c});var client9002=jayson['client'][_0x4c40('0x10')]({'port':0x232a});var client9003=jayson[_0x4c40('0xf')][_0x4c40('0x10')]({'port':0x232b});var client9001=jayson[_0x4c40('0xf')][_0x4c40('0x10')]({'port':0x2329});function respondWithRpcPromise(_0x1f0afb,_0x45b5f2,_0x36ec05,_0x38a13b){return new BPromise(function(_0x3dbeae,_0x3a2d5){var _0x414471=_0x38a13b||client;return _0x414471['request'](_0x1f0afb,_0x36ec05)[_0x4c40('0x11')](function(_0x537d93){logger[_0x4c40('0x12')](_0x4c40('0x13'),_0x45b5f2,'request\x20sent');logger['debug'](_0x4c40('0x14'),_0x45b5f2,'request\x20sent',JSON[_0x4c40('0x15')](_0x537d93));if(_0x537d93['error']){if(_0x537d93[_0x4c40('0x16')][_0x4c40('0x17')]===0x1f4){logger[_0x4c40('0x16')](_0x4c40('0x13'),_0x45b5f2,_0x537d93['error'][_0x4c40('0x18')]);return _0x3a2d5(_0x537d93[_0x4c40('0x16')][_0x4c40('0x18')]);}logger[_0x4c40('0x16')]('ChatWebsite,\x20%s,\x20%s',_0x45b5f2,_0x537d93[_0x4c40('0x16')][_0x4c40('0x18')]);return _0x3dbeae(_0x537d93[_0x4c40('0x16')][_0x4c40('0x18')]);}else{logger[_0x4c40('0x12')](_0x4c40('0x13'),_0x45b5f2,'request\x20sent');_0x3dbeae(_0x537d93[_0x4c40('0x19')]['message']);}})[_0x4c40('0x1a')](function(_0x4beadb){logger[_0x4c40('0x16')](_0x4c40('0x13'),_0x45b5f2,_0x4beadb);_0x3a2d5(_0x4beadb);});});}function respondWithStatusCode(_0x1ee030,_0x4ab9fd){_0x4ab9fd=_0x4ab9fd||0xcc;return function(_0x4fb602){if(_0x4fb602){return _0x1ee030['sendStatus'](_0x4ab9fd);}return _0x1ee030[_0x4c40('0x1b')](_0x4ab9fd)[_0x4c40('0x1c')]();};}function respondWithResult(_0x23a7eb,_0x4413d6){_0x4413d6=_0x4413d6||0xc8;return function(_0x37f34a){if(_0x37f34a){return _0x23a7eb[_0x4c40('0x1b')](_0x4413d6)['json'](_0x37f34a);}};}function respondWithFilteredResult(_0x136bdd,_0x788e36){return function(_0x10507d){if(_0x10507d){var _0x226b56=typeof _0x788e36[_0x4c40('0x1d')]===_0x4c40('0x1e')&&typeof _0x788e36['limit']===_0x4c40('0x1e');var _0xc79dda=_0x10507d[_0x4c40('0x1f')];var _0x46a26a=_0x226b56?0x0:_0x788e36[_0x4c40('0x1d')];var _0xb4d0bf=_0x226b56?_0x10507d[_0x4c40('0x1f')]:_0x788e36['offset']+_0x788e36[_0x4c40('0x20')];var _0x1e8e1;if(_0xb4d0bf>=_0xc79dda){_0xb4d0bf=_0xc79dda;_0x1e8e1=0xc8;}else{_0x1e8e1=0xce;}_0x136bdd[_0x4c40('0x1b')](_0x1e8e1);return _0x136bdd[_0x4c40('0x21')](_0x4c40('0x22'),_0x46a26a+'-'+_0xb4d0bf+'/'+_0xc79dda)['json'](_0x10507d);}return null;};}function saveUpdates(_0x3409cc){return function(_0x31c9f0){if(_0x31c9f0){return _0x31c9f0[_0x4c40('0x23')](_0x3409cc)[_0x4c40('0x11')](function(_0x4c5eca){return _0x4c5eca;});}return null;};}function removeEntity(_0x110cbd){return function(_0xcb1111){if(_0xcb1111){return _0xcb1111['destroy']()['then'](function(){var _0x28f911=_0xcb1111['get']({'plain':!![]});var _0x10c39a=_0x4c40('0x24');return db[_0x4c40('0x25')][_0x4c40('0x26')]({'where':{'type':_0x10c39a,'resourceId':_0x28f911['id']}})['then'](function(){return _0xcb1111;});})[_0x4c40('0x11')](function(){_0x110cbd[_0x4c40('0x1b')](0xcc)[_0x4c40('0x1c')]();});}};}function handleEntityNotFound(_0x5e6d2b){return function(_0x1e106b){if(!_0x1e106b){_0x5e6d2b[_0x4c40('0x27')](0x194);}return _0x1e106b;};}function handleError(_0x15df6c,_0x1bb5a9){_0x1bb5a9=_0x1bb5a9||0x1f4;return function(_0x21da23){logger[_0x4c40('0x16')](_0x21da23[_0x4c40('0x28')]);if(_0x21da23[_0x4c40('0x29')]){delete _0x21da23[_0x4c40('0x29')];}_0x15df6c[_0x4c40('0x1b')](_0x1bb5a9)[_0x4c40('0x2a')](_0x21da23);};}exports[_0x4c40('0x2b')]=function(_0x5bbfdb,_0x64b226){var _0x340d9d={'include':[{'model':db[_0x4c40('0x2c')],'as':'mandatoryDispositionPause'}]},_0x267e65={},_0x2d561c={'count':0x0,'rows':[]};var _0xad92ef=_[_0x4c40('0x2d')](db[_0x4c40('0x2e')]['rawAttributes'],function(_0xeb99da){return{'name':_0xeb99da[_0x4c40('0x2f')],'type':_0xeb99da['type'][_0x4c40('0x30')]};});_0x267e65[_0x4c40('0x31')]=_[_0x4c40('0x2d')](_0xad92ef,_0x4c40('0x29'));_0x267e65[_0x4c40('0x32')]=_[_0x4c40('0x33')](_0x5bbfdb[_0x4c40('0x32')]);_0x267e65[_0x4c40('0x34')]=_['intersection'](_0x267e65[_0x4c40('0x31')],_0x267e65['query']);_0x340d9d[_0x4c40('0x35')]=_[_0x4c40('0x36')](_0x267e65[_0x4c40('0x31')],qs['fields'](_0x5bbfdb[_0x4c40('0x32')][_0x4c40('0x37')]));_0x340d9d[_0x4c40('0x35')]=_0x340d9d[_0x4c40('0x35')][_0x4c40('0x38')]?_0x340d9d[_0x4c40('0x35')]:_0x267e65['model'];if(!_0x5bbfdb[_0x4c40('0x32')][_0x4c40('0x39')](_0x4c40('0x3a'))){_0x340d9d['limit']=qs[_0x4c40('0x20')](_0x5bbfdb[_0x4c40('0x32')][_0x4c40('0x20')]);_0x340d9d['offset']=qs[_0x4c40('0x1d')](_0x5bbfdb[_0x4c40('0x32')]['offset']);}_0x340d9d['order']=qs[_0x4c40('0x3b')](_0x5bbfdb['query']['sort']);_0x340d9d[_0x4c40('0x3c')]=qs[_0x4c40('0x34')](_[_0x4c40('0x3d')](_0x5bbfdb[_0x4c40('0x32')],_0x267e65[_0x4c40('0x34')]),_0xad92ef);if(_0x5bbfdb[_0x4c40('0x32')]['filter']){_0x340d9d[_0x4c40('0x3c')]=_['merge'](_0x340d9d['where'],{'$or':_[_0x4c40('0x2d')](_0xad92ef,function(_0x4f1e3e){if(_0x4f1e3e['type']!==_0x4c40('0x3e')){var _0x144ca4={};_0x144ca4[_0x4f1e3e[_0x4c40('0x29')]]={'$like':'%'+_0x5bbfdb[_0x4c40('0x32')]['filter']+'%'};return _0x144ca4;}})});}_0x340d9d=_['merge']({},_0x340d9d,_0x5bbfdb[_0x4c40('0x3f')]);var _0x3ae403={'where':_0x340d9d[_0x4c40('0x3c')]};return db[_0x4c40('0x2e')][_0x4c40('0x1f')](_0x3ae403)[_0x4c40('0x11')](function(_0x55d49a){_0x2d561c[_0x4c40('0x1f')]=_0x55d49a;if(_0x5bbfdb['query'][_0x4c40('0x40')]){_0x340d9d[_0x4c40('0x41')]=[{'all':!![]}];}return db[_0x4c40('0x2e')][_0x4c40('0x42')](_0x340d9d);})['then'](function(_0x36c56d){_0x2d561c[_0x4c40('0x43')]=_0x36c56d;return _0x2d561c;})[_0x4c40('0x11')](respondWithFilteredResult(_0x64b226,_0x340d9d))['catch'](handleError(_0x64b226,null));};exports[_0x4c40('0x44')]=function(_0x539e33,_0x550a01){var _0x3be0a4={'raw':![],'where':{'id':_0x539e33[_0x4c40('0x45')]['id']},'include':[{'model':db[_0x4c40('0x2c')],'as':'mandatoryDispositionPause'}]},_0x829368={};_0x829368[_0x4c40('0x31')]=_[_0x4c40('0x33')](db[_0x4c40('0x2e')][_0x4c40('0x46')]);_0x829368['query']=_[_0x4c40('0x33')](_0x539e33[_0x4c40('0x32')]);_0x829368[_0x4c40('0x34')]=_[_0x4c40('0x36')](_0x829368[_0x4c40('0x31')],_0x829368['query']);_0x3be0a4[_0x4c40('0x35')]=_[_0x4c40('0x36')](_0x829368['model'],qs[_0x4c40('0x37')](_0x539e33['query'][_0x4c40('0x37')]));_0x3be0a4[_0x4c40('0x35')]=_0x3be0a4[_0x4c40('0x35')][_0x4c40('0x38')]?_0x3be0a4[_0x4c40('0x35')]:_0x829368[_0x4c40('0x31')];if(_0x539e33[_0x4c40('0x32')][_0x4c40('0x40')]){_0x3be0a4[_0x4c40('0x41')]=[{'all':!![]}];}_0x3be0a4=_[_0x4c40('0x47')]({},_0x3be0a4,_0x539e33[_0x4c40('0x3f')]);return db[_0x4c40('0x2e')][_0x4c40('0x48')](_0x3be0a4)[_0x4c40('0x11')](handleEntityNotFound(_0x550a01,null))['then'](respondWithResult(_0x550a01,null))[_0x4c40('0x1a')](handleError(_0x550a01,null));};exports[_0x4c40('0x49')]=function(_0x17a077,_0x461783){return db[_0x4c40('0x2e')][_0x4c40('0x49')](_0x17a077[_0x4c40('0x4a')],{})[_0x4c40('0x11')](function(_0x4c1f72){var _0x164ca3=_0x17a077['user']['get']({'plain':!![]});if(!_0x164ca3)throw new Error(_0x4c40('0x4b'));if(_0x164ca3[_0x4c40('0x4c')]===_0x4c40('0x4d')){var _0x1da7ce=_0x4c1f72[_0x4c40('0x4e')]({'plain':!![]});var _0x316a21=_0x4c40('0x24');return db['UserProfileSection']['find']({'where':{'name':_0x316a21,'userProfileId':_0x164ca3['userProfileId']},'raw':!![]})[_0x4c40('0x11')](function(_0x55dd68){if(_0x55dd68&&_0x55dd68[_0x4c40('0x4f')]===0x0){return db['UserProfileResource'][_0x4c40('0x49')]({'name':_0x1da7ce['name'],'resourceId':_0x1da7ce['id'],'type':_0x55dd68['name'],'sectionId':_0x55dd68['id']},{})[_0x4c40('0x11')](function(){return _0x4c1f72;});}else{return _0x4c1f72;}})[_0x4c40('0x1a')](function(_0x181c85){logger[_0x4c40('0x16')](_0x4c40('0x50'),_0x181c85);throw _0x181c85;});}return _0x4c1f72;})[_0x4c40('0x11')](respondWithResult(_0x461783,0xc9))[_0x4c40('0x1a')](handleError(_0x461783,null));};exports[_0x4c40('0x23')]=function(_0x856050,_0x269447){if(_0x856050[_0x4c40('0x4a')]['id']){delete _0x856050[_0x4c40('0x4a')]['id'];}return db[_0x4c40('0x2e')]['find']({'where':{'id':_0x856050[_0x4c40('0x45')]['id']},'include':[{'model':db[_0x4c40('0x2c')],'as':'mandatoryDispositionPause'}]})['then'](handleEntityNotFound(_0x269447,null))[_0x4c40('0x11')](saveUpdates(_0x856050['body'],null))[_0x4c40('0x11')](respondWithResult(_0x269447,null))['catch'](handleError(_0x269447,null));};exports[_0x4c40('0x26')]=function(_0x42d85f,_0x332066){return db[_0x4c40('0x2e')]['find']({'where':{'id':_0x42d85f['params']['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x332066,null))[_0x4c40('0x11')](removeEntity(_0x332066,null))[_0x4c40('0x1a')](handleError(_0x332066,null));};exports[_0x4c40('0x51')]=function(_0x349103,_0x4e5665){return db['ChatWebsite'][_0x4c40('0x51')]()[_0x4c40('0x11')](respondWithResult(_0x4e5665,null))[_0x4c40('0x1a')](handleError(_0x4e5665,null));};exports[_0x4c40('0x52')]=function(_0x17b065,_0x32f00c){if(_0x17b065[_0x4c40('0x4a')]['id']){delete _0x17b065[_0x4c40('0x4a')]['id'];}return db['ChatWebsite'][_0x4c40('0x48')]({'where':{'id':_0x17b065['params']['id']}})['then'](handleEntityNotFound(_0x32f00c,null))[_0x4c40('0x11')](function(_0x2d1e0d){if(_0x2d1e0d){_0x17b065[_0x4c40('0x4a')][_0x4c40('0x53')]=_0x2d1e0d['id'];return db[_0x4c40('0x54')]['create'](_0x17b065[_0x4c40('0x4a')]);}})['then'](respondWithResult(_0x32f00c,null))[_0x4c40('0x1a')](handleError(_0x32f00c,null));};exports['getDispositions']=function(_0x1b5db0,_0x15d8ef){var _0x5218d2={'raw':![],'where':{}};var _0x565d6b={};var _0x2ce7cc={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x4c40('0x55')]({'where':{'id':_0x1b5db0['params']['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x15d8ef,null))[_0x4c40('0x11')](function(_0x5795ba){if(_0x5795ba){_0x565d6b[_0x4c40('0x31')]=_['keys'](db[_0x4c40('0x54')][_0x4c40('0x46')]);_0x565d6b[_0x4c40('0x32')]=_[_0x4c40('0x33')](_0x1b5db0[_0x4c40('0x32')]);_0x565d6b[_0x4c40('0x34')]=_[_0x4c40('0x36')](_0x565d6b[_0x4c40('0x31')],_0x565d6b[_0x4c40('0x32')]);_0x5218d2[_0x4c40('0x35')]=_[_0x4c40('0x36')](_0x565d6b[_0x4c40('0x31')],qs[_0x4c40('0x37')](_0x1b5db0['query'][_0x4c40('0x37')]));_0x5218d2[_0x4c40('0x35')]=_0x5218d2[_0x4c40('0x35')][_0x4c40('0x38')]?_0x5218d2[_0x4c40('0x35')]:_0x565d6b[_0x4c40('0x31')];if(!_0x1b5db0['query'][_0x4c40('0x39')](_0x4c40('0x3a'))){_0x5218d2[_0x4c40('0x20')]=qs[_0x4c40('0x20')](_0x1b5db0['query']['limit']);_0x5218d2[_0x4c40('0x1d')]=qs[_0x4c40('0x1d')](_0x1b5db0[_0x4c40('0x32')][_0x4c40('0x1d')]);}_0x5218d2[_0x4c40('0x56')]=qs['sort'](_0x1b5db0['query'][_0x4c40('0x3b')]);_0x5218d2['where']=qs[_0x4c40('0x34')](_['pick'](_0x1b5db0[_0x4c40('0x32')],_0x565d6b[_0x4c40('0x34')]));_0x5218d2[_0x4c40('0x3c')]['ChatWebsiteId']=_0x5795ba['id'];if(_0x1b5db0['query'][_0x4c40('0x57')]){_0x5218d2[_0x4c40('0x3c')]=_[_0x4c40('0x47')](_0x5218d2[_0x4c40('0x3c')],{'$or':_[_0x4c40('0x2d')](_0x5218d2['attributes'],function(_0x11d41c){var _0x54bf97={};_0x54bf97[_0x11d41c]={'$like':'%'+_0x1b5db0['query'][_0x4c40('0x57')]+'%'};return _0x54bf97;})});}_0x5218d2=_['merge']({},_0x5218d2,_0x1b5db0[_0x4c40('0x3f')]);return db[_0x4c40('0x54')][_0x4c40('0x1f')]({'where':_0x5218d2[_0x4c40('0x3c')]})[_0x4c40('0x11')](function(_0x5b73a1){_0x2ce7cc[_0x4c40('0x1f')]=_0x5b73a1;if(_0x1b5db0[_0x4c40('0x32')][_0x4c40('0x40')]){_0x5218d2[_0x4c40('0x41')]=[{'all':!![]}];}return db[_0x4c40('0x54')][_0x4c40('0x42')](_0x5218d2);})[_0x4c40('0x11')](function(_0x799a8){_0x2ce7cc[_0x4c40('0x43')]=_0x799a8;return _0x2ce7cc;});}})[_0x4c40('0x11')](respondWithFilteredResult(_0x15d8ef,_0x5218d2))[_0x4c40('0x1a')](handleError(_0x15d8ef,null));};exports[_0x4c40('0x58')]=function(_0x1e5c3a,_0x117337){return db['ChatWebsite']['find']({'where':{'id':_0x1e5c3a[_0x4c40('0x45')]['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x117337,null))['then'](function(_0x598376){if(_0x598376){return _0x598376[_0x4c40('0x58')](_0x1e5c3a[_0x4c40('0x32')][_0x4c40('0x59')]);}})[_0x4c40('0x11')](respondWithStatusCode(_0x117337,null))['catch'](handleError(_0x117337,null));};exports[_0x4c40('0x5a')]=function(_0x54b6c4,_0x432879){if(_0x54b6c4[_0x4c40('0x4a')]['id']){delete _0x54b6c4[_0x4c40('0x4a')]['id'];}return db[_0x4c40('0x2e')][_0x4c40('0x48')]({'where':{'id':_0x54b6c4[_0x4c40('0x45')]['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x432879,null))[_0x4c40('0x11')](function(_0x7714b0){if(_0x7714b0){_0x54b6c4[_0x4c40('0x4a')][_0x4c40('0x53')]=_0x7714b0['id'];return db[_0x4c40('0x5b')][_0x4c40('0x49')](_0x54b6c4[_0x4c40('0x4a')]);}})[_0x4c40('0x11')](respondWithResult(_0x432879,null))[_0x4c40('0x1a')](handleError(_0x432879,null));};exports[_0x4c40('0x5c')]=function(_0x263ee1,_0x4c33e1){var _0x1aa30f={'raw':![],'where':{}};var _0x49c8ce={};var _0x37ecdf={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x4c40('0x55')]({'where':{'id':_0x263ee1[_0x4c40('0x45')]['id']}})['then'](handleEntityNotFound(_0x4c33e1,null))[_0x4c40('0x11')](function(_0x51597c){if(_0x51597c){_0x49c8ce['model']=_['keys'](db['CannedAnswer'][_0x4c40('0x46')]);_0x49c8ce[_0x4c40('0x32')]=_[_0x4c40('0x33')](_0x263ee1[_0x4c40('0x32')]);_0x49c8ce[_0x4c40('0x34')]=_[_0x4c40('0x36')](_0x49c8ce[_0x4c40('0x31')],_0x49c8ce[_0x4c40('0x32')]);_0x1aa30f[_0x4c40('0x35')]=_['intersection'](_0x49c8ce['model'],qs[_0x4c40('0x37')](_0x263ee1['query'][_0x4c40('0x37')]));_0x1aa30f[_0x4c40('0x35')]=_0x1aa30f['attributes']['length']?_0x1aa30f['attributes']:_0x49c8ce['model'];if(!_0x263ee1[_0x4c40('0x32')][_0x4c40('0x39')](_0x4c40('0x3a'))){_0x1aa30f['limit']=qs[_0x4c40('0x20')](_0x263ee1[_0x4c40('0x32')][_0x4c40('0x20')]);_0x1aa30f[_0x4c40('0x1d')]=qs[_0x4c40('0x1d')](_0x263ee1[_0x4c40('0x32')][_0x4c40('0x1d')]);}_0x1aa30f[_0x4c40('0x56')]=qs['sort'](_0x263ee1[_0x4c40('0x32')]['sort']);_0x1aa30f['where']=qs['filters'](_[_0x4c40('0x3d')](_0x263ee1[_0x4c40('0x32')],_0x49c8ce[_0x4c40('0x34')]));_0x1aa30f[_0x4c40('0x3c')][_0x4c40('0x53')]=_0x51597c['id'];if(_0x263ee1[_0x4c40('0x32')][_0x4c40('0x57')]){_0x1aa30f[_0x4c40('0x3c')]=_[_0x4c40('0x47')](_0x1aa30f[_0x4c40('0x3c')],{'$or':_[_0x4c40('0x2d')](_0x1aa30f[_0x4c40('0x35')],function(_0x7c1a51){var _0x2e1232={};_0x2e1232[_0x7c1a51]={'$like':'%'+_0x263ee1[_0x4c40('0x32')]['filter']+'%'};return _0x2e1232;})});}_0x1aa30f=_[_0x4c40('0x47')]({},_0x1aa30f,_0x263ee1[_0x4c40('0x3f')]);return db[_0x4c40('0x5b')][_0x4c40('0x1f')]({'where':_0x1aa30f[_0x4c40('0x3c')]})[_0x4c40('0x11')](function(_0x54b7d8){_0x37ecdf[_0x4c40('0x1f')]=_0x54b7d8;if(_0x263ee1[_0x4c40('0x32')][_0x4c40('0x40')]){_0x1aa30f[_0x4c40('0x41')]=[{'all':!![]}];}return db['CannedAnswer']['findAll'](_0x1aa30f);})[_0x4c40('0x11')](function(_0x14997f){_0x37ecdf['rows']=_0x14997f;return _0x37ecdf;});}})[_0x4c40('0x11')](respondWithFilteredResult(_0x4c33e1,_0x1aa30f))['catch'](handleError(_0x4c33e1,null));};exports[_0x4c40('0x5d')]=function(_0x51801c,_0x5ee3ad){return db[_0x4c40('0x2e')][_0x4c40('0x48')]({'where':{'id':_0x51801c[_0x4c40('0x45')]['id']}})['then'](handleEntityNotFound(_0x5ee3ad,null))[_0x4c40('0x11')](function(_0x321186){if(_0x321186){return _0x321186[_0x4c40('0x5d')](_0x51801c[_0x4c40('0x32')]['ids']);}})[_0x4c40('0x11')](respondWithStatusCode(_0x5ee3ad,null))[_0x4c40('0x1a')](handleError(_0x5ee3ad,null));};exports['addLogo']=function(_0x3642f0,_0x90ebd8){_0x3642f0[_0x4c40('0x4a')][_0x4c40('0x5e')]=_0x3642f0[_0x4c40('0x5f')][_0x4c40('0x60')];return db['ChatWebsite'][_0x4c40('0x48')]({'where':{'id':_0x3642f0[_0x4c40('0x45')]['id']}})['then'](handleEntityNotFound(_0x90ebd8,null))[_0x4c40('0x11')](saveUpdates(_0x3642f0[_0x4c40('0x4a')],null))['then'](respondWithResult(_0x90ebd8,null))[_0x4c40('0x1a')](handleError(_0x90ebd8,null));};exports[_0x4c40('0x61')]=function(_0x47ff76,_0x59ad6a){_0x47ff76[_0x4c40('0x4a')][_0x4c40('0x62')]=_0x47ff76[_0x4c40('0x5f')][_0x4c40('0x60')];return db[_0x4c40('0x2e')][_0x4c40('0x48')]({'where':{'id':_0x47ff76[_0x4c40('0x45')]['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x59ad6a,null))['then'](saveUpdates(_0x47ff76[_0x4c40('0x4a')],null))[_0x4c40('0x11')](respondWithResult(_0x59ad6a,null))[_0x4c40('0x1a')](handleError(_0x59ad6a,null));};exports['addCustomerAvatar']=function(_0x244fe4,_0xef5682){_0x244fe4['body'][_0x4c40('0x63')]=_0x244fe4[_0x4c40('0x5f')][_0x4c40('0x60')];return db[_0x4c40('0x2e')]['find']({'where':{'id':_0x244fe4[_0x4c40('0x45')]['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0xef5682,null))[_0x4c40('0x11')](saveUpdates(_0x244fe4['body'],null))[_0x4c40('0x11')](respondWithResult(_0xef5682,null))[_0x4c40('0x1a')](handleError(_0xef5682,null));};exports['addSystemAvatar']=function(_0x45f819,_0x37357e){_0x45f819[_0x4c40('0x4a')][_0x4c40('0x64')]=_0x45f819[_0x4c40('0x5f')][_0x4c40('0x60')];return db['ChatWebsite'][_0x4c40('0x48')]({'where':{'id':_0x45f819[_0x4c40('0x45')]['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x37357e,null))['then'](saveUpdates(_0x45f819[_0x4c40('0x4a')],null))['then'](respondWithResult(_0x37357e,null))[_0x4c40('0x1a')](handleError(_0x37357e,null));};exports[_0x4c40('0x65')]=function(_0x11d3a4,_0x36def0){var _0x40a781=path[_0x4c40('0x66')](config[_0x4c40('0x67')],'server/files/images/logos/default_logo.svg');var _0x1c83d8={'where':{'id':_0x11d3a4['params']['id']},'attributes':['id',_0x4c40('0x5e')],'raw':!![]};var _0x505c2f=![];return require('../../config/license/util')[_0x4c40('0x68')]()['then'](function(_0x1474e4){if(_0x1474e4){_0x505c2f=_0x1474e4[_0x4c40('0x69')];}})[_0x4c40('0x11')](function(){return db['ChatWebsite'][_0x4c40('0x48')](_0x1c83d8);})[_0x4c40('0x11')](handleEntityNotFound(_0x36def0,null))['then'](function(_0x3e4fcb){if(_0x3e4fcb){if(!_[_0x4c40('0x6a')](_0x3e4fcb[_0x4c40('0x5e')])){if(fs[_0x4c40('0x6b')](path['join'](config[_0x4c40('0x67')],_0x4c40('0x6c'),_0x3e4fcb[_0x4c40('0x5e')]))&&_0x505c2f){_0x40a781=path[_0x4c40('0x66')](config[_0x4c40('0x67')],_0x4c40('0x6c'),_0x3e4fcb[_0x4c40('0x5e')]);}}return _0x36def0[_0x4c40('0x6d')](_0x40a781);}})[_0x4c40('0x1a')](handleError(_0x36def0,null));};exports[_0x4c40('0x6e')]=function(_0x3b2d0d,_0x367b7b){var _0xec9a21=path['join'](config[_0x4c40('0x67')],_0x4c40('0x6f'));var _0xb4ca85={'where':{'id':_0x3b2d0d[_0x4c40('0x45')]['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db['ChatWebsite'][_0x4c40('0x48')](_0xb4ca85)[_0x4c40('0x11')](handleEntityNotFound(_0x367b7b,null))[_0x4c40('0x11')](function(_0x31e473){if(_0x31e473){if(!_[_0x4c40('0x6a')](_0x31e473[_0x4c40('0x62')])){if(fs[_0x4c40('0x6b')](path['join'](config['root'],_0x4c40('0x70'),_0x31e473['agentAvatar']))){_0xec9a21=path['join'](config[_0x4c40('0x67')],_0x4c40('0x70'),_0x31e473['agentAvatar']);}}return _0x367b7b[_0x4c40('0x6d')](_0xec9a21);}})['catch'](handleError(_0x367b7b,null));};exports[_0x4c40('0x71')]=function(_0x337ea2,_0x2bce1a){var _0x1e81bb=path[_0x4c40('0x66')](config[_0x4c40('0x67')],_0x4c40('0x72'));var _0x3a7fb1={'where':{'id':_0x337ea2[_0x4c40('0x45')]['id']},'attributes':['id',_0x4c40('0x63'),_0x4c40('0x73')],'raw':!![]};return db[_0x4c40('0x2e')]['find'](_0x3a7fb1)[_0x4c40('0x11')](handleEntityNotFound(_0x2bce1a,null))[_0x4c40('0x11')](function(_0x13a797){if(_0x13a797){if(!_[_0x4c40('0x6a')](_0x13a797['customerAvatar'])){if(fs['existsSync'](path[_0x4c40('0x66')](config[_0x4c40('0x67')],'server/files/images/avatars/',_0x13a797[_0x4c40('0x63')]))&&_0x13a797[_0x4c40('0x73')]){_0x1e81bb=path[_0x4c40('0x66')](config[_0x4c40('0x67')],_0x4c40('0x70'),_0x13a797[_0x4c40('0x63')]);}}return _0x2bce1a[_0x4c40('0x6d')](_0x1e81bb);}})[_0x4c40('0x1a')](handleError(_0x2bce1a,null));};exports[_0x4c40('0x74')]=function(_0x4ef34b,_0x3ee898){var _0x370805=path['join'](config[_0x4c40('0x67')],'server/files/images/avatars/system_avatar.png');var _0x251377={'where':{'id':_0x4ef34b[_0x4c40('0x45')]['id']},'attributes':['id',_0x4c40('0x64')],'raw':!![]};return db[_0x4c40('0x2e')][_0x4c40('0x48')](_0x251377)['then'](handleEntityNotFound(_0x3ee898,null))['then'](function(_0x5ddc7f){if(_0x5ddc7f){if(!_['isNil'](_0x5ddc7f[_0x4c40('0x64')])){if(fs[_0x4c40('0x6b')](path[_0x4c40('0x66')](config[_0x4c40('0x67')],_0x4c40('0x70'),_0x5ddc7f['systemAvatar']))){_0x370805=path[_0x4c40('0x66')](config[_0x4c40('0x67')],_0x4c40('0x70'),_0x5ddc7f['systemAvatar']);}}return _0x3ee898[_0x4c40('0x6d')](_0x370805);}})[_0x4c40('0x1a')](handleError(_0x3ee898,null));};exports[_0x4c40('0x75')]=function(_0x3496f7,_0x5f15ec){var _0x155459=require('user-agent-parser');var _0x5a1599=new _0x155459();var _0x2f699c=_0x5a1599['setUA'](_0x3496f7[_0x4c40('0x76')][_0x4c40('0x77')])[_0x4c40('0x78')]();var _0x39a39c={'body':_0x3496f7[_0x4c40('0x4a')],'channel':_0x4c40('0x79')};var _0x1e9909=[];var _0x4e8493=[];var _0x3d68d8={};var _0x31eb2d=![];return db['CmContact'][_0x4c40('0x51')]()[_0x4c40('0x11')](function(_0x5066){if(!_0x5066){throw new db[(_0x4c40('0x7a'))][(_0x4c40('0x7b'))](_0x4c40('0x7c'));}_0x1e9909=_[_0x4c40('0x7d')](_[_0x4c40('0x33')](_0x5066),[_0x4c40('0x7e'),_0x4c40('0x7f')]);_0x4e8493=_['difference'](_['keys'](_0x5066),[_0x4c40('0x7e'),_0x4c40('0x7f'),_0x4c40('0x80'),_0x4c40('0x81')]);if(_0x3496f7[_0x4c40('0x4a')]['id']){delete _0x3496f7[_0x4c40('0x4a')]['id'];}if(_['isNil'](_0x3496f7[_0x4c40('0x4a')]['from'])){throw new db['Sequelize'][(_0x4c40('0x7b'))]('from\x20is\x20mandatory');}if(_[_0x4c40('0x6a')](_0x3496f7[_0x4c40('0x4a')][_0x4c40('0x4a')])||_0x3496f7[_0x4c40('0x4a')]['body']===''){throw new db[(_0x4c40('0x7a'))][(_0x4c40('0x7b'))](_0x4c40('0x82'));}if(_[_0x4c40('0x6a')](_0x3496f7[_0x4c40('0x4a')]['mapKey'])){throw new db[(_0x4c40('0x7a'))]['ValidationError'](_0x4c40('0x83')+_0x4e8493);}if(!_[_0x4c40('0x84')](_0x4e8493,_0x3496f7[_0x4c40('0x4a')]['mapKey'])){throw new db[(_0x4c40('0x7a'))][(_0x4c40('0x7b'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4e8493);}_0x3d68d8[_0x3496f7[_0x4c40('0x4a')][_0x4c40('0x85')]]=_0x3496f7['body'][_0x4c40('0x86')];})[_0x4c40('0x11')](function(){return db[_0x4c40('0x2e')][_0x4c40('0x48')]({'where':{'id':_0x3496f7['params']['id']},'include':[{'model':db['CmList'],'as':_0x4c40('0x87'),'include':[{'model':db[_0x4c40('0x88')],'as':'Contacts','where':_0x3d68d8,'limit':0x1,'order':[[_0x4c40('0x7f'),'DESC']]}]},{'model':db[_0x4c40('0x89')],'as':'Applications'}]});})[_0x4c40('0x11')](handleEntityNotFound(_0x5f15ec,null))[_0x4c40('0x11')](function(_0x4e9161){if(_0x4e9161&&_0x4e9161[_0x4c40('0x87')]){_0x39a39c[_0x4c40('0x8a')]=_0x4e9161;_0x39a39c[_0x4c40('0x8b')]=_0x4e9161[_0x4c40('0x8c')];_0x39a39c[_0x4c40('0x8d')]=_0x4e9161[_0x4c40('0x87')];_0x39a39c[_0x4c40('0x8b')]=_[_0x4c40('0x8e')](_0x39a39c['applications'],[_0x4c40('0x8f')],['asc']);if(_0x39a39c[_0x4c40('0x8a')][_0x4c40('0x8c')]){delete _0x39a39c[_0x4c40('0x8a')]['Applications'];}if(_0x39a39c[_0x4c40('0x8a')][_0x4c40('0x87')]&&_0x39a39c['account'][_0x4c40('0x87')]['Contacts']['length']){return _0x39a39c[_0x4c40('0x8a')][_0x4c40('0x87')]['Contacts'][0x0];}var _0x4a6429=_[_0x4c40('0xa')](_0x3496f7[_0x4c40('0x4a')],{'firstName':_0x3496f7['body'][_0x4c40('0x86')],'ListId':_0x4e9161[_0x4c40('0x81')]});_0x4a6429[_0x3496f7[_0x4c40('0x4a')][_0x4c40('0x85')]]=_0x3496f7['body'][_0x4c40('0x86')];return db[_0x4c40('0x88')][_0x4c40('0x49')](_0x4a6429,{'fields':_0x1e9909,'raw':!![]});}})[_0x4c40('0x11')](handleEntityNotFound(_0x5f15ec,null))[_0x4c40('0x11')](function(_0x1751f4){_0x39a39c['contact']=_0x1751f4;var _0x1b1662=_0x3496f7[_0x4c40('0x4a')][_0x4c40('0x90')];if(_0x3496f7['headers'][_0x4c40('0x91')]){_0x1b1662=_0x3496f7[_0x4c40('0x76')][_0x4c40('0x91')];}else if(_0x3496f7[_0x4c40('0x76')][_0x4c40('0x92')]){_0x1b1662=_[_0x4c40('0x93')](_0x3496f7['headers']['x-forwarded-for'][_0x4c40('0x94')](','));}if(_0x1751f4){var _0x2494b0={'ContactId':_0x1751f4['id'],'ChatWebsiteId':_0x3496f7[_0x4c40('0x45')]['id'],'from':(_0x1751f4[_0x4c40('0x95')]||'')+'\x20'+(_0x1751f4['lastName']||''),'customerIp':_0x1b1662,'customerPort':_0x3496f7[_0x4c40('0x76')][_0x4c40('0x96')]?_0x3496f7[_0x4c40('0x76')][_0x4c40('0x96')]:null,'referer':_0x3496f7[_0x4c40('0x4a')][_0x4c40('0x97')],'browserName':_0x2f699c[_0x4c40('0x98')]['name']&&_0x2f699c[_0x4c40('0x98')][_0x4c40('0x99')]?util[_0x4c40('0x9a')](_0x4c40('0x9b'),_0x2f699c['browser']['name'],_0x2f699c[_0x4c40('0x98')][_0x4c40('0x99')]):'unknown','browserVersion':_0x2f699c[_0x4c40('0x98')][_0x4c40('0x99')]||_0x4c40('0x9c'),'osName':util[_0x4c40('0x9a')](_0x4c40('0x9b'),_0x2f699c['os'][_0x4c40('0x29')],_0x2f699c['os'][_0x4c40('0x99')]),'osVersion':_0x2f699c['os']['version'],'deviceModel':_0x2f699c[_0x4c40('0x9d')][_0x4c40('0x31')]&&_0x2f699c[_0x4c40('0x9d')][_0x4c40('0x9e')]?util[_0x4c40('0x9a')]('%s\x20%s\x20%s',_0x2f699c['device'][_0x4c40('0x31')],_0x2f699c[_0x4c40('0x9d')]['vendor'],_0x2f699c[_0x4c40('0x9d')][_0x4c40('0x9f')]):null,'deviceVendor':_0x2f699c[_0x4c40('0x9d')]['vendor'],'deviceType':_0x2f699c[_0x4c40('0x9d')][_0x4c40('0x9f')],'formData':JSON[_0x4c40('0x15')](_0x3496f7['body'])};var _0x458e92={'ChatWebsiteId':_0x3496f7[_0x4c40('0x45')]['id'],'closed':![]};if(_0x3496f7[_0x4c40('0x4a')][_0x4c40('0xa0')]){_0x458e92[_0x4c40('0xa0')]=_0x3496f7[_0x4c40('0x4a')][_0x4c40('0xa0')];return db['ChatInteraction']['find']({'where':_0x458e92})[_0x4c40('0x11')](function(_0x49a7fd){if(_0x49a7fd){return[_0x49a7fd,![]];}_0x2494b0[_0x4c40('0xa0')]=_0x3496f7[_0x4c40('0x4a')]['threadId'];_0x2494b0[_0x4c40('0xa1')]=_0x3496f7[_0x4c40('0x4a')][_0x4c40('0xa1')];return db['ChatInteraction'][_0x4c40('0x49')](_0x2494b0)[_0x4c40('0x11')](function(_0x1a3efb){return[_0x1a3efb,!![]];});});}_0x458e92[_0x4c40('0xa2')]=_0x1751f4['id'];if(_0x3496f7[_0x4c40('0x4a')][_0x4c40('0xa3')]&&_0x3496f7[_0x4c40('0x4a')][_0x4c40('0xa3')]['id']){_0x458e92['id']=_0x3496f7[_0x4c40('0x4a')][_0x4c40('0xa3')]['id'];return db[_0x4c40('0xa4')]['find']({'where':_0x458e92})['then'](function(_0x45a759){if(_0x45a759){return[_0x45a759,![]];}return db[_0x4c40('0xa4')][_0x4c40('0x49')](_0x2494b0)[_0x4c40('0x11')](function(_0x4027a0){return[_0x4027a0,!![]];});});}return db[_0x4c40('0xa4')][_0x4c40('0x49')](_0x2494b0)[_0x4c40('0x11')](function(_0x205bae){return[_0x205bae,!![]];});}})[_0x4c40('0xa5')](function(_0x4cb7cc,_0xf8bc61){if(_0x4cb7cc){_0x31eb2d=_0xf8bc61;if(!_0xf8bc61){var _0x59b86f={'from':(_0x39a39c[_0x4c40('0xa6')]['firstName']||'')+'\x20'+(_0x39a39c[_0x4c40('0xa6')][_0x4c40('0xa7')]||'')};if(_0x3496f7[_0x4c40('0x4a')][_0x4c40('0xa0')]&&_0x3496f7[_0x4c40('0x4a')][_0x4c40('0xa8')]&&_0x3496f7['body'][_0x4c40('0xa0')]!=_0x3496f7[_0x4c40('0x4a')][_0x4c40('0xa8')]){_0x59b86f[_0x4c40('0xa0')]=_0x3496f7[_0x4c40('0x4a')][_0x4c40('0xa8')];}return _0x4cb7cc[_0x4c40('0x23')](_0x59b86f);}else{return _0x4cb7cc;}}})[_0x4c40('0x11')](function(_0x1c1924){_0x39a39c[_0x4c40('0xa3')]=_0x1c1924[_0x4c40('0x4e')]({'plain':!![]});_0x39a39c[_0x4c40('0xa3')][_0x4c40('0xa9')]=_0x31eb2d;if(_0x39a39c[_0x4c40('0xa3')][_0x4c40('0xa9')]){if(_0x39a39c['account'][_0x4c40('0xaa')]){_0x39a39c[_0x4c40('0x8b')]['push']({'id':0x0,'priority':_0x39a39c['applications'][_0x4c40('0x38')]+0x1,'app':_0x4c40('0xab'),'appdata':_0x4c40('0xac'),'interval':_0x4c40('0xad')});}}return db['ChatMessage'][_0x4c40('0x49')]({'body':_0x3496f7[_0x4c40('0x4a')]['body'],'ChatWebsiteId':_0x3496f7['params']['id'],'ChatInteractionId':_0x1c1924['id'],'direction':'in','ContactId':_0x39a39c[_0x4c40('0xa6')]['id'],'AttachmentId':_0x3496f7[_0x4c40('0x4a')][_0x4c40('0xae')]});})[_0x4c40('0x11')](function(_0x6beb65){_0x39a39c['message']=_0x6beb65;if(_0x39a39c['interaction'][_0x4c40('0xaf')]){return db[_0x4c40('0xb0')][_0x4c40('0x48')]({'attributes':['id','name'],'where':{'id':_0x39a39c[_0x4c40('0xa3')][_0x4c40('0xaf')]}})[_0x4c40('0x11')](function(_0x52938e){if(_0x52938e){_0x39a39c[_0x4c40('0x8b')][_0x4c40('0xb1')]({'id':0x0,'priority':0x0,'app':_0x4c40('0xb2'),'appdata':_0x52938e[_0x4c40('0x29')]+','+(_0x39a39c['account'][_0x4c40('0xb3')]||0xa),'interval':_0x4c40('0xad')});_0x39a39c[_0x4c40('0xb4')]=!![];}return respondWithRpcPromise(_0x4c40('0xb5'),_0x4c40('0xb6'),_0x39a39c);});}return respondWithRpcPromise('Start',_0x4c40('0xb6'),_0x39a39c);})[_0x4c40('0x11')](function(_0x235df2){respondWithRpcPromise(_0x4c40('0xb7'),_0x4c40('0xb7'),{'event':'notify','message':_0x235df2},client9002);return _0x235df2;})['then'](respondWithResult(_0x5f15ec,null))['catch'](handleError(_0x5f15ec,null));};exports[_0x4c40('0xb8')]=function(_0x4e5c4c,_0x31a94f){var _0xd371bd,_0x11ba06,_0x95c24c;var _0x29f3de=[];var _0x5a1966={};var _0x265d10=_0x4e5c4c[_0x4c40('0xb9')]||[];var _0x110b3d=[];var _0x5f3dd5;return db[_0x4c40('0x88')]['describe']()[_0x4c40('0x11')](function(_0x5d6818){if(!_0x5d6818){throw new db[(_0x4c40('0x7a'))][(_0x4c40('0x7b'))](_0x4c40('0x7c'));}_0x29f3de=_['difference'](_[_0x4c40('0x33')](_0x5d6818),[_0x4c40('0x7e'),_0x4c40('0x7f'),_0x4c40('0x80'),_0x4c40('0x81')]);if(_0x4e5c4c['body']['id']){delete _0x4e5c4c['body']['id'];}if(_[_0x4c40('0x6a')](_0x4e5c4c[_0x4c40('0x4a')][_0x4c40('0x86')])){throw _0x31a94f[_0x4c40('0x1b')](0x1f4)[_0x4c40('0x2a')](new db['Sequelize'][(_0x4c40('0x7b'))](_0x4c40('0xba')));}if(_['isNil'](_0x4e5c4c[_0x4c40('0x4a')]['body'])||_0x4e5c4c[_0x4c40('0x4a')][_0x4c40('0x4a')]===''){throw _0x31a94f[_0x4c40('0x1b')](0x1f4)[_0x4c40('0x2a')](new db[(_0x4c40('0x7a'))][(_0x4c40('0x7b'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0x4c40('0x6a')](_0x4e5c4c[_0x4c40('0x4a')]['mapKeyOffline'])){throw _0x31a94f[_0x4c40('0x1b')](0x1f4)[_0x4c40('0x2a')](new db[(_0x4c40('0x7a'))][(_0x4c40('0x7b'))](_0x4c40('0xbb')+_0x29f3de));}if(!_[_0x4c40('0x84')](_0x29f3de,_0x4e5c4c[_0x4c40('0x4a')][_0x4c40('0xbc')])){throw _0x31a94f[_0x4c40('0x1b')](0x1f4)[_0x4c40('0x2a')](new db[(_0x4c40('0x7a'))][(_0x4c40('0x7b'))](_0x4c40('0xbd')+_0x29f3de));}_0x5a1966[_0x4e5c4c[_0x4c40('0x4a')][_0x4c40('0xbc')]]=_0x4e5c4c['body']['from'];})[_0x4c40('0x11')](function(){return db['ChatWebsite']['find']({'where':{'id':_0x4e5c4c[_0x4c40('0x45')]['id']},'include':[{'model':db[_0x4c40('0xbe')],'as':_0x4c40('0x87')},{'model':db[_0x4c40('0xbf')],'as':'MailAccount'}]});})[_0x4c40('0x11')](handleEntityNotFound(_0x31a94f,null))[_0x4c40('0x11')](function(_0x5797d2){if(_0x5797d2&&_0x5797d2[_0x4c40('0x87')]){_0x11ba06=_0x5797d2;var _0x2fcb4e=_['defaults'](_0x4e5c4c[_0x4c40('0x4a')],{'firstName':_0x4e5c4c['body'][_0x4c40('0x86')],'phone':_0x4e5c4c[_0x4c40('0x4a')][_0x4c40('0x86')],'ListId':_0x5797d2[_0x4c40('0x81')]});_0x2fcb4e[_0x4e5c4c['body'][_0x4c40('0xbc')]]=_0x4e5c4c['body'][_0x4c40('0x86')];return db[_0x4c40('0x88')][_0x4c40('0xc0')]({'where':_0x5a1966,'defaults':_0x2fcb4e});}})[_0x4c40('0xa5')](function(_0x176462){if(_0x176462){_0x95c24c=_0x176462;var _0x5d86b3=fs[_0x4c40('0xc1')](path[_0x4c40('0x66')](config['root'],_0x4c40('0xc2')),_0x4c40('0xc3'));var _0xd9a624=ejs[_0x4c40('0xc4')](_0x5d86b3,{'body':_['toPairs'](_0x4e5c4c[_0x4c40('0x4a')][_0x4c40('0x4a')]),'bodyTitle':_0x11ba06[_0x4c40('0xc5')]});return db[_0x4c40('0xc6')][_0x4c40('0x49')]({'body':_0xd9a624,'plainBody':htmlToText[_0x4c40('0xc7')](_0xd9a624),'ContactId':_0x176462['id'],'ChatWebsiteId':_0x11ba06['id']});}})[_0x4c40('0x11')](function(_0x488e76){_0x5f3dd5=_0x488e76;if(_0x265d10[_0x4c40('0x38')]){var _0x5f5146=_0x265d10[_0x4c40('0x2d')](function(_0x559fe6){return{'name':_0x559fe6['originalname'],'basename':_0x559fe6[_0x4c40('0x60')],'type':_0x559fe6[_0x4c40('0xc8')],'ChatOfflineMessageId':_0x488e76['id']};});_0x110b3d=_0x5f5146[_0x4c40('0x2d')](_0x16fab3=>{var _0x183032={'filename':_0x16fab3[_0x4c40('0x29')],'path':path[_0x4c40('0x66')](config[_0x4c40('0x67')],_0x4c40('0xc9'),_0x4c40('0xb9'),'attachments',_0x4c40('0xca'),_0x16fab3[_0x4c40('0xcb')])};return _0x183032;});if(!_0x11ba06[_0x4c40('0xcc')]){return db['sequelize'][_0x4c40('0xcd')](function(_0x5bb2dd){return db['Attachment']['bulkCreate'](_0x5f5146,{'transaction':_0x5bb2dd});});}}})['then'](function(){if(_0x5f3dd5){_0xd371bd=_0x5f3dd5;return db['MailAccount'][_0x4c40('0x55')]({'where':{'service':!![]},'include':[{'model':db[_0x4c40('0xce')],'as':_0x4c40('0xcf'),'raw':!![],'include':[{'model':db['CloudProvider'],'as':_0x4c40('0xd0'),'raw':!![]}]}]});}})[_0x4c40('0x11')](function(_0x4c7608){if(_0x4c7608&&_0x4c7608['Smtp']&&_0x11ba06[_0x4c40('0xd1')]&&_0x11ba06[_0x4c40('0xd2')]){var _0x63e82d=_0x4c7608[_0x4c40('0xd3')]();return respondWithRpcPromise(_0x4c40('0xd4'),_0x4c40('0xd5'),{'account':_0x63e82d,'message':{'from':util[_0x4c40('0x9a')]('\x22%s\x22\x20<%s>',_0x4c7608[_0x4c40('0x29')],_0x4c7608[_0x4c40('0xd6')]||_0x4c7608[_0x4c40('0xcf')][_0x4c40('0x4d')]),'to':_0x11ba06[_0x4c40('0xd2')],'subject':_0x11ba06[_0x4c40('0xd7')],'html':_0xd371bd[_0x4c40('0x4a')],'attachments':_0x110b3d}},client9003)['then'](function(){return _0xd371bd;})['catch'](function(_0x573dd9){logger[_0x4c40('0x16')](_0x573dd9);});}})[_0x4c40('0x11')](function(){if(_0x11ba06&&_0x11ba06[_0x4c40('0xcc')]&&_0x11ba06[_0x4c40('0xd8')]){var _0x568a2a=[];if(_0x265d10[_0x4c40('0x38')]){_0x568a2a=_0x265d10[_0x4c40('0x2d')](function(_0x3490b1){return{'name':_0x3490b1[_0x4c40('0xd9')],'basename':_0x3490b1[_0x4c40('0x60')],'type':_0x3490b1['mimetype'],'ChatOfflineMessageId':_0x5f3dd5['id']};});}var _0x2eef60;if(!_[_0x4c40('0x6a')](_0x11ba06[_0x4c40('0xda')])){var _0x25d373=_[_0x4c40('0x2d')](_0x4e5c4c[_0x4c40('0x4a')],function(_0x130711){return _0x130711;});var _0x203d83=_['toPairsIn'](_0x25d373)[0x0];var _0x17a536=_[_0x4c40('0xdb')](_0x203d83,function(_0xffdd88){return _0xffdd88;});_0x2eef60=_0x17a536[0x1][_0x11ba06[_0x4c40('0xda')]];}var _0x21f671={'from':_0x95c24c[_0x4c40('0xd6')],'firstName':_0x95c24c[_0x4c40('0x95')],'lastName':_0x95c24c[_0x4c40('0xa7')],'mapKey':_0x4c40('0xd6'),'message':{'from':_0x95c24c['email'],'to':_0x11ba06[_0x4c40('0xbf')]['email'],'cc':'','subject':_[_0x4c40('0x6a')](_0x2eef60)?_0x11ba06[_0x4c40('0xd7')]:_0x2eef60,'messageId':'','sentAt':new Date(),'attach':_0x568a2a[_0x4c40('0x38')],'attachments':_0x568a2a,'originChannel':_0x4c40('0xdc'),'ChatWebsiteId':_0x11ba06['id'],'ChatOfflineMessageId':_0xd371bd['id'],'originTo':_0x11ba06[_0x4c40('0xbf')][_0x4c40('0xd6')]},'body':_0xd371bd[_0x4c40('0x4a')]};var _0x5472bf={'account':{'id':_0x11ba06[_0x4c40('0xd8')]},'body':_0x21f671,'log':_0x4c40('0xdd')};return respondWithRpcPromise(_0x4c40('0xdd'),_0x4c40('0xde'),_0x5472bf,client9001)['then'](function(){return _0xd371bd;})[_0x4c40('0x1a')](function(_0x416bdb){logger[_0x4c40('0x16')](_0x416bdb);});}return;})['then'](function(){if(_0xd371bd){return _0xd371bd;}})[_0x4c40('0x11')](respondWithResult(_0x31a94f,null))['catch'](function(_0x42744c){logger[_0x4c40('0x16')](_0x4c40('0x1a'),_0x42744c);for(var _0x18f530 of _0x265d10){var _0x31861c=path[_0x4c40('0x66')](config[_0x4c40('0x67')],_0x4c40('0xc9'),_0x4c40('0xb9'),_0x4c40('0xdf'),'offline-chat',_0x18f530[_0x4c40('0x60')]);fs_extra[_0x4c40('0xe0')](_0x31861c)[_0x4c40('0x1a')](function(_0x313648){logger['error'](_0x4c40('0xe1'),_0x31861c,_0x313648);});}});};exports['addInteraction']=function(_0xc80662,_0x3df6ab){return db[_0x4c40('0xa4')][_0x4c40('0x48')]({'where':{'id':_0xc80662['params']['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x3df6ab,null))['then'](function(_0x1f291c){if(_0x1f291c){return _0x1f291c[_0x4c40('0xe2')](_0xc80662[_0x4c40('0x4a')][_0x4c40('0x59')],_['omit'](_0xc80662['body'],[_0x4c40('0x59'),'id'])||{});}})['then'](respondWithResult(_0x3df6ab,null))[_0x4c40('0x1a')](handleError(_0x3df6ab,null));};exports[_0x4c40('0xe3')]=function(_0x827b73,_0x2e663f){var _0x42614a={'raw':![],'where':{}};var _0x4c101b={};var _0x25e3eb={'count':0x0,'rows':[]};return db[_0x4c40('0x2e')][_0x4c40('0x55')]({'where':{'id':_0x827b73['params']['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x2e663f,null))[_0x4c40('0x11')](function(_0x1643d2){if(_0x1643d2){_0x4c101b[_0x4c40('0x31')]=_[_0x4c40('0x33')](db[_0x4c40('0xa4')]['rawAttributes']);_0x4c101b[_0x4c40('0x32')]=_[_0x4c40('0x33')](_0x827b73[_0x4c40('0x32')]);_0x4c101b[_0x4c40('0x34')]=_[_0x4c40('0x36')](_0x4c101b[_0x4c40('0x31')],_0x4c101b[_0x4c40('0x32')]);_0x42614a['attributes']=_[_0x4c40('0x36')](_0x4c101b[_0x4c40('0x31')],qs['fields'](_0x827b73[_0x4c40('0x32')][_0x4c40('0x37')]));_0x42614a[_0x4c40('0x35')]=_0x42614a['attributes']['length']?_0x42614a['attributes']:_0x4c101b[_0x4c40('0x31')];if(!_0x827b73[_0x4c40('0x32')][_0x4c40('0x39')](_0x4c40('0x3a'))){_0x42614a[_0x4c40('0x20')]=qs[_0x4c40('0x20')](_0x827b73[_0x4c40('0x32')]['limit']);_0x42614a['offset']=qs[_0x4c40('0x1d')](_0x827b73[_0x4c40('0x32')][_0x4c40('0x1d')]);}_0x42614a['order']=qs['sort'](_0x827b73[_0x4c40('0x32')][_0x4c40('0x3b')]);_0x42614a['where']=qs[_0x4c40('0x34')](_['pick'](_0x827b73[_0x4c40('0x32')],_0x4c101b[_0x4c40('0x34')]));_0x42614a[_0x4c40('0x3c')][_0x4c40('0x53')]=_0x1643d2['id'];if(_0x827b73[_0x4c40('0x32')][_0x4c40('0x57')]){_0x42614a[_0x4c40('0x3c')]=_['merge'](_0x42614a[_0x4c40('0x3c')],{'$or':_[_0x4c40('0x2d')](_0x42614a[_0x4c40('0x35')],function(_0x192e6f){var _0x4d9b39={};_0x4d9b39[_0x192e6f]={'$like':'%'+_0x827b73['query'][_0x4c40('0x57')]+'%'};return _0x4d9b39;})});}_0x42614a=_[_0x4c40('0x47')]({},_0x42614a,_0x827b73['options']);return db[_0x4c40('0xa4')][_0x4c40('0x1f')]({'where':_0x42614a[_0x4c40('0x3c')]})[_0x4c40('0x11')](function(_0x55622b){_0x25e3eb[_0x4c40('0x1f')]=_0x55622b;if(_0x827b73[_0x4c40('0x32')]['includeAll']){_0x42614a['include']=[{'model':db[_0x4c40('0x88')],'as':_0x4c40('0xe4'),'required':![]},{'model':db[_0x4c40('0xb0')],'as':_0x4c40('0xe5'),'attributes':[_0x4c40('0x29'),'fullname','internal'],'required':![]},{'model':db[_0x4c40('0xe6')],'as':_0x4c40('0xe7'),'attributes':['id',_0x4c40('0x29'),_0x4c40('0xe8')],'where':_0x827b73[_0x4c40('0x32')][_0x4c40('0xe9')]?{'id':_0x827b73[_0x4c40('0x32')][_0x4c40('0xe9')]}:undefined,'required':_0x827b73[_0x4c40('0x32')][_0x4c40('0xe9')]?!![]:![]}];}return db[_0x4c40('0xa4')]['findAll'](_0x42614a);})[_0x4c40('0x11')](function(_0x55c181){_0x25e3eb[_0x4c40('0x43')]=_0x55c181;return _0x25e3eb;});}})[_0x4c40('0x11')](respondWithFilteredResult(_0x2e663f,_0x42614a))[_0x4c40('0x1a')](handleError(_0x2e663f,null));};function iftimePromise(_0x247d06,_0x3649ca){return respondWithRpcPromise(_0x4c40('0xea'),_0x4c40('0xeb'),{'command':_0x3649ca['timezone']?util['format'](_0x4c40('0xec'),_0x247d06[_0x4c40('0xed')],_0x3649ca[_0x4c40('0xee')]):util['format']('iftime\x20%s',_0x247d06[_0x4c40('0xed')])},client9002)['then'](function(_0x1007b4){var _0x136641=_0x1007b4&&_0x1007b4['indexOf']('true')>=0x0?!![]:![];logger['info']('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x3649ca['id'],_0x247d06['id'],_0x247d06[_0x4c40('0xed')],_0x136641?_0x4c40('0xef'):_0x4c40('0xf0'),_0x3649ca['timezone']?_0x3649ca[_0x4c40('0xee')]:'No\x20timezone');return _0x136641;})[_0x4c40('0x1a')](function(_0x44c32a){logger[_0x4c40('0x16')](_0x4c40('0xf1'),_0x3649ca['id'],_0x247d06['id'],_0x247d06['interval'],util['inspect'](_0x44c32a,{'showHidden':![],'depth':null}),_0x3649ca['timezone']?_0x3649ca['timezone']:'No\x20timezone');return![];});}exports['getSnippet']=function(_0x2fe97f,_0xaf85cd){var _0x12d480=0x0;var _0x507113=0x0;var _0xfe0d09=![];var _0x32e689;var _0x15dd73;return db['ChatWebsite'][_0x4c40('0x48')]({'where':{'id':_0x2fe97f['params']['id']},'include':[{'model':db[_0x4c40('0xf2')],'as':_0x4c40('0xf2'),'include':[{'model':db[_0x4c40('0xf2')],'as':_0x4c40('0xf3'),'attributes':['id','interval'],'raw':!![]}]}]})[_0x4c40('0x11')](handleEntityNotFound(_0xaf85cd,null))['then'](function(_0x110d02){if(_0x110d02){_0x32e689=_0x110d02;return _0x110d02[_0x4c40('0xf4')]({'raw':!![]});}})[_0x4c40('0x11')](function(_0x3ff974){if(_0x32e689){if(_0x3ff974){_0x15dd73=_0x3ff974;}}return require('../../config/license/util')[_0x4c40('0x68')]();})[_0x4c40('0x11')](function(_0x236a4a){if(_0x236a4a){_0x507113=_0x236a4a[_0x4c40('0xf5')];_0xfe0d09=_0x236a4a[_0x4c40('0x69')];}})[_0x4c40('0x11')](function(){return db['ChatInteraction']['count']({'where':{'closed':![]}});})[_0x4c40('0x11')](function(_0xbcc444){_0x12d480=_0xbcc444;if(_0x507113&&_0xbcc444>_0x507113){return db[_0x4c40('0xf6')]['findOne']({'where':{'id':0x1}})[_0x4c40('0x11')](function(_0x31b1bd){if(_0x31b1bd){_0x31b1bd[_0x4c40('0xf7')]('chatLicenseExceeded');}});}})[_0x4c40('0x11')](function(){if(_0x32e689[_0x4c40('0xf2')]&&_0x32e689[_0x4c40('0xf2')][_0x4c40('0xf3')]){var _0x3df82d=[];for(var _0x47bcfd=0x0;_0x47bcfd<_0x32e689[_0x4c40('0xf2')][_0x4c40('0xf3')][_0x4c40('0x38')];_0x47bcfd++){var _0x1c64d5=_0x32e689[_0x4c40('0xf2')][_0x4c40('0xf3')][_0x47bcfd][_0x4c40('0x4e')]({'plain':!![]});_0x3df82d['push'](iftimePromise(_0x1c64d5,_0x32e689));}return BPromise['all'](_0x3df82d)[_0x4c40('0x11')](function(_0x17c2e9){return _['some'](_0x17c2e9);});}else{return!![];}})[_0x4c40('0x11')](function(_0x41054f){var _0x40e61a=fs['readFileSync'](path[_0x4c40('0x66')](config[_0x4c40('0x67')],_0x4c40('0xf8')),_0x4c40('0xc3'));var _0x3d8ac8=new url['URL'](_0x32e689[_0x4c40('0xf9')])[_0x4c40('0xfa')];var _0x12cff1='3.2.0';var _0x56a1ae=![];var _0x353f98={'chatVersion':_0x12cff1,'chatWebsiteAddressOrigin':_0x3d8ac8,'remote':_0x32e689[_0x4c40('0xfb')],'query':querystring[_0x4c40('0x15')](_[_0x4c40('0x47')](_0x32e689[_0x4c40('0x4e')]({'plain':!![]}),{'customerIp':_0x2fe97f[_0x4c40('0x76')][_0x4c40('0x92')]||_0x2fe97f['headers'][_0x4c40('0xfc')]||_0x2fe97f[_0x4c40('0xfd')][_0x4c40('0xfe')]||_0x2fe97f['ip'],'referer':_0x2fe97f[_0x4c40('0x76')][_0x4c40('0x97')],'openedInteractions':_0x12d480,'maxInteractions':_0x507113,'virtual':_0xfe0d09[_0x4c40('0xf5')],'online':_0x41054f,'custom':_0xfe0d09}))['replace'](/'/g,'\x5c\x27')};_0xaf85cd[_0x4c40('0x2a')](ejs[_0x4c40('0xc4')](Mustache[_0x4c40('0xc4')](_0x40e61a,_0x353f98),{'proactiveActions':_0x15dd73,'alignment':_0x32e689[_0x4c40('0xff')],'verticalAlignment':_0x32e689['verticalAlignment'],'div_color':_0x32e689['color'],'labelText':_0x32e689[_0x4c40('0x100')],'text_color':_0x32e689['textColor'],'text_button_color':_0x32e689['textButtonColor'],'button_color':_0x32e689['color_button'],'background_color':_0x32e689[_0x4c40('0x101')],'hideWhenOffline':_0x32e689['hideWhenOffline'],'intervalId':_0x32e689['IntervalId'],'isDevelopment':_0x56a1ae,'chatVersion':_0x12cff1}));})[_0x4c40('0x1a')](handleError(_0xaf85cd,null));};exports[_0x4c40('0x102')]=function(_0xa8ec3f,_0x5cfdaa){var _0x3c0e97=_0xa8ec3f['params']['id'];var _0x18b404=_0xa8ec3f[_0x4c40('0x4a')];var _0x404cf7=0xc8;var _0x47b219=null;return db[_0x4c40('0x103')][_0x4c40('0xcd')]({'isolationLevel':db[_0x4c40('0x103')][_0x4c40('0x104')][_0x4c40('0x105')][_0x4c40('0x106')]},function(_0x361609){return db[_0x4c40('0x2e')][_0x4c40('0x55')]({'where':{'id':_0x3c0e97},'transaction':_0x361609})[_0x4c40('0x11')](function(_0x5473fb){if(_0x5473fb){return db[_0x4c40('0x89')]['destroy']({'where':{'ChatWebsiteId':_0x3c0e97},'transaction':_0x361609})[_0x4c40('0x11')](function(){var _0x1d50c4=_[_0x4c40('0x2d')](_0x18b404,function(_0x54e87a){_0x54e87a[_0x4c40('0x53')]=_0x3c0e97;return _0x54e87a;});return db['ChatApplication'][_0x4c40('0x107')](_0x1d50c4,{'transaction':_0x361609});});}else{_0x404cf7=0x194;_0x47b219=[];}});})[_0x4c40('0x11')](function(){if(_0x404cf7!==0x194){return db[_0x4c40('0x89')]['findAndCountAll']({'where':{'ChatWebsiteId':_0x3c0e97},'order':_0x4c40('0x8f')})[_0x4c40('0x11')](function(_0x13cb23){_0x47b219=_0x13cb23;});}})[_0x4c40('0x1a')](function(_0x509a30){_0x404cf7=0x1f4;logger[_0x4c40('0x16')](_0x509a30[_0x4c40('0x28')]);if(_0x509a30['name']){delete _0x509a30[_0x4c40('0x29')];}_0x47b219=_0x509a30;})['finally'](function(){if(_0x47b219===null){_0x5cfdaa[_0x4c40('0x27')](_0x404cf7);}else{if(_0x404cf7===0x1f4){_0x5cfdaa[_0x4c40('0x1b')](_0x404cf7)[_0x4c40('0x2a')](_0x47b219);}else{_0x5cfdaa[_0x4c40('0x1b')](_0x404cf7)[_0x4c40('0x108')](_0x47b219);}}});};exports[_0x4c40('0x109')]=function(_0x105f12,_0x5eacaa){var _0x1d2b52={};var _0x3ec850={};var _0x486729;var _0x5685cb;return db[_0x4c40('0x2e')][_0x4c40('0x55')]({'where':{'id':_0x105f12[_0x4c40('0x45')]['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x5eacaa,null))[_0x4c40('0x11')](function(_0x31d1a3){if(_0x31d1a3){_0x486729=_0x31d1a3;_0x3ec850['model']=_[_0x4c40('0x33')](db[_0x4c40('0x89')]['rawAttributes']);_0x3ec850[_0x4c40('0x32')]=_[_0x4c40('0x33')](_0x105f12[_0x4c40('0x32')]);_0x3ec850[_0x4c40('0x34')]=_[_0x4c40('0x36')](_0x3ec850[_0x4c40('0x31')],_0x3ec850[_0x4c40('0x32')]);_0x1d2b52['attributes']=_[_0x4c40('0x36')](_0x3ec850['model'],qs[_0x4c40('0x37')](_0x105f12[_0x4c40('0x32')][_0x4c40('0x37')]));_0x1d2b52[_0x4c40('0x35')]=_0x1d2b52['attributes'][_0x4c40('0x38')]?_0x1d2b52[_0x4c40('0x35')]:_0x3ec850['model'];_0x1d2b52[_0x4c40('0x56')]=qs[_0x4c40('0x3b')](_0x105f12[_0x4c40('0x32')][_0x4c40('0x3b')]);_0x1d2b52['where']=qs[_0x4c40('0x34')](_[_0x4c40('0x3d')](_0x105f12[_0x4c40('0x32')],_0x3ec850[_0x4c40('0x34')]));if(_0x105f12[_0x4c40('0x32')][_0x4c40('0x57')]){_0x1d2b52[_0x4c40('0x3c')]=_[_0x4c40('0x47')](_0x1d2b52[_0x4c40('0x3c')],{'$or':_[_0x4c40('0x2d')](_0x1d2b52[_0x4c40('0x35')],function(_0x44806a){var _0x2131ba={};_0x2131ba[_0x44806a]={'$like':'%'+_0x105f12[_0x4c40('0x32')][_0x4c40('0x57')]+'%'};return _0x2131ba;})});}_0x1d2b52=_[_0x4c40('0x47')]({},_0x1d2b52,_0x105f12[_0x4c40('0x3f')]);return _0x486729[_0x4c40('0x109')](_0x1d2b52);}})[_0x4c40('0x11')](function(_0x400aea){if(_0x400aea){_0x5685cb=_0x400aea[_0x4c40('0x38')];if(!_0x105f12[_0x4c40('0x32')]['hasOwnProperty']('nolimit')){_0x1d2b52[_0x4c40('0x20')]=qs[_0x4c40('0x20')](_0x105f12[_0x4c40('0x32')][_0x4c40('0x20')]);_0x1d2b52['offset']=qs[_0x4c40('0x1d')](_0x105f12['query']['offset']);}return _0x486729[_0x4c40('0x109')](_0x1d2b52);}})[_0x4c40('0x11')](function(_0x385f3d){if(_0x385f3d){return _0x385f3d?{'count':_0x5685cb,'rows':_0x385f3d}:null;}})['then'](respondWithResult(_0x5eacaa,null))[_0x4c40('0x1a')](handleError(_0x5eacaa,null));};exports[_0x4c40('0x10a')]=function(_0x5a48c2,_0x46310f){return db[_0x4c40('0x10b')][_0x4c40('0x48')]({'where':{'id':_0x5a48c2[_0x4c40('0x45')]['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x46310f,null))[_0x4c40('0x11')](function(_0x3472fa){if(_0x3472fa){return _0x3472fa[_0x4c40('0x10a')](_0x5a48c2[_0x4c40('0x4a')][_0x4c40('0x59')],_[_0x4c40('0x10c')](_0x5a48c2[_0x4c40('0x4a')],[_0x4c40('0x59'),'id'])||{});}})[_0x4c40('0x11')](respondWithResult(_0x46310f,null))[_0x4c40('0x1a')](handleError(_0x46310f,null));};exports[_0x4c40('0xf4')]=function(_0x16e2e4,_0x42d522){var _0xafb148={};var _0x1c7e76={};var _0x353c9b;var _0x53170a;return db[_0x4c40('0x2e')][_0x4c40('0x55')]({'where':{'id':_0x16e2e4[_0x4c40('0x45')]['id']}})['then'](handleEntityNotFound(_0x42d522,null))[_0x4c40('0x11')](function(_0x542714){if(_0x542714){_0x353c9b=_0x542714;_0x1c7e76[_0x4c40('0x31')]=_[_0x4c40('0x33')](db[_0x4c40('0x10d')]['rawAttributes']);_0x1c7e76[_0x4c40('0x32')]=_[_0x4c40('0x33')](_0x16e2e4[_0x4c40('0x32')]);_0x1c7e76['filters']=_['intersection'](_0x1c7e76['model'],_0x1c7e76[_0x4c40('0x32')]);_0xafb148[_0x4c40('0x35')]=_[_0x4c40('0x36')](_0x1c7e76[_0x4c40('0x31')],qs[_0x4c40('0x37')](_0x16e2e4[_0x4c40('0x32')][_0x4c40('0x37')]));_0xafb148[_0x4c40('0x35')]=_0xafb148[_0x4c40('0x35')][_0x4c40('0x38')]?_0xafb148[_0x4c40('0x35')]:_0x1c7e76[_0x4c40('0x31')];_0xafb148['order']=qs[_0x4c40('0x3b')](_0x16e2e4['query'][_0x4c40('0x3b')]);_0xafb148[_0x4c40('0x3c')]=qs[_0x4c40('0x34')](_[_0x4c40('0x3d')](_0x16e2e4[_0x4c40('0x32')],_0x1c7e76['filters']));if(_0x16e2e4[_0x4c40('0x32')][_0x4c40('0x57')]){_0xafb148['where']=_[_0x4c40('0x47')](_0xafb148[_0x4c40('0x3c')],{'$or':_['map'](_0xafb148[_0x4c40('0x35')],function(_0x333d81){var _0x177c55={};_0x177c55[_0x333d81]={'$like':'%'+_0x16e2e4[_0x4c40('0x32')][_0x4c40('0x57')]+'%'};return _0x177c55;})});}_0xafb148=_[_0x4c40('0x47')]({},_0xafb148,_0x16e2e4[_0x4c40('0x3f')]);return _0x353c9b[_0x4c40('0xf4')](_0xafb148);}})[_0x4c40('0x11')](function(_0x54fc63){if(_0x54fc63){_0x53170a=_0x54fc63[_0x4c40('0x38')];if(!_0x16e2e4[_0x4c40('0x32')]['hasOwnProperty'](_0x4c40('0x3a'))){_0xafb148[_0x4c40('0x20')]=qs[_0x4c40('0x20')](_0x16e2e4[_0x4c40('0x32')][_0x4c40('0x20')]);_0xafb148['offset']=qs[_0x4c40('0x1d')](_0x16e2e4[_0x4c40('0x32')][_0x4c40('0x1d')]);}return _0x353c9b['getProactiveActions'](_0xafb148);}})['then'](function(_0x1e701f){if(_0x1e701f){return _0x1e701f?{'count':_0x53170a,'rows':_0x1e701f}:null;}})[_0x4c40('0x11')](respondWithResult(_0x42d522,null))['catch'](handleError(_0x42d522,null));};exports[_0x4c40('0x10e')]=function(_0x31fb9d,_0x4fe42e){var _0x380a4e=_0x31fb9d['query'][_0x4c40('0x10f')]===_0x4c40('0x110')?_0x4c40('0x111'):'onlineForm';return db[_0x4c40('0x2e')][_0x4c40('0x48')]({'attributes':['id',_0x380a4e],'where':{'id':_0x31fb9d[_0x4c40('0x45')]['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x4fe42e,null))[_0x4c40('0x11')](function(_0x49aa40){if(_0x49aa40){var _0x5fda3a=_0x49aa40[_0x380a4e];var _0x5cb528=_0x5fda3a&&_0x5fda3a[_0x4c40('0x112')]?_0x5fda3a['items']:[];_0x4fe42e[_0x4c40('0x2a')]({'fromKey':_['isNil'](_0x5fda3a[_0x4c40('0x113')])?undefined:_0x5fda3a[_0x4c40('0x113')],'count':_0x5cb528[_0x4c40('0x38')],'rows':_0x5cb528});}})[_0x4c40('0x1a')](handleError(_0x4fe42e,null));};exports['getOfflineMessages']=function(_0x33e228,_0x2423a3){var _0x218f08={'raw':![],'where':{}};var _0x51b1ed={};var _0x125534={'count':0x0,'rows':[]};return db[_0x4c40('0x2e')][_0x4c40('0x55')]({'where':{'id':_0x33e228[_0x4c40('0x45')]['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x2423a3,null))['then'](function(_0x3c9898){if(_0x3c9898){_0x51b1ed[_0x4c40('0x31')]=_[_0x4c40('0x33')](db[_0x4c40('0xc6')][_0x4c40('0x46')]);_0x51b1ed['query']=_[_0x4c40('0x33')](_0x33e228['query']);_0x51b1ed['filters']=_['intersection'](_0x51b1ed['model'],_0x51b1ed[_0x4c40('0x32')]);_0x218f08['attributes']=_[_0x4c40('0x36')](_0x51b1ed[_0x4c40('0x31')],qs[_0x4c40('0x37')](_0x33e228[_0x4c40('0x32')][_0x4c40('0x37')]));_0x218f08['attributes']=_0x218f08[_0x4c40('0x35')][_0x4c40('0x38')]?_0x218f08[_0x4c40('0x35')]:_0x51b1ed['model'];if(!_0x33e228[_0x4c40('0x32')]['hasOwnProperty'](_0x4c40('0x3a'))){_0x218f08[_0x4c40('0x20')]=qs['limit'](_0x33e228['query'][_0x4c40('0x20')]);_0x218f08[_0x4c40('0x1d')]=qs[_0x4c40('0x1d')](_0x33e228['query'][_0x4c40('0x1d')]);}_0x218f08[_0x4c40('0x56')]=qs[_0x4c40('0x3b')](_0x33e228['query'][_0x4c40('0x3b')]);_0x218f08['where']=qs[_0x4c40('0x34')](_[_0x4c40('0x3d')](_0x33e228[_0x4c40('0x32')],_0x51b1ed['filters']));_0x218f08['where'][_0x4c40('0x53')]=_0x3c9898['id'];if(_0x33e228[_0x4c40('0x32')]['filter']){_0x218f08['where']=_[_0x4c40('0x47')](_0x218f08[_0x4c40('0x3c')],{'$or':_['map'](_0x218f08['attributes'],function(_0x58e6fd){var _0x20f27d={};_0x20f27d[_0x58e6fd]={'$like':'%'+_0x33e228[_0x4c40('0x32')][_0x4c40('0x57')]+'%'};return _0x20f27d;})});}_0x218f08=_[_0x4c40('0x47')]({},_0x218f08,_0x33e228[_0x4c40('0x3f')]);return db[_0x4c40('0xc6')][_0x4c40('0x1f')]({'where':_0x218f08['where']})[_0x4c40('0x11')](function(_0x5a23f2){_0x125534[_0x4c40('0x1f')]=_0x5a23f2;if(_0x33e228[_0x4c40('0x32')][_0x4c40('0x40')]){_0x218f08[_0x4c40('0x41')]=[{'all':!![]}];}else{_0x218f08[_0x4c40('0x41')]=[{'model':db[_0x4c40('0x88')],'as':_0x4c40('0xe4'),'required':![]},{'model':db['Attachment'],'as':'Attachments','required':![]}];}return db[_0x4c40('0xc6')]['findAll'](_0x218f08);})['then'](function(_0x545973){_0x125534['rows']=_0x545973;return _0x125534;});}})[_0x4c40('0x11')](respondWithFilteredResult(_0x2423a3,_0x218f08))[_0x4c40('0x1a')](handleError(_0x2423a3,null));};exports[_0x4c40('0x114')]=function(_0x526c68,_0x4e29b6){return db[_0x4c40('0x2e')][_0x4c40('0x48')]({'where':{'id':_0x526c68[_0x4c40('0x45')]['id']}})[_0x4c40('0x11')](handleEntityNotFound(_0x4e29b6,null))['then'](function(_0x1bbd0c){if(_0x1bbd0c){return _0x1bbd0c[_0x4c40('0x114')](_0x526c68[_0x4c40('0x4a')]['ids'],_['omit'](_0x526c68[_0x4c40('0x4a')],[_0x4c40('0x59'),'id'])||{})[_0x4c40('0xa5')](function(_0xffe505){for(var _0x4d431a=0x0;_0x4d431a<_0x526c68[_0x4c40('0x4a')]['ids'][_0x4c40('0x38')];_0x4d431a+=0x1){socket[_0x4c40('0x115')](_0x4c40('0x116'),{'UserId':Number(_0x526c68[_0x4c40('0x4a')][_0x4c40('0x59')][_0x4d431a]),'ChatWebsiteId':Number(_0x526c68[_0x4c40('0x45')]['id'])});}return _0xffe505;});}})['then'](respondWithResult(_0x4e29b6,null))[_0x4c40('0x1a')](handleError(_0x4e29b6,null));};exports[_0x4c40('0x117')]=function(_0x3e128d,_0x599422){return db['ChatWebsite'][_0x4c40('0x48')]({'where':{'id':_0x3e128d[_0x4c40('0x45')]['id']}})['then'](handleEntityNotFound(_0x599422,null))[_0x4c40('0x11')](function(_0x3ad1af){if(_0x3ad1af){return _0x3ad1af[_0x4c40('0x117')](_0x3e128d[_0x4c40('0x32')][_0x4c40('0x59')])[_0x4c40('0x11')](function(){if(_[_0x4c40('0x118')](_0x3e128d[_0x4c40('0x32')]['ids'])){for(var _0x175dca=0x0;_0x175dca<_0x3e128d[_0x4c40('0x32')]['ids'][_0x4c40('0x38')];_0x175dca+=0x1){socket[_0x4c40('0x115')](_0x4c40('0x119'),{'UserId':Number(_0x3e128d[_0x4c40('0x32')][_0x4c40('0x59')][_0x175dca]),'ChatWebsiteId':Number(_0x3e128d['params']['id'])});}}else{socket[_0x4c40('0x115')](_0x4c40('0x119'),{'UserId':Number(_0x3e128d[_0x4c40('0x32')][_0x4c40('0x59')]),'ChatWebsiteId':Number(_0x3e128d[_0x4c40('0x45')]['id'])});}});}})[_0x4c40('0x11')](respondWithStatusCode(_0x599422,null))[_0x4c40('0x1a')](handleError(_0x599422,null));};exports[_0x4c40('0x11a')]=function(_0x22c0f6,_0x3b61f0){var _0x45fd46={};var _0x2447ad={};var _0x17d96d;var _0x5556e5;return db[_0x4c40('0x2e')][_0x4c40('0x55')]({'where':{'id':_0x22c0f6[_0x4c40('0x45')]['id']}})['then'](handleEntityNotFound(_0x3b61f0,null))[_0x4c40('0x11')](function(_0x188be6){if(_0x188be6){_0x17d96d=_0x188be6;_0x2447ad[_0x4c40('0x31')]=_[_0x4c40('0x33')](db['User'][_0x4c40('0x46')]);_0x2447ad[_0x4c40('0x32')]=_['keys'](_0x22c0f6[_0x4c40('0x32')]);_0x2447ad['filters']=_[_0x4c40('0x36')](_0x2447ad[_0x4c40('0x31')],_0x2447ad['query']);_0x45fd46[_0x4c40('0x35')]=_[_0x4c40('0x36')](_0x2447ad[_0x4c40('0x31')],qs[_0x4c40('0x37')](_0x22c0f6['query'][_0x4c40('0x37')]));_0x45fd46[_0x4c40('0x35')]=_0x45fd46[_0x4c40('0x35')][_0x4c40('0x38')]?_0x45fd46[_0x4c40('0x35')]:_0x2447ad[_0x4c40('0x31')];_0x45fd46[_0x4c40('0x56')]=qs[_0x4c40('0x3b')](_0x22c0f6['query']['sort']);_0x45fd46['where']=qs['filters'](_[_0x4c40('0x3d')](_0x22c0f6[_0x4c40('0x32')],_0x2447ad[_0x4c40('0x34')]));if(_0x22c0f6[_0x4c40('0x32')][_0x4c40('0x57')]){_0x45fd46['where']=_[_0x4c40('0x47')](_0x45fd46[_0x4c40('0x3c')],{'$or':_[_0x4c40('0x2d')](_0x45fd46[_0x4c40('0x35')],function(_0x2bbe01){var _0x3b671b={};_0x3b671b[_0x2bbe01]={'$like':'%'+_0x22c0f6[_0x4c40('0x32')][_0x4c40('0x57')]+'%'};return _0x3b671b;})});}_0x45fd46=_[_0x4c40('0x47')]({},_0x45fd46,_0x22c0f6[_0x4c40('0x3f')]);return _0x17d96d[_0x4c40('0x11a')](_0x45fd46);}})[_0x4c40('0x11')](function(_0x4dd8a2){if(_0x4dd8a2){_0x5556e5=_0x4dd8a2[_0x4c40('0x38')];if(!_0x22c0f6[_0x4c40('0x32')][_0x4c40('0x39')](_0x4c40('0x3a'))){_0x45fd46[_0x4c40('0x20')]=qs[_0x4c40('0x20')](_0x22c0f6[_0x4c40('0x32')][_0x4c40('0x20')]);_0x45fd46[_0x4c40('0x1d')]=qs[_0x4c40('0x1d')](_0x22c0f6['query'][_0x4c40('0x1d')]);}return _0x17d96d[_0x4c40('0x11a')](_0x45fd46);}})[_0x4c40('0x11')](function(_0x54787c){if(_0x54787c){return _0x54787c?{'count':_0x5556e5,'rows':_0x54787c}:null;}})[_0x4c40('0x11')](respondWithResult(_0x3b61f0,null))[_0x4c40('0x1a')](handleError(_0x3b61f0,null));};
\ No newline at end of file