Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 52ab0e1..1f97e41 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8fd6=['key','name','keys','filters','intersection','model','query','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','where','merge','VIRTUAL','filter','options','includeAll','include','findAll','rows','show','params','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','ChatWebsites','UserProfileSection','autoAssociation','describe','addDisposition','ChatWebsiteId','Disposition','findOne','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','addLogo','sitepic','filename','addAvatar','agentAvatar','file','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','getLicense','custom','isNil','getAvatar','server/files/images/avatars/default_avatar.png','existsSync','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','customerAvatar','showCustomerAvatar','download','getSystemAvatar','user-agent-parser','setUA','headers','user-agent','getResult','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','createdAt','updatedAt','difference','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','List','Contacts','DESC','Applications','list','orderBy','applications','asc','account','ListId','contact','cf-connecting-ip','x-forwarded-for','first','split','firstName','lastName','x-real-port','referer','browser','version','format','%s\x20%s','unknown','device','vendor','%s\x20%s\x20%s','threadId','ChatInteraction','externalUrl','interaction','spread','messageId','created','push','close','unmanaged','*,*,*,*','ChatMessage','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','notify','offline','CompanyId','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','findOrCreate','server/files/templates/chatOfflineMessage.ejs','toPairs','offlineMessageBody','ChatOfflineMessage','MailAccount','MailServerOut','Smtp','service','host','port','secure','authentication','auth','pass','sendMail','email','user','forwardOfflineAddress','offlineMessageSubject','addInteraction','omit','getInteractions','Contact','Owner','fullname','Tag','Tags','color','tag','Command','getSnippet','timezone','iftime\x20%s,%s','interval','iftime\x20%s','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','inspect','Interval','getProactiveActions','virtual','increment','chatLicenseExceeded','Intervals','all','readFileSync','server/files/chat/iframe.js','utf8','connection','remoteAddress','replace','render','alignment','verticalAlignment','textColor','addApplications','sequelize','transaction','ChatApplication','bulkCreate','findAndCountAll','priority','getApplications','addProactiveActions','getFields','online','offlineForm','onlineForm','items','fromKey','getOfflineMessages','addAgents','userChatWebsite:save','removeAgents','isArray','emit','userChatWebsite:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','./chatWebsite.socket','register','jayson/promise','client','http','request','info','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','message','ChatWebsite,\x20%s,\x20%s','catch','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','get','UserProfileResource','then','send','index','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','fieldName','type'];(function(_0x2c54e5,_0x45a051){var _0x3e8da2=function(_0xa7688b){while(--_0xa7688b){_0x2c54e5['push'](_0x2c54e5['shift']());}};_0x3e8da2(++_0x45a051);}(_0x8fd6,0xdd));var _0x68fd=function(_0x3e72da,_0x7909e3){_0x3e72da=_0x3e72da-0x0;var _0x20a27d=_0x8fd6[_0x3e72da];return _0x20a27d;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x68fd('0x0'));var rimraf=require(_0x68fd('0x1'));var zipdir=require(_0x68fd('0x2'));var jsonpatch=require(_0x68fd('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x68fd('0x4'));var Mustache=require(_0x68fd('0x5'));var util=require(_0x68fd('0x6'));var path=require(_0x68fd('0x7'));var sox=require(_0x68fd('0x8'));var csv=require(_0x68fd('0x9'));var ejs=require(_0x68fd('0xa'));var fs=require('fs');var _=require(_0x68fd('0xb'));var squel=require(_0x68fd('0xc'));var crypto=require(_0x68fd('0xd'));var jsforce=require(_0x68fd('0xe'));var deskjs=require(_0x68fd('0xf'));var toCsv=require(_0x68fd('0x9'));var querystring=require('querystring');var Papa=require(_0x68fd('0x10'));var Redis=require(_0x68fd('0x11'));var authService=require(_0x68fd('0x12'));var qs=require(_0x68fd('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x68fd('0x14'));var logger=require('../../config/logger')(_0x68fd('0x15'));var utils=require(_0x68fd('0x16'));var config=require(_0x68fd('0x17'));var licenseUtil=require(_0x68fd('0x18'));var db=require(_0x68fd('0x19'))['db'];config['redis']=_[_0x68fd('0x1a')](config[_0x68fd('0x1b')],{'host':_0x68fd('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x68fd('0x1b')]));require(_0x68fd('0x1d'))[_0x68fd('0x1e')](socket);var jayson=require(_0x68fd('0x1f'));var client=jayson[_0x68fd('0x20')][_0x68fd('0x21')]({'port':0x232c});var client9002=jayson[_0x68fd('0x20')]['http']({'port':0x232a});var client9003=jayson[_0x68fd('0x20')]['http']({'port':0x232b});function respondWithRpcPromise(_0x2f987c,_0x2c94f0,_0x71e805,_0x2b233c){return new BPromise(function(_0x521213,_0x10e26d){var _0x1fd11e=_0x2b233c||client;return _0x1fd11e[_0x68fd('0x22')](_0x2f987c,_0x71e805)['then'](function(_0x1fddc9){logger[_0x68fd('0x23')]('ChatWebsite,\x20%s,\x20%s',_0x2c94f0,_0x68fd('0x24'));logger[_0x68fd('0x25')](_0x68fd('0x26'),_0x2c94f0,_0x68fd('0x24'),JSON[_0x68fd('0x27')](_0x1fddc9));if(_0x1fddc9[_0x68fd('0x28')]){if(_0x1fddc9[_0x68fd('0x28')]['code']===0x1f4){logger[_0x68fd('0x28')]('ChatWebsite,\x20%s,\x20%s',_0x2c94f0,_0x1fddc9[_0x68fd('0x28')][_0x68fd('0x29')]);return _0x10e26d(_0x1fddc9[_0x68fd('0x28')][_0x68fd('0x29')]);}logger['error'](_0x68fd('0x2a'),_0x2c94f0,_0x1fddc9[_0x68fd('0x28')][_0x68fd('0x29')]);return _0x521213(_0x1fddc9[_0x68fd('0x28')][_0x68fd('0x29')]);}else{logger[_0x68fd('0x23')](_0x68fd('0x2a'),_0x2c94f0,_0x68fd('0x24'));_0x521213(_0x1fddc9['result']['message']);}})[_0x68fd('0x2b')](function(_0x325a33){logger[_0x68fd('0x28')](_0x68fd('0x2a'),_0x2c94f0,_0x325a33);_0x10e26d(_0x325a33);});});}function respondWithStatusCode(_0x3b9491,_0x130ba3){_0x130ba3=_0x130ba3||0xcc;return function(_0xa8937f){if(_0xa8937f){return _0x3b9491[_0x68fd('0x2c')](_0x130ba3);}return _0x3b9491[_0x68fd('0x2d')](_0x130ba3)[_0x68fd('0x2e')]();};}function respondWithResult(_0x46f360,_0x1e6ac8){_0x1e6ac8=_0x1e6ac8||0xc8;return function(_0x160fac){if(_0x160fac){return _0x46f360[_0x68fd('0x2d')](_0x1e6ac8)[_0x68fd('0x2f')](_0x160fac);}};}function respondWithFilteredResult(_0x2e75f8,_0x596fd2){return function(_0x3098e3){if(_0x3098e3){var _0x5c10db=_0x3098e3[_0x68fd('0x30')],_0x41ebc3=_0x596fd2[_0x68fd('0x31')],_0x31f156=_0x596fd2[_0x68fd('0x31')]+_0x596fd2[_0x68fd('0x32')],_0x4c672f;if(_0x31f156>=_0x5c10db){_0x31f156=_0x5c10db;_0x4c672f=0xc8;}else{_0x4c672f=0xce;}_0x2e75f8[_0x68fd('0x2d')](_0x4c672f);return _0x2e75f8[_0x68fd('0x33')](_0x68fd('0x34'),_0x41ebc3+'-'+_0x31f156+'/'+_0x5c10db)[_0x68fd('0x2f')](_0x3098e3);}return null;};}function patchUpdates(_0x49dddf){return function(_0x2d9406){try{jsonpatch[_0x68fd('0x35')](_0x2d9406,_0x49dddf,!![]);}catch(_0x4c6432){return BPromise[_0x68fd('0x36')](_0x4c6432);}return _0x2d9406[_0x68fd('0x37')]();};}function saveUpdates(_0x47080e,_0x5d8ad1){return function(_0x556f67){if(_0x556f67){return _0x556f67[_0x68fd('0x38')](_0x47080e)['then'](function(_0x2215ce){return _0x2215ce;});}return null;};}function removeEntity(_0x42a463,_0x418e97){return function(_0x9a32fb){if(_0x9a32fb){return _0x9a32fb[_0x68fd('0x39')]()['then'](function(){var _0x34a188=_0x9a32fb[_0x68fd('0x3a')]({'plain':!![]});var _0x185116='ChatWebsites';return db[_0x68fd('0x3b')][_0x68fd('0x39')]({'where':{'type':_0x185116,'resourceId':_0x34a188['id']}})['then'](function(){return _0x9a32fb;});})[_0x68fd('0x3c')](function(){_0x42a463[_0x68fd('0x2d')](0xcc)[_0x68fd('0x2e')]();});}};}function handleEntityNotFound(_0x2746a3,_0x4b5819){return function(_0x4789cf){if(!_0x4789cf){_0x2746a3[_0x68fd('0x2c')](0x194);}return _0x4789cf;};}function handleError(_0x545197,_0x34bbf8){_0x34bbf8=_0x34bbf8||0x1f4;return function(_0x594409){logger[_0x68fd('0x28')](_0x594409['stack']);if(_0x594409['name']){delete _0x594409['name'];}_0x545197[_0x68fd('0x2d')](_0x34bbf8)[_0x68fd('0x3d')](_0x594409);};}exports[_0x68fd('0x3e')]=function(_0x4db35d,_0x231c9d){var _0x2c3cd2={'include':[{'model':db[_0x68fd('0x3f')],'as':_0x68fd('0x40')}]},_0x1410b3={},_0x1baa06={'count':0x0,'rows':[]};var _0x4ffd6e=_[_0x68fd('0x41')](db[_0x68fd('0x42')][_0x68fd('0x43')],function(_0x36c134){return{'name':_0x36c134[_0x68fd('0x44')],'type':_0x36c134[_0x68fd('0x45')][_0x68fd('0x46')]};});_0x1410b3['model']=_[_0x68fd('0x41')](_0x4ffd6e,_0x68fd('0x47'));_0x1410b3['query']=_[_0x68fd('0x48')](_0x4db35d['query']);_0x1410b3[_0x68fd('0x49')]=_[_0x68fd('0x4a')](_0x1410b3[_0x68fd('0x4b')],_0x1410b3[_0x68fd('0x4c')]);_0x2c3cd2[_0x68fd('0x4d')]=_[_0x68fd('0x4a')](_0x1410b3[_0x68fd('0x4b')],qs[_0x68fd('0x4e')](_0x4db35d[_0x68fd('0x4c')][_0x68fd('0x4e')]));_0x2c3cd2['attributes']=_0x2c3cd2[_0x68fd('0x4d')][_0x68fd('0x4f')]?_0x2c3cd2['attributes']:_0x1410b3[_0x68fd('0x4b')];if(!_0x4db35d['query'][_0x68fd('0x50')](_0x68fd('0x51'))){_0x2c3cd2[_0x68fd('0x32')]=qs[_0x68fd('0x32')](_0x4db35d[_0x68fd('0x4c')][_0x68fd('0x32')]);_0x2c3cd2['offset']=qs[_0x68fd('0x31')](_0x4db35d['query'][_0x68fd('0x31')]);}_0x2c3cd2[_0x68fd('0x52')]=qs[_0x68fd('0x53')](_0x4db35d['query'][_0x68fd('0x53')]);_0x2c3cd2['where']=qs[_0x68fd('0x49')](_[_0x68fd('0x54')](_0x4db35d[_0x68fd('0x4c')],_0x1410b3[_0x68fd('0x49')]),_0x4ffd6e);if(_0x4db35d['query']['filter']){_0x2c3cd2[_0x68fd('0x55')]=_[_0x68fd('0x56')](_0x2c3cd2[_0x68fd('0x55')],{'$or':_[_0x68fd('0x41')](_0x4ffd6e,function(_0x209408){if(_0x209408['type']!==_0x68fd('0x57')){var _0x19e7bf={};_0x19e7bf[_0x209408[_0x68fd('0x47')]]={'$like':'%'+_0x4db35d[_0x68fd('0x4c')][_0x68fd('0x58')]+'%'};return _0x19e7bf;}})});}_0x2c3cd2=_['merge']({},_0x2c3cd2,_0x4db35d[_0x68fd('0x59')]);var _0x37782f={'where':_0x2c3cd2[_0x68fd('0x55')]};return db[_0x68fd('0x42')][_0x68fd('0x30')](_0x37782f)['then'](function(_0x578771){_0x1baa06[_0x68fd('0x30')]=_0x578771;if(_0x4db35d[_0x68fd('0x4c')][_0x68fd('0x5a')]){_0x2c3cd2[_0x68fd('0x5b')]=[{'all':!![]}];}return db['ChatWebsite'][_0x68fd('0x5c')](_0x2c3cd2);})[_0x68fd('0x3c')](function(_0x18fa4a){_0x1baa06[_0x68fd('0x5d')]=_0x18fa4a;return _0x1baa06;})[_0x68fd('0x3c')](respondWithFilteredResult(_0x231c9d,_0x2c3cd2))[_0x68fd('0x2b')](handleError(_0x231c9d,null));};exports[_0x68fd('0x5e')]=function(_0x5c4bee,_0x469e9a){var _0x513fd7={'raw':![],'where':{'id':_0x5c4bee[_0x68fd('0x5f')]['id']},'include':[{'model':db[_0x68fd('0x3f')],'as':_0x68fd('0x40')}]},_0x36a3df={};_0x36a3df[_0x68fd('0x4b')]=_['keys'](db[_0x68fd('0x42')][_0x68fd('0x43')]);_0x36a3df[_0x68fd('0x4c')]=_[_0x68fd('0x48')](_0x5c4bee[_0x68fd('0x4c')]);_0x36a3df[_0x68fd('0x49')]=_['intersection'](_0x36a3df[_0x68fd('0x4b')],_0x36a3df['query']);_0x513fd7[_0x68fd('0x4d')]=_[_0x68fd('0x4a')](_0x36a3df[_0x68fd('0x4b')],qs['fields'](_0x5c4bee[_0x68fd('0x4c')][_0x68fd('0x4e')]));_0x513fd7[_0x68fd('0x4d')]=_0x513fd7['attributes'][_0x68fd('0x4f')]?_0x513fd7[_0x68fd('0x4d')]:_0x36a3df[_0x68fd('0x4b')];if(_0x5c4bee[_0x68fd('0x4c')][_0x68fd('0x5a')]){_0x513fd7[_0x68fd('0x5b')]=[{'all':!![]}];}_0x513fd7=_[_0x68fd('0x56')]({},_0x513fd7,_0x5c4bee['options']);return db[_0x68fd('0x42')][_0x68fd('0x60')](_0x513fd7)[_0x68fd('0x3c')](handleEntityNotFound(_0x469e9a,null))[_0x68fd('0x3c')](respondWithResult(_0x469e9a,null))['catch'](handleError(_0x469e9a,null));};exports['create']=function(_0x242316,_0x5bfd9b){return db[_0x68fd('0x42')][_0x68fd('0x61')](_0x242316[_0x68fd('0x62')],{})[_0x68fd('0x3c')](function(_0x3cf37f){var _0x4edc48=_0x242316['user'][_0x68fd('0x3a')]({'plain':!![]});if(!_0x4edc48)throw new Error(_0x68fd('0x63'));if(_0x4edc48['role']==='user'){var _0x41bdd3=_0x3cf37f[_0x68fd('0x3a')]({'plain':!![]});var _0x5e1873=_0x68fd('0x64');return db[_0x68fd('0x65')]['find']({'where':{'name':_0x5e1873,'userProfileId':_0x4edc48['userProfileId']},'raw':!![]})[_0x68fd('0x3c')](function(_0xf14c3c){if(_0xf14c3c&&_0xf14c3c[_0x68fd('0x66')]===0x0){return db[_0x68fd('0x3b')]['create']({'name':_0x41bdd3['name'],'resourceId':_0x41bdd3['id'],'type':_0xf14c3c[_0x68fd('0x47')],'sectionId':_0xf14c3c['id']},{})['then'](function(){return _0x3cf37f;});}else{return _0x3cf37f;}})[_0x68fd('0x2b')](function(_0x4c0f72){logger[_0x68fd('0x28')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x4c0f72);throw _0x4c0f72;});}return _0x3cf37f;})[_0x68fd('0x3c')](respondWithResult(_0x5bfd9b,0xc9))[_0x68fd('0x2b')](handleError(_0x5bfd9b,null));};exports[_0x68fd('0x38')]=function(_0x5f1d17,_0x5854e9){if(_0x5f1d17[_0x68fd('0x62')]['id']){delete _0x5f1d17[_0x68fd('0x62')]['id'];}return db[_0x68fd('0x42')][_0x68fd('0x60')]({'where':{'id':_0x5f1d17[_0x68fd('0x5f')]['id']},'include':[{'model':db[_0x68fd('0x3f')],'as':_0x68fd('0x40')}]})[_0x68fd('0x3c')](handleEntityNotFound(_0x5854e9,null))[_0x68fd('0x3c')](saveUpdates(_0x5f1d17[_0x68fd('0x62')],null))['then'](respondWithResult(_0x5854e9,null))['catch'](handleError(_0x5854e9,null));};exports[_0x68fd('0x39')]=function(_0x253ce4,_0x106810){return db[_0x68fd('0x42')][_0x68fd('0x60')]({'where':{'id':_0x253ce4[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x106810,null))[_0x68fd('0x3c')](removeEntity(_0x106810,null))[_0x68fd('0x2b')](handleError(_0x106810,null));};exports['describe']=function(_0x39eb87,_0x422aab){return db[_0x68fd('0x42')][_0x68fd('0x67')]()[_0x68fd('0x3c')](respondWithResult(_0x422aab,null))[_0x68fd('0x2b')](handleError(_0x422aab,null));};exports[_0x68fd('0x68')]=function(_0x14d7b7,_0x7f9527,_0x59e758){if(_0x14d7b7['body']['id']){delete _0x14d7b7['body']['id'];}return db[_0x68fd('0x42')][_0x68fd('0x60')]({'where':{'id':_0x14d7b7[_0x68fd('0x5f')]['id']}})['then'](handleEntityNotFound(_0x7f9527,null))['then'](function(_0x2c2572){if(_0x2c2572){_0x14d7b7[_0x68fd('0x62')][_0x68fd('0x69')]=_0x2c2572['id'];return db[_0x68fd('0x6a')][_0x68fd('0x61')](_0x14d7b7[_0x68fd('0x62')]);}})['then'](respondWithResult(_0x7f9527,null))[_0x68fd('0x2b')](handleError(_0x7f9527,null));};exports['getDispositions']=function(_0x29008c,_0x56e808,_0x1a5c2b){var _0x2a9651={'raw':![],'where':{}};var _0x288b15={};var _0x5757c5={'count':0x0,'rows':[]};return db[_0x68fd('0x42')][_0x68fd('0x6b')]({'where':{'id':_0x29008c[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x56e808,null))[_0x68fd('0x3c')](function(_0x37f081){if(_0x37f081){_0x288b15[_0x68fd('0x4b')]=_[_0x68fd('0x48')](db['Disposition'][_0x68fd('0x43')]);_0x288b15[_0x68fd('0x4c')]=_[_0x68fd('0x48')](_0x29008c['query']);_0x288b15[_0x68fd('0x49')]=_[_0x68fd('0x4a')](_0x288b15[_0x68fd('0x4b')],_0x288b15[_0x68fd('0x4c')]);_0x2a9651[_0x68fd('0x4d')]=_['intersection'](_0x288b15[_0x68fd('0x4b')],qs[_0x68fd('0x4e')](_0x29008c[_0x68fd('0x4c')][_0x68fd('0x4e')]));_0x2a9651[_0x68fd('0x4d')]=_0x2a9651[_0x68fd('0x4d')][_0x68fd('0x4f')]?_0x2a9651[_0x68fd('0x4d')]:_0x288b15[_0x68fd('0x4b')];if(!_0x29008c[_0x68fd('0x4c')][_0x68fd('0x50')](_0x68fd('0x51'))){_0x2a9651[_0x68fd('0x32')]=qs[_0x68fd('0x32')](_0x29008c[_0x68fd('0x4c')]['limit']);_0x2a9651['offset']=qs[_0x68fd('0x31')](_0x29008c[_0x68fd('0x4c')][_0x68fd('0x31')]);}_0x2a9651['order']=qs[_0x68fd('0x53')](_0x29008c[_0x68fd('0x4c')][_0x68fd('0x53')]);_0x2a9651[_0x68fd('0x55')]=qs[_0x68fd('0x49')](_['pick'](_0x29008c[_0x68fd('0x4c')],_0x288b15['filters']));_0x2a9651[_0x68fd('0x55')][_0x68fd('0x69')]=_0x37f081['id'];if(_0x29008c[_0x68fd('0x4c')][_0x68fd('0x58')]){_0x2a9651[_0x68fd('0x55')]=_[_0x68fd('0x56')](_0x2a9651[_0x68fd('0x55')],{'$or':_[_0x68fd('0x41')](_0x2a9651[_0x68fd('0x4d')],function(_0x2f2eb6){var _0x343458={};_0x343458[_0x2f2eb6]={'$like':'%'+_0x29008c[_0x68fd('0x4c')][_0x68fd('0x58')]+'%'};return _0x343458;})});}_0x2a9651=_[_0x68fd('0x56')]({},_0x2a9651,_0x29008c[_0x68fd('0x59')]);return db[_0x68fd('0x6a')][_0x68fd('0x30')]({'where':_0x2a9651[_0x68fd('0x55')]})['then'](function(_0x5b9c4c){_0x5757c5['count']=_0x5b9c4c;if(_0x29008c[_0x68fd('0x4c')][_0x68fd('0x5a')]){_0x2a9651['include']=[{'all':!![]}];}return db['Disposition'][_0x68fd('0x5c')](_0x2a9651);})[_0x68fd('0x3c')](function(_0x27ba7b){_0x5757c5['rows']=_0x27ba7b;return _0x5757c5;});}})[_0x68fd('0x3c')](respondWithFilteredResult(_0x56e808,_0x2a9651))[_0x68fd('0x2b')](handleError(_0x56e808,null));};exports[_0x68fd('0x6c')]=function(_0x24b375,_0x4151e5,_0x1247b3){return db[_0x68fd('0x42')]['find']({'where':{'id':_0x24b375[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x4151e5,null))[_0x68fd('0x3c')](function(_0x36b78f){if(_0x36b78f){return _0x36b78f['removeDispositions'](_0x24b375['query'][_0x68fd('0x6d')]);}})[_0x68fd('0x3c')](respondWithStatusCode(_0x4151e5,null))[_0x68fd('0x2b')](handleError(_0x4151e5,null));};exports[_0x68fd('0x6e')]=function(_0x425fe5,_0x161fce,_0x801e6a){if(_0x425fe5['body']['id']){delete _0x425fe5[_0x68fd('0x62')]['id'];}return db[_0x68fd('0x42')][_0x68fd('0x60')]({'where':{'id':_0x425fe5[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x161fce,null))[_0x68fd('0x3c')](function(_0xf2287e){if(_0xf2287e){_0x425fe5[_0x68fd('0x62')][_0x68fd('0x69')]=_0xf2287e['id'];return db[_0x68fd('0x6f')][_0x68fd('0x61')](_0x425fe5[_0x68fd('0x62')]);}})[_0x68fd('0x3c')](respondWithResult(_0x161fce,null))[_0x68fd('0x2b')](handleError(_0x161fce,null));};exports[_0x68fd('0x70')]=function(_0x33b826,_0x4c7bd5,_0x1b18c4){var _0x4cb9a2={'raw':![],'where':{}};var _0x26557f={};var _0x3c1f04={'count':0x0,'rows':[]};return db[_0x68fd('0x42')]['findOne']({'where':{'id':_0x33b826['params']['id']}})['then'](handleEntityNotFound(_0x4c7bd5,null))[_0x68fd('0x3c')](function(_0x4d88f7){if(_0x4d88f7){_0x26557f[_0x68fd('0x4b')]=_[_0x68fd('0x48')](db[_0x68fd('0x6f')][_0x68fd('0x43')]);_0x26557f[_0x68fd('0x4c')]=_[_0x68fd('0x48')](_0x33b826[_0x68fd('0x4c')]);_0x26557f['filters']=_[_0x68fd('0x4a')](_0x26557f['model'],_0x26557f['query']);_0x4cb9a2[_0x68fd('0x4d')]=_[_0x68fd('0x4a')](_0x26557f['model'],qs[_0x68fd('0x4e')](_0x33b826[_0x68fd('0x4c')][_0x68fd('0x4e')]));_0x4cb9a2[_0x68fd('0x4d')]=_0x4cb9a2[_0x68fd('0x4d')][_0x68fd('0x4f')]?_0x4cb9a2['attributes']:_0x26557f[_0x68fd('0x4b')];if(!_0x33b826[_0x68fd('0x4c')][_0x68fd('0x50')]('nolimit')){_0x4cb9a2['limit']=qs[_0x68fd('0x32')](_0x33b826['query']['limit']);_0x4cb9a2[_0x68fd('0x31')]=qs[_0x68fd('0x31')](_0x33b826[_0x68fd('0x4c')][_0x68fd('0x31')]);}_0x4cb9a2[_0x68fd('0x52')]=qs[_0x68fd('0x53')](_0x33b826[_0x68fd('0x4c')][_0x68fd('0x53')]);_0x4cb9a2[_0x68fd('0x55')]=qs['filters'](_[_0x68fd('0x54')](_0x33b826[_0x68fd('0x4c')],_0x26557f[_0x68fd('0x49')]));_0x4cb9a2[_0x68fd('0x55')][_0x68fd('0x69')]=_0x4d88f7['id'];if(_0x33b826[_0x68fd('0x4c')][_0x68fd('0x58')]){_0x4cb9a2[_0x68fd('0x55')]=_[_0x68fd('0x56')](_0x4cb9a2[_0x68fd('0x55')],{'$or':_[_0x68fd('0x41')](_0x4cb9a2[_0x68fd('0x4d')],function(_0x160d26){var _0x3cb097={};_0x3cb097[_0x160d26]={'$like':'%'+_0x33b826[_0x68fd('0x4c')]['filter']+'%'};return _0x3cb097;})});}_0x4cb9a2=_[_0x68fd('0x56')]({},_0x4cb9a2,_0x33b826[_0x68fd('0x59')]);return db[_0x68fd('0x6f')][_0x68fd('0x30')]({'where':_0x4cb9a2[_0x68fd('0x55')]})[_0x68fd('0x3c')](function(_0x21c767){_0x3c1f04[_0x68fd('0x30')]=_0x21c767;if(_0x33b826[_0x68fd('0x4c')][_0x68fd('0x5a')]){_0x4cb9a2[_0x68fd('0x5b')]=[{'all':!![]}];}return db['CannedAnswer'][_0x68fd('0x5c')](_0x4cb9a2);})[_0x68fd('0x3c')](function(_0x4d54e4){_0x3c1f04[_0x68fd('0x5d')]=_0x4d54e4;return _0x3c1f04;});}})[_0x68fd('0x3c')](respondWithFilteredResult(_0x4c7bd5,_0x4cb9a2))[_0x68fd('0x2b')](handleError(_0x4c7bd5,null));};exports[_0x68fd('0x71')]=function(_0x2fa8f7,_0x1317ac,_0x3221cb){return db['ChatWebsite'][_0x68fd('0x60')]({'where':{'id':_0x2fa8f7[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x1317ac,null))[_0x68fd('0x3c')](function(_0x302bf9){if(_0x302bf9){return _0x302bf9[_0x68fd('0x71')](_0x2fa8f7[_0x68fd('0x4c')]['ids']);}})[_0x68fd('0x3c')](respondWithStatusCode(_0x1317ac,null))[_0x68fd('0x2b')](handleError(_0x1317ac,null));};exports[_0x68fd('0x72')]=function(_0x3a40ff,_0x2ae38a,_0x48cfd9){_0x3a40ff[_0x68fd('0x62')][_0x68fd('0x73')]=_0x3a40ff['file'][_0x68fd('0x74')];return db['ChatWebsite'][_0x68fd('0x60')]({'where':{'id':_0x3a40ff[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x2ae38a,null))[_0x68fd('0x3c')](saveUpdates(_0x3a40ff[_0x68fd('0x62')],null))[_0x68fd('0x3c')](respondWithResult(_0x2ae38a,null))[_0x68fd('0x2b')](handleError(_0x2ae38a,null));};exports[_0x68fd('0x75')]=function(_0x31ee6f,_0x38cd51,_0x182ebf){_0x31ee6f[_0x68fd('0x62')][_0x68fd('0x76')]=_0x31ee6f[_0x68fd('0x77')]['filename'];return db[_0x68fd('0x42')][_0x68fd('0x60')]({'where':{'id':_0x31ee6f[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x38cd51,null))[_0x68fd('0x3c')](saveUpdates(_0x31ee6f[_0x68fd('0x62')],null))[_0x68fd('0x3c')](respondWithResult(_0x38cd51,null))[_0x68fd('0x2b')](handleError(_0x38cd51,null));};exports['addCustomerAvatar']=function(_0x582c2a,_0x1b863b,_0x91a200){_0x582c2a[_0x68fd('0x62')]['customerAvatar']=_0x582c2a['file'][_0x68fd('0x74')];return db['ChatWebsite'][_0x68fd('0x60')]({'where':{'id':_0x582c2a[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x1b863b,null))[_0x68fd('0x3c')](saveUpdates(_0x582c2a[_0x68fd('0x62')],null))['then'](respondWithResult(_0x1b863b,null))[_0x68fd('0x2b')](handleError(_0x1b863b,null));};exports[_0x68fd('0x78')]=function(_0x5ee1d4,_0x310357,_0x2e9312){_0x5ee1d4[_0x68fd('0x62')][_0x68fd('0x79')]=_0x5ee1d4[_0x68fd('0x77')][_0x68fd('0x74')];return db['ChatWebsite']['find']({'where':{'id':_0x5ee1d4[_0x68fd('0x5f')]['id']}})['then'](handleEntityNotFound(_0x310357,null))[_0x68fd('0x3c')](saveUpdates(_0x5ee1d4[_0x68fd('0x62')],null))[_0x68fd('0x3c')](respondWithResult(_0x310357,null))[_0x68fd('0x2b')](handleError(_0x310357,null));};exports[_0x68fd('0x7a')]=function(_0x491a04,_0x4f50da,_0x2c6540){var _0x195e04=path[_0x68fd('0x7b')](config[_0x68fd('0x7c')],_0x68fd('0x7d'));var _0xc99c7={'where':{'id':_0x491a04[_0x68fd('0x5f')]['id']},'attributes':['id',_0x68fd('0x73')],'raw':!![]};var _0x5711b1=![];return require(_0x68fd('0x18'))[_0x68fd('0x7e')]()[_0x68fd('0x3c')](function(_0x465120){if(_0x465120){_0x5711b1=_0x465120[_0x68fd('0x7f')];}})[_0x68fd('0x3c')](function(){return db[_0x68fd('0x42')]['find'](_0xc99c7);})[_0x68fd('0x3c')](handleEntityNotFound(_0x4f50da,null))[_0x68fd('0x3c')](function(_0x328185){if(_0x328185){if(!_[_0x68fd('0x80')](_0x328185[_0x68fd('0x73')])){if(fs['existsSync'](path[_0x68fd('0x7b')](config[_0x68fd('0x7c')],'server/files/images/logos/',_0x328185[_0x68fd('0x73')]))&&_0x5711b1){_0x195e04=path[_0x68fd('0x7b')](config[_0x68fd('0x7c')],'server/files/images/logos/',_0x328185[_0x68fd('0x73')]);}}return _0x4f50da['download'](_0x195e04);}})[_0x68fd('0x2b')](handleError(_0x4f50da,null));};exports[_0x68fd('0x81')]=function(_0x582394,_0x5bf5f7,_0x3a4af0){var _0x9a5a2f=path['join'](config[_0x68fd('0x7c')],_0x68fd('0x82'));var _0x12189c={'where':{'id':_0x582394[_0x68fd('0x5f')]['id']},'attributes':['id',_0x68fd('0x76')],'raw':!![]};return db['ChatWebsite'][_0x68fd('0x60')](_0x12189c)[_0x68fd('0x3c')](handleEntityNotFound(_0x5bf5f7,null))[_0x68fd('0x3c')](function(_0xc429a){if(_0xc429a){if(!_[_0x68fd('0x80')](_0xc429a[_0x68fd('0x76')])){if(fs[_0x68fd('0x83')](path[_0x68fd('0x7b')](config[_0x68fd('0x7c')],_0x68fd('0x84'),_0xc429a[_0x68fd('0x76')]))){_0x9a5a2f=path[_0x68fd('0x7b')](config[_0x68fd('0x7c')],'server/files/images/avatars/',_0xc429a['agentAvatar']);}}return _0x5bf5f7['download'](_0x9a5a2f);}})[_0x68fd('0x2b')](handleError(_0x5bf5f7,null));};exports[_0x68fd('0x85')]=function(_0x55b1a4,_0x5e762f,_0x582921){var _0x4e91ac=path[_0x68fd('0x7b')](config['root'],_0x68fd('0x86'));var _0x2a1938={'where':{'id':_0x55b1a4[_0x68fd('0x5f')]['id']},'attributes':['id',_0x68fd('0x87'),_0x68fd('0x88')],'raw':!![]};return db[_0x68fd('0x42')][_0x68fd('0x60')](_0x2a1938)[_0x68fd('0x3c')](handleEntityNotFound(_0x5e762f,null))['then'](function(_0x2d4a70){if(_0x2d4a70){if(!_[_0x68fd('0x80')](_0x2d4a70[_0x68fd('0x87')])){if(fs['existsSync'](path[_0x68fd('0x7b')](config[_0x68fd('0x7c')],'server/files/images/avatars/',_0x2d4a70[_0x68fd('0x87')]))&&_0x2d4a70[_0x68fd('0x88')]){_0x4e91ac=path['join'](config[_0x68fd('0x7c')],_0x68fd('0x84'),_0x2d4a70[_0x68fd('0x87')]);}}return _0x5e762f[_0x68fd('0x89')](_0x4e91ac);}})[_0x68fd('0x2b')](handleError(_0x5e762f,null));};exports[_0x68fd('0x8a')]=function(_0x5695f1,_0x5e8cb7,_0x4a180f){var _0x5fa513=path[_0x68fd('0x7b')](config[_0x68fd('0x7c')],'server/files/images/avatars/system_avatar.png');var _0x45fc9b={'where':{'id':_0x5695f1[_0x68fd('0x5f')]['id']},'attributes':['id',_0x68fd('0x79')],'raw':!![]};return db[_0x68fd('0x42')]['find'](_0x45fc9b)[_0x68fd('0x3c')](handleEntityNotFound(_0x5e8cb7,null))[_0x68fd('0x3c')](function(_0x558fa2){if(_0x558fa2){if(!_[_0x68fd('0x80')](_0x558fa2['systemAvatar'])){if(fs[_0x68fd('0x83')](path[_0x68fd('0x7b')](config[_0x68fd('0x7c')],_0x68fd('0x84'),_0x558fa2[_0x68fd('0x79')]))){_0x5fa513=path[_0x68fd('0x7b')](config[_0x68fd('0x7c')],_0x68fd('0x84'),_0x558fa2[_0x68fd('0x79')]);}}return _0x5e8cb7[_0x68fd('0x89')](_0x5fa513);}})[_0x68fd('0x2b')](handleError(_0x5e8cb7,null));};exports['notify']=function(_0xd8257f,_0x1a91d2,_0x1b1735){var _0x3cb175=require(_0x68fd('0x8b'));var _0x3e8905=new _0x3cb175();var _0x5bdd31=_0x3e8905[_0x68fd('0x8c')](_0xd8257f[_0x68fd('0x8d')][_0x68fd('0x8e')])[_0x68fd('0x8f')]();var _0x41722e={'body':_0xd8257f[_0x68fd('0x62')],'channel':'chat'};var _0x4e2a21=[];var _0x18fae7=[];var _0x20b269={};var _0x1e3568=![];return db[_0x68fd('0x90')][_0x68fd('0x67')]()['then'](function(_0xedb4b){if(!_0xedb4b){throw new db[(_0x68fd('0x91'))][(_0x68fd('0x92'))](_0x68fd('0x93'));}_0x4e2a21=_['difference'](_[_0x68fd('0x48')](_0xedb4b),[_0x68fd('0x94'),_0x68fd('0x95')]);_0x18fae7=_[_0x68fd('0x96')](_[_0x68fd('0x48')](_0xedb4b),[_0x68fd('0x94'),_0x68fd('0x95'),'CompanyId','ListId']);if(_0xd8257f['body']['id']){delete _0xd8257f[_0x68fd('0x62')]['id'];}if(_[_0x68fd('0x80')](_0xd8257f[_0x68fd('0x62')][_0x68fd('0x97')])){throw new db[(_0x68fd('0x91'))][(_0x68fd('0x92'))](_0x68fd('0x98'));}if(_[_0x68fd('0x80')](_0xd8257f[_0x68fd('0x62')]['body'])||_0xd8257f['body'][_0x68fd('0x62')]===''){throw new db[(_0x68fd('0x91'))][(_0x68fd('0x92'))](_0x68fd('0x99'));}if(_[_0x68fd('0x80')](_0xd8257f[_0x68fd('0x62')]['mapKey'])){throw new db[(_0x68fd('0x91'))][(_0x68fd('0x92'))](_0x68fd('0x9a')+_0x18fae7);}if(!_[_0x68fd('0x9b')](_0x18fae7,_0xd8257f[_0x68fd('0x62')][_0x68fd('0x9c')])){throw new db[(_0x68fd('0x91'))][(_0x68fd('0x92'))](_0x68fd('0x9d')+_0x18fae7);}_0x20b269[_0xd8257f[_0x68fd('0x62')]['mapKey']]=_0xd8257f[_0x68fd('0x62')]['from'];})[_0x68fd('0x3c')](function(){return db[_0x68fd('0x42')]['find']({'where':{'id':_0xd8257f[_0x68fd('0x5f')]['id']},'include':[{'model':db['CmList'],'as':_0x68fd('0x9e'),'include':[{'model':db['CmContact'],'as':_0x68fd('0x9f'),'where':_0x20b269,'limit':0x1,'order':[['updatedAt',_0x68fd('0xa0')]]}]},{'model':db['ChatApplication'],'as':_0x68fd('0xa1')}]});})[_0x68fd('0x3c')](handleEntityNotFound(_0x1a91d2,null))[_0x68fd('0x3c')](function(_0x3ae2e5){if(_0x3ae2e5&&_0x3ae2e5[_0x68fd('0x9e')]){_0x41722e['account']=_0x3ae2e5;_0x41722e['applications']=_0x3ae2e5[_0x68fd('0xa1')];_0x41722e[_0x68fd('0xa2')]=_0x3ae2e5['List'];_0x41722e['applications']=_[_0x68fd('0xa3')](_0x41722e[_0x68fd('0xa4')],['priority'],[_0x68fd('0xa5')]);if(_0x41722e[_0x68fd('0xa6')][_0x68fd('0xa1')]){delete _0x41722e[_0x68fd('0xa6')][_0x68fd('0xa1')];}if(_0x41722e[_0x68fd('0xa6')][_0x68fd('0x9e')]&&_0x41722e[_0x68fd('0xa6')][_0x68fd('0x9e')][_0x68fd('0x9f')][_0x68fd('0x4f')]){return _0x41722e[_0x68fd('0xa6')][_0x68fd('0x9e')][_0x68fd('0x9f')][0x0];}var _0xb1d5b0=_[_0x68fd('0x1a')](_0xd8257f['body'],{'firstName':_0xd8257f['body'][_0x68fd('0x97')],'ListId':_0x3ae2e5[_0x68fd('0xa7')]});_0xb1d5b0[_0xd8257f[_0x68fd('0x62')][_0x68fd('0x9c')]]=_0xd8257f[_0x68fd('0x62')][_0x68fd('0x97')];return db[_0x68fd('0x90')]['create'](_0xb1d5b0,{'fields':_0x4e2a21,'raw':!![]});}})[_0x68fd('0x3c')](handleEntityNotFound(_0x1a91d2,null))['then'](function(_0x6f77f6){_0x41722e[_0x68fd('0xa8')]=_0x6f77f6;var _0x4fac7e=_0xd8257f[_0x68fd('0x62')]['customerIp'];if(_0xd8257f['headers'][_0x68fd('0xa9')]){_0x4fac7e=_0xd8257f[_0x68fd('0x8d')][_0x68fd('0xa9')];}else if(_0xd8257f[_0x68fd('0x8d')][_0x68fd('0xaa')]){_0x4fac7e=_[_0x68fd('0xab')](_0xd8257f[_0x68fd('0x8d')][_0x68fd('0xaa')][_0x68fd('0xac')](','));}if(_0x6f77f6){var _0x277160={'ContactId':_0x6f77f6['id'],'ChatWebsiteId':_0xd8257f[_0x68fd('0x5f')]['id'],'from':(_0x6f77f6[_0x68fd('0xad')]||'')+'\x20'+(_0x6f77f6[_0x68fd('0xae')]||''),'customerIp':_0x4fac7e,'customerPort':_0xd8257f[_0x68fd('0x8d')][_0x68fd('0xaf')]?_0xd8257f[_0x68fd('0x8d')][_0x68fd('0xaf')]:null,'referer':_0xd8257f[_0x68fd('0x62')][_0x68fd('0xb0')],'browserName':_0x5bdd31[_0x68fd('0xb1')][_0x68fd('0x47')]&&_0x5bdd31[_0x68fd('0xb1')][_0x68fd('0xb2')]?util[_0x68fd('0xb3')](_0x68fd('0xb4'),_0x5bdd31[_0x68fd('0xb1')][_0x68fd('0x47')],_0x5bdd31[_0x68fd('0xb1')][_0x68fd('0xb2')]):_0x68fd('0xb5'),'browserVersion':_0x5bdd31[_0x68fd('0xb1')]['version']||_0x68fd('0xb5'),'osName':util['format'](_0x68fd('0xb4'),_0x5bdd31['os'][_0x68fd('0x47')],_0x5bdd31['os']['version']),'osVersion':_0x5bdd31['os'][_0x68fd('0xb2')],'deviceModel':_0x5bdd31[_0x68fd('0xb6')][_0x68fd('0x4b')]&&_0x5bdd31['device'][_0x68fd('0xb7')]?util[_0x68fd('0xb3')](_0x68fd('0xb8'),_0x5bdd31[_0x68fd('0xb6')][_0x68fd('0x4b')],_0x5bdd31[_0x68fd('0xb6')]['vendor'],_0x5bdd31[_0x68fd('0xb6')][_0x68fd('0x45')]):null,'deviceVendor':_0x5bdd31[_0x68fd('0xb6')][_0x68fd('0xb7')],'deviceType':_0x5bdd31[_0x68fd('0xb6')][_0x68fd('0x45')],'formData':JSON[_0x68fd('0x27')](_0xd8257f['body'])};var _0x55aca7={'ChatWebsiteId':_0xd8257f[_0x68fd('0x5f')]['id'],'closed':![]};if(_0xd8257f['body'][_0x68fd('0xb9')]){_0x55aca7[_0x68fd('0xb9')]=_0xd8257f[_0x68fd('0x62')][_0x68fd('0xb9')];return db[_0x68fd('0xba')][_0x68fd('0x60')]({'where':_0x55aca7})[_0x68fd('0x3c')](function(_0x57fff3){if(_0x57fff3){return[_0x57fff3,![]];}_0x277160[_0x68fd('0xb9')]=_0xd8257f[_0x68fd('0x62')][_0x68fd('0xb9')];_0x277160[_0x68fd('0xbb')]=_0xd8257f['body'][_0x68fd('0xbb')];return db[_0x68fd('0xba')][_0x68fd('0x61')](_0x277160)[_0x68fd('0x3c')](function(_0x27630f){return[_0x27630f,!![]];});});}_0x55aca7['ContactId']=_0x6f77f6['id'];if(_0xd8257f['body'][_0x68fd('0xbc')]&&_0xd8257f[_0x68fd('0x62')]['interaction']['id']){_0x55aca7['id']=_0xd8257f[_0x68fd('0x62')][_0x68fd('0xbc')]['id'];return db[_0x68fd('0xba')][_0x68fd('0x60')]({'where':_0x55aca7})[_0x68fd('0x3c')](function(_0x4772b1){if(_0x4772b1){return[_0x4772b1,![]];}return db[_0x68fd('0xba')][_0x68fd('0x61')](_0x277160)['then'](function(_0x10f79d){return[_0x10f79d,!![]];});});}return db['ChatInteraction'][_0x68fd('0x61')](_0x277160)[_0x68fd('0x3c')](function(_0xa0ecd7){return[_0xa0ecd7,!![]];});}})[_0x68fd('0xbd')](function(_0x56a67d,_0xbe131){if(_0x56a67d){_0x1e3568=_0xbe131;if(!_0xbe131){var _0x42d1d5={'from':(_0x41722e[_0x68fd('0xa8')][_0x68fd('0xad')]||'')+'\x20'+(_0x41722e['contact'][_0x68fd('0xae')]||'')};if(_0xd8257f['body'][_0x68fd('0xb9')]&&_0xd8257f[_0x68fd('0x62')][_0x68fd('0xbe')]&&_0xd8257f[_0x68fd('0x62')][_0x68fd('0xb9')]!=_0xd8257f[_0x68fd('0x62')][_0x68fd('0xbe')]){_0x42d1d5['threadId']=_0xd8257f[_0x68fd('0x62')][_0x68fd('0xbe')];}return _0x56a67d[_0x68fd('0x38')](_0x42d1d5);}else{return _0x56a67d;}}})[_0x68fd('0x3c')](function(_0x27ac53){_0x41722e[_0x68fd('0xbc')]=_0x27ac53['get']({'plain':!![]});_0x41722e[_0x68fd('0xbc')][_0x68fd('0xbf')]=_0x1e3568;if(_0x41722e[_0x68fd('0xbc')][_0x68fd('0xbf')]){if(_0x41722e[_0x68fd('0xa6')]['autoclose']){_0x41722e['applications'][_0x68fd('0xc0')]({'id':0x0,'priority':_0x41722e[_0x68fd('0xa4')][_0x68fd('0x4f')]+0x1,'app':_0x68fd('0xc1'),'appdata':_0x68fd('0xc2'),'interval':_0x68fd('0xc3')});}}return db[_0x68fd('0xc4')][_0x68fd('0x61')]({'body':_0xd8257f[_0x68fd('0x62')][_0x68fd('0x62')],'ChatWebsiteId':_0xd8257f[_0x68fd('0x5f')]['id'],'ChatInteractionId':_0x27ac53['id'],'direction':'in','ContactId':_0x41722e[_0x68fd('0xa8')]['id'],'AttachmentId':_0xd8257f[_0x68fd('0x62')][_0x68fd('0xc5')]});})[_0x68fd('0x3c')](function(_0x3676db){_0x41722e[_0x68fd('0x29')]=_0x3676db;if(_0x41722e[_0x68fd('0xbc')][_0x68fd('0xc6')]){return db[_0x68fd('0xc7')]['find']({'attributes':['id','name'],'where':{'id':_0x41722e['interaction'][_0x68fd('0xc6')]}})['then'](function(_0x44191a){if(_0x44191a){_0x41722e['applications'][_0x68fd('0xc8')]({'id':0x0,'priority':0x0,'app':_0x68fd('0xc9'),'appdata':_0x44191a[_0x68fd('0x47')]+','+(_0x41722e['account'][_0x68fd('0xca')]||0xa),'interval':_0x68fd('0xc3')});_0x41722e[_0x68fd('0xcb')]=!![];}return respondWithRpcPromise(_0x68fd('0xcc'),_0x68fd('0xcd'),_0x41722e);});}return respondWithRpcPromise(_0x68fd('0xcc'),_0x68fd('0xcd'),_0x41722e);})[_0x68fd('0x3c')](function(_0x112c66){respondWithRpcPromise('EventManager',_0x68fd('0xce'),{'event':_0x68fd('0xcf'),'message':_0x112c66},client9002);return _0x112c66;})[_0x68fd('0x3c')](respondWithResult(_0x1a91d2,null))['catch'](handleError(_0x1a91d2,null));};exports[_0x68fd('0xd0')]=function(_0x125502,_0x4946d4,_0x4e957a){var _0x27680b,_0x50b25c,_0x24204c;var _0x502b0d=[];var _0x34a6ee=[];var _0x2c1f05={};return db[_0x68fd('0x90')]['describe']()[_0x68fd('0x3c')](function(_0x4f938c){if(!_0x4f938c){throw new db[(_0x68fd('0x91'))]['ValidationError'](_0x68fd('0x93'));}_0x34a6ee=_[_0x68fd('0x96')](_['keys'](_0x4f938c),[_0x68fd('0x94'),_0x68fd('0x95')]);_0x502b0d=_[_0x68fd('0x96')](_['keys'](_0x4f938c),['createdAt','updatedAt',_0x68fd('0xd1'),_0x68fd('0xa7')]);if(_0x125502[_0x68fd('0x62')]['id']){delete _0x125502[_0x68fd('0x62')]['id'];}if(_[_0x68fd('0x80')](_0x125502[_0x68fd('0x62')]['from'])){throw _0x4946d4[_0x68fd('0x2d')](0x1f4)[_0x68fd('0x3d')](new db[(_0x68fd('0x91'))]['ValidationError']('from\x20is\x20mandatory'));}if(_[_0x68fd('0x80')](_0x125502['body'][_0x68fd('0x62')])||_0x125502[_0x68fd('0x62')]['body']===''){throw _0x4946d4['status'](0x1f4)[_0x68fd('0x3d')](new db['Sequelize'][(_0x68fd('0x92'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0x68fd('0x80')](_0x125502[_0x68fd('0x62')][_0x68fd('0xd2')])){throw _0x4946d4[_0x68fd('0x2d')](0x1f4)[_0x68fd('0x3d')](new db[(_0x68fd('0x91'))][(_0x68fd('0x92'))](_0x68fd('0xd3')+_0x502b0d));}if(!_[_0x68fd('0x9b')](_0x502b0d,_0x125502[_0x68fd('0x62')][_0x68fd('0xd2')])){throw _0x4946d4[_0x68fd('0x2d')](0x1f4)[_0x68fd('0x3d')](new db['Sequelize']['ValidationError']('mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x502b0d));}_0x2c1f05[_0x125502[_0x68fd('0x62')][_0x68fd('0xd2')]]=_0x125502[_0x68fd('0x62')][_0x68fd('0x97')];})[_0x68fd('0x3c')](function(){return db[_0x68fd('0x42')][_0x68fd('0x60')]({'where':{'id':_0x125502[_0x68fd('0x5f')]['id']},'include':[{'model':db[_0x68fd('0xd4')],'as':_0x68fd('0x9e')}]});})[_0x68fd('0x3c')](handleEntityNotFound(_0x4946d4,null))[_0x68fd('0x3c')](function(_0x461cad){if(_0x461cad&&_0x461cad['List']){_0x50b25c=_0x461cad;var _0x189387=_[_0x68fd('0x1a')](_0x125502[_0x68fd('0x62')],{'firstName':_0x125502[_0x68fd('0x62')][_0x68fd('0x97')],'phone':_0x125502[_0x68fd('0x62')][_0x68fd('0x97')],'ListId':_0x461cad[_0x68fd('0xa7')]});_0x189387[_0x125502[_0x68fd('0x62')][_0x68fd('0xd2')]]=_0x125502['body']['from'];return db[_0x68fd('0x90')][_0x68fd('0xd5')]({'where':_0x2c1f05,'defaults':_0x189387});}})[_0x68fd('0xbd')](function(_0x5e1bc9){if(_0x5e1bc9){_0x24204c=_0x5e1bc9;var _0x351c93=fs['readFileSync'](path[_0x68fd('0x7b')](config[_0x68fd('0x7c')],_0x68fd('0xd6')),'utf8');var _0x3e75cc=ejs['render'](_0x351c93,{'body':_[_0x68fd('0xd7')](_0x125502['body'][_0x68fd('0x62')]),'bodyTitle':_0x50b25c[_0x68fd('0xd8')]});return db[_0x68fd('0xd9')][_0x68fd('0x61')]({'body':_0x3e75cc,'ContactId':_0x5e1bc9['id'],'ChatWebsiteId':_0x50b25c['id']});}})['then'](function(_0x354bf5){if(_0x354bf5){_0x27680b=_0x354bf5;return db[_0x68fd('0xda')][_0x68fd('0x6b')]({'where':{'service':!![]},'include':[{'model':db[_0x68fd('0xdb')],'as':'Smtp','raw':!![]}]});}})['then'](function(_0x1a5407){if(_0x1a5407&&_0x1a5407[_0x68fd('0xdc')]&&_0x50b25c['forwardOfflineAddress']){var _0x27ba72={'tls':{'rejectUnauthorized':![]}};if(_0x1a5407[_0x68fd('0xdc')]['service']){_0x27ba72[_0x68fd('0xdd')]=_0x1a5407[_0x68fd('0xdc')][_0x68fd('0xdd')];}else{_0x27ba72[_0x68fd('0xde')]=_0x1a5407[_0x68fd('0xdc')][_0x68fd('0xde')];_0x27ba72[_0x68fd('0xdf')]=_0x1a5407[_0x68fd('0xdc')]['port'];_0x27ba72[_0x68fd('0xe0')]=_0x1a5407[_0x68fd('0xdc')][_0x68fd('0xe0')];}if(_0x1a5407[_0x68fd('0xdc')][_0x68fd('0xe1')]){_0x27ba72[_0x68fd('0xe2')]={'user':_0x1a5407['Smtp']['user'],'pass':_0x1a5407[_0x68fd('0xdc')][_0x68fd('0xe3')]};}return respondWithRpcPromise('SendMail',_0x68fd('0xe4'),{'account':_0x27ba72,'message':{'from':util[_0x68fd('0xb3')]('\x22%s\x22\x20<%s>',_0x1a5407[_0x68fd('0x47')],_0x1a5407[_0x68fd('0xe5')]||_0x1a5407['Smtp'][_0x68fd('0xe6')]),'to':_0x50b25c[_0x68fd('0xe7')],'subject':_0x50b25c[_0x68fd('0xe8')],'text':_0x27680b[_0x68fd('0x62')]}},client9003)['then'](function(){return _0x27680b;})[_0x68fd('0x2b')](function(_0x3bba57){console['error'](_0x3bba57);});}})[_0x68fd('0x3c')](function(){if(_0x27680b){return _0x27680b;}})['then'](respondWithResult(_0x4946d4,null))[_0x68fd('0x2b')](handleError(_0x4946d4,null));};exports[_0x68fd('0xe9')]=function(_0x1225ad,_0x5c6dad,_0x1e3c29){return db['ChatInteraction'][_0x68fd('0x60')]({'where':{'id':_0x1225ad[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x5c6dad,null))['then'](function(_0x4e3ef0){if(_0x4e3ef0){return _0x4e3ef0['addInteraction'](_0x1225ad[_0x68fd('0x62')][_0x68fd('0x6d')],_[_0x68fd('0xea')](_0x1225ad[_0x68fd('0x62')],['ids','id'])||{});}})[_0x68fd('0x3c')](respondWithResult(_0x5c6dad,null))[_0x68fd('0x2b')](handleError(_0x5c6dad,null));};exports[_0x68fd('0xeb')]=function(_0x31105f,_0x1ba21a,_0x4d6028){var _0x2289f3={'raw':![],'where':{}};var _0x58176b={};var _0x181137={'count':0x0,'rows':[]};return db[_0x68fd('0x42')]['findOne']({'where':{'id':_0x31105f[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x1ba21a,null))[_0x68fd('0x3c')](function(_0x4b0fa0){if(_0x4b0fa0){_0x58176b[_0x68fd('0x4b')]=_[_0x68fd('0x48')](db[_0x68fd('0xba')][_0x68fd('0x43')]);_0x58176b['query']=_[_0x68fd('0x48')](_0x31105f['query']);_0x58176b[_0x68fd('0x49')]=_[_0x68fd('0x4a')](_0x58176b[_0x68fd('0x4b')],_0x58176b['query']);_0x2289f3['attributes']=_['intersection'](_0x58176b[_0x68fd('0x4b')],qs[_0x68fd('0x4e')](_0x31105f[_0x68fd('0x4c')][_0x68fd('0x4e')]));_0x2289f3[_0x68fd('0x4d')]=_0x2289f3[_0x68fd('0x4d')][_0x68fd('0x4f')]?_0x2289f3[_0x68fd('0x4d')]:_0x58176b['model'];if(!_0x31105f[_0x68fd('0x4c')][_0x68fd('0x50')](_0x68fd('0x51'))){_0x2289f3[_0x68fd('0x32')]=qs[_0x68fd('0x32')](_0x31105f[_0x68fd('0x4c')][_0x68fd('0x32')]);_0x2289f3['offset']=qs[_0x68fd('0x31')](_0x31105f[_0x68fd('0x4c')][_0x68fd('0x31')]);}_0x2289f3[_0x68fd('0x52')]=qs[_0x68fd('0x53')](_0x31105f[_0x68fd('0x4c')][_0x68fd('0x53')]);_0x2289f3['where']=qs[_0x68fd('0x49')](_[_0x68fd('0x54')](_0x31105f[_0x68fd('0x4c')],_0x58176b['filters']));_0x2289f3[_0x68fd('0x55')][_0x68fd('0x69')]=_0x4b0fa0['id'];if(_0x31105f[_0x68fd('0x4c')]['filter']){_0x2289f3[_0x68fd('0x55')]=_[_0x68fd('0x56')](_0x2289f3[_0x68fd('0x55')],{'$or':_[_0x68fd('0x41')](_0x2289f3[_0x68fd('0x4d')],function(_0x199ecb){var _0x254ee8={};_0x254ee8[_0x199ecb]={'$like':'%'+_0x31105f['query']['filter']+'%'};return _0x254ee8;})});}_0x2289f3=_[_0x68fd('0x56')]({},_0x2289f3,_0x31105f[_0x68fd('0x59')]);return db[_0x68fd('0xba')][_0x68fd('0x30')]({'where':_0x2289f3[_0x68fd('0x55')]})['then'](function(_0x1159cd){_0x181137[_0x68fd('0x30')]=_0x1159cd;if(_0x31105f[_0x68fd('0x4c')][_0x68fd('0x5a')]){_0x2289f3['include']=[{'model':db[_0x68fd('0x90')],'as':_0x68fd('0xec'),'required':![]},{'model':db[_0x68fd('0xc7')],'as':_0x68fd('0xed'),'attributes':['name',_0x68fd('0xee'),'internal'],'required':![]},{'model':db[_0x68fd('0xef')],'as':_0x68fd('0xf0'),'attributes':['id',_0x68fd('0x47'),_0x68fd('0xf1')],'where':_0x31105f[_0x68fd('0x4c')]['tag']?{'id':_0x31105f[_0x68fd('0x4c')][_0x68fd('0xf2')]}:undefined,'required':_0x31105f['query'][_0x68fd('0xf2')]?!![]:![]}];}return db[_0x68fd('0xba')][_0x68fd('0x5c')](_0x2289f3);})['then'](function(_0x33c39a){_0x181137[_0x68fd('0x5d')]=_0x33c39a;return _0x181137;});}})[_0x68fd('0x3c')](respondWithFilteredResult(_0x1ba21a,_0x2289f3))['catch'](handleError(_0x1ba21a,null));};function iftimePromise(_0x2e4e81,_0x1b8220){return respondWithRpcPromise(_0x68fd('0xf3'),_0x68fd('0xf4'),{'command':_0x1b8220[_0x68fd('0xf5')]?util[_0x68fd('0xb3')](_0x68fd('0xf6'),_0x2e4e81[_0x68fd('0xf7')],_0x1b8220['timezone']):util[_0x68fd('0xb3')](_0x68fd('0xf8'),_0x2e4e81[_0x68fd('0xf7')])},client9002)[_0x68fd('0x3c')](function(_0x4704c9){var _0x26f3ee=_0x4704c9&&_0x4704c9['indexOf']('true')>=0x0?!![]:![];logger[_0x68fd('0x23')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x1b8220['id'],_0x2e4e81['id'],_0x2e4e81[_0x68fd('0xf7')],_0x26f3ee?'ONLINE':'OFFLINE',_0x1b8220['timezone']?_0x1b8220[_0x68fd('0xf5')]:'No\x20timezone');return _0x26f3ee;})[_0x68fd('0x2b')](function(_0x1531fd){logger[_0x68fd('0x28')](_0x68fd('0xf9'),_0x1b8220['id'],_0x2e4e81['id'],_0x2e4e81[_0x68fd('0xf7')],util[_0x68fd('0xfa')](_0x1531fd,{'showHidden':![],'depth':null}),_0x1b8220[_0x68fd('0xf5')]?_0x1b8220['timezone']:'No\x20timezone');return![];});}exports[_0x68fd('0xf4')]=function(_0x168f4b,_0x54192c,_0x363b1d){var _0x2d572b=0x0;var _0x1deac4=0x0;var _0x455b17=![];var _0x406833;var _0xa3badd;return db[_0x68fd('0x42')][_0x68fd('0x60')]({'where':{'id':_0x168f4b[_0x68fd('0x5f')]['id']},'include':[{'model':db[_0x68fd('0xfb')],'as':_0x68fd('0xfb'),'include':[{'model':db[_0x68fd('0xfb')],'as':'Intervals','attributes':['id','interval'],'raw':!![]}]}]})['then'](handleEntityNotFound(_0x54192c,null))[_0x68fd('0x3c')](function(_0x228049){if(_0x228049){_0x406833=_0x228049;return _0x228049[_0x68fd('0xfc')]({'raw':!![]});}})[_0x68fd('0x3c')](function(_0x81f2e){if(_0x406833){if(_0x81f2e){_0xa3badd=_0x81f2e;}}return require(_0x68fd('0x18'))[_0x68fd('0x7e')]();})[_0x68fd('0x3c')](function(_0x2b85b5){if(_0x2b85b5){_0x1deac4=_0x2b85b5[_0x68fd('0xfd')];_0x455b17=_0x2b85b5[_0x68fd('0x7f')];}})['then'](function(){return db['ChatInteraction'][_0x68fd('0x30')]({'where':{'closed':![]}});})[_0x68fd('0x3c')](function(_0x14540a){_0x2d572b=_0x14540a;if(_0x1deac4&&_0x14540a>_0x1deac4){return db['License'][_0x68fd('0x6b')]({'where':{'id':0x1}})['then'](function(_0xac8bef){if(_0xac8bef){_0xac8bef[_0x68fd('0xfe')](_0x68fd('0xff'));}});}})[_0x68fd('0x3c')](function(){if(_0x406833[_0x68fd('0xfb')]&&_0x406833[_0x68fd('0xfb')]['Intervals']){var _0x56f1c5=[];for(var _0x3db53c=0x0;_0x3db53c<_0x406833[_0x68fd('0xfb')][_0x68fd('0x100')]['length'];_0x3db53c++){var _0x5ad9ba=_0x406833[_0x68fd('0xfb')][_0x68fd('0x100')][_0x3db53c]['get']({'plain':!![]});_0x56f1c5[_0x68fd('0xc0')](iftimePromise(_0x5ad9ba,_0x406833));}return BPromise[_0x68fd('0x101')](_0x56f1c5)['then'](function(_0x5ee730){return _['some'](_0x5ee730);});}else{return!![];}})['then'](function(_0x210dc4){var _0x55f7f1=fs[_0x68fd('0x102')](path[_0x68fd('0x7b')](config[_0x68fd('0x7c')],_0x68fd('0x103')),_0x68fd('0x104'));var _0x53bdc1={'remote':_0x406833['remote'],'query':querystring[_0x68fd('0x27')](_[_0x68fd('0x56')](_0x406833[_0x68fd('0x3a')]({'plain':!![]}),{'customerIp':_0x168f4b[_0x68fd('0x8d')][_0x68fd('0xaa')]||_0x168f4b[_0x68fd('0x8d')]['x-real-ip']||_0x168f4b[_0x68fd('0x105')][_0x68fd('0x106')]||_0x168f4b['ip'],'referer':_0x168f4b[_0x68fd('0x8d')][_0x68fd('0xb0')],'openedInteractions':_0x2d572b,'maxInteractions':_0x1deac4,'virtual':_0x455b17[_0x68fd('0xfd')],'online':_0x210dc4,'custom':_0x455b17}))[_0x68fd('0x107')](/'/g,'\x5c\x27')};_0x54192c[_0x68fd('0x3d')](ejs[_0x68fd('0x108')](Mustache[_0x68fd('0x108')](_0x55f7f1,_0x53bdc1),{'proactiveActions':_0xa3badd,'alignment':_0x406833[_0x68fd('0x109')],'verticalAlignment':_0x406833[_0x68fd('0x10a')],'div_color':_0x406833[_0x68fd('0xf1')],'text_color':_0x406833[_0x68fd('0x10b')]}));})[_0x68fd('0x2b')](handleError(_0x54192c,null));};exports[_0x68fd('0x10c')]=function(_0x3ca38c,_0xf9fc05,_0x35e0aa){return db[_0x68fd('0x42')][_0x68fd('0x6b')]({'where':{'id':_0x3ca38c[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0xf9fc05,null))[_0x68fd('0x3c')](function(_0x30fae3){if(_0x30fae3){return db[_0x68fd('0x10d')][_0x68fd('0x10e')](function(_0x5eea07){return db[_0x68fd('0x10f')][_0x68fd('0x39')]({'where':{'ChatWebsiteId':_0x3ca38c[_0x68fd('0x5f')]['id']},'transaction':_0x5eea07})['then'](function(_0x296dad){var _0x196036=_[_0x68fd('0x41')](_0x3ca38c[_0x68fd('0x62')],function(_0x47bbc9){_0x47bbc9[_0x68fd('0x69')]=_0x3ca38c[_0x68fd('0x5f')]['id'];return _0x47bbc9;});return db['ChatApplication'][_0x68fd('0x110')](_0x196036,{'transaction':_0x5eea07});});})[_0x68fd('0x3c')](function(){return db['ChatApplication'][_0x68fd('0x111')]({'where':{'ChatWebsiteId':_0x3ca38c[_0x68fd('0x5f')]['id']},'order':_0x68fd('0x112')});});}})['then'](respondWithResult(_0xf9fc05,null))['catch'](handleError(_0xf9fc05,null));};exports[_0x68fd('0x113')]=function(_0x42bd3a,_0x30085d,_0x28b9a9){var _0x4535d0={};var _0x1004d1={};var _0x4b4522;var _0x354bcc;return db[_0x68fd('0x42')][_0x68fd('0x6b')]({'where':{'id':_0x42bd3a[_0x68fd('0x5f')]['id']}})['then'](handleEntityNotFound(_0x30085d,null))[_0x68fd('0x3c')](function(_0x219cfe){if(_0x219cfe){_0x4b4522=_0x219cfe;_0x1004d1[_0x68fd('0x4b')]=_[_0x68fd('0x48')](db[_0x68fd('0x10f')][_0x68fd('0x43')]);_0x1004d1[_0x68fd('0x4c')]=_[_0x68fd('0x48')](_0x42bd3a['query']);_0x1004d1[_0x68fd('0x49')]=_[_0x68fd('0x4a')](_0x1004d1[_0x68fd('0x4b')],_0x1004d1[_0x68fd('0x4c')]);_0x4535d0[_0x68fd('0x4d')]=_[_0x68fd('0x4a')](_0x1004d1['model'],qs[_0x68fd('0x4e')](_0x42bd3a[_0x68fd('0x4c')][_0x68fd('0x4e')]));_0x4535d0[_0x68fd('0x4d')]=_0x4535d0[_0x68fd('0x4d')]['length']?_0x4535d0[_0x68fd('0x4d')]:_0x1004d1[_0x68fd('0x4b')];_0x4535d0[_0x68fd('0x52')]=qs[_0x68fd('0x53')](_0x42bd3a[_0x68fd('0x4c')][_0x68fd('0x53')]);_0x4535d0['where']=qs['filters'](_[_0x68fd('0x54')](_0x42bd3a['query'],_0x1004d1['filters']));if(_0x42bd3a['query'][_0x68fd('0x58')]){_0x4535d0[_0x68fd('0x55')]=_[_0x68fd('0x56')](_0x4535d0['where'],{'$or':_[_0x68fd('0x41')](_0x4535d0['attributes'],function(_0x2cb607){var _0x2c90b6={};_0x2c90b6[_0x2cb607]={'$like':'%'+_0x42bd3a[_0x68fd('0x4c')][_0x68fd('0x58')]+'%'};return _0x2c90b6;})});}_0x4535d0=_[_0x68fd('0x56')]({},_0x4535d0,_0x42bd3a[_0x68fd('0x59')]);return _0x4b4522['getApplications'](_0x4535d0);}})['then'](function(_0x221d2d){if(_0x221d2d){_0x354bcc=_0x221d2d[_0x68fd('0x4f')];if(!_0x42bd3a['query'][_0x68fd('0x50')](_0x68fd('0x51'))){_0x4535d0[_0x68fd('0x32')]=qs[_0x68fd('0x32')](_0x42bd3a['query']['limit']);_0x4535d0[_0x68fd('0x31')]=qs[_0x68fd('0x31')](_0x42bd3a[_0x68fd('0x4c')][_0x68fd('0x31')]);}return _0x4b4522[_0x68fd('0x113')](_0x4535d0);}})[_0x68fd('0x3c')](function(_0x359e7b){if(_0x359e7b){return _0x359e7b?{'count':_0x354bcc,'rows':_0x359e7b}:null;}})['then'](respondWithResult(_0x30085d,null))[_0x68fd('0x2b')](handleError(_0x30085d,null));};exports['addProactiveActions']=function(_0x5501c2,_0x1b1f30,_0x1bf154){return db['chatProactiveAction'][_0x68fd('0x60')]({'where':{'id':_0x5501c2[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x1b1f30,null))['then'](function(_0xdba24d){if(_0xdba24d){return _0xdba24d[_0x68fd('0x114')](_0x5501c2[_0x68fd('0x62')][_0x68fd('0x6d')],_[_0x68fd('0xea')](_0x5501c2[_0x68fd('0x62')],['ids','id'])||{});}})['then'](respondWithResult(_0x1b1f30,null))[_0x68fd('0x2b')](handleError(_0x1b1f30,null));};exports[_0x68fd('0xfc')]=function(_0x5599a0,_0x3da50a,_0x23a550){var _0x2fc58c={};var _0xc8b9c3={};var _0x83e48c;var _0x4e80e0;return db['ChatWebsite']['findOne']({'where':{'id':_0x5599a0[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x3da50a,null))[_0x68fd('0x3c')](function(_0x11df82){if(_0x11df82){_0x83e48c=_0x11df82;_0xc8b9c3[_0x68fd('0x4b')]=_[_0x68fd('0x48')](db['ChatProactiveAction']['rawAttributes']);_0xc8b9c3[_0x68fd('0x4c')]=_['keys'](_0x5599a0[_0x68fd('0x4c')]);_0xc8b9c3['filters']=_[_0x68fd('0x4a')](_0xc8b9c3[_0x68fd('0x4b')],_0xc8b9c3['query']);_0x2fc58c[_0x68fd('0x4d')]=_['intersection'](_0xc8b9c3[_0x68fd('0x4b')],qs[_0x68fd('0x4e')](_0x5599a0[_0x68fd('0x4c')][_0x68fd('0x4e')]));_0x2fc58c[_0x68fd('0x4d')]=_0x2fc58c[_0x68fd('0x4d')][_0x68fd('0x4f')]?_0x2fc58c[_0x68fd('0x4d')]:_0xc8b9c3[_0x68fd('0x4b')];_0x2fc58c[_0x68fd('0x52')]=qs['sort'](_0x5599a0['query']['sort']);_0x2fc58c['where']=qs[_0x68fd('0x49')](_[_0x68fd('0x54')](_0x5599a0[_0x68fd('0x4c')],_0xc8b9c3[_0x68fd('0x49')]));if(_0x5599a0[_0x68fd('0x4c')]['filter']){_0x2fc58c[_0x68fd('0x55')]=_[_0x68fd('0x56')](_0x2fc58c[_0x68fd('0x55')],{'$or':_[_0x68fd('0x41')](_0x2fc58c['attributes'],function(_0x84aef2){var _0x4be83d={};_0x4be83d[_0x84aef2]={'$like':'%'+_0x5599a0[_0x68fd('0x4c')][_0x68fd('0x58')]+'%'};return _0x4be83d;})});}_0x2fc58c=_[_0x68fd('0x56')]({},_0x2fc58c,_0x5599a0[_0x68fd('0x59')]);return _0x83e48c[_0x68fd('0xfc')](_0x2fc58c);}})[_0x68fd('0x3c')](function(_0x197ed1){if(_0x197ed1){_0x4e80e0=_0x197ed1['length'];if(!_0x5599a0[_0x68fd('0x4c')][_0x68fd('0x50')](_0x68fd('0x51'))){_0x2fc58c[_0x68fd('0x32')]=qs[_0x68fd('0x32')](_0x5599a0[_0x68fd('0x4c')][_0x68fd('0x32')]);_0x2fc58c[_0x68fd('0x31')]=qs[_0x68fd('0x31')](_0x5599a0[_0x68fd('0x4c')][_0x68fd('0x31')]);}return _0x83e48c[_0x68fd('0xfc')](_0x2fc58c);}})[_0x68fd('0x3c')](function(_0x2cf68f){if(_0x2cf68f){return _0x2cf68f?{'count':_0x4e80e0,'rows':_0x2cf68f}:null;}})['then'](respondWithResult(_0x3da50a,null))[_0x68fd('0x2b')](handleError(_0x3da50a,null));};exports[_0x68fd('0x115')]=function(_0x187a95,_0x38372c,_0x1ee93e){var _0x10c0ac=_0x187a95[_0x68fd('0x4c')][_0x68fd('0x116')]==='false'?_0x68fd('0x117'):_0x68fd('0x118');return db[_0x68fd('0x42')][_0x68fd('0x60')]({'attributes':['id',_0x10c0ac],'where':{'id':_0x187a95[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x38372c,null))[_0x68fd('0x3c')](function(_0x20d44){if(_0x20d44){var _0x4a6355=_0x20d44[_0x10c0ac];var _0x880e8e=_0x4a6355&&_0x4a6355[_0x68fd('0x119')]?_0x4a6355[_0x68fd('0x119')]:[];_0x38372c[_0x68fd('0x3d')]({'fromKey':_[_0x68fd('0x80')](_0x4a6355[_0x68fd('0x11a')])?undefined:_0x4a6355[_0x68fd('0x11a')],'count':_0x880e8e['length'],'rows':_0x880e8e});}})['catch'](handleError(_0x38372c,null));};exports[_0x68fd('0x11b')]=function(_0x1b485a,_0x39d577,_0x4df04f){var _0x16d6c2={'raw':![],'where':{}};var _0x34f965={};var _0x5c92b7={'count':0x0,'rows':[]};return db[_0x68fd('0x42')][_0x68fd('0x6b')]({'where':{'id':_0x1b485a[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x39d577,null))[_0x68fd('0x3c')](function(_0x135a07){if(_0x135a07){_0x34f965['model']=_[_0x68fd('0x48')](db[_0x68fd('0xd9')][_0x68fd('0x43')]);_0x34f965[_0x68fd('0x4c')]=_[_0x68fd('0x48')](_0x1b485a['query']);_0x34f965['filters']=_[_0x68fd('0x4a')](_0x34f965[_0x68fd('0x4b')],_0x34f965['query']);_0x16d6c2[_0x68fd('0x4d')]=_[_0x68fd('0x4a')](_0x34f965[_0x68fd('0x4b')],qs[_0x68fd('0x4e')](_0x1b485a[_0x68fd('0x4c')][_0x68fd('0x4e')]));_0x16d6c2['attributes']=_0x16d6c2[_0x68fd('0x4d')][_0x68fd('0x4f')]?_0x16d6c2[_0x68fd('0x4d')]:_0x34f965[_0x68fd('0x4b')];if(!_0x1b485a[_0x68fd('0x4c')][_0x68fd('0x50')](_0x68fd('0x51'))){_0x16d6c2[_0x68fd('0x32')]=qs['limit'](_0x1b485a['query'][_0x68fd('0x32')]);_0x16d6c2[_0x68fd('0x31')]=qs[_0x68fd('0x31')](_0x1b485a['query'][_0x68fd('0x31')]);}_0x16d6c2[_0x68fd('0x52')]=qs['sort'](_0x1b485a[_0x68fd('0x4c')][_0x68fd('0x53')]);_0x16d6c2[_0x68fd('0x55')]=qs['filters'](_[_0x68fd('0x54')](_0x1b485a[_0x68fd('0x4c')],_0x34f965['filters']));_0x16d6c2[_0x68fd('0x55')][_0x68fd('0x69')]=_0x135a07['id'];if(_0x1b485a[_0x68fd('0x4c')][_0x68fd('0x58')]){_0x16d6c2['where']=_[_0x68fd('0x56')](_0x16d6c2['where'],{'$or':_[_0x68fd('0x41')](_0x16d6c2['attributes'],function(_0x52959b){var _0xc97d4c={};_0xc97d4c[_0x52959b]={'$like':'%'+_0x1b485a[_0x68fd('0x4c')][_0x68fd('0x58')]+'%'};return _0xc97d4c;})});}_0x16d6c2=_[_0x68fd('0x56')]({},_0x16d6c2,_0x1b485a[_0x68fd('0x59')]);return db[_0x68fd('0xd9')][_0x68fd('0x30')]({'where':_0x16d6c2[_0x68fd('0x55')]})[_0x68fd('0x3c')](function(_0x5a9d68){_0x5c92b7['count']=_0x5a9d68;if(_0x1b485a[_0x68fd('0x4c')]['includeAll']){_0x16d6c2[_0x68fd('0x5b')]=[{'all':!![]}];}else{_0x16d6c2['include']=[{'model':db[_0x68fd('0x90')],'as':_0x68fd('0xec'),'required':![]}];}return db['ChatOfflineMessage'][_0x68fd('0x5c')](_0x16d6c2);})[_0x68fd('0x3c')](function(_0x246eab){_0x5c92b7[_0x68fd('0x5d')]=_0x246eab;return _0x5c92b7;});}})[_0x68fd('0x3c')](respondWithFilteredResult(_0x39d577,_0x16d6c2))[_0x68fd('0x2b')](handleError(_0x39d577,null));};exports[_0x68fd('0x11c')]=function(_0x29d67a,_0x14884d,_0x4189b9){return db[_0x68fd('0x42')][_0x68fd('0x60')]({'where':{'id':_0x29d67a[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x14884d,null))[_0x68fd('0x3c')](function(_0xce64ad){if(_0xce64ad){return _0xce64ad[_0x68fd('0x11c')](_0x29d67a['body'][_0x68fd('0x6d')],_['omit'](_0x29d67a[_0x68fd('0x62')],[_0x68fd('0x6d'),'id'])||{})[_0x68fd('0xbd')](function(_0x412e15){for(var _0x1f552d=0x0;_0x1f552d<_0x29d67a[_0x68fd('0x62')][_0x68fd('0x6d')][_0x68fd('0x4f')];_0x1f552d+=0x1){socket['emit'](_0x68fd('0x11d'),{'UserId':_0x29d67a[_0x68fd('0x62')][_0x68fd('0x6d')][_0x1f552d],'ChatWebsiteId':_0x29d67a['params']['id']});}return _0x412e15;});}})['then'](respondWithResult(_0x14884d,null))['catch'](handleError(_0x14884d,null));};exports[_0x68fd('0x11e')]=function(_0x5525e9,_0x299f19,_0x489280){return db[_0x68fd('0x42')][_0x68fd('0x60')]({'where':{'id':_0x5525e9[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0x299f19,null))[_0x68fd('0x3c')](function(_0x3e2d53){if(_0x3e2d53){return _0x3e2d53['removeAgents'](_0x5525e9['query'][_0x68fd('0x6d')])[_0x68fd('0x3c')](function(){if(_[_0x68fd('0x11f')](_0x5525e9[_0x68fd('0x4c')][_0x68fd('0x6d')])){for(var _0x591cf0=0x0;_0x591cf0<_0x5525e9[_0x68fd('0x4c')][_0x68fd('0x6d')][_0x68fd('0x4f')];_0x591cf0+=0x1){socket[_0x68fd('0x120')](_0x68fd('0x121'),{'UserId':Number(_0x5525e9['query'][_0x68fd('0x6d')][_0x591cf0]),'ChatWebsiteId':Number(_0x5525e9[_0x68fd('0x5f')]['id'])});}}else{socket[_0x68fd('0x120')](_0x68fd('0x121'),{'UserId':Number(_0x5525e9[_0x68fd('0x4c')][_0x68fd('0x6d')]),'ChatWebsiteId':Number(_0x5525e9[_0x68fd('0x5f')]['id'])});}});}})[_0x68fd('0x3c')](respondWithStatusCode(_0x299f19,null))[_0x68fd('0x2b')](handleError(_0x299f19,null));};exports[_0x68fd('0x122')]=function(_0x2960f6,_0xc03677,_0x3e6c8c){var _0xfd1069={};var _0x3488da={};var _0x50b6cd;var _0x4cd81a;return db['ChatWebsite'][_0x68fd('0x6b')]({'where':{'id':_0x2960f6[_0x68fd('0x5f')]['id']}})[_0x68fd('0x3c')](handleEntityNotFound(_0xc03677,null))['then'](function(_0x24f316){if(_0x24f316){_0x50b6cd=_0x24f316;_0x3488da[_0x68fd('0x4b')]=_[_0x68fd('0x48')](db[_0x68fd('0xc7')][_0x68fd('0x43')]);_0x3488da[_0x68fd('0x4c')]=_[_0x68fd('0x48')](_0x2960f6[_0x68fd('0x4c')]);_0x3488da[_0x68fd('0x49')]=_['intersection'](_0x3488da[_0x68fd('0x4b')],_0x3488da[_0x68fd('0x4c')]);_0xfd1069['attributes']=_[_0x68fd('0x4a')](_0x3488da[_0x68fd('0x4b')],qs[_0x68fd('0x4e')](_0x2960f6[_0x68fd('0x4c')]['fields']));_0xfd1069[_0x68fd('0x4d')]=_0xfd1069['attributes'][_0x68fd('0x4f')]?_0xfd1069[_0x68fd('0x4d')]:_0x3488da[_0x68fd('0x4b')];_0xfd1069[_0x68fd('0x52')]=qs[_0x68fd('0x53')](_0x2960f6[_0x68fd('0x4c')]['sort']);_0xfd1069[_0x68fd('0x55')]=qs['filters'](_[_0x68fd('0x54')](_0x2960f6[_0x68fd('0x4c')],_0x3488da['filters']));if(_0x2960f6['query'][_0x68fd('0x58')]){_0xfd1069[_0x68fd('0x55')]=_[_0x68fd('0x56')](_0xfd1069[_0x68fd('0x55')],{'$or':_[_0x68fd('0x41')](_0xfd1069[_0x68fd('0x4d')],function(_0x3ac61d){var _0x4eb1e4={};_0x4eb1e4[_0x3ac61d]={'$like':'%'+_0x2960f6[_0x68fd('0x4c')][_0x68fd('0x58')]+'%'};return _0x4eb1e4;})});}_0xfd1069=_[_0x68fd('0x56')]({},_0xfd1069,_0x2960f6[_0x68fd('0x59')]);return _0x50b6cd[_0x68fd('0x122')](_0xfd1069);}})['then'](function(_0x23f27a){if(_0x23f27a){_0x4cd81a=_0x23f27a[_0x68fd('0x4f')];if(!_0x2960f6[_0x68fd('0x4c')]['hasOwnProperty'](_0x68fd('0x51'))){_0xfd1069['limit']=qs[_0x68fd('0x32')](_0x2960f6[_0x68fd('0x4c')][_0x68fd('0x32')]);_0xfd1069[_0x68fd('0x31')]=qs['offset'](_0x2960f6['query']['offset']);}return _0x50b6cd[_0x68fd('0x122')](_0xfd1069);}})[_0x68fd('0x3c')](function(_0x9eee9d){if(_0x9eee9d){return _0x9eee9d?{'count':_0x4cd81a,'rows':_0x9eee9d}:null;}})['then'](respondWithResult(_0xc03677,null))[_0x68fd('0x2b')](handleError(_0xc03677,null));};
\ No newline at end of file
+var _0xbaf0=['userChatWebsite:remove','getAgents','mustache','util','path','ejs','fs-extra','lodash','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','socket.io-emitter','./chatWebsite.socket','register','html-to-text','jayson/promise','client','http','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','sendStatus','status','json','offset','undefined','limit','count','set','update','destroy','get','ChatWebsites','UserProfileResource','end','stack','name','send','Pause','mandatoryDispositionPause','ChatWebsite','rawAttributes','fieldName','model','map','keys','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','type','VIRTUAL','options','includeAll','include','rows','show','params','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getDispositions','findOne','Disposition','findAll','removeDispositions','ids','addAnswer','ChatWebsiteId','CannedAnswer','length','removeAnswers','addLogo','sitepic','file','filename','addAvatar','agentAvatar','addCustomerAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','getLicense','custom','isNil','server/files/images/logos/','download','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','notify','headers','user-agent','getResult','chat','CmContact','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','from','Sequelize','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','includes','CmList','Contacts','DESC','Applications','List','account','applications','list','orderBy','priority','asc','ListId','contact','customerIp','cf-connecting-ip','first','x-forwarded-for','split','firstName','x-real-port','browser','format','%s\x20%s','version','unknown','device','vendor','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','lastName','messageId','created','unmanaged','*,*,*,*','AttachmentId','UserId','User','unshift','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','offline','mapKeyOffline','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','fromString','originalname','mimetype','server','files','attachments','offline-chat','basename','openNewInteraction','sequelize','Attachment','bulkCreate','MailServerOut','Smtp','forwardOffline','forwardOfflineAddress','service','host','port','secure','authentication','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','MailAccountId','subjectOffline','toPairsIn','mapValues','Chat','NotifyMailAccount','notifyMail','remove','addInteraction','Contact','Owner','fullname','internal','Tags','Command','iftime\x20%s,%s','interval','timezone','iftime\x20%s','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','OFFLINE','No\x20timezone','inspect','getSnippet','Interval','Intervals','getProactiveActions','../../config/license/util','virtual','License','increment','chatLicenseExceeded','push','all','server/files/chat/iframe.ejs','remote','referer','alignment','verticalAlignment','labelText','textColor','color_button','backgroundColor','addApplications','transaction','ISOLATION_LEVELS','READ_COMMITTED','ChatApplication','finally','getApplications','chatProactiveAction','addProactiveActions','omit','getFields','online','false','onlineForm','items','fromKey','Attachments','addAgents','emit','userChatWebsite:save','removeAgents'];(function(_0x32f261,_0x307d25){var _0x21656d=function(_0x3ff582){while(--_0x3ff582){_0x32f261['push'](_0x32f261['shift']());}};_0x21656d(++_0x307d25);}(_0xbaf0,0x12a));var _0x0baf=function(_0x432682,_0x253044){_0x432682=_0x432682-0x0;var _0x463d05=_0xbaf0[_0x432682];return _0x463d05;};'use strict';var BPromise=require('bluebird');var Mustache=require(_0x0baf('0x0'));var util=require(_0x0baf('0x1'));var path=require(_0x0baf('0x2'));var ejs=require(_0x0baf('0x3'));var fs=require('fs');var fs_extra=require(_0x0baf('0x4'));var _=require(_0x0baf('0x5'));var querystring=require('querystring');var Redis=require(_0x0baf('0x6'));var qs=require(_0x0baf('0x7'));var logger=require(_0x0baf('0x8'))(_0x0baf('0x9'));var config=require(_0x0baf('0xa'));var db=require(_0x0baf('0xb'))['db'];config[_0x0baf('0xc')]=_[_0x0baf('0xd')](config[_0x0baf('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x0baf('0xe'))(new Redis(config['redis']));require(_0x0baf('0xf'))[_0x0baf('0x10')](socket);var htmlToText=require(_0x0baf('0x11'));var jayson=require(_0x0baf('0x12'));var client=jayson[_0x0baf('0x13')][_0x0baf('0x14')]({'port':0x232c});var client9002=jayson[_0x0baf('0x13')][_0x0baf('0x14')]({'port':0x232a});var client9003=jayson[_0x0baf('0x13')][_0x0baf('0x14')]({'port':0x232b});var client9001=jayson[_0x0baf('0x13')]['http']({'port':0x2329});function respondWithRpcPromise(_0x5a53e2,_0x465dd7,_0xe4378c,_0x5db689){return new BPromise(function(_0x13df17,_0x5a0583){var _0x2ab33e=_0x5db689||client;return _0x2ab33e['request'](_0x5a53e2,_0xe4378c)[_0x0baf('0x15')](function(_0x1f50c3){logger[_0x0baf('0x16')](_0x0baf('0x17'),_0x465dd7,_0x0baf('0x18'));logger[_0x0baf('0x19')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x465dd7,'request\x20sent',JSON[_0x0baf('0x1a')](_0x1f50c3));if(_0x1f50c3[_0x0baf('0x1b')]){if(_0x1f50c3[_0x0baf('0x1b')][_0x0baf('0x1c')]===0x1f4){logger[_0x0baf('0x1b')](_0x0baf('0x17'),_0x465dd7,_0x1f50c3['error'][_0x0baf('0x1d')]);return _0x5a0583(_0x1f50c3[_0x0baf('0x1b')][_0x0baf('0x1d')]);}logger[_0x0baf('0x1b')](_0x0baf('0x17'),_0x465dd7,_0x1f50c3[_0x0baf('0x1b')]['message']);return _0x13df17(_0x1f50c3['error'][_0x0baf('0x1d')]);}else{logger[_0x0baf('0x16')](_0x0baf('0x17'),_0x465dd7,_0x0baf('0x18'));_0x13df17(_0x1f50c3[_0x0baf('0x1e')][_0x0baf('0x1d')]);}})[_0x0baf('0x1f')](function(_0x636a13){logger[_0x0baf('0x1b')](_0x0baf('0x17'),_0x465dd7,_0x636a13);_0x5a0583(_0x636a13);});});}function respondWithStatusCode(_0x54f2fa,_0x334bd6){_0x334bd6=_0x334bd6||0xcc;return function(_0x482522){if(_0x482522){return _0x54f2fa[_0x0baf('0x20')](_0x334bd6);}return _0x54f2fa['status'](_0x334bd6)['end']();};}function respondWithResult(_0x2ef0aa,_0x48a0e9){_0x48a0e9=_0x48a0e9||0xc8;return function(_0x4be1b9){if(_0x4be1b9){return _0x2ef0aa[_0x0baf('0x21')](_0x48a0e9)[_0x0baf('0x22')](_0x4be1b9);}};}function respondWithFilteredResult(_0x34e264,_0x19d9fd){return function(_0x3a1ba1){if(_0x3a1ba1){var _0x56b299=typeof _0x19d9fd[_0x0baf('0x23')]===_0x0baf('0x24')&&typeof _0x19d9fd[_0x0baf('0x25')]===_0x0baf('0x24');var _0x3843b8=_0x3a1ba1[_0x0baf('0x26')];var _0x453525=_0x56b299?0x0:_0x19d9fd['offset'];var _0x1590b4=_0x56b299?_0x3a1ba1[_0x0baf('0x26')]:_0x19d9fd[_0x0baf('0x23')]+_0x19d9fd[_0x0baf('0x25')];var _0x55c715;if(_0x1590b4>=_0x3843b8){_0x1590b4=_0x3843b8;_0x55c715=0xc8;}else{_0x55c715=0xce;}_0x34e264[_0x0baf('0x21')](_0x55c715);return _0x34e264[_0x0baf('0x27')]('Content-Range',_0x453525+'-'+_0x1590b4+'/'+_0x3843b8)[_0x0baf('0x22')](_0x3a1ba1);}return null;};}function saveUpdates(_0x32e4fb){return function(_0x478ce8){if(_0x478ce8){return _0x478ce8[_0x0baf('0x28')](_0x32e4fb)[_0x0baf('0x15')](function(_0x366924){return _0x366924;});}return null;};}function removeEntity(_0x213a6a){return function(_0x57476f){if(_0x57476f){return _0x57476f[_0x0baf('0x29')]()[_0x0baf('0x15')](function(){var _0x37be4e=_0x57476f[_0x0baf('0x2a')]({'plain':!![]});var _0x24ecee=_0x0baf('0x2b');return db[_0x0baf('0x2c')][_0x0baf('0x29')]({'where':{'type':_0x24ecee,'resourceId':_0x37be4e['id']}})[_0x0baf('0x15')](function(){return _0x57476f;});})[_0x0baf('0x15')](function(){_0x213a6a[_0x0baf('0x21')](0xcc)[_0x0baf('0x2d')]();});}};}function handleEntityNotFound(_0x45294a){return function(_0x3a3353){if(!_0x3a3353){_0x45294a['sendStatus'](0x194);}return _0x3a3353;};}function handleError(_0x2fd426,_0x53ae1d){_0x53ae1d=_0x53ae1d||0x1f4;return function(_0x1aa474){logger[_0x0baf('0x1b')](_0x1aa474[_0x0baf('0x2e')]);if(_0x1aa474[_0x0baf('0x2f')]){delete _0x1aa474['name'];}_0x2fd426[_0x0baf('0x21')](_0x53ae1d)[_0x0baf('0x30')](_0x1aa474);};}exports['index']=function(_0x23d890,_0x2447c2){var _0x62a2ed={'include':[{'model':db[_0x0baf('0x31')],'as':_0x0baf('0x32')}]},_0xbaa9a7={},_0x1f60bd={'count':0x0,'rows':[]};var _0x675461=_['map'](db[_0x0baf('0x33')][_0x0baf('0x34')],function(_0x5b991f){return{'name':_0x5b991f[_0x0baf('0x35')],'type':_0x5b991f['type']['key']};});_0xbaa9a7[_0x0baf('0x36')]=_[_0x0baf('0x37')](_0x675461,'name');_0xbaa9a7['query']=_[_0x0baf('0x38')](_0x23d890[_0x0baf('0x39')]);_0xbaa9a7[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0xbaa9a7[_0x0baf('0x36')],_0xbaa9a7[_0x0baf('0x39')]);_0x62a2ed[_0x0baf('0x3c')]=_[_0x0baf('0x3b')](_0xbaa9a7[_0x0baf('0x36')],qs[_0x0baf('0x3d')](_0x23d890[_0x0baf('0x39')][_0x0baf('0x3d')]));_0x62a2ed[_0x0baf('0x3c')]=_0x62a2ed[_0x0baf('0x3c')]['length']?_0x62a2ed[_0x0baf('0x3c')]:_0xbaa9a7[_0x0baf('0x36')];if(!_0x23d890['query'][_0x0baf('0x3e')](_0x0baf('0x3f'))){_0x62a2ed[_0x0baf('0x25')]=qs[_0x0baf('0x25')](_0x23d890[_0x0baf('0x39')][_0x0baf('0x25')]);_0x62a2ed['offset']=qs[_0x0baf('0x23')](_0x23d890[_0x0baf('0x39')]['offset']);}_0x62a2ed[_0x0baf('0x40')]=qs[_0x0baf('0x41')](_0x23d890[_0x0baf('0x39')][_0x0baf('0x41')]);_0x62a2ed['where']=qs[_0x0baf('0x3a')](_[_0x0baf('0x42')](_0x23d890[_0x0baf('0x39')],_0xbaa9a7[_0x0baf('0x3a')]),_0x675461);if(_0x23d890[_0x0baf('0x39')][_0x0baf('0x43')]){_0x62a2ed[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0x62a2ed[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0x675461,function(_0x56270e){if(_0x56270e[_0x0baf('0x46')]!==_0x0baf('0x47')){var _0x1daf1d={};_0x1daf1d[_0x56270e[_0x0baf('0x2f')]]={'$like':'%'+_0x23d890[_0x0baf('0x39')]['filter']+'%'};return _0x1daf1d;}})});}_0x62a2ed=_[_0x0baf('0x45')]({},_0x62a2ed,_0x23d890[_0x0baf('0x48')]);var _0x27c3ee={'where':_0x62a2ed[_0x0baf('0x44')]};return db[_0x0baf('0x33')]['count'](_0x27c3ee)[_0x0baf('0x15')](function(_0x85bedb){_0x1f60bd[_0x0baf('0x26')]=_0x85bedb;if(_0x23d890[_0x0baf('0x39')][_0x0baf('0x49')]){_0x62a2ed[_0x0baf('0x4a')]=[{'all':!![]}];}return db[_0x0baf('0x33')]['findAll'](_0x62a2ed);})[_0x0baf('0x15')](function(_0x167fb8){_0x1f60bd[_0x0baf('0x4b')]=_0x167fb8;return _0x1f60bd;})['then'](respondWithFilteredResult(_0x2447c2,_0x62a2ed))[_0x0baf('0x1f')](handleError(_0x2447c2,null));};exports[_0x0baf('0x4c')]=function(_0x10fa62,_0x3fabec){var _0x204d77={'raw':![],'where':{'id':_0x10fa62[_0x0baf('0x4d')]['id']},'include':[{'model':db['Pause'],'as':_0x0baf('0x32')}]},_0x1b71a3={};_0x1b71a3[_0x0baf('0x36')]=_[_0x0baf('0x38')](db[_0x0baf('0x33')][_0x0baf('0x34')]);_0x1b71a3[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x10fa62[_0x0baf('0x39')]);_0x1b71a3[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x1b71a3[_0x0baf('0x36')],_0x1b71a3['query']);_0x204d77['attributes']=_[_0x0baf('0x3b')](_0x1b71a3[_0x0baf('0x36')],qs[_0x0baf('0x3d')](_0x10fa62[_0x0baf('0x39')][_0x0baf('0x3d')]));_0x204d77[_0x0baf('0x3c')]=_0x204d77[_0x0baf('0x3c')]['length']?_0x204d77[_0x0baf('0x3c')]:_0x1b71a3[_0x0baf('0x36')];if(_0x10fa62[_0x0baf('0x39')][_0x0baf('0x49')]){_0x204d77[_0x0baf('0x4a')]=[{'all':!![]}];}_0x204d77=_[_0x0baf('0x45')]({},_0x204d77,_0x10fa62['options']);return db[_0x0baf('0x33')]['find'](_0x204d77)[_0x0baf('0x15')](handleEntityNotFound(_0x3fabec,null))['then'](respondWithResult(_0x3fabec,null))[_0x0baf('0x1f')](handleError(_0x3fabec,null));};exports['create']=function(_0x35b1a5,_0x4c035b){return db[_0x0baf('0x33')][_0x0baf('0x4e')](_0x35b1a5[_0x0baf('0x4f')],{})[_0x0baf('0x15')](function(_0x42a68b){var _0x576475=_0x35b1a5[_0x0baf('0x50')][_0x0baf('0x2a')]({'plain':!![]});if(!_0x576475)throw new Error(_0x0baf('0x51'));if(_0x576475[_0x0baf('0x52')]===_0x0baf('0x50')){var _0xa19b21=_0x42a68b['get']({'plain':!![]});var _0x402f4d=_0x0baf('0x2b');return db[_0x0baf('0x53')][_0x0baf('0x54')]({'where':{'name':_0x402f4d,'userProfileId':_0x576475[_0x0baf('0x55')]},'raw':!![]})[_0x0baf('0x15')](function(_0x3834a2){if(_0x3834a2&&_0x3834a2['autoAssociation']===0x0){return db['UserProfileResource'][_0x0baf('0x4e')]({'name':_0xa19b21[_0x0baf('0x2f')],'resourceId':_0xa19b21['id'],'type':_0x3834a2[_0x0baf('0x2f')],'sectionId':_0x3834a2['id']},{})[_0x0baf('0x15')](function(){return _0x42a68b;});}else{return _0x42a68b;}})[_0x0baf('0x1f')](function(_0x35221e){logger[_0x0baf('0x1b')](_0x0baf('0x56'),_0x35221e);throw _0x35221e;});}return _0x42a68b;})[_0x0baf('0x15')](respondWithResult(_0x4c035b,0xc9))['catch'](handleError(_0x4c035b,null));};exports[_0x0baf('0x28')]=function(_0x268be8,_0x3c2d03){if(_0x268be8[_0x0baf('0x4f')]['id']){delete _0x268be8[_0x0baf('0x4f')]['id'];}return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x268be8['params']['id']},'include':[{'model':db[_0x0baf('0x31')],'as':_0x0baf('0x32')}]})[_0x0baf('0x15')](handleEntityNotFound(_0x3c2d03,null))[_0x0baf('0x15')](saveUpdates(_0x268be8[_0x0baf('0x4f')],null))[_0x0baf('0x15')](respondWithResult(_0x3c2d03,null))[_0x0baf('0x1f')](handleError(_0x3c2d03,null));};exports[_0x0baf('0x29')]=function(_0x498405,_0x178495){return db['ChatWebsite'][_0x0baf('0x54')]({'where':{'id':_0x498405['params']['id']}})['then'](handleEntityNotFound(_0x178495,null))[_0x0baf('0x15')](removeEntity(_0x178495,null))['catch'](handleError(_0x178495,null));};exports[_0x0baf('0x57')]=function(_0x2b17f8,_0x49d713){return db[_0x0baf('0x33')][_0x0baf('0x57')]()[_0x0baf('0x15')](respondWithResult(_0x49d713,null))['catch'](handleError(_0x49d713,null));};exports['addDisposition']=function(_0x2438df,_0x7e8946){if(_0x2438df[_0x0baf('0x4f')]['id']){delete _0x2438df[_0x0baf('0x4f')]['id'];}return db[_0x0baf('0x33')]['find']({'where':{'id':_0x2438df[_0x0baf('0x4d')]['id']}})['then'](handleEntityNotFound(_0x7e8946,null))['then'](function(_0x59a0b2){if(_0x59a0b2){_0x2438df[_0x0baf('0x4f')]['ChatWebsiteId']=_0x59a0b2['id'];return db['Disposition'][_0x0baf('0x4e')](_0x2438df[_0x0baf('0x4f')]);}})[_0x0baf('0x15')](respondWithResult(_0x7e8946,null))[_0x0baf('0x1f')](handleError(_0x7e8946,null));};exports[_0x0baf('0x58')]=function(_0x27ddc7,_0x4c05d6){var _0xec3b32={'raw':![],'where':{}};var _0x1a0a67={};var _0x185473={'count':0x0,'rows':[]};return db[_0x0baf('0x33')][_0x0baf('0x59')]({'where':{'id':_0x27ddc7[_0x0baf('0x4d')]['id']}})['then'](handleEntityNotFound(_0x4c05d6,null))[_0x0baf('0x15')](function(_0x468363){if(_0x468363){_0x1a0a67[_0x0baf('0x36')]=_['keys'](db[_0x0baf('0x5a')][_0x0baf('0x34')]);_0x1a0a67[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x27ddc7[_0x0baf('0x39')]);_0x1a0a67[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x1a0a67['model'],_0x1a0a67['query']);_0xec3b32['attributes']=_[_0x0baf('0x3b')](_0x1a0a67[_0x0baf('0x36')],qs[_0x0baf('0x3d')](_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x3d')]));_0xec3b32[_0x0baf('0x3c')]=_0xec3b32['attributes']['length']?_0xec3b32[_0x0baf('0x3c')]:_0x1a0a67['model'];if(!_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x3e')]('nolimit')){_0xec3b32[_0x0baf('0x25')]=qs[_0x0baf('0x25')](_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x25')]);_0xec3b32[_0x0baf('0x23')]=qs[_0x0baf('0x23')](_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x23')]);}_0xec3b32[_0x0baf('0x40')]=qs['sort'](_0x27ddc7['query']['sort']);_0xec3b32['where']=qs['filters'](_[_0x0baf('0x42')](_0x27ddc7[_0x0baf('0x39')],_0x1a0a67[_0x0baf('0x3a')]));_0xec3b32[_0x0baf('0x44')]['ChatWebsiteId']=_0x468363['id'];if(_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x43')]){_0xec3b32['where']=_['merge'](_0xec3b32[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0xec3b32[_0x0baf('0x3c')],function(_0x442e5f){var _0x30b35e={};_0x30b35e[_0x442e5f]={'$like':'%'+_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x43')]+'%'};return _0x30b35e;})});}_0xec3b32=_[_0x0baf('0x45')]({},_0xec3b32,_0x27ddc7['options']);return db[_0x0baf('0x5a')][_0x0baf('0x26')]({'where':_0xec3b32['where']})[_0x0baf('0x15')](function(_0x2db4ec){_0x185473['count']=_0x2db4ec;if(_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x49')]){_0xec3b32[_0x0baf('0x4a')]=[{'all':!![]}];}return db[_0x0baf('0x5a')][_0x0baf('0x5b')](_0xec3b32);})['then'](function(_0x4807fc){_0x185473[_0x0baf('0x4b')]=_0x4807fc;return _0x185473;});}})[_0x0baf('0x15')](respondWithFilteredResult(_0x4c05d6,_0xec3b32))['catch'](handleError(_0x4c05d6,null));};exports[_0x0baf('0x5c')]=function(_0x59dad5,_0x21ad25){return db['ChatWebsite'][_0x0baf('0x54')]({'where':{'id':_0x59dad5[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x21ad25,null))['then'](function(_0x3c2bc1){if(_0x3c2bc1){return _0x3c2bc1['removeDispositions'](_0x59dad5[_0x0baf('0x39')][_0x0baf('0x5d')]);}})[_0x0baf('0x15')](respondWithStatusCode(_0x21ad25,null))[_0x0baf('0x1f')](handleError(_0x21ad25,null));};exports[_0x0baf('0x5e')]=function(_0x52e845,_0x866e6e){if(_0x52e845[_0x0baf('0x4f')]['id']){delete _0x52e845['body']['id'];}return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x52e845[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x866e6e,null))[_0x0baf('0x15')](function(_0x250df2){if(_0x250df2){_0x52e845[_0x0baf('0x4f')][_0x0baf('0x5f')]=_0x250df2['id'];return db[_0x0baf('0x60')][_0x0baf('0x4e')](_0x52e845[_0x0baf('0x4f')]);}})[_0x0baf('0x15')](respondWithResult(_0x866e6e,null))['catch'](handleError(_0x866e6e,null));};exports['getAnswers']=function(_0x29a036,_0x322a09){var _0x384c29={'raw':![],'where':{}};var _0x52f267={};var _0x507783={'count':0x0,'rows':[]};return db[_0x0baf('0x33')][_0x0baf('0x59')]({'where':{'id':_0x29a036[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x322a09,null))[_0x0baf('0x15')](function(_0x3033c8){if(_0x3033c8){_0x52f267[_0x0baf('0x36')]=_[_0x0baf('0x38')](db[_0x0baf('0x60')]['rawAttributes']);_0x52f267[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x29a036[_0x0baf('0x39')]);_0x52f267[_0x0baf('0x3a')]=_['intersection'](_0x52f267['model'],_0x52f267['query']);_0x384c29[_0x0baf('0x3c')]=_[_0x0baf('0x3b')](_0x52f267['model'],qs['fields'](_0x29a036[_0x0baf('0x39')][_0x0baf('0x3d')]));_0x384c29['attributes']=_0x384c29[_0x0baf('0x3c')][_0x0baf('0x61')]?_0x384c29[_0x0baf('0x3c')]:_0x52f267[_0x0baf('0x36')];if(!_0x29a036[_0x0baf('0x39')][_0x0baf('0x3e')](_0x0baf('0x3f'))){_0x384c29[_0x0baf('0x25')]=qs[_0x0baf('0x25')](_0x29a036[_0x0baf('0x39')][_0x0baf('0x25')]);_0x384c29[_0x0baf('0x23')]=qs['offset'](_0x29a036[_0x0baf('0x39')][_0x0baf('0x23')]);}_0x384c29[_0x0baf('0x40')]=qs[_0x0baf('0x41')](_0x29a036[_0x0baf('0x39')][_0x0baf('0x41')]);_0x384c29['where']=qs[_0x0baf('0x3a')](_[_0x0baf('0x42')](_0x29a036[_0x0baf('0x39')],_0x52f267[_0x0baf('0x3a')]));_0x384c29[_0x0baf('0x44')]['ChatWebsiteId']=_0x3033c8['id'];if(_0x29a036[_0x0baf('0x39')][_0x0baf('0x43')]){_0x384c29[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0x384c29[_0x0baf('0x44')],{'$or':_['map'](_0x384c29['attributes'],function(_0xb5f4e5){var _0x5a2454={};_0x5a2454[_0xb5f4e5]={'$like':'%'+_0x29a036[_0x0baf('0x39')]['filter']+'%'};return _0x5a2454;})});}_0x384c29=_[_0x0baf('0x45')]({},_0x384c29,_0x29a036[_0x0baf('0x48')]);return db[_0x0baf('0x60')][_0x0baf('0x26')]({'where':_0x384c29['where']})[_0x0baf('0x15')](function(_0x106ffa){_0x507783[_0x0baf('0x26')]=_0x106ffa;if(_0x29a036['query']['includeAll']){_0x384c29['include']=[{'all':!![]}];}return db['CannedAnswer'][_0x0baf('0x5b')](_0x384c29);})[_0x0baf('0x15')](function(_0x2b7f13){_0x507783[_0x0baf('0x4b')]=_0x2b7f13;return _0x507783;});}})['then'](respondWithFilteredResult(_0x322a09,_0x384c29))[_0x0baf('0x1f')](handleError(_0x322a09,null));};exports[_0x0baf('0x62')]=function(_0x1843eb,_0x4b4ef8){return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x1843eb['params']['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x4b4ef8,null))['then'](function(_0x8a0a1b){if(_0x8a0a1b){return _0x8a0a1b[_0x0baf('0x62')](_0x1843eb[_0x0baf('0x39')][_0x0baf('0x5d')]);}})['then'](respondWithStatusCode(_0x4b4ef8,null))['catch'](handleError(_0x4b4ef8,null));};exports[_0x0baf('0x63')]=function(_0x4e1a7e,_0x3b4ae3){_0x4e1a7e[_0x0baf('0x4f')][_0x0baf('0x64')]=_0x4e1a7e[_0x0baf('0x65')][_0x0baf('0x66')];return db['ChatWebsite'][_0x0baf('0x54')]({'where':{'id':_0x4e1a7e['params']['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x3b4ae3,null))['then'](saveUpdates(_0x4e1a7e[_0x0baf('0x4f')],null))['then'](respondWithResult(_0x3b4ae3,null))[_0x0baf('0x1f')](handleError(_0x3b4ae3,null));};exports[_0x0baf('0x67')]=function(_0x443f62,_0x5033f3){_0x443f62['body'][_0x0baf('0x68')]=_0x443f62[_0x0baf('0x65')][_0x0baf('0x66')];return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x443f62[_0x0baf('0x4d')]['id']}})['then'](handleEntityNotFound(_0x5033f3,null))[_0x0baf('0x15')](saveUpdates(_0x443f62['body'],null))[_0x0baf('0x15')](respondWithResult(_0x5033f3,null))['catch'](handleError(_0x5033f3,null));};exports[_0x0baf('0x69')]=function(_0x4df797,_0x30f32b){_0x4df797['body'][_0x0baf('0x6a')]=_0x4df797[_0x0baf('0x65')]['filename'];return db['ChatWebsite'][_0x0baf('0x54')]({'where':{'id':_0x4df797[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x30f32b,null))[_0x0baf('0x15')](saveUpdates(_0x4df797['body'],null))['then'](respondWithResult(_0x30f32b,null))[_0x0baf('0x1f')](handleError(_0x30f32b,null));};exports[_0x0baf('0x6b')]=function(_0x116d52,_0x2c7417){_0x116d52[_0x0baf('0x4f')][_0x0baf('0x6c')]=_0x116d52[_0x0baf('0x65')][_0x0baf('0x66')];return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x116d52['params']['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x2c7417,null))['then'](saveUpdates(_0x116d52[_0x0baf('0x4f')],null))[_0x0baf('0x15')](respondWithResult(_0x2c7417,null))[_0x0baf('0x1f')](handleError(_0x2c7417,null));};exports[_0x0baf('0x6d')]=function(_0x4d7d29,_0x227fbd){var _0x647233=path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],_0x0baf('0x70'));var _0x2c2b77={'where':{'id':_0x4d7d29[_0x0baf('0x4d')]['id']},'attributes':['id',_0x0baf('0x64')],'raw':!![]};var _0xb61593=![];return require('../../config/license/util')[_0x0baf('0x71')]()[_0x0baf('0x15')](function(_0x4d501e){if(_0x4d501e){_0xb61593=_0x4d501e[_0x0baf('0x72')];}})[_0x0baf('0x15')](function(){return db[_0x0baf('0x33')][_0x0baf('0x54')](_0x2c2b77);})[_0x0baf('0x15')](handleEntityNotFound(_0x227fbd,null))[_0x0baf('0x15')](function(_0x3c5654){if(_0x3c5654){if(!_[_0x0baf('0x73')](_0x3c5654[_0x0baf('0x64')])){if(fs['existsSync'](path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],_0x0baf('0x74'),_0x3c5654[_0x0baf('0x64')]))&&_0xb61593){_0x647233=path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],'server/files/images/logos/',_0x3c5654[_0x0baf('0x64')]);}}return _0x227fbd[_0x0baf('0x75')](_0x647233);}})[_0x0baf('0x1f')](handleError(_0x227fbd,null));};exports['getAvatar']=function(_0x49855a,_0x5adbd9){var _0x1adb84=path[_0x0baf('0x6e')](config['root'],_0x0baf('0x76'));var _0x577536={'where':{'id':_0x49855a[_0x0baf('0x4d')]['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db[_0x0baf('0x33')][_0x0baf('0x54')](_0x577536)['then'](handleEntityNotFound(_0x5adbd9,null))[_0x0baf('0x15')](function(_0x290686){if(_0x290686){if(!_[_0x0baf('0x73')](_0x290686[_0x0baf('0x68')])){if(fs[_0x0baf('0x77')](path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],'server/files/images/avatars/',_0x290686[_0x0baf('0x68')]))){_0x1adb84=path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],_0x0baf('0x78'),_0x290686[_0x0baf('0x68')]);}}return _0x5adbd9[_0x0baf('0x75')](_0x1adb84);}})[_0x0baf('0x1f')](handleError(_0x5adbd9,null));};exports[_0x0baf('0x79')]=function(_0x4415c2,_0x46103a){var _0x308b3f=path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],_0x0baf('0x7a'));var _0x59dd6c={'where':{'id':_0x4415c2['params']['id']},'attributes':['id',_0x0baf('0x6a'),_0x0baf('0x7b')],'raw':!![]};return db[_0x0baf('0x33')][_0x0baf('0x54')](_0x59dd6c)['then'](handleEntityNotFound(_0x46103a,null))[_0x0baf('0x15')](function(_0xc6c049){if(_0xc6c049){if(!_[_0x0baf('0x73')](_0xc6c049[_0x0baf('0x6a')])){if(fs[_0x0baf('0x77')](path[_0x0baf('0x6e')](config['root'],_0x0baf('0x78'),_0xc6c049[_0x0baf('0x6a')]))&&_0xc6c049[_0x0baf('0x7b')]){_0x308b3f=path['join'](config[_0x0baf('0x6f')],_0x0baf('0x78'),_0xc6c049[_0x0baf('0x6a')]);}}return _0x46103a['download'](_0x308b3f);}})['catch'](handleError(_0x46103a,null));};exports['getSystemAvatar']=function(_0x11a85a,_0x51c895){var _0x2f0104=path[_0x0baf('0x6e')](config['root'],_0x0baf('0x7c'));var _0x5b5cd5={'where':{'id':_0x11a85a['params']['id']},'attributes':['id',_0x0baf('0x6c')],'raw':!![]};return db['ChatWebsite'][_0x0baf('0x54')](_0x5b5cd5)['then'](handleEntityNotFound(_0x51c895,null))['then'](function(_0x56c377){if(_0x56c377){if(!_[_0x0baf('0x73')](_0x56c377[_0x0baf('0x6c')])){if(fs[_0x0baf('0x77')](path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],_0x0baf('0x78'),_0x56c377[_0x0baf('0x6c')]))){_0x2f0104=path['join'](config[_0x0baf('0x6f')],_0x0baf('0x78'),_0x56c377[_0x0baf('0x6c')]);}}return _0x51c895['download'](_0x2f0104);}})[_0x0baf('0x1f')](handleError(_0x51c895,null));};exports[_0x0baf('0x7d')]=function(_0x12311d,_0x52c7f7){var _0x25eccd=require('user-agent-parser');var _0x235bd5=new _0x25eccd();var _0x12ff07=_0x235bd5['setUA'](_0x12311d[_0x0baf('0x7e')][_0x0baf('0x7f')])[_0x0baf('0x80')]();var _0x1805ff={'body':_0x12311d['body'],'channel':_0x0baf('0x81')};var _0x39eb13=[];var _0x4d4eab=[];var _0x5054f9={};var _0x1ac8eb=![];return db[_0x0baf('0x82')][_0x0baf('0x57')]()[_0x0baf('0x15')](function(_0x4d4a7f){if(!_0x4d4a7f){throw new db['Sequelize'][(_0x0baf('0x83'))](_0x0baf('0x84'));}_0x39eb13=_[_0x0baf('0x85')](_[_0x0baf('0x38')](_0x4d4a7f),[_0x0baf('0x86'),'updatedAt']);_0x4d4eab=_[_0x0baf('0x85')](_[_0x0baf('0x38')](_0x4d4a7f),['createdAt',_0x0baf('0x87'),_0x0baf('0x88'),'ListId']);if(_0x12311d[_0x0baf('0x4f')]['id']){delete _0x12311d[_0x0baf('0x4f')]['id'];}if(_[_0x0baf('0x73')](_0x12311d[_0x0baf('0x4f')][_0x0baf('0x89')])){throw new db[(_0x0baf('0x8a'))][(_0x0baf('0x83'))](_0x0baf('0x8b'));}if(_['isNil'](_0x12311d[_0x0baf('0x4f')][_0x0baf('0x4f')])||_0x12311d[_0x0baf('0x4f')][_0x0baf('0x4f')]===''){throw new db['Sequelize'][(_0x0baf('0x83'))](_0x0baf('0x8c'));}if(_['isNil'](_0x12311d[_0x0baf('0x4f')][_0x0baf('0x8d')])){throw new db[(_0x0baf('0x8a'))][(_0x0baf('0x83'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4d4eab);}if(!_[_0x0baf('0x8e')](_0x4d4eab,_0x12311d[_0x0baf('0x4f')][_0x0baf('0x8d')])){throw new db[(_0x0baf('0x8a'))][(_0x0baf('0x83'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4d4eab);}_0x5054f9[_0x12311d[_0x0baf('0x4f')][_0x0baf('0x8d')]]=_0x12311d[_0x0baf('0x4f')]['from'];})[_0x0baf('0x15')](function(){return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x12311d[_0x0baf('0x4d')]['id']},'include':[{'model':db[_0x0baf('0x8f')],'as':'List','include':[{'model':db['CmContact'],'as':_0x0baf('0x90'),'where':_0x5054f9,'limit':0x1,'order':[[_0x0baf('0x87'),_0x0baf('0x91')]]}]},{'model':db['ChatApplication'],'as':_0x0baf('0x92')}]});})[_0x0baf('0x15')](handleEntityNotFound(_0x52c7f7,null))[_0x0baf('0x15')](function(_0x3cfb49){if(_0x3cfb49&&_0x3cfb49[_0x0baf('0x93')]){_0x1805ff[_0x0baf('0x94')]=_0x3cfb49;_0x1805ff[_0x0baf('0x95')]=_0x3cfb49[_0x0baf('0x92')];_0x1805ff[_0x0baf('0x96')]=_0x3cfb49[_0x0baf('0x93')];_0x1805ff['applications']=_[_0x0baf('0x97')](_0x1805ff[_0x0baf('0x95')],[_0x0baf('0x98')],[_0x0baf('0x99')]);if(_0x1805ff['account'][_0x0baf('0x92')]){delete _0x1805ff[_0x0baf('0x94')][_0x0baf('0x92')];}if(_0x1805ff['account'][_0x0baf('0x93')]&&_0x1805ff[_0x0baf('0x94')][_0x0baf('0x93')][_0x0baf('0x90')][_0x0baf('0x61')]){return _0x1805ff['account'][_0x0baf('0x93')][_0x0baf('0x90')][0x0];}var _0x53df55=_['defaults'](_0x12311d[_0x0baf('0x4f')],{'firstName':_0x12311d[_0x0baf('0x4f')][_0x0baf('0x89')],'ListId':_0x3cfb49[_0x0baf('0x9a')]});_0x53df55[_0x12311d[_0x0baf('0x4f')][_0x0baf('0x8d')]]=_0x12311d[_0x0baf('0x4f')]['from'];return db['CmContact'][_0x0baf('0x4e')](_0x53df55,{'fields':_0x39eb13,'raw':!![]});}})[_0x0baf('0x15')](handleEntityNotFound(_0x52c7f7,null))[_0x0baf('0x15')](function(_0x47de3f){_0x1805ff[_0x0baf('0x9b')]=_0x47de3f;var _0x3a6bf8=_0x12311d['body'][_0x0baf('0x9c')];if(_0x12311d[_0x0baf('0x7e')]['cf-connecting-ip']){_0x3a6bf8=_0x12311d[_0x0baf('0x7e')][_0x0baf('0x9d')];}else if(_0x12311d[_0x0baf('0x7e')]['x-forwarded-for']){_0x3a6bf8=_[_0x0baf('0x9e')](_0x12311d[_0x0baf('0x7e')][_0x0baf('0x9f')][_0x0baf('0xa0')](','));}if(_0x47de3f){var _0x3021f7={'ContactId':_0x47de3f['id'],'ChatWebsiteId':_0x12311d[_0x0baf('0x4d')]['id'],'from':(_0x47de3f[_0x0baf('0xa1')]||'')+'\x20'+(_0x47de3f['lastName']||''),'customerIp':_0x3a6bf8,'customerPort':_0x12311d[_0x0baf('0x7e')]['x-real-port']?_0x12311d[_0x0baf('0x7e')][_0x0baf('0xa2')]:null,'referer':_0x12311d['body']['referer'],'browserName':_0x12ff07[_0x0baf('0xa3')][_0x0baf('0x2f')]&&_0x12ff07[_0x0baf('0xa3')]['version']?util[_0x0baf('0xa4')](_0x0baf('0xa5'),_0x12ff07[_0x0baf('0xa3')][_0x0baf('0x2f')],_0x12ff07[_0x0baf('0xa3')][_0x0baf('0xa6')]):_0x0baf('0xa7'),'browserVersion':_0x12ff07[_0x0baf('0xa3')]['version']||'unknown','osName':util[_0x0baf('0xa4')](_0x0baf('0xa5'),_0x12ff07['os']['name'],_0x12ff07['os'][_0x0baf('0xa6')]),'osVersion':_0x12ff07['os'][_0x0baf('0xa6')],'deviceModel':_0x12ff07[_0x0baf('0xa8')][_0x0baf('0x36')]&&_0x12ff07[_0x0baf('0xa8')][_0x0baf('0xa9')]?util[_0x0baf('0xa4')]('%s\x20%s\x20%s',_0x12ff07[_0x0baf('0xa8')]['model'],_0x12ff07[_0x0baf('0xa8')][_0x0baf('0xa9')],_0x12ff07['device']['type']):null,'deviceVendor':_0x12ff07[_0x0baf('0xa8')][_0x0baf('0xa9')],'deviceType':_0x12ff07[_0x0baf('0xa8')][_0x0baf('0x46')],'formData':JSON[_0x0baf('0x1a')](_0x12311d[_0x0baf('0x4f')])};var _0x18f7bd={'ChatWebsiteId':_0x12311d['params']['id'],'closed':![]};if(_0x12311d['body']['threadId']){_0x18f7bd[_0x0baf('0xaa')]=_0x12311d['body'][_0x0baf('0xaa')];return db[_0x0baf('0xab')]['find']({'where':_0x18f7bd})['then'](function(_0x40785c){if(_0x40785c){return[_0x40785c,![]];}_0x3021f7[_0x0baf('0xaa')]=_0x12311d[_0x0baf('0x4f')][_0x0baf('0xaa')];_0x3021f7[_0x0baf('0xac')]=_0x12311d['body'][_0x0baf('0xac')];return db[_0x0baf('0xab')][_0x0baf('0x4e')](_0x3021f7)[_0x0baf('0x15')](function(_0xf784df){return[_0xf784df,!![]];});});}_0x18f7bd[_0x0baf('0xad')]=_0x47de3f['id'];if(_0x12311d['body'][_0x0baf('0xae')]&&_0x12311d[_0x0baf('0x4f')][_0x0baf('0xae')]['id']){_0x18f7bd['id']=_0x12311d['body'][_0x0baf('0xae')]['id'];return db[_0x0baf('0xab')]['find']({'where':_0x18f7bd})[_0x0baf('0x15')](function(_0xe93008){if(_0xe93008){return[_0xe93008,![]];}return db[_0x0baf('0xab')][_0x0baf('0x4e')](_0x3021f7)['then'](function(_0x4ffc8e){return[_0x4ffc8e,!![]];});});}return db[_0x0baf('0xab')][_0x0baf('0x4e')](_0x3021f7)['then'](function(_0x43022c){return[_0x43022c,!![]];});}})[_0x0baf('0xaf')](function(_0xcd88a1,_0x13ac02){if(_0xcd88a1){_0x1ac8eb=_0x13ac02;if(!_0x13ac02){var _0x122a1a={'from':(_0x1805ff['contact'][_0x0baf('0xa1')]||'')+'\x20'+(_0x1805ff[_0x0baf('0x9b')][_0x0baf('0xb0')]||'')};if(_0x12311d[_0x0baf('0x4f')]['threadId']&&_0x12311d[_0x0baf('0x4f')]['messageId']&&_0x12311d[_0x0baf('0x4f')][_0x0baf('0xaa')]!=_0x12311d[_0x0baf('0x4f')]['messageId']){_0x122a1a[_0x0baf('0xaa')]=_0x12311d[_0x0baf('0x4f')][_0x0baf('0xb1')];}return _0xcd88a1[_0x0baf('0x28')](_0x122a1a);}else{return _0xcd88a1;}}})[_0x0baf('0x15')](function(_0x2a72b3){_0x1805ff[_0x0baf('0xae')]=_0x2a72b3[_0x0baf('0x2a')]({'plain':!![]});_0x1805ff[_0x0baf('0xae')][_0x0baf('0xb2')]=_0x1ac8eb;if(_0x1805ff[_0x0baf('0xae')][_0x0baf('0xb2')]){if(_0x1805ff['account']['autoclose']){_0x1805ff[_0x0baf('0x95')]['push']({'id':0x0,'priority':_0x1805ff['applications']['length']+0x1,'app':'close','appdata':_0x0baf('0xb3'),'interval':_0x0baf('0xb4')});}}return db['ChatMessage']['create']({'body':_0x12311d['body']['body'],'ChatWebsiteId':_0x12311d[_0x0baf('0x4d')]['id'],'ChatInteractionId':_0x2a72b3['id'],'direction':'in','ContactId':_0x1805ff['contact']['id'],'AttachmentId':_0x12311d[_0x0baf('0x4f')][_0x0baf('0xb5')]});})[_0x0baf('0x15')](function(_0xa1b680){_0x1805ff[_0x0baf('0x1d')]=_0xa1b680;if(_0x1805ff[_0x0baf('0xae')][_0x0baf('0xb6')]){return db[_0x0baf('0xb7')]['find']({'attributes':['id','name'],'where':{'id':_0x1805ff[_0x0baf('0xae')][_0x0baf('0xb6')]}})['then'](function(_0x21a72d){if(_0x21a72d){_0x1805ff['applications'][_0x0baf('0xb8')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x21a72d['name']+','+(_0x1805ff[_0x0baf('0x94')][_0x0baf('0xb9')]||0xa),'interval':_0x0baf('0xb4')});_0x1805ff[_0x0baf('0xba')]=!![];}return respondWithRpcPromise(_0x0baf('0xbb'),_0x0baf('0xbc'),_0x1805ff);});}return respondWithRpcPromise(_0x0baf('0xbb'),_0x0baf('0xbc'),_0x1805ff);})[_0x0baf('0x15')](function(_0x3348c6){respondWithRpcPromise(_0x0baf('0xbd'),_0x0baf('0xbd'),{'event':_0x0baf('0x7d'),'message':_0x3348c6},client9002);return _0x3348c6;})[_0x0baf('0x15')](respondWithResult(_0x52c7f7,null))[_0x0baf('0x1f')](handleError(_0x52c7f7,null));};exports[_0x0baf('0xbe')]=function(_0x5b61ff,_0x3c78ca){var _0x1a016f,_0x5b9e60,_0x9f2b22;var _0x39526b=[];var _0x5ee76f={};var _0x186d83=_0x5b61ff['files']||[];var _0x3f816f=[];var _0x569bbb;return db[_0x0baf('0x82')]['describe']()[_0x0baf('0x15')](function(_0x298cb5){if(!_0x298cb5){throw new db[(_0x0baf('0x8a'))][(_0x0baf('0x83'))]('no\x20available\x20attributes');}_0x39526b=_[_0x0baf('0x85')](_[_0x0baf('0x38')](_0x298cb5),[_0x0baf('0x86'),_0x0baf('0x87'),'CompanyId','ListId']);if(_0x5b61ff[_0x0baf('0x4f')]['id']){delete _0x5b61ff[_0x0baf('0x4f')]['id'];}if(_[_0x0baf('0x73')](_0x5b61ff[_0x0baf('0x4f')]['from'])){throw _0x3c78ca[_0x0baf('0x21')](0x1f4)[_0x0baf('0x30')](new db[(_0x0baf('0x8a'))]['ValidationError']('from\x20is\x20mandatory'));}if(_[_0x0baf('0x73')](_0x5b61ff['body'][_0x0baf('0x4f')])||_0x5b61ff['body'][_0x0baf('0x4f')]===''){throw _0x3c78ca[_0x0baf('0x21')](0x1f4)[_0x0baf('0x30')](new db['Sequelize'][(_0x0baf('0x83'))](_0x0baf('0x8c')));}if(_['isNil'](_0x5b61ff['body'][_0x0baf('0xbf')])){throw _0x3c78ca['status'](0x1f4)[_0x0baf('0x30')](new db[(_0x0baf('0x8a'))]['ValidationError']('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x39526b));}if(!_[_0x0baf('0x8e')](_0x39526b,_0x5b61ff[_0x0baf('0x4f')]['mapKeyOffline'])){throw _0x3c78ca[_0x0baf('0x21')](0x1f4)['send'](new db[(_0x0baf('0x8a'))][(_0x0baf('0x83'))]('mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x39526b));}_0x5ee76f[_0x5b61ff[_0x0baf('0x4f')][_0x0baf('0xbf')]]=_0x5b61ff[_0x0baf('0x4f')][_0x0baf('0x89')];})[_0x0baf('0x15')](function(){return db['ChatWebsite'][_0x0baf('0x54')]({'where':{'id':_0x5b61ff['params']['id']},'include':[{'model':db['CmList'],'as':'List'},{'model':db[_0x0baf('0xc0')],'as':_0x0baf('0xc0')}]});})['then'](handleEntityNotFound(_0x3c78ca,null))[_0x0baf('0x15')](function(_0x58e1ae){if(_0x58e1ae&&_0x58e1ae['List']){_0x5b9e60=_0x58e1ae;var _0x30a982=_[_0x0baf('0xd')](_0x5b61ff[_0x0baf('0x4f')],{'firstName':_0x5b61ff[_0x0baf('0x4f')][_0x0baf('0x89')],'phone':_0x5b61ff[_0x0baf('0x4f')][_0x0baf('0x89')],'ListId':_0x58e1ae[_0x0baf('0x9a')]});_0x30a982[_0x5b61ff[_0x0baf('0x4f')][_0x0baf('0xbf')]]=_0x5b61ff['body'][_0x0baf('0x89')];return db[_0x0baf('0x82')][_0x0baf('0xc1')]({'where':_0x5ee76f,'defaults':_0x30a982});}})[_0x0baf('0xaf')](function(_0x1d1ed6){if(_0x1d1ed6){_0x9f2b22=_0x1d1ed6;var _0x57b26e=fs[_0x0baf('0xc2')](path['join'](config[_0x0baf('0x6f')],_0x0baf('0xc3')),_0x0baf('0xc4'));var _0x44f822=ejs[_0x0baf('0xc5')](_0x57b26e,{'body':_[_0x0baf('0xc6')](_0x5b61ff[_0x0baf('0x4f')]['body']),'bodyTitle':_0x5b9e60[_0x0baf('0xc7')]});return db[_0x0baf('0xc8')][_0x0baf('0x4e')]({'body':_0x44f822,'plainBody':htmlToText[_0x0baf('0xc9')](_0x44f822),'ContactId':_0x1d1ed6['id'],'ChatWebsiteId':_0x5b9e60['id']});}})[_0x0baf('0x15')](function(_0x130ad1){_0x569bbb=_0x130ad1;if(_0x186d83[_0x0baf('0x61')]){var _0x17ef4f=_0x186d83[_0x0baf('0x37')](function(_0x1ee4c7){return{'name':_0x1ee4c7[_0x0baf('0xca')],'basename':_0x1ee4c7[_0x0baf('0x66')],'type':_0x1ee4c7[_0x0baf('0xcb')],'ChatOfflineMessageId':_0x130ad1['id']};});_0x3f816f=_0x17ef4f[_0x0baf('0x37')](_0x37430c=>{var _0x3fffe8={'filename':_0x37430c[_0x0baf('0x2f')],'path':path[_0x0baf('0x6e')](config['root'],_0x0baf('0xcc'),_0x0baf('0xcd'),_0x0baf('0xce'),_0x0baf('0xcf'),_0x37430c[_0x0baf('0xd0')])};return _0x3fffe8;});if(!_0x5b9e60[_0x0baf('0xd1')]){return db[_0x0baf('0xd2')]['transaction'](function(_0xa7a73a){return db[_0x0baf('0xd3')][_0x0baf('0xd4')](_0x17ef4f,{'transaction':_0xa7a73a});});}}})[_0x0baf('0x15')](function(){if(_0x569bbb){_0x1a016f=_0x569bbb;return db[_0x0baf('0xc0')][_0x0baf('0x59')]({'where':{'active':!![]},'include':[{'model':db[_0x0baf('0xd5')],'as':'Smtp','raw':!![]}]});}})[_0x0baf('0x15')](function(_0x17b3a9){if(_0x17b3a9&&_0x17b3a9[_0x0baf('0xd6')]&&_0x5b9e60[_0x0baf('0xd7')]&&_0x5b9e60[_0x0baf('0xd8')]){var _0x1912ff={'tls':{'rejectUnauthorized':![]}};if(_0x17b3a9['Smtp'][_0x0baf('0xd9')]){_0x1912ff[_0x0baf('0xd9')]=_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0xd9')];}else{_0x1912ff[_0x0baf('0xda')]=_0x17b3a9['Smtp']['host'];_0x1912ff[_0x0baf('0xdb')]=_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0xdb')];_0x1912ff[_0x0baf('0xdc')]=_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0xdc')];}if(_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0xdd')]){_0x1912ff[_0x0baf('0xde')]={'user':_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0x50')],'pass':_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0xdf')]};}return respondWithRpcPromise(_0x0baf('0xe0'),_0x0baf('0xe1'),{'account':_0x1912ff,'message':{'from':util[_0x0baf('0xa4')](_0x0baf('0xe2'),_0x17b3a9[_0x0baf('0x2f')],_0x17b3a9[_0x0baf('0xe3')]||_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0x50')]),'to':_0x5b9e60[_0x0baf('0xd8')],'subject':_0x5b9e60[_0x0baf('0xe4')],'html':_0x1a016f[_0x0baf('0x4f')],'attachments':_0x3f816f}},client9003)[_0x0baf('0x15')](function(){return _0x1a016f;})[_0x0baf('0x1f')](function(_0x1d4581){console['error'](_0x1d4581);});}})[_0x0baf('0x15')](function(){if(_0x5b9e60&&_0x5b9e60[_0x0baf('0xd1')]&&_0x5b9e60[_0x0baf('0xe5')]){var _0x14a397=[];if(_0x186d83[_0x0baf('0x61')]){_0x14a397=_0x186d83['map'](function(_0x3e3fba){return{'name':_0x3e3fba[_0x0baf('0xca')],'basename':_0x3e3fba[_0x0baf('0x66')],'type':_0x3e3fba[_0x0baf('0xcb')],'ChatOfflineMessageId':_0x569bbb['id']};});}var _0x1db841;if(!_[_0x0baf('0x73')](_0x5b9e60[_0x0baf('0xe6')])){var _0x237a20=_[_0x0baf('0x37')](_0x5b61ff[_0x0baf('0x4f')],function(_0xe840f2){return _0xe840f2;});var _0x12726d=_[_0x0baf('0xe7')](_0x237a20)[0x0];var _0x1b2278=_[_0x0baf('0xe8')](_0x12726d,function(_0x221aac){return _0x221aac;});_0x1db841=_0x1b2278[0x1][_0x5b9e60[_0x0baf('0xe6')]];}var _0x3e970a={'from':_0x9f2b22['email'],'firstName':_0x9f2b22[_0x0baf('0xa1')],'lastName':_0x9f2b22['lastName'],'mapKey':'email','message':{'from':_0x9f2b22[_0x0baf('0xe3')],'to':_0x5b9e60[_0x0baf('0xc0')][_0x0baf('0xe3')],'cc':'','subject':_['isNil'](_0x1db841)?_0x5b9e60[_0x0baf('0xe4')]:_0x1db841,'messageId':'','sentAt':new Date(),'attach':_0x14a397[_0x0baf('0x61')],'attachments':_0x14a397,'originChannel':_0x0baf('0xe9'),'ChatWebsiteId':_0x5b9e60['id'],'ChatOfflineMessageId':_0x1a016f['id'],'originTo':_0x5b9e60[_0x0baf('0xc0')][_0x0baf('0xe3')]},'body':_0x1a016f[_0x0baf('0x4f')]};var _0x49543e={'account':{'id':_0x5b9e60[_0x0baf('0xe5')]},'body':_0x3e970a,'log':_0x0baf('0xea')};return respondWithRpcPromise(_0x0baf('0xea'),_0x0baf('0xeb'),_0x49543e,client9001)[_0x0baf('0x15')](function(){return _0x1a016f;})[_0x0baf('0x1f')](function(_0x4c2bae){console[_0x0baf('0x1b')](_0x4c2bae);});}return;})['then'](function(){if(_0x1a016f){return _0x1a016f;}})[_0x0baf('0x15')](respondWithResult(_0x3c78ca,null))[_0x0baf('0x1f')](function(_0x47b168){console['error'](_0x0baf('0x1f'),_0x47b168);for(var _0x1de1dd of _0x186d83){var _0xf4da6a=path['join'](config[_0x0baf('0x6f')],_0x0baf('0xcc'),'files',_0x0baf('0xce'),_0x0baf('0xcf'),_0x1de1dd[_0x0baf('0x66')]);fs_extra[_0x0baf('0xec')](_0xf4da6a)[_0x0baf('0x1f')](function(_0x2759bb){console[_0x0baf('0x1b')]('Could\x20not\x20remove\x20attachment\x20file',_0xf4da6a,_0x2759bb);});}});};exports['addInteraction']=function(_0x131573,_0x1bd67f){return db[_0x0baf('0xab')][_0x0baf('0x54')]({'where':{'id':_0x131573[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x1bd67f,null))[_0x0baf('0x15')](function(_0x4316c5){if(_0x4316c5){return _0x4316c5[_0x0baf('0xed')](_0x131573[_0x0baf('0x4f')]['ids'],_['omit'](_0x131573[_0x0baf('0x4f')],[_0x0baf('0x5d'),'id'])||{});}})[_0x0baf('0x15')](respondWithResult(_0x1bd67f,null))['catch'](handleError(_0x1bd67f,null));};exports['getInteractions']=function(_0x3d740a,_0x2cb735){var _0xf82eb5={'raw':![],'where':{}};var _0x197bbe={};var _0x4a6a50={'count':0x0,'rows':[]};return db[_0x0baf('0x33')][_0x0baf('0x59')]({'where':{'id':_0x3d740a[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x2cb735,null))[_0x0baf('0x15')](function(_0x120c18){if(_0x120c18){_0x197bbe[_0x0baf('0x36')]=_[_0x0baf('0x38')](db['ChatInteraction'][_0x0baf('0x34')]);_0x197bbe[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x3d740a[_0x0baf('0x39')]);_0x197bbe[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x197bbe['model'],_0x197bbe[_0x0baf('0x39')]);_0xf82eb5[_0x0baf('0x3c')]=_['intersection'](_0x197bbe['model'],qs[_0x0baf('0x3d')](_0x3d740a['query'][_0x0baf('0x3d')]));_0xf82eb5[_0x0baf('0x3c')]=_0xf82eb5[_0x0baf('0x3c')][_0x0baf('0x61')]?_0xf82eb5['attributes']:_0x197bbe[_0x0baf('0x36')];if(!_0x3d740a[_0x0baf('0x39')][_0x0baf('0x3e')]('nolimit')){_0xf82eb5[_0x0baf('0x25')]=qs[_0x0baf('0x25')](_0x3d740a['query'][_0x0baf('0x25')]);_0xf82eb5['offset']=qs[_0x0baf('0x23')](_0x3d740a[_0x0baf('0x39')][_0x0baf('0x23')]);}_0xf82eb5[_0x0baf('0x40')]=qs['sort'](_0x3d740a[_0x0baf('0x39')][_0x0baf('0x41')]);_0xf82eb5['where']=qs[_0x0baf('0x3a')](_[_0x0baf('0x42')](_0x3d740a['query'],_0x197bbe[_0x0baf('0x3a')]));_0xf82eb5[_0x0baf('0x44')]['ChatWebsiteId']=_0x120c18['id'];if(_0x3d740a[_0x0baf('0x39')][_0x0baf('0x43')]){_0xf82eb5[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0xf82eb5[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0xf82eb5['attributes'],function(_0x181385){var _0x120f68={};_0x120f68[_0x181385]={'$like':'%'+_0x3d740a[_0x0baf('0x39')][_0x0baf('0x43')]+'%'};return _0x120f68;})});}_0xf82eb5=_[_0x0baf('0x45')]({},_0xf82eb5,_0x3d740a[_0x0baf('0x48')]);return db[_0x0baf('0xab')][_0x0baf('0x26')]({'where':_0xf82eb5[_0x0baf('0x44')]})[_0x0baf('0x15')](function(_0x72e44c){_0x4a6a50[_0x0baf('0x26')]=_0x72e44c;if(_0x3d740a[_0x0baf('0x39')][_0x0baf('0x49')]){_0xf82eb5[_0x0baf('0x4a')]=[{'model':db[_0x0baf('0x82')],'as':_0x0baf('0xee'),'required':![]},{'model':db[_0x0baf('0xb7')],'as':_0x0baf('0xef'),'attributes':[_0x0baf('0x2f'),_0x0baf('0xf0'),_0x0baf('0xf1')],'required':![]},{'model':db['Tag'],'as':_0x0baf('0xf2'),'attributes':['id',_0x0baf('0x2f'),'color'],'where':_0x3d740a['query']['tag']?{'id':_0x3d740a[_0x0baf('0x39')]['tag']}:undefined,'required':_0x3d740a['query']['tag']?!![]:![]}];}return db[_0x0baf('0xab')][_0x0baf('0x5b')](_0xf82eb5);})[_0x0baf('0x15')](function(_0x5ab269){_0x4a6a50[_0x0baf('0x4b')]=_0x5ab269;return _0x4a6a50;});}})['then'](respondWithFilteredResult(_0x2cb735,_0xf82eb5))['catch'](handleError(_0x2cb735,null));};function iftimePromise(_0x743f4b,_0xc93c2b){return respondWithRpcPromise(_0x0baf('0xf3'),'getSnippet',{'command':_0xc93c2b['timezone']?util[_0x0baf('0xa4')](_0x0baf('0xf4'),_0x743f4b[_0x0baf('0xf5')],_0xc93c2b[_0x0baf('0xf6')]):util[_0x0baf('0xa4')](_0x0baf('0xf7'),_0x743f4b['interval'])},client9002)['then'](function(_0x217cd8){var _0x21e3b1=_0x217cd8&&_0x217cd8['indexOf'](_0x0baf('0xf8'))>=0x0?!![]:![];logger[_0x0baf('0x16')](_0x0baf('0xf9'),_0xc93c2b['id'],_0x743f4b['id'],_0x743f4b[_0x0baf('0xf5')],_0x21e3b1?'ONLINE':_0x0baf('0xfa'),_0xc93c2b['timezone']?_0xc93c2b['timezone']:_0x0baf('0xfb'));return _0x21e3b1;})['catch'](function(_0x4a0f32){logger[_0x0baf('0x1b')](_0x0baf('0xf9'),_0xc93c2b['id'],_0x743f4b['id'],_0x743f4b['interval'],util[_0x0baf('0xfc')](_0x4a0f32,{'showHidden':![],'depth':null}),_0xc93c2b[_0x0baf('0xf6')]?_0xc93c2b[_0x0baf('0xf6')]:_0x0baf('0xfb'));return![];});}exports[_0x0baf('0xfd')]=function(_0x1ad92d,_0x532e4b){var _0x395ad5=0x0;var _0x47fcb1=0x0;var _0x2a4997=![];var _0x2997b3;var _0x4e0fc6;return db['ChatWebsite'][_0x0baf('0x54')]({'where':{'id':_0x1ad92d[_0x0baf('0x4d')]['id']},'include':[{'model':db['Interval'],'as':_0x0baf('0xfe'),'include':[{'model':db[_0x0baf('0xfe')],'as':_0x0baf('0xff'),'attributes':['id',_0x0baf('0xf5')],'raw':!![]}]}]})[_0x0baf('0x15')](handleEntityNotFound(_0x532e4b,null))[_0x0baf('0x15')](function(_0x20f37b){if(_0x20f37b){_0x2997b3=_0x20f37b;return _0x20f37b[_0x0baf('0x100')]({'raw':!![]});}})['then'](function(_0x3f136e){if(_0x2997b3){if(_0x3f136e){_0x4e0fc6=_0x3f136e;}}return require(_0x0baf('0x101'))['getLicense']();})['then'](function(_0x276d39){if(_0x276d39){_0x47fcb1=_0x276d39[_0x0baf('0x102')];_0x2a4997=_0x276d39['custom'];}})[_0x0baf('0x15')](function(){return db[_0x0baf('0xab')]['count']({'where':{'closed':![]}});})[_0x0baf('0x15')](function(_0x47825b){_0x395ad5=_0x47825b;if(_0x47fcb1&&_0x47825b>_0x47fcb1){return db[_0x0baf('0x103')][_0x0baf('0x59')]({'where':{'id':0x1}})[_0x0baf('0x15')](function(_0x9f5f16){if(_0x9f5f16){_0x9f5f16[_0x0baf('0x104')](_0x0baf('0x105'));}});}})[_0x0baf('0x15')](function(){if(_0x2997b3['Interval']&&_0x2997b3[_0x0baf('0xfe')][_0x0baf('0xff')]){var _0x547a10=[];for(var _0x4ef69a=0x0;_0x4ef69a<_0x2997b3[_0x0baf('0xfe')]['Intervals'][_0x0baf('0x61')];_0x4ef69a++){var _0x3752fd=_0x2997b3[_0x0baf('0xfe')][_0x0baf('0xff')][_0x4ef69a][_0x0baf('0x2a')]({'plain':!![]});_0x547a10[_0x0baf('0x106')](iftimePromise(_0x3752fd,_0x2997b3));}return BPromise[_0x0baf('0x107')](_0x547a10)[_0x0baf('0x15')](function(_0x148b9a){return _['some'](_0x148b9a);});}else{return!![];}})[_0x0baf('0x15')](function(_0x6721e9){var _0x2d4336=fs[_0x0baf('0xc2')](path['join'](config[_0x0baf('0x6f')],_0x0baf('0x108')),_0x0baf('0xc4'));var _0x550db0={'remote':_0x2997b3[_0x0baf('0x109')],'query':querystring[_0x0baf('0x1a')](_[_0x0baf('0x45')](_0x2997b3[_0x0baf('0x2a')]({'plain':!![]}),{'customerIp':_0x1ad92d['headers'][_0x0baf('0x9f')]||_0x1ad92d[_0x0baf('0x7e')]['x-real-ip']||_0x1ad92d['connection']['remoteAddress']||_0x1ad92d['ip'],'referer':_0x1ad92d[_0x0baf('0x7e')][_0x0baf('0x10a')],'openedInteractions':_0x395ad5,'maxInteractions':_0x47fcb1,'virtual':_0x2a4997[_0x0baf('0x102')],'online':_0x6721e9,'custom':_0x2a4997}))['replace'](/'/g,'\x5c\x27')};_0x532e4b[_0x0baf('0x30')](ejs[_0x0baf('0xc5')](Mustache[_0x0baf('0xc5')](_0x2d4336,_0x550db0),{'proactiveActions':_0x4e0fc6,'alignment':_0x2997b3[_0x0baf('0x10b')],'verticalAlignment':_0x2997b3[_0x0baf('0x10c')],'div_color':_0x2997b3['color'],'labelText':_0x2997b3[_0x0baf('0x10d')],'text_color':_0x2997b3[_0x0baf('0x10e')],'button_color':_0x2997b3[_0x0baf('0x10f')],'background_color':_0x2997b3[_0x0baf('0x110')]}));})[_0x0baf('0x1f')](handleError(_0x532e4b,null));};exports[_0x0baf('0x111')]=function(_0x5ab670,_0x4c4ffe){var _0x181980=_0x5ab670[_0x0baf('0x4d')]['id'];var _0x313e3e=_0x5ab670[_0x0baf('0x4f')];var _0x1cf4b5=0xc8;var _0x5d1985=null;return db[_0x0baf('0xd2')][_0x0baf('0x112')]({'isolationLevel':db[_0x0baf('0xd2')]['Transaction'][_0x0baf('0x113')][_0x0baf('0x114')]},function(_0x1e10a4){return db[_0x0baf('0x33')]['findOne']({'where':{'id':_0x181980},'transaction':_0x1e10a4})[_0x0baf('0x15')](function(_0x4d6e8e){if(_0x4d6e8e){return db[_0x0baf('0x115')][_0x0baf('0x29')]({'where':{'ChatWebsiteId':_0x181980},'transaction':_0x1e10a4})[_0x0baf('0x15')](function(){var _0x594a08=_['map'](_0x313e3e,function(_0x45e0ec){_0x45e0ec[_0x0baf('0x5f')]=_0x181980;return _0x45e0ec;});return db[_0x0baf('0x115')][_0x0baf('0xd4')](_0x594a08,{'transaction':_0x1e10a4});});}else{_0x1cf4b5=0x194;_0x5d1985=[];}});})['then'](function(){if(_0x1cf4b5!==0x194){return db['ChatApplication']['findAndCountAll']({'where':{'ChatWebsiteId':_0x181980},'order':_0x0baf('0x98')})[_0x0baf('0x15')](function(_0x46171d){_0x5d1985=_0x46171d;});}})['catch'](function(_0x2ba54d){_0x1cf4b5=0x1f4;logger[_0x0baf('0x1b')](_0x2ba54d[_0x0baf('0x2e')]);if(_0x2ba54d['name']){delete _0x2ba54d[_0x0baf('0x2f')];}_0x5d1985=_0x2ba54d;})[_0x0baf('0x116')](function(){if(_0x5d1985===null){_0x4c4ffe[_0x0baf('0x20')](_0x1cf4b5);}else{if(_0x1cf4b5===0x1f4){_0x4c4ffe['status'](_0x1cf4b5)['send'](_0x5d1985);}else{_0x4c4ffe['status'](_0x1cf4b5)['json'](_0x5d1985);}}});};exports[_0x0baf('0x117')]=function(_0x1c8b91,_0x3124bc){var _0x5ba16f={};var _0xcbc041={};var _0x5b1808;var _0x1abba8;return db[_0x0baf('0x33')]['findOne']({'where':{'id':_0x1c8b91['params']['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x3124bc,null))[_0x0baf('0x15')](function(_0xc0952d){if(_0xc0952d){_0x5b1808=_0xc0952d;_0xcbc041['model']=_[_0x0baf('0x38')](db[_0x0baf('0x115')]['rawAttributes']);_0xcbc041['query']=_[_0x0baf('0x38')](_0x1c8b91[_0x0baf('0x39')]);_0xcbc041[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0xcbc041[_0x0baf('0x36')],_0xcbc041[_0x0baf('0x39')]);_0x5ba16f[_0x0baf('0x3c')]=_[_0x0baf('0x3b')](_0xcbc041[_0x0baf('0x36')],qs[_0x0baf('0x3d')](_0x1c8b91[_0x0baf('0x39')][_0x0baf('0x3d')]));_0x5ba16f[_0x0baf('0x3c')]=_0x5ba16f[_0x0baf('0x3c')][_0x0baf('0x61')]?_0x5ba16f['attributes']:_0xcbc041[_0x0baf('0x36')];_0x5ba16f[_0x0baf('0x40')]=qs[_0x0baf('0x41')](_0x1c8b91['query']['sort']);_0x5ba16f[_0x0baf('0x44')]=qs[_0x0baf('0x3a')](_[_0x0baf('0x42')](_0x1c8b91[_0x0baf('0x39')],_0xcbc041[_0x0baf('0x3a')]));if(_0x1c8b91[_0x0baf('0x39')][_0x0baf('0x43')]){_0x5ba16f[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0x5ba16f[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0x5ba16f[_0x0baf('0x3c')],function(_0x4306bb){var _0x2c2d4b={};_0x2c2d4b[_0x4306bb]={'$like':'%'+_0x1c8b91[_0x0baf('0x39')]['filter']+'%'};return _0x2c2d4b;})});}_0x5ba16f=_[_0x0baf('0x45')]({},_0x5ba16f,_0x1c8b91[_0x0baf('0x48')]);return _0x5b1808[_0x0baf('0x117')](_0x5ba16f);}})[_0x0baf('0x15')](function(_0x4056b6){if(_0x4056b6){_0x1abba8=_0x4056b6[_0x0baf('0x61')];if(!_0x1c8b91[_0x0baf('0x39')]['hasOwnProperty']('nolimit')){_0x5ba16f[_0x0baf('0x25')]=qs['limit'](_0x1c8b91['query'][_0x0baf('0x25')]);_0x5ba16f['offset']=qs[_0x0baf('0x23')](_0x1c8b91[_0x0baf('0x39')][_0x0baf('0x23')]);}return _0x5b1808[_0x0baf('0x117')](_0x5ba16f);}})[_0x0baf('0x15')](function(_0x2a02e6){if(_0x2a02e6){return _0x2a02e6?{'count':_0x1abba8,'rows':_0x2a02e6}:null;}})[_0x0baf('0x15')](respondWithResult(_0x3124bc,null))[_0x0baf('0x1f')](handleError(_0x3124bc,null));};exports['addProactiveActions']=function(_0x4bcc76,_0xae7f71){return db[_0x0baf('0x118')][_0x0baf('0x54')]({'where':{'id':_0x4bcc76[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0xae7f71,null))['then'](function(_0x123037){if(_0x123037){return _0x123037[_0x0baf('0x119')](_0x4bcc76[_0x0baf('0x4f')][_0x0baf('0x5d')],_[_0x0baf('0x11a')](_0x4bcc76[_0x0baf('0x4f')],[_0x0baf('0x5d'),'id'])||{});}})[_0x0baf('0x15')](respondWithResult(_0xae7f71,null))[_0x0baf('0x1f')](handleError(_0xae7f71,null));};exports[_0x0baf('0x100')]=function(_0x238649,_0x30ef34){var _0x43c6a6={};var _0x2448dd={};var _0x4a999b;var _0x165555;return db[_0x0baf('0x33')][_0x0baf('0x59')]({'where':{'id':_0x238649[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x30ef34,null))['then'](function(_0x2723ea){if(_0x2723ea){_0x4a999b=_0x2723ea;_0x2448dd[_0x0baf('0x36')]=_[_0x0baf('0x38')](db['ChatProactiveAction']['rawAttributes']);_0x2448dd[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x238649['query']);_0x2448dd[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x2448dd['model'],_0x2448dd[_0x0baf('0x39')]);_0x43c6a6[_0x0baf('0x3c')]=_[_0x0baf('0x3b')](_0x2448dd[_0x0baf('0x36')],qs[_0x0baf('0x3d')](_0x238649[_0x0baf('0x39')][_0x0baf('0x3d')]));_0x43c6a6['attributes']=_0x43c6a6['attributes'][_0x0baf('0x61')]?_0x43c6a6['attributes']:_0x2448dd[_0x0baf('0x36')];_0x43c6a6[_0x0baf('0x40')]=qs[_0x0baf('0x41')](_0x238649['query'][_0x0baf('0x41')]);_0x43c6a6[_0x0baf('0x44')]=qs['filters'](_[_0x0baf('0x42')](_0x238649[_0x0baf('0x39')],_0x2448dd[_0x0baf('0x3a')]));if(_0x238649[_0x0baf('0x39')][_0x0baf('0x43')]){_0x43c6a6[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0x43c6a6[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0x43c6a6['attributes'],function(_0x2739c7){var _0x1bea85={};_0x1bea85[_0x2739c7]={'$like':'%'+_0x238649['query']['filter']+'%'};return _0x1bea85;})});}_0x43c6a6=_[_0x0baf('0x45')]({},_0x43c6a6,_0x238649[_0x0baf('0x48')]);return _0x4a999b[_0x0baf('0x100')](_0x43c6a6);}})[_0x0baf('0x15')](function(_0x34d2db){if(_0x34d2db){_0x165555=_0x34d2db['length'];if(!_0x238649['query'][_0x0baf('0x3e')]('nolimit')){_0x43c6a6[_0x0baf('0x25')]=qs['limit'](_0x238649[_0x0baf('0x39')][_0x0baf('0x25')]);_0x43c6a6[_0x0baf('0x23')]=qs['offset'](_0x238649[_0x0baf('0x39')][_0x0baf('0x23')]);}return _0x4a999b[_0x0baf('0x100')](_0x43c6a6);}})['then'](function(_0xb3a031){if(_0xb3a031){return _0xb3a031?{'count':_0x165555,'rows':_0xb3a031}:null;}})[_0x0baf('0x15')](respondWithResult(_0x30ef34,null))[_0x0baf('0x1f')](handleError(_0x30ef34,null));};exports[_0x0baf('0x11b')]=function(_0x3597fe,_0x132995){var _0x12c4bf=_0x3597fe[_0x0baf('0x39')][_0x0baf('0x11c')]===_0x0baf('0x11d')?'offlineForm':_0x0baf('0x11e');return db[_0x0baf('0x33')]['find']({'attributes':['id',_0x12c4bf],'where':{'id':_0x3597fe[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x132995,null))[_0x0baf('0x15')](function(_0xc2b22e){if(_0xc2b22e){var _0x51f903=_0xc2b22e[_0x12c4bf];var _0x423e9c=_0x51f903&&_0x51f903[_0x0baf('0x11f')]?_0x51f903[_0x0baf('0x11f')]:[];_0x132995['send']({'fromKey':_['isNil'](_0x51f903[_0x0baf('0x120')])?undefined:_0x51f903['fromKey'],'count':_0x423e9c[_0x0baf('0x61')],'rows':_0x423e9c});}})[_0x0baf('0x1f')](handleError(_0x132995,null));};exports['getOfflineMessages']=function(_0x53e81a,_0x572289){var _0x4fc936={'raw':![],'where':{}};var _0x423636={};var _0x51f03c={'count':0x0,'rows':[]};return db[_0x0baf('0x33')][_0x0baf('0x59')]({'where':{'id':_0x53e81a[_0x0baf('0x4d')]['id']}})['then'](handleEntityNotFound(_0x572289,null))['then'](function(_0xa010ed){if(_0xa010ed){_0x423636[_0x0baf('0x36')]=_['keys'](db[_0x0baf('0xc8')]['rawAttributes']);_0x423636[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x53e81a['query']);_0x423636[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x423636['model'],_0x423636[_0x0baf('0x39')]);_0x4fc936[_0x0baf('0x3c')]=_[_0x0baf('0x3b')](_0x423636[_0x0baf('0x36')],qs['fields'](_0x53e81a[_0x0baf('0x39')]['fields']));_0x4fc936[_0x0baf('0x3c')]=_0x4fc936[_0x0baf('0x3c')][_0x0baf('0x61')]?_0x4fc936['attributes']:_0x423636['model'];if(!_0x53e81a[_0x0baf('0x39')][_0x0baf('0x3e')](_0x0baf('0x3f'))){_0x4fc936['limit']=qs[_0x0baf('0x25')](_0x53e81a[_0x0baf('0x39')][_0x0baf('0x25')]);_0x4fc936['offset']=qs[_0x0baf('0x23')](_0x53e81a['query'][_0x0baf('0x23')]);}_0x4fc936[_0x0baf('0x40')]=qs[_0x0baf('0x41')](_0x53e81a[_0x0baf('0x39')][_0x0baf('0x41')]);_0x4fc936[_0x0baf('0x44')]=qs[_0x0baf('0x3a')](_[_0x0baf('0x42')](_0x53e81a[_0x0baf('0x39')],_0x423636['filters']));_0x4fc936[_0x0baf('0x44')][_0x0baf('0x5f')]=_0xa010ed['id'];if(_0x53e81a[_0x0baf('0x39')][_0x0baf('0x43')]){_0x4fc936[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0x4fc936[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0x4fc936[_0x0baf('0x3c')],function(_0x410e8e){var _0x54facf={};_0x54facf[_0x410e8e]={'$like':'%'+_0x53e81a[_0x0baf('0x39')][_0x0baf('0x43')]+'%'};return _0x54facf;})});}_0x4fc936=_['merge']({},_0x4fc936,_0x53e81a[_0x0baf('0x48')]);return db[_0x0baf('0xc8')][_0x0baf('0x26')]({'where':_0x4fc936[_0x0baf('0x44')]})[_0x0baf('0x15')](function(_0x1fb9f7){_0x51f03c[_0x0baf('0x26')]=_0x1fb9f7;if(_0x53e81a[_0x0baf('0x39')][_0x0baf('0x49')]){_0x4fc936['include']=[{'all':!![]}];}else{_0x4fc936[_0x0baf('0x4a')]=[{'model':db[_0x0baf('0x82')],'as':_0x0baf('0xee'),'required':![]},{'model':db[_0x0baf('0xd3')],'as':_0x0baf('0x121'),'required':![]}];}return db['ChatOfflineMessage']['findAll'](_0x4fc936);})[_0x0baf('0x15')](function(_0x58b532){_0x51f03c[_0x0baf('0x4b')]=_0x58b532;return _0x51f03c;});}})[_0x0baf('0x15')](respondWithFilteredResult(_0x572289,_0x4fc936))[_0x0baf('0x1f')](handleError(_0x572289,null));};exports[_0x0baf('0x122')]=function(_0x3a667a,_0x2629e9){return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x3a667a[_0x0baf('0x4d')]['id']}})['then'](handleEntityNotFound(_0x2629e9,null))['then'](function(_0x274787){if(_0x274787){return _0x274787[_0x0baf('0x122')](_0x3a667a[_0x0baf('0x4f')][_0x0baf('0x5d')],_['omit'](_0x3a667a[_0x0baf('0x4f')],['ids','id'])||{})[_0x0baf('0xaf')](function(_0x548f40){for(var _0x64dd21=0x0;_0x64dd21<_0x3a667a[_0x0baf('0x4f')][_0x0baf('0x5d')]['length'];_0x64dd21+=0x1){socket[_0x0baf('0x123')](_0x0baf('0x124'),{'UserId':Number(_0x3a667a['body']['ids'][_0x64dd21]),'ChatWebsiteId':Number(_0x3a667a['params']['id'])});}return _0x548f40;});}})['then'](respondWithResult(_0x2629e9,null))[_0x0baf('0x1f')](handleError(_0x2629e9,null));};exports[_0x0baf('0x125')]=function(_0x1c414,_0x27c810){return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x1c414[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x27c810,null))[_0x0baf('0x15')](function(_0xfa0191){if(_0xfa0191){return _0xfa0191[_0x0baf('0x125')](_0x1c414[_0x0baf('0x39')]['ids'])[_0x0baf('0x15')](function(){if(_['isArray'](_0x1c414[_0x0baf('0x39')][_0x0baf('0x5d')])){for(var _0x93dcbd=0x0;_0x93dcbd<_0x1c414[_0x0baf('0x39')][_0x0baf('0x5d')][_0x0baf('0x61')];_0x93dcbd+=0x1){socket[_0x0baf('0x123')]('userChatWebsite:remove',{'UserId':Number(_0x1c414[_0x0baf('0x39')]['ids'][_0x93dcbd]),'ChatWebsiteId':Number(_0x1c414[_0x0baf('0x4d')]['id'])});}}else{socket[_0x0baf('0x123')](_0x0baf('0x126'),{'UserId':Number(_0x1c414[_0x0baf('0x39')][_0x0baf('0x5d')]),'ChatWebsiteId':Number(_0x1c414['params']['id'])});}});}})['then'](respondWithStatusCode(_0x27c810,null))[_0x0baf('0x1f')](handleError(_0x27c810,null));};exports[_0x0baf('0x127')]=function(_0x28c059,_0x51c9e0){var _0x52faae={};var _0x47868e={};var _0x2849c1;var _0x3dd487;return db[_0x0baf('0x33')][_0x0baf('0x59')]({'where':{'id':_0x28c059[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x51c9e0,null))[_0x0baf('0x15')](function(_0x393408){if(_0x393408){_0x2849c1=_0x393408;_0x47868e['model']=_['keys'](db[_0x0baf('0xb7')][_0x0baf('0x34')]);_0x47868e[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x28c059['query']);_0x47868e[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x47868e[_0x0baf('0x36')],_0x47868e['query']);_0x52faae[_0x0baf('0x3c')]=_[_0x0baf('0x3b')](_0x47868e[_0x0baf('0x36')],qs[_0x0baf('0x3d')](_0x28c059['query'][_0x0baf('0x3d')]));_0x52faae[_0x0baf('0x3c')]=_0x52faae[_0x0baf('0x3c')]['length']?_0x52faae[_0x0baf('0x3c')]:_0x47868e[_0x0baf('0x36')];_0x52faae['order']=qs[_0x0baf('0x41')](_0x28c059[_0x0baf('0x39')][_0x0baf('0x41')]);_0x52faae[_0x0baf('0x44')]=qs[_0x0baf('0x3a')](_['pick'](_0x28c059['query'],_0x47868e[_0x0baf('0x3a')]));if(_0x28c059['query'][_0x0baf('0x43')]){_0x52faae[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0x52faae[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0x52faae[_0x0baf('0x3c')],function(_0xe30e49){var _0x3a5d39={};_0x3a5d39[_0xe30e49]={'$like':'%'+_0x28c059[_0x0baf('0x39')][_0x0baf('0x43')]+'%'};return _0x3a5d39;})});}_0x52faae=_[_0x0baf('0x45')]({},_0x52faae,_0x28c059[_0x0baf('0x48')]);return _0x2849c1[_0x0baf('0x127')](_0x52faae);}})['then'](function(_0x1684e5){if(_0x1684e5){_0x3dd487=_0x1684e5[_0x0baf('0x61')];if(!_0x28c059[_0x0baf('0x39')][_0x0baf('0x3e')](_0x0baf('0x3f'))){_0x52faae[_0x0baf('0x25')]=qs[_0x0baf('0x25')](_0x28c059[_0x0baf('0x39')][_0x0baf('0x25')]);_0x52faae[_0x0baf('0x23')]=qs[_0x0baf('0x23')](_0x28c059[_0x0baf('0x39')]['offset']);}return _0x2849c1[_0x0baf('0x127')](_0x52faae);}})[_0x0baf('0x15')](function(_0x1ea92f){if(_0x1ea92f){return _0x1ea92f?{'count':_0x3dd487,'rows':_0x1ea92f}:null;}})['then'](respondWithResult(_0x51c9e0,null))[_0x0baf('0x1f')](handleError(_0x51c9e0,null));};
\ No newline at end of file