Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index d8b4750..8ec3af5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf14b=['user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','findOne','hasOwnProperty','order','filter','include','findAll','rows','removeDispositions','ids','addAnswer','CannedAnswer','pick','removeAnswers','addLogo','sitepic','file','filename','addAvatar','addCustomerAvatar','addSystemAvatar','getLogo','join','root','../../config/license/util','custom','isNil','existsSync','server/files/images/logos/','download','server/files/images/avatars/default_avatar.png','agentAvatar','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','customerAvatar','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','systemAvatar','user-agent-parser','setUA','headers','user-agent','getResult','chat','CmContact','Sequelize','ValidationError','difference','createdAt','ListId','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','updatedAt','DESC','ChatApplication','Applications','applications','orderBy','priority','account','from','customerIp','cf-connecting-ip','first','split','firstName','x-real-port','browser','version','format','%s\x20%s','unknown','device','vendor','%s\x20%s\x20%s','threadId','ChatInteraction','externalUrl','interaction','spread','contact','lastName','messageId','created','push','close','unmanaged','*,*,*,*','AttachmentId','UserId','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','notify','offline','files','CompanyId','send','mapKeyOffline','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','ChatOfflineMessage','mimetype','attachments','offline-chat','basename','openNewInteraction','sequelize','Attachment','bulkCreate','Smtp','CloudProvider','forwardOffline','forwardOfflineAddress','getSmtpOptions','SendMail','sendMail','email','offlineMessageSubject','originalname','subjectOffline','toPairsIn','Chat','MailAccountId','NotifyMailAccount','notifyMail','server','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','Contact','User','Owner','fullname','Tag','Tags','color','tag','getSnippet','timezone','interval','iftime\x20%s','indexOf','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','Intervals','getProactiveActions','getLicense','virtual','License','increment','chatLicenseExceeded','all','some','remote','x-forwarded-for','x-real-ip','remoteAddress','referer','replace','alignment','labelText','textColor','backgroundColor','hideWhenOffline','IntervalId','addApplications','transaction','findAndCountAll','finally','getApplications','addProactiveActions','chatProactiveAction','ChatProactiveAction','getFields','false','offlineForm','onlineForm','items','Attachments','addAgents','emit','removeAgents','isArray','userChatWebsite:remove','getAgents','bluebird','mustache','util','path','ejs','fs-extra','lodash','querystring','ioredis','../../components/parsers/qs','api','../../config/environment','../../mysqldb','redis','defaults','localhost','./chatWebsite.socket','register','client','http','request','then','info','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','ChatWebsite,\x20%s,\x20%s','message','result','catch','sendStatus','status','json','offset','undefined','count','limit','set','Content-Range','update','destroy','ChatWebsites','UserProfileResource','end','stack','name','index','Pause','mandatoryDispositionPause','map','fieldName','type','model','keys','query','filters','intersection','attributes','fields','length','nolimit','sort','where','VIRTUAL','merge','options','ChatWebsite','includeAll','rawAttributes','find','create'];(function(_0x304fe0,_0x430c48){var _0x1649f8=function(_0x33a894){while(--_0x33a894){_0x304fe0['push'](_0x304fe0['shift']());}};_0x1649f8(++_0x430c48);}(_0xf14b,0xdd));var _0xbf14=function(_0x574d49,_0x180f7a){_0x574d49=_0x574d49-0x0;var _0x4be431=_0xf14b[_0x574d49];return _0x4be431;};'use strict';var BPromise=require(_0xbf14('0x0'));var Mustache=require(_0xbf14('0x1'));var util=require(_0xbf14('0x2'));var path=require(_0xbf14('0x3'));var ejs=require(_0xbf14('0x4'));var fs=require('fs');var fs_extra=require(_0xbf14('0x5'));var _=require(_0xbf14('0x6'));var querystring=require(_0xbf14('0x7'));var Redis=require(_0xbf14('0x8'));var qs=require(_0xbf14('0x9'));var logger=require('../../config/logger')(_0xbf14('0xa'));var config=require(_0xbf14('0xb'));var db=require(_0xbf14('0xc'))['db'];config[_0xbf14('0xd')]=_[_0xbf14('0xe')](config[_0xbf14('0xd')],{'host':_0xbf14('0xf'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xbf14('0xd')]));require(_0xbf14('0x10'))[_0xbf14('0x11')](socket);var htmlToText=require('html-to-text');var jayson=require('jayson/promise');var client=jayson[_0xbf14('0x12')][_0xbf14('0x13')]({'port':0x232c});var client9002=jayson[_0xbf14('0x12')][_0xbf14('0x13')]({'port':0x232a});var client9003=jayson[_0xbf14('0x12')][_0xbf14('0x13')]({'port':0x232b});var client9001=jayson['client']['http']({'port':0x2329});function respondWithRpcPromise(_0x489c04,_0xc11e9f,_0x29a064,_0x27d669){return new BPromise(function(_0x3ee705,_0x10b52e){var _0x3abb3f=_0x27d669||client;return _0x3abb3f[_0xbf14('0x14')](_0x489c04,_0x29a064)[_0xbf14('0x15')](function(_0x290957){logger[_0xbf14('0x16')]('ChatWebsite,\x20%s,\x20%s',_0xc11e9f,_0xbf14('0x17'));logger[_0xbf14('0x18')](_0xbf14('0x19'),_0xc11e9f,'request\x20sent',JSON[_0xbf14('0x1a')](_0x290957));if(_0x290957[_0xbf14('0x1b')]){if(_0x290957['error'][_0xbf14('0x1c')]===0x1f4){logger[_0xbf14('0x1b')](_0xbf14('0x1d'),_0xc11e9f,_0x290957[_0xbf14('0x1b')]['message']);return _0x10b52e(_0x290957[_0xbf14('0x1b')][_0xbf14('0x1e')]);}logger[_0xbf14('0x1b')]('ChatWebsite,\x20%s,\x20%s',_0xc11e9f,_0x290957[_0xbf14('0x1b')][_0xbf14('0x1e')]);return _0x3ee705(_0x290957[_0xbf14('0x1b')][_0xbf14('0x1e')]);}else{logger[_0xbf14('0x16')](_0xbf14('0x1d'),_0xc11e9f,'request\x20sent');_0x3ee705(_0x290957[_0xbf14('0x1f')]['message']);}})[_0xbf14('0x20')](function(_0x419696){logger[_0xbf14('0x1b')](_0xbf14('0x1d'),_0xc11e9f,_0x419696);_0x10b52e(_0x419696);});});}function respondWithStatusCode(_0x2b20b4,_0x16bf7a){_0x16bf7a=_0x16bf7a||0xcc;return function(_0x8c3ccc){if(_0x8c3ccc){return _0x2b20b4[_0xbf14('0x21')](_0x16bf7a);}return _0x2b20b4[_0xbf14('0x22')](_0x16bf7a)['end']();};}function respondWithResult(_0x288cb1,_0x5743f4){_0x5743f4=_0x5743f4||0xc8;return function(_0xdee1df){if(_0xdee1df){return _0x288cb1[_0xbf14('0x22')](_0x5743f4)[_0xbf14('0x23')](_0xdee1df);}};}function respondWithFilteredResult(_0x5c812b,_0x5bb89d){return function(_0x7bde1d){if(_0x7bde1d){var _0x265ae0=typeof _0x5bb89d[_0xbf14('0x24')]==='undefined'&&typeof _0x5bb89d['limit']===_0xbf14('0x25');var _0x3d631c=_0x7bde1d[_0xbf14('0x26')];var _0x37adae=_0x265ae0?0x0:_0x5bb89d[_0xbf14('0x24')];var _0x1c228b=_0x265ae0?_0x7bde1d[_0xbf14('0x26')]:_0x5bb89d['offset']+_0x5bb89d[_0xbf14('0x27')];var _0x766cb1;if(_0x1c228b>=_0x3d631c){_0x1c228b=_0x3d631c;_0x766cb1=0xc8;}else{_0x766cb1=0xce;}_0x5c812b['status'](_0x766cb1);return _0x5c812b[_0xbf14('0x28')](_0xbf14('0x29'),_0x37adae+'-'+_0x1c228b+'/'+_0x3d631c)[_0xbf14('0x23')](_0x7bde1d);}return null;};}function saveUpdates(_0x579930){return function(_0x2b8c7c){if(_0x2b8c7c){return _0x2b8c7c[_0xbf14('0x2a')](_0x579930)[_0xbf14('0x15')](function(_0x196ed1){return _0x196ed1;});}return null;};}function removeEntity(_0xf3d111){return function(_0x4f6ac4){if(_0x4f6ac4){return _0x4f6ac4[_0xbf14('0x2b')]()[_0xbf14('0x15')](function(){var _0x4bce0d=_0x4f6ac4['get']({'plain':!![]});var _0xa9bdd7=_0xbf14('0x2c');return db[_0xbf14('0x2d')][_0xbf14('0x2b')]({'where':{'type':_0xa9bdd7,'resourceId':_0x4bce0d['id']}})[_0xbf14('0x15')](function(){return _0x4f6ac4;});})[_0xbf14('0x15')](function(){_0xf3d111[_0xbf14('0x22')](0xcc)[_0xbf14('0x2e')]();});}};}function handleEntityNotFound(_0x1cb2a4){return function(_0x4b1c56){if(!_0x4b1c56){_0x1cb2a4[_0xbf14('0x21')](0x194);}return _0x4b1c56;};}function handleError(_0x5023f3,_0x37a77b){_0x37a77b=_0x37a77b||0x1f4;return function(_0x4bb4a4){logger[_0xbf14('0x1b')](_0x4bb4a4[_0xbf14('0x2f')]);if(_0x4bb4a4[_0xbf14('0x30')]){delete _0x4bb4a4[_0xbf14('0x30')];}_0x5023f3[_0xbf14('0x22')](_0x37a77b)['send'](_0x4bb4a4);};}exports[_0xbf14('0x31')]=function(_0x8e3c88,_0x5613f0){var _0x18ae0d={'include':[{'model':db[_0xbf14('0x32')],'as':_0xbf14('0x33')}]},_0x2e7f64={},_0x234494={'count':0x0,'rows':[]};var _0x8562b6=_[_0xbf14('0x34')](db['ChatWebsite']['rawAttributes'],function(_0x5eaded){return{'name':_0x5eaded[_0xbf14('0x35')],'type':_0x5eaded[_0xbf14('0x36')]['key']};});_0x2e7f64[_0xbf14('0x37')]=_['map'](_0x8562b6,_0xbf14('0x30'));_0x2e7f64['query']=_[_0xbf14('0x38')](_0x8e3c88[_0xbf14('0x39')]);_0x2e7f64[_0xbf14('0x3a')]=_[_0xbf14('0x3b')](_0x2e7f64['model'],_0x2e7f64[_0xbf14('0x39')]);_0x18ae0d[_0xbf14('0x3c')]=_[_0xbf14('0x3b')](_0x2e7f64['model'],qs[_0xbf14('0x3d')](_0x8e3c88[_0xbf14('0x39')][_0xbf14('0x3d')]));_0x18ae0d[_0xbf14('0x3c')]=_0x18ae0d[_0xbf14('0x3c')][_0xbf14('0x3e')]?_0x18ae0d[_0xbf14('0x3c')]:_0x2e7f64[_0xbf14('0x37')];if(!_0x8e3c88['query']['hasOwnProperty'](_0xbf14('0x3f'))){_0x18ae0d[_0xbf14('0x27')]=qs['limit'](_0x8e3c88[_0xbf14('0x39')][_0xbf14('0x27')]);_0x18ae0d['offset']=qs[_0xbf14('0x24')](_0x8e3c88[_0xbf14('0x39')]['offset']);}_0x18ae0d['order']=qs[_0xbf14('0x40')](_0x8e3c88['query'][_0xbf14('0x40')]);_0x18ae0d[_0xbf14('0x41')]=qs['filters'](_['pick'](_0x8e3c88[_0xbf14('0x39')],_0x2e7f64['filters']),_0x8562b6);if(_0x8e3c88['query']['filter']){_0x18ae0d['where']=_['merge'](_0x18ae0d[_0xbf14('0x41')],{'$or':_[_0xbf14('0x34')](_0x8562b6,function(_0x56c527){if(_0x56c527[_0xbf14('0x36')]!==_0xbf14('0x42')){var _0x2dc039={};_0x2dc039[_0x56c527['name']]={'$like':'%'+_0x8e3c88[_0xbf14('0x39')]['filter']+'%'};return _0x2dc039;}})});}_0x18ae0d=_[_0xbf14('0x43')]({},_0x18ae0d,_0x8e3c88[_0xbf14('0x44')]);var _0x32f87a={'where':_0x18ae0d['where']};return db[_0xbf14('0x45')][_0xbf14('0x26')](_0x32f87a)['then'](function(_0x353fc1){_0x234494[_0xbf14('0x26')]=_0x353fc1;if(_0x8e3c88[_0xbf14('0x39')][_0xbf14('0x46')]){_0x18ae0d['include']=[{'all':!![]}];}return db[_0xbf14('0x45')]['findAll'](_0x18ae0d);})['then'](function(_0x446416){_0x234494['rows']=_0x446416;return _0x234494;})[_0xbf14('0x15')](respondWithFilteredResult(_0x5613f0,_0x18ae0d))[_0xbf14('0x20')](handleError(_0x5613f0,null));};exports['show']=function(_0x2b7e1c,_0x3987ff){var _0xb24136={'raw':![],'where':{'id':_0x2b7e1c['params']['id']},'include':[{'model':db[_0xbf14('0x32')],'as':'mandatoryDispositionPause'}]},_0x47602c={};_0x47602c['model']=_[_0xbf14('0x38')](db['ChatWebsite'][_0xbf14('0x47')]);_0x47602c[_0xbf14('0x39')]=_[_0xbf14('0x38')](_0x2b7e1c[_0xbf14('0x39')]);_0x47602c[_0xbf14('0x3a')]=_[_0xbf14('0x3b')](_0x47602c[_0xbf14('0x37')],_0x47602c[_0xbf14('0x39')]);_0xb24136['attributes']=_[_0xbf14('0x3b')](_0x47602c['model'],qs['fields'](_0x2b7e1c[_0xbf14('0x39')][_0xbf14('0x3d')]));_0xb24136[_0xbf14('0x3c')]=_0xb24136['attributes']['length']?_0xb24136[_0xbf14('0x3c')]:_0x47602c['model'];if(_0x2b7e1c[_0xbf14('0x39')][_0xbf14('0x46')]){_0xb24136['include']=[{'all':!![]}];}_0xb24136=_['merge']({},_0xb24136,_0x2b7e1c['options']);return db[_0xbf14('0x45')][_0xbf14('0x48')](_0xb24136)[_0xbf14('0x15')](handleEntityNotFound(_0x3987ff,null))[_0xbf14('0x15')](respondWithResult(_0x3987ff,null))['catch'](handleError(_0x3987ff,null));};exports[_0xbf14('0x49')]=function(_0x121cf1,_0x41307a){return db['ChatWebsite'][_0xbf14('0x49')](_0x121cf1['body'],{})[_0xbf14('0x15')](function(_0x1240e3){var _0x48c93e=_0x121cf1[_0xbf14('0x4a')][_0xbf14('0x4b')]({'plain':!![]});if(!_0x48c93e)throw new Error(_0xbf14('0x4c'));if(_0x48c93e[_0xbf14('0x4d')]==='user'){var _0x194c8e=_0x1240e3[_0xbf14('0x4b')]({'plain':!![]});var _0x51fe2c='ChatWebsites';return db[_0xbf14('0x4e')][_0xbf14('0x48')]({'where':{'name':_0x51fe2c,'userProfileId':_0x48c93e['userProfileId']},'raw':!![]})[_0xbf14('0x15')](function(_0x171ca7){if(_0x171ca7&&_0x171ca7[_0xbf14('0x4f')]===0x0){return db[_0xbf14('0x2d')]['create']({'name':_0x194c8e[_0xbf14('0x30')],'resourceId':_0x194c8e['id'],'type':_0x171ca7['name'],'sectionId':_0x171ca7['id']},{})[_0xbf14('0x15')](function(){return _0x1240e3;});}else{return _0x1240e3;}})['catch'](function(_0x599d91){logger[_0xbf14('0x1b')](_0xbf14('0x50'),_0x599d91);throw _0x599d91;});}return _0x1240e3;})[_0xbf14('0x15')](respondWithResult(_0x41307a,0xc9))[_0xbf14('0x20')](handleError(_0x41307a,null));};exports['update']=function(_0x1ec366,_0x59b449){if(_0x1ec366[_0xbf14('0x51')]['id']){delete _0x1ec366['body']['id'];}return db[_0xbf14('0x45')][_0xbf14('0x48')]({'where':{'id':_0x1ec366[_0xbf14('0x52')]['id']},'include':[{'model':db[_0xbf14('0x32')],'as':_0xbf14('0x33')}]})[_0xbf14('0x15')](handleEntityNotFound(_0x59b449,null))[_0xbf14('0x15')](saveUpdates(_0x1ec366['body'],null))['then'](respondWithResult(_0x59b449,null))['catch'](handleError(_0x59b449,null));};exports[_0xbf14('0x2b')]=function(_0x1a1593,_0x145315){return db['ChatWebsite']['find']({'where':{'id':_0x1a1593[_0xbf14('0x52')]['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x145315,null))[_0xbf14('0x15')](removeEntity(_0x145315,null))[_0xbf14('0x20')](handleError(_0x145315,null));};exports[_0xbf14('0x53')]=function(_0x22e17b,_0x34edef){return db[_0xbf14('0x45')][_0xbf14('0x53')]()[_0xbf14('0x15')](respondWithResult(_0x34edef,null))[_0xbf14('0x20')](handleError(_0x34edef,null));};exports[_0xbf14('0x54')]=function(_0x230d0c,_0xae633b){if(_0x230d0c[_0xbf14('0x51')]['id']){delete _0x230d0c[_0xbf14('0x51')]['id'];}return db['ChatWebsite']['find']({'where':{'id':_0x230d0c[_0xbf14('0x52')]['id']}})['then'](handleEntityNotFound(_0xae633b,null))[_0xbf14('0x15')](function(_0x3eb6eb){if(_0x3eb6eb){_0x230d0c['body'][_0xbf14('0x55')]=_0x3eb6eb['id'];return db[_0xbf14('0x56')][_0xbf14('0x49')](_0x230d0c[_0xbf14('0x51')]);}})[_0xbf14('0x15')](respondWithResult(_0xae633b,null))['catch'](handleError(_0xae633b,null));};exports[_0xbf14('0x57')]=function(_0x217c93,_0x4b9c4f){var _0x22ed50={'raw':![],'where':{}};var _0x4992df={};var _0x1db0fc={'count':0x0,'rows':[]};return db[_0xbf14('0x45')][_0xbf14('0x58')]({'where':{'id':_0x217c93['params']['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x4b9c4f,null))[_0xbf14('0x15')](function(_0x92cfdb){if(_0x92cfdb){_0x4992df[_0xbf14('0x37')]=_[_0xbf14('0x38')](db['Disposition'][_0xbf14('0x47')]);_0x4992df[_0xbf14('0x39')]=_[_0xbf14('0x38')](_0x217c93[_0xbf14('0x39')]);_0x4992df[_0xbf14('0x3a')]=_[_0xbf14('0x3b')](_0x4992df[_0xbf14('0x37')],_0x4992df[_0xbf14('0x39')]);_0x22ed50[_0xbf14('0x3c')]=_[_0xbf14('0x3b')](_0x4992df['model'],qs['fields'](_0x217c93[_0xbf14('0x39')][_0xbf14('0x3d')]));_0x22ed50['attributes']=_0x22ed50['attributes']['length']?_0x22ed50[_0xbf14('0x3c')]:_0x4992df[_0xbf14('0x37')];if(!_0x217c93[_0xbf14('0x39')][_0xbf14('0x59')](_0xbf14('0x3f'))){_0x22ed50[_0xbf14('0x27')]=qs[_0xbf14('0x27')](_0x217c93[_0xbf14('0x39')][_0xbf14('0x27')]);_0x22ed50['offset']=qs[_0xbf14('0x24')](_0x217c93[_0xbf14('0x39')][_0xbf14('0x24')]);}_0x22ed50[_0xbf14('0x5a')]=qs['sort'](_0x217c93[_0xbf14('0x39')][_0xbf14('0x40')]);_0x22ed50[_0xbf14('0x41')]=qs[_0xbf14('0x3a')](_['pick'](_0x217c93[_0xbf14('0x39')],_0x4992df['filters']));_0x22ed50[_0xbf14('0x41')]['ChatWebsiteId']=_0x92cfdb['id'];if(_0x217c93['query'][_0xbf14('0x5b')]){_0x22ed50[_0xbf14('0x41')]=_[_0xbf14('0x43')](_0x22ed50['where'],{'$or':_[_0xbf14('0x34')](_0x22ed50[_0xbf14('0x3c')],function(_0x27c98f){var _0xf024e7={};_0xf024e7[_0x27c98f]={'$like':'%'+_0x217c93[_0xbf14('0x39')][_0xbf14('0x5b')]+'%'};return _0xf024e7;})});}_0x22ed50=_[_0xbf14('0x43')]({},_0x22ed50,_0x217c93[_0xbf14('0x44')]);return db[_0xbf14('0x56')]['count']({'where':_0x22ed50[_0xbf14('0x41')]})['then'](function(_0x3f094c){_0x1db0fc[_0xbf14('0x26')]=_0x3f094c;if(_0x217c93[_0xbf14('0x39')][_0xbf14('0x46')]){_0x22ed50[_0xbf14('0x5c')]=[{'all':!![]}];}return db[_0xbf14('0x56')][_0xbf14('0x5d')](_0x22ed50);})['then'](function(_0xa85170){_0x1db0fc[_0xbf14('0x5e')]=_0xa85170;return _0x1db0fc;});}})[_0xbf14('0x15')](respondWithFilteredResult(_0x4b9c4f,_0x22ed50))['catch'](handleError(_0x4b9c4f,null));};exports['removeDispositions']=function(_0x311e0d,_0x69245a){return db[_0xbf14('0x45')][_0xbf14('0x48')]({'where':{'id':_0x311e0d[_0xbf14('0x52')]['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x69245a,null))[_0xbf14('0x15')](function(_0x206788){if(_0x206788){return _0x206788[_0xbf14('0x5f')](_0x311e0d[_0xbf14('0x39')][_0xbf14('0x60')]);}})[_0xbf14('0x15')](respondWithStatusCode(_0x69245a,null))[_0xbf14('0x20')](handleError(_0x69245a,null));};exports[_0xbf14('0x61')]=function(_0x185d0a,_0x42566a){if(_0x185d0a[_0xbf14('0x51')]['id']){delete _0x185d0a[_0xbf14('0x51')]['id'];}return db[_0xbf14('0x45')][_0xbf14('0x48')]({'where':{'id':_0x185d0a['params']['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x42566a,null))[_0xbf14('0x15')](function(_0x4befe9){if(_0x4befe9){_0x185d0a[_0xbf14('0x51')][_0xbf14('0x55')]=_0x4befe9['id'];return db[_0xbf14('0x62')]['create'](_0x185d0a['body']);}})[_0xbf14('0x15')](respondWithResult(_0x42566a,null))['catch'](handleError(_0x42566a,null));};exports['getAnswers']=function(_0x1d47a8,_0x26e620){var _0x222580={'raw':![],'where':{}};var _0x2b5e4a={};var _0x1c6f1a={'count':0x0,'rows':[]};return db[_0xbf14('0x45')][_0xbf14('0x58')]({'where':{'id':_0x1d47a8['params']['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x26e620,null))['then'](function(_0x193ac3){if(_0x193ac3){_0x2b5e4a['model']=_[_0xbf14('0x38')](db[_0xbf14('0x62')]['rawAttributes']);_0x2b5e4a[_0xbf14('0x39')]=_[_0xbf14('0x38')](_0x1d47a8[_0xbf14('0x39')]);_0x2b5e4a[_0xbf14('0x3a')]=_[_0xbf14('0x3b')](_0x2b5e4a[_0xbf14('0x37')],_0x2b5e4a[_0xbf14('0x39')]);_0x222580[_0xbf14('0x3c')]=_[_0xbf14('0x3b')](_0x2b5e4a[_0xbf14('0x37')],qs['fields'](_0x1d47a8[_0xbf14('0x39')][_0xbf14('0x3d')]));_0x222580[_0xbf14('0x3c')]=_0x222580[_0xbf14('0x3c')]['length']?_0x222580[_0xbf14('0x3c')]:_0x2b5e4a[_0xbf14('0x37')];if(!_0x1d47a8[_0xbf14('0x39')][_0xbf14('0x59')]('nolimit')){_0x222580[_0xbf14('0x27')]=qs[_0xbf14('0x27')](_0x1d47a8[_0xbf14('0x39')]['limit']);_0x222580[_0xbf14('0x24')]=qs[_0xbf14('0x24')](_0x1d47a8[_0xbf14('0x39')][_0xbf14('0x24')]);}_0x222580['order']=qs[_0xbf14('0x40')](_0x1d47a8['query']['sort']);_0x222580[_0xbf14('0x41')]=qs[_0xbf14('0x3a')](_[_0xbf14('0x63')](_0x1d47a8[_0xbf14('0x39')],_0x2b5e4a[_0xbf14('0x3a')]));_0x222580['where'][_0xbf14('0x55')]=_0x193ac3['id'];if(_0x1d47a8[_0xbf14('0x39')][_0xbf14('0x5b')]){_0x222580[_0xbf14('0x41')]=_[_0xbf14('0x43')](_0x222580[_0xbf14('0x41')],{'$or':_[_0xbf14('0x34')](_0x222580[_0xbf14('0x3c')],function(_0x5c78e5){var _0x299bf3={};_0x299bf3[_0x5c78e5]={'$like':'%'+_0x1d47a8['query'][_0xbf14('0x5b')]+'%'};return _0x299bf3;})});}_0x222580=_['merge']({},_0x222580,_0x1d47a8['options']);return db['CannedAnswer'][_0xbf14('0x26')]({'where':_0x222580['where']})['then'](function(_0x5a3a75){_0x1c6f1a[_0xbf14('0x26')]=_0x5a3a75;if(_0x1d47a8[_0xbf14('0x39')][_0xbf14('0x46')]){_0x222580[_0xbf14('0x5c')]=[{'all':!![]}];}return db[_0xbf14('0x62')][_0xbf14('0x5d')](_0x222580);})['then'](function(_0x196a48){_0x1c6f1a[_0xbf14('0x5e')]=_0x196a48;return _0x1c6f1a;});}})[_0xbf14('0x15')](respondWithFilteredResult(_0x26e620,_0x222580))[_0xbf14('0x20')](handleError(_0x26e620,null));};exports[_0xbf14('0x64')]=function(_0x50d179,_0x4535f1){return db['ChatWebsite'][_0xbf14('0x48')]({'where':{'id':_0x50d179['params']['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x4535f1,null))[_0xbf14('0x15')](function(_0x6f4d41){if(_0x6f4d41){return _0x6f4d41['removeAnswers'](_0x50d179[_0xbf14('0x39')][_0xbf14('0x60')]);}})['then'](respondWithStatusCode(_0x4535f1,null))[_0xbf14('0x20')](handleError(_0x4535f1,null));};exports[_0xbf14('0x65')]=function(_0x170e0f,_0x7eef3b){_0x170e0f[_0xbf14('0x51')][_0xbf14('0x66')]=_0x170e0f[_0xbf14('0x67')][_0xbf14('0x68')];return db['ChatWebsite']['find']({'where':{'id':_0x170e0f['params']['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x7eef3b,null))['then'](saveUpdates(_0x170e0f[_0xbf14('0x51')],null))[_0xbf14('0x15')](respondWithResult(_0x7eef3b,null))[_0xbf14('0x20')](handleError(_0x7eef3b,null));};exports[_0xbf14('0x69')]=function(_0x1ac72e,_0x22debc){_0x1ac72e['body']['agentAvatar']=_0x1ac72e['file'][_0xbf14('0x68')];return db[_0xbf14('0x45')][_0xbf14('0x48')]({'where':{'id':_0x1ac72e[_0xbf14('0x52')]['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x22debc,null))[_0xbf14('0x15')](saveUpdates(_0x1ac72e['body'],null))[_0xbf14('0x15')](respondWithResult(_0x22debc,null))[_0xbf14('0x20')](handleError(_0x22debc,null));};exports[_0xbf14('0x6a')]=function(_0x117f89,_0x3b7f71){_0x117f89[_0xbf14('0x51')]['customerAvatar']=_0x117f89['file']['filename'];return db[_0xbf14('0x45')][_0xbf14('0x48')]({'where':{'id':_0x117f89[_0xbf14('0x52')]['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x3b7f71,null))[_0xbf14('0x15')](saveUpdates(_0x117f89[_0xbf14('0x51')],null))['then'](respondWithResult(_0x3b7f71,null))[_0xbf14('0x20')](handleError(_0x3b7f71,null));};exports[_0xbf14('0x6b')]=function(_0x5a3a16,_0x1154bb){_0x5a3a16[_0xbf14('0x51')]['systemAvatar']=_0x5a3a16[_0xbf14('0x67')][_0xbf14('0x68')];return db[_0xbf14('0x45')][_0xbf14('0x48')]({'where':{'id':_0x5a3a16[_0xbf14('0x52')]['id']}})['then'](handleEntityNotFound(_0x1154bb,null))['then'](saveUpdates(_0x5a3a16[_0xbf14('0x51')],null))[_0xbf14('0x15')](respondWithResult(_0x1154bb,null))[_0xbf14('0x20')](handleError(_0x1154bb,null));};exports[_0xbf14('0x6c')]=function(_0x3c10d2,_0x2fde47){var _0x10a89f=path[_0xbf14('0x6d')](config[_0xbf14('0x6e')],'server/files/images/logos/default_logo.svg');var _0x559070={'where':{'id':_0x3c10d2['params']['id']},'attributes':['id',_0xbf14('0x66')],'raw':!![]};var _0x5a38c4=![];return require(_0xbf14('0x6f'))['getLicense']()['then'](function(_0x1e3a49){if(_0x1e3a49){_0x5a38c4=_0x1e3a49[_0xbf14('0x70')];}})[_0xbf14('0x15')](function(){return db[_0xbf14('0x45')]['find'](_0x559070);})[_0xbf14('0x15')](handleEntityNotFound(_0x2fde47,null))[_0xbf14('0x15')](function(_0xd79a54){if(_0xd79a54){if(!_[_0xbf14('0x71')](_0xd79a54[_0xbf14('0x66')])){if(fs[_0xbf14('0x72')](path[_0xbf14('0x6d')](config[_0xbf14('0x6e')],'server/files/images/logos/',_0xd79a54[_0xbf14('0x66')]))&&_0x5a38c4){_0x10a89f=path[_0xbf14('0x6d')](config[_0xbf14('0x6e')],_0xbf14('0x73'),_0xd79a54[_0xbf14('0x66')]);}}return _0x2fde47[_0xbf14('0x74')](_0x10a89f);}})['catch'](handleError(_0x2fde47,null));};exports['getAvatar']=function(_0x3b40d7,_0x38a688){var _0x9ebb66=path[_0xbf14('0x6d')](config['root'],_0xbf14('0x75'));var _0xc97fa0={'where':{'id':_0x3b40d7['params']['id']},'attributes':['id',_0xbf14('0x76')],'raw':!![]};return db[_0xbf14('0x45')][_0xbf14('0x48')](_0xc97fa0)[_0xbf14('0x15')](handleEntityNotFound(_0x38a688,null))[_0xbf14('0x15')](function(_0x5d463c){if(_0x5d463c){if(!_['isNil'](_0x5d463c[_0xbf14('0x76')])){if(fs['existsSync'](path[_0xbf14('0x6d')](config[_0xbf14('0x6e')],'server/files/images/avatars/',_0x5d463c[_0xbf14('0x76')]))){_0x9ebb66=path[_0xbf14('0x6d')](config[_0xbf14('0x6e')],_0xbf14('0x77'),_0x5d463c[_0xbf14('0x76')]);}}return _0x38a688['download'](_0x9ebb66);}})[_0xbf14('0x20')](handleError(_0x38a688,null));};exports[_0xbf14('0x78')]=function(_0x48f493,_0x6ea118){var _0xd5dc2e=path['join'](config[_0xbf14('0x6e')],_0xbf14('0x79'));var _0x2ad606={'where':{'id':_0x48f493[_0xbf14('0x52')]['id']},'attributes':['id',_0xbf14('0x7a'),_0xbf14('0x7b')],'raw':!![]};return db['ChatWebsite'][_0xbf14('0x48')](_0x2ad606)[_0xbf14('0x15')](handleEntityNotFound(_0x6ea118,null))['then'](function(_0x4eaa6d){if(_0x4eaa6d){if(!_[_0xbf14('0x71')](_0x4eaa6d['customerAvatar'])){if(fs[_0xbf14('0x72')](path[_0xbf14('0x6d')](config['root'],_0xbf14('0x77'),_0x4eaa6d[_0xbf14('0x7a')]))&&_0x4eaa6d[_0xbf14('0x7b')]){_0xd5dc2e=path[_0xbf14('0x6d')](config[_0xbf14('0x6e')],_0xbf14('0x77'),_0x4eaa6d['customerAvatar']);}}return _0x6ea118[_0xbf14('0x74')](_0xd5dc2e);}})[_0xbf14('0x20')](handleError(_0x6ea118,null));};exports[_0xbf14('0x7c')]=function(_0x483532,_0x2307e3){var _0x5a05ec=path['join'](config[_0xbf14('0x6e')],_0xbf14('0x7d'));var _0x330b97={'where':{'id':_0x483532[_0xbf14('0x52')]['id']},'attributes':['id',_0xbf14('0x7e')],'raw':!![]};return db[_0xbf14('0x45')][_0xbf14('0x48')](_0x330b97)[_0xbf14('0x15')](handleEntityNotFound(_0x2307e3,null))[_0xbf14('0x15')](function(_0x569821){if(_0x569821){if(!_[_0xbf14('0x71')](_0x569821[_0xbf14('0x7e')])){if(fs['existsSync'](path[_0xbf14('0x6d')](config[_0xbf14('0x6e')],'server/files/images/avatars/',_0x569821[_0xbf14('0x7e')]))){_0x5a05ec=path[_0xbf14('0x6d')](config[_0xbf14('0x6e')],'server/files/images/avatars/',_0x569821['systemAvatar']);}}return _0x2307e3[_0xbf14('0x74')](_0x5a05ec);}})[_0xbf14('0x20')](handleError(_0x2307e3,null));};exports['notify']=function(_0x2c5e8b,_0x195be0){var _0x537ab9=require(_0xbf14('0x7f'));var _0x13ab91=new _0x537ab9();var _0x15d2f6=_0x13ab91[_0xbf14('0x80')](_0x2c5e8b[_0xbf14('0x81')][_0xbf14('0x82')])[_0xbf14('0x83')]();var _0x1b0b95={'body':_0x2c5e8b[_0xbf14('0x51')],'channel':_0xbf14('0x84')};var _0x1c7583=[];var _0x3335fe=[];var _0x2175c7={};var _0x44f76f=![];return db[_0xbf14('0x85')][_0xbf14('0x53')]()[_0xbf14('0x15')](function(_0x1d3fd3){if(!_0x1d3fd3){throw new db[(_0xbf14('0x86'))][(_0xbf14('0x87'))]('no\x20available\x20attributes');}_0x1c7583=_[_0xbf14('0x88')](_[_0xbf14('0x38')](_0x1d3fd3),[_0xbf14('0x89'),'updatedAt']);_0x3335fe=_[_0xbf14('0x88')](_[_0xbf14('0x38')](_0x1d3fd3),['createdAt','updatedAt','CompanyId',_0xbf14('0x8a')]);if(_0x2c5e8b[_0xbf14('0x51')]['id']){delete _0x2c5e8b[_0xbf14('0x51')]['id'];}if(_['isNil'](_0x2c5e8b[_0xbf14('0x51')]['from'])){throw new db[(_0xbf14('0x86'))]['ValidationError'](_0xbf14('0x8b'));}if(_['isNil'](_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0x51')])||_0x2c5e8b['body']['body']===''){throw new db[(_0xbf14('0x86'))][(_0xbf14('0x87'))](_0xbf14('0x8c'));}if(_[_0xbf14('0x71')](_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0x8d')])){throw new db[(_0xbf14('0x86'))][(_0xbf14('0x87'))](_0xbf14('0x8e')+_0x3335fe);}if(!_[_0xbf14('0x8f')](_0x3335fe,_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0x8d')])){throw new db['Sequelize'][(_0xbf14('0x87'))](_0xbf14('0x90')+_0x3335fe);}_0x2175c7[_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0x8d')]]=_0x2c5e8b[_0xbf14('0x51')]['from'];})[_0xbf14('0x15')](function(){return db[_0xbf14('0x45')][_0xbf14('0x48')]({'where':{'id':_0x2c5e8b['params']['id']},'include':[{'model':db[_0xbf14('0x91')],'as':_0xbf14('0x92'),'include':[{'model':db[_0xbf14('0x85')],'as':_0xbf14('0x93'),'where':_0x2175c7,'limit':0x1,'order':[[_0xbf14('0x94'),_0xbf14('0x95')]]}]},{'model':db[_0xbf14('0x96')],'as':_0xbf14('0x97')}]});})[_0xbf14('0x15')](handleEntityNotFound(_0x195be0,null))[_0xbf14('0x15')](function(_0x576632){if(_0x576632&&_0x576632['List']){_0x1b0b95['account']=_0x576632;_0x1b0b95[_0xbf14('0x98')]=_0x576632[_0xbf14('0x97')];_0x1b0b95['list']=_0x576632[_0xbf14('0x92')];_0x1b0b95[_0xbf14('0x98')]=_[_0xbf14('0x99')](_0x1b0b95[_0xbf14('0x98')],[_0xbf14('0x9a')],['asc']);if(_0x1b0b95['account']['Applications']){delete _0x1b0b95['account'][_0xbf14('0x97')];}if(_0x1b0b95[_0xbf14('0x9b')][_0xbf14('0x92')]&&_0x1b0b95[_0xbf14('0x9b')][_0xbf14('0x92')][_0xbf14('0x93')][_0xbf14('0x3e')]){return _0x1b0b95['account'][_0xbf14('0x92')][_0xbf14('0x93')][0x0];}var _0x169632=_['defaults'](_0x2c5e8b['body'],{'firstName':_0x2c5e8b['body'][_0xbf14('0x9c')],'ListId':_0x576632[_0xbf14('0x8a')]});_0x169632[_0x2c5e8b[_0xbf14('0x51')]['mapKey']]=_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0x9c')];return db['CmContact'][_0xbf14('0x49')](_0x169632,{'fields':_0x1c7583,'raw':!![]});}})[_0xbf14('0x15')](handleEntityNotFound(_0x195be0,null))[_0xbf14('0x15')](function(_0x54976f){_0x1b0b95['contact']=_0x54976f;var _0x1395a7=_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0x9d')];if(_0x2c5e8b[_0xbf14('0x81')][_0xbf14('0x9e')]){_0x1395a7=_0x2c5e8b[_0xbf14('0x81')]['cf-connecting-ip'];}else if(_0x2c5e8b['headers']['x-forwarded-for']){_0x1395a7=_[_0xbf14('0x9f')](_0x2c5e8b[_0xbf14('0x81')]['x-forwarded-for'][_0xbf14('0xa0')](','));}if(_0x54976f){var _0x5029d5={'ContactId':_0x54976f['id'],'ChatWebsiteId':_0x2c5e8b[_0xbf14('0x52')]['id'],'from':(_0x54976f[_0xbf14('0xa1')]||'')+'\x20'+(_0x54976f['lastName']||''),'customerIp':_0x1395a7,'customerPort':_0x2c5e8b[_0xbf14('0x81')][_0xbf14('0xa2')]?_0x2c5e8b['headers'][_0xbf14('0xa2')]:null,'referer':_0x2c5e8b['body']['referer'],'browserName':_0x15d2f6[_0xbf14('0xa3')]['name']&&_0x15d2f6[_0xbf14('0xa3')][_0xbf14('0xa4')]?util[_0xbf14('0xa5')](_0xbf14('0xa6'),_0x15d2f6['browser']['name'],_0x15d2f6[_0xbf14('0xa3')][_0xbf14('0xa4')]):_0xbf14('0xa7'),'browserVersion':_0x15d2f6[_0xbf14('0xa3')][_0xbf14('0xa4')]||'unknown','osName':util[_0xbf14('0xa5')](_0xbf14('0xa6'),_0x15d2f6['os']['name'],_0x15d2f6['os'][_0xbf14('0xa4')]),'osVersion':_0x15d2f6['os'][_0xbf14('0xa4')],'deviceModel':_0x15d2f6[_0xbf14('0xa8')][_0xbf14('0x37')]&&_0x15d2f6['device'][_0xbf14('0xa9')]?util[_0xbf14('0xa5')](_0xbf14('0xaa'),_0x15d2f6[_0xbf14('0xa8')][_0xbf14('0x37')],_0x15d2f6[_0xbf14('0xa8')]['vendor'],_0x15d2f6['device'][_0xbf14('0x36')]):null,'deviceVendor':_0x15d2f6[_0xbf14('0xa8')][_0xbf14('0xa9')],'deviceType':_0x15d2f6['device'][_0xbf14('0x36')],'formData':JSON[_0xbf14('0x1a')](_0x2c5e8b['body'])};var _0xafb850={'ChatWebsiteId':_0x2c5e8b['params']['id'],'closed':![]};if(_0x2c5e8b[_0xbf14('0x51')]['threadId']){_0xafb850[_0xbf14('0xab')]=_0x2c5e8b[_0xbf14('0x51')]['threadId'];return db[_0xbf14('0xac')][_0xbf14('0x48')]({'where':_0xafb850})[_0xbf14('0x15')](function(_0x20e70e){if(_0x20e70e){return[_0x20e70e,![]];}_0x5029d5[_0xbf14('0xab')]=_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0xab')];_0x5029d5[_0xbf14('0xad')]=_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0xad')];return db[_0xbf14('0xac')][_0xbf14('0x49')](_0x5029d5)[_0xbf14('0x15')](function(_0x1537f7){return[_0x1537f7,!![]];});});}_0xafb850['ContactId']=_0x54976f['id'];if(_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0xae')]&&_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0xae')]['id']){_0xafb850['id']=_0x2c5e8b['body'][_0xbf14('0xae')]['id'];return db['ChatInteraction'][_0xbf14('0x48')]({'where':_0xafb850})['then'](function(_0x217846){if(_0x217846){return[_0x217846,![]];}return db[_0xbf14('0xac')][_0xbf14('0x49')](_0x5029d5)[_0xbf14('0x15')](function(_0x266079){return[_0x266079,!![]];});});}return db[_0xbf14('0xac')][_0xbf14('0x49')](_0x5029d5)['then'](function(_0x5d92d9){return[_0x5d92d9,!![]];});}})[_0xbf14('0xaf')](function(_0x4f8614,_0x5e524f){if(_0x4f8614){_0x44f76f=_0x5e524f;if(!_0x5e524f){var _0x1fa3f4={'from':(_0x1b0b95[_0xbf14('0xb0')][_0xbf14('0xa1')]||'')+'\x20'+(_0x1b0b95[_0xbf14('0xb0')][_0xbf14('0xb1')]||'')};if(_0x2c5e8b[_0xbf14('0x51')]['threadId']&&_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0xb2')]&&_0x2c5e8b['body'][_0xbf14('0xab')]!=_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0xb2')]){_0x1fa3f4[_0xbf14('0xab')]=_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0xb2')];}return _0x4f8614[_0xbf14('0x2a')](_0x1fa3f4);}else{return _0x4f8614;}}})[_0xbf14('0x15')](function(_0x3f3e81){_0x1b0b95[_0xbf14('0xae')]=_0x3f3e81['get']({'plain':!![]});_0x1b0b95[_0xbf14('0xae')][_0xbf14('0xb3')]=_0x44f76f;if(_0x1b0b95[_0xbf14('0xae')][_0xbf14('0xb3')]){if(_0x1b0b95['account']['autoclose']){_0x1b0b95['applications'][_0xbf14('0xb4')]({'id':0x0,'priority':_0x1b0b95[_0xbf14('0x98')]['length']+0x1,'app':_0xbf14('0xb5'),'appdata':_0xbf14('0xb6'),'interval':_0xbf14('0xb7')});}}return db['ChatMessage'][_0xbf14('0x49')]({'body':_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0x51')],'ChatWebsiteId':_0x2c5e8b[_0xbf14('0x52')]['id'],'ChatInteractionId':_0x3f3e81['id'],'direction':'in','ContactId':_0x1b0b95['contact']['id'],'AttachmentId':_0x2c5e8b[_0xbf14('0x51')][_0xbf14('0xb8')]});})[_0xbf14('0x15')](function(_0x291fc3){_0x1b0b95[_0xbf14('0x1e')]=_0x291fc3;if(_0x1b0b95['interaction'][_0xbf14('0xb9')]){return db['User']['find']({'attributes':['id','name'],'where':{'id':_0x1b0b95[_0xbf14('0xae')][_0xbf14('0xb9')]}})['then'](function(_0x423e06){if(_0x423e06){_0x1b0b95['applications']['unshift']({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x423e06[_0xbf14('0x30')]+','+(_0x1b0b95[_0xbf14('0x9b')][_0xbf14('0xba')]||0xa),'interval':_0xbf14('0xb7')});_0x1b0b95[_0xbf14('0xbb')]=!![];}return respondWithRpcPromise(_0xbf14('0xbc'),_0xbf14('0xbd'),_0x1b0b95);});}return respondWithRpcPromise(_0xbf14('0xbc'),_0xbf14('0xbd'),_0x1b0b95);})[_0xbf14('0x15')](function(_0x445589){respondWithRpcPromise(_0xbf14('0xbe'),_0xbf14('0xbe'),{'event':_0xbf14('0xbf'),'message':_0x445589},client9002);return _0x445589;})[_0xbf14('0x15')](respondWithResult(_0x195be0,null))[_0xbf14('0x20')](handleError(_0x195be0,null));};exports[_0xbf14('0xc0')]=function(_0x2d1bb6,_0xbc2f42){var _0x2d8ccd,_0x28b715,_0x281bfe;var _0xace33e=[];var _0xdd48a={};var _0xa4c8d5=_0x2d1bb6[_0xbf14('0xc1')]||[];var _0x3de613=[];var _0xebc595;return db['CmContact']['describe']()[_0xbf14('0x15')](function(_0x2ea302){if(!_0x2ea302){throw new db[(_0xbf14('0x86'))][(_0xbf14('0x87'))]('no\x20available\x20attributes');}_0xace33e=_['difference'](_[_0xbf14('0x38')](_0x2ea302),['createdAt','updatedAt',_0xbf14('0xc2'),'ListId']);if(_0x2d1bb6[_0xbf14('0x51')]['id']){delete _0x2d1bb6[_0xbf14('0x51')]['id'];}if(_[_0xbf14('0x71')](_0x2d1bb6[_0xbf14('0x51')][_0xbf14('0x9c')])){throw _0xbc2f42[_0xbf14('0x22')](0x1f4)[_0xbf14('0xc3')](new db[(_0xbf14('0x86'))][(_0xbf14('0x87'))](_0xbf14('0x8b')));}if(_[_0xbf14('0x71')](_0x2d1bb6[_0xbf14('0x51')][_0xbf14('0x51')])||_0x2d1bb6[_0xbf14('0x51')]['body']===''){throw _0xbc2f42[_0xbf14('0x22')](0x1f4)[_0xbf14('0xc3')](new db[(_0xbf14('0x86'))][(_0xbf14('0x87'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0xbf14('0x71')](_0x2d1bb6[_0xbf14('0x51')][_0xbf14('0xc4')])){throw _0xbc2f42[_0xbf14('0x22')](0x1f4)[_0xbf14('0xc3')](new db[(_0xbf14('0x86'))][(_0xbf14('0x87'))]('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0xace33e));}if(!_[_0xbf14('0x8f')](_0xace33e,_0x2d1bb6['body'][_0xbf14('0xc4')])){throw _0xbc2f42[_0xbf14('0x22')](0x1f4)[_0xbf14('0xc3')](new db[(_0xbf14('0x86'))][(_0xbf14('0x87'))](_0xbf14('0xc5')+_0xace33e));}_0xdd48a[_0x2d1bb6['body'][_0xbf14('0xc4')]]=_0x2d1bb6['body'][_0xbf14('0x9c')];})['then'](function(){return db['ChatWebsite']['find']({'where':{'id':_0x2d1bb6[_0xbf14('0x52')]['id']},'include':[{'model':db[_0xbf14('0x91')],'as':_0xbf14('0x92')},{'model':db[_0xbf14('0xc6')],'as':_0xbf14('0xc6')}]});})['then'](handleEntityNotFound(_0xbc2f42,null))[_0xbf14('0x15')](function(_0x4b85b9){if(_0x4b85b9&&_0x4b85b9[_0xbf14('0x92')]){_0x28b715=_0x4b85b9;var _0x197425=_[_0xbf14('0xe')](_0x2d1bb6['body'],{'firstName':_0x2d1bb6[_0xbf14('0x51')][_0xbf14('0x9c')],'phone':_0x2d1bb6[_0xbf14('0x51')][_0xbf14('0x9c')],'ListId':_0x4b85b9[_0xbf14('0x8a')]});_0x197425[_0x2d1bb6[_0xbf14('0x51')]['mapKeyOffline']]=_0x2d1bb6[_0xbf14('0x51')][_0xbf14('0x9c')];return db[_0xbf14('0x85')][_0xbf14('0xc7')]({'where':_0xdd48a,'defaults':_0x197425});}})[_0xbf14('0xaf')](function(_0x43be92){if(_0x43be92){_0x281bfe=_0x43be92;var _0x2e176a=fs[_0xbf14('0xc8')](path[_0xbf14('0x6d')](config[_0xbf14('0x6e')],_0xbf14('0xc9')),_0xbf14('0xca'));var _0x52ac98=ejs[_0xbf14('0xcb')](_0x2e176a,{'body':_[_0xbf14('0xcc')](_0x2d1bb6['body']['body']),'bodyTitle':_0x28b715['offlineMessageBody']});return db[_0xbf14('0xcd')][_0xbf14('0x49')]({'body':_0x52ac98,'plainBody':htmlToText['fromString'](_0x52ac98),'ContactId':_0x43be92['id'],'ChatWebsiteId':_0x28b715['id']});}})[_0xbf14('0x15')](function(_0x104eb0){_0xebc595=_0x104eb0;if(_0xa4c8d5[_0xbf14('0x3e')]){var _0x3a834=_0xa4c8d5[_0xbf14('0x34')](function(_0x39e98b){return{'name':_0x39e98b['originalname'],'basename':_0x39e98b[_0xbf14('0x68')],'type':_0x39e98b[_0xbf14('0xce')],'ChatOfflineMessageId':_0x104eb0['id']};});_0x3de613=_0x3a834[_0xbf14('0x34')](_0x393739=>{var _0x2a3387={'filename':_0x393739[_0xbf14('0x30')],'path':path[_0xbf14('0x6d')](config[_0xbf14('0x6e')],'server','files',_0xbf14('0xcf'),_0xbf14('0xd0'),_0x393739[_0xbf14('0xd1')])};return _0x2a3387;});if(!_0x28b715[_0xbf14('0xd2')]){return db[_0xbf14('0xd3')]['transaction'](function(_0x581309){return db[_0xbf14('0xd4')][_0xbf14('0xd5')](_0x3a834,{'transaction':_0x581309});});}}})['then'](function(){if(_0xebc595){_0x2d8ccd=_0xebc595;return db[_0xbf14('0xc6')][_0xbf14('0x58')]({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':_0xbf14('0xd6'),'raw':!![],'include':[{'model':db[_0xbf14('0xd7')],'as':_0xbf14('0xd7'),'raw':!![]}]}]});}})[_0xbf14('0x15')](function(_0x63871){if(_0x63871&&_0x63871[_0xbf14('0xd6')]&&_0x28b715[_0xbf14('0xd8')]&&_0x28b715[_0xbf14('0xd9')]){var _0x2992e2=_0x63871[_0xbf14('0xda')]();return respondWithRpcPromise(_0xbf14('0xdb'),_0xbf14('0xdc'),{'account':_0x2992e2,'message':{'from':util[_0xbf14('0xa5')]('\x22%s\x22\x20<%s>',_0x63871[_0xbf14('0x30')],_0x63871[_0xbf14('0xdd')]||_0x63871[_0xbf14('0xd6')][_0xbf14('0x4a')]),'to':_0x28b715[_0xbf14('0xd9')],'subject':_0x28b715[_0xbf14('0xde')],'html':_0x2d8ccd[_0xbf14('0x51')],'attachments':_0x3de613}},client9003)['then'](function(){return _0x2d8ccd;})[_0xbf14('0x20')](function(_0x3ffa4f){logger['error'](_0x3ffa4f);});}})[_0xbf14('0x15')](function(){if(_0x28b715&&_0x28b715['openNewInteraction']&&_0x28b715['MailAccountId']){var _0x590834=[];if(_0xa4c8d5['length']){_0x590834=_0xa4c8d5[_0xbf14('0x34')](function(_0x380bd2){return{'name':_0x380bd2[_0xbf14('0xdf')],'basename':_0x380bd2[_0xbf14('0x68')],'type':_0x380bd2[_0xbf14('0xce')],'ChatOfflineMessageId':_0xebc595['id']};});}var _0x3e385b;if(!_['isNil'](_0x28b715[_0xbf14('0xe0')])){var _0x1cc634=_[_0xbf14('0x34')](_0x2d1bb6['body'],function(_0x3d6b6c){return _0x3d6b6c;});var _0xa3adfa=_[_0xbf14('0xe1')](_0x1cc634)[0x0];var _0x40ff22=_['mapValues'](_0xa3adfa,function(_0x3bb687){return _0x3bb687;});_0x3e385b=_0x40ff22[0x1][_0x28b715[_0xbf14('0xe0')]];}var _0x2521c7={'from':_0x281bfe['email'],'firstName':_0x281bfe[_0xbf14('0xa1')],'lastName':_0x281bfe[_0xbf14('0xb1')],'mapKey':_0xbf14('0xdd'),'message':{'from':_0x281bfe[_0xbf14('0xdd')],'to':_0x28b715['MailAccount'][_0xbf14('0xdd')],'cc':'','subject':_[_0xbf14('0x71')](_0x3e385b)?_0x28b715[_0xbf14('0xde')]:_0x3e385b,'messageId':'','sentAt':new Date(),'attach':_0x590834[_0xbf14('0x3e')],'attachments':_0x590834,'originChannel':_0xbf14('0xe2'),'ChatWebsiteId':_0x28b715['id'],'ChatOfflineMessageId':_0x2d8ccd['id'],'originTo':_0x28b715[_0xbf14('0xc6')][_0xbf14('0xdd')]},'body':_0x2d8ccd[_0xbf14('0x51')]};var _0x11d8fb={'account':{'id':_0x28b715[_0xbf14('0xe3')]},'body':_0x2521c7,'log':_0xbf14('0xe4')};return respondWithRpcPromise(_0xbf14('0xe4'),_0xbf14('0xe5'),_0x11d8fb,client9001)['then'](function(){return _0x2d8ccd;})['catch'](function(_0x305406){logger['error'](_0x305406);});}return;})[_0xbf14('0x15')](function(){if(_0x2d8ccd){return _0x2d8ccd;}})['then'](respondWithResult(_0xbc2f42,null))[_0xbf14('0x20')](function(_0x244b15){logger['error'](_0xbf14('0x20'),_0x244b15);for(var _0x4be402 of _0xa4c8d5){var _0x3f5328=path[_0xbf14('0x6d')](config[_0xbf14('0x6e')],_0xbf14('0xe6'),_0xbf14('0xc1'),'attachments',_0xbf14('0xd0'),_0x4be402[_0xbf14('0x68')]);fs_extra[_0xbf14('0xe7')](_0x3f5328)['catch'](function(_0x118bee){logger[_0xbf14('0x1b')](_0xbf14('0xe8'),_0x3f5328,_0x118bee);});}});};exports['addInteraction']=function(_0x561711,_0x178a39){return db[_0xbf14('0xac')][_0xbf14('0x48')]({'where':{'id':_0x561711['params']['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x178a39,null))[_0xbf14('0x15')](function(_0x21c8bf){if(_0x21c8bf){return _0x21c8bf[_0xbf14('0xe9')](_0x561711[_0xbf14('0x51')][_0xbf14('0x60')],_[_0xbf14('0xea')](_0x561711[_0xbf14('0x51')],['ids','id'])||{});}})[_0xbf14('0x15')](respondWithResult(_0x178a39,null))[_0xbf14('0x20')](handleError(_0x178a39,null));};exports['getInteractions']=function(_0x558c60,_0x4c68d0){var _0x3781a5={'raw':![],'where':{}};var _0x3e51a1={};var _0x871224={'count':0x0,'rows':[]};return db[_0xbf14('0x45')][_0xbf14('0x58')]({'where':{'id':_0x558c60[_0xbf14('0x52')]['id']}})['then'](handleEntityNotFound(_0x4c68d0,null))[_0xbf14('0x15')](function(_0x341c9a){if(_0x341c9a){_0x3e51a1[_0xbf14('0x37')]=_[_0xbf14('0x38')](db[_0xbf14('0xac')][_0xbf14('0x47')]);_0x3e51a1['query']=_['keys'](_0x558c60[_0xbf14('0x39')]);_0x3e51a1[_0xbf14('0x3a')]=_[_0xbf14('0x3b')](_0x3e51a1[_0xbf14('0x37')],_0x3e51a1[_0xbf14('0x39')]);_0x3781a5['attributes']=_[_0xbf14('0x3b')](_0x3e51a1[_0xbf14('0x37')],qs['fields'](_0x558c60[_0xbf14('0x39')]['fields']));_0x3781a5[_0xbf14('0x3c')]=_0x3781a5[_0xbf14('0x3c')][_0xbf14('0x3e')]?_0x3781a5[_0xbf14('0x3c')]:_0x3e51a1['model'];if(!_0x558c60[_0xbf14('0x39')][_0xbf14('0x59')](_0xbf14('0x3f'))){_0x3781a5[_0xbf14('0x27')]=qs['limit'](_0x558c60['query'][_0xbf14('0x27')]);_0x3781a5[_0xbf14('0x24')]=qs['offset'](_0x558c60['query']['offset']);}_0x3781a5[_0xbf14('0x5a')]=qs[_0xbf14('0x40')](_0x558c60[_0xbf14('0x39')]['sort']);_0x3781a5[_0xbf14('0x41')]=qs[_0xbf14('0x3a')](_[_0xbf14('0x63')](_0x558c60[_0xbf14('0x39')],_0x3e51a1[_0xbf14('0x3a')]));_0x3781a5['where'][_0xbf14('0x55')]=_0x341c9a['id'];if(_0x558c60[_0xbf14('0x39')][_0xbf14('0x5b')]){_0x3781a5[_0xbf14('0x41')]=_[_0xbf14('0x43')](_0x3781a5[_0xbf14('0x41')],{'$or':_['map'](_0x3781a5[_0xbf14('0x3c')],function(_0x215ebe){var _0x1d9422={};_0x1d9422[_0x215ebe]={'$like':'%'+_0x558c60['query']['filter']+'%'};return _0x1d9422;})});}_0x3781a5=_[_0xbf14('0x43')]({},_0x3781a5,_0x558c60[_0xbf14('0x44')]);return db[_0xbf14('0xac')][_0xbf14('0x26')]({'where':_0x3781a5[_0xbf14('0x41')]})[_0xbf14('0x15')](function(_0x2ff528){_0x871224[_0xbf14('0x26')]=_0x2ff528;if(_0x558c60[_0xbf14('0x39')][_0xbf14('0x46')]){_0x3781a5[_0xbf14('0x5c')]=[{'model':db[_0xbf14('0x85')],'as':_0xbf14('0xeb'),'required':![]},{'model':db[_0xbf14('0xec')],'as':_0xbf14('0xed'),'attributes':[_0xbf14('0x30'),_0xbf14('0xee'),'internal'],'required':![]},{'model':db[_0xbf14('0xef')],'as':_0xbf14('0xf0'),'attributes':['id',_0xbf14('0x30'),_0xbf14('0xf1')],'where':_0x558c60[_0xbf14('0x39')][_0xbf14('0xf2')]?{'id':_0x558c60[_0xbf14('0x39')][_0xbf14('0xf2')]}:undefined,'required':_0x558c60[_0xbf14('0x39')][_0xbf14('0xf2')]?!![]:![]}];}return db[_0xbf14('0xac')][_0xbf14('0x5d')](_0x3781a5);})[_0xbf14('0x15')](function(_0x3a7f08){_0x871224[_0xbf14('0x5e')]=_0x3a7f08;return _0x871224;});}})[_0xbf14('0x15')](respondWithFilteredResult(_0x4c68d0,_0x3781a5))[_0xbf14('0x20')](handleError(_0x4c68d0,null));};function iftimePromise(_0xd66e83,_0x42b1f9){return respondWithRpcPromise('Command',_0xbf14('0xf3'),{'command':_0x42b1f9[_0xbf14('0xf4')]?util[_0xbf14('0xa5')]('iftime\x20%s,%s',_0xd66e83[_0xbf14('0xf5')],_0x42b1f9[_0xbf14('0xf4')]):util[_0xbf14('0xa5')](_0xbf14('0xf6'),_0xd66e83[_0xbf14('0xf5')])},client9002)['then'](function(_0x7721c8){var _0x2ac27e=_0x7721c8&&_0x7721c8[_0xbf14('0xf7')]('true')>=0x0?!![]:![];logger[_0xbf14('0x16')](_0xbf14('0xf8'),_0x42b1f9['id'],_0xd66e83['id'],_0xd66e83[_0xbf14('0xf5')],_0x2ac27e?_0xbf14('0xf9'):_0xbf14('0xfa'),_0x42b1f9[_0xbf14('0xf4')]?_0x42b1f9[_0xbf14('0xf4')]:_0xbf14('0xfb'));return _0x2ac27e;})[_0xbf14('0x20')](function(_0x464b4e){logger[_0xbf14('0x1b')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x42b1f9['id'],_0xd66e83['id'],_0xd66e83['interval'],util[_0xbf14('0xfc')](_0x464b4e,{'showHidden':![],'depth':null}),_0x42b1f9['timezone']?_0x42b1f9[_0xbf14('0xf4')]:_0xbf14('0xfb'));return![];});}exports[_0xbf14('0xf3')]=function(_0x4942fe,_0x50d8f2){var _0x1e13f0=0x0;var _0x52af53=0x0;var _0x27fce8=![];var _0x55b3fd;var _0x476efe;return db[_0xbf14('0x45')]['find']({'where':{'id':_0x4942fe[_0xbf14('0x52')]['id']},'include':[{'model':db['Interval'],'as':_0xbf14('0xfd'),'include':[{'model':db[_0xbf14('0xfd')],'as':_0xbf14('0xfe'),'attributes':['id',_0xbf14('0xf5')],'raw':!![]}]}]})[_0xbf14('0x15')](handleEntityNotFound(_0x50d8f2,null))[_0xbf14('0x15')](function(_0x5f0fe8){if(_0x5f0fe8){_0x55b3fd=_0x5f0fe8;return _0x5f0fe8[_0xbf14('0xff')]({'raw':!![]});}})[_0xbf14('0x15')](function(_0x24f5ea){if(_0x55b3fd){if(_0x24f5ea){_0x476efe=_0x24f5ea;}}return require(_0xbf14('0x6f'))[_0xbf14('0x100')]();})[_0xbf14('0x15')](function(_0x1cddfa){if(_0x1cddfa){_0x52af53=_0x1cddfa[_0xbf14('0x101')];_0x27fce8=_0x1cddfa[_0xbf14('0x70')];}})['then'](function(){return db[_0xbf14('0xac')][_0xbf14('0x26')]({'where':{'closed':![]}});})[_0xbf14('0x15')](function(_0x4e4434){_0x1e13f0=_0x4e4434;if(_0x52af53&&_0x4e4434>_0x52af53){return db[_0xbf14('0x102')]['findOne']({'where':{'id':0x1}})[_0xbf14('0x15')](function(_0x7b4263){if(_0x7b4263){_0x7b4263[_0xbf14('0x103')](_0xbf14('0x104'));}});}})['then'](function(){if(_0x55b3fd[_0xbf14('0xfd')]&&_0x55b3fd[_0xbf14('0xfd')][_0xbf14('0xfe')]){var _0x522a82=[];for(var _0x350743=0x0;_0x350743<_0x55b3fd[_0xbf14('0xfd')][_0xbf14('0xfe')][_0xbf14('0x3e')];_0x350743++){var _0x484341=_0x55b3fd[_0xbf14('0xfd')][_0xbf14('0xfe')][_0x350743]['get']({'plain':!![]});_0x522a82[_0xbf14('0xb4')](iftimePromise(_0x484341,_0x55b3fd));}return BPromise[_0xbf14('0x105')](_0x522a82)[_0xbf14('0x15')](function(_0x6784e7){return _[_0xbf14('0x106')](_0x6784e7);});}else{return!![];}})[_0xbf14('0x15')](function(_0x33e9d7){var _0x1f9732=fs[_0xbf14('0xc8')](path[_0xbf14('0x6d')](config[_0xbf14('0x6e')],'server/files/chat/iframe.ejs'),_0xbf14('0xca'));var _0x455a61={'remote':_0x55b3fd[_0xbf14('0x107')],'query':querystring['stringify'](_[_0xbf14('0x43')](_0x55b3fd[_0xbf14('0x4b')]({'plain':!![]}),{'customerIp':_0x4942fe[_0xbf14('0x81')][_0xbf14('0x108')]||_0x4942fe[_0xbf14('0x81')][_0xbf14('0x109')]||_0x4942fe['connection'][_0xbf14('0x10a')]||_0x4942fe['ip'],'referer':_0x4942fe[_0xbf14('0x81')][_0xbf14('0x10b')],'openedInteractions':_0x1e13f0,'maxInteractions':_0x52af53,'virtual':_0x27fce8['virtual'],'online':_0x33e9d7,'custom':_0x27fce8}))[_0xbf14('0x10c')](/'/g,'\x5c\x27')};_0x50d8f2['send'](ejs['render'](Mustache['render'](_0x1f9732,_0x455a61),{'proactiveActions':_0x476efe,'alignment':_0x55b3fd[_0xbf14('0x10d')],'verticalAlignment':_0x55b3fd['verticalAlignment'],'div_color':_0x55b3fd[_0xbf14('0xf1')],'labelText':_0x55b3fd[_0xbf14('0x10e')],'text_color':_0x55b3fd[_0xbf14('0x10f')],'button_color':_0x55b3fd['color_button'],'background_color':_0x55b3fd[_0xbf14('0x110')],'hideWhenOffline':_0x55b3fd[_0xbf14('0x111')],'interval':_0x55b3fd[_0xbf14('0x112')]}));})[_0xbf14('0x20')](handleError(_0x50d8f2,null));};exports[_0xbf14('0x113')]=function(_0x16a0bb,_0x2c8cea){var _0x5d2a7c=_0x16a0bb[_0xbf14('0x52')]['id'];var _0x1a1575=_0x16a0bb[_0xbf14('0x51')];var _0x4cd609=0xc8;var _0x5d8c71=null;return db[_0xbf14('0xd3')][_0xbf14('0x114')]({'isolationLevel':db['sequelize']['Transaction']['ISOLATION_LEVELS']['READ_COMMITTED']},function(_0x1c89d5){return db[_0xbf14('0x45')]['findOne']({'where':{'id':_0x5d2a7c},'transaction':_0x1c89d5})[_0xbf14('0x15')](function(_0x23587e){if(_0x23587e){return db[_0xbf14('0x96')][_0xbf14('0x2b')]({'where':{'ChatWebsiteId':_0x5d2a7c},'transaction':_0x1c89d5})[_0xbf14('0x15')](function(){var _0x3d3c5c=_[_0xbf14('0x34')](_0x1a1575,function(_0x2c97d9){_0x2c97d9[_0xbf14('0x55')]=_0x5d2a7c;return _0x2c97d9;});return db['ChatApplication'][_0xbf14('0xd5')](_0x3d3c5c,{'transaction':_0x1c89d5});});}else{_0x4cd609=0x194;_0x5d8c71=[];}});})[_0xbf14('0x15')](function(){if(_0x4cd609!==0x194){return db[_0xbf14('0x96')][_0xbf14('0x115')]({'where':{'ChatWebsiteId':_0x5d2a7c},'order':'priority'})[_0xbf14('0x15')](function(_0x21a7fd){_0x5d8c71=_0x21a7fd;});}})['catch'](function(_0x1ee25e){_0x4cd609=0x1f4;logger['error'](_0x1ee25e['stack']);if(_0x1ee25e[_0xbf14('0x30')]){delete _0x1ee25e['name'];}_0x5d8c71=_0x1ee25e;})[_0xbf14('0x116')](function(){if(_0x5d8c71===null){_0x2c8cea[_0xbf14('0x21')](_0x4cd609);}else{if(_0x4cd609===0x1f4){_0x2c8cea[_0xbf14('0x22')](_0x4cd609)['send'](_0x5d8c71);}else{_0x2c8cea[_0xbf14('0x22')](_0x4cd609)[_0xbf14('0x23')](_0x5d8c71);}}});};exports[_0xbf14('0x117')]=function(_0x50b890,_0x4bef0e){var _0x395e8b={};var _0x1d06aa={};var _0x332547;var _0x48c45c;return db[_0xbf14('0x45')][_0xbf14('0x58')]({'where':{'id':_0x50b890[_0xbf14('0x52')]['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x4bef0e,null))[_0xbf14('0x15')](function(_0x519d43){if(_0x519d43){_0x332547=_0x519d43;_0x1d06aa[_0xbf14('0x37')]=_[_0xbf14('0x38')](db[_0xbf14('0x96')]['rawAttributes']);_0x1d06aa['query']=_[_0xbf14('0x38')](_0x50b890['query']);_0x1d06aa[_0xbf14('0x3a')]=_[_0xbf14('0x3b')](_0x1d06aa['model'],_0x1d06aa[_0xbf14('0x39')]);_0x395e8b['attributes']=_[_0xbf14('0x3b')](_0x1d06aa['model'],qs[_0xbf14('0x3d')](_0x50b890['query'][_0xbf14('0x3d')]));_0x395e8b[_0xbf14('0x3c')]=_0x395e8b[_0xbf14('0x3c')][_0xbf14('0x3e')]?_0x395e8b['attributes']:_0x1d06aa['model'];_0x395e8b[_0xbf14('0x5a')]=qs[_0xbf14('0x40')](_0x50b890['query']['sort']);_0x395e8b[_0xbf14('0x41')]=qs['filters'](_['pick'](_0x50b890[_0xbf14('0x39')],_0x1d06aa[_0xbf14('0x3a')]));if(_0x50b890[_0xbf14('0x39')][_0xbf14('0x5b')]){_0x395e8b['where']=_['merge'](_0x395e8b[_0xbf14('0x41')],{'$or':_[_0xbf14('0x34')](_0x395e8b[_0xbf14('0x3c')],function(_0x5de2f3){var _0x337340={};_0x337340[_0x5de2f3]={'$like':'%'+_0x50b890[_0xbf14('0x39')][_0xbf14('0x5b')]+'%'};return _0x337340;})});}_0x395e8b=_[_0xbf14('0x43')]({},_0x395e8b,_0x50b890[_0xbf14('0x44')]);return _0x332547[_0xbf14('0x117')](_0x395e8b);}})[_0xbf14('0x15')](function(_0x5b2e31){if(_0x5b2e31){_0x48c45c=_0x5b2e31[_0xbf14('0x3e')];if(!_0x50b890[_0xbf14('0x39')]['hasOwnProperty'](_0xbf14('0x3f'))){_0x395e8b['limit']=qs[_0xbf14('0x27')](_0x50b890[_0xbf14('0x39')]['limit']);_0x395e8b[_0xbf14('0x24')]=qs[_0xbf14('0x24')](_0x50b890[_0xbf14('0x39')][_0xbf14('0x24')]);}return _0x332547[_0xbf14('0x117')](_0x395e8b);}})[_0xbf14('0x15')](function(_0x2ae937){if(_0x2ae937){return _0x2ae937?{'count':_0x48c45c,'rows':_0x2ae937}:null;}})['then'](respondWithResult(_0x4bef0e,null))[_0xbf14('0x20')](handleError(_0x4bef0e,null));};exports[_0xbf14('0x118')]=function(_0x3433d1,_0x5758ab){return db[_0xbf14('0x119')][_0xbf14('0x48')]({'where':{'id':_0x3433d1['params']['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x5758ab,null))['then'](function(_0x20f508){if(_0x20f508){return _0x20f508[_0xbf14('0x118')](_0x3433d1[_0xbf14('0x51')][_0xbf14('0x60')],_[_0xbf14('0xea')](_0x3433d1['body'],['ids','id'])||{});}})[_0xbf14('0x15')](respondWithResult(_0x5758ab,null))[_0xbf14('0x20')](handleError(_0x5758ab,null));};exports[_0xbf14('0xff')]=function(_0x2616c4,_0x132a86){var _0x3a0edb={};var _0x4ad803={};var _0x35c659;var _0x402e7b;return db[_0xbf14('0x45')][_0xbf14('0x58')]({'where':{'id':_0x2616c4[_0xbf14('0x52')]['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x132a86,null))[_0xbf14('0x15')](function(_0x1c5e40){if(_0x1c5e40){_0x35c659=_0x1c5e40;_0x4ad803[_0xbf14('0x37')]=_['keys'](db[_0xbf14('0x11a')]['rawAttributes']);_0x4ad803[_0xbf14('0x39')]=_[_0xbf14('0x38')](_0x2616c4['query']);_0x4ad803[_0xbf14('0x3a')]=_[_0xbf14('0x3b')](_0x4ad803[_0xbf14('0x37')],_0x4ad803[_0xbf14('0x39')]);_0x3a0edb[_0xbf14('0x3c')]=_['intersection'](_0x4ad803[_0xbf14('0x37')],qs[_0xbf14('0x3d')](_0x2616c4[_0xbf14('0x39')][_0xbf14('0x3d')]));_0x3a0edb[_0xbf14('0x3c')]=_0x3a0edb['attributes'][_0xbf14('0x3e')]?_0x3a0edb[_0xbf14('0x3c')]:_0x4ad803[_0xbf14('0x37')];_0x3a0edb[_0xbf14('0x5a')]=qs[_0xbf14('0x40')](_0x2616c4[_0xbf14('0x39')][_0xbf14('0x40')]);_0x3a0edb[_0xbf14('0x41')]=qs[_0xbf14('0x3a')](_[_0xbf14('0x63')](_0x2616c4[_0xbf14('0x39')],_0x4ad803['filters']));if(_0x2616c4['query'][_0xbf14('0x5b')]){_0x3a0edb[_0xbf14('0x41')]=_[_0xbf14('0x43')](_0x3a0edb[_0xbf14('0x41')],{'$or':_[_0xbf14('0x34')](_0x3a0edb[_0xbf14('0x3c')],function(_0x49b285){var _0x16a01b={};_0x16a01b[_0x49b285]={'$like':'%'+_0x2616c4[_0xbf14('0x39')]['filter']+'%'};return _0x16a01b;})});}_0x3a0edb=_[_0xbf14('0x43')]({},_0x3a0edb,_0x2616c4[_0xbf14('0x44')]);return _0x35c659['getProactiveActions'](_0x3a0edb);}})[_0xbf14('0x15')](function(_0x1dbbbd){if(_0x1dbbbd){_0x402e7b=_0x1dbbbd[_0xbf14('0x3e')];if(!_0x2616c4['query'][_0xbf14('0x59')](_0xbf14('0x3f'))){_0x3a0edb[_0xbf14('0x27')]=qs[_0xbf14('0x27')](_0x2616c4['query']['limit']);_0x3a0edb[_0xbf14('0x24')]=qs[_0xbf14('0x24')](_0x2616c4[_0xbf14('0x39')]['offset']);}return _0x35c659[_0xbf14('0xff')](_0x3a0edb);}})['then'](function(_0x4c3f59){if(_0x4c3f59){return _0x4c3f59?{'count':_0x402e7b,'rows':_0x4c3f59}:null;}})[_0xbf14('0x15')](respondWithResult(_0x132a86,null))['catch'](handleError(_0x132a86,null));};exports[_0xbf14('0x11b')]=function(_0x5a8f40,_0xe5e229){var _0x1eab71=_0x5a8f40[_0xbf14('0x39')]['online']===_0xbf14('0x11c')?_0xbf14('0x11d'):_0xbf14('0x11e');return db[_0xbf14('0x45')][_0xbf14('0x48')]({'attributes':['id',_0x1eab71],'where':{'id':_0x5a8f40[_0xbf14('0x52')]['id']}})['then'](handleEntityNotFound(_0xe5e229,null))[_0xbf14('0x15')](function(_0x47e4ef){if(_0x47e4ef){var _0x3a7fb4=_0x47e4ef[_0x1eab71];var _0xeee990=_0x3a7fb4&&_0x3a7fb4[_0xbf14('0x11f')]?_0x3a7fb4[_0xbf14('0x11f')]:[];_0xe5e229[_0xbf14('0xc3')]({'fromKey':_[_0xbf14('0x71')](_0x3a7fb4['fromKey'])?undefined:_0x3a7fb4['fromKey'],'count':_0xeee990[_0xbf14('0x3e')],'rows':_0xeee990});}})['catch'](handleError(_0xe5e229,null));};exports['getOfflineMessages']=function(_0x5c6b09,_0xd66839){var _0x2cc579={'raw':![],'where':{}};var _0x2db725={};var _0x36d4d1={'count':0x0,'rows':[]};return db['ChatWebsite'][_0xbf14('0x58')]({'where':{'id':_0x5c6b09[_0xbf14('0x52')]['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0xd66839,null))['then'](function(_0x418938){if(_0x418938){_0x2db725[_0xbf14('0x37')]=_[_0xbf14('0x38')](db[_0xbf14('0xcd')][_0xbf14('0x47')]);_0x2db725[_0xbf14('0x39')]=_[_0xbf14('0x38')](_0x5c6b09[_0xbf14('0x39')]);_0x2db725[_0xbf14('0x3a')]=_[_0xbf14('0x3b')](_0x2db725['model'],_0x2db725[_0xbf14('0x39')]);_0x2cc579[_0xbf14('0x3c')]=_[_0xbf14('0x3b')](_0x2db725['model'],qs[_0xbf14('0x3d')](_0x5c6b09['query'][_0xbf14('0x3d')]));_0x2cc579[_0xbf14('0x3c')]=_0x2cc579[_0xbf14('0x3c')][_0xbf14('0x3e')]?_0x2cc579[_0xbf14('0x3c')]:_0x2db725[_0xbf14('0x37')];if(!_0x5c6b09[_0xbf14('0x39')][_0xbf14('0x59')]('nolimit')){_0x2cc579[_0xbf14('0x27')]=qs[_0xbf14('0x27')](_0x5c6b09[_0xbf14('0x39')][_0xbf14('0x27')]);_0x2cc579[_0xbf14('0x24')]=qs[_0xbf14('0x24')](_0x5c6b09['query'][_0xbf14('0x24')]);}_0x2cc579['order']=qs[_0xbf14('0x40')](_0x5c6b09['query'][_0xbf14('0x40')]);_0x2cc579[_0xbf14('0x41')]=qs[_0xbf14('0x3a')](_['pick'](_0x5c6b09[_0xbf14('0x39')],_0x2db725[_0xbf14('0x3a')]));_0x2cc579[_0xbf14('0x41')][_0xbf14('0x55')]=_0x418938['id'];if(_0x5c6b09['query'][_0xbf14('0x5b')]){_0x2cc579[_0xbf14('0x41')]=_['merge'](_0x2cc579[_0xbf14('0x41')],{'$or':_[_0xbf14('0x34')](_0x2cc579[_0xbf14('0x3c')],function(_0x221e3b){var _0x2d99f0={};_0x2d99f0[_0x221e3b]={'$like':'%'+_0x5c6b09[_0xbf14('0x39')]['filter']+'%'};return _0x2d99f0;})});}_0x2cc579=_[_0xbf14('0x43')]({},_0x2cc579,_0x5c6b09[_0xbf14('0x44')]);return db['ChatOfflineMessage']['count']({'where':_0x2cc579['where']})['then'](function(_0x485cbc){_0x36d4d1['count']=_0x485cbc;if(_0x5c6b09[_0xbf14('0x39')]['includeAll']){_0x2cc579['include']=[{'all':!![]}];}else{_0x2cc579[_0xbf14('0x5c')]=[{'model':db[_0xbf14('0x85')],'as':_0xbf14('0xeb'),'required':![]},{'model':db[_0xbf14('0xd4')],'as':_0xbf14('0x120'),'required':![]}];}return db['ChatOfflineMessage'][_0xbf14('0x5d')](_0x2cc579);})['then'](function(_0x394958){_0x36d4d1['rows']=_0x394958;return _0x36d4d1;});}})['then'](respondWithFilteredResult(_0xd66839,_0x2cc579))[_0xbf14('0x20')](handleError(_0xd66839,null));};exports[_0xbf14('0x121')]=function(_0x8798ed,_0x2e3fd1){return db[_0xbf14('0x45')][_0xbf14('0x48')]({'where':{'id':_0x8798ed[_0xbf14('0x52')]['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x2e3fd1,null))['then'](function(_0x457ae5){if(_0x457ae5){return _0x457ae5[_0xbf14('0x121')](_0x8798ed[_0xbf14('0x51')]['ids'],_[_0xbf14('0xea')](_0x8798ed['body'],[_0xbf14('0x60'),'id'])||{})[_0xbf14('0xaf')](function(_0x1d58e0){for(var _0x35b7da=0x0;_0x35b7da<_0x8798ed[_0xbf14('0x51')][_0xbf14('0x60')][_0xbf14('0x3e')];_0x35b7da+=0x1){socket[_0xbf14('0x122')]('userChatWebsite:save',{'UserId':Number(_0x8798ed[_0xbf14('0x51')]['ids'][_0x35b7da]),'ChatWebsiteId':Number(_0x8798ed[_0xbf14('0x52')]['id'])});}return _0x1d58e0;});}})[_0xbf14('0x15')](respondWithResult(_0x2e3fd1,null))[_0xbf14('0x20')](handleError(_0x2e3fd1,null));};exports[_0xbf14('0x123')]=function(_0x2f27e8,_0x1c97ab){return db[_0xbf14('0x45')][_0xbf14('0x48')]({'where':{'id':_0x2f27e8[_0xbf14('0x52')]['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x1c97ab,null))['then'](function(_0x3c86c6){if(_0x3c86c6){return _0x3c86c6['removeAgents'](_0x2f27e8[_0xbf14('0x39')]['ids'])['then'](function(){if(_[_0xbf14('0x124')](_0x2f27e8[_0xbf14('0x39')][_0xbf14('0x60')])){for(var _0xefc20b=0x0;_0xefc20b<_0x2f27e8['query']['ids'][_0xbf14('0x3e')];_0xefc20b+=0x1){socket[_0xbf14('0x122')](_0xbf14('0x125'),{'UserId':Number(_0x2f27e8['query'][_0xbf14('0x60')][_0xefc20b]),'ChatWebsiteId':Number(_0x2f27e8[_0xbf14('0x52')]['id'])});}}else{socket[_0xbf14('0x122')]('userChatWebsite:remove',{'UserId':Number(_0x2f27e8[_0xbf14('0x39')][_0xbf14('0x60')]),'ChatWebsiteId':Number(_0x2f27e8['params']['id'])});}});}})[_0xbf14('0x15')](respondWithStatusCode(_0x1c97ab,null))['catch'](handleError(_0x1c97ab,null));};exports[_0xbf14('0x126')]=function(_0x476257,_0x124425){var _0x28841c={};var _0x3e3ad9={};var _0x137b0d;var _0xc9c598;return db[_0xbf14('0x45')]['findOne']({'where':{'id':_0x476257[_0xbf14('0x52')]['id']}})[_0xbf14('0x15')](handleEntityNotFound(_0x124425,null))[_0xbf14('0x15')](function(_0x8a0847){if(_0x8a0847){_0x137b0d=_0x8a0847;_0x3e3ad9['model']=_[_0xbf14('0x38')](db[_0xbf14('0xec')]['rawAttributes']);_0x3e3ad9['query']=_[_0xbf14('0x38')](_0x476257[_0xbf14('0x39')]);_0x3e3ad9[_0xbf14('0x3a')]=_[_0xbf14('0x3b')](_0x3e3ad9['model'],_0x3e3ad9[_0xbf14('0x39')]);_0x28841c[_0xbf14('0x3c')]=_[_0xbf14('0x3b')](_0x3e3ad9[_0xbf14('0x37')],qs[_0xbf14('0x3d')](_0x476257['query'][_0xbf14('0x3d')]));_0x28841c[_0xbf14('0x3c')]=_0x28841c[_0xbf14('0x3c')]['length']?_0x28841c[_0xbf14('0x3c')]:_0x3e3ad9[_0xbf14('0x37')];_0x28841c['order']=qs['sort'](_0x476257['query'][_0xbf14('0x40')]);_0x28841c[_0xbf14('0x41')]=qs[_0xbf14('0x3a')](_['pick'](_0x476257[_0xbf14('0x39')],_0x3e3ad9[_0xbf14('0x3a')]));if(_0x476257['query'][_0xbf14('0x5b')]){_0x28841c['where']=_['merge'](_0x28841c[_0xbf14('0x41')],{'$or':_['map'](_0x28841c[_0xbf14('0x3c')],function(_0x567f20){var _0x21a8db={};_0x21a8db[_0x567f20]={'$like':'%'+_0x476257['query'][_0xbf14('0x5b')]+'%'};return _0x21a8db;})});}_0x28841c=_[_0xbf14('0x43')]({},_0x28841c,_0x476257[_0xbf14('0x44')]);return _0x137b0d['getAgents'](_0x28841c);}})['then'](function(_0x48ceb0){if(_0x48ceb0){_0xc9c598=_0x48ceb0['length'];if(!_0x476257[_0xbf14('0x39')][_0xbf14('0x59')](_0xbf14('0x3f'))){_0x28841c['limit']=qs[_0xbf14('0x27')](_0x476257[_0xbf14('0x39')]['limit']);_0x28841c[_0xbf14('0x24')]=qs[_0xbf14('0x24')](_0x476257['query'][_0xbf14('0x24')]);}return _0x137b0d[_0xbf14('0x126')](_0x28841c);}})[_0xbf14('0x15')](function(_0x3b596){if(_0x3b596){return _0x3b596?{'count':_0xc9c598,'rows':_0x3b596}:null;}})[_0xbf14('0x15')](respondWithResult(_0x124425,null))['catch'](handleError(_0x124425,null));};
\ No newline at end of file
+var _0x984b=['vendor','%s\x20%s\x20%s','type','stringify','index','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','fieldName','key','query','keys','filters','intersection','attributes','fields','length','nolimit','offset','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','find','create','address','forEach','testWildcardValidity','trim','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','hasOwnProperty','removeDispositions','addAnswer','CannedAnswer','getAnswers','findOne','removeAnswers','ids','sitepic','file','filename','agentAvatar','addCustomerAvatar','addSystemAvatar','systemAvatar','join','root','server/files/images/logos/default_logo.svg','../../config/license/util','getLicense','custom','server/files/images/logos/','download','getAvatar','isNil','server/files/images/avatars/','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','customerAvatar','existsSync','getSystemAvatar','server/files/images/avatars/system_avatar.png','Interval','resolve','timezone','ifTime','notify','chat','mapKey','MapKey\x20is\x20mandatory','createdAt','updatedAt','includes','CompanyId','ListId','Invalid\x20MapKey\x20parameter.\x20Allowed\x20values:\x20','List','DESC','ChatApplication','Applications','Intervals','interval','Chat\x20Website\x20with\x20id\x20%s\x20not\x20found','account','applications','orderBy','priority','list','Contacts','from','CmContact','threadId','closed','Writing\x20on\x20closed\x20interaction','externalUrl','ChatInteraction','interaction','messageId','created','autoclose','push','close','unmanaged','*,*,*,*','ChatMessage','AttachmentId','UserId','unshift','agent','queueId','waitForTheAssignedQueue','Start','EventManager','offline','files','Sequelize','ValidationError','no\x20available\x20attributes','difference','from\x20is\x20mandatory','mapKeyOffline','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','spread','server/files/templates/chatOfflineMessage.ejs','render','toPairs','fromString','originalname','mimetype','server','attachments','offline-chat','basename','openNewInteraction','sequelize','transaction','Attachment','bulkCreate','MailAccount','Smtp','CloudProvider','SendMail','sendMail','\x22%s\x22\x20<%s>','email','forwardOfflineAddress','offlineMessageSubject','subjectOffline','toPairsIn','mapValues','Chat','MailAccountId','NotifyMailAccount','notifyMail','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','User','Owner','fullname','internal','Tag','Tags','tag','getSnippet','getProactiveActions','virtual','License','chatLicenseExceeded','readFileSync','server/files/chat/iframe.ejs','utf8','3.13.0','headers','origin','http://localhost:9000','testWebsiteWithWildcard','remote','connection','remoteAddress','replace','alignment','color','labelText','textColor','textButtonColor','backgroundColor','IntervalId','ISOLATION_LEVELS','findAndCountAll','finally','getApplications','chatProactiveAction','ChatProactiveAction','getFields','online','false','offlineForm','onlineForm','items','getOfflineMessages','ChatOfflineMessage','Attachments','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','ejs','fs-extra','lodash','ioredis','jayson/promise','api','../../config/environment','APIBadRequestError','../../errors/api','handleError','APIConflictError','./helpers/wildcard-expressions','url','URL','../../mysqldb','redis','defaults','localhost','register','client','http','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','sendStatus','status','end','json','undefined','limit','count','set','update','destroy','get','ChatWebsites','UserProfileResource','stack','name','send','user-agent-parser','setUA','getResult','customerIp','cf-connecting-ip','x-forwarded-for','first','split','firstName','lastName','x-real-port','referer','browser','version','format','%s\x20%s','device','model'];(function(_0x40daf9,_0x1beebc){var _0x14446f=function(_0x492fe1){while(--_0x492fe1){_0x40daf9['push'](_0x40daf9['shift']());}};_0x14446f(++_0x1beebc);}(_0x984b,0xee));var _0xb984=function(_0x1cc9f9,_0x6bf4c5){_0x1cc9f9=_0x1cc9f9-0x0;var _0x341e9a=_0x984b[_0x1cc9f9];return _0x341e9a;};'use strict';var Mustache=require('mustache');var util=require('util');var path=require('path');var ejs=require(_0xb984('0x0'));var fs=require('fs');var fs_extra=require(_0xb984('0x1'));var _=require(_0xb984('0x2'));var querystring=require('querystring');var htmlToText=require('html-to-text');var Redis=require(_0xb984('0x3'));var jayson=require(_0xb984('0x4'));var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')(_0xb984('0x5'));var config=require(_0xb984('0x6'));var APIBadRequestError=require('../../errors/api')[_0xb984('0x7')];var APINotFoundError=require(_0xb984('0x8'))['APINotFoundError'];var APIOutOfIntervalError=require(_0xb984('0x8'))['APIOutOfIntervalError'];var APIHandleError=require(_0xb984('0x8'))[_0xb984('0x9')];var APIConflictError=require(_0xb984('0x8'))[_0xb984('0xa')];var wildcardUtils=require(_0xb984('0xb'));var URL=require(_0xb984('0xc'))[_0xb984('0xd')];var db=require(_0xb984('0xe'))['db'];config[_0xb984('0xf')]=_[_0xb984('0x10')](config[_0xb984('0xf')],{'host':_0xb984('0x11'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb984('0xf')]));require('./chatWebsite.socket')[_0xb984('0x12')](socket);var client=jayson[_0xb984('0x13')]['http']({'port':0x232c});var client9002=jayson[_0xb984('0x13')][_0xb984('0x14')]({'port':0x232a});var client9003=jayson['client'][_0xb984('0x14')]({'port':0x232b});var client9001=jayson[_0xb984('0x13')]['http']({'port':0x2329});function respondWithRpcPromise(_0xede12d,_0x4073cb,_0x57365c,_0x6fae41){return new Promise(function(_0x5cd1aa,_0x3b8241){var _0x1dc4df=_0x6fae41||client;return _0x1dc4df[_0xb984('0x15')](_0xede12d,_0x57365c)[_0xb984('0x16')](function(_0x59dcb7){logger[_0xb984('0x17')](_0xb984('0x18'),_0x4073cb,_0xb984('0x19'));logger[_0xb984('0x1a')](_0xb984('0x1b'),_0x4073cb,_0xb984('0x19'),JSON['stringify'](_0x59dcb7));if(_0x59dcb7[_0xb984('0x1c')]){if(_0x59dcb7[_0xb984('0x1c')][_0xb984('0x1d')]===0x1f4){logger[_0xb984('0x1c')](_0xb984('0x18'),_0x4073cb,_0x59dcb7[_0xb984('0x1c')]['message']);return _0x3b8241(_0x59dcb7[_0xb984('0x1c')][_0xb984('0x1e')]);}logger['error'](_0xb984('0x18'),_0x4073cb,_0x59dcb7[_0xb984('0x1c')][_0xb984('0x1e')]);return _0x5cd1aa(_0x59dcb7[_0xb984('0x1c')][_0xb984('0x1e')]);}else{logger[_0xb984('0x17')](_0xb984('0x18'),_0x4073cb,'request\x20sent');_0x5cd1aa(_0x59dcb7[_0xb984('0x1f')][_0xb984('0x1e')]);}})[_0xb984('0x20')](function(_0x5d4d38){logger[_0xb984('0x1c')](_0xb984('0x18'),_0x4073cb,_0x5d4d38);_0x3b8241(_0x5d4d38);});});}function respondWithStatusCode(_0x1cb2c2,_0x2d0450){_0x2d0450=_0x2d0450||0xcc;return function(_0x1f7b62){if(_0x1f7b62){return _0x1cb2c2[_0xb984('0x21')](_0x2d0450);}return _0x1cb2c2[_0xb984('0x22')](_0x2d0450)[_0xb984('0x23')]();};}function respondWithResult(_0x5d93d9,_0x249d47){_0x249d47=_0x249d47||0xc8;return function(_0x469af6){if(_0x469af6){return _0x5d93d9[_0xb984('0x22')](_0x249d47)[_0xb984('0x24')](_0x469af6);}};}function respondWithFilteredResult(_0x4fb896,_0xa44895){return function(_0x67e4d3){if(_0x67e4d3){var _0x476811=typeof _0xa44895['offset']===_0xb984('0x25')&&typeof _0xa44895[_0xb984('0x26')]===_0xb984('0x25');var _0x3d2757=_0x67e4d3['count'];var _0x5b8da1=_0x476811?0x0:_0xa44895['offset'];var _0x10b9ac=_0x476811?_0x67e4d3[_0xb984('0x27')]:_0xa44895['offset']+_0xa44895[_0xb984('0x26')];var _0x2bb03f;if(_0x10b9ac>=_0x3d2757){_0x10b9ac=_0x3d2757;_0x2bb03f=0xc8;}else{_0x2bb03f=0xce;}_0x4fb896[_0xb984('0x22')](_0x2bb03f);return _0x4fb896[_0xb984('0x28')]('Content-Range',_0x5b8da1+'-'+_0x10b9ac+'/'+_0x3d2757)['json'](_0x67e4d3);}return null;};}function saveUpdates(_0x315f70){return function(_0x2daa31){if(_0x2daa31){return _0x2daa31[_0xb984('0x29')](_0x315f70)[_0xb984('0x16')](function(_0x4df9e0){return _0x4df9e0;});}return null;};}function removeEntity(_0x44ef84){return function(_0x35b37f){if(_0x35b37f){return _0x35b37f[_0xb984('0x2a')]()[_0xb984('0x16')](function(){var _0x3d2714=_0x35b37f[_0xb984('0x2b')]({'plain':!![]});var _0x5f4426=_0xb984('0x2c');return db[_0xb984('0x2d')][_0xb984('0x2a')]({'where':{'type':_0x5f4426,'resourceId':_0x3d2714['id']}})[_0xb984('0x16')](function(){return _0x35b37f;});})[_0xb984('0x16')](function(){_0x44ef84[_0xb984('0x22')](0xcc)['end']();});}};}function handleEntityNotFound(_0x31f490){return function(_0x138dc5){if(!_0x138dc5){_0x31f490['sendStatus'](0x194);}return _0x138dc5;};}function handleError(_0x578a80,_0x13a950){_0x13a950=_0x13a950||0x1f4;return function(_0x4a440d){logger[_0xb984('0x1c')](_0x4a440d[_0xb984('0x2e')]);if(_0x4a440d['name']){delete _0x4a440d[_0xb984('0x2f')];}_0x578a80['status'](_0x13a950)[_0xb984('0x30')](_0x4a440d);};}function createInteractionObject(_0x5c25a9,_0x19bd91,_0x557302,_0x52f872){var _0xf6d925=require(_0xb984('0x31'));var _0x4dac3f=new _0xf6d925();var _0x26b36c=_0x4dac3f[_0xb984('0x32')](_0x557302['user-agent'])[_0xb984('0x33')]();var _0x446f45=_0x19bd91[_0xb984('0x34')];if(_0x557302[_0xb984('0x35')]){_0x446f45=_0x557302['cf-connecting-ip'];}else if(_0x557302[_0xb984('0x36')]){_0x446f45=_[_0xb984('0x37')](_0x557302[_0xb984('0x36')][_0xb984('0x38')](','));}return{'ContactId':_0x52f872['id'],'ChatWebsiteId':_0x5c25a9,'from':(_0x52f872[_0xb984('0x39')]||'')+'\x20'+(_0x52f872[_0xb984('0x3a')]||''),'customerIp':_0x446f45,'customerPort':_0x557302[_0xb984('0x3b')]?_0x557302[_0xb984('0x3b')]:null,'referer':_0x19bd91[_0xb984('0x3c')],'browserName':_0x26b36c[_0xb984('0x3d')]['name']&&_0x26b36c[_0xb984('0x3d')][_0xb984('0x3e')]?util[_0xb984('0x3f')](_0xb984('0x40'),_0x26b36c[_0xb984('0x3d')][_0xb984('0x2f')],_0x26b36c[_0xb984('0x3d')][_0xb984('0x3e')]):'unknown','browserVersion':_0x26b36c['browser'][_0xb984('0x3e')]||'unknown','osName':util[_0xb984('0x3f')](_0xb984('0x40'),_0x26b36c['os'][_0xb984('0x2f')],_0x26b36c['os'][_0xb984('0x3e')]),'osVersion':_0x26b36c['os']['version'],'deviceModel':_0x26b36c[_0xb984('0x41')][_0xb984('0x42')]&&_0x26b36c['device'][_0xb984('0x43')]?util[_0xb984('0x3f')](_0xb984('0x44'),_0x26b36c[_0xb984('0x41')][_0xb984('0x42')],_0x26b36c[_0xb984('0x41')][_0xb984('0x43')],_0x26b36c['device'][_0xb984('0x45')]):null,'deviceVendor':_0x26b36c[_0xb984('0x41')]['vendor'],'deviceType':_0x26b36c['device'][_0xb984('0x45')],'formData':JSON[_0xb984('0x46')](_0x19bd91)};}exports[_0xb984('0x47')]=function(_0x248800,_0x1acc7a){var _0x56a3bf={'include':[{'model':db[_0xb984('0x48')],'as':_0xb984('0x49')}]},_0x664cb1={},_0x40666f={'count':0x0,'rows':[]};var _0x460a7e=_[_0xb984('0x4a')](db[_0xb984('0x4b')][_0xb984('0x4c')],function(_0x23b95b){return{'name':_0x23b95b[_0xb984('0x4d')],'type':_0x23b95b['type'][_0xb984('0x4e')]};});_0x664cb1[_0xb984('0x42')]=_['map'](_0x460a7e,_0xb984('0x2f'));_0x664cb1[_0xb984('0x4f')]=_[_0xb984('0x50')](_0x248800[_0xb984('0x4f')]);_0x664cb1[_0xb984('0x51')]=_[_0xb984('0x52')](_0x664cb1[_0xb984('0x42')],_0x664cb1[_0xb984('0x4f')]);_0x56a3bf[_0xb984('0x53')]=_[_0xb984('0x52')](_0x664cb1['model'],qs[_0xb984('0x54')](_0x248800[_0xb984('0x4f')][_0xb984('0x54')]));_0x56a3bf[_0xb984('0x53')]=_0x56a3bf[_0xb984('0x53')][_0xb984('0x55')]?_0x56a3bf[_0xb984('0x53')]:_0x664cb1[_0xb984('0x42')];if(!_0x248800[_0xb984('0x4f')]['hasOwnProperty'](_0xb984('0x56'))){_0x56a3bf[_0xb984('0x26')]=qs[_0xb984('0x26')](_0x248800['query'][_0xb984('0x26')]);_0x56a3bf[_0xb984('0x57')]=qs['offset'](_0x248800[_0xb984('0x4f')]['offset']);}_0x56a3bf[_0xb984('0x58')]=qs[_0xb984('0x59')](_0x248800['query'][_0xb984('0x59')]);_0x56a3bf[_0xb984('0x5a')]=qs[_0xb984('0x51')](_[_0xb984('0x5b')](_0x248800[_0xb984('0x4f')],_0x664cb1[_0xb984('0x51')]),_0x460a7e);if(_0x248800['query'][_0xb984('0x5c')]){_0x56a3bf['where']=_[_0xb984('0x5d')](_0x56a3bf[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x460a7e,function(_0x5cf038){if(_0x5cf038['type']!==_0xb984('0x5e')){var _0x2dfaf8={};_0x2dfaf8[_0x5cf038['name']]={'$like':'%'+_0x248800['query'][_0xb984('0x5c')]+'%'};return _0x2dfaf8;}})});}_0x56a3bf=_[_0xb984('0x5d')]({},_0x56a3bf,_0x248800[_0xb984('0x5f')]);var _0x3daaa0={'where':_0x56a3bf[_0xb984('0x5a')]};return db[_0xb984('0x4b')]['count'](_0x3daaa0)['then'](function(_0x3dcdf1){_0x40666f[_0xb984('0x27')]=_0x3dcdf1;if(_0x248800['query'][_0xb984('0x60')]){_0x56a3bf[_0xb984('0x61')]=[{'all':!![]}];}return db[_0xb984('0x4b')][_0xb984('0x62')](_0x56a3bf);})['then'](function(_0x4d719c){_0x40666f[_0xb984('0x63')]=_0x4d719c;return _0x40666f;})[_0xb984('0x16')](respondWithFilteredResult(_0x1acc7a,_0x56a3bf))[_0xb984('0x20')](handleError(_0x1acc7a,null));};exports[_0xb984('0x64')]=function(_0x3bdadc,_0x3cc2a0){var _0x49ecfd={'raw':![],'where':{'id':_0x3bdadc[_0xb984('0x65')]['id']},'include':[{'model':db[_0xb984('0x48')],'as':_0xb984('0x49')}]},_0x2de42b={};_0x2de42b[_0xb984('0x42')]=_[_0xb984('0x50')](db['ChatWebsite']['rawAttributes']);_0x2de42b['query']=_[_0xb984('0x50')](_0x3bdadc[_0xb984('0x4f')]);_0x2de42b[_0xb984('0x51')]=_[_0xb984('0x52')](_0x2de42b[_0xb984('0x42')],_0x2de42b['query']);_0x49ecfd[_0xb984('0x53')]=_[_0xb984('0x52')](_0x2de42b[_0xb984('0x42')],qs['fields'](_0x3bdadc[_0xb984('0x4f')][_0xb984('0x54')]));_0x49ecfd['attributes']=_0x49ecfd['attributes'][_0xb984('0x55')]?_0x49ecfd['attributes']:_0x2de42b['model'];if(_0x3bdadc[_0xb984('0x4f')]['includeAll']){_0x49ecfd[_0xb984('0x61')]=[{'all':!![]}];}_0x49ecfd=_[_0xb984('0x5d')]({},_0x49ecfd,_0x3bdadc[_0xb984('0x5f')]);return db[_0xb984('0x4b')][_0xb984('0x66')](_0x49ecfd)[_0xb984('0x16')](handleEntityNotFound(_0x3cc2a0,null))[_0xb984('0x16')](respondWithResult(_0x3cc2a0,null))[_0xb984('0x20')](handleError(_0x3cc2a0,null));};exports[_0xb984('0x67')]=function(_0x2b187f,_0x742a0f){var _0x1d9213=null;_0x2b187f['body'][_0xb984('0x68')][_0xb984('0x38')](',')[_0xb984('0x69')](_0x511780=>{if(_0x511780['trim']()!==''&&!wildcardUtils[_0xb984('0x6a')](_0x511780[_0xb984('0x6b')]())){_0x1d9213=new APIBadRequestError('\x22'+_0x511780[_0xb984('0x6b')]()+'\x22\x20is\x20not\x20a\x20valid\x20wildcard\x20expression');}});if(_0x1d9213){return handleError(_0x742a0f,null)(_0x1d9213);}return db[_0xb984('0x4b')][_0xb984('0x67')](_0x2b187f[_0xb984('0x6c')],{})[_0xb984('0x16')](function(_0x434c5c){var _0x1793e2=_0x2b187f[_0xb984('0x6d')][_0xb984('0x2b')]({'plain':!![]});if(!_0x1793e2)throw new Error(_0xb984('0x6e'));if(_0x1793e2[_0xb984('0x6f')]===_0xb984('0x6d')){var _0x4c377f=_0x434c5c[_0xb984('0x2b')]({'plain':!![]});var _0x9ea21f='ChatWebsites';return db[_0xb984('0x70')]['find']({'where':{'name':_0x9ea21f,'userProfileId':_0x1793e2[_0xb984('0x71')]},'raw':!![]})['then'](function(_0x3cfd28){if(_0x3cfd28&&_0x3cfd28[_0xb984('0x72')]===0x0){return db[_0xb984('0x2d')][_0xb984('0x67')]({'name':_0x4c377f[_0xb984('0x2f')],'resourceId':_0x4c377f['id'],'type':_0x3cfd28[_0xb984('0x2f')],'sectionId':_0x3cfd28['id']},{})[_0xb984('0x16')](function(){return _0x434c5c;});}else{return _0x434c5c;}})[_0xb984('0x20')](function(_0x3bc1d3){logger[_0xb984('0x1c')](_0xb984('0x73'),_0x3bc1d3);throw _0x3bc1d3;});}return _0x434c5c;})[_0xb984('0x16')](respondWithResult(_0x742a0f,0xc9))[_0xb984('0x20')](handleError(_0x742a0f,null));};exports['update']=function(_0x4886bf,_0x917c53){var _0x441166=null;_0x4886bf[_0xb984('0x6c')]['address'][_0xb984('0x38')](',')[_0xb984('0x69')](_0x50544b=>{if(_0x50544b['trim']()!==''&&!wildcardUtils['testWildcardValidity'](_0x50544b[_0xb984('0x6b')]())){_0x441166=new APIBadRequestError('\x22'+_0x50544b['trim']()+'\x22\x20is\x20not\x20a\x20valid\x20wildcard\x20expression');}});if(_0x441166){return handleError(_0x917c53,null)(_0x441166);}if(_0x4886bf['body']['id']){delete _0x4886bf[_0xb984('0x6c')]['id'];}return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x4886bf[_0xb984('0x65')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]})[_0xb984('0x16')](handleEntityNotFound(_0x917c53,null))[_0xb984('0x16')](saveUpdates(_0x4886bf[_0xb984('0x6c')],null))[_0xb984('0x16')](respondWithResult(_0x917c53,null))[_0xb984('0x20')](handleError(_0x917c53,null));};exports['destroy']=function(_0x2063cd,_0x3e7ed1){return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x2063cd[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x3e7ed1,null))['then'](removeEntity(_0x3e7ed1,null))[_0xb984('0x20')](handleError(_0x3e7ed1,null));};exports['describe']=function(_0x12890c,_0x1d9392){return db[_0xb984('0x4b')][_0xb984('0x74')]()[_0xb984('0x16')](respondWithResult(_0x1d9392,null))['catch'](handleError(_0x1d9392,null));};exports[_0xb984('0x75')]=function(_0x203915,_0x1f0e09){if(_0x203915['body']['id']){delete _0x203915[_0xb984('0x6c')]['id'];}return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x203915[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x1f0e09,null))['then'](function(_0x504d1a){if(_0x504d1a){_0x203915[_0xb984('0x6c')][_0xb984('0x76')]=_0x504d1a['id'];return db[_0xb984('0x77')][_0xb984('0x67')](_0x203915['body']);}})[_0xb984('0x16')](respondWithResult(_0x1f0e09,null))[_0xb984('0x20')](handleError(_0x1f0e09,null));};exports[_0xb984('0x78')]=function(_0x199e48,_0x5e4b1f){var _0x1b0673={'raw':![],'where':{}};var _0x2725eb={};var _0x417526={'count':0x0,'rows':[]};return db[_0xb984('0x4b')]['findOne']({'where':{'id':_0x199e48[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x5e4b1f,null))[_0xb984('0x16')](function(_0x2d686e){if(_0x2d686e){_0x2725eb[_0xb984('0x42')]=_[_0xb984('0x50')](db[_0xb984('0x77')][_0xb984('0x4c')]);_0x2725eb[_0xb984('0x4f')]=_[_0xb984('0x50')](_0x199e48[_0xb984('0x4f')]);_0x2725eb['filters']=_[_0xb984('0x52')](_0x2725eb[_0xb984('0x42')],_0x2725eb[_0xb984('0x4f')]);_0x1b0673[_0xb984('0x53')]=_[_0xb984('0x52')](_0x2725eb[_0xb984('0x42')],qs['fields'](_0x199e48[_0xb984('0x4f')][_0xb984('0x54')]));_0x1b0673[_0xb984('0x53')]=_0x1b0673[_0xb984('0x53')]['length']?_0x1b0673[_0xb984('0x53')]:_0x2725eb[_0xb984('0x42')];if(!_0x199e48['query'][_0xb984('0x79')]('nolimit')){_0x1b0673['limit']=qs[_0xb984('0x26')](_0x199e48[_0xb984('0x4f')][_0xb984('0x26')]);_0x1b0673[_0xb984('0x57')]=qs[_0xb984('0x57')](_0x199e48[_0xb984('0x4f')][_0xb984('0x57')]);}_0x1b0673[_0xb984('0x58')]=qs[_0xb984('0x59')](_0x199e48['query']['sort']);_0x1b0673[_0xb984('0x5a')]=qs[_0xb984('0x51')](_[_0xb984('0x5b')](_0x199e48[_0xb984('0x4f')],_0x2725eb['filters']));_0x1b0673[_0xb984('0x5a')][_0xb984('0x76')]=_0x2d686e['id'];if(_0x199e48[_0xb984('0x4f')][_0xb984('0x5c')]){_0x1b0673[_0xb984('0x5a')]=_[_0xb984('0x5d')](_0x1b0673['where'],{'$or':_[_0xb984('0x4a')](_0x1b0673['attributes'],function(_0x38b0e6){var _0x56cb5d={};_0x56cb5d[_0x38b0e6]={'$like':'%'+_0x199e48[_0xb984('0x4f')]['filter']+'%'};return _0x56cb5d;})});}_0x1b0673=_['merge']({},_0x1b0673,_0x199e48[_0xb984('0x5f')]);return db[_0xb984('0x77')]['count']({'where':_0x1b0673[_0xb984('0x5a')]})[_0xb984('0x16')](function(_0x1eecfd){_0x417526[_0xb984('0x27')]=_0x1eecfd;if(_0x199e48[_0xb984('0x4f')]['includeAll']){_0x1b0673['include']=[{'all':!![]}];}return db[_0xb984('0x77')][_0xb984('0x62')](_0x1b0673);})['then'](function(_0x42a63d){_0x417526[_0xb984('0x63')]=_0x42a63d;return _0x417526;});}})[_0xb984('0x16')](respondWithFilteredResult(_0x5e4b1f,_0x1b0673))['catch'](handleError(_0x5e4b1f,null));};exports[_0xb984('0x7a')]=function(_0x52c145,_0x15a258){return db[_0xb984('0x4b')]['find']({'where':{'id':_0x52c145[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x15a258,null))[_0xb984('0x16')](function(_0xc39a0){if(_0xc39a0){return _0xc39a0['removeDispositions'](_0x52c145['query']['ids']);}})['then'](respondWithStatusCode(_0x15a258,null))['catch'](handleError(_0x15a258,null));};exports[_0xb984('0x7b')]=function(_0x431b44,_0x50de1){if(_0x431b44[_0xb984('0x6c')]['id']){delete _0x431b44[_0xb984('0x6c')]['id'];}return db[_0xb984('0x4b')]['find']({'where':{'id':_0x431b44[_0xb984('0x65')]['id']}})['then'](handleEntityNotFound(_0x50de1,null))['then'](function(_0x45cf65){if(_0x45cf65){_0x431b44['body'][_0xb984('0x76')]=_0x45cf65['id'];return db[_0xb984('0x7c')]['create'](_0x431b44[_0xb984('0x6c')]);}})[_0xb984('0x16')](respondWithResult(_0x50de1,null))[_0xb984('0x20')](handleError(_0x50de1,null));};exports[_0xb984('0x7d')]=function(_0x1e48c5,_0x35c63a){var _0x175683={'raw':![],'where':{}};var _0x1ac7bd={};var _0x2c2750={'count':0x0,'rows':[]};return db[_0xb984('0x4b')][_0xb984('0x7e')]({'where':{'id':_0x1e48c5[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x35c63a,null))['then'](function(_0x3e2bd0){if(_0x3e2bd0){_0x1ac7bd['model']=_[_0xb984('0x50')](db['CannedAnswer'][_0xb984('0x4c')]);_0x1ac7bd[_0xb984('0x4f')]=_[_0xb984('0x50')](_0x1e48c5[_0xb984('0x4f')]);_0x1ac7bd[_0xb984('0x51')]=_[_0xb984('0x52')](_0x1ac7bd[_0xb984('0x42')],_0x1ac7bd['query']);_0x175683[_0xb984('0x53')]=_[_0xb984('0x52')](_0x1ac7bd[_0xb984('0x42')],qs[_0xb984('0x54')](_0x1e48c5[_0xb984('0x4f')][_0xb984('0x54')]));_0x175683[_0xb984('0x53')]=_0x175683[_0xb984('0x53')][_0xb984('0x55')]?_0x175683['attributes']:_0x1ac7bd[_0xb984('0x42')];if(!_0x1e48c5[_0xb984('0x4f')][_0xb984('0x79')](_0xb984('0x56'))){_0x175683[_0xb984('0x26')]=qs[_0xb984('0x26')](_0x1e48c5[_0xb984('0x4f')][_0xb984('0x26')]);_0x175683[_0xb984('0x57')]=qs[_0xb984('0x57')](_0x1e48c5['query'][_0xb984('0x57')]);}_0x175683['order']=qs[_0xb984('0x59')](_0x1e48c5[_0xb984('0x4f')][_0xb984('0x59')]);_0x175683[_0xb984('0x5a')]=qs[_0xb984('0x51')](_['pick'](_0x1e48c5[_0xb984('0x4f')],_0x1ac7bd[_0xb984('0x51')]));_0x175683['where'][_0xb984('0x76')]=_0x3e2bd0['id'];if(_0x1e48c5[_0xb984('0x4f')][_0xb984('0x5c')]){_0x175683['where']=_[_0xb984('0x5d')](_0x175683[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x175683[_0xb984('0x53')],function(_0xc92c53){var _0x22425e={};_0x22425e[_0xc92c53]={'$like':'%'+_0x1e48c5[_0xb984('0x4f')][_0xb984('0x5c')]+'%'};return _0x22425e;})});}_0x175683=_[_0xb984('0x5d')]({},_0x175683,_0x1e48c5[_0xb984('0x5f')]);return db['CannedAnswer']['count']({'where':_0x175683['where']})[_0xb984('0x16')](function(_0xfe3d03){_0x2c2750[_0xb984('0x27')]=_0xfe3d03;if(_0x1e48c5[_0xb984('0x4f')]['includeAll']){_0x175683['include']=[{'all':!![]}];}return db['CannedAnswer'][_0xb984('0x62')](_0x175683);})[_0xb984('0x16')](function(_0x5e9fa1){_0x2c2750[_0xb984('0x63')]=_0x5e9fa1;return _0x2c2750;});}})['then'](respondWithFilteredResult(_0x35c63a,_0x175683))[_0xb984('0x20')](handleError(_0x35c63a,null));};exports['removeAnswers']=function(_0x1ca908,_0x5e2d33){return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x1ca908['params']['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x5e2d33,null))['then'](function(_0x3b0e65){if(_0x3b0e65){return _0x3b0e65[_0xb984('0x7f')](_0x1ca908[_0xb984('0x4f')][_0xb984('0x80')]);}})['then'](respondWithStatusCode(_0x5e2d33,null))[_0xb984('0x20')](handleError(_0x5e2d33,null));};exports['addLogo']=function(_0x272bf0,_0x28c248){_0x272bf0[_0xb984('0x6c')][_0xb984('0x81')]=_0x272bf0[_0xb984('0x82')][_0xb984('0x83')];return db['ChatWebsite'][_0xb984('0x66')]({'where':{'id':_0x272bf0[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x28c248,null))['then'](saveUpdates(_0x272bf0[_0xb984('0x6c')],null))[_0xb984('0x16')](respondWithResult(_0x28c248,null))[_0xb984('0x20')](handleError(_0x28c248,null));};exports['addAvatar']=function(_0x26b0bf,_0x3138df){_0x26b0bf[_0xb984('0x6c')][_0xb984('0x84')]=_0x26b0bf[_0xb984('0x82')][_0xb984('0x83')];return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x26b0bf[_0xb984('0x65')]['id']}})['then'](handleEntityNotFound(_0x3138df,null))[_0xb984('0x16')](saveUpdates(_0x26b0bf[_0xb984('0x6c')],null))[_0xb984('0x16')](respondWithResult(_0x3138df,null))[_0xb984('0x20')](handleError(_0x3138df,null));};exports[_0xb984('0x85')]=function(_0x1382d7,_0x5d1e30){_0x1382d7['body']['customerAvatar']=_0x1382d7['file']['filename'];return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x1382d7[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x5d1e30,null))[_0xb984('0x16')](saveUpdates(_0x1382d7[_0xb984('0x6c')],null))[_0xb984('0x16')](respondWithResult(_0x5d1e30,null))[_0xb984('0x20')](handleError(_0x5d1e30,null));};exports[_0xb984('0x86')]=function(_0x2f3a0e,_0x27ec1e){_0x2f3a0e[_0xb984('0x6c')][_0xb984('0x87')]=_0x2f3a0e[_0xb984('0x82')][_0xb984('0x83')];return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x2f3a0e[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x27ec1e,null))[_0xb984('0x16')](saveUpdates(_0x2f3a0e['body'],null))[_0xb984('0x16')](respondWithResult(_0x27ec1e,null))[_0xb984('0x20')](handleError(_0x27ec1e,null));};exports['getLogo']=function(_0x197038,_0x36ffc1){var _0x428c26=path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0x8a'));var _0x444d38={'where':{'id':_0x197038[_0xb984('0x65')]['id']},'attributes':['id',_0xb984('0x81')],'raw':!![]};var _0x447d61=![];return require(_0xb984('0x8b'))[_0xb984('0x8c')]()[_0xb984('0x16')](function(_0x1a4dc6){if(_0x1a4dc6){_0x447d61=_0x1a4dc6[_0xb984('0x8d')];}})[_0xb984('0x16')](function(){return db[_0xb984('0x4b')][_0xb984('0x66')](_0x444d38);})[_0xb984('0x16')](handleEntityNotFound(_0x36ffc1,null))[_0xb984('0x16')](function(_0x476fdd){if(_0x476fdd){if(!_['isNil'](_0x476fdd[_0xb984('0x81')])){if(fs['existsSync'](path['join'](config[_0xb984('0x89')],_0xb984('0x8e'),_0x476fdd[_0xb984('0x81')]))&&_0x447d61){_0x428c26=path['join'](config[_0xb984('0x89')],_0xb984('0x8e'),_0x476fdd[_0xb984('0x81')]);}}return _0x36ffc1[_0xb984('0x8f')](_0x428c26);}})['catch'](handleError(_0x36ffc1,null));};exports[_0xb984('0x90')]=function(_0x146470,_0x2cb327){var _0x2a4478=path['join'](config[_0xb984('0x89')],'server/files/images/avatars/default_avatar.png');var _0x5569e2={'where':{'id':_0x146470[_0xb984('0x65')]['id']},'attributes':['id',_0xb984('0x84')],'raw':!![]};return db['ChatWebsite'][_0xb984('0x66')](_0x5569e2)[_0xb984('0x16')](handleEntityNotFound(_0x2cb327,null))[_0xb984('0x16')](function(_0x2975da){if(_0x2975da){if(!_[_0xb984('0x91')](_0x2975da['agentAvatar'])){if(fs['existsSync'](path['join'](config['root'],_0xb984('0x92'),_0x2975da[_0xb984('0x84')]))){_0x2a4478=path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0x92'),_0x2975da[_0xb984('0x84')]);}}return _0x2cb327[_0xb984('0x8f')](_0x2a4478);}})[_0xb984('0x20')](handleError(_0x2cb327,null));};exports['getCustomerAvatar']=function(_0x7a61a3,_0x364971){var _0x15c0d1=path['join'](config[_0xb984('0x89')],_0xb984('0x93'));var _0x126072={'where':{'id':_0x7a61a3[_0xb984('0x65')]['id']},'attributes':['id','customerAvatar',_0xb984('0x94')],'raw':!![]};return db[_0xb984('0x4b')]['find'](_0x126072)[_0xb984('0x16')](handleEntityNotFound(_0x364971,null))['then'](function(_0xa2ae6e){if(_0xa2ae6e){if(!_[_0xb984('0x91')](_0xa2ae6e[_0xb984('0x95')])){if(fs[_0xb984('0x96')](path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0x92'),_0xa2ae6e[_0xb984('0x95')]))&&_0xa2ae6e[_0xb984('0x94')]){_0x15c0d1=path['join'](config[_0xb984('0x89')],_0xb984('0x92'),_0xa2ae6e[_0xb984('0x95')]);}}return _0x364971[_0xb984('0x8f')](_0x15c0d1);}})['catch'](handleError(_0x364971,null));};exports[_0xb984('0x97')]=function(_0x566cf1,_0x1b9c9b){var _0x178bc5=path['join'](config[_0xb984('0x89')],_0xb984('0x98'));var _0x3ea17b={'where':{'id':_0x566cf1[_0xb984('0x65')]['id']},'attributes':['id',_0xb984('0x87')],'raw':!![]};return db[_0xb984('0x4b')][_0xb984('0x66')](_0x3ea17b)[_0xb984('0x16')](handleEntityNotFound(_0x1b9c9b,null))[_0xb984('0x16')](function(_0x18dda5){if(_0x18dda5){if(!_[_0xb984('0x91')](_0x18dda5['systemAvatar'])){if(fs[_0xb984('0x96')](path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0x92'),_0x18dda5[_0xb984('0x87')]))){_0x178bc5=path[_0xb984('0x88')](config[_0xb984('0x89')],'server/files/images/avatars/',_0x18dda5['systemAvatar']);}}return _0x1b9c9b[_0xb984('0x8f')](_0x178bc5);}})[_0xb984('0x20')](handleError(_0x1b9c9b,null));};function checkWebsiteInterval(_0x1261d7){var _0x7903b8=_0x1261d7[_0xb984('0x99')];if(!_0x7903b8){return Promise[_0xb984('0x9a')](_0x1261d7);}var _0x4d0329=_0x1261d7[_0xb984('0x9b')]||undefined;return _0x7903b8[_0xb984('0x9c')](_0x4d0329)[_0xb984('0x16')](function(_0xe6d4e3){if(!_0xe6d4e3){throw new APIOutOfIntervalError();}return _0x1261d7;});}exports[_0xb984('0x9d')]=function(_0xaf2e56,_0x59ef00){var _0x4964a2={'body':_0xaf2e56[_0xb984('0x6c')],'channel':_0xb984('0x9e')};var _0x40fe08=[];var _0x6df7f6=[];var _0x201dea={};var _0x34a464=![];if(_0xaf2e56[_0xb984('0x6c')]['id']){delete _0xaf2e56[_0xb984('0x6c')]['id'];}if(_[_0xb984('0x91')](_0xaf2e56[_0xb984('0x6c')]['from'])){throw new APIBadRequestError('From\x20is\x20mandatory');}if(_['isNil'](_0xaf2e56[_0xb984('0x6c')][_0xb984('0x9f')])){throw new APIBadRequestError(_0xb984('0xa0'));}if(_['isEmpty'](_0xaf2e56['body'][_0xb984('0x6c')])){throw new APIBadRequestError('Body\x20is\x20mandatory');}var _0x5408f0=_0xaf2e56[_0xb984('0x6c')][_0xb984('0x34')]&&_0xaf2e56[_0xb984('0x6c')]['referer'];return db['CmContact'][_0xb984('0x74')]()[_0xb984('0x16')](function(_0x21859f){if(!_0x21859f){throw new Error('No\x20available\x20attributes');}_0x40fe08=Object[_0xb984('0x50')](_0x21859f)[_0xb984('0x5c')](function(_0x217025){return![_0xb984('0xa1'),_0xb984('0xa2')][_0xb984('0xa3')](_0x217025);});_0x6df7f6=Object['keys'](_0x21859f)[_0xb984('0x5c')](function(_0x5d0b15){return![_0xb984('0xa1'),_0xb984('0xa2'),_0xb984('0xa4'),_0xb984('0xa5')][_0xb984('0xa3')](_0x5d0b15);});if(!_['includes'](_0x6df7f6,_0xaf2e56[_0xb984('0x6c')][_0xb984('0x9f')])){throw new APIBadRequestError(_0xb984('0xa6')+_0x6df7f6[_0xb984('0x88')](',\x20'));}_0x201dea[_0xaf2e56['body']['mapKey']]=_0xaf2e56[_0xb984('0x6c')]['from'];})[_0xb984('0x16')](function(){return db[_0xb984('0x4b')]['find']({'where':{'id':_0xaf2e56[_0xb984('0x65')]['id']},'include':[{'model':db['CmList'],'as':_0xb984('0xa7'),'include':[{'model':db['CmContact'],'as':'Contacts','where':_0x201dea,'limit':0x1,'order':[['updatedAt',_0xb984('0xa8')]]}]},{'model':db[_0xb984('0xa9')],'as':_0xb984('0xaa')},{'model':db['Interval'],'as':_0xb984('0x99'),'include':[{'model':db['Interval'],'as':_0xb984('0xab'),'attributes':['id',_0xb984('0xac')],'raw':!![]}]}]});})[_0xb984('0x16')](function(_0x51a74a){if(!_0x51a74a){throw new APINotFoundError(util[_0xb984('0x3f')](_0xb984('0xad'),_0xaf2e56[_0xb984('0x65')]['id']));}if(_0x5408f0){return checkWebsiteInterval(_0x51a74a);}return _0x51a74a;})[_0xb984('0x16')](function(_0x34f9de){_0x4964a2[_0xb984('0xae')]=_0x34f9de;_0x4964a2[_0xb984('0xaf')]=_[_0xb984('0xb0')](_0x34f9de['Applications'],[_0xb984('0xb1')],['asc']);if(_0x4964a2[_0xb984('0xae')][_0xb984('0xaa')]){delete _0x4964a2[_0xb984('0xae')][_0xb984('0xaa')];}_0x4964a2['list']=_0x34f9de[_0xb984('0xa7')]||{'id':_0x34f9de['ListId']};if(_0x4964a2[_0xb984('0xb2')]&&_0x4964a2[_0xb984('0xb2')]['Contacts'][_0xb984('0x55')]){return _0x4964a2['list'][_0xb984('0xb3')][0x0];}var _0x24dc10=_[_0xb984('0x10')](_0xaf2e56[_0xb984('0x6c')],{'firstName':_0xaf2e56[_0xb984('0x6c')][_0xb984('0xb4')],'ListId':_0x34f9de[_0xb984('0xa5')]});_0x24dc10[_0xaf2e56[_0xb984('0x6c')][_0xb984('0x9f')]]=_0xaf2e56[_0xb984('0x6c')][_0xb984('0xb4')];return db[_0xb984('0xb5')][_0xb984('0x67')](_0x24dc10,{'fields':_0x40fe08,'raw':!![]});})['then'](function(_0x3ec9bf){_0x4964a2['contact']=_0x3ec9bf;var _0x1657b9=createInteractionObject(_0xaf2e56[_0xb984('0x65')]['id'],_0xaf2e56['body'],_0xaf2e56['headers'],_0x3ec9bf);var _0x2cce8b={'ChatWebsiteId':_0xaf2e56[_0xb984('0x65')]['id']};if(_0xaf2e56[_0xb984('0x6c')][_0xb984('0xb6')]){_0x2cce8b['threadId']=_0xaf2e56[_0xb984('0x6c')][_0xb984('0xb6')];_0x2cce8b[_0xb984('0xb7')]=![];return db['ChatInteraction'][_0xb984('0x66')]({'where':_0x2cce8b})[_0xb984('0x16')](function(_0x95059b){var _0x41d5cc=_0xaf2e56[_0xb984('0x6c')]['customerIp']&&_0xaf2e56[_0xb984('0x6c')][_0xb984('0x3c')];if(_0x95059b){_0x34a464=!![];return _0x95059b;}else if(!_0x41d5cc&&_0x95059b&&_0x95059b[_0xb984('0xb7')]){throw new APIConflictError(_0xb984('0xb8'));}_0x1657b9[_0xb984('0xb6')]=_0xaf2e56[_0xb984('0x6c')][_0xb984('0xb6')];_0x1657b9[_0xb984('0xb9')]=_0xaf2e56[_0xb984('0x6c')]['externalUrl'];return db[_0xb984('0xba')][_0xb984('0x67')](_0x1657b9);});}_0x2cce8b['ContactId']=_0x3ec9bf['id'];if(_0xaf2e56[_0xb984('0x6c')]['interaction']&&_0xaf2e56['body'][_0xb984('0xbb')]['id']){_0x2cce8b['id']=_0xaf2e56[_0xb984('0x6c')][_0xb984('0xbb')]['id'];return db[_0xb984('0xba')][_0xb984('0x66')]({'where':_0x2cce8b})[_0xb984('0x16')](function(_0x5bda49){var _0x87fb63=_0xaf2e56['body'][_0xb984('0x34')]&&_0xaf2e56[_0xb984('0x6c')][_0xb984('0x3c')];if(!_0x87fb63&&_0x5bda49&&_0x5bda49[_0xb984('0xb7')]){throw new APIConflictError(_0xb984('0xb8'));}else if(_0x5bda49){_0x34a464=!![];return _0x5bda49;}else{return db[_0xb984('0xba')][_0xb984('0x67')](_0x1657b9);}});}return db[_0xb984('0xba')]['create'](_0x1657b9);})[_0xb984('0x16')](function(_0x2ef68f){if(!_0x34a464){return _0x2ef68f;}var _0x2b2b68={'from':(_0x4964a2['contact'][_0xb984('0x39')]||'')+'\x20'+(_0x4964a2['contact'][_0xb984('0x3a')]||'')};if(_0xaf2e56[_0xb984('0x6c')][_0xb984('0xb6')]&&_0xaf2e56['body']['messageId']&&_0xaf2e56[_0xb984('0x6c')]['threadId']!=_0xaf2e56[_0xb984('0x6c')][_0xb984('0xbc')]){_0x2b2b68['threadId']=_0xaf2e56[_0xb984('0x6c')][_0xb984('0xbc')];}return _0x2ef68f[_0xb984('0x29')](_0x2b2b68);})[_0xb984('0x16')](function(_0x391988){_0x4964a2[_0xb984('0xbb')]=_0x391988[_0xb984('0x2b')]({'plain':!![]});_0x4964a2[_0xb984('0xbb')]['created']=!_0x34a464;if(_0x4964a2[_0xb984('0xbb')][_0xb984('0xbd')]){if(_0x4964a2[_0xb984('0xae')][_0xb984('0xbe')]){_0x4964a2[_0xb984('0xaf')][_0xb984('0xbf')]({'id':0x0,'priority':_0x4964a2[_0xb984('0xaf')][_0xb984('0x55')]+0x1,'app':_0xb984('0xc0'),'appdata':_0xb984('0xc1'),'interval':_0xb984('0xc2')});}}return db[_0xb984('0xc3')][_0xb984('0x67')]({'body':_0xaf2e56[_0xb984('0x6c')]['body'],'ChatWebsiteId':_0xaf2e56[_0xb984('0x65')]['id'],'ChatInteractionId':_0x391988['id'],'direction':'in','ContactId':_0x4964a2['contact']['id'],'AttachmentId':_0xaf2e56[_0xb984('0x6c')][_0xb984('0xc4')]});})[_0xb984('0x16')](function(_0xcf9ea6){_0x4964a2[_0xb984('0x1e')]=_0xcf9ea6;if(!_0x4964a2['interaction'][_0xb984('0xc5')]){return;}return db['User'][_0xb984('0x66')]({'attributes':['id',_0xb984('0x2f')],'where':{'id':_0x4964a2['interaction'][_0xb984('0xc5')]}});})[_0xb984('0x16')](function(_0x373d95){if(_0x373d95){_0x4964a2[_0xb984('0xaf')][_0xb984('0xc6')]({'id':0x0,'priority':0x0,'app':_0xb984('0xc7'),'appdata':_0x373d95[_0xb984('0x2f')]+','+(_0x4964a2['account']['waitForTheAssignedAgent']||0xa),'interval':'*,*,*,*'});_0x4964a2['forcedOwnership']=!![];}if(!_0x4964a2[_0xb984('0xbb')]['queueId']){return;}return db['ChatQueue'][_0xb984('0x66')]({'attributes':['id',_0xb984('0x2f')],'where':{'id':_0x4964a2[_0xb984('0xbb')][_0xb984('0xc8')]}});})[_0xb984('0x16')](function(_0x39b639){if(_0x39b639){_0x4964a2[_0xb984('0xaf')][_0xb984('0xc6')]({'id':0x0,'priority':0x1,'app':'queue','appdata':_0x39b639['name']+','+(_0x4964a2[_0xb984('0xae')][_0xb984('0xc9')]||0x12c),'interval':_0xb984('0xc2')});}return respondWithRpcPromise(_0xb984('0xca'),'startRouting',_0x4964a2);})[_0xb984('0x16')](function(_0x1d0780){respondWithRpcPromise(_0xb984('0xcb'),_0xb984('0xcb'),{'event':_0xb984('0x9d'),'message':_0x1d0780},client9002);return _0x1d0780;})['then'](respondWithResult(_0x59ef00,null))[_0xb984('0x20')](APIHandleError(_0x59ef00));};exports[_0xb984('0xcc')]=function(_0x3deb31,_0x3c982a){var _0x4a683e,_0x2d8347,_0x327159;var _0x4d67da=[];var _0x1ea3e2={};var _0x7892c7=_0x3deb31[_0xb984('0xcd')]||[];var _0x564a33=[];var _0x51f9d2;return db[_0xb984('0xb5')]['describe']()[_0xb984('0x16')](function(_0x2b39a9){if(!_0x2b39a9){throw new db[(_0xb984('0xce'))][(_0xb984('0xcf'))](_0xb984('0xd0'));}_0x4d67da=_[_0xb984('0xd1')](_['keys'](_0x2b39a9),['createdAt',_0xb984('0xa2'),_0xb984('0xa4'),_0xb984('0xa5')]);if(_0x3deb31[_0xb984('0x6c')]['id']){delete _0x3deb31[_0xb984('0x6c')]['id'];}if(_[_0xb984('0x91')](_0x3deb31['body'][_0xb984('0xb4')])){throw _0x3c982a['status'](0x1f4)[_0xb984('0x30')](new db[(_0xb984('0xce'))][(_0xb984('0xcf'))](_0xb984('0xd2')));}if(_[_0xb984('0x91')](_0x3deb31[_0xb984('0x6c')][_0xb984('0x6c')])||_0x3deb31[_0xb984('0x6c')][_0xb984('0x6c')]===''){throw _0x3c982a[_0xb984('0x22')](0x1f4)[_0xb984('0x30')](new db['Sequelize'][(_0xb984('0xcf'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0xb984('0x91')](_0x3deb31[_0xb984('0x6c')][_0xb984('0xd3')])){throw _0x3c982a[_0xb984('0x22')](0x1f4)[_0xb984('0x30')](new db[(_0xb984('0xce'))][(_0xb984('0xcf'))]('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4d67da));}if(!_['includes'](_0x4d67da,_0x3deb31[_0xb984('0x6c')]['mapKeyOffline'])){throw _0x3c982a['status'](0x1f4)[_0xb984('0x30')](new db[(_0xb984('0xce'))][(_0xb984('0xcf'))](_0xb984('0xd4')+_0x4d67da));}_0x1ea3e2[_0x3deb31[_0xb984('0x6c')]['mapKeyOffline']]=_0x3deb31[_0xb984('0x6c')][_0xb984('0xb4')];})['then'](function(){return db['ChatWebsite'][_0xb984('0x66')]({'where':{'id':_0x3deb31[_0xb984('0x65')]['id']},'include':[{'model':db[_0xb984('0xd5')],'as':_0xb984('0xa7')},{'model':db['MailAccount'],'as':'MailAccount'}]});})['then'](handleEntityNotFound(_0x3c982a,null))[_0xb984('0x16')](function(_0x30ebd){if(_0x30ebd&&_0x30ebd['List']){_0x2d8347=_0x30ebd;var _0x380f7b=_[_0xb984('0x10')](_0x3deb31[_0xb984('0x6c')],{'firstName':_0x3deb31[_0xb984('0x6c')][_0xb984('0xb4')],'phone':_0x3deb31[_0xb984('0x6c')][_0xb984('0xb4')],'ListId':_0x30ebd[_0xb984('0xa5')]});_0x380f7b[_0x3deb31[_0xb984('0x6c')][_0xb984('0xd3')]]=_0x3deb31['body'][_0xb984('0xb4')];return db[_0xb984('0xb5')]['findOrCreate']({'where':_0x1ea3e2,'defaults':_0x380f7b});}})[_0xb984('0xd6')](function(_0x2d960e){if(_0x2d960e){_0x327159=_0x2d960e;var _0xa402d1=fs['readFileSync'](path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0xd7')),'utf8');var _0x2b99d9=ejs[_0xb984('0xd8')](_0xa402d1,{'body':_[_0xb984('0xd9')](_0x3deb31[_0xb984('0x6c')][_0xb984('0x6c')]),'bodyTitle':_0x2d8347['offlineMessageBody']});return db['ChatOfflineMessage'][_0xb984('0x67')]({'body':_0x2b99d9,'plainBody':htmlToText[_0xb984('0xda')](_0x2b99d9),'ContactId':_0x2d960e['id'],'ChatWebsiteId':_0x2d8347['id']});}})[_0xb984('0x16')](function(_0x230900){_0x51f9d2=_0x230900;if(_0x7892c7[_0xb984('0x55')]){var _0x3fed67=_0x7892c7['map'](function(_0x17818b){return{'name':_0x17818b[_0xb984('0xdb')],'basename':_0x17818b[_0xb984('0x83')],'type':_0x17818b[_0xb984('0xdc')],'ChatOfflineMessageId':_0x230900['id']};});_0x564a33=_0x3fed67[_0xb984('0x4a')](_0x48db10=>{var _0x1bf129={'filename':_0x48db10[_0xb984('0x2f')],'path':path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0xdd'),_0xb984('0xcd'),_0xb984('0xde'),_0xb984('0xdf'),_0x48db10[_0xb984('0xe0')])};return _0x1bf129;});if(!_0x2d8347[_0xb984('0xe1')]){return db[_0xb984('0xe2')][_0xb984('0xe3')](function(_0x25c025){return db[_0xb984('0xe4')][_0xb984('0xe5')](_0x3fed67,{'transaction':_0x25c025});});}}})[_0xb984('0x16')](function(){if(_0x51f9d2){_0x4a683e=_0x51f9d2;return db[_0xb984('0xe6')][_0xb984('0x7e')]({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':_0xb984('0xe7'),'raw':!![],'include':[{'model':db['CloudProvider'],'as':_0xb984('0xe8'),'raw':!![]}]}]});}})[_0xb984('0x16')](function(_0x1453de){if(_0x1453de&&_0x1453de[_0xb984('0xe7')]&&_0x2d8347['forwardOffline']&&_0x2d8347['forwardOfflineAddress']){var _0x386213=_0x1453de['getSmtpOptions']();return respondWithRpcPromise(_0xb984('0xe9'),_0xb984('0xea'),{'account':_0x386213,'message':{'from':util[_0xb984('0x3f')](_0xb984('0xeb'),_0x1453de[_0xb984('0x2f')],_0x1453de[_0xb984('0xec')]||_0x1453de[_0xb984('0xe7')]['user']),'to':_0x2d8347[_0xb984('0xed')],'subject':_0x2d8347[_0xb984('0xee')],'html':_0x4a683e['body'],'attachments':_0x564a33}},client9003)[_0xb984('0x16')](function(){return _0x4a683e;})[_0xb984('0x20')](function(_0x2b3973){logger['error'](_0x2b3973);});}})['then'](function(){if(_0x2d8347&&_0x2d8347['openNewInteraction']&&_0x2d8347['MailAccountId']){var _0x5144b9=[];if(_0x7892c7['length']){_0x5144b9=_0x7892c7['map'](function(_0x2da5c1){return{'name':_0x2da5c1[_0xb984('0xdb')],'basename':_0x2da5c1[_0xb984('0x83')],'type':_0x2da5c1[_0xb984('0xdc')],'ChatOfflineMessageId':_0x51f9d2['id']};});}var _0x5351c1;if(!_[_0xb984('0x91')](_0x2d8347[_0xb984('0xef')])){var _0x5e2df9=_[_0xb984('0x4a')](_0x3deb31['body'],function(_0xd91a0b){return _0xd91a0b;});var _0x5944da=_[_0xb984('0xf0')](_0x5e2df9)[0x0];var _0x54c95b=_[_0xb984('0xf1')](_0x5944da,function(_0x4054bc){return _0x4054bc;});_0x5351c1=_0x54c95b[0x1][_0x2d8347[_0xb984('0xef')]];}var _0x1cf6ed={'from':_0x327159[_0xb984('0xec')],'firstName':_0x327159['firstName'],'lastName':_0x327159[_0xb984('0x3a')],'mapKey':'email','message':{'from':_0x327159['email'],'to':_0x2d8347['MailAccount'][_0xb984('0xec')],'cc':'','subject':_[_0xb984('0x91')](_0x5351c1)?_0x2d8347['offlineMessageSubject']:_0x5351c1,'messageId':'','sentAt':new Date(),'attach':_0x5144b9['length'],'attachments':_0x5144b9,'originChannel':_0xb984('0xf2'),'ChatWebsiteId':_0x2d8347['id'],'ChatOfflineMessageId':_0x4a683e['id'],'originTo':_0x2d8347['MailAccount']['email']},'body':_0x4a683e[_0xb984('0x6c')]};var _0x1923e0={'account':{'id':_0x2d8347[_0xb984('0xf3')]},'body':_0x1cf6ed,'log':_0xb984('0xf4')};return respondWithRpcPromise(_0xb984('0xf4'),_0xb984('0xf5'),_0x1923e0,client9001)['then'](function(){return _0x4a683e;})[_0xb984('0x20')](function(_0x21e3cb){logger[_0xb984('0x1c')](_0x21e3cb);});}return;})[_0xb984('0x16')](function(){if(_0x4a683e){return _0x4a683e;}})['then'](respondWithResult(_0x3c982a,null))[_0xb984('0x20')](function(){for(var _0x239446 of _0x7892c7){var _0x560a43=path[_0xb984('0x88')](config['root'],_0xb984('0xdd'),_0xb984('0xcd'),_0xb984('0xde'),_0xb984('0xdf'),_0x239446[_0xb984('0x83')]);fs_extra[_0xb984('0xf6')](_0x560a43)[_0xb984('0x20')](function(_0xf96fed){logger[_0xb984('0x1c')](_0xb984('0xf7'),_0x560a43,_0xf96fed);});}});};exports[_0xb984('0xf8')]=function(_0x470640,_0x484883){return db[_0xb984('0xba')]['find']({'where':{'id':_0x470640[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x484883,null))['then'](function(_0x1dc7cf){if(_0x1dc7cf){return _0x1dc7cf[_0xb984('0xf8')](_0x470640[_0xb984('0x6c')][_0xb984('0x80')],_[_0xb984('0xf9')](_0x470640[_0xb984('0x6c')],[_0xb984('0x80'),'id'])||{});}})[_0xb984('0x16')](respondWithResult(_0x484883,null))[_0xb984('0x20')](handleError(_0x484883,null));};exports[_0xb984('0xfa')]=function(_0x3eb419,_0x148d95){var _0x21412e={'raw':![],'where':{}};var _0x2dac8e={};var _0x230f60={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x3eb419[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x148d95,null))['then'](function(_0x306d47){if(_0x306d47){_0x2dac8e[_0xb984('0x42')]=_[_0xb984('0x50')](db[_0xb984('0xba')][_0xb984('0x4c')]);_0x2dac8e['query']=_[_0xb984('0x50')](_0x3eb419[_0xb984('0x4f')]);_0x2dac8e['filters']=_[_0xb984('0x52')](_0x2dac8e['model'],_0x2dac8e[_0xb984('0x4f')]);_0x21412e[_0xb984('0x53')]=_[_0xb984('0x52')](_0x2dac8e[_0xb984('0x42')],qs[_0xb984('0x54')](_0x3eb419[_0xb984('0x4f')]['fields']));_0x21412e[_0xb984('0x53')]=_0x21412e['attributes']['length']?_0x21412e['attributes']:_0x2dac8e[_0xb984('0x42')];if(!_0x3eb419[_0xb984('0x4f')][_0xb984('0x79')](_0xb984('0x56'))){_0x21412e[_0xb984('0x26')]=qs[_0xb984('0x26')](_0x3eb419[_0xb984('0x4f')][_0xb984('0x26')]);_0x21412e[_0xb984('0x57')]=qs[_0xb984('0x57')](_0x3eb419[_0xb984('0x4f')][_0xb984('0x57')]);}_0x21412e[_0xb984('0x58')]=qs[_0xb984('0x59')](_0x3eb419[_0xb984('0x4f')][_0xb984('0x59')]);_0x21412e[_0xb984('0x5a')]=qs[_0xb984('0x51')](_[_0xb984('0x5b')](_0x3eb419[_0xb984('0x4f')],_0x2dac8e[_0xb984('0x51')]));_0x21412e[_0xb984('0x5a')]['ChatWebsiteId']=_0x306d47['id'];if(_0x3eb419['query']['filter']){_0x21412e[_0xb984('0x5a')]=_[_0xb984('0x5d')](_0x21412e[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x21412e[_0xb984('0x53')],function(_0x316390){var _0x441031={};_0x441031[_0x316390]={'$like':'%'+_0x3eb419['query'][_0xb984('0x5c')]+'%'};return _0x441031;})});}_0x21412e=_[_0xb984('0x5d')]({},_0x21412e,_0x3eb419[_0xb984('0x5f')]);return db[_0xb984('0xba')][_0xb984('0x27')]({'where':_0x21412e[_0xb984('0x5a')]})[_0xb984('0x16')](function(_0x86780d){_0x230f60[_0xb984('0x27')]=_0x86780d;if(_0x3eb419[_0xb984('0x4f')][_0xb984('0x60')]){_0x21412e[_0xb984('0x61')]=[{'model':db[_0xb984('0xb5')],'as':_0xb984('0xfb'),'required':![]},{'model':db[_0xb984('0xfc')],'as':_0xb984('0xfd'),'attributes':[_0xb984('0x2f'),_0xb984('0xfe'),_0xb984('0xff')],'required':![]},{'model':db[_0xb984('0x100')],'as':_0xb984('0x101'),'attributes':['id',_0xb984('0x2f'),'color'],'where':_0x3eb419[_0xb984('0x4f')][_0xb984('0x102')]?{'id':_0x3eb419[_0xb984('0x4f')]['tag']}:undefined,'required':_0x3eb419[_0xb984('0x4f')]['tag']?!![]:![]}];}return db['ChatInteraction'][_0xb984('0x62')](_0x21412e);})['then'](function(_0x162eb7){_0x230f60[_0xb984('0x63')]=_0x162eb7;return _0x230f60;});}})['then'](respondWithFilteredResult(_0x148d95,_0x21412e))[_0xb984('0x20')](handleError(_0x148d95,null));};exports[_0xb984('0x103')]=function(_0x1af036,_0x5e7936){var _0x3145f8=0x0;var _0x2e9f8e=0x0;var _0x1029bb=![];var _0x2ad62e;var _0x31c9a1;return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x1af036[_0xb984('0x65')]['id']},'include':[{'model':db[_0xb984('0x99')],'as':_0xb984('0x99'),'include':[{'model':db['Interval'],'as':'Intervals','attributes':['id',_0xb984('0xac')]}]}]})[_0xb984('0x16')](handleEntityNotFound(_0x5e7936,null))[_0xb984('0x16')](function(_0x4bd400){if(_0x4bd400){_0x2ad62e=_0x4bd400;return _0x4bd400[_0xb984('0x104')]({'raw':!![]});}})[_0xb984('0x16')](function(_0x2dc204){if(_0x2ad62e){if(_0x2dc204){_0x31c9a1=_0x2dc204;}}return require('../../config/license/util')['getLicense']();})[_0xb984('0x16')](function(_0x5ca21e){if(_0x5ca21e){_0x2e9f8e=_0x5ca21e[_0xb984('0x105')];_0x1029bb=_0x5ca21e['custom'];}})[_0xb984('0x16')](function(){return db[_0xb984('0xba')][_0xb984('0x27')]({'where':{'closed':![]}});})[_0xb984('0x16')](function(_0x3f70f2){_0x3145f8=_0x3f70f2;if(_0x2e9f8e&&_0x3f70f2>_0x2e9f8e){return db[_0xb984('0x106')][_0xb984('0x7e')]({'where':{'id':0x1}})['then'](function(_0x2b2d2f){if(_0x2b2d2f){_0x2b2d2f['increment'](_0xb984('0x107'));}});}})['then'](function(){var _0x4c01f7=_0x2ad62e[_0xb984('0x99')];var _0x83aa33=_0x2ad62e[_0xb984('0x9b')]||undefined;return _0x4c01f7?_0x4c01f7[_0xb984('0x9c')](_0x83aa33):!![];})['then'](function(_0x256b3d){var _0x5eee58=fs[_0xb984('0x108')](path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0x109')),_0xb984('0x10a'));var _0xb5c49f=_0xb984('0x10b');var _0x22d584=![];var _0x461ab4,_0x2ba2fc;if(_0x1af036[_0xb984('0x10c')]['referer']){_0x461ab4=new URL(_0x1af036[_0xb984('0x10c')]['referer'])[_0xb984('0x10d')];}else if(_0x1af036[_0xb984('0x10c')][_0xb984('0x10d')]){_0x461ab4=new URL(_0x1af036['headers'][_0xb984('0x10d')])[_0xb984('0x10d')];}else{_0x461ab4=_0xb984('0x10e');}_0x2ba2fc=typeof _0x2ad62e[_0xb984('0x68')]['split'](',')[_0xb984('0x66')](function(_0x2df7bd){return wildcardUtils[_0xb984('0x10f')](_0x2df7bd,_0x461ab4);})!=='undefined';var _0x384873={'chatVersion':_0xb5c49f,'chatWebsiteAddressOrigin':_0x2ba2fc?_0x461ab4:_0x2ad62e[_0xb984('0x68')],'remote':_0x2ad62e[_0xb984('0x110')],'query':querystring['stringify'](_['merge'](_0x2ad62e['get']({'plain':!![]}),{'customerIp':_0x1af036[_0xb984('0x10c')]['x-forwarded-for']||_0x1af036['headers']['x-real-ip']||_0x1af036[_0xb984('0x111')][_0xb984('0x112')]||_0x1af036['ip'],'referer':_0x1af036['headers'][_0xb984('0x3c')],'openedInteractions':_0x3145f8,'maxInteractions':_0x2e9f8e,'virtual':_0x1029bb[_0xb984('0x105')],'online':_0x256b3d,'custom':_0x1029bb,'address':_0x2ba2fc?_0x461ab4:null}))[_0xb984('0x113')](/'/g,'\x5c\x27')};_0x5e7936[_0xb984('0x30')](ejs['render'](Mustache[_0xb984('0xd8')](_0x5eee58,_0x384873),{'proactiveActions':_0x31c9a1,'alignment':_0x2ad62e[_0xb984('0x114')],'verticalAlignment':_0x2ad62e['verticalAlignment'],'div_color':_0x2ad62e[_0xb984('0x115')],'labelText':_0x2ad62e[_0xb984('0x116')],'text_color':_0x2ad62e[_0xb984('0x117')],'text_button_color':_0x2ad62e[_0xb984('0x118')],'button_color':_0x2ad62e['color_button'],'background_color':_0x2ad62e[_0xb984('0x119')],'hideWhenOffline':_0x2ad62e['hideWhenOffline'],'intervalId':_0x2ad62e[_0xb984('0x11a')],'isDevelopment':_0x22d584,'chatVersion':_0xb5c49f}));})['catch'](handleError(_0x5e7936,null));};exports['addApplications']=function(_0x3338a3,_0x4a7169){var _0xce8465=_0x3338a3[_0xb984('0x65')]['id'];var _0x1c3ccd=_0x3338a3['body'];var _0x1a70dc=0xc8;var _0x23fea7=null;return db['sequelize'][_0xb984('0xe3')]({'isolationLevel':db['sequelize']['Transaction'][_0xb984('0x11b')]['READ_COMMITTED']},function(_0x3c82be){return db['ChatWebsite'][_0xb984('0x7e')]({'where':{'id':_0xce8465},'transaction':_0x3c82be})[_0xb984('0x16')](function(_0x464eae){if(_0x464eae){return db['ChatApplication'][_0xb984('0x2a')]({'where':{'ChatWebsiteId':_0xce8465},'transaction':_0x3c82be})['then'](function(){var _0x3cd674=_[_0xb984('0x4a')](_0x1c3ccd,function(_0x3d961f){_0x3d961f['ChatWebsiteId']=_0xce8465;return _0x3d961f;});return db[_0xb984('0xa9')]['bulkCreate'](_0x3cd674,{'transaction':_0x3c82be});});}else{_0x1a70dc=0x194;_0x23fea7=[];}});})[_0xb984('0x16')](function(){if(_0x1a70dc!==0x194){return db[_0xb984('0xa9')][_0xb984('0x11c')]({'where':{'ChatWebsiteId':_0xce8465},'order':_0xb984('0xb1')})['then'](function(_0x1c19a7){_0x23fea7=_0x1c19a7;});}})[_0xb984('0x20')](function(_0x14478c){_0x1a70dc=0x1f4;logger[_0xb984('0x1c')](_0x14478c['stack']);if(_0x14478c[_0xb984('0x2f')]){delete _0x14478c[_0xb984('0x2f')];}_0x23fea7=_0x14478c;})[_0xb984('0x11d')](function(){if(_0x23fea7===null){_0x4a7169[_0xb984('0x21')](_0x1a70dc);}else{if(_0x1a70dc===0x1f4){_0x4a7169[_0xb984('0x22')](_0x1a70dc)[_0xb984('0x30')](_0x23fea7);}else{_0x4a7169[_0xb984('0x22')](_0x1a70dc)[_0xb984('0x24')](_0x23fea7);}}});};exports[_0xb984('0x11e')]=function(_0x5a2758,_0x1ac027){var _0x577d83={};var _0x2699c3={};var _0x4c59eb;var _0x5ea724;return db[_0xb984('0x4b')]['findOne']({'where':{'id':_0x5a2758[_0xb984('0x65')]['id']}})['then'](handleEntityNotFound(_0x1ac027,null))[_0xb984('0x16')](function(_0x224023){if(_0x224023){_0x4c59eb=_0x224023;_0x2699c3['model']=_['keys'](db[_0xb984('0xa9')]['rawAttributes']);_0x2699c3[_0xb984('0x4f')]=_['keys'](_0x5a2758[_0xb984('0x4f')]);_0x2699c3['filters']=_[_0xb984('0x52')](_0x2699c3[_0xb984('0x42')],_0x2699c3[_0xb984('0x4f')]);_0x577d83[_0xb984('0x53')]=_[_0xb984('0x52')](_0x2699c3[_0xb984('0x42')],qs[_0xb984('0x54')](_0x5a2758[_0xb984('0x4f')]['fields']));_0x577d83[_0xb984('0x53')]=_0x577d83[_0xb984('0x53')][_0xb984('0x55')]?_0x577d83[_0xb984('0x53')]:_0x2699c3[_0xb984('0x42')];_0x577d83[_0xb984('0x58')]=qs[_0xb984('0x59')](_0x5a2758[_0xb984('0x4f')][_0xb984('0x59')]);_0x577d83[_0xb984('0x5a')]=qs[_0xb984('0x51')](_[_0xb984('0x5b')](_0x5a2758['query'],_0x2699c3['filters']));if(_0x5a2758[_0xb984('0x4f')][_0xb984('0x5c')]){_0x577d83[_0xb984('0x5a')]=_[_0xb984('0x5d')](_0x577d83[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x577d83[_0xb984('0x53')],function(_0xbb1af1){var _0x3d6db4={};_0x3d6db4[_0xbb1af1]={'$like':'%'+_0x5a2758['query'][_0xb984('0x5c')]+'%'};return _0x3d6db4;})});}_0x577d83=_[_0xb984('0x5d')]({},_0x577d83,_0x5a2758['options']);return _0x4c59eb[_0xb984('0x11e')](_0x577d83);}})[_0xb984('0x16')](function(_0x1e3555){if(_0x1e3555){_0x5ea724=_0x1e3555[_0xb984('0x55')];if(!_0x5a2758[_0xb984('0x4f')][_0xb984('0x79')](_0xb984('0x56'))){_0x577d83[_0xb984('0x26')]=qs[_0xb984('0x26')](_0x5a2758[_0xb984('0x4f')][_0xb984('0x26')]);_0x577d83[_0xb984('0x57')]=qs[_0xb984('0x57')](_0x5a2758[_0xb984('0x4f')]['offset']);}return _0x4c59eb[_0xb984('0x11e')](_0x577d83);}})['then'](function(_0x45ad9f){if(_0x45ad9f){return _0x45ad9f?{'count':_0x5ea724,'rows':_0x45ad9f}:null;}})[_0xb984('0x16')](respondWithResult(_0x1ac027,null))['catch'](handleError(_0x1ac027,null));};exports['addProactiveActions']=function(_0x10965f,_0x496396){return db[_0xb984('0x11f')]['find']({'where':{'id':_0x10965f[_0xb984('0x65')]['id']}})['then'](handleEntityNotFound(_0x496396,null))[_0xb984('0x16')](function(_0x4a498d){if(_0x4a498d){return _0x4a498d['addProactiveActions'](_0x10965f[_0xb984('0x6c')][_0xb984('0x80')],_[_0xb984('0xf9')](_0x10965f['body'],[_0xb984('0x80'),'id'])||{});}})[_0xb984('0x16')](respondWithResult(_0x496396,null))[_0xb984('0x20')](handleError(_0x496396,null));};exports[_0xb984('0x104')]=function(_0x509927,_0x2f477e){var _0x5efa1e={};var _0x1220f4={};var _0x4ac8a9;var _0x215b05;return db[_0xb984('0x4b')][_0xb984('0x7e')]({'where':{'id':_0x509927[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x2f477e,null))['then'](function(_0x83930f){if(_0x83930f){_0x4ac8a9=_0x83930f;_0x1220f4[_0xb984('0x42')]=_[_0xb984('0x50')](db[_0xb984('0x120')][_0xb984('0x4c')]);_0x1220f4[_0xb984('0x4f')]=_['keys'](_0x509927[_0xb984('0x4f')]);_0x1220f4[_0xb984('0x51')]=_[_0xb984('0x52')](_0x1220f4['model'],_0x1220f4['query']);_0x5efa1e[_0xb984('0x53')]=_[_0xb984('0x52')](_0x1220f4['model'],qs[_0xb984('0x54')](_0x509927['query'][_0xb984('0x54')]));_0x5efa1e['attributes']=_0x5efa1e[_0xb984('0x53')][_0xb984('0x55')]?_0x5efa1e[_0xb984('0x53')]:_0x1220f4[_0xb984('0x42')];_0x5efa1e[_0xb984('0x58')]=qs['sort'](_0x509927['query'][_0xb984('0x59')]);_0x5efa1e[_0xb984('0x5a')]=qs['filters'](_[_0xb984('0x5b')](_0x509927[_0xb984('0x4f')],_0x1220f4[_0xb984('0x51')]));if(_0x509927[_0xb984('0x4f')]['filter']){_0x5efa1e[_0xb984('0x5a')]=_[_0xb984('0x5d')](_0x5efa1e[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x5efa1e[_0xb984('0x53')],function(_0x53dfd7){var _0x2b4b04={};_0x2b4b04[_0x53dfd7]={'$like':'%'+_0x509927[_0xb984('0x4f')][_0xb984('0x5c')]+'%'};return _0x2b4b04;})});}_0x5efa1e=_[_0xb984('0x5d')]({},_0x5efa1e,_0x509927[_0xb984('0x5f')]);return _0x4ac8a9[_0xb984('0x104')](_0x5efa1e);}})[_0xb984('0x16')](function(_0x17de2f){if(_0x17de2f){_0x215b05=_0x17de2f[_0xb984('0x55')];if(!_0x509927[_0xb984('0x4f')][_0xb984('0x79')](_0xb984('0x56'))){_0x5efa1e['limit']=qs['limit'](_0x509927[_0xb984('0x4f')]['limit']);_0x5efa1e[_0xb984('0x57')]=qs['offset'](_0x509927['query']['offset']);}return _0x4ac8a9[_0xb984('0x104')](_0x5efa1e);}})[_0xb984('0x16')](function(_0x3fdc7d){if(_0x3fdc7d){return _0x3fdc7d?{'count':_0x215b05,'rows':_0x3fdc7d}:null;}})[_0xb984('0x16')](respondWithResult(_0x2f477e,null))[_0xb984('0x20')](handleError(_0x2f477e,null));};exports[_0xb984('0x121')]=function(_0x2e9d36,_0x3d7ae9){var _0x18b112=_0x2e9d36[_0xb984('0x4f')][_0xb984('0x122')]===_0xb984('0x123')?_0xb984('0x124'):_0xb984('0x125');return db[_0xb984('0x4b')][_0xb984('0x66')]({'attributes':['id',_0x18b112],'where':{'id':_0x2e9d36[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x3d7ae9,null))[_0xb984('0x16')](function(_0x2f4779){if(_0x2f4779){var _0xd81de1=_0x2f4779[_0x18b112];var _0x1f98a1=_0xd81de1&&_0xd81de1[_0xb984('0x126')]?_0xd81de1[_0xb984('0x126')]:[];_0x3d7ae9[_0xb984('0x30')]({'fromKey':_[_0xb984('0x91')](_0xd81de1['fromKey'])?undefined:_0xd81de1['fromKey'],'count':_0x1f98a1['length'],'rows':_0x1f98a1});}})[_0xb984('0x20')](handleError(_0x3d7ae9,null));};exports[_0xb984('0x127')]=function(_0x14a46c,_0x464919){var _0x3e80f5={'raw':![],'where':{}};var _0x20c8c5={};var _0x362f2a={'count':0x0,'rows':[]};return db[_0xb984('0x4b')][_0xb984('0x7e')]({'where':{'id':_0x14a46c[_0xb984('0x65')]['id']}})['then'](handleEntityNotFound(_0x464919,null))['then'](function(_0x427a6e){if(_0x427a6e){_0x20c8c5[_0xb984('0x42')]=_[_0xb984('0x50')](db[_0xb984('0x128')][_0xb984('0x4c')]);_0x20c8c5['query']=_['keys'](_0x14a46c[_0xb984('0x4f')]);_0x20c8c5[_0xb984('0x51')]=_[_0xb984('0x52')](_0x20c8c5[_0xb984('0x42')],_0x20c8c5[_0xb984('0x4f')]);_0x3e80f5[_0xb984('0x53')]=_[_0xb984('0x52')](_0x20c8c5[_0xb984('0x42')],qs[_0xb984('0x54')](_0x14a46c[_0xb984('0x4f')]['fields']));_0x3e80f5[_0xb984('0x53')]=_0x3e80f5[_0xb984('0x53')][_0xb984('0x55')]?_0x3e80f5[_0xb984('0x53')]:_0x20c8c5[_0xb984('0x42')];if(!_0x14a46c['query'][_0xb984('0x79')]('nolimit')){_0x3e80f5[_0xb984('0x26')]=qs[_0xb984('0x26')](_0x14a46c[_0xb984('0x4f')][_0xb984('0x26')]);_0x3e80f5[_0xb984('0x57')]=qs[_0xb984('0x57')](_0x14a46c[_0xb984('0x4f')][_0xb984('0x57')]);}_0x3e80f5[_0xb984('0x58')]=qs[_0xb984('0x59')](_0x14a46c[_0xb984('0x4f')][_0xb984('0x59')]);_0x3e80f5[_0xb984('0x5a')]=qs[_0xb984('0x51')](_['pick'](_0x14a46c['query'],_0x20c8c5[_0xb984('0x51')]));_0x3e80f5[_0xb984('0x5a')][_0xb984('0x76')]=_0x427a6e['id'];if(_0x14a46c[_0xb984('0x4f')][_0xb984('0x5c')]){_0x3e80f5[_0xb984('0x5a')]=_[_0xb984('0x5d')](_0x3e80f5[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x3e80f5[_0xb984('0x53')],function(_0x501d65){var _0x38f917={};_0x38f917[_0x501d65]={'$like':'%'+_0x14a46c[_0xb984('0x4f')][_0xb984('0x5c')]+'%'};return _0x38f917;})});}_0x3e80f5=_[_0xb984('0x5d')]({},_0x3e80f5,_0x14a46c[_0xb984('0x5f')]);return db[_0xb984('0x128')][_0xb984('0x27')]({'where':_0x3e80f5['where']})[_0xb984('0x16')](function(_0x3a1c1c){_0x362f2a[_0xb984('0x27')]=_0x3a1c1c;if(_0x14a46c[_0xb984('0x4f')][_0xb984('0x60')]){_0x3e80f5[_0xb984('0x61')]=[{'all':!![]}];}else{_0x3e80f5[_0xb984('0x61')]=[{'model':db[_0xb984('0xb5')],'as':'Contact','required':![]},{'model':db[_0xb984('0xe4')],'as':_0xb984('0x129'),'required':![]}];}return db[_0xb984('0x128')]['findAll'](_0x3e80f5);})[_0xb984('0x16')](function(_0x5735ed){_0x362f2a[_0xb984('0x63')]=_0x5735ed;return _0x362f2a;});}})[_0xb984('0x16')](respondWithFilteredResult(_0x464919,_0x3e80f5))[_0xb984('0x20')](handleError(_0x464919,null));};exports[_0xb984('0x12a')]=function(_0x108963,_0x294cb9){return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x108963[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x294cb9,null))['then'](function(_0x72bcf8){if(_0x72bcf8){return _0x72bcf8[_0xb984('0x12a')](_0x108963[_0xb984('0x6c')][_0xb984('0x80')],_[_0xb984('0xf9')](_0x108963['body'],['ids','id'])||{})[_0xb984('0xd6')](function(_0x496fbb){for(var _0x7b3434=0x0;_0x7b3434<_0x108963[_0xb984('0x6c')][_0xb984('0x80')][_0xb984('0x55')];_0x7b3434+=0x1){socket[_0xb984('0x12b')](_0xb984('0x12c'),{'UserId':Number(_0x108963['body']['ids'][_0x7b3434]),'ChatWebsiteId':Number(_0x108963[_0xb984('0x65')]['id'])});}return _0x496fbb;});}})[_0xb984('0x16')](respondWithResult(_0x294cb9,null))[_0xb984('0x20')](handleError(_0x294cb9,null));};exports['removeAgents']=function(_0xcc9c8e,_0x24bac4){return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0xcc9c8e['params']['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x24bac4,null))[_0xb984('0x16')](function(_0x16f05e){if(_0x16f05e){return _0x16f05e[_0xb984('0x12d')](_0xcc9c8e[_0xb984('0x4f')][_0xb984('0x80')])[_0xb984('0x16')](function(){if(_[_0xb984('0x12e')](_0xcc9c8e[_0xb984('0x4f')][_0xb984('0x80')])){for(var _0x2e99bc=0x0;_0x2e99bc<_0xcc9c8e[_0xb984('0x4f')][_0xb984('0x80')][_0xb984('0x55')];_0x2e99bc+=0x1){socket[_0xb984('0x12b')]('userChatWebsite:remove',{'UserId':Number(_0xcc9c8e[_0xb984('0x4f')][_0xb984('0x80')][_0x2e99bc]),'ChatWebsiteId':Number(_0xcc9c8e['params']['id'])});}}else{socket[_0xb984('0x12b')](_0xb984('0x12f'),{'UserId':Number(_0xcc9c8e[_0xb984('0x4f')][_0xb984('0x80')]),'ChatWebsiteId':Number(_0xcc9c8e[_0xb984('0x65')]['id'])});}});}})[_0xb984('0x16')](respondWithStatusCode(_0x24bac4,null))[_0xb984('0x20')](handleError(_0x24bac4,null));};exports['getAgents']=function(_0x314eac,_0x19fcd0){var _0x573a4c={};var _0xbed419={};var _0x24787b;var _0x30484e;return db['ChatWebsite'][_0xb984('0x7e')]({'where':{'id':_0x314eac[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x19fcd0,null))[_0xb984('0x16')](function(_0x5ba451){if(_0x5ba451){_0x24787b=_0x5ba451;_0xbed419[_0xb984('0x42')]=_[_0xb984('0x50')](db[_0xb984('0xfc')][_0xb984('0x4c')]);_0xbed419[_0xb984('0x4f')]=_[_0xb984('0x50')](_0x314eac[_0xb984('0x4f')]);_0xbed419[_0xb984('0x51')]=_[_0xb984('0x52')](_0xbed419[_0xb984('0x42')],_0xbed419['query']);_0x573a4c[_0xb984('0x53')]=_['intersection'](_0xbed419[_0xb984('0x42')],qs[_0xb984('0x54')](_0x314eac[_0xb984('0x4f')][_0xb984('0x54')]));_0x573a4c[_0xb984('0x53')]=_0x573a4c[_0xb984('0x53')][_0xb984('0x55')]?_0x573a4c[_0xb984('0x53')]:_0xbed419[_0xb984('0x42')];_0x573a4c[_0xb984('0x58')]=qs[_0xb984('0x59')](_0x314eac[_0xb984('0x4f')][_0xb984('0x59')]);_0x573a4c['where']=qs[_0xb984('0x51')](_['pick'](_0x314eac[_0xb984('0x4f')],_0xbed419['filters']));if(_0x314eac[_0xb984('0x4f')]['filter']){_0x573a4c[_0xb984('0x5a')]=_[_0xb984('0x5d')](_0x573a4c[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x573a4c[_0xb984('0x53')],function(_0x2a212a){var _0x36dfa1={};_0x36dfa1[_0x2a212a]={'$like':'%'+_0x314eac[_0xb984('0x4f')][_0xb984('0x5c')]+'%'};return _0x36dfa1;})});}_0x573a4c=_['merge']({},_0x573a4c,_0x314eac['options']);return _0x24787b[_0xb984('0x130')](_0x573a4c);}})[_0xb984('0x16')](function(_0x4bd4cc){if(_0x4bd4cc){_0x30484e=_0x4bd4cc[_0xb984('0x55')];if(!_0x314eac[_0xb984('0x4f')][_0xb984('0x79')](_0xb984('0x56'))){_0x573a4c[_0xb984('0x26')]=qs[_0xb984('0x26')](_0x314eac['query'][_0xb984('0x26')]);_0x573a4c[_0xb984('0x57')]=qs[_0xb984('0x57')](_0x314eac[_0xb984('0x4f')][_0xb984('0x57')]);}return _0x24787b[_0xb984('0x130')](_0x573a4c);}})['then'](function(_0x54cbef){if(_0x54cbef){return _0x54cbef?{'count':_0x30484e,'rows':_0x54cbef}:null;}})[_0xb984('0x16')](respondWithResult(_0x19fcd0,null))[_0xb984('0x20')](handleError(_0x19fcd0,null));};
\ No newline at end of file