Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index d21939d..c472aea 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x47a2=['some','remote','x-real-ip','connection','remoteAddress','replace','alignment','verticalAlignment','textColor','textButtonColor','hideWhenOffline','IntervalId','addApplications','Transaction','READ_COMMITTED','findAndCountAll','getApplications','addProactiveActions','chatProactiveAction','ChatProactiveAction','getFields','online','false','offlineForm','items','fromKey','getOfflineMessages','ChatOfflineMessage','Attachments','addAgents','emit','removeAgents','isArray','userChatWebsite:remove','getAgents','mustache','util','path','ejs','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./chatWebsite.socket','register','html-to-text','jayson/promise','http','client','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','error','code','message','catch','end','json','offset','limit','undefined','count','set','update','destroy','get','ChatWebsites','UserProfileResource','status','sendStatus','stack','name','send','Pause','mandatoryDispositionPause','map','ChatWebsite','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','includeAll','include','findAll','params','rawAttributes','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','findOne','rows','removeDispositions','ids','addAnswer','CannedAnswer','pick','removeAnswers','addLogo','sitepic','filename','addAvatar','agentAvatar','file','customerAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','../../config/license/util','getLicense','custom','isNil','server/files/images/logos/','download','getAvatar','server/files/images/avatars/default_avatar.png','existsSync','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','server/files/images/avatars/system_avatar.png','setUA','headers','user-agent','getResult','chat','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','updatedAt','CompanyId','ListId','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','DESC','ChatApplication','Applications','account','list','applications','orderBy','priority','contact','customerIp','cf-connecting-ip','x-forwarded-for','split','firstName','lastName','referer','browser','version','%s\x20%s','unknown','device','vendor','%s\x20%s\x20%s','stringify','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','messageId','created','autoclose','push','close','*,*,*,*','ChatMessage','AttachmentId','UserId','User','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','offline','files','difference','createdAt','mapKeyOffline','MailAccount','findOrCreate','readFileSync','utf8','render','toPairs','offlineMessageBody','fromString','server','offline-chat','openNewInteraction','sequelize','transaction','Attachment','bulkCreate','Smtp','CloudProvider','forwardOfflineAddress','getSmtpOptions','SendMail','sendMail','format','\x22%s\x22\x20<%s>','email','offlineMessageSubject','MailAccountId','originalname','mimetype','subjectOffline','toPairsIn','mapValues','NotifyMailAccount','notifyMail','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','Owner','fullname','internal','Tag','color','tag','getSnippet','timezone','iftime\x20%s,%s','interval','iftime\x20%s','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','inspect','Interval','Intervals','getProactiveActions','virtual','License','increment','chatLicenseExceeded','all'];(function(_0x688df,_0x3cc215){var _0x266fef=function(_0x439d3f){while(--_0x439d3f){_0x688df['push'](_0x688df['shift']());}};_0x266fef(++_0x3cc215);}(_0x47a2,0x149));var _0x247a=function(_0x54ca4e,_0x3a5fe0){_0x54ca4e=_0x54ca4e-0x0;var _0x2a8924=_0x47a2[_0x54ca4e];return _0x2a8924;};'use strict';var BPromise=require('bluebird');var Mustache=require(_0x247a('0x0'));var util=require(_0x247a('0x1'));var path=require(_0x247a('0x2'));var ejs=require(_0x247a('0x3'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var querystring=require('querystring');var Redis=require(_0x247a('0x4'));var qs=require(_0x247a('0x5'));var logger=require(_0x247a('0x6'))(_0x247a('0x7'));var config=require(_0x247a('0x8'));var db=require(_0x247a('0x9'))['db'];config['redis']=_[_0x247a('0xa')](config[_0x247a('0xb')],{'host':_0x247a('0xc'),'port':0x18eb});var socket=require(_0x247a('0xd'))(new Redis(config[_0x247a('0xb')]));require(_0x247a('0xe'))[_0x247a('0xf')](socket);var htmlToText=require(_0x247a('0x10'));var jayson=require(_0x247a('0x11'));var client=jayson['client'][_0x247a('0x12')]({'port':0x232c});var client9002=jayson[_0x247a('0x13')][_0x247a('0x12')]({'port':0x232a});var client9003=jayson[_0x247a('0x13')]['http']({'port':0x232b});var client9001=jayson['client'][_0x247a('0x12')]({'port':0x2329});function respondWithRpcPromise(_0xc1a897,_0x4909e3,_0x59700d,_0x5c039d){return new BPromise(function(_0x221d8a,_0x5a8348){var _0x26f580=_0x5c039d||client;return _0x26f580[_0x247a('0x14')](_0xc1a897,_0x59700d)[_0x247a('0x15')](function(_0x5442c1){logger[_0x247a('0x16')](_0x247a('0x17'),_0x4909e3,_0x247a('0x18'));logger[_0x247a('0x19')](_0x247a('0x1a'),_0x4909e3,_0x247a('0x18'),JSON['stringify'](_0x5442c1));if(_0x5442c1[_0x247a('0x1b')]){if(_0x5442c1[_0x247a('0x1b')][_0x247a('0x1c')]===0x1f4){logger[_0x247a('0x1b')](_0x247a('0x17'),_0x4909e3,_0x5442c1[_0x247a('0x1b')][_0x247a('0x1d')]);return _0x5a8348(_0x5442c1[_0x247a('0x1b')]['message']);}logger[_0x247a('0x1b')](_0x247a('0x17'),_0x4909e3,_0x5442c1[_0x247a('0x1b')][_0x247a('0x1d')]);return _0x221d8a(_0x5442c1['error'][_0x247a('0x1d')]);}else{logger[_0x247a('0x16')]('ChatWebsite,\x20%s,\x20%s',_0x4909e3,_0x247a('0x18'));_0x221d8a(_0x5442c1['result']['message']);}})[_0x247a('0x1e')](function(_0x406e96){logger[_0x247a('0x1b')](_0x247a('0x17'),_0x4909e3,_0x406e96);_0x5a8348(_0x406e96);});});}function respondWithStatusCode(_0x1ca09f,_0x5989cf){_0x5989cf=_0x5989cf||0xcc;return function(_0x4c0ad1){if(_0x4c0ad1){return _0x1ca09f['sendStatus'](_0x5989cf);}return _0x1ca09f['status'](_0x5989cf)[_0x247a('0x1f')]();};}function respondWithResult(_0x1e5e00,_0x38533c){_0x38533c=_0x38533c||0xc8;return function(_0x781771){if(_0x781771){return _0x1e5e00['status'](_0x38533c)[_0x247a('0x20')](_0x781771);}};}function respondWithFilteredResult(_0x240afe,_0x5dba48){return function(_0x2c9164){if(_0x2c9164){var _0xb517d5=typeof _0x5dba48[_0x247a('0x21')]==='undefined'&&typeof _0x5dba48[_0x247a('0x22')]===_0x247a('0x23');var _0x597460=_0x2c9164[_0x247a('0x24')];var _0xe23389=_0xb517d5?0x0:_0x5dba48[_0x247a('0x21')];var _0x31c4ba=_0xb517d5?_0x2c9164['count']:_0x5dba48[_0x247a('0x21')]+_0x5dba48[_0x247a('0x22')];var _0x47b05c;if(_0x31c4ba>=_0x597460){_0x31c4ba=_0x597460;_0x47b05c=0xc8;}else{_0x47b05c=0xce;}_0x240afe['status'](_0x47b05c);return _0x240afe[_0x247a('0x25')]('Content-Range',_0xe23389+'-'+_0x31c4ba+'/'+_0x597460)['json'](_0x2c9164);}return null;};}function saveUpdates(_0xebe58){return function(_0x329bc7){if(_0x329bc7){return _0x329bc7[_0x247a('0x26')](_0xebe58)[_0x247a('0x15')](function(_0x498a93){return _0x498a93;});}return null;};}function removeEntity(_0x156ec6){return function(_0x54cf94){if(_0x54cf94){return _0x54cf94[_0x247a('0x27')]()['then'](function(){var _0x1a6994=_0x54cf94[_0x247a('0x28')]({'plain':!![]});var _0x501501=_0x247a('0x29');return db[_0x247a('0x2a')][_0x247a('0x27')]({'where':{'type':_0x501501,'resourceId':_0x1a6994['id']}})['then'](function(){return _0x54cf94;});})[_0x247a('0x15')](function(){_0x156ec6[_0x247a('0x2b')](0xcc)[_0x247a('0x1f')]();});}};}function handleEntityNotFound(_0x519e0f){return function(_0x34e0ef){if(!_0x34e0ef){_0x519e0f[_0x247a('0x2c')](0x194);}return _0x34e0ef;};}function handleError(_0x1c3b7a,_0x423360){_0x423360=_0x423360||0x1f4;return function(_0x655854){logger[_0x247a('0x1b')](_0x655854[_0x247a('0x2d')]);if(_0x655854[_0x247a('0x2e')]){delete _0x655854[_0x247a('0x2e')];}_0x1c3b7a[_0x247a('0x2b')](_0x423360)[_0x247a('0x2f')](_0x655854);};}exports['index']=function(_0x5e073e,_0x28f049){var _0x58fca9={'include':[{'model':db[_0x247a('0x30')],'as':_0x247a('0x31')}]},_0x31e303={},_0x25896e={'count':0x0,'rows':[]};var _0x44b9d8=_[_0x247a('0x32')](db[_0x247a('0x33')]['rawAttributes'],function(_0xc20972){return{'name':_0xc20972['fieldName'],'type':_0xc20972[_0x247a('0x34')]['key']};});_0x31e303[_0x247a('0x35')]=_['map'](_0x44b9d8,_0x247a('0x2e'));_0x31e303[_0x247a('0x36')]=_[_0x247a('0x37')](_0x5e073e[_0x247a('0x36')]);_0x31e303[_0x247a('0x38')]=_[_0x247a('0x39')](_0x31e303[_0x247a('0x35')],_0x31e303['query']);_0x58fca9[_0x247a('0x3a')]=_['intersection'](_0x31e303['model'],qs[_0x247a('0x3b')](_0x5e073e[_0x247a('0x36')]['fields']));_0x58fca9[_0x247a('0x3a')]=_0x58fca9[_0x247a('0x3a')][_0x247a('0x3c')]?_0x58fca9[_0x247a('0x3a')]:_0x31e303[_0x247a('0x35')];if(!_0x5e073e[_0x247a('0x36')][_0x247a('0x3d')](_0x247a('0x3e'))){_0x58fca9['limit']=qs['limit'](_0x5e073e['query'][_0x247a('0x22')]);_0x58fca9['offset']=qs[_0x247a('0x21')](_0x5e073e[_0x247a('0x36')][_0x247a('0x21')]);}_0x58fca9[_0x247a('0x3f')]=qs[_0x247a('0x40')](_0x5e073e[_0x247a('0x36')]['sort']);_0x58fca9[_0x247a('0x41')]=qs[_0x247a('0x38')](_['pick'](_0x5e073e[_0x247a('0x36')],_0x31e303['filters']),_0x44b9d8);if(_0x5e073e['query'][_0x247a('0x42')]){_0x58fca9[_0x247a('0x41')]=_[_0x247a('0x43')](_0x58fca9['where'],{'$or':_['map'](_0x44b9d8,function(_0x229e0b){if(_0x229e0b[_0x247a('0x34')]!==_0x247a('0x44')){var _0x38da71={};_0x38da71[_0x229e0b['name']]={'$like':'%'+_0x5e073e[_0x247a('0x36')][_0x247a('0x42')]+'%'};return _0x38da71;}})});}_0x58fca9=_['merge']({},_0x58fca9,_0x5e073e[_0x247a('0x45')]);var _0x1d2d55={'where':_0x58fca9[_0x247a('0x41')]};return db['ChatWebsite'][_0x247a('0x24')](_0x1d2d55)[_0x247a('0x15')](function(_0x3f4bbb){_0x25896e[_0x247a('0x24')]=_0x3f4bbb;if(_0x5e073e[_0x247a('0x36')][_0x247a('0x46')]){_0x58fca9[_0x247a('0x47')]=[{'all':!![]}];}return db[_0x247a('0x33')][_0x247a('0x48')](_0x58fca9);})[_0x247a('0x15')](function(_0xa2f670){_0x25896e['rows']=_0xa2f670;return _0x25896e;})[_0x247a('0x15')](respondWithFilteredResult(_0x28f049,_0x58fca9))['catch'](handleError(_0x28f049,null));};exports['show']=function(_0x38489c,_0x18785b){var _0x573b94={'raw':![],'where':{'id':_0x38489c[_0x247a('0x49')]['id']},'include':[{'model':db[_0x247a('0x30')],'as':_0x247a('0x31')}]},_0x3f4480={};_0x3f4480[_0x247a('0x35')]=_[_0x247a('0x37')](db[_0x247a('0x33')][_0x247a('0x4a')]);_0x3f4480[_0x247a('0x36')]=_[_0x247a('0x37')](_0x38489c['query']);_0x3f4480['filters']=_[_0x247a('0x39')](_0x3f4480[_0x247a('0x35')],_0x3f4480[_0x247a('0x36')]);_0x573b94[_0x247a('0x3a')]=_[_0x247a('0x39')](_0x3f4480[_0x247a('0x35')],qs[_0x247a('0x3b')](_0x38489c[_0x247a('0x36')][_0x247a('0x3b')]));_0x573b94[_0x247a('0x3a')]=_0x573b94[_0x247a('0x3a')][_0x247a('0x3c')]?_0x573b94[_0x247a('0x3a')]:_0x3f4480[_0x247a('0x35')];if(_0x38489c[_0x247a('0x36')][_0x247a('0x46')]){_0x573b94[_0x247a('0x47')]=[{'all':!![]}];}_0x573b94=_[_0x247a('0x43')]({},_0x573b94,_0x38489c['options']);return db[_0x247a('0x33')][_0x247a('0x4b')](_0x573b94)['then'](handleEntityNotFound(_0x18785b,null))[_0x247a('0x15')](respondWithResult(_0x18785b,null))[_0x247a('0x1e')](handleError(_0x18785b,null));};exports[_0x247a('0x4c')]=function(_0x13a687,_0x173453){return db[_0x247a('0x33')]['create'](_0x13a687[_0x247a('0x4d')],{})['then'](function(_0xf6573f){var _0x203dce=_0x13a687['user'][_0x247a('0x28')]({'plain':!![]});if(!_0x203dce)throw new Error(_0x247a('0x4e'));if(_0x203dce[_0x247a('0x4f')]===_0x247a('0x50')){var _0x5ae47e=_0xf6573f[_0x247a('0x28')]({'plain':!![]});var _0x350f90=_0x247a('0x29');return db[_0x247a('0x51')][_0x247a('0x4b')]({'where':{'name':_0x350f90,'userProfileId':_0x203dce['userProfileId']},'raw':!![]})[_0x247a('0x15')](function(_0x25db98){if(_0x25db98&&_0x25db98[_0x247a('0x52')]===0x0){return db[_0x247a('0x2a')]['create']({'name':_0x5ae47e[_0x247a('0x2e')],'resourceId':_0x5ae47e['id'],'type':_0x25db98['name'],'sectionId':_0x25db98['id']},{})[_0x247a('0x15')](function(){return _0xf6573f;});}else{return _0xf6573f;}})['catch'](function(_0x4e2795){logger['error'](_0x247a('0x53'),_0x4e2795);throw _0x4e2795;});}return _0xf6573f;})['then'](respondWithResult(_0x173453,0xc9))[_0x247a('0x1e')](handleError(_0x173453,null));};exports[_0x247a('0x26')]=function(_0x1c67b4,_0x3779d8){if(_0x1c67b4['body']['id']){delete _0x1c67b4['body']['id'];}return db[_0x247a('0x33')][_0x247a('0x4b')]({'where':{'id':_0x1c67b4[_0x247a('0x49')]['id']},'include':[{'model':db[_0x247a('0x30')],'as':'mandatoryDispositionPause'}]})[_0x247a('0x15')](handleEntityNotFound(_0x3779d8,null))['then'](saveUpdates(_0x1c67b4[_0x247a('0x4d')],null))[_0x247a('0x15')](respondWithResult(_0x3779d8,null))[_0x247a('0x1e')](handleError(_0x3779d8,null));};exports['destroy']=function(_0x9c0cb2,_0x12b670){return db[_0x247a('0x33')][_0x247a('0x4b')]({'where':{'id':_0x9c0cb2['params']['id']}})[_0x247a('0x15')](handleEntityNotFound(_0x12b670,null))['then'](removeEntity(_0x12b670,null))[_0x247a('0x1e')](handleError(_0x12b670,null));};exports[_0x247a('0x54')]=function(_0x3e9732,_0x8b111b){return db[_0x247a('0x33')][_0x247a('0x54')]()[_0x247a('0x15')](respondWithResult(_0x8b111b,null))[_0x247a('0x1e')](handleError(_0x8b111b,null));};exports[_0x247a('0x55')]=function(_0x1014a5,_0x411bed){if(_0x1014a5[_0x247a('0x4d')]['id']){delete _0x1014a5[_0x247a('0x4d')]['id'];}return db[_0x247a('0x33')][_0x247a('0x4b')]({'where':{'id':_0x1014a5[_0x247a('0x49')]['id']}})['then'](handleEntityNotFound(_0x411bed,null))[_0x247a('0x15')](function(_0xdff882){if(_0xdff882){_0x1014a5['body'][_0x247a('0x56')]=_0xdff882['id'];return db[_0x247a('0x57')][_0x247a('0x4c')](_0x1014a5[_0x247a('0x4d')]);}})[_0x247a('0x15')](respondWithResult(_0x411bed,null))[_0x247a('0x1e')](handleError(_0x411bed,null));};exports[_0x247a('0x58')]=function(_0x3ff5ae,_0x583ad8){var _0x221c96={'raw':![],'where':{}};var _0x3009e7={};var _0x7f7d9f={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x247a('0x59')]({'where':{'id':_0x3ff5ae[_0x247a('0x49')]['id']}})[_0x247a('0x15')](handleEntityNotFound(_0x583ad8,null))[_0x247a('0x15')](function(_0x3d232c){if(_0x3d232c){_0x3009e7[_0x247a('0x35')]=_[_0x247a('0x37')](db['Disposition'][_0x247a('0x4a')]);_0x3009e7[_0x247a('0x36')]=_[_0x247a('0x37')](_0x3ff5ae[_0x247a('0x36')]);_0x3009e7['filters']=_['intersection'](_0x3009e7[_0x247a('0x35')],_0x3009e7[_0x247a('0x36')]);_0x221c96['attributes']=_[_0x247a('0x39')](_0x3009e7[_0x247a('0x35')],qs[_0x247a('0x3b')](_0x3ff5ae[_0x247a('0x36')]['fields']));_0x221c96[_0x247a('0x3a')]=_0x221c96['attributes'][_0x247a('0x3c')]?_0x221c96[_0x247a('0x3a')]:_0x3009e7['model'];if(!_0x3ff5ae[_0x247a('0x36')][_0x247a('0x3d')]('nolimit')){_0x221c96[_0x247a('0x22')]=qs[_0x247a('0x22')](_0x3ff5ae[_0x247a('0x36')][_0x247a('0x22')]);_0x221c96[_0x247a('0x21')]=qs[_0x247a('0x21')](_0x3ff5ae[_0x247a('0x36')][_0x247a('0x21')]);}_0x221c96['order']=qs[_0x247a('0x40')](_0x3ff5ae['query'][_0x247a('0x40')]);_0x221c96[_0x247a('0x41')]=qs[_0x247a('0x38')](_['pick'](_0x3ff5ae[_0x247a('0x36')],_0x3009e7[_0x247a('0x38')]));_0x221c96['where']['ChatWebsiteId']=_0x3d232c['id'];if(_0x3ff5ae[_0x247a('0x36')]['filter']){_0x221c96[_0x247a('0x41')]=_[_0x247a('0x43')](_0x221c96[_0x247a('0x41')],{'$or':_['map'](_0x221c96[_0x247a('0x3a')],function(_0x17faa9){var _0xaa215a={};_0xaa215a[_0x17faa9]={'$like':'%'+_0x3ff5ae[_0x247a('0x36')][_0x247a('0x42')]+'%'};return _0xaa215a;})});}_0x221c96=_[_0x247a('0x43')]({},_0x221c96,_0x3ff5ae[_0x247a('0x45')]);return db[_0x247a('0x57')][_0x247a('0x24')]({'where':_0x221c96[_0x247a('0x41')]})[_0x247a('0x15')](function(_0x3f25de){_0x7f7d9f[_0x247a('0x24')]=_0x3f25de;if(_0x3ff5ae[_0x247a('0x36')][_0x247a('0x46')]){_0x221c96[_0x247a('0x47')]=[{'all':!![]}];}return db[_0x247a('0x57')][_0x247a('0x48')](_0x221c96);})[_0x247a('0x15')](function(_0x1e62a5){_0x7f7d9f[_0x247a('0x5a')]=_0x1e62a5;return _0x7f7d9f;});}})[_0x247a('0x15')](respondWithFilteredResult(_0x583ad8,_0x221c96))[_0x247a('0x1e')](handleError(_0x583ad8,null));};exports['removeDispositions']=function(_0x5d13cf,_0x2c049c){return db[_0x247a('0x33')][_0x247a('0x4b')]({'where':{'id':_0x5d13cf[_0x247a('0x49')]['id']}})['then'](handleEntityNotFound(_0x2c049c,null))[_0x247a('0x15')](function(_0x24b0e7){if(_0x24b0e7){return _0x24b0e7[_0x247a('0x5b')](_0x5d13cf[_0x247a('0x36')][_0x247a('0x5c')]);}})[_0x247a('0x15')](respondWithStatusCode(_0x2c049c,null))[_0x247a('0x1e')](handleError(_0x2c049c,null));};exports[_0x247a('0x5d')]=function(_0x50f385,_0x3deaf5){if(_0x50f385[_0x247a('0x4d')]['id']){delete _0x50f385['body']['id'];}return db['ChatWebsite'][_0x247a('0x4b')]({'where':{'id':_0x50f385[_0x247a('0x49')]['id']}})[_0x247a('0x15')](handleEntityNotFound(_0x3deaf5,null))[_0x247a('0x15')](function(_0x2cc809){if(_0x2cc809){_0x50f385['body'][_0x247a('0x56')]=_0x2cc809['id'];return db[_0x247a('0x5e')][_0x247a('0x4c')](_0x50f385[_0x247a('0x4d')]);}})[_0x247a('0x15')](respondWithResult(_0x3deaf5,null))[_0x247a('0x1e')](handleError(_0x3deaf5,null));};exports['getAnswers']=function(_0x405dc6,_0x5b63){var _0x2657bc={'raw':![],'where':{}};var _0x47881={};var _0x486ad6={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x247a('0x59')]({'where':{'id':_0x405dc6['params']['id']}})['then'](handleEntityNotFound(_0x5b63,null))[_0x247a('0x15')](function(_0x2c1839){if(_0x2c1839){_0x47881['model']=_[_0x247a('0x37')](db[_0x247a('0x5e')][_0x247a('0x4a')]);_0x47881[_0x247a('0x36')]=_[_0x247a('0x37')](_0x405dc6[_0x247a('0x36')]);_0x47881['filters']=_[_0x247a('0x39')](_0x47881[_0x247a('0x35')],_0x47881[_0x247a('0x36')]);_0x2657bc[_0x247a('0x3a')]=_[_0x247a('0x39')](_0x47881[_0x247a('0x35')],qs[_0x247a('0x3b')](_0x405dc6[_0x247a('0x36')]['fields']));_0x2657bc[_0x247a('0x3a')]=_0x2657bc[_0x247a('0x3a')][_0x247a('0x3c')]?_0x2657bc['attributes']:_0x47881['model'];if(!_0x405dc6[_0x247a('0x36')][_0x247a('0x3d')](_0x247a('0x3e'))){_0x2657bc['limit']=qs['limit'](_0x405dc6[_0x247a('0x36')][_0x247a('0x22')]);_0x2657bc['offset']=qs[_0x247a('0x21')](_0x405dc6['query']['offset']);}_0x2657bc[_0x247a('0x3f')]=qs[_0x247a('0x40')](_0x405dc6['query'][_0x247a('0x40')]);_0x2657bc[_0x247a('0x41')]=qs[_0x247a('0x38')](_[_0x247a('0x5f')](_0x405dc6[_0x247a('0x36')],_0x47881[_0x247a('0x38')]));_0x2657bc[_0x247a('0x41')]['ChatWebsiteId']=_0x2c1839['id'];if(_0x405dc6['query'][_0x247a('0x42')]){_0x2657bc['where']=_['merge'](_0x2657bc[_0x247a('0x41')],{'$or':_['map'](_0x2657bc[_0x247a('0x3a')],function(_0x34dbb8){var _0x71448f={};_0x71448f[_0x34dbb8]={'$like':'%'+_0x405dc6[_0x247a('0x36')]['filter']+'%'};return _0x71448f;})});}_0x2657bc=_[_0x247a('0x43')]({},_0x2657bc,_0x405dc6['options']);return db[_0x247a('0x5e')][_0x247a('0x24')]({'where':_0x2657bc['where']})[_0x247a('0x15')](function(_0x318ee6){_0x486ad6[_0x247a('0x24')]=_0x318ee6;if(_0x405dc6[_0x247a('0x36')][_0x247a('0x46')]){_0x2657bc[_0x247a('0x47')]=[{'all':!![]}];}return db['CannedAnswer'][_0x247a('0x48')](_0x2657bc);})[_0x247a('0x15')](function(_0x2f7df2){_0x486ad6[_0x247a('0x5a')]=_0x2f7df2;return _0x486ad6;});}})['then'](respondWithFilteredResult(_0x5b63,_0x2657bc))[_0x247a('0x1e')](handleError(_0x5b63,null));};exports['removeAnswers']=function(_0x5a2b9c,_0x8c88a7){return db[_0x247a('0x33')][_0x247a('0x4b')]({'where':{'id':_0x5a2b9c['params']['id']}})['then'](handleEntityNotFound(_0x8c88a7,null))['then'](function(_0x362e7a){if(_0x362e7a){return _0x362e7a[_0x247a('0x60')](_0x5a2b9c[_0x247a('0x36')][_0x247a('0x5c')]);}})[_0x247a('0x15')](respondWithStatusCode(_0x8c88a7,null))['catch'](handleError(_0x8c88a7,null));};exports[_0x247a('0x61')]=function(_0x5aaec4,_0x244426){_0x5aaec4['body'][_0x247a('0x62')]=_0x5aaec4['file'][_0x247a('0x63')];return db[_0x247a('0x33')][_0x247a('0x4b')]({'where':{'id':_0x5aaec4['params']['id']}})['then'](handleEntityNotFound(_0x244426,null))[_0x247a('0x15')](saveUpdates(_0x5aaec4[_0x247a('0x4d')],null))['then'](respondWithResult(_0x244426,null))[_0x247a('0x1e')](handleError(_0x244426,null));};exports[_0x247a('0x64')]=function(_0x32d001,_0x3a132b){_0x32d001['body'][_0x247a('0x65')]=_0x32d001[_0x247a('0x66')][_0x247a('0x63')];return db[_0x247a('0x33')][_0x247a('0x4b')]({'where':{'id':_0x32d001['params']['id']}})['then'](handleEntityNotFound(_0x3a132b,null))['then'](saveUpdates(_0x32d001[_0x247a('0x4d')],null))[_0x247a('0x15')](respondWithResult(_0x3a132b,null))[_0x247a('0x1e')](handleError(_0x3a132b,null));};exports['addCustomerAvatar']=function(_0x377621,_0x1adf87){_0x377621[_0x247a('0x4d')][_0x247a('0x67')]=_0x377621['file'][_0x247a('0x63')];return db[_0x247a('0x33')][_0x247a('0x4b')]({'where':{'id':_0x377621['params']['id']}})[_0x247a('0x15')](handleEntityNotFound(_0x1adf87,null))['then'](saveUpdates(_0x377621['body'],null))[_0x247a('0x15')](respondWithResult(_0x1adf87,null))['catch'](handleError(_0x1adf87,null));};exports[_0x247a('0x68')]=function(_0x156895,_0x12d349){_0x156895[_0x247a('0x4d')][_0x247a('0x69')]=_0x156895[_0x247a('0x66')][_0x247a('0x63')];return db['ChatWebsite'][_0x247a('0x4b')]({'where':{'id':_0x156895['params']['id']}})[_0x247a('0x15')](handleEntityNotFound(_0x12d349,null))['then'](saveUpdates(_0x156895['body'],null))[_0x247a('0x15')](respondWithResult(_0x12d349,null))[_0x247a('0x1e')](handleError(_0x12d349,null));};exports[_0x247a('0x6a')]=function(_0x451c25,_0x2e5d08){var _0x44cc22=path[_0x247a('0x6b')](config[_0x247a('0x6c')],'server/files/images/logos/default_logo.svg');var _0x385713={'where':{'id':_0x451c25['params']['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x1a551a=![];return require(_0x247a('0x6d'))[_0x247a('0x6e')]()[_0x247a('0x15')](function(_0x5b0301){if(_0x5b0301){_0x1a551a=_0x5b0301[_0x247a('0x6f')];}})[_0x247a('0x15')](function(){return db['ChatWebsite']['find'](_0x385713);})[_0x247a('0x15')](handleEntityNotFound(_0x2e5d08,null))['then'](function(_0x4a33cf){if(_0x4a33cf){if(!_[_0x247a('0x70')](_0x4a33cf[_0x247a('0x62')])){if(fs['existsSync'](path[_0x247a('0x6b')](config[_0x247a('0x6c')],_0x247a('0x71'),_0x4a33cf['sitepic']))&&_0x1a551a){_0x44cc22=path[_0x247a('0x6b')](config['root'],_0x247a('0x71'),_0x4a33cf['sitepic']);}}return _0x2e5d08[_0x247a('0x72')](_0x44cc22);}})['catch'](handleError(_0x2e5d08,null));};exports[_0x247a('0x73')]=function(_0x753ade,_0x302fa1){var _0x86cad5=path[_0x247a('0x6b')](config[_0x247a('0x6c')],_0x247a('0x74'));var _0x14df72={'where':{'id':_0x753ade[_0x247a('0x49')]['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db[_0x247a('0x33')][_0x247a('0x4b')](_0x14df72)[_0x247a('0x15')](handleEntityNotFound(_0x302fa1,null))['then'](function(_0x486aaa){if(_0x486aaa){if(!_['isNil'](_0x486aaa[_0x247a('0x65')])){if(fs[_0x247a('0x75')](path[_0x247a('0x6b')](config[_0x247a('0x6c')],_0x247a('0x76'),_0x486aaa[_0x247a('0x65')]))){_0x86cad5=path[_0x247a('0x6b')](config['root'],'server/files/images/avatars/',_0x486aaa[_0x247a('0x65')]);}}return _0x302fa1[_0x247a('0x72')](_0x86cad5);}})[_0x247a('0x1e')](handleError(_0x302fa1,null));};exports[_0x247a('0x77')]=function(_0x3b97b6,_0x5c2b88){var _0x5c4918=path['join'](config[_0x247a('0x6c')],_0x247a('0x78'));var _0x39f9d4={'where':{'id':_0x3b97b6[_0x247a('0x49')]['id']},'attributes':['id','customerAvatar','showCustomerAvatar'],'raw':!![]};return db[_0x247a('0x33')]['find'](_0x39f9d4)[_0x247a('0x15')](handleEntityNotFound(_0x5c2b88,null))[_0x247a('0x15')](function(_0x3f6e12){if(_0x3f6e12){if(!_['isNil'](_0x3f6e12[_0x247a('0x67')])){if(fs[_0x247a('0x75')](path[_0x247a('0x6b')](config[_0x247a('0x6c')],_0x247a('0x76'),_0x3f6e12[_0x247a('0x67')]))&&_0x3f6e12[_0x247a('0x79')]){_0x5c4918=path['join'](config[_0x247a('0x6c')],_0x247a('0x76'),_0x3f6e12[_0x247a('0x67')]);}}return _0x5c2b88['download'](_0x5c4918);}})[_0x247a('0x1e')](handleError(_0x5c2b88,null));};exports['getSystemAvatar']=function(_0x5e534a,_0x45d44a){var _0x5e8e78=path[_0x247a('0x6b')](config[_0x247a('0x6c')],_0x247a('0x7a'));var _0x220415={'where':{'id':_0x5e534a[_0x247a('0x49')]['id']},'attributes':['id',_0x247a('0x69')],'raw':!![]};return db[_0x247a('0x33')][_0x247a('0x4b')](_0x220415)[_0x247a('0x15')](handleEntityNotFound(_0x45d44a,null))[_0x247a('0x15')](function(_0x472692){if(_0x472692){if(!_[_0x247a('0x70')](_0x472692[_0x247a('0x69')])){if(fs[_0x247a('0x75')](path['join'](config[_0x247a('0x6c')],_0x247a('0x76'),_0x472692[_0x247a('0x69')]))){_0x5e8e78=path[_0x247a('0x6b')](config['root'],_0x247a('0x76'),_0x472692['systemAvatar']);}}return _0x45d44a[_0x247a('0x72')](_0x5e8e78);}})['catch'](handleError(_0x45d44a,null));};exports['notify']=function(_0x3c7987,_0x362d5a){var _0x210f2a=require('user-agent-parser');var _0x2f45dc=new _0x210f2a();var _0x41b6b9=_0x2f45dc[_0x247a('0x7b')](_0x3c7987[_0x247a('0x7c')][_0x247a('0x7d')])[_0x247a('0x7e')]();var _0x37f13b={'body':_0x3c7987[_0x247a('0x4d')],'channel':_0x247a('0x7f')};var _0x4c76bd=[];var _0x2e05b4=[];var _0xcda883={};var _0x239414=![];return db[_0x247a('0x80')][_0x247a('0x54')]()[_0x247a('0x15')](function(_0x217863){if(!_0x217863){throw new db[(_0x247a('0x81'))][(_0x247a('0x82'))](_0x247a('0x83'));}_0x4c76bd=_['difference'](_[_0x247a('0x37')](_0x217863),['createdAt',_0x247a('0x84')]);_0x2e05b4=_['difference'](_[_0x247a('0x37')](_0x217863),['createdAt','updatedAt',_0x247a('0x85'),_0x247a('0x86')]);if(_0x3c7987[_0x247a('0x4d')]['id']){delete _0x3c7987[_0x247a('0x4d')]['id'];}if(_[_0x247a('0x70')](_0x3c7987[_0x247a('0x4d')][_0x247a('0x87')])){throw new db[(_0x247a('0x81'))][(_0x247a('0x82'))](_0x247a('0x88'));}if(_[_0x247a('0x70')](_0x3c7987[_0x247a('0x4d')][_0x247a('0x4d')])||_0x3c7987[_0x247a('0x4d')][_0x247a('0x4d')]===''){throw new db[(_0x247a('0x81'))]['ValidationError'](_0x247a('0x89'));}if(_[_0x247a('0x70')](_0x3c7987['body']['mapKey'])){throw new db[(_0x247a('0x81'))]['ValidationError'](_0x247a('0x8a')+_0x2e05b4);}if(!_[_0x247a('0x8b')](_0x2e05b4,_0x3c7987['body'][_0x247a('0x8c')])){throw new db[(_0x247a('0x81'))][(_0x247a('0x82'))](_0x247a('0x8d')+_0x2e05b4);}_0xcda883[_0x3c7987[_0x247a('0x4d')][_0x247a('0x8c')]]=_0x3c7987[_0x247a('0x4d')][_0x247a('0x87')];})[_0x247a('0x15')](function(){return db[_0x247a('0x33')][_0x247a('0x4b')]({'where':{'id':_0x3c7987[_0x247a('0x49')]['id']},'include':[{'model':db[_0x247a('0x8e')],'as':_0x247a('0x8f'),'include':[{'model':db[_0x247a('0x80')],'as':_0x247a('0x90'),'where':_0xcda883,'limit':0x1,'order':[['updatedAt',_0x247a('0x91')]]}]},{'model':db[_0x247a('0x92')],'as':_0x247a('0x93')}]});})[_0x247a('0x15')](handleEntityNotFound(_0x362d5a,null))[_0x247a('0x15')](function(_0x14ed85){if(_0x14ed85&&_0x14ed85['List']){_0x37f13b[_0x247a('0x94')]=_0x14ed85;_0x37f13b['applications']=_0x14ed85['Applications'];_0x37f13b[_0x247a('0x95')]=_0x14ed85[_0x247a('0x8f')];_0x37f13b[_0x247a('0x96')]=_[_0x247a('0x97')](_0x37f13b[_0x247a('0x96')],[_0x247a('0x98')],['asc']);if(_0x37f13b[_0x247a('0x94')][_0x247a('0x93')]){delete _0x37f13b[_0x247a('0x94')]['Applications'];}if(_0x37f13b[_0x247a('0x94')][_0x247a('0x8f')]&&_0x37f13b[_0x247a('0x94')]['List'][_0x247a('0x90')]['length']){return _0x37f13b[_0x247a('0x94')]['List'][_0x247a('0x90')][0x0];}var _0x417543=_['defaults'](_0x3c7987[_0x247a('0x4d')],{'firstName':_0x3c7987[_0x247a('0x4d')][_0x247a('0x87')],'ListId':_0x14ed85[_0x247a('0x86')]});_0x417543[_0x3c7987['body']['mapKey']]=_0x3c7987[_0x247a('0x4d')]['from'];return db[_0x247a('0x80')][_0x247a('0x4c')](_0x417543,{'fields':_0x4c76bd,'raw':!![]});}})['then'](handleEntityNotFound(_0x362d5a,null))[_0x247a('0x15')](function(_0x137967){_0x37f13b[_0x247a('0x99')]=_0x137967;var _0x3f7773=_0x3c7987['body'][_0x247a('0x9a')];if(_0x3c7987[_0x247a('0x7c')][_0x247a('0x9b')]){_0x3f7773=_0x3c7987[_0x247a('0x7c')]['cf-connecting-ip'];}else if(_0x3c7987[_0x247a('0x7c')][_0x247a('0x9c')]){_0x3f7773=_['first'](_0x3c7987[_0x247a('0x7c')][_0x247a('0x9c')][_0x247a('0x9d')](','));}if(_0x137967){var _0x5b319d={'ContactId':_0x137967['id'],'ChatWebsiteId':_0x3c7987[_0x247a('0x49')]['id'],'from':(_0x137967[_0x247a('0x9e')]||'')+'\x20'+(_0x137967[_0x247a('0x9f')]||''),'customerIp':_0x3f7773,'customerPort':_0x3c7987[_0x247a('0x7c')]['x-real-port']?_0x3c7987[_0x247a('0x7c')]['x-real-port']:null,'referer':_0x3c7987[_0x247a('0x4d')][_0x247a('0xa0')],'browserName':_0x41b6b9[_0x247a('0xa1')]['name']&&_0x41b6b9[_0x247a('0xa1')][_0x247a('0xa2')]?util['format'](_0x247a('0xa3'),_0x41b6b9[_0x247a('0xa1')][_0x247a('0x2e')],_0x41b6b9[_0x247a('0xa1')]['version']):_0x247a('0xa4'),'browserVersion':_0x41b6b9[_0x247a('0xa1')]['version']||'unknown','osName':util['format'](_0x247a('0xa3'),_0x41b6b9['os'][_0x247a('0x2e')],_0x41b6b9['os'][_0x247a('0xa2')]),'osVersion':_0x41b6b9['os'][_0x247a('0xa2')],'deviceModel':_0x41b6b9[_0x247a('0xa5')][_0x247a('0x35')]&&_0x41b6b9[_0x247a('0xa5')][_0x247a('0xa6')]?util['format'](_0x247a('0xa7'),_0x41b6b9[_0x247a('0xa5')][_0x247a('0x35')],_0x41b6b9[_0x247a('0xa5')]['vendor'],_0x41b6b9[_0x247a('0xa5')][_0x247a('0x34')]):null,'deviceVendor':_0x41b6b9[_0x247a('0xa5')][_0x247a('0xa6')],'deviceType':_0x41b6b9[_0x247a('0xa5')][_0x247a('0x34')],'formData':JSON[_0x247a('0xa8')](_0x3c7987[_0x247a('0x4d')])};var _0x1e7286={'ChatWebsiteId':_0x3c7987[_0x247a('0x49')]['id'],'closed':![]};if(_0x3c7987['body'][_0x247a('0xa9')]){_0x1e7286[_0x247a('0xa9')]=_0x3c7987[_0x247a('0x4d')][_0x247a('0xa9')];return db[_0x247a('0xaa')]['find']({'where':_0x1e7286})[_0x247a('0x15')](function(_0x2bde25){if(_0x2bde25){return[_0x2bde25,![]];}_0x5b319d['threadId']=_0x3c7987[_0x247a('0x4d')][_0x247a('0xa9')];_0x5b319d[_0x247a('0xab')]=_0x3c7987['body'][_0x247a('0xab')];return db[_0x247a('0xaa')][_0x247a('0x4c')](_0x5b319d)[_0x247a('0x15')](function(_0x2847e3){return[_0x2847e3,!![]];});});}_0x1e7286[_0x247a('0xac')]=_0x137967['id'];if(_0x3c7987[_0x247a('0x4d')][_0x247a('0xad')]&&_0x3c7987[_0x247a('0x4d')][_0x247a('0xad')]['id']){_0x1e7286['id']=_0x3c7987[_0x247a('0x4d')][_0x247a('0xad')]['id'];return db[_0x247a('0xaa')][_0x247a('0x4b')]({'where':_0x1e7286})[_0x247a('0x15')](function(_0x1dc50f){if(_0x1dc50f){return[_0x1dc50f,![]];}return db[_0x247a('0xaa')]['create'](_0x5b319d)[_0x247a('0x15')](function(_0x345d67){return[_0x345d67,!![]];});});}return db[_0x247a('0xaa')][_0x247a('0x4c')](_0x5b319d)[_0x247a('0x15')](function(_0x23b995){return[_0x23b995,!![]];});}})[_0x247a('0xae')](function(_0x5c9ee4,_0x1dba37){if(_0x5c9ee4){_0x239414=_0x1dba37;if(!_0x1dba37){var _0x46d7cc={'from':(_0x37f13b['contact'][_0x247a('0x9e')]||'')+'\x20'+(_0x37f13b[_0x247a('0x99')][_0x247a('0x9f')]||'')};if(_0x3c7987[_0x247a('0x4d')]['threadId']&&_0x3c7987[_0x247a('0x4d')][_0x247a('0xaf')]&&_0x3c7987[_0x247a('0x4d')][_0x247a('0xa9')]!=_0x3c7987[_0x247a('0x4d')][_0x247a('0xaf')]){_0x46d7cc[_0x247a('0xa9')]=_0x3c7987[_0x247a('0x4d')][_0x247a('0xaf')];}return _0x5c9ee4[_0x247a('0x26')](_0x46d7cc);}else{return _0x5c9ee4;}}})[_0x247a('0x15')](function(_0x43b765){_0x37f13b['interaction']=_0x43b765[_0x247a('0x28')]({'plain':!![]});_0x37f13b['interaction']['created']=_0x239414;if(_0x37f13b['interaction'][_0x247a('0xb0')]){if(_0x37f13b[_0x247a('0x94')][_0x247a('0xb1')]){_0x37f13b[_0x247a('0x96')][_0x247a('0xb2')]({'id':0x0,'priority':_0x37f13b['applications']['length']+0x1,'app':_0x247a('0xb3'),'appdata':'unmanaged','interval':_0x247a('0xb4')});}}return db[_0x247a('0xb5')][_0x247a('0x4c')]({'body':_0x3c7987[_0x247a('0x4d')]['body'],'ChatWebsiteId':_0x3c7987['params']['id'],'ChatInteractionId':_0x43b765['id'],'direction':'in','ContactId':_0x37f13b['contact']['id'],'AttachmentId':_0x3c7987['body'][_0x247a('0xb6')]});})[_0x247a('0x15')](function(_0x5af189){_0x37f13b[_0x247a('0x1d')]=_0x5af189;if(_0x37f13b[_0x247a('0xad')][_0x247a('0xb7')]){return db[_0x247a('0xb8')][_0x247a('0x4b')]({'attributes':['id',_0x247a('0x2e')],'where':{'id':_0x37f13b[_0x247a('0xad')][_0x247a('0xb7')]}})[_0x247a('0x15')](function(_0x2a0275){if(_0x2a0275){_0x37f13b[_0x247a('0x96')]['unshift']({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x2a0275['name']+','+(_0x37f13b[_0x247a('0x94')][_0x247a('0xb9')]||0xa),'interval':_0x247a('0xb4')});_0x37f13b[_0x247a('0xba')]=!![];}return respondWithRpcPromise(_0x247a('0xbb'),'startRouting',_0x37f13b);});}return respondWithRpcPromise(_0x247a('0xbb'),_0x247a('0xbc'),_0x37f13b);})[_0x247a('0x15')](function(_0x4c9f94){respondWithRpcPromise(_0x247a('0xbd'),'EventManager',{'event':'notify','message':_0x4c9f94},client9002);return _0x4c9f94;})[_0x247a('0x15')](respondWithResult(_0x362d5a,null))[_0x247a('0x1e')](handleError(_0x362d5a,null));};exports[_0x247a('0xbe')]=function(_0x40bba2,_0xe38d69){var _0x4dd337,_0x1b0ee4,_0x13ea12;var _0x1db134=[];var _0xaf785f={};var _0x36d496=_0x40bba2[_0x247a('0xbf')]||[];var _0x2b0c55=[];var _0x24ed4f;return db[_0x247a('0x80')]['describe']()[_0x247a('0x15')](function(_0x1deb08){if(!_0x1deb08){throw new db['Sequelize']['ValidationError']('no\x20available\x20attributes');}_0x1db134=_[_0x247a('0xc0')](_[_0x247a('0x37')](_0x1deb08),[_0x247a('0xc1'),_0x247a('0x84'),_0x247a('0x85'),_0x247a('0x86')]);if(_0x40bba2[_0x247a('0x4d')]['id']){delete _0x40bba2[_0x247a('0x4d')]['id'];}if(_[_0x247a('0x70')](_0x40bba2[_0x247a('0x4d')][_0x247a('0x87')])){throw _0xe38d69[_0x247a('0x2b')](0x1f4)[_0x247a('0x2f')](new db[(_0x247a('0x81'))]['ValidationError'](_0x247a('0x88')));}if(_[_0x247a('0x70')](_0x40bba2['body'][_0x247a('0x4d')])||_0x40bba2[_0x247a('0x4d')][_0x247a('0x4d')]===''){throw _0xe38d69[_0x247a('0x2b')](0x1f4)[_0x247a('0x2f')](new db[(_0x247a('0x81'))][(_0x247a('0x82'))](_0x247a('0x89')));}if(_['isNil'](_0x40bba2['body'][_0x247a('0xc2')])){throw _0xe38d69['status'](0x1f4)[_0x247a('0x2f')](new db[(_0x247a('0x81'))]['ValidationError']('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x1db134));}if(!_[_0x247a('0x8b')](_0x1db134,_0x40bba2[_0x247a('0x4d')][_0x247a('0xc2')])){throw _0xe38d69[_0x247a('0x2b')](0x1f4)[_0x247a('0x2f')](new db[(_0x247a('0x81'))][(_0x247a('0x82'))]('mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x1db134));}_0xaf785f[_0x40bba2[_0x247a('0x4d')][_0x247a('0xc2')]]=_0x40bba2[_0x247a('0x4d')]['from'];})[_0x247a('0x15')](function(){return db[_0x247a('0x33')]['find']({'where':{'id':_0x40bba2['params']['id']},'include':[{'model':db[_0x247a('0x8e')],'as':'List'},{'model':db['MailAccount'],'as':_0x247a('0xc3')}]});})[_0x247a('0x15')](handleEntityNotFound(_0xe38d69,null))[_0x247a('0x15')](function(_0x3928ad){if(_0x3928ad&&_0x3928ad[_0x247a('0x8f')]){_0x1b0ee4=_0x3928ad;var _0xcd198d=_[_0x247a('0xa')](_0x40bba2[_0x247a('0x4d')],{'firstName':_0x40bba2[_0x247a('0x4d')][_0x247a('0x87')],'phone':_0x40bba2[_0x247a('0x4d')][_0x247a('0x87')],'ListId':_0x3928ad[_0x247a('0x86')]});_0xcd198d[_0x40bba2[_0x247a('0x4d')][_0x247a('0xc2')]]=_0x40bba2[_0x247a('0x4d')]['from'];return db[_0x247a('0x80')][_0x247a('0xc4')]({'where':_0xaf785f,'defaults':_0xcd198d});}})[_0x247a('0xae')](function(_0x4ef720){if(_0x4ef720){_0x13ea12=_0x4ef720;var _0x56ea71=fs[_0x247a('0xc5')](path[_0x247a('0x6b')](config[_0x247a('0x6c')],'server/files/templates/chatOfflineMessage.ejs'),_0x247a('0xc6'));var _0x11da62=ejs[_0x247a('0xc7')](_0x56ea71,{'body':_[_0x247a('0xc8')](_0x40bba2[_0x247a('0x4d')][_0x247a('0x4d')]),'bodyTitle':_0x1b0ee4[_0x247a('0xc9')]});return db['ChatOfflineMessage'][_0x247a('0x4c')]({'body':_0x11da62,'plainBody':htmlToText[_0x247a('0xca')](_0x11da62),'ContactId':_0x4ef720['id'],'ChatWebsiteId':_0x1b0ee4['id']});}})[_0x247a('0x15')](function(_0x380e96){_0x24ed4f=_0x380e96;if(_0x36d496[_0x247a('0x3c')]){var _0x3c4096=_0x36d496[_0x247a('0x32')](function(_0x562784){return{'name':_0x562784['originalname'],'basename':_0x562784['filename'],'type':_0x562784['mimetype'],'ChatOfflineMessageId':_0x380e96['id']};});_0x2b0c55=_0x3c4096[_0x247a('0x32')](_0xbeb4ce=>{var _0x128e0f={'filename':_0xbeb4ce[_0x247a('0x2e')],'path':path[_0x247a('0x6b')](config['root'],_0x247a('0xcb'),_0x247a('0xbf'),'attachments',_0x247a('0xcc'),_0xbeb4ce['basename'])};return _0x128e0f;});if(!_0x1b0ee4[_0x247a('0xcd')]){return db[_0x247a('0xce')][_0x247a('0xcf')](function(_0x5020e6){return db[_0x247a('0xd0')][_0x247a('0xd1')](_0x3c4096,{'transaction':_0x5020e6});});}}})[_0x247a('0x15')](function(){if(_0x24ed4f){_0x4dd337=_0x24ed4f;return db['MailAccount'][_0x247a('0x59')]({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':_0x247a('0xd2'),'raw':!![],'include':[{'model':db[_0x247a('0xd3')],'as':_0x247a('0xd3'),'raw':!![]}]}]});}})[_0x247a('0x15')](function(_0x44fef9){if(_0x44fef9&&_0x44fef9['Smtp']&&_0x1b0ee4['forwardOffline']&&_0x1b0ee4[_0x247a('0xd4')]){var _0x2164f4=_0x44fef9[_0x247a('0xd5')]();return respondWithRpcPromise(_0x247a('0xd6'),_0x247a('0xd7'),{'account':_0x2164f4,'message':{'from':util[_0x247a('0xd8')](_0x247a('0xd9'),_0x44fef9[_0x247a('0x2e')],_0x44fef9[_0x247a('0xda')]||_0x44fef9[_0x247a('0xd2')]['user']),'to':_0x1b0ee4[_0x247a('0xd4')],'subject':_0x1b0ee4[_0x247a('0xdb')],'html':_0x4dd337[_0x247a('0x4d')],'attachments':_0x2b0c55}},client9003)[_0x247a('0x15')](function(){return _0x4dd337;})['catch'](function(_0x319724){logger[_0x247a('0x1b')](_0x319724);});}})[_0x247a('0x15')](function(){if(_0x1b0ee4&&_0x1b0ee4['openNewInteraction']&&_0x1b0ee4[_0x247a('0xdc')]){var _0x5f276a=[];if(_0x36d496[_0x247a('0x3c')]){_0x5f276a=_0x36d496[_0x247a('0x32')](function(_0x56d882){return{'name':_0x56d882[_0x247a('0xdd')],'basename':_0x56d882[_0x247a('0x63')],'type':_0x56d882[_0x247a('0xde')],'ChatOfflineMessageId':_0x24ed4f['id']};});}var _0x2b2882;if(!_['isNil'](_0x1b0ee4[_0x247a('0xdf')])){var _0xe8935c=_[_0x247a('0x32')](_0x40bba2[_0x247a('0x4d')],function(_0x32dfc2){return _0x32dfc2;});var _0x1ad71e=_[_0x247a('0xe0')](_0xe8935c)[0x0];var _0x4f489b=_[_0x247a('0xe1')](_0x1ad71e,function(_0x3c0b92){return _0x3c0b92;});_0x2b2882=_0x4f489b[0x1][_0x1b0ee4[_0x247a('0xdf')]];}var _0x4c7e02={'from':_0x13ea12[_0x247a('0xda')],'firstName':_0x13ea12['firstName'],'lastName':_0x13ea12[_0x247a('0x9f')],'mapKey':_0x247a('0xda'),'message':{'from':_0x13ea12['email'],'to':_0x1b0ee4['MailAccount'][_0x247a('0xda')],'cc':'','subject':_[_0x247a('0x70')](_0x2b2882)?_0x1b0ee4[_0x247a('0xdb')]:_0x2b2882,'messageId':'','sentAt':new Date(),'attach':_0x5f276a['length'],'attachments':_0x5f276a,'originChannel':'Chat','ChatWebsiteId':_0x1b0ee4['id'],'ChatOfflineMessageId':_0x4dd337['id'],'originTo':_0x1b0ee4[_0x247a('0xc3')][_0x247a('0xda')]},'body':_0x4dd337[_0x247a('0x4d')]};var _0x2b8079={'account':{'id':_0x1b0ee4[_0x247a('0xdc')]},'body':_0x4c7e02,'log':_0x247a('0xe2')};return respondWithRpcPromise(_0x247a('0xe2'),_0x247a('0xe3'),_0x2b8079,client9001)[_0x247a('0x15')](function(){return _0x4dd337;})[_0x247a('0x1e')](function(_0x4772fc){logger[_0x247a('0x1b')](_0x4772fc);});}return;})[_0x247a('0x15')](function(){if(_0x4dd337){return _0x4dd337;}})[_0x247a('0x15')](respondWithResult(_0xe38d69,null))['catch'](function(_0x30b173){logger[_0x247a('0x1b')](_0x247a('0x1e'),_0x30b173);for(var _0x305e23 of _0x36d496){var _0x22f0d7=path[_0x247a('0x6b')](config['root'],_0x247a('0xcb'),'files','attachments',_0x247a('0xcc'),_0x305e23[_0x247a('0x63')]);fs_extra[_0x247a('0xe4')](_0x22f0d7)[_0x247a('0x1e')](function(_0x5708ac){logger[_0x247a('0x1b')](_0x247a('0xe5'),_0x22f0d7,_0x5708ac);});}});};exports[_0x247a('0xe6')]=function(_0x47e85e,_0x8c2b60){return db[_0x247a('0xaa')][_0x247a('0x4b')]({'where':{'id':_0x47e85e[_0x247a('0x49')]['id']}})['then'](handleEntityNotFound(_0x8c2b60,null))[_0x247a('0x15')](function(_0x36fefe){if(_0x36fefe){return _0x36fefe['addInteraction'](_0x47e85e['body']['ids'],_[_0x247a('0xe7')](_0x47e85e['body'],[_0x247a('0x5c'),'id'])||{});}})[_0x247a('0x15')](respondWithResult(_0x8c2b60,null))[_0x247a('0x1e')](handleError(_0x8c2b60,null));};exports[_0x247a('0xe8')]=function(_0xfd8658,_0x3a4017){var _0x4c658c={'raw':![],'where':{}};var _0x41038f={};var _0x16dd04={'count':0x0,'rows':[]};return db[_0x247a('0x33')][_0x247a('0x59')]({'where':{'id':_0xfd8658[_0x247a('0x49')]['id']}})['then'](handleEntityNotFound(_0x3a4017,null))[_0x247a('0x15')](function(_0x3a2a22){if(_0x3a2a22){_0x41038f[_0x247a('0x35')]=_[_0x247a('0x37')](db[_0x247a('0xaa')]['rawAttributes']);_0x41038f[_0x247a('0x36')]=_['keys'](_0xfd8658[_0x247a('0x36')]);_0x41038f[_0x247a('0x38')]=_['intersection'](_0x41038f[_0x247a('0x35')],_0x41038f['query']);_0x4c658c[_0x247a('0x3a')]=_[_0x247a('0x39')](_0x41038f['model'],qs[_0x247a('0x3b')](_0xfd8658[_0x247a('0x36')]['fields']));_0x4c658c['attributes']=_0x4c658c[_0x247a('0x3a')][_0x247a('0x3c')]?_0x4c658c['attributes']:_0x41038f[_0x247a('0x35')];if(!_0xfd8658[_0x247a('0x36')][_0x247a('0x3d')]('nolimit')){_0x4c658c[_0x247a('0x22')]=qs[_0x247a('0x22')](_0xfd8658[_0x247a('0x36')][_0x247a('0x22')]);_0x4c658c['offset']=qs[_0x247a('0x21')](_0xfd8658[_0x247a('0x36')][_0x247a('0x21')]);}_0x4c658c['order']=qs[_0x247a('0x40')](_0xfd8658[_0x247a('0x36')]['sort']);_0x4c658c[_0x247a('0x41')]=qs['filters'](_['pick'](_0xfd8658['query'],_0x41038f['filters']));_0x4c658c[_0x247a('0x41')]['ChatWebsiteId']=_0x3a2a22['id'];if(_0xfd8658['query'][_0x247a('0x42')]){_0x4c658c['where']=_[_0x247a('0x43')](_0x4c658c[_0x247a('0x41')],{'$or':_[_0x247a('0x32')](_0x4c658c[_0x247a('0x3a')],function(_0x4a128e){var _0x512bee={};_0x512bee[_0x4a128e]={'$like':'%'+_0xfd8658[_0x247a('0x36')][_0x247a('0x42')]+'%'};return _0x512bee;})});}_0x4c658c=_[_0x247a('0x43')]({},_0x4c658c,_0xfd8658[_0x247a('0x45')]);return db[_0x247a('0xaa')]['count']({'where':_0x4c658c[_0x247a('0x41')]})[_0x247a('0x15')](function(_0x5e67f2){_0x16dd04[_0x247a('0x24')]=_0x5e67f2;if(_0xfd8658[_0x247a('0x36')][_0x247a('0x46')]){_0x4c658c[_0x247a('0x47')]=[{'model':db['CmContact'],'as':_0x247a('0xe9'),'required':![]},{'model':db[_0x247a('0xb8')],'as':_0x247a('0xea'),'attributes':[_0x247a('0x2e'),_0x247a('0xeb'),_0x247a('0xec')],'required':![]},{'model':db[_0x247a('0xed')],'as':'Tags','attributes':['id',_0x247a('0x2e'),_0x247a('0xee')],'where':_0xfd8658[_0x247a('0x36')][_0x247a('0xef')]?{'id':_0xfd8658['query'][_0x247a('0xef')]}:undefined,'required':_0xfd8658[_0x247a('0x36')][_0x247a('0xef')]?!![]:![]}];}return db[_0x247a('0xaa')]['findAll'](_0x4c658c);})[_0x247a('0x15')](function(_0x2ebc31){_0x16dd04[_0x247a('0x5a')]=_0x2ebc31;return _0x16dd04;});}})[_0x247a('0x15')](respondWithFilteredResult(_0x3a4017,_0x4c658c))['catch'](handleError(_0x3a4017,null));};function iftimePromise(_0x37c721,_0x29688f){return respondWithRpcPromise('Command',_0x247a('0xf0'),{'command':_0x29688f[_0x247a('0xf1')]?util['format'](_0x247a('0xf2'),_0x37c721[_0x247a('0xf3')],_0x29688f['timezone']):util[_0x247a('0xd8')](_0x247a('0xf4'),_0x37c721[_0x247a('0xf3')])},client9002)[_0x247a('0x15')](function(_0x4d4089){var _0x46bcad=_0x4d4089&&_0x4d4089[_0x247a('0xf5')](_0x247a('0xf6'))>=0x0?!![]:![];logger[_0x247a('0x16')](_0x247a('0xf7'),_0x29688f['id'],_0x37c721['id'],_0x37c721['interval'],_0x46bcad?_0x247a('0xf8'):_0x247a('0xf9'),_0x29688f[_0x247a('0xf1')]?_0x29688f[_0x247a('0xf1')]:'No\x20timezone');return _0x46bcad;})[_0x247a('0x1e')](function(_0x5392f1){logger[_0x247a('0x1b')](_0x247a('0xf7'),_0x29688f['id'],_0x37c721['id'],_0x37c721[_0x247a('0xf3')],util[_0x247a('0xfa')](_0x5392f1,{'showHidden':![],'depth':null}),_0x29688f[_0x247a('0xf1')]?_0x29688f[_0x247a('0xf1')]:'No\x20timezone');return![];});}exports[_0x247a('0xf0')]=function(_0x19260f,_0x34175a){var _0x4434da=0x0;var _0x3f206d=0x0;var _0x2fe538=![];var _0x4b0d28;var _0x32129f;return db[_0x247a('0x33')]['find']({'where':{'id':_0x19260f[_0x247a('0x49')]['id']},'include':[{'model':db[_0x247a('0xfb')],'as':_0x247a('0xfb'),'include':[{'model':db[_0x247a('0xfb')],'as':_0x247a('0xfc'),'attributes':['id','interval'],'raw':!![]}]}]})['then'](handleEntityNotFound(_0x34175a,null))[_0x247a('0x15')](function(_0x3a9d35){if(_0x3a9d35){_0x4b0d28=_0x3a9d35;return _0x3a9d35[_0x247a('0xfd')]({'raw':!![]});}})[_0x247a('0x15')](function(_0x24dc9a){if(_0x4b0d28){if(_0x24dc9a){_0x32129f=_0x24dc9a;}}return require(_0x247a('0x6d'))[_0x247a('0x6e')]();})[_0x247a('0x15')](function(_0x9be65f){if(_0x9be65f){_0x3f206d=_0x9be65f[_0x247a('0xfe')];_0x2fe538=_0x9be65f[_0x247a('0x6f')];}})[_0x247a('0x15')](function(){return db[_0x247a('0xaa')][_0x247a('0x24')]({'where':{'closed':![]}});})[_0x247a('0x15')](function(_0x1560e6){_0x4434da=_0x1560e6;if(_0x3f206d&&_0x1560e6>_0x3f206d){return db[_0x247a('0xff')][_0x247a('0x59')]({'where':{'id':0x1}})[_0x247a('0x15')](function(_0x4113ac){if(_0x4113ac){_0x4113ac[_0x247a('0x100')](_0x247a('0x101'));}});}})[_0x247a('0x15')](function(){if(_0x4b0d28['Interval']&&_0x4b0d28[_0x247a('0xfb')]['Intervals']){var _0x37ef12=[];for(var _0x17854a=0x0;_0x17854a<_0x4b0d28[_0x247a('0xfb')]['Intervals'][_0x247a('0x3c')];_0x17854a++){var _0x1ccc42=_0x4b0d28[_0x247a('0xfb')][_0x247a('0xfc')][_0x17854a][_0x247a('0x28')]({'plain':!![]});_0x37ef12[_0x247a('0xb2')](iftimePromise(_0x1ccc42,_0x4b0d28));}return BPromise[_0x247a('0x102')](_0x37ef12)[_0x247a('0x15')](function(_0x56b7ab){return _[_0x247a('0x103')](_0x56b7ab);});}else{return!![];}})['then'](function(_0x5267a6){var _0xd9cf45=fs[_0x247a('0xc5')](path[_0x247a('0x6b')](config['root'],'server/files/chat/iframe.ejs'),'utf8');var _0x510ab4={'remote':_0x4b0d28[_0x247a('0x104')],'query':querystring[_0x247a('0xa8')](_['merge'](_0x4b0d28['get']({'plain':!![]}),{'customerIp':_0x19260f[_0x247a('0x7c')][_0x247a('0x9c')]||_0x19260f[_0x247a('0x7c')][_0x247a('0x105')]||_0x19260f[_0x247a('0x106')][_0x247a('0x107')]||_0x19260f['ip'],'referer':_0x19260f['headers']['referer'],'openedInteractions':_0x4434da,'maxInteractions':_0x3f206d,'virtual':_0x2fe538['virtual'],'online':_0x5267a6,'custom':_0x2fe538}))[_0x247a('0x108')](/'/g,'\x5c\x27')};_0x34175a[_0x247a('0x2f')](ejs['render'](Mustache['render'](_0xd9cf45,_0x510ab4),{'proactiveActions':_0x32129f,'alignment':_0x4b0d28[_0x247a('0x109')],'verticalAlignment':_0x4b0d28[_0x247a('0x10a')],'div_color':_0x4b0d28[_0x247a('0xee')],'labelText':_0x4b0d28['labelText'],'text_color':_0x4b0d28[_0x247a('0x10b')],'text_button_color':_0x4b0d28[_0x247a('0x10c')],'button_color':_0x4b0d28['color_button'],'background_color':_0x4b0d28['backgroundColor'],'hideWhenOffline':_0x4b0d28[_0x247a('0x10d')],'interval':_0x4b0d28[_0x247a('0x10e')]}));})['catch'](handleError(_0x34175a,null));};exports[_0x247a('0x10f')]=function(_0x22e5f2,_0x27c0b9){var _0xfb7b9=_0x22e5f2[_0x247a('0x49')]['id'];var _0x36a8a9=_0x22e5f2['body'];var _0x528454=0xc8;var _0x9080ec=null;return db[_0x247a('0xce')]['transaction']({'isolationLevel':db['sequelize'][_0x247a('0x110')]['ISOLATION_LEVELS'][_0x247a('0x111')]},function(_0x59a51f){return db[_0x247a('0x33')][_0x247a('0x59')]({'where':{'id':_0xfb7b9},'transaction':_0x59a51f})[_0x247a('0x15')](function(_0x11fb28){if(_0x11fb28){return db[_0x247a('0x92')]['destroy']({'where':{'ChatWebsiteId':_0xfb7b9},'transaction':_0x59a51f})['then'](function(){var _0x476136=_[_0x247a('0x32')](_0x36a8a9,function(_0x4bec63){_0x4bec63[_0x247a('0x56')]=_0xfb7b9;return _0x4bec63;});return db[_0x247a('0x92')][_0x247a('0xd1')](_0x476136,{'transaction':_0x59a51f});});}else{_0x528454=0x194;_0x9080ec=[];}});})[_0x247a('0x15')](function(){if(_0x528454!==0x194){return db[_0x247a('0x92')][_0x247a('0x112')]({'where':{'ChatWebsiteId':_0xfb7b9},'order':_0x247a('0x98')})[_0x247a('0x15')](function(_0xa3f785){_0x9080ec=_0xa3f785;});}})[_0x247a('0x1e')](function(_0x147184){_0x528454=0x1f4;logger[_0x247a('0x1b')](_0x147184[_0x247a('0x2d')]);if(_0x147184[_0x247a('0x2e')]){delete _0x147184[_0x247a('0x2e')];}_0x9080ec=_0x147184;})['finally'](function(){if(_0x9080ec===null){_0x27c0b9[_0x247a('0x2c')](_0x528454);}else{if(_0x528454===0x1f4){_0x27c0b9[_0x247a('0x2b')](_0x528454)[_0x247a('0x2f')](_0x9080ec);}else{_0x27c0b9['status'](_0x528454)[_0x247a('0x20')](_0x9080ec);}}});};exports[_0x247a('0x113')]=function(_0x317dfe,_0x34b5b9){var _0x4538e1={};var _0x1faaa0={};var _0x5d04f4;var _0x40b0c9;return db[_0x247a('0x33')][_0x247a('0x59')]({'where':{'id':_0x317dfe[_0x247a('0x49')]['id']}})[_0x247a('0x15')](handleEntityNotFound(_0x34b5b9,null))[_0x247a('0x15')](function(_0x2b1191){if(_0x2b1191){_0x5d04f4=_0x2b1191;_0x1faaa0['model']=_[_0x247a('0x37')](db[_0x247a('0x92')][_0x247a('0x4a')]);_0x1faaa0[_0x247a('0x36')]=_[_0x247a('0x37')](_0x317dfe['query']);_0x1faaa0[_0x247a('0x38')]=_[_0x247a('0x39')](_0x1faaa0[_0x247a('0x35')],_0x1faaa0['query']);_0x4538e1[_0x247a('0x3a')]=_[_0x247a('0x39')](_0x1faaa0[_0x247a('0x35')],qs['fields'](_0x317dfe[_0x247a('0x36')]['fields']));_0x4538e1[_0x247a('0x3a')]=_0x4538e1[_0x247a('0x3a')][_0x247a('0x3c')]?_0x4538e1[_0x247a('0x3a')]:_0x1faaa0['model'];_0x4538e1['order']=qs[_0x247a('0x40')](_0x317dfe[_0x247a('0x36')][_0x247a('0x40')]);_0x4538e1[_0x247a('0x41')]=qs[_0x247a('0x38')](_['pick'](_0x317dfe[_0x247a('0x36')],_0x1faaa0['filters']));if(_0x317dfe[_0x247a('0x36')][_0x247a('0x42')]){_0x4538e1[_0x247a('0x41')]=_[_0x247a('0x43')](_0x4538e1[_0x247a('0x41')],{'$or':_[_0x247a('0x32')](_0x4538e1[_0x247a('0x3a')],function(_0x330991){var _0x1f8a6e={};_0x1f8a6e[_0x330991]={'$like':'%'+_0x317dfe['query'][_0x247a('0x42')]+'%'};return _0x1f8a6e;})});}_0x4538e1=_[_0x247a('0x43')]({},_0x4538e1,_0x317dfe[_0x247a('0x45')]);return _0x5d04f4[_0x247a('0x113')](_0x4538e1);}})[_0x247a('0x15')](function(_0x44542d){if(_0x44542d){_0x40b0c9=_0x44542d[_0x247a('0x3c')];if(!_0x317dfe['query'][_0x247a('0x3d')](_0x247a('0x3e'))){_0x4538e1[_0x247a('0x22')]=qs[_0x247a('0x22')](_0x317dfe['query'][_0x247a('0x22')]);_0x4538e1['offset']=qs[_0x247a('0x21')](_0x317dfe[_0x247a('0x36')]['offset']);}return _0x5d04f4['getApplications'](_0x4538e1);}})[_0x247a('0x15')](function(_0x37bdec){if(_0x37bdec){return _0x37bdec?{'count':_0x40b0c9,'rows':_0x37bdec}:null;}})[_0x247a('0x15')](respondWithResult(_0x34b5b9,null))[_0x247a('0x1e')](handleError(_0x34b5b9,null));};exports[_0x247a('0x114')]=function(_0x15f822,_0x3bea05){return db[_0x247a('0x115')][_0x247a('0x4b')]({'where':{'id':_0x15f822['params']['id']}})[_0x247a('0x15')](handleEntityNotFound(_0x3bea05,null))[_0x247a('0x15')](function(_0x4ae94b){if(_0x4ae94b){return _0x4ae94b[_0x247a('0x114')](_0x15f822[_0x247a('0x4d')][_0x247a('0x5c')],_[_0x247a('0xe7')](_0x15f822[_0x247a('0x4d')],[_0x247a('0x5c'),'id'])||{});}})[_0x247a('0x15')](respondWithResult(_0x3bea05,null))[_0x247a('0x1e')](handleError(_0x3bea05,null));};exports['getProactiveActions']=function(_0x16f3fd,_0x5c6ae8){var _0x30b2d0={};var _0x57d77d={};var _0x4d5bc1;var _0x183c99;return db[_0x247a('0x33')][_0x247a('0x59')]({'where':{'id':_0x16f3fd[_0x247a('0x49')]['id']}})[_0x247a('0x15')](handleEntityNotFound(_0x5c6ae8,null))['then'](function(_0x18cfaf){if(_0x18cfaf){_0x4d5bc1=_0x18cfaf;_0x57d77d[_0x247a('0x35')]=_[_0x247a('0x37')](db[_0x247a('0x116')]['rawAttributes']);_0x57d77d['query']=_['keys'](_0x16f3fd[_0x247a('0x36')]);_0x57d77d['filters']=_['intersection'](_0x57d77d[_0x247a('0x35')],_0x57d77d[_0x247a('0x36')]);_0x30b2d0[_0x247a('0x3a')]=_[_0x247a('0x39')](_0x57d77d[_0x247a('0x35')],qs['fields'](_0x16f3fd[_0x247a('0x36')][_0x247a('0x3b')]));_0x30b2d0[_0x247a('0x3a')]=_0x30b2d0[_0x247a('0x3a')]['length']?_0x30b2d0['attributes']:_0x57d77d['model'];_0x30b2d0['order']=qs[_0x247a('0x40')](_0x16f3fd[_0x247a('0x36')]['sort']);_0x30b2d0[_0x247a('0x41')]=qs[_0x247a('0x38')](_[_0x247a('0x5f')](_0x16f3fd[_0x247a('0x36')],_0x57d77d['filters']));if(_0x16f3fd['query']['filter']){_0x30b2d0['where']=_['merge'](_0x30b2d0[_0x247a('0x41')],{'$or':_[_0x247a('0x32')](_0x30b2d0[_0x247a('0x3a')],function(_0x30facd){var _0x42d2f0={};_0x42d2f0[_0x30facd]={'$like':'%'+_0x16f3fd['query']['filter']+'%'};return _0x42d2f0;})});}_0x30b2d0=_[_0x247a('0x43')]({},_0x30b2d0,_0x16f3fd[_0x247a('0x45')]);return _0x4d5bc1['getProactiveActions'](_0x30b2d0);}})['then'](function(_0x5306be){if(_0x5306be){_0x183c99=_0x5306be['length'];if(!_0x16f3fd[_0x247a('0x36')]['hasOwnProperty'](_0x247a('0x3e'))){_0x30b2d0[_0x247a('0x22')]=qs['limit'](_0x16f3fd['query']['limit']);_0x30b2d0[_0x247a('0x21')]=qs['offset'](_0x16f3fd[_0x247a('0x36')][_0x247a('0x21')]);}return _0x4d5bc1[_0x247a('0xfd')](_0x30b2d0);}})['then'](function(_0x188119){if(_0x188119){return _0x188119?{'count':_0x183c99,'rows':_0x188119}:null;}})['then'](respondWithResult(_0x5c6ae8,null))['catch'](handleError(_0x5c6ae8,null));};exports[_0x247a('0x117')]=function(_0x560d0c,_0x352d58){var _0x4b408f=_0x560d0c[_0x247a('0x36')][_0x247a('0x118')]===_0x247a('0x119')?_0x247a('0x11a'):'onlineForm';return db['ChatWebsite'][_0x247a('0x4b')]({'attributes':['id',_0x4b408f],'where':{'id':_0x560d0c['params']['id']}})[_0x247a('0x15')](handleEntityNotFound(_0x352d58,null))[_0x247a('0x15')](function(_0x29e04b){if(_0x29e04b){var _0x3e4583=_0x29e04b[_0x4b408f];var _0xcee79c=_0x3e4583&&_0x3e4583[_0x247a('0x11b')]?_0x3e4583[_0x247a('0x11b')]:[];_0x352d58[_0x247a('0x2f')]({'fromKey':_[_0x247a('0x70')](_0x3e4583[_0x247a('0x11c')])?undefined:_0x3e4583[_0x247a('0x11c')],'count':_0xcee79c[_0x247a('0x3c')],'rows':_0xcee79c});}})[_0x247a('0x1e')](handleError(_0x352d58,null));};exports[_0x247a('0x11d')]=function(_0x5c0a45,_0x300362){var _0x3b4589={'raw':![],'where':{}};var _0x401a1b={};var _0x1d03d8={'count':0x0,'rows':[]};return db[_0x247a('0x33')][_0x247a('0x59')]({'where':{'id':_0x5c0a45[_0x247a('0x49')]['id']}})[_0x247a('0x15')](handleEntityNotFound(_0x300362,null))[_0x247a('0x15')](function(_0x3e31b7){if(_0x3e31b7){_0x401a1b[_0x247a('0x35')]=_[_0x247a('0x37')](db[_0x247a('0x11e')][_0x247a('0x4a')]);_0x401a1b['query']=_[_0x247a('0x37')](_0x5c0a45[_0x247a('0x36')]);_0x401a1b[_0x247a('0x38')]=_[_0x247a('0x39')](_0x401a1b[_0x247a('0x35')],_0x401a1b[_0x247a('0x36')]);_0x3b4589[_0x247a('0x3a')]=_[_0x247a('0x39')](_0x401a1b[_0x247a('0x35')],qs[_0x247a('0x3b')](_0x5c0a45[_0x247a('0x36')]['fields']));_0x3b4589[_0x247a('0x3a')]=_0x3b4589[_0x247a('0x3a')][_0x247a('0x3c')]?_0x3b4589[_0x247a('0x3a')]:_0x401a1b[_0x247a('0x35')];if(!_0x5c0a45[_0x247a('0x36')][_0x247a('0x3d')]('nolimit')){_0x3b4589[_0x247a('0x22')]=qs['limit'](_0x5c0a45[_0x247a('0x36')][_0x247a('0x22')]);_0x3b4589[_0x247a('0x21')]=qs[_0x247a('0x21')](_0x5c0a45['query'][_0x247a('0x21')]);}_0x3b4589[_0x247a('0x3f')]=qs[_0x247a('0x40')](_0x5c0a45['query'][_0x247a('0x40')]);_0x3b4589[_0x247a('0x41')]=qs[_0x247a('0x38')](_[_0x247a('0x5f')](_0x5c0a45['query'],_0x401a1b[_0x247a('0x38')]));_0x3b4589[_0x247a('0x41')][_0x247a('0x56')]=_0x3e31b7['id'];if(_0x5c0a45[_0x247a('0x36')]['filter']){_0x3b4589[_0x247a('0x41')]=_[_0x247a('0x43')](_0x3b4589[_0x247a('0x41')],{'$or':_[_0x247a('0x32')](_0x3b4589['attributes'],function(_0xbe2be5){var _0x15cd5d={};_0x15cd5d[_0xbe2be5]={'$like':'%'+_0x5c0a45[_0x247a('0x36')][_0x247a('0x42')]+'%'};return _0x15cd5d;})});}_0x3b4589=_[_0x247a('0x43')]({},_0x3b4589,_0x5c0a45['options']);return db[_0x247a('0x11e')]['count']({'where':_0x3b4589[_0x247a('0x41')]})[_0x247a('0x15')](function(_0x12c1d4){_0x1d03d8[_0x247a('0x24')]=_0x12c1d4;if(_0x5c0a45[_0x247a('0x36')][_0x247a('0x46')]){_0x3b4589[_0x247a('0x47')]=[{'all':!![]}];}else{_0x3b4589['include']=[{'model':db[_0x247a('0x80')],'as':_0x247a('0xe9'),'required':![]},{'model':db[_0x247a('0xd0')],'as':_0x247a('0x11f'),'required':![]}];}return db[_0x247a('0x11e')][_0x247a('0x48')](_0x3b4589);})[_0x247a('0x15')](function(_0x4db79f){_0x1d03d8[_0x247a('0x5a')]=_0x4db79f;return _0x1d03d8;});}})[_0x247a('0x15')](respondWithFilteredResult(_0x300362,_0x3b4589))[_0x247a('0x1e')](handleError(_0x300362,null));};exports[_0x247a('0x120')]=function(_0x97fe8f,_0xd61d0){return db['ChatWebsite'][_0x247a('0x4b')]({'where':{'id':_0x97fe8f['params']['id']}})[_0x247a('0x15')](handleEntityNotFound(_0xd61d0,null))[_0x247a('0x15')](function(_0x300e){if(_0x300e){return _0x300e[_0x247a('0x120')](_0x97fe8f[_0x247a('0x4d')][_0x247a('0x5c')],_[_0x247a('0xe7')](_0x97fe8f[_0x247a('0x4d')],[_0x247a('0x5c'),'id'])||{})['spread'](function(_0x5207c8){for(var _0x48c70c=0x0;_0x48c70c<_0x97fe8f[_0x247a('0x4d')][_0x247a('0x5c')][_0x247a('0x3c')];_0x48c70c+=0x1){socket[_0x247a('0x121')]('userChatWebsite:save',{'UserId':Number(_0x97fe8f[_0x247a('0x4d')]['ids'][_0x48c70c]),'ChatWebsiteId':Number(_0x97fe8f[_0x247a('0x49')]['id'])});}return _0x5207c8;});}})[_0x247a('0x15')](respondWithResult(_0xd61d0,null))[_0x247a('0x1e')](handleError(_0xd61d0,null));};exports['removeAgents']=function(_0x34783e,_0x4940ea){return db[_0x247a('0x33')][_0x247a('0x4b')]({'where':{'id':_0x34783e['params']['id']}})[_0x247a('0x15')](handleEntityNotFound(_0x4940ea,null))[_0x247a('0x15')](function(_0x50a33b){if(_0x50a33b){return _0x50a33b[_0x247a('0x122')](_0x34783e[_0x247a('0x36')][_0x247a('0x5c')])['then'](function(){if(_[_0x247a('0x123')](_0x34783e[_0x247a('0x36')]['ids'])){for(var _0x1e8c38=0x0;_0x1e8c38<_0x34783e[_0x247a('0x36')][_0x247a('0x5c')][_0x247a('0x3c')];_0x1e8c38+=0x1){socket[_0x247a('0x121')](_0x247a('0x124'),{'UserId':Number(_0x34783e[_0x247a('0x36')][_0x247a('0x5c')][_0x1e8c38]),'ChatWebsiteId':Number(_0x34783e[_0x247a('0x49')]['id'])});}}else{socket[_0x247a('0x121')](_0x247a('0x124'),{'UserId':Number(_0x34783e['query'][_0x247a('0x5c')]),'ChatWebsiteId':Number(_0x34783e[_0x247a('0x49')]['id'])});}});}})[_0x247a('0x15')](respondWithStatusCode(_0x4940ea,null))[_0x247a('0x1e')](handleError(_0x4940ea,null));};exports[_0x247a('0x125')]=function(_0x36d7dd,_0x522ecb){var _0x3d983a={};var _0x372bb8={};var _0x2bdc2c;var _0x491920;return db[_0x247a('0x33')]['findOne']({'where':{'id':_0x36d7dd['params']['id']}})[_0x247a('0x15')](handleEntityNotFound(_0x522ecb,null))[_0x247a('0x15')](function(_0x4718b5){if(_0x4718b5){_0x2bdc2c=_0x4718b5;_0x372bb8[_0x247a('0x35')]=_[_0x247a('0x37')](db[_0x247a('0xb8')][_0x247a('0x4a')]);_0x372bb8['query']=_[_0x247a('0x37')](_0x36d7dd[_0x247a('0x36')]);_0x372bb8[_0x247a('0x38')]=_[_0x247a('0x39')](_0x372bb8['model'],_0x372bb8['query']);_0x3d983a[_0x247a('0x3a')]=_[_0x247a('0x39')](_0x372bb8[_0x247a('0x35')],qs['fields'](_0x36d7dd['query'][_0x247a('0x3b')]));_0x3d983a[_0x247a('0x3a')]=_0x3d983a[_0x247a('0x3a')]['length']?_0x3d983a[_0x247a('0x3a')]:_0x372bb8[_0x247a('0x35')];_0x3d983a[_0x247a('0x3f')]=qs[_0x247a('0x40')](_0x36d7dd['query']['sort']);_0x3d983a[_0x247a('0x41')]=qs['filters'](_['pick'](_0x36d7dd[_0x247a('0x36')],_0x372bb8[_0x247a('0x38')]));if(_0x36d7dd[_0x247a('0x36')]['filter']){_0x3d983a[_0x247a('0x41')]=_['merge'](_0x3d983a[_0x247a('0x41')],{'$or':_['map'](_0x3d983a[_0x247a('0x3a')],function(_0x5e91de){var _0x4c9b5f={};_0x4c9b5f[_0x5e91de]={'$like':'%'+_0x36d7dd[_0x247a('0x36')]['filter']+'%'};return _0x4c9b5f;})});}_0x3d983a=_['merge']({},_0x3d983a,_0x36d7dd[_0x247a('0x45')]);return _0x2bdc2c[_0x247a('0x125')](_0x3d983a);}})['then'](function(_0x4e60f8){if(_0x4e60f8){_0x491920=_0x4e60f8['length'];if(!_0x36d7dd[_0x247a('0x36')][_0x247a('0x3d')](_0x247a('0x3e'))){_0x3d983a[_0x247a('0x22')]=qs[_0x247a('0x22')](_0x36d7dd['query']['limit']);_0x3d983a['offset']=qs[_0x247a('0x21')](_0x36d7dd['query']['offset']);}return _0x2bdc2c['getAgents'](_0x3d983a);}})['then'](function(_0x2a929e){if(_0x2a929e){return _0x2a929e?{'count':_0x491920,'rows':_0x2a929e}:null;}})[_0x247a('0x15')](respondWithResult(_0x522ecb,null))[_0x247a('0x1e')](handleError(_0x522ecb,null));};
\ No newline at end of file
+var _0xfeac=['customerAvatar','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','download','user-agent-parser','setUA','headers','getResult','chat','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','difference','ListId','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','List','Contacts','DESC','ChatApplication','account','Applications','list','applications','orderBy','priority','asc','defaults','contact','customerIp','cf-connecting-ip','x-forwarded-for','first','split','firstName','x-real-port','referer','browser','format','%s\x20%s','version','unknown','device','vendor','%s\x20%s\x20%s','stringify','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','lastName','messageId','created','push','*,*,*,*','ChatMessage','AttachmentId','UserId','User','unshift','agent','Start','startRouting','notify','offline','files','createdAt','updatedAt','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','send','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','offlineMessageBody','ChatOfflineMessage','fromString','mimetype','server','attachments','offline-chat','basename','openNewInteraction','sequelize','transaction','Attachment','MailServerOut','Smtp','CloudProvider','forwardOffline','forwardOfflineAddress','sendMail','\x22%s\x22\x20<%s>','offlineMessageSubject','MailAccountId','originalname','subjectOffline','toPairsIn','mapValues','email','Chat','NotifyMailAccount','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','Contact','Owner','fullname','internal','Tags','color','tag','rows','Command','getSnippet','timezone','iftime\x20%s,%s','iftime\x20%s','interval','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','getProactiveActions','License','increment','chatLicenseExceeded','Intervals','all','some','origin','3.1.0','remote','x-real-ip','connection','remoteAddress','virtual','replace','verticalAlignment','labelText','textColor','textButtonColor','color_button','backgroundColor','hideWhenOffline','READ_COMMITTED','bulkCreate','findAndCountAll','finally','getApplications','addProactiveActions','chatProactiveAction','getFields','online','false','offlineForm','onlineForm','items','fromKey','getOfflineMessages','Attachments','addAgents','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','emit','getAgents','bluebird','mustache','util','path','ejs','fs-extra','lodash','querystring','ioredis','../../components/parsers/qs','api','../../config/environment','url','../../mysqldb','redis','localhost','socket.io-emitter','./chatWebsite.socket','html-to-text','jayson/promise','client','http','request','then','info','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','ChatWebsite,\x20%s,\x20%s','result','sendStatus','status','end','offset','undefined','count','limit','set','Content-Range','json','update','destroy','get','UserProfileResource','stack','name','index','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','order','sort','where','filter','VIRTUAL','merge','options','includeAll','include','findAll','show','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ChatWebsiteId','getDispositions','findOne','Disposition','nolimit','pick','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','hasOwnProperty','removeAnswers','addLogo','sitepic','file','filename','addCustomerAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','../../config/license/util','getLicense','custom','existsSync','server/files/images/logos/','getAvatar','isNil','agentAvatar','server/files/images/avatars/','server/files/images/avatars/customer_avatar.png'];(function(_0x208327,_0x26b904){var _0x3127bd=function(_0x424aa6){while(--_0x424aa6){_0x208327['push'](_0x208327['shift']());}};_0x3127bd(++_0x26b904);}(_0xfeac,0xba));var _0xcfea=function(_0x55b433,_0x1de67d){_0x55b433=_0x55b433-0x0;var _0x20e28e=_0xfeac[_0x55b433];return _0x20e28e;};'use strict';var BPromise=require(_0xcfea('0x0'));var Mustache=require(_0xcfea('0x1'));var util=require(_0xcfea('0x2'));var path=require(_0xcfea('0x3'));var ejs=require(_0xcfea('0x4'));var fs=require('fs');var fs_extra=require(_0xcfea('0x5'));var _=require(_0xcfea('0x6'));var querystring=require(_0xcfea('0x7'));var Redis=require(_0xcfea('0x8'));var qs=require(_0xcfea('0x9'));var logger=require('../../config/logger')(_0xcfea('0xa'));var config=require(_0xcfea('0xb'));var url=require(_0xcfea('0xc'));var db=require(_0xcfea('0xd'))['db'];config[_0xcfea('0xe')]=_['defaults'](config[_0xcfea('0xe')],{'host':_0xcfea('0xf'),'port':0x18eb});var socket=require(_0xcfea('0x10'))(new Redis(config[_0xcfea('0xe')]));require(_0xcfea('0x11'))['register'](socket);var htmlToText=require(_0xcfea('0x12'));var jayson=require(_0xcfea('0x13'));var client=jayson[_0xcfea('0x14')][_0xcfea('0x15')]({'port':0x232c});var client9002=jayson[_0xcfea('0x14')][_0xcfea('0x15')]({'port':0x232a});var client9003=jayson[_0xcfea('0x14')][_0xcfea('0x15')]({'port':0x232b});var client9001=jayson[_0xcfea('0x14')]['http']({'port':0x2329});function respondWithRpcPromise(_0x26fd3d,_0x4c7672,_0x14c681,_0x4e3757){return new BPromise(function(_0x2926d6,_0x40e87f){var _0x408e3a=_0x4e3757||client;return _0x408e3a[_0xcfea('0x16')](_0x26fd3d,_0x14c681)[_0xcfea('0x17')](function(_0xa73df5){logger[_0xcfea('0x18')]('ChatWebsite,\x20%s,\x20%s',_0x4c7672,'request\x20sent');logger[_0xcfea('0x19')](_0xcfea('0x1a'),_0x4c7672,_0xcfea('0x1b'),JSON['stringify'](_0xa73df5));if(_0xa73df5[_0xcfea('0x1c')]){if(_0xa73df5[_0xcfea('0x1c')][_0xcfea('0x1d')]===0x1f4){logger[_0xcfea('0x1c')]('ChatWebsite,\x20%s,\x20%s',_0x4c7672,_0xa73df5[_0xcfea('0x1c')][_0xcfea('0x1e')]);return _0x40e87f(_0xa73df5[_0xcfea('0x1c')][_0xcfea('0x1e')]);}logger['error'](_0xcfea('0x1f'),_0x4c7672,_0xa73df5['error']['message']);return _0x2926d6(_0xa73df5['error'][_0xcfea('0x1e')]);}else{logger[_0xcfea('0x18')]('ChatWebsite,\x20%s,\x20%s',_0x4c7672,_0xcfea('0x1b'));_0x2926d6(_0xa73df5[_0xcfea('0x20')][_0xcfea('0x1e')]);}})['catch'](function(_0x1ba1ef){logger[_0xcfea('0x1c')](_0xcfea('0x1f'),_0x4c7672,_0x1ba1ef);_0x40e87f(_0x1ba1ef);});});}function respondWithStatusCode(_0x4cee74,_0x9b738e){_0x9b738e=_0x9b738e||0xcc;return function(_0x3f6637){if(_0x3f6637){return _0x4cee74[_0xcfea('0x21')](_0x9b738e);}return _0x4cee74[_0xcfea('0x22')](_0x9b738e)[_0xcfea('0x23')]();};}function respondWithResult(_0x8038cd,_0x3dcde3){_0x3dcde3=_0x3dcde3||0xc8;return function(_0x3c7434){if(_0x3c7434){return _0x8038cd['status'](_0x3dcde3)['json'](_0x3c7434);}};}function respondWithFilteredResult(_0x5dcd63,_0x67dfa7){return function(_0x16babe){if(_0x16babe){var _0x1e689f=typeof _0x67dfa7[_0xcfea('0x24')]===_0xcfea('0x25')&&typeof _0x67dfa7['limit']===_0xcfea('0x25');var _0x1988b0=_0x16babe['count'];var _0x1c5a69=_0x1e689f?0x0:_0x67dfa7[_0xcfea('0x24')];var _0x3488d6=_0x1e689f?_0x16babe[_0xcfea('0x26')]:_0x67dfa7['offset']+_0x67dfa7[_0xcfea('0x27')];var _0x3279b4;if(_0x3488d6>=_0x1988b0){_0x3488d6=_0x1988b0;_0x3279b4=0xc8;}else{_0x3279b4=0xce;}_0x5dcd63[_0xcfea('0x22')](_0x3279b4);return _0x5dcd63[_0xcfea('0x28')](_0xcfea('0x29'),_0x1c5a69+'-'+_0x3488d6+'/'+_0x1988b0)[_0xcfea('0x2a')](_0x16babe);}return null;};}function saveUpdates(_0x28c14e){return function(_0x3bf88a){if(_0x3bf88a){return _0x3bf88a[_0xcfea('0x2b')](_0x28c14e)[_0xcfea('0x17')](function(_0x539a32){return _0x539a32;});}return null;};}function removeEntity(_0x1b8c6d){return function(_0xba88c0){if(_0xba88c0){return _0xba88c0[_0xcfea('0x2c')]()[_0xcfea('0x17')](function(){var _0x567429=_0xba88c0[_0xcfea('0x2d')]({'plain':!![]});var _0x475e05='ChatWebsites';return db[_0xcfea('0x2e')][_0xcfea('0x2c')]({'where':{'type':_0x475e05,'resourceId':_0x567429['id']}})['then'](function(){return _0xba88c0;});})[_0xcfea('0x17')](function(){_0x1b8c6d[_0xcfea('0x22')](0xcc)['end']();});}};}function handleEntityNotFound(_0x59030c){return function(_0x526d2e){if(!_0x526d2e){_0x59030c[_0xcfea('0x21')](0x194);}return _0x526d2e;};}function handleError(_0x1846a6,_0x8600e3){_0x8600e3=_0x8600e3||0x1f4;return function(_0x530b9d){logger[_0xcfea('0x1c')](_0x530b9d[_0xcfea('0x2f')]);if(_0x530b9d[_0xcfea('0x30')]){delete _0x530b9d[_0xcfea('0x30')];}_0x1846a6[_0xcfea('0x22')](_0x8600e3)['send'](_0x530b9d);};}exports[_0xcfea('0x31')]=function(_0x3a830f,_0x27e748){var _0x582de8={'include':[{'model':db[_0xcfea('0x32')],'as':_0xcfea('0x33')}]},_0x5bd4aa={},_0x55fb3c={'count':0x0,'rows':[]};var _0x546893=_[_0xcfea('0x34')](db[_0xcfea('0x35')][_0xcfea('0x36')],function(_0x20d0f8){return{'name':_0x20d0f8[_0xcfea('0x37')],'type':_0x20d0f8[_0xcfea('0x38')][_0xcfea('0x39')]};});_0x5bd4aa[_0xcfea('0x3a')]=_[_0xcfea('0x34')](_0x546893,_0xcfea('0x30'));_0x5bd4aa[_0xcfea('0x3b')]=_[_0xcfea('0x3c')](_0x3a830f['query']);_0x5bd4aa[_0xcfea('0x3d')]=_[_0xcfea('0x3e')](_0x5bd4aa[_0xcfea('0x3a')],_0x5bd4aa['query']);_0x582de8[_0xcfea('0x3f')]=_[_0xcfea('0x3e')](_0x5bd4aa[_0xcfea('0x3a')],qs[_0xcfea('0x40')](_0x3a830f['query'][_0xcfea('0x40')]));_0x582de8[_0xcfea('0x3f')]=_0x582de8['attributes'][_0xcfea('0x41')]?_0x582de8['attributes']:_0x5bd4aa[_0xcfea('0x3a')];if(!_0x3a830f[_0xcfea('0x3b')]['hasOwnProperty']('nolimit')){_0x582de8[_0xcfea('0x27')]=qs[_0xcfea('0x27')](_0x3a830f['query']['limit']);_0x582de8['offset']=qs[_0xcfea('0x24')](_0x3a830f['query'][_0xcfea('0x24')]);}_0x582de8[_0xcfea('0x42')]=qs[_0xcfea('0x43')](_0x3a830f[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x582de8[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_['pick'](_0x3a830f[_0xcfea('0x3b')],_0x5bd4aa['filters']),_0x546893);if(_0x3a830f[_0xcfea('0x3b')][_0xcfea('0x45')]){_0x582de8[_0xcfea('0x44')]=_['merge'](_0x582de8['where'],{'$or':_[_0xcfea('0x34')](_0x546893,function(_0x1d98cd){if(_0x1d98cd[_0xcfea('0x38')]!==_0xcfea('0x46')){var _0x2a6666={};_0x2a6666[_0x1d98cd[_0xcfea('0x30')]]={'$like':'%'+_0x3a830f['query'][_0xcfea('0x45')]+'%'};return _0x2a6666;}})});}_0x582de8=_[_0xcfea('0x47')]({},_0x582de8,_0x3a830f[_0xcfea('0x48')]);var _0x25ee9b={'where':_0x582de8[_0xcfea('0x44')]};return db[_0xcfea('0x35')][_0xcfea('0x26')](_0x25ee9b)[_0xcfea('0x17')](function(_0x4f2b6d){_0x55fb3c[_0xcfea('0x26')]=_0x4f2b6d;if(_0x3a830f[_0xcfea('0x3b')][_0xcfea('0x49')]){_0x582de8[_0xcfea('0x4a')]=[{'all':!![]}];}return db[_0xcfea('0x35')][_0xcfea('0x4b')](_0x582de8);})[_0xcfea('0x17')](function(_0x47579b){_0x55fb3c['rows']=_0x47579b;return _0x55fb3c;})[_0xcfea('0x17')](respondWithFilteredResult(_0x27e748,_0x582de8))['catch'](handleError(_0x27e748,null));};exports[_0xcfea('0x4c')]=function(_0x3f91a1,_0x3ffb48){var _0x785a3d={'raw':![],'where':{'id':_0x3f91a1[_0xcfea('0x4d')]['id']},'include':[{'model':db[_0xcfea('0x32')],'as':'mandatoryDispositionPause'}]},_0x4b29e9={};_0x4b29e9[_0xcfea('0x3a')]=_['keys'](db[_0xcfea('0x35')]['rawAttributes']);_0x4b29e9[_0xcfea('0x3b')]=_['keys'](_0x3f91a1[_0xcfea('0x3b')]);_0x4b29e9[_0xcfea('0x3d')]=_['intersection'](_0x4b29e9[_0xcfea('0x3a')],_0x4b29e9[_0xcfea('0x3b')]);_0x785a3d[_0xcfea('0x3f')]=_['intersection'](_0x4b29e9[_0xcfea('0x3a')],qs[_0xcfea('0x40')](_0x3f91a1[_0xcfea('0x3b')]['fields']));_0x785a3d['attributes']=_0x785a3d['attributes']['length']?_0x785a3d[_0xcfea('0x3f')]:_0x4b29e9[_0xcfea('0x3a')];if(_0x3f91a1[_0xcfea('0x3b')][_0xcfea('0x49')]){_0x785a3d[_0xcfea('0x4a')]=[{'all':!![]}];}_0x785a3d=_[_0xcfea('0x47')]({},_0x785a3d,_0x3f91a1[_0xcfea('0x48')]);return db['ChatWebsite'][_0xcfea('0x4e')](_0x785a3d)[_0xcfea('0x17')](handleEntityNotFound(_0x3ffb48,null))[_0xcfea('0x17')](respondWithResult(_0x3ffb48,null))['catch'](handleError(_0x3ffb48,null));};exports[_0xcfea('0x4f')]=function(_0x3e4fea,_0x14ab74){return db[_0xcfea('0x35')]['create'](_0x3e4fea[_0xcfea('0x50')],{})[_0xcfea('0x17')](function(_0x4d9fd0){var _0x3accbb=_0x3e4fea[_0xcfea('0x51')][_0xcfea('0x2d')]({'plain':!![]});if(!_0x3accbb)throw new Error(_0xcfea('0x52'));if(_0x3accbb[_0xcfea('0x53')]==='user'){var _0x4f7752=_0x4d9fd0[_0xcfea('0x2d')]({'plain':!![]});var _0x5ad7d7='ChatWebsites';return db[_0xcfea('0x54')][_0xcfea('0x4e')]({'where':{'name':_0x5ad7d7,'userProfileId':_0x3accbb[_0xcfea('0x55')]},'raw':!![]})['then'](function(_0x35e6f9){if(_0x35e6f9&&_0x35e6f9['autoAssociation']===0x0){return db[_0xcfea('0x2e')][_0xcfea('0x4f')]({'name':_0x4f7752[_0xcfea('0x30')],'resourceId':_0x4f7752['id'],'type':_0x35e6f9[_0xcfea('0x30')],'sectionId':_0x35e6f9['id']},{})[_0xcfea('0x17')](function(){return _0x4d9fd0;});}else{return _0x4d9fd0;}})[_0xcfea('0x56')](function(_0x21c18f){logger[_0xcfea('0x1c')](_0xcfea('0x57'),_0x21c18f);throw _0x21c18f;});}return _0x4d9fd0;})[_0xcfea('0x17')](respondWithResult(_0x14ab74,0xc9))[_0xcfea('0x56')](handleError(_0x14ab74,null));};exports['update']=function(_0x1f6677,_0x574188){if(_0x1f6677[_0xcfea('0x50')]['id']){delete _0x1f6677['body']['id'];}return db['ChatWebsite'][_0xcfea('0x4e')]({'where':{'id':_0x1f6677[_0xcfea('0x4d')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]})['then'](handleEntityNotFound(_0x574188,null))[_0xcfea('0x17')](saveUpdates(_0x1f6677[_0xcfea('0x50')],null))[_0xcfea('0x17')](respondWithResult(_0x574188,null))['catch'](handleError(_0x574188,null));};exports[_0xcfea('0x2c')]=function(_0x70ae5f,_0x21f7ad){return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x70ae5f[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x21f7ad,null))[_0xcfea('0x17')](removeEntity(_0x21f7ad,null))['catch'](handleError(_0x21f7ad,null));};exports[_0xcfea('0x58')]=function(_0x1a44cb,_0x5cb1b8){return db['ChatWebsite'][_0xcfea('0x58')]()[_0xcfea('0x17')](respondWithResult(_0x5cb1b8,null))[_0xcfea('0x56')](handleError(_0x5cb1b8,null));};exports[_0xcfea('0x59')]=function(_0x5c1066,_0x42010c){if(_0x5c1066[_0xcfea('0x50')]['id']){delete _0x5c1066[_0xcfea('0x50')]['id'];}return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x5c1066['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x42010c,null))[_0xcfea('0x17')](function(_0x479d03){if(_0x479d03){_0x5c1066['body'][_0xcfea('0x5a')]=_0x479d03['id'];return db['Disposition'][_0xcfea('0x4f')](_0x5c1066['body']);}})[_0xcfea('0x17')](respondWithResult(_0x42010c,null))['catch'](handleError(_0x42010c,null));};exports[_0xcfea('0x5b')]=function(_0x3b51f6,_0xd9df9d){var _0x3eab88={'raw':![],'where':{}};var _0x5d5990={};var _0x4a2a88={'count':0x0,'rows':[]};return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x3b51f6[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0xd9df9d,null))['then'](function(_0x29de50){if(_0x29de50){_0x5d5990['model']=_[_0xcfea('0x3c')](db[_0xcfea('0x5d')][_0xcfea('0x36')]);_0x5d5990[_0xcfea('0x3b')]=_['keys'](_0x3b51f6[_0xcfea('0x3b')]);_0x5d5990[_0xcfea('0x3d')]=_[_0xcfea('0x3e')](_0x5d5990['model'],_0x5d5990[_0xcfea('0x3b')]);_0x3eab88[_0xcfea('0x3f')]=_['intersection'](_0x5d5990[_0xcfea('0x3a')],qs[_0xcfea('0x40')](_0x3b51f6[_0xcfea('0x3b')]['fields']));_0x3eab88[_0xcfea('0x3f')]=_0x3eab88[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x3eab88[_0xcfea('0x3f')]:_0x5d5990[_0xcfea('0x3a')];if(!_0x3b51f6['query']['hasOwnProperty'](_0xcfea('0x5e'))){_0x3eab88['limit']=qs[_0xcfea('0x27')](_0x3b51f6[_0xcfea('0x3b')][_0xcfea('0x27')]);_0x3eab88[_0xcfea('0x24')]=qs[_0xcfea('0x24')](_0x3b51f6[_0xcfea('0x3b')]['offset']);}_0x3eab88[_0xcfea('0x42')]=qs[_0xcfea('0x43')](_0x3b51f6[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x3eab88[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_[_0xcfea('0x5f')](_0x3b51f6[_0xcfea('0x3b')],_0x5d5990['filters']));_0x3eab88[_0xcfea('0x44')][_0xcfea('0x5a')]=_0x29de50['id'];if(_0x3b51f6[_0xcfea('0x3b')][_0xcfea('0x45')]){_0x3eab88[_0xcfea('0x44')]=_[_0xcfea('0x47')](_0x3eab88[_0xcfea('0x44')],{'$or':_[_0xcfea('0x34')](_0x3eab88[_0xcfea('0x3f')],function(_0x457208){var _0x5d273f={};_0x5d273f[_0x457208]={'$like':'%'+_0x3b51f6[_0xcfea('0x3b')][_0xcfea('0x45')]+'%'};return _0x5d273f;})});}_0x3eab88=_['merge']({},_0x3eab88,_0x3b51f6[_0xcfea('0x48')]);return db[_0xcfea('0x5d')][_0xcfea('0x26')]({'where':_0x3eab88[_0xcfea('0x44')]})[_0xcfea('0x17')](function(_0xcbca8d){_0x4a2a88[_0xcfea('0x26')]=_0xcbca8d;if(_0x3b51f6[_0xcfea('0x3b')][_0xcfea('0x49')]){_0x3eab88[_0xcfea('0x4a')]=[{'all':!![]}];}return db['Disposition'][_0xcfea('0x4b')](_0x3eab88);})['then'](function(_0x4d08d5){_0x4a2a88['rows']=_0x4d08d5;return _0x4a2a88;});}})['then'](respondWithFilteredResult(_0xd9df9d,_0x3eab88))[_0xcfea('0x56')](handleError(_0xd9df9d,null));};exports[_0xcfea('0x60')]=function(_0xe4f178,_0xa244ae){return db['ChatWebsite'][_0xcfea('0x4e')]({'where':{'id':_0xe4f178[_0xcfea('0x4d')]['id']}})['then'](handleEntityNotFound(_0xa244ae,null))[_0xcfea('0x17')](function(_0x59998f){if(_0x59998f){return _0x59998f['removeDispositions'](_0xe4f178[_0xcfea('0x3b')][_0xcfea('0x61')]);}})['then'](respondWithStatusCode(_0xa244ae,null))[_0xcfea('0x56')](handleError(_0xa244ae,null));};exports[_0xcfea('0x62')]=function(_0x4071d2,_0x4b7b32){if(_0x4071d2[_0xcfea('0x50')]['id']){delete _0x4071d2[_0xcfea('0x50')]['id'];}return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x4071d2[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x4b7b32,null))[_0xcfea('0x17')](function(_0x141535){if(_0x141535){_0x4071d2['body']['ChatWebsiteId']=_0x141535['id'];return db[_0xcfea('0x63')][_0xcfea('0x4f')](_0x4071d2[_0xcfea('0x50')]);}})['then'](respondWithResult(_0x4b7b32,null))[_0xcfea('0x56')](handleError(_0x4b7b32,null));};exports[_0xcfea('0x64')]=function(_0x5f0e1c,_0x40e39d){var _0x299ae5={'raw':![],'where':{}};var _0x1f6438={};var _0x34ece2={'count':0x0,'rows':[]};return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x5f0e1c['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x40e39d,null))[_0xcfea('0x17')](function(_0x75a111){if(_0x75a111){_0x1f6438[_0xcfea('0x3a')]=_[_0xcfea('0x3c')](db[_0xcfea('0x63')][_0xcfea('0x36')]);_0x1f6438['query']=_[_0xcfea('0x3c')](_0x5f0e1c[_0xcfea('0x3b')]);_0x1f6438[_0xcfea('0x3d')]=_[_0xcfea('0x3e')](_0x1f6438[_0xcfea('0x3a')],_0x1f6438[_0xcfea('0x3b')]);_0x299ae5[_0xcfea('0x3f')]=_[_0xcfea('0x3e')](_0x1f6438[_0xcfea('0x3a')],qs[_0xcfea('0x40')](_0x5f0e1c['query'][_0xcfea('0x40')]));_0x299ae5[_0xcfea('0x3f')]=_0x299ae5[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x299ae5['attributes']:_0x1f6438[_0xcfea('0x3a')];if(!_0x5f0e1c[_0xcfea('0x3b')][_0xcfea('0x65')](_0xcfea('0x5e'))){_0x299ae5[_0xcfea('0x27')]=qs[_0xcfea('0x27')](_0x5f0e1c['query']['limit']);_0x299ae5[_0xcfea('0x24')]=qs[_0xcfea('0x24')](_0x5f0e1c[_0xcfea('0x3b')][_0xcfea('0x24')]);}_0x299ae5[_0xcfea('0x42')]=qs[_0xcfea('0x43')](_0x5f0e1c[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x299ae5[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_[_0xcfea('0x5f')](_0x5f0e1c[_0xcfea('0x3b')],_0x1f6438['filters']));_0x299ae5['where'][_0xcfea('0x5a')]=_0x75a111['id'];if(_0x5f0e1c[_0xcfea('0x3b')]['filter']){_0x299ae5[_0xcfea('0x44')]=_[_0xcfea('0x47')](_0x299ae5['where'],{'$or':_[_0xcfea('0x34')](_0x299ae5[_0xcfea('0x3f')],function(_0x544303){var _0x593293={};_0x593293[_0x544303]={'$like':'%'+_0x5f0e1c[_0xcfea('0x3b')][_0xcfea('0x45')]+'%'};return _0x593293;})});}_0x299ae5=_[_0xcfea('0x47')]({},_0x299ae5,_0x5f0e1c[_0xcfea('0x48')]);return db['CannedAnswer']['count']({'where':_0x299ae5[_0xcfea('0x44')]})['then'](function(_0x3b8fe3){_0x34ece2['count']=_0x3b8fe3;if(_0x5f0e1c[_0xcfea('0x3b')][_0xcfea('0x49')]){_0x299ae5[_0xcfea('0x4a')]=[{'all':!![]}];}return db['CannedAnswer'][_0xcfea('0x4b')](_0x299ae5);})[_0xcfea('0x17')](function(_0xa277bb){_0x34ece2['rows']=_0xa277bb;return _0x34ece2;});}})[_0xcfea('0x17')](respondWithFilteredResult(_0x40e39d,_0x299ae5))['catch'](handleError(_0x40e39d,null));};exports[_0xcfea('0x66')]=function(_0x319a81,_0x2a3a07){return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x319a81[_0xcfea('0x4d')]['id']}})['then'](handleEntityNotFound(_0x2a3a07,null))[_0xcfea('0x17')](function(_0x439ab5){if(_0x439ab5){return _0x439ab5[_0xcfea('0x66')](_0x319a81[_0xcfea('0x3b')][_0xcfea('0x61')]);}})[_0xcfea('0x17')](respondWithStatusCode(_0x2a3a07,null))['catch'](handleError(_0x2a3a07,null));};exports[_0xcfea('0x67')]=function(_0x3dbe2f,_0x1286f5){_0x3dbe2f[_0xcfea('0x50')][_0xcfea('0x68')]=_0x3dbe2f[_0xcfea('0x69')][_0xcfea('0x6a')];return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x3dbe2f['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x1286f5,null))[_0xcfea('0x17')](saveUpdates(_0x3dbe2f[_0xcfea('0x50')],null))[_0xcfea('0x17')](respondWithResult(_0x1286f5,null))[_0xcfea('0x56')](handleError(_0x1286f5,null));};exports['addAvatar']=function(_0x7dc116,_0x348e65){_0x7dc116['body']['agentAvatar']=_0x7dc116[_0xcfea('0x69')][_0xcfea('0x6a')];return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x7dc116['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x348e65,null))[_0xcfea('0x17')](saveUpdates(_0x7dc116[_0xcfea('0x50')],null))[_0xcfea('0x17')](respondWithResult(_0x348e65,null))[_0xcfea('0x56')](handleError(_0x348e65,null));};exports[_0xcfea('0x6b')]=function(_0x5704ee,_0x3709f7){_0x5704ee[_0xcfea('0x50')]['customerAvatar']=_0x5704ee[_0xcfea('0x69')]['filename'];return db[_0xcfea('0x35')]['find']({'where':{'id':_0x5704ee[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x3709f7,null))[_0xcfea('0x17')](saveUpdates(_0x5704ee['body'],null))[_0xcfea('0x17')](respondWithResult(_0x3709f7,null))[_0xcfea('0x56')](handleError(_0x3709f7,null));};exports[_0xcfea('0x6c')]=function(_0x59613a,_0x5b5836){_0x59613a[_0xcfea('0x50')][_0xcfea('0x6d')]=_0x59613a['file'][_0xcfea('0x6a')];return db['ChatWebsite'][_0xcfea('0x4e')]({'where':{'id':_0x59613a[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x5b5836,null))[_0xcfea('0x17')](saveUpdates(_0x59613a[_0xcfea('0x50')],null))[_0xcfea('0x17')](respondWithResult(_0x5b5836,null))[_0xcfea('0x56')](handleError(_0x5b5836,null));};exports[_0xcfea('0x6e')]=function(_0x6fd62f,_0xe2356d){var _0x452825=path[_0xcfea('0x6f')](config[_0xcfea('0x70')],_0xcfea('0x71'));var _0x2935be={'where':{'id':_0x6fd62f[_0xcfea('0x4d')]['id']},'attributes':['id',_0xcfea('0x68')],'raw':!![]};var _0x461568=![];return require(_0xcfea('0x72'))[_0xcfea('0x73')]()['then'](function(_0x4101a5){if(_0x4101a5){_0x461568=_0x4101a5[_0xcfea('0x74')];}})[_0xcfea('0x17')](function(){return db[_0xcfea('0x35')][_0xcfea('0x4e')](_0x2935be);})['then'](handleEntityNotFound(_0xe2356d,null))[_0xcfea('0x17')](function(_0x5ecfe5){if(_0x5ecfe5){if(!_['isNil'](_0x5ecfe5['sitepic'])){if(fs[_0xcfea('0x75')](path[_0xcfea('0x6f')](config[_0xcfea('0x70')],_0xcfea('0x76'),_0x5ecfe5[_0xcfea('0x68')]))&&_0x461568){_0x452825=path['join'](config[_0xcfea('0x70')],_0xcfea('0x76'),_0x5ecfe5[_0xcfea('0x68')]);}}return _0xe2356d['download'](_0x452825);}})['catch'](handleError(_0xe2356d,null));};exports[_0xcfea('0x77')]=function(_0xa23629,_0x578aa2){var _0x4ae185=path['join'](config['root'],'server/files/images/avatars/default_avatar.png');var _0x146ed0={'where':{'id':_0xa23629[_0xcfea('0x4d')]['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db[_0xcfea('0x35')][_0xcfea('0x4e')](_0x146ed0)['then'](handleEntityNotFound(_0x578aa2,null))[_0xcfea('0x17')](function(_0x501ec3){if(_0x501ec3){if(!_[_0xcfea('0x78')](_0x501ec3[_0xcfea('0x79')])){if(fs[_0xcfea('0x75')](path[_0xcfea('0x6f')](config['root'],'server/files/images/avatars/',_0x501ec3['agentAvatar']))){_0x4ae185=path[_0xcfea('0x6f')](config[_0xcfea('0x70')],_0xcfea('0x7a'),_0x501ec3['agentAvatar']);}}return _0x578aa2['download'](_0x4ae185);}})[_0xcfea('0x56')](handleError(_0x578aa2,null));};exports['getCustomerAvatar']=function(_0x432491,_0x4ac594){var _0x15ebbc=path['join'](config[_0xcfea('0x70')],_0xcfea('0x7b'));var _0x39f48a={'where':{'id':_0x432491['params']['id']},'attributes':['id',_0xcfea('0x7c'),_0xcfea('0x7d')],'raw':!![]};return db[_0xcfea('0x35')]['find'](_0x39f48a)[_0xcfea('0x17')](handleEntityNotFound(_0x4ac594,null))[_0xcfea('0x17')](function(_0x5d0934){if(_0x5d0934){if(!_[_0xcfea('0x78')](_0x5d0934[_0xcfea('0x7c')])){if(fs[_0xcfea('0x75')](path[_0xcfea('0x6f')](config['root'],_0xcfea('0x7a'),_0x5d0934[_0xcfea('0x7c')]))&&_0x5d0934[_0xcfea('0x7d')]){_0x15ebbc=path[_0xcfea('0x6f')](config['root'],'server/files/images/avatars/',_0x5d0934[_0xcfea('0x7c')]);}}return _0x4ac594['download'](_0x15ebbc);}})[_0xcfea('0x56')](handleError(_0x4ac594,null));};exports[_0xcfea('0x7e')]=function(_0x47c5b9,_0x15c10e){var _0x540ced=path[_0xcfea('0x6f')](config['root'],_0xcfea('0x7f'));var _0x224fe6={'where':{'id':_0x47c5b9[_0xcfea('0x4d')]['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db[_0xcfea('0x35')]['find'](_0x224fe6)[_0xcfea('0x17')](handleEntityNotFound(_0x15c10e,null))['then'](function(_0x104bb7){if(_0x104bb7){if(!_[_0xcfea('0x78')](_0x104bb7['systemAvatar'])){if(fs['existsSync'](path[_0xcfea('0x6f')](config[_0xcfea('0x70')],'server/files/images/avatars/',_0x104bb7[_0xcfea('0x6d')]))){_0x540ced=path[_0xcfea('0x6f')](config[_0xcfea('0x70')],'server/files/images/avatars/',_0x104bb7[_0xcfea('0x6d')]);}}return _0x15c10e[_0xcfea('0x80')](_0x540ced);}})[_0xcfea('0x56')](handleError(_0x15c10e,null));};exports['notify']=function(_0x517dfd,_0x3fcdbd){var _0x5a69df=require(_0xcfea('0x81'));var _0x518401=new _0x5a69df();var _0x59c771=_0x518401[_0xcfea('0x82')](_0x517dfd[_0xcfea('0x83')]['user-agent'])[_0xcfea('0x84')]();var _0x5b8ef0={'body':_0x517dfd[_0xcfea('0x50')],'channel':_0xcfea('0x85')};var _0x3f30dd=[];var _0x3872e6=[];var _0x370ff3={};var _0x5f2500=![];return db[_0xcfea('0x86')][_0xcfea('0x58')]()['then'](function(_0x2c3f13){if(!_0x2c3f13){throw new db[(_0xcfea('0x87'))][(_0xcfea('0x88'))](_0xcfea('0x89'));}_0x3f30dd=_[_0xcfea('0x8a')](_[_0xcfea('0x3c')](_0x2c3f13),['createdAt','updatedAt']);_0x3872e6=_[_0xcfea('0x8a')](_['keys'](_0x2c3f13),['createdAt','updatedAt','CompanyId',_0xcfea('0x8b')]);if(_0x517dfd[_0xcfea('0x50')]['id']){delete _0x517dfd['body']['id'];}if(_['isNil'](_0x517dfd['body'][_0xcfea('0x8c')])){throw new db[(_0xcfea('0x87'))]['ValidationError'](_0xcfea('0x8d'));}if(_[_0xcfea('0x78')](_0x517dfd[_0xcfea('0x50')][_0xcfea('0x50')])||_0x517dfd[_0xcfea('0x50')][_0xcfea('0x50')]===''){throw new db[(_0xcfea('0x87'))][(_0xcfea('0x88'))](_0xcfea('0x8e'));}if(_[_0xcfea('0x78')](_0x517dfd[_0xcfea('0x50')][_0xcfea('0x8f')])){throw new db[(_0xcfea('0x87'))][(_0xcfea('0x88'))](_0xcfea('0x90')+_0x3872e6);}if(!_[_0xcfea('0x91')](_0x3872e6,_0x517dfd['body'][_0xcfea('0x8f')])){throw new db[(_0xcfea('0x87'))]['ValidationError'](_0xcfea('0x92')+_0x3872e6);}_0x370ff3[_0x517dfd[_0xcfea('0x50')][_0xcfea('0x8f')]]=_0x517dfd[_0xcfea('0x50')][_0xcfea('0x8c')];})['then'](function(){return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x517dfd[_0xcfea('0x4d')]['id']},'include':[{'model':db['CmList'],'as':_0xcfea('0x93'),'include':[{'model':db['CmContact'],'as':_0xcfea('0x94'),'where':_0x370ff3,'limit':0x1,'order':[['updatedAt',_0xcfea('0x95')]]}]},{'model':db[_0xcfea('0x96')],'as':'Applications'}]});})[_0xcfea('0x17')](handleEntityNotFound(_0x3fcdbd,null))[_0xcfea('0x17')](function(_0x404470){if(_0x404470&&_0x404470[_0xcfea('0x93')]){_0x5b8ef0[_0xcfea('0x97')]=_0x404470;_0x5b8ef0['applications']=_0x404470[_0xcfea('0x98')];_0x5b8ef0[_0xcfea('0x99')]=_0x404470[_0xcfea('0x93')];_0x5b8ef0[_0xcfea('0x9a')]=_[_0xcfea('0x9b')](_0x5b8ef0['applications'],[_0xcfea('0x9c')],[_0xcfea('0x9d')]);if(_0x5b8ef0[_0xcfea('0x97')][_0xcfea('0x98')]){delete _0x5b8ef0[_0xcfea('0x97')]['Applications'];}if(_0x5b8ef0['account'][_0xcfea('0x93')]&&_0x5b8ef0[_0xcfea('0x97')][_0xcfea('0x93')][_0xcfea('0x94')][_0xcfea('0x41')]){return _0x5b8ef0[_0xcfea('0x97')][_0xcfea('0x93')][_0xcfea('0x94')][0x0];}var _0x13d11d=_[_0xcfea('0x9e')](_0x517dfd[_0xcfea('0x50')],{'firstName':_0x517dfd['body'][_0xcfea('0x8c')],'ListId':_0x404470[_0xcfea('0x8b')]});_0x13d11d[_0x517dfd[_0xcfea('0x50')]['mapKey']]=_0x517dfd[_0xcfea('0x50')][_0xcfea('0x8c')];return db[_0xcfea('0x86')][_0xcfea('0x4f')](_0x13d11d,{'fields':_0x3f30dd,'raw':!![]});}})['then'](handleEntityNotFound(_0x3fcdbd,null))['then'](function(_0x211b8c){_0x5b8ef0[_0xcfea('0x9f')]=_0x211b8c;var _0x1561c8=_0x517dfd[_0xcfea('0x50')][_0xcfea('0xa0')];if(_0x517dfd[_0xcfea('0x83')][_0xcfea('0xa1')]){_0x1561c8=_0x517dfd[_0xcfea('0x83')][_0xcfea('0xa1')];}else if(_0x517dfd[_0xcfea('0x83')][_0xcfea('0xa2')]){_0x1561c8=_[_0xcfea('0xa3')](_0x517dfd['headers'][_0xcfea('0xa2')][_0xcfea('0xa4')](','));}if(_0x211b8c){var _0xbceae8={'ContactId':_0x211b8c['id'],'ChatWebsiteId':_0x517dfd['params']['id'],'from':(_0x211b8c[_0xcfea('0xa5')]||'')+'\x20'+(_0x211b8c['lastName']||''),'customerIp':_0x1561c8,'customerPort':_0x517dfd['headers']['x-real-port']?_0x517dfd[_0xcfea('0x83')][_0xcfea('0xa6')]:null,'referer':_0x517dfd[_0xcfea('0x50')][_0xcfea('0xa7')],'browserName':_0x59c771['browser'][_0xcfea('0x30')]&&_0x59c771[_0xcfea('0xa8')]['version']?util[_0xcfea('0xa9')](_0xcfea('0xaa'),_0x59c771[_0xcfea('0xa8')][_0xcfea('0x30')],_0x59c771[_0xcfea('0xa8')][_0xcfea('0xab')]):_0xcfea('0xac'),'browserVersion':_0x59c771[_0xcfea('0xa8')][_0xcfea('0xab')]||_0xcfea('0xac'),'osName':util['format'](_0xcfea('0xaa'),_0x59c771['os']['name'],_0x59c771['os']['version']),'osVersion':_0x59c771['os'][_0xcfea('0xab')],'deviceModel':_0x59c771['device'][_0xcfea('0x3a')]&&_0x59c771[_0xcfea('0xad')][_0xcfea('0xae')]?util[_0xcfea('0xa9')](_0xcfea('0xaf'),_0x59c771[_0xcfea('0xad')][_0xcfea('0x3a')],_0x59c771[_0xcfea('0xad')][_0xcfea('0xae')],_0x59c771[_0xcfea('0xad')][_0xcfea('0x38')]):null,'deviceVendor':_0x59c771['device'][_0xcfea('0xae')],'deviceType':_0x59c771[_0xcfea('0xad')][_0xcfea('0x38')],'formData':JSON[_0xcfea('0xb0')](_0x517dfd[_0xcfea('0x50')])};var _0x242b9e={'ChatWebsiteId':_0x517dfd['params']['id'],'closed':![]};if(_0x517dfd[_0xcfea('0x50')]['threadId']){_0x242b9e[_0xcfea('0xb1')]=_0x517dfd['body'][_0xcfea('0xb1')];return db[_0xcfea('0xb2')]['find']({'where':_0x242b9e})[_0xcfea('0x17')](function(_0x153019){if(_0x153019){return[_0x153019,![]];}_0xbceae8['threadId']=_0x517dfd[_0xcfea('0x50')][_0xcfea('0xb1')];_0xbceae8[_0xcfea('0xb3')]=_0x517dfd[_0xcfea('0x50')][_0xcfea('0xb3')];return db[_0xcfea('0xb2')][_0xcfea('0x4f')](_0xbceae8)['then'](function(_0x5f3982){return[_0x5f3982,!![]];});});}_0x242b9e[_0xcfea('0xb4')]=_0x211b8c['id'];if(_0x517dfd[_0xcfea('0x50')]['interaction']&&_0x517dfd[_0xcfea('0x50')]['interaction']['id']){_0x242b9e['id']=_0x517dfd[_0xcfea('0x50')][_0xcfea('0xb5')]['id'];return db[_0xcfea('0xb2')]['find']({'where':_0x242b9e})['then'](function(_0x3ee281){if(_0x3ee281){return[_0x3ee281,![]];}return db[_0xcfea('0xb2')][_0xcfea('0x4f')](_0xbceae8)[_0xcfea('0x17')](function(_0x263f02){return[_0x263f02,!![]];});});}return db[_0xcfea('0xb2')]['create'](_0xbceae8)['then'](function(_0x4de82e){return[_0x4de82e,!![]];});}})[_0xcfea('0xb6')](function(_0x3a0ca8,_0x2d6f49){if(_0x3a0ca8){_0x5f2500=_0x2d6f49;if(!_0x2d6f49){var _0x484862={'from':(_0x5b8ef0['contact'][_0xcfea('0xa5')]||'')+'\x20'+(_0x5b8ef0[_0xcfea('0x9f')][_0xcfea('0xb7')]||'')};if(_0x517dfd['body'][_0xcfea('0xb1')]&&_0x517dfd[_0xcfea('0x50')]['messageId']&&_0x517dfd[_0xcfea('0x50')]['threadId']!=_0x517dfd[_0xcfea('0x50')][_0xcfea('0xb8')]){_0x484862[_0xcfea('0xb1')]=_0x517dfd[_0xcfea('0x50')][_0xcfea('0xb8')];}return _0x3a0ca8[_0xcfea('0x2b')](_0x484862);}else{return _0x3a0ca8;}}})[_0xcfea('0x17')](function(_0x1cad09){_0x5b8ef0[_0xcfea('0xb5')]=_0x1cad09[_0xcfea('0x2d')]({'plain':!![]});_0x5b8ef0[_0xcfea('0xb5')][_0xcfea('0xb9')]=_0x5f2500;if(_0x5b8ef0[_0xcfea('0xb5')][_0xcfea('0xb9')]){if(_0x5b8ef0[_0xcfea('0x97')]['autoclose']){_0x5b8ef0[_0xcfea('0x9a')][_0xcfea('0xba')]({'id':0x0,'priority':_0x5b8ef0[_0xcfea('0x9a')][_0xcfea('0x41')]+0x1,'app':'close','appdata':'unmanaged','interval':_0xcfea('0xbb')});}}return db[_0xcfea('0xbc')][_0xcfea('0x4f')]({'body':_0x517dfd[_0xcfea('0x50')]['body'],'ChatWebsiteId':_0x517dfd[_0xcfea('0x4d')]['id'],'ChatInteractionId':_0x1cad09['id'],'direction':'in','ContactId':_0x5b8ef0['contact']['id'],'AttachmentId':_0x517dfd[_0xcfea('0x50')][_0xcfea('0xbd')]});})[_0xcfea('0x17')](function(_0x4a736f){_0x5b8ef0['message']=_0x4a736f;if(_0x5b8ef0['interaction'][_0xcfea('0xbe')]){return db[_0xcfea('0xbf')][_0xcfea('0x4e')]({'attributes':['id','name'],'where':{'id':_0x5b8ef0[_0xcfea('0xb5')][_0xcfea('0xbe')]}})[_0xcfea('0x17')](function(_0x5b579f){if(_0x5b579f){_0x5b8ef0[_0xcfea('0x9a')][_0xcfea('0xc0')]({'id':0x0,'priority':0x0,'app':_0xcfea('0xc1'),'appdata':_0x5b579f['name']+','+(_0x5b8ef0[_0xcfea('0x97')]['waitForTheAssignedAgent']||0xa),'interval':_0xcfea('0xbb')});_0x5b8ef0['forcedOwnership']=!![];}return respondWithRpcPromise(_0xcfea('0xc2'),_0xcfea('0xc3'),_0x5b8ef0);});}return respondWithRpcPromise(_0xcfea('0xc2'),'startRouting',_0x5b8ef0);})[_0xcfea('0x17')](function(_0x2e60dd){respondWithRpcPromise('EventManager','EventManager',{'event':_0xcfea('0xc4'),'message':_0x2e60dd},client9002);return _0x2e60dd;})[_0xcfea('0x17')](respondWithResult(_0x3fcdbd,null))['catch'](handleError(_0x3fcdbd,null));};exports[_0xcfea('0xc5')]=function(_0x2000bd,_0x366bc3){var _0x15e81a,_0x41a19e,_0x766279;var _0x5f59df=[];var _0x171eaf={};var _0x3d5e62=_0x2000bd[_0xcfea('0xc6')]||[];var _0x48604f=[];var _0x5b97f6;return db[_0xcfea('0x86')][_0xcfea('0x58')]()[_0xcfea('0x17')](function(_0x907ef1){if(!_0x907ef1){throw new db['Sequelize'][(_0xcfea('0x88'))]('no\x20available\x20attributes');}_0x5f59df=_[_0xcfea('0x8a')](_['keys'](_0x907ef1),[_0xcfea('0xc7'),_0xcfea('0xc8'),'CompanyId',_0xcfea('0x8b')]);if(_0x2000bd[_0xcfea('0x50')]['id']){delete _0x2000bd[_0xcfea('0x50')]['id'];}if(_[_0xcfea('0x78')](_0x2000bd['body']['from'])){throw _0x366bc3['status'](0x1f4)['send'](new db[(_0xcfea('0x87'))][(_0xcfea('0x88'))](_0xcfea('0x8d')));}if(_['isNil'](_0x2000bd['body'][_0xcfea('0x50')])||_0x2000bd['body'][_0xcfea('0x50')]===''){throw _0x366bc3[_0xcfea('0x22')](0x1f4)['send'](new db[(_0xcfea('0x87'))]['ValidationError'](_0xcfea('0x8e')));}if(_[_0xcfea('0x78')](_0x2000bd[_0xcfea('0x50')][_0xcfea('0xc9')])){throw _0x366bc3['status'](0x1f4)['send'](new db[(_0xcfea('0x87'))][(_0xcfea('0x88'))](_0xcfea('0xca')+_0x5f59df));}if(!_[_0xcfea('0x91')](_0x5f59df,_0x2000bd[_0xcfea('0x50')][_0xcfea('0xc9')])){throw _0x366bc3[_0xcfea('0x22')](0x1f4)[_0xcfea('0xcb')](new db[(_0xcfea('0x87'))][(_0xcfea('0x88'))](_0xcfea('0xcc')+_0x5f59df));}_0x171eaf[_0x2000bd[_0xcfea('0x50')][_0xcfea('0xc9')]]=_0x2000bd[_0xcfea('0x50')][_0xcfea('0x8c')];})['then'](function(){return db['ChatWebsite'][_0xcfea('0x4e')]({'where':{'id':_0x2000bd['params']['id']},'include':[{'model':db['CmList'],'as':_0xcfea('0x93')},{'model':db[_0xcfea('0xcd')],'as':_0xcfea('0xcd')}]});})[_0xcfea('0x17')](handleEntityNotFound(_0x366bc3,null))[_0xcfea('0x17')](function(_0x366ef6){if(_0x366ef6&&_0x366ef6[_0xcfea('0x93')]){_0x41a19e=_0x366ef6;var _0x148b22=_[_0xcfea('0x9e')](_0x2000bd[_0xcfea('0x50')],{'firstName':_0x2000bd['body'][_0xcfea('0x8c')],'phone':_0x2000bd[_0xcfea('0x50')][_0xcfea('0x8c')],'ListId':_0x366ef6['ListId']});_0x148b22[_0x2000bd[_0xcfea('0x50')]['mapKeyOffline']]=_0x2000bd[_0xcfea('0x50')]['from'];return db[_0xcfea('0x86')][_0xcfea('0xce')]({'where':_0x171eaf,'defaults':_0x148b22});}})[_0xcfea('0xb6')](function(_0x3a21ca){if(_0x3a21ca){_0x766279=_0x3a21ca;var _0x470634=fs[_0xcfea('0xcf')](path[_0xcfea('0x6f')](config['root'],_0xcfea('0xd0')),_0xcfea('0xd1'));var _0x3a394b=ejs[_0xcfea('0xd2')](_0x470634,{'body':_['toPairs'](_0x2000bd['body'][_0xcfea('0x50')]),'bodyTitle':_0x41a19e[_0xcfea('0xd3')]});return db[_0xcfea('0xd4')][_0xcfea('0x4f')]({'body':_0x3a394b,'plainBody':htmlToText[_0xcfea('0xd5')](_0x3a394b),'ContactId':_0x3a21ca['id'],'ChatWebsiteId':_0x41a19e['id']});}})[_0xcfea('0x17')](function(_0x5a123a){_0x5b97f6=_0x5a123a;if(_0x3d5e62[_0xcfea('0x41')]){var _0x45bbf5=_0x3d5e62['map'](function(_0xadb458){return{'name':_0xadb458['originalname'],'basename':_0xadb458['filename'],'type':_0xadb458[_0xcfea('0xd6')],'ChatOfflineMessageId':_0x5a123a['id']};});_0x48604f=_0x45bbf5[_0xcfea('0x34')](_0x496f74=>{var _0x1e85c2={'filename':_0x496f74[_0xcfea('0x30')],'path':path[_0xcfea('0x6f')](config['root'],_0xcfea('0xd7'),_0xcfea('0xc6'),_0xcfea('0xd8'),_0xcfea('0xd9'),_0x496f74[_0xcfea('0xda')])};return _0x1e85c2;});if(!_0x41a19e[_0xcfea('0xdb')]){return db[_0xcfea('0xdc')][_0xcfea('0xdd')](function(_0x114b98){return db[_0xcfea('0xde')]['bulkCreate'](_0x45bbf5,{'transaction':_0x114b98});});}}})[_0xcfea('0x17')](function(){if(_0x5b97f6){_0x15e81a=_0x5b97f6;return db[_0xcfea('0xcd')][_0xcfea('0x5c')]({'where':{'service':!![]},'include':[{'model':db[_0xcfea('0xdf')],'as':_0xcfea('0xe0'),'raw':!![],'include':[{'model':db[_0xcfea('0xe1')],'as':'CloudProvider','raw':!![]}]}]});}})['then'](function(_0x409121){if(_0x409121&&_0x409121[_0xcfea('0xe0')]&&_0x41a19e[_0xcfea('0xe2')]&&_0x41a19e[_0xcfea('0xe3')]){var _0xede4f6=_0x409121['getSmtpOptions']();return respondWithRpcPromise('SendMail',_0xcfea('0xe4'),{'account':_0xede4f6,'message':{'from':util[_0xcfea('0xa9')](_0xcfea('0xe5'),_0x409121['name'],_0x409121['email']||_0x409121['Smtp']['user']),'to':_0x41a19e[_0xcfea('0xe3')],'subject':_0x41a19e[_0xcfea('0xe6')],'html':_0x15e81a[_0xcfea('0x50')],'attachments':_0x48604f}},client9003)[_0xcfea('0x17')](function(){return _0x15e81a;})[_0xcfea('0x56')](function(_0x254aa0){logger['error'](_0x254aa0);});}})['then'](function(){if(_0x41a19e&&_0x41a19e['openNewInteraction']&&_0x41a19e[_0xcfea('0xe7')]){var _0xeacd1c=[];if(_0x3d5e62[_0xcfea('0x41')]){_0xeacd1c=_0x3d5e62[_0xcfea('0x34')](function(_0x44683c){return{'name':_0x44683c[_0xcfea('0xe8')],'basename':_0x44683c[_0xcfea('0x6a')],'type':_0x44683c[_0xcfea('0xd6')],'ChatOfflineMessageId':_0x5b97f6['id']};});}var _0x3c89dc;if(!_[_0xcfea('0x78')](_0x41a19e[_0xcfea('0xe9')])){var _0x47b2f9=_[_0xcfea('0x34')](_0x2000bd['body'],function(_0xdc5b21){return _0xdc5b21;});var _0x50b4bc=_[_0xcfea('0xea')](_0x47b2f9)[0x0];var _0x598362=_[_0xcfea('0xeb')](_0x50b4bc,function(_0x88f986){return _0x88f986;});_0x3c89dc=_0x598362[0x1][_0x41a19e['subjectOffline']];}var _0x1fe8b5={'from':_0x766279[_0xcfea('0xec')],'firstName':_0x766279[_0xcfea('0xa5')],'lastName':_0x766279[_0xcfea('0xb7')],'mapKey':_0xcfea('0xec'),'message':{'from':_0x766279[_0xcfea('0xec')],'to':_0x41a19e['MailAccount']['email'],'cc':'','subject':_[_0xcfea('0x78')](_0x3c89dc)?_0x41a19e[_0xcfea('0xe6')]:_0x3c89dc,'messageId':'','sentAt':new Date(),'attach':_0xeacd1c[_0xcfea('0x41')],'attachments':_0xeacd1c,'originChannel':_0xcfea('0xed'),'ChatWebsiteId':_0x41a19e['id'],'ChatOfflineMessageId':_0x15e81a['id'],'originTo':_0x41a19e['MailAccount'][_0xcfea('0xec')]},'body':_0x15e81a[_0xcfea('0x50')]};var _0x4e37fd={'account':{'id':_0x41a19e[_0xcfea('0xe7')]},'body':_0x1fe8b5,'log':'NotifyMailAccount'};return respondWithRpcPromise(_0xcfea('0xee'),'notifyMail',_0x4e37fd,client9001)['then'](function(){return _0x15e81a;})[_0xcfea('0x56')](function(_0xf6d892){logger[_0xcfea('0x1c')](_0xf6d892);});}return;})[_0xcfea('0x17')](function(){if(_0x15e81a){return _0x15e81a;}})[_0xcfea('0x17')](respondWithResult(_0x366bc3,null))[_0xcfea('0x56')](function(_0xe2bd59){logger[_0xcfea('0x1c')](_0xcfea('0x56'),_0xe2bd59);for(var _0x472543 of _0x3d5e62){var _0x3c8b90=path[_0xcfea('0x6f')](config[_0xcfea('0x70')],'server',_0xcfea('0xc6'),_0xcfea('0xd8'),_0xcfea('0xd9'),_0x472543[_0xcfea('0x6a')]);fs_extra[_0xcfea('0xef')](_0x3c8b90)[_0xcfea('0x56')](function(_0x2bba9d){logger[_0xcfea('0x1c')](_0xcfea('0xf0'),_0x3c8b90,_0x2bba9d);});}});};exports['addInteraction']=function(_0x5465e5,_0x3f0d95){return db[_0xcfea('0xb2')][_0xcfea('0x4e')]({'where':{'id':_0x5465e5[_0xcfea('0x4d')]['id']}})['then'](handleEntityNotFound(_0x3f0d95,null))[_0xcfea('0x17')](function(_0x3557d5){if(_0x3557d5){return _0x3557d5[_0xcfea('0xf1')](_0x5465e5[_0xcfea('0x50')][_0xcfea('0x61')],_[_0xcfea('0xf2')](_0x5465e5['body'],[_0xcfea('0x61'),'id'])||{});}})['then'](respondWithResult(_0x3f0d95,null))['catch'](handleError(_0x3f0d95,null));};exports['getInteractions']=function(_0x218217,_0x5b8ab0){var _0x2f6286={'raw':![],'where':{}};var _0x48dba0={};var _0x255c55={'count':0x0,'rows':[]};return db['ChatWebsite'][_0xcfea('0x5c')]({'where':{'id':_0x218217['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x5b8ab0,null))[_0xcfea('0x17')](function(_0x5df211){if(_0x5df211){_0x48dba0[_0xcfea('0x3a')]=_[_0xcfea('0x3c')](db['ChatInteraction']['rawAttributes']);_0x48dba0[_0xcfea('0x3b')]=_['keys'](_0x218217[_0xcfea('0x3b')]);_0x48dba0[_0xcfea('0x3d')]=_['intersection'](_0x48dba0[_0xcfea('0x3a')],_0x48dba0['query']);_0x2f6286[_0xcfea('0x3f')]=_[_0xcfea('0x3e')](_0x48dba0['model'],qs[_0xcfea('0x40')](_0x218217[_0xcfea('0x3b')]['fields']));_0x2f6286[_0xcfea('0x3f')]=_0x2f6286[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x2f6286[_0xcfea('0x3f')]:_0x48dba0[_0xcfea('0x3a')];if(!_0x218217['query'][_0xcfea('0x65')]('nolimit')){_0x2f6286[_0xcfea('0x27')]=qs[_0xcfea('0x27')](_0x218217[_0xcfea('0x3b')][_0xcfea('0x27')]);_0x2f6286['offset']=qs[_0xcfea('0x24')](_0x218217[_0xcfea('0x3b')][_0xcfea('0x24')]);}_0x2f6286[_0xcfea('0x42')]=qs[_0xcfea('0x43')](_0x218217[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x2f6286[_0xcfea('0x44')]=qs['filters'](_[_0xcfea('0x5f')](_0x218217[_0xcfea('0x3b')],_0x48dba0[_0xcfea('0x3d')]));_0x2f6286['where'][_0xcfea('0x5a')]=_0x5df211['id'];if(_0x218217['query'][_0xcfea('0x45')]){_0x2f6286['where']=_[_0xcfea('0x47')](_0x2f6286[_0xcfea('0x44')],{'$or':_['map'](_0x2f6286[_0xcfea('0x3f')],function(_0x3c2d77){var _0x1330f4={};_0x1330f4[_0x3c2d77]={'$like':'%'+_0x218217['query'][_0xcfea('0x45')]+'%'};return _0x1330f4;})});}_0x2f6286=_[_0xcfea('0x47')]({},_0x2f6286,_0x218217['options']);return db['ChatInteraction'][_0xcfea('0x26')]({'where':_0x2f6286['where']})[_0xcfea('0x17')](function(_0x397b20){_0x255c55[_0xcfea('0x26')]=_0x397b20;if(_0x218217[_0xcfea('0x3b')][_0xcfea('0x49')]){_0x2f6286[_0xcfea('0x4a')]=[{'model':db[_0xcfea('0x86')],'as':_0xcfea('0xf3'),'required':![]},{'model':db['User'],'as':_0xcfea('0xf4'),'attributes':[_0xcfea('0x30'),_0xcfea('0xf5'),_0xcfea('0xf6')],'required':![]},{'model':db['Tag'],'as':_0xcfea('0xf7'),'attributes':['id',_0xcfea('0x30'),_0xcfea('0xf8')],'where':_0x218217['query'][_0xcfea('0xf9')]?{'id':_0x218217[_0xcfea('0x3b')][_0xcfea('0xf9')]}:undefined,'required':_0x218217[_0xcfea('0x3b')][_0xcfea('0xf9')]?!![]:![]}];}return db[_0xcfea('0xb2')][_0xcfea('0x4b')](_0x2f6286);})['then'](function(_0xae7d5c){_0x255c55[_0xcfea('0xfa')]=_0xae7d5c;return _0x255c55;});}})['then'](respondWithFilteredResult(_0x5b8ab0,_0x2f6286))[_0xcfea('0x56')](handleError(_0x5b8ab0,null));};function iftimePromise(_0x4a9e1d,_0x584ea0){return respondWithRpcPromise(_0xcfea('0xfb'),_0xcfea('0xfc'),{'command':_0x584ea0[_0xcfea('0xfd')]?util['format'](_0xcfea('0xfe'),_0x4a9e1d['interval'],_0x584ea0[_0xcfea('0xfd')]):util[_0xcfea('0xa9')](_0xcfea('0xff'),_0x4a9e1d[_0xcfea('0x100')])},client9002)[_0xcfea('0x17')](function(_0x4ab1f8){var _0x2cec0b=_0x4ab1f8&&_0x4ab1f8[_0xcfea('0x101')](_0xcfea('0x102'))>=0x0?!![]:![];logger[_0xcfea('0x18')](_0xcfea('0x103'),_0x584ea0['id'],_0x4a9e1d['id'],_0x4a9e1d[_0xcfea('0x100')],_0x2cec0b?_0xcfea('0x104'):_0xcfea('0x105'),_0x584ea0['timezone']?_0x584ea0[_0xcfea('0xfd')]:_0xcfea('0x106'));return _0x2cec0b;})[_0xcfea('0x56')](function(_0x18fb70){logger[_0xcfea('0x1c')](_0xcfea('0x103'),_0x584ea0['id'],_0x4a9e1d['id'],_0x4a9e1d[_0xcfea('0x100')],util[_0xcfea('0x107')](_0x18fb70,{'showHidden':![],'depth':null}),_0x584ea0[_0xcfea('0xfd')]?_0x584ea0[_0xcfea('0xfd')]:_0xcfea('0x106'));return![];});}exports['getSnippet']=function(_0xcb357c,_0x47cd9b){var _0x362ee3=0x0;var _0x227ac2=0x0;var _0x1faffa=![];var _0x3f03a2;var _0x5b3308;return db['ChatWebsite'][_0xcfea('0x4e')]({'where':{'id':_0xcb357c[_0xcfea('0x4d')]['id']},'include':[{'model':db[_0xcfea('0x108')],'as':_0xcfea('0x108'),'include':[{'model':db['Interval'],'as':'Intervals','attributes':['id',_0xcfea('0x100')],'raw':!![]}]}]})[_0xcfea('0x17')](handleEntityNotFound(_0x47cd9b,null))[_0xcfea('0x17')](function(_0x53cdd7){if(_0x53cdd7){_0x3f03a2=_0x53cdd7;return _0x53cdd7[_0xcfea('0x109')]({'raw':!![]});}})[_0xcfea('0x17')](function(_0x17f8fb){if(_0x3f03a2){if(_0x17f8fb){_0x5b3308=_0x17f8fb;}}return require('../../config/license/util')[_0xcfea('0x73')]();})['then'](function(_0x1b287f){if(_0x1b287f){_0x227ac2=_0x1b287f['virtual'];_0x1faffa=_0x1b287f[_0xcfea('0x74')];}})[_0xcfea('0x17')](function(){return db[_0xcfea('0xb2')][_0xcfea('0x26')]({'where':{'closed':![]}});})[_0xcfea('0x17')](function(_0x451e11){_0x362ee3=_0x451e11;if(_0x227ac2&&_0x451e11>_0x227ac2){return db[_0xcfea('0x10a')][_0xcfea('0x5c')]({'where':{'id':0x1}})['then'](function(_0x1ffd57){if(_0x1ffd57){_0x1ffd57[_0xcfea('0x10b')](_0xcfea('0x10c'));}});}})[_0xcfea('0x17')](function(){if(_0x3f03a2[_0xcfea('0x108')]&&_0x3f03a2[_0xcfea('0x108')][_0xcfea('0x10d')]){var _0x19c356=[];for(var _0x99da58=0x0;_0x99da58<_0x3f03a2[_0xcfea('0x108')][_0xcfea('0x10d')][_0xcfea('0x41')];_0x99da58++){var _0x16f58f=_0x3f03a2[_0xcfea('0x108')][_0xcfea('0x10d')][_0x99da58][_0xcfea('0x2d')]({'plain':!![]});_0x19c356['push'](iftimePromise(_0x16f58f,_0x3f03a2));}return BPromise[_0xcfea('0x10e')](_0x19c356)[_0xcfea('0x17')](function(_0x345e45){return _[_0xcfea('0x10f')](_0x345e45);});}else{return!![];}})[_0xcfea('0x17')](function(_0xd9e7ef){var _0x2f3e64=fs[_0xcfea('0xcf')](path[_0xcfea('0x6f')](config[_0xcfea('0x70')],'server/files/chat/iframe.ejs'),_0xcfea('0xd1'));var _0x4bf605=new url['URL'](_0x3f03a2['address'])[_0xcfea('0x110')];var _0x1888df=_0xcfea('0x111');var _0x309476=![];var _0x59003a={'chatVersion':_0x1888df,'chatWebsiteAddressOrigin':_0x4bf605,'remote':_0x3f03a2[_0xcfea('0x112')],'query':querystring[_0xcfea('0xb0')](_[_0xcfea('0x47')](_0x3f03a2['get']({'plain':!![]}),{'customerIp':_0xcb357c[_0xcfea('0x83')]['x-forwarded-for']||_0xcb357c[_0xcfea('0x83')][_0xcfea('0x113')]||_0xcb357c[_0xcfea('0x114')][_0xcfea('0x115')]||_0xcb357c['ip'],'referer':_0xcb357c[_0xcfea('0x83')][_0xcfea('0xa7')],'openedInteractions':_0x362ee3,'maxInteractions':_0x227ac2,'virtual':_0x1faffa[_0xcfea('0x116')],'online':_0xd9e7ef,'custom':_0x1faffa}))[_0xcfea('0x117')](/'/g,'\x5c\x27')};_0x47cd9b[_0xcfea('0xcb')](ejs[_0xcfea('0xd2')](Mustache['render'](_0x2f3e64,_0x59003a),{'proactiveActions':_0x5b3308,'alignment':_0x3f03a2['alignment'],'verticalAlignment':_0x3f03a2[_0xcfea('0x118')],'div_color':_0x3f03a2[_0xcfea('0xf8')],'labelText':_0x3f03a2[_0xcfea('0x119')],'text_color':_0x3f03a2[_0xcfea('0x11a')],'text_button_color':_0x3f03a2[_0xcfea('0x11b')],'button_color':_0x3f03a2[_0xcfea('0x11c')],'background_color':_0x3f03a2[_0xcfea('0x11d')],'hideWhenOffline':_0x3f03a2[_0xcfea('0x11e')],'intervalId':_0x3f03a2['IntervalId'],'isDevelopment':_0x309476,'chatVersion':_0x1888df}));})['catch'](handleError(_0x47cd9b,null));};exports['addApplications']=function(_0x12e3aa,_0x5b4084){var _0x5a1888=_0x12e3aa[_0xcfea('0x4d')]['id'];var _0x56a16d=_0x12e3aa[_0xcfea('0x50')];var _0x472250=0xc8;var _0x5bf796=null;return db[_0xcfea('0xdc')]['transaction']({'isolationLevel':db[_0xcfea('0xdc')]['Transaction']['ISOLATION_LEVELS'][_0xcfea('0x11f')]},function(_0x1bf5c4){return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x5a1888},'transaction':_0x1bf5c4})['then'](function(_0x58325f){if(_0x58325f){return db[_0xcfea('0x96')][_0xcfea('0x2c')]({'where':{'ChatWebsiteId':_0x5a1888},'transaction':_0x1bf5c4})[_0xcfea('0x17')](function(){var _0x1af3fc=_[_0xcfea('0x34')](_0x56a16d,function(_0x51e7f8){_0x51e7f8['ChatWebsiteId']=_0x5a1888;return _0x51e7f8;});return db['ChatApplication'][_0xcfea('0x120')](_0x1af3fc,{'transaction':_0x1bf5c4});});}else{_0x472250=0x194;_0x5bf796=[];}});})[_0xcfea('0x17')](function(){if(_0x472250!==0x194){return db[_0xcfea('0x96')][_0xcfea('0x121')]({'where':{'ChatWebsiteId':_0x5a1888},'order':_0xcfea('0x9c')})['then'](function(_0x5d7bf8){_0x5bf796=_0x5d7bf8;});}})[_0xcfea('0x56')](function(_0x3b3187){_0x472250=0x1f4;logger[_0xcfea('0x1c')](_0x3b3187['stack']);if(_0x3b3187[_0xcfea('0x30')]){delete _0x3b3187[_0xcfea('0x30')];}_0x5bf796=_0x3b3187;})[_0xcfea('0x122')](function(){if(_0x5bf796===null){_0x5b4084[_0xcfea('0x21')](_0x472250);}else{if(_0x472250===0x1f4){_0x5b4084[_0xcfea('0x22')](_0x472250)[_0xcfea('0xcb')](_0x5bf796);}else{_0x5b4084[_0xcfea('0x22')](_0x472250)[_0xcfea('0x2a')](_0x5bf796);}}});};exports[_0xcfea('0x123')]=function(_0x1f34d8,_0xcf0d9d){var _0x45636c={};var _0x3e2e5c={};var _0xbb7350;var _0x27fb5b;return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x1f34d8['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0xcf0d9d,null))[_0xcfea('0x17')](function(_0x11dd9d){if(_0x11dd9d){_0xbb7350=_0x11dd9d;_0x3e2e5c[_0xcfea('0x3a')]=_[_0xcfea('0x3c')](db[_0xcfea('0x96')][_0xcfea('0x36')]);_0x3e2e5c[_0xcfea('0x3b')]=_[_0xcfea('0x3c')](_0x1f34d8['query']);_0x3e2e5c[_0xcfea('0x3d')]=_[_0xcfea('0x3e')](_0x3e2e5c[_0xcfea('0x3a')],_0x3e2e5c['query']);_0x45636c[_0xcfea('0x3f')]=_[_0xcfea('0x3e')](_0x3e2e5c['model'],qs[_0xcfea('0x40')](_0x1f34d8['query'][_0xcfea('0x40')]));_0x45636c['attributes']=_0x45636c[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x45636c[_0xcfea('0x3f')]:_0x3e2e5c[_0xcfea('0x3a')];_0x45636c['order']=qs[_0xcfea('0x43')](_0x1f34d8['query'][_0xcfea('0x43')]);_0x45636c[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_[_0xcfea('0x5f')](_0x1f34d8[_0xcfea('0x3b')],_0x3e2e5c[_0xcfea('0x3d')]));if(_0x1f34d8['query'][_0xcfea('0x45')]){_0x45636c['where']=_[_0xcfea('0x47')](_0x45636c[_0xcfea('0x44')],{'$or':_[_0xcfea('0x34')](_0x45636c['attributes'],function(_0x1b16eb){var _0x4e3790={};_0x4e3790[_0x1b16eb]={'$like':'%'+_0x1f34d8[_0xcfea('0x3b')]['filter']+'%'};return _0x4e3790;})});}_0x45636c=_[_0xcfea('0x47')]({},_0x45636c,_0x1f34d8[_0xcfea('0x48')]);return _0xbb7350['getApplications'](_0x45636c);}})[_0xcfea('0x17')](function(_0x2ef9d9){if(_0x2ef9d9){_0x27fb5b=_0x2ef9d9[_0xcfea('0x41')];if(!_0x1f34d8['query']['hasOwnProperty'](_0xcfea('0x5e'))){_0x45636c['limit']=qs[_0xcfea('0x27')](_0x1f34d8[_0xcfea('0x3b')][_0xcfea('0x27')]);_0x45636c[_0xcfea('0x24')]=qs[_0xcfea('0x24')](_0x1f34d8['query'][_0xcfea('0x24')]);}return _0xbb7350[_0xcfea('0x123')](_0x45636c);}})[_0xcfea('0x17')](function(_0x292ec3){if(_0x292ec3){return _0x292ec3?{'count':_0x27fb5b,'rows':_0x292ec3}:null;}})[_0xcfea('0x17')](respondWithResult(_0xcf0d9d,null))[_0xcfea('0x56')](handleError(_0xcf0d9d,null));};exports[_0xcfea('0x124')]=function(_0x4d3218,_0x395461){return db[_0xcfea('0x125')][_0xcfea('0x4e')]({'where':{'id':_0x4d3218[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x395461,null))[_0xcfea('0x17')](function(_0x19499b){if(_0x19499b){return _0x19499b[_0xcfea('0x124')](_0x4d3218['body']['ids'],_['omit'](_0x4d3218[_0xcfea('0x50')],[_0xcfea('0x61'),'id'])||{});}})[_0xcfea('0x17')](respondWithResult(_0x395461,null))[_0xcfea('0x56')](handleError(_0x395461,null));};exports['getProactiveActions']=function(_0x111329,_0x4736c2){var _0x1b862b={};var _0x483a4f={};var _0x57b998;var _0x2a2172;return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x111329[_0xcfea('0x4d')]['id']}})['then'](handleEntityNotFound(_0x4736c2,null))[_0xcfea('0x17')](function(_0xaa2da4){if(_0xaa2da4){_0x57b998=_0xaa2da4;_0x483a4f[_0xcfea('0x3a')]=_[_0xcfea('0x3c')](db['ChatProactiveAction']['rawAttributes']);_0x483a4f[_0xcfea('0x3b')]=_[_0xcfea('0x3c')](_0x111329[_0xcfea('0x3b')]);_0x483a4f[_0xcfea('0x3d')]=_[_0xcfea('0x3e')](_0x483a4f[_0xcfea('0x3a')],_0x483a4f['query']);_0x1b862b[_0xcfea('0x3f')]=_[_0xcfea('0x3e')](_0x483a4f[_0xcfea('0x3a')],qs[_0xcfea('0x40')](_0x111329[_0xcfea('0x3b')][_0xcfea('0x40')]));_0x1b862b[_0xcfea('0x3f')]=_0x1b862b[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x1b862b['attributes']:_0x483a4f[_0xcfea('0x3a')];_0x1b862b[_0xcfea('0x42')]=qs[_0xcfea('0x43')](_0x111329[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x1b862b[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_['pick'](_0x111329[_0xcfea('0x3b')],_0x483a4f[_0xcfea('0x3d')]));if(_0x111329[_0xcfea('0x3b')][_0xcfea('0x45')]){_0x1b862b[_0xcfea('0x44')]=_[_0xcfea('0x47')](_0x1b862b[_0xcfea('0x44')],{'$or':_[_0xcfea('0x34')](_0x1b862b[_0xcfea('0x3f')],function(_0x347824){var _0x31a0fe={};_0x31a0fe[_0x347824]={'$like':'%'+_0x111329['query']['filter']+'%'};return _0x31a0fe;})});}_0x1b862b=_['merge']({},_0x1b862b,_0x111329[_0xcfea('0x48')]);return _0x57b998[_0xcfea('0x109')](_0x1b862b);}})[_0xcfea('0x17')](function(_0x306421){if(_0x306421){_0x2a2172=_0x306421[_0xcfea('0x41')];if(!_0x111329[_0xcfea('0x3b')][_0xcfea('0x65')](_0xcfea('0x5e'))){_0x1b862b[_0xcfea('0x27')]=qs[_0xcfea('0x27')](_0x111329[_0xcfea('0x3b')][_0xcfea('0x27')]);_0x1b862b[_0xcfea('0x24')]=qs['offset'](_0x111329[_0xcfea('0x3b')][_0xcfea('0x24')]);}return _0x57b998[_0xcfea('0x109')](_0x1b862b);}})['then'](function(_0x529c21){if(_0x529c21){return _0x529c21?{'count':_0x2a2172,'rows':_0x529c21}:null;}})[_0xcfea('0x17')](respondWithResult(_0x4736c2,null))[_0xcfea('0x56')](handleError(_0x4736c2,null));};exports[_0xcfea('0x126')]=function(_0x45f712,_0x25b269){var _0x34b3ee=_0x45f712['query'][_0xcfea('0x127')]===_0xcfea('0x128')?_0xcfea('0x129'):_0xcfea('0x12a');return db['ChatWebsite']['find']({'attributes':['id',_0x34b3ee],'where':{'id':_0x45f712['params']['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x25b269,null))[_0xcfea('0x17')](function(_0x150846){if(_0x150846){var _0x2e84a1=_0x150846[_0x34b3ee];var _0x2c9ead=_0x2e84a1&&_0x2e84a1[_0xcfea('0x12b')]?_0x2e84a1[_0xcfea('0x12b')]:[];_0x25b269[_0xcfea('0xcb')]({'fromKey':_[_0xcfea('0x78')](_0x2e84a1[_0xcfea('0x12c')])?undefined:_0x2e84a1[_0xcfea('0x12c')],'count':_0x2c9ead[_0xcfea('0x41')],'rows':_0x2c9ead});}})[_0xcfea('0x56')](handleError(_0x25b269,null));};exports[_0xcfea('0x12d')]=function(_0x38af27,_0x216480){var _0x5a27bf={'raw':![],'where':{}};var _0x1b63ba={};var _0x5eb6f1={'count':0x0,'rows':[]};return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x38af27[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x216480,null))['then'](function(_0x45a352){if(_0x45a352){_0x1b63ba[_0xcfea('0x3a')]=_['keys'](db[_0xcfea('0xd4')][_0xcfea('0x36')]);_0x1b63ba[_0xcfea('0x3b')]=_[_0xcfea('0x3c')](_0x38af27[_0xcfea('0x3b')]);_0x1b63ba[_0xcfea('0x3d')]=_[_0xcfea('0x3e')](_0x1b63ba[_0xcfea('0x3a')],_0x1b63ba[_0xcfea('0x3b')]);_0x5a27bf['attributes']=_[_0xcfea('0x3e')](_0x1b63ba['model'],qs[_0xcfea('0x40')](_0x38af27[_0xcfea('0x3b')]['fields']));_0x5a27bf[_0xcfea('0x3f')]=_0x5a27bf[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x5a27bf['attributes']:_0x1b63ba['model'];if(!_0x38af27[_0xcfea('0x3b')]['hasOwnProperty'](_0xcfea('0x5e'))){_0x5a27bf[_0xcfea('0x27')]=qs['limit'](_0x38af27[_0xcfea('0x3b')][_0xcfea('0x27')]);_0x5a27bf[_0xcfea('0x24')]=qs[_0xcfea('0x24')](_0x38af27[_0xcfea('0x3b')][_0xcfea('0x24')]);}_0x5a27bf[_0xcfea('0x42')]=qs['sort'](_0x38af27[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x5a27bf[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_[_0xcfea('0x5f')](_0x38af27[_0xcfea('0x3b')],_0x1b63ba['filters']));_0x5a27bf['where'][_0xcfea('0x5a')]=_0x45a352['id'];if(_0x38af27['query'][_0xcfea('0x45')]){_0x5a27bf[_0xcfea('0x44')]=_[_0xcfea('0x47')](_0x5a27bf[_0xcfea('0x44')],{'$or':_[_0xcfea('0x34')](_0x5a27bf['attributes'],function(_0x594c4d){var _0x27128c={};_0x27128c[_0x594c4d]={'$like':'%'+_0x38af27[_0xcfea('0x3b')][_0xcfea('0x45')]+'%'};return _0x27128c;})});}_0x5a27bf=_['merge']({},_0x5a27bf,_0x38af27[_0xcfea('0x48')]);return db['ChatOfflineMessage'][_0xcfea('0x26')]({'where':_0x5a27bf[_0xcfea('0x44')]})[_0xcfea('0x17')](function(_0xc2ef93){_0x5eb6f1[_0xcfea('0x26')]=_0xc2ef93;if(_0x38af27[_0xcfea('0x3b')][_0xcfea('0x49')]){_0x5a27bf[_0xcfea('0x4a')]=[{'all':!![]}];}else{_0x5a27bf['include']=[{'model':db[_0xcfea('0x86')],'as':_0xcfea('0xf3'),'required':![]},{'model':db[_0xcfea('0xde')],'as':_0xcfea('0x12e'),'required':![]}];}return db[_0xcfea('0xd4')]['findAll'](_0x5a27bf);})[_0xcfea('0x17')](function(_0x13fa4b){_0x5eb6f1['rows']=_0x13fa4b;return _0x5eb6f1;});}})[_0xcfea('0x17')](respondWithFilteredResult(_0x216480,_0x5a27bf))['catch'](handleError(_0x216480,null));};exports[_0xcfea('0x12f')]=function(_0x270ff7,_0x2a86dd){return db[_0xcfea('0x35')][_0xcfea('0x4e')]({'where':{'id':_0x270ff7[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x2a86dd,null))[_0xcfea('0x17')](function(_0x55fbf5){if(_0x55fbf5){return _0x55fbf5[_0xcfea('0x12f')](_0x270ff7[_0xcfea('0x50')]['ids'],_['omit'](_0x270ff7['body'],['ids','id'])||{})[_0xcfea('0xb6')](function(_0x2d5f93){for(var _0x7ec349=0x0;_0x7ec349<_0x270ff7[_0xcfea('0x50')][_0xcfea('0x61')]['length'];_0x7ec349+=0x1){socket['emit'](_0xcfea('0x130'),{'UserId':Number(_0x270ff7['body']['ids'][_0x7ec349]),'ChatWebsiteId':Number(_0x270ff7['params']['id'])});}return _0x2d5f93;});}})[_0xcfea('0x17')](respondWithResult(_0x2a86dd,null))[_0xcfea('0x56')](handleError(_0x2a86dd,null));};exports[_0xcfea('0x131')]=function(_0x151681,_0x4c997b){return db[_0xcfea('0x35')]['find']({'where':{'id':_0x151681[_0xcfea('0x4d')]['id']}})[_0xcfea('0x17')](handleEntityNotFound(_0x4c997b,null))[_0xcfea('0x17')](function(_0x430893){if(_0x430893){return _0x430893['removeAgents'](_0x151681[_0xcfea('0x3b')][_0xcfea('0x61')])['then'](function(){if(_[_0xcfea('0x132')](_0x151681[_0xcfea('0x3b')][_0xcfea('0x61')])){for(var _0x55d521=0x0;_0x55d521<_0x151681[_0xcfea('0x3b')]['ids'][_0xcfea('0x41')];_0x55d521+=0x1){socket['emit'](_0xcfea('0x133'),{'UserId':Number(_0x151681[_0xcfea('0x3b')][_0xcfea('0x61')][_0x55d521]),'ChatWebsiteId':Number(_0x151681[_0xcfea('0x4d')]['id'])});}}else{socket[_0xcfea('0x134')](_0xcfea('0x133'),{'UserId':Number(_0x151681['query'][_0xcfea('0x61')]),'ChatWebsiteId':Number(_0x151681[_0xcfea('0x4d')]['id'])});}});}})[_0xcfea('0x17')](respondWithStatusCode(_0x4c997b,null))[_0xcfea('0x56')](handleError(_0x4c997b,null));};exports[_0xcfea('0x135')]=function(_0x4a7099,_0x36218b){var _0x4c6b10={};var _0x4ca748={};var _0x1b0a0e;var _0x4400e7;return db[_0xcfea('0x35')][_0xcfea('0x5c')]({'where':{'id':_0x4a7099[_0xcfea('0x4d')]['id']}})['then'](handleEntityNotFound(_0x36218b,null))[_0xcfea('0x17')](function(_0x4a569c){if(_0x4a569c){_0x1b0a0e=_0x4a569c;_0x4ca748[_0xcfea('0x3a')]=_['keys'](db[_0xcfea('0xbf')]['rawAttributes']);_0x4ca748[_0xcfea('0x3b')]=_[_0xcfea('0x3c')](_0x4a7099[_0xcfea('0x3b')]);_0x4ca748['filters']=_[_0xcfea('0x3e')](_0x4ca748[_0xcfea('0x3a')],_0x4ca748[_0xcfea('0x3b')]);_0x4c6b10[_0xcfea('0x3f')]=_['intersection'](_0x4ca748[_0xcfea('0x3a')],qs[_0xcfea('0x40')](_0x4a7099[_0xcfea('0x3b')][_0xcfea('0x40')]));_0x4c6b10[_0xcfea('0x3f')]=_0x4c6b10[_0xcfea('0x3f')][_0xcfea('0x41')]?_0x4c6b10[_0xcfea('0x3f')]:_0x4ca748[_0xcfea('0x3a')];_0x4c6b10['order']=qs['sort'](_0x4a7099[_0xcfea('0x3b')][_0xcfea('0x43')]);_0x4c6b10[_0xcfea('0x44')]=qs[_0xcfea('0x3d')](_[_0xcfea('0x5f')](_0x4a7099[_0xcfea('0x3b')],_0x4ca748[_0xcfea('0x3d')]));if(_0x4a7099[_0xcfea('0x3b')][_0xcfea('0x45')]){_0x4c6b10[_0xcfea('0x44')]=_[_0xcfea('0x47')](_0x4c6b10[_0xcfea('0x44')],{'$or':_[_0xcfea('0x34')](_0x4c6b10[_0xcfea('0x3f')],function(_0x31d767){var _0x12b293={};_0x12b293[_0x31d767]={'$like':'%'+_0x4a7099[_0xcfea('0x3b')][_0xcfea('0x45')]+'%'};return _0x12b293;})});}_0x4c6b10=_['merge']({},_0x4c6b10,_0x4a7099['options']);return _0x1b0a0e[_0xcfea('0x135')](_0x4c6b10);}})[_0xcfea('0x17')](function(_0x374dd7){if(_0x374dd7){_0x4400e7=_0x374dd7[_0xcfea('0x41')];if(!_0x4a7099[_0xcfea('0x3b')][_0xcfea('0x65')](_0xcfea('0x5e'))){_0x4c6b10[_0xcfea('0x27')]=qs[_0xcfea('0x27')](_0x4a7099['query'][_0xcfea('0x27')]);_0x4c6b10[_0xcfea('0x24')]=qs['offset'](_0x4a7099[_0xcfea('0x3b')][_0xcfea('0x24')]);}return _0x1b0a0e[_0xcfea('0x135')](_0x4c6b10);}})[_0xcfea('0x17')](function(_0x2a72cd){if(_0x2a72cd){return _0x2a72cd?{'count':_0x4400e7,'rows':_0x2a72cd}:null;}})[_0xcfea('0x17')](respondWithResult(_0x36218b,null))['catch'](handleError(_0x36218b,null));};
\ No newline at end of file