Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index fe9bd07..1f97e41 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2e8f=['addCustomerAvatar','systemAvatar','getLogo','server/files/images/logos/default_logo.svg','getLicense','custom','isNil','existsSync','join','root','server/files/images/logos/','download','getAvatar','agentAvatar','server/files/images/avatars/','customerAvatar','showCustomerAvatar','notify','setUA','headers','user-agent','getResult','chat','CmContact','Sequelize','no\x20available\x20attributes','difference','createdAt','updatedAt','ListId','from','ValidationError','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','DESC','Applications','account','applications','list','orderBy','priority','asc','customerIp','cf-connecting-ip','x-forwarded-for','split','lastName','x-real-port','referer','browser','version','%s\x20%s','unknown','device','vendor','format','%s\x20%s\x20%s','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','contact','messageId','created','autoclose','push','close','*,*,*,*','ChatMessage','AttachmentId','UserId','User','unshift','agent','forcedOwnership','Start','startRouting','files','CompanyId','send','from\x20is\x20mandatory','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','toPairs','offlineMessageBody','ChatOfflineMessage','attachments','offline-chat','basename','openNewInteraction','sequelize','transaction','Attachment','bulkCreate','MailServerOut','Smtp','forwardOffline','forwardOfflineAddress','service','host','secure','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','mimetype','subjectOffline','toPairsIn','mapValues','NotifyMailAccount','remove','addInteraction','ids','omit','getInteractions','Contact','Owner','fullname','internal','Tag','Tags','tag','Command','timezone','iftime\x20%s,%s','interval','iftime\x20%s','indexOf','true','ONLINE','No\x20timezone','inspect','getSnippet','Interval','Intervals','getProactiveActions','virtual','License','increment','all','some','remote','remoteAddress','replace','alignment','verticalAlignment','color','textColor','color_button','addApplications','ChatApplication','findAndCountAll','getApplications','addProactiveActions','chatProactiveAction','ChatProactiveAction','getFields','online','false','offlineForm','items','fromKey','getOfflineMessages','Attachments','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','eml-format','rimraf','zip-dir','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','squel','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/environment','../../config/license/util','redis','client','http','request','then','info','ChatWebsite,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','result','catch','sendStatus','status','json','offset','undefined','limit','count','Content-Range','apply','reject','save','update','destroy','UserProfileResource','end','stack','name','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','fieldName','type','key','keys','filters','model','attributes','intersection','fields','query','length','nolimit','sort','where','merge','VIRTUAL','filter','includeAll','include','findAll','show','find','create','body','user','get','ChatWebsites','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','Disposition','findOne','hasOwnProperty','order','pick','removeDispositions','addAnswer','ChatWebsiteId','CannedAnswer','options','rows','removeAnswers','sitepic','file','filename'];(function(_0x40b7ea,_0x550490){var _0x2627ec=function(_0x78fd8e){while(--_0x78fd8e){_0x40b7ea['push'](_0x40b7ea['shift']());}};_0x2627ec(++_0x550490);}(_0x2e8f,0x1de));var _0xf2e8=function(_0x5cb97e,_0x132a39){_0x5cb97e=_0x5cb97e-0x0;var _0x1714b4=_0x2e8f[_0x5cb97e];return _0x1714b4;};'use strict';var emlformat=require(_0xf2e8('0x0'));var rimraf=require(_0xf2e8('0x1'));var zipdir=require(_0xf2e8('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xf2e8('0x3'));var BPromise=require(_0xf2e8('0x4'));var Mustache=require('mustache');var util=require(_0xf2e8('0x5'));var path=require(_0xf2e8('0x6'));var sox=require(_0xf2e8('0x7'));var csv=require(_0xf2e8('0x8'));var ejs=require(_0xf2e8('0x9'));var fs=require('fs');var fs_extra=require(_0xf2e8('0xa'));var _=require('lodash');var squel=require(_0xf2e8('0xb'));var crypto=require('crypto');var jsforce=require(_0xf2e8('0xc'));var deskjs=require(_0xf2e8('0xd'));var toCsv=require(_0xf2e8('0x8'));var querystring=require('querystring');var Papa=require(_0xf2e8('0xe'));var Redis=require('ioredis');var authService=require(_0xf2e8('0xf'));var qs=require(_0xf2e8('0x10'));var as=require(_0xf2e8('0x11'));var hardwareService=require(_0xf2e8('0x12'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0xf2e8('0x13'));var licenseUtil=require(_0xf2e8('0x14'));var db=require('../../mysqldb')['db'];config['redis']=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf2e8('0x15')]));require('./chatWebsite.socket')['register'](socket);var jayson=require('jayson/promise');var client=jayson[_0xf2e8('0x16')][_0xf2e8('0x17')]({'port':0x232c});var client9002=jayson['client']['http']({'port':0x232a});var client9003=jayson[_0xf2e8('0x16')]['http']({'port':0x232b});var client9001=jayson[_0xf2e8('0x16')]['http']({'port':0x2329});function respondWithRpcPromise(_0x4eeae9,_0x130bdd,_0x135113,_0x447c55){return new BPromise(function(_0x4fc12d,_0x866553){var _0x15dc3c=_0x447c55||client;return _0x15dc3c[_0xf2e8('0x18')](_0x4eeae9,_0x135113)[_0xf2e8('0x19')](function(_0x1a3530){logger[_0xf2e8('0x1a')](_0xf2e8('0x1b'),_0x130bdd,'request\x20sent');logger['debug']('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x130bdd,'request\x20sent',JSON[_0xf2e8('0x1c')](_0x1a3530));if(_0x1a3530[_0xf2e8('0x1d')]){if(_0x1a3530['error'][_0xf2e8('0x1e')]===0x1f4){logger[_0xf2e8('0x1d')](_0xf2e8('0x1b'),_0x130bdd,_0x1a3530[_0xf2e8('0x1d')][_0xf2e8('0x1f')]);return _0x866553(_0x1a3530[_0xf2e8('0x1d')][_0xf2e8('0x1f')]);}logger['error'](_0xf2e8('0x1b'),_0x130bdd,_0x1a3530[_0xf2e8('0x1d')][_0xf2e8('0x1f')]);return _0x4fc12d(_0x1a3530['error'][_0xf2e8('0x1f')]);}else{logger[_0xf2e8('0x1a')](_0xf2e8('0x1b'),_0x130bdd,_0xf2e8('0x20'));_0x4fc12d(_0x1a3530[_0xf2e8('0x21')]['message']);}})[_0xf2e8('0x22')](function(_0x2fe3bc){logger[_0xf2e8('0x1d')]('ChatWebsite,\x20%s,\x20%s',_0x130bdd,_0x2fe3bc);_0x866553(_0x2fe3bc);});});}function respondWithStatusCode(_0x5204b1,_0x2be4d5){_0x2be4d5=_0x2be4d5||0xcc;return function(_0x12f313){if(_0x12f313){return _0x5204b1[_0xf2e8('0x23')](_0x2be4d5);}return _0x5204b1[_0xf2e8('0x24')](_0x2be4d5)['end']();};}function respondWithResult(_0x49f730,_0x27094a){_0x27094a=_0x27094a||0xc8;return function(_0x4b984e){if(_0x4b984e){return _0x49f730[_0xf2e8('0x24')](_0x27094a)[_0xf2e8('0x25')](_0x4b984e);}};}function respondWithFilteredResult(_0x2c20d1,_0x58bd24){return function(_0x11b3a2){if(_0x11b3a2){var _0x28b321=typeof _0x58bd24[_0xf2e8('0x26')]===_0xf2e8('0x27')&&typeof _0x58bd24[_0xf2e8('0x28')]===_0xf2e8('0x27');var _0x3ba10f=_0x11b3a2[_0xf2e8('0x29')];var _0x5e9460=_0x28b321?0x0:_0x58bd24[_0xf2e8('0x26')];var _0x13b10c=_0x28b321?_0x11b3a2[_0xf2e8('0x29')]:_0x58bd24[_0xf2e8('0x26')]+_0x58bd24['limit'];var _0x3f8c5d;if(_0x13b10c>=_0x3ba10f){_0x13b10c=_0x3ba10f;_0x3f8c5d=0xc8;}else{_0x3f8c5d=0xce;}_0x2c20d1[_0xf2e8('0x24')](_0x3f8c5d);return _0x2c20d1['set'](_0xf2e8('0x2a'),_0x5e9460+'-'+_0x13b10c+'/'+_0x3ba10f)[_0xf2e8('0x25')](_0x11b3a2);}return null;};}function patchUpdates(_0x4af5e0){return function(_0x4d3a28){try{jsonpatch[_0xf2e8('0x2b')](_0x4d3a28,_0x4af5e0,!![]);}catch(_0x21a49){return BPromise[_0xf2e8('0x2c')](_0x21a49);}return _0x4d3a28[_0xf2e8('0x2d')]();};}function saveUpdates(_0x28064a,_0x30846d){return function(_0x26299d){if(_0x26299d){return _0x26299d[_0xf2e8('0x2e')](_0x28064a)[_0xf2e8('0x19')](function(_0x5612cd){return _0x5612cd;});}return null;};}function removeEntity(_0x461bd5,_0x2fa168){return function(_0x3b13b4){if(_0x3b13b4){return _0x3b13b4[_0xf2e8('0x2f')]()[_0xf2e8('0x19')](function(){var _0x2dfe0d=_0x3b13b4['get']({'plain':!![]});var _0x436d5a='ChatWebsites';return db[_0xf2e8('0x30')][_0xf2e8('0x2f')]({'where':{'type':_0x436d5a,'resourceId':_0x2dfe0d['id']}})[_0xf2e8('0x19')](function(){return _0x3b13b4;});})['then'](function(){_0x461bd5['status'](0xcc)[_0xf2e8('0x31')]();});}};}function handleEntityNotFound(_0x218d73,_0x5cd935){return function(_0x527cfe){if(!_0x527cfe){_0x218d73['sendStatus'](0x194);}return _0x527cfe;};}function handleError(_0x5a04c5,_0x46b4e3){_0x46b4e3=_0x46b4e3||0x1f4;return function(_0x4ba217){logger['error'](_0x4ba217[_0xf2e8('0x32')]);if(_0x4ba217[_0xf2e8('0x33')]){delete _0x4ba217['name'];}_0x5a04c5[_0xf2e8('0x24')](_0x46b4e3)['send'](_0x4ba217);};}exports['index']=function(_0x4a84a2,_0x21b49b){var _0x2fae0d={'include':[{'model':db[_0xf2e8('0x34')],'as':_0xf2e8('0x35')}]},_0xdf78c3={},_0x5f59bf={'count':0x0,'rows':[]};var _0x444446=_[_0xf2e8('0x36')](db[_0xf2e8('0x37')][_0xf2e8('0x38')],function(_0x249c6e){return{'name':_0x249c6e[_0xf2e8('0x39')],'type':_0x249c6e[_0xf2e8('0x3a')][_0xf2e8('0x3b')]};});_0xdf78c3['model']=_[_0xf2e8('0x36')](_0x444446,_0xf2e8('0x33'));_0xdf78c3['query']=_[_0xf2e8('0x3c')](_0x4a84a2['query']);_0xdf78c3[_0xf2e8('0x3d')]=_['intersection'](_0xdf78c3[_0xf2e8('0x3e')],_0xdf78c3['query']);_0x2fae0d[_0xf2e8('0x3f')]=_[_0xf2e8('0x40')](_0xdf78c3[_0xf2e8('0x3e')],qs[_0xf2e8('0x41')](_0x4a84a2[_0xf2e8('0x42')][_0xf2e8('0x41')]));_0x2fae0d[_0xf2e8('0x3f')]=_0x2fae0d[_0xf2e8('0x3f')][_0xf2e8('0x43')]?_0x2fae0d[_0xf2e8('0x3f')]:_0xdf78c3[_0xf2e8('0x3e')];if(!_0x4a84a2[_0xf2e8('0x42')]['hasOwnProperty'](_0xf2e8('0x44'))){_0x2fae0d[_0xf2e8('0x28')]=qs['limit'](_0x4a84a2[_0xf2e8('0x42')][_0xf2e8('0x28')]);_0x2fae0d['offset']=qs['offset'](_0x4a84a2[_0xf2e8('0x42')][_0xf2e8('0x26')]);}_0x2fae0d['order']=qs[_0xf2e8('0x45')](_0x4a84a2[_0xf2e8('0x42')]['sort']);_0x2fae0d[_0xf2e8('0x46')]=qs[_0xf2e8('0x3d')](_['pick'](_0x4a84a2[_0xf2e8('0x42')],_0xdf78c3[_0xf2e8('0x3d')]),_0x444446);if(_0x4a84a2[_0xf2e8('0x42')]['filter']){_0x2fae0d['where']=_[_0xf2e8('0x47')](_0x2fae0d[_0xf2e8('0x46')],{'$or':_['map'](_0x444446,function(_0x3ae15d){if(_0x3ae15d[_0xf2e8('0x3a')]!==_0xf2e8('0x48')){var _0x42049d={};_0x42049d[_0x3ae15d[_0xf2e8('0x33')]]={'$like':'%'+_0x4a84a2['query'][_0xf2e8('0x49')]+'%'};return _0x42049d;}})});}_0x2fae0d=_['merge']({},_0x2fae0d,_0x4a84a2['options']);var _0x54039c={'where':_0x2fae0d[_0xf2e8('0x46')]};return db['ChatWebsite'][_0xf2e8('0x29')](_0x54039c)[_0xf2e8('0x19')](function(_0x5e0ecb){_0x5f59bf[_0xf2e8('0x29')]=_0x5e0ecb;if(_0x4a84a2[_0xf2e8('0x42')][_0xf2e8('0x4a')]){_0x2fae0d[_0xf2e8('0x4b')]=[{'all':!![]}];}return db[_0xf2e8('0x37')][_0xf2e8('0x4c')](_0x2fae0d);})[_0xf2e8('0x19')](function(_0x3277e2){_0x5f59bf['rows']=_0x3277e2;return _0x5f59bf;})['then'](respondWithFilteredResult(_0x21b49b,_0x2fae0d))['catch'](handleError(_0x21b49b,null));};exports[_0xf2e8('0x4d')]=function(_0x3c57a6,_0x33164a){var _0x369d85={'raw':![],'where':{'id':_0x3c57a6['params']['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x1cef8a={};_0x1cef8a[_0xf2e8('0x3e')]=_[_0xf2e8('0x3c')](db[_0xf2e8('0x37')][_0xf2e8('0x38')]);_0x1cef8a[_0xf2e8('0x42')]=_[_0xf2e8('0x3c')](_0x3c57a6[_0xf2e8('0x42')]);_0x1cef8a[_0xf2e8('0x3d')]=_[_0xf2e8('0x40')](_0x1cef8a[_0xf2e8('0x3e')],_0x1cef8a[_0xf2e8('0x42')]);_0x369d85[_0xf2e8('0x3f')]=_['intersection'](_0x1cef8a[_0xf2e8('0x3e')],qs[_0xf2e8('0x41')](_0x3c57a6[_0xf2e8('0x42')][_0xf2e8('0x41')]));_0x369d85[_0xf2e8('0x3f')]=_0x369d85[_0xf2e8('0x3f')][_0xf2e8('0x43')]?_0x369d85[_0xf2e8('0x3f')]:_0x1cef8a[_0xf2e8('0x3e')];if(_0x3c57a6['query'][_0xf2e8('0x4a')]){_0x369d85[_0xf2e8('0x4b')]=[{'all':!![]}];}_0x369d85=_[_0xf2e8('0x47')]({},_0x369d85,_0x3c57a6['options']);return db[_0xf2e8('0x37')][_0xf2e8('0x4e')](_0x369d85)[_0xf2e8('0x19')](handleEntityNotFound(_0x33164a,null))[_0xf2e8('0x19')](respondWithResult(_0x33164a,null))[_0xf2e8('0x22')](handleError(_0x33164a,null));};exports[_0xf2e8('0x4f')]=function(_0x18542d,_0x4d113a){return db['ChatWebsite']['create'](_0x18542d[_0xf2e8('0x50')],{})[_0xf2e8('0x19')](function(_0x3f7916){var _0x5864de=_0x18542d[_0xf2e8('0x51')]['get']({'plain':!![]});if(!_0x5864de)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x5864de['role']===_0xf2e8('0x51')){var _0x7e83fa=_0x3f7916[_0xf2e8('0x52')]({'plain':!![]});var _0x5d5b1d=_0xf2e8('0x53');return db[_0xf2e8('0x54')][_0xf2e8('0x4e')]({'where':{'name':_0x5d5b1d,'userProfileId':_0x5864de[_0xf2e8('0x55')]},'raw':!![]})[_0xf2e8('0x19')](function(_0x392bb9){if(_0x392bb9&&_0x392bb9['autoAssociation']===0x0){return db['UserProfileResource'][_0xf2e8('0x4f')]({'name':_0x7e83fa[_0xf2e8('0x33')],'resourceId':_0x7e83fa['id'],'type':_0x392bb9[_0xf2e8('0x33')],'sectionId':_0x392bb9['id']},{})[_0xf2e8('0x19')](function(){return _0x3f7916;});}else{return _0x3f7916;}})[_0xf2e8('0x22')](function(_0x116c38){logger[_0xf2e8('0x1d')](_0xf2e8('0x56'),_0x116c38);throw _0x116c38;});}return _0x3f7916;})[_0xf2e8('0x19')](respondWithResult(_0x4d113a,0xc9))['catch'](handleError(_0x4d113a,null));};exports[_0xf2e8('0x2e')]=function(_0x3d3a25,_0x236259){if(_0x3d3a25[_0xf2e8('0x50')]['id']){delete _0x3d3a25[_0xf2e8('0x50')]['id'];}return db[_0xf2e8('0x37')][_0xf2e8('0x4e')]({'where':{'id':_0x3d3a25['params']['id']},'include':[{'model':db[_0xf2e8('0x34')],'as':'mandatoryDispositionPause'}]})[_0xf2e8('0x19')](handleEntityNotFound(_0x236259,null))[_0xf2e8('0x19')](saveUpdates(_0x3d3a25[_0xf2e8('0x50')],null))[_0xf2e8('0x19')](respondWithResult(_0x236259,null))[_0xf2e8('0x22')](handleError(_0x236259,null));};exports[_0xf2e8('0x2f')]=function(_0x438225,_0x557b97){return db[_0xf2e8('0x37')][_0xf2e8('0x4e')]({'where':{'id':_0x438225[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x557b97,null))[_0xf2e8('0x19')](removeEntity(_0x557b97,null))[_0xf2e8('0x22')](handleError(_0x557b97,null));};exports[_0xf2e8('0x58')]=function(_0x2782ee,_0xdf708e){return db[_0xf2e8('0x37')]['describe']()[_0xf2e8('0x19')](respondWithResult(_0xdf708e,null))['catch'](handleError(_0xdf708e,null));};exports['addDisposition']=function(_0x384b05,_0x570d43,_0x370e9e){if(_0x384b05[_0xf2e8('0x50')]['id']){delete _0x384b05[_0xf2e8('0x50')]['id'];}return db[_0xf2e8('0x37')]['find']({'where':{'id':_0x384b05[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x570d43,null))['then'](function(_0x265802){if(_0x265802){_0x384b05[_0xf2e8('0x50')]['ChatWebsiteId']=_0x265802['id'];return db[_0xf2e8('0x59')][_0xf2e8('0x4f')](_0x384b05[_0xf2e8('0x50')]);}})[_0xf2e8('0x19')](respondWithResult(_0x570d43,null))[_0xf2e8('0x22')](handleError(_0x570d43,null));};exports['getDispositions']=function(_0x535295,_0x3a29d4,_0x3e022d){var _0xb2fd93={'raw':![],'where':{}};var _0x2731dd={};var _0x2cfe64={'count':0x0,'rows':[]};return db[_0xf2e8('0x37')][_0xf2e8('0x5a')]({'where':{'id':_0x535295['params']['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x3a29d4,null))[_0xf2e8('0x19')](function(_0x496ad5){if(_0x496ad5){_0x2731dd[_0xf2e8('0x3e')]=_['keys'](db[_0xf2e8('0x59')][_0xf2e8('0x38')]);_0x2731dd[_0xf2e8('0x42')]=_[_0xf2e8('0x3c')](_0x535295[_0xf2e8('0x42')]);_0x2731dd[_0xf2e8('0x3d')]=_[_0xf2e8('0x40')](_0x2731dd[_0xf2e8('0x3e')],_0x2731dd[_0xf2e8('0x42')]);_0xb2fd93[_0xf2e8('0x3f')]=_[_0xf2e8('0x40')](_0x2731dd[_0xf2e8('0x3e')],qs[_0xf2e8('0x41')](_0x535295[_0xf2e8('0x42')][_0xf2e8('0x41')]));_0xb2fd93['attributes']=_0xb2fd93[_0xf2e8('0x3f')][_0xf2e8('0x43')]?_0xb2fd93[_0xf2e8('0x3f')]:_0x2731dd[_0xf2e8('0x3e')];if(!_0x535295[_0xf2e8('0x42')][_0xf2e8('0x5b')](_0xf2e8('0x44'))){_0xb2fd93['limit']=qs[_0xf2e8('0x28')](_0x535295['query'][_0xf2e8('0x28')]);_0xb2fd93[_0xf2e8('0x26')]=qs[_0xf2e8('0x26')](_0x535295[_0xf2e8('0x42')][_0xf2e8('0x26')]);}_0xb2fd93[_0xf2e8('0x5c')]=qs[_0xf2e8('0x45')](_0x535295['query']['sort']);_0xb2fd93['where']=qs['filters'](_[_0xf2e8('0x5d')](_0x535295['query'],_0x2731dd[_0xf2e8('0x3d')]));_0xb2fd93[_0xf2e8('0x46')]['ChatWebsiteId']=_0x496ad5['id'];if(_0x535295[_0xf2e8('0x42')][_0xf2e8('0x49')]){_0xb2fd93['where']=_[_0xf2e8('0x47')](_0xb2fd93['where'],{'$or':_[_0xf2e8('0x36')](_0xb2fd93[_0xf2e8('0x3f')],function(_0x25e4bd){var _0x2b5779={};_0x2b5779[_0x25e4bd]={'$like':'%'+_0x535295[_0xf2e8('0x42')][_0xf2e8('0x49')]+'%'};return _0x2b5779;})});}_0xb2fd93=_[_0xf2e8('0x47')]({},_0xb2fd93,_0x535295['options']);return db[_0xf2e8('0x59')][_0xf2e8('0x29')]({'where':_0xb2fd93[_0xf2e8('0x46')]})['then'](function(_0x24b658){_0x2cfe64[_0xf2e8('0x29')]=_0x24b658;if(_0x535295['query']['includeAll']){_0xb2fd93[_0xf2e8('0x4b')]=[{'all':!![]}];}return db[_0xf2e8('0x59')][_0xf2e8('0x4c')](_0xb2fd93);})[_0xf2e8('0x19')](function(_0x55adc1){_0x2cfe64['rows']=_0x55adc1;return _0x2cfe64;});}})[_0xf2e8('0x19')](respondWithFilteredResult(_0x3a29d4,_0xb2fd93))[_0xf2e8('0x22')](handleError(_0x3a29d4,null));};exports[_0xf2e8('0x5e')]=function(_0x1cd2cc,_0x281dc6,_0x20ac2e){return db['ChatWebsite'][_0xf2e8('0x4e')]({'where':{'id':_0x1cd2cc[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x281dc6,null))['then'](function(_0x11d740){if(_0x11d740){return _0x11d740['removeDispositions'](_0x1cd2cc[_0xf2e8('0x42')]['ids']);}})[_0xf2e8('0x19')](respondWithStatusCode(_0x281dc6,null))['catch'](handleError(_0x281dc6,null));};exports[_0xf2e8('0x5f')]=function(_0x1e6199,_0x1bff08,_0x638780){if(_0x1e6199[_0xf2e8('0x50')]['id']){delete _0x1e6199[_0xf2e8('0x50')]['id'];}return db[_0xf2e8('0x37')][_0xf2e8('0x4e')]({'where':{'id':_0x1e6199['params']['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x1bff08,null))[_0xf2e8('0x19')](function(_0x1eda8b){if(_0x1eda8b){_0x1e6199['body'][_0xf2e8('0x60')]=_0x1eda8b['id'];return db[_0xf2e8('0x61')][_0xf2e8('0x4f')](_0x1e6199[_0xf2e8('0x50')]);}})['then'](respondWithResult(_0x1bff08,null))[_0xf2e8('0x22')](handleError(_0x1bff08,null));};exports['getAnswers']=function(_0x5b0924,_0x5e4a96,_0x5da9c5){var _0x2522b4={'raw':![],'where':{}};var _0x295013={};var _0x2f4594={'count':0x0,'rows':[]};return db[_0xf2e8('0x37')][_0xf2e8('0x5a')]({'where':{'id':_0x5b0924['params']['id']}})['then'](handleEntityNotFound(_0x5e4a96,null))[_0xf2e8('0x19')](function(_0xbab5b1){if(_0xbab5b1){_0x295013['model']=_[_0xf2e8('0x3c')](db[_0xf2e8('0x61')][_0xf2e8('0x38')]);_0x295013[_0xf2e8('0x42')]=_[_0xf2e8('0x3c')](_0x5b0924['query']);_0x295013[_0xf2e8('0x3d')]=_['intersection'](_0x295013[_0xf2e8('0x3e')],_0x295013[_0xf2e8('0x42')]);_0x2522b4['attributes']=_[_0xf2e8('0x40')](_0x295013[_0xf2e8('0x3e')],qs['fields'](_0x5b0924['query']['fields']));_0x2522b4[_0xf2e8('0x3f')]=_0x2522b4[_0xf2e8('0x3f')]['length']?_0x2522b4[_0xf2e8('0x3f')]:_0x295013[_0xf2e8('0x3e')];if(!_0x5b0924[_0xf2e8('0x42')]['hasOwnProperty'](_0xf2e8('0x44'))){_0x2522b4['limit']=qs[_0xf2e8('0x28')](_0x5b0924['query'][_0xf2e8('0x28')]);_0x2522b4[_0xf2e8('0x26')]=qs[_0xf2e8('0x26')](_0x5b0924[_0xf2e8('0x42')][_0xf2e8('0x26')]);}_0x2522b4[_0xf2e8('0x5c')]=qs['sort'](_0x5b0924[_0xf2e8('0x42')][_0xf2e8('0x45')]);_0x2522b4[_0xf2e8('0x46')]=qs['filters'](_[_0xf2e8('0x5d')](_0x5b0924[_0xf2e8('0x42')],_0x295013[_0xf2e8('0x3d')]));_0x2522b4[_0xf2e8('0x46')][_0xf2e8('0x60')]=_0xbab5b1['id'];if(_0x5b0924['query'][_0xf2e8('0x49')]){_0x2522b4[_0xf2e8('0x46')]=_[_0xf2e8('0x47')](_0x2522b4[_0xf2e8('0x46')],{'$or':_[_0xf2e8('0x36')](_0x2522b4[_0xf2e8('0x3f')],function(_0x473782){var _0x2bef76={};_0x2bef76[_0x473782]={'$like':'%'+_0x5b0924[_0xf2e8('0x42')][_0xf2e8('0x49')]+'%'};return _0x2bef76;})});}_0x2522b4=_[_0xf2e8('0x47')]({},_0x2522b4,_0x5b0924[_0xf2e8('0x62')]);return db['CannedAnswer'][_0xf2e8('0x29')]({'where':_0x2522b4[_0xf2e8('0x46')]})[_0xf2e8('0x19')](function(_0xd0087f){_0x2f4594[_0xf2e8('0x29')]=_0xd0087f;if(_0x5b0924[_0xf2e8('0x42')]['includeAll']){_0x2522b4[_0xf2e8('0x4b')]=[{'all':!![]}];}return db[_0xf2e8('0x61')]['findAll'](_0x2522b4);})[_0xf2e8('0x19')](function(_0x390658){_0x2f4594[_0xf2e8('0x63')]=_0x390658;return _0x2f4594;});}})['then'](respondWithFilteredResult(_0x5e4a96,_0x2522b4))['catch'](handleError(_0x5e4a96,null));};exports[_0xf2e8('0x64')]=function(_0x17ac41,_0x377e4e,_0x5de9d6){return db['ChatWebsite'][_0xf2e8('0x4e')]({'where':{'id':_0x17ac41[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x377e4e,null))['then'](function(_0x41a3f5){if(_0x41a3f5){return _0x41a3f5[_0xf2e8('0x64')](_0x17ac41['query']['ids']);}})[_0xf2e8('0x19')](respondWithStatusCode(_0x377e4e,null))[_0xf2e8('0x22')](handleError(_0x377e4e,null));};exports['addLogo']=function(_0x577a00,_0x275103,_0x33390d){_0x577a00[_0xf2e8('0x50')][_0xf2e8('0x65')]=_0x577a00[_0xf2e8('0x66')][_0xf2e8('0x67')];return db[_0xf2e8('0x37')][_0xf2e8('0x4e')]({'where':{'id':_0x577a00[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x275103,null))[_0xf2e8('0x19')](saveUpdates(_0x577a00['body'],null))['then'](respondWithResult(_0x275103,null))[_0xf2e8('0x22')](handleError(_0x275103,null));};exports['addAvatar']=function(_0x50bd90,_0x272bd0,_0x2e5002){_0x50bd90[_0xf2e8('0x50')]['agentAvatar']=_0x50bd90['file']['filename'];return db[_0xf2e8('0x37')][_0xf2e8('0x4e')]({'where':{'id':_0x50bd90[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x272bd0,null))['then'](saveUpdates(_0x50bd90[_0xf2e8('0x50')],null))['then'](respondWithResult(_0x272bd0,null))[_0xf2e8('0x22')](handleError(_0x272bd0,null));};exports[_0xf2e8('0x68')]=function(_0x2af46d,_0x2d4802,_0x2fb12d){_0x2af46d['body']['customerAvatar']=_0x2af46d[_0xf2e8('0x66')][_0xf2e8('0x67')];return db[_0xf2e8('0x37')][_0xf2e8('0x4e')]({'where':{'id':_0x2af46d[_0xf2e8('0x57')]['id']}})['then'](handleEntityNotFound(_0x2d4802,null))['then'](saveUpdates(_0x2af46d[_0xf2e8('0x50')],null))['then'](respondWithResult(_0x2d4802,null))[_0xf2e8('0x22')](handleError(_0x2d4802,null));};exports['addSystemAvatar']=function(_0x468d4e,_0x1c587b,_0x55ec5b){_0x468d4e[_0xf2e8('0x50')][_0xf2e8('0x69')]=_0x468d4e['file'][_0xf2e8('0x67')];return db['ChatWebsite'][_0xf2e8('0x4e')]({'where':{'id':_0x468d4e[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x1c587b,null))[_0xf2e8('0x19')](saveUpdates(_0x468d4e[_0xf2e8('0x50')],null))['then'](respondWithResult(_0x1c587b,null))['catch'](handleError(_0x1c587b,null));};exports[_0xf2e8('0x6a')]=function(_0x534cb8,_0x1533e8,_0x408df8){var _0x50e9f5=path['join'](config['root'],_0xf2e8('0x6b'));var _0x387414={'where':{'id':_0x534cb8[_0xf2e8('0x57')]['id']},'attributes':['id',_0xf2e8('0x65')],'raw':!![]};var _0x39bbff=![];return require(_0xf2e8('0x14'))[_0xf2e8('0x6c')]()[_0xf2e8('0x19')](function(_0x3fa8dd){if(_0x3fa8dd){_0x39bbff=_0x3fa8dd[_0xf2e8('0x6d')];}})[_0xf2e8('0x19')](function(){return db[_0xf2e8('0x37')][_0xf2e8('0x4e')](_0x387414);})[_0xf2e8('0x19')](handleEntityNotFound(_0x1533e8,null))[_0xf2e8('0x19')](function(_0x3b3acc){if(_0x3b3acc){if(!_[_0xf2e8('0x6e')](_0x3b3acc[_0xf2e8('0x65')])){if(fs[_0xf2e8('0x6f')](path[_0xf2e8('0x70')](config[_0xf2e8('0x71')],_0xf2e8('0x72'),_0x3b3acc[_0xf2e8('0x65')]))&&_0x39bbff){_0x50e9f5=path[_0xf2e8('0x70')](config[_0xf2e8('0x71')],'server/files/images/logos/',_0x3b3acc[_0xf2e8('0x65')]);}}return _0x1533e8[_0xf2e8('0x73')](_0x50e9f5);}})[_0xf2e8('0x22')](handleError(_0x1533e8,null));};exports[_0xf2e8('0x74')]=function(_0x5d5e34,_0x16b796,_0x10f04a){var _0x31f8c6=path[_0xf2e8('0x70')](config[_0xf2e8('0x71')],'server/files/images/avatars/default_avatar.png');var _0x26dbd1={'where':{'id':_0x5d5e34[_0xf2e8('0x57')]['id']},'attributes':['id',_0xf2e8('0x75')],'raw':!![]};return db[_0xf2e8('0x37')][_0xf2e8('0x4e')](_0x26dbd1)[_0xf2e8('0x19')](handleEntityNotFound(_0x16b796,null))[_0xf2e8('0x19')](function(_0x3b06e9){if(_0x3b06e9){if(!_[_0xf2e8('0x6e')](_0x3b06e9[_0xf2e8('0x75')])){if(fs[_0xf2e8('0x6f')](path['join'](config[_0xf2e8('0x71')],_0xf2e8('0x76'),_0x3b06e9['agentAvatar']))){_0x31f8c6=path[_0xf2e8('0x70')](config[_0xf2e8('0x71')],_0xf2e8('0x76'),_0x3b06e9[_0xf2e8('0x75')]);}}return _0x16b796[_0xf2e8('0x73')](_0x31f8c6);}})[_0xf2e8('0x22')](handleError(_0x16b796,null));};exports['getCustomerAvatar']=function(_0x4753f0,_0x4c0472,_0x157356){var _0x1e8d90=path[_0xf2e8('0x70')](config[_0xf2e8('0x71')],'server/files/images/avatars/customer_avatar.png');var _0xa57014={'where':{'id':_0x4753f0['params']['id']},'attributes':['id',_0xf2e8('0x77'),_0xf2e8('0x78')],'raw':!![]};return db['ChatWebsite']['find'](_0xa57014)['then'](handleEntityNotFound(_0x4c0472,null))[_0xf2e8('0x19')](function(_0x3e79e4){if(_0x3e79e4){if(!_[_0xf2e8('0x6e')](_0x3e79e4[_0xf2e8('0x77')])){if(fs[_0xf2e8('0x6f')](path[_0xf2e8('0x70')](config[_0xf2e8('0x71')],'server/files/images/avatars/',_0x3e79e4[_0xf2e8('0x77')]))&&_0x3e79e4[_0xf2e8('0x78')]){_0x1e8d90=path[_0xf2e8('0x70')](config['root'],_0xf2e8('0x76'),_0x3e79e4['customerAvatar']);}}return _0x4c0472['download'](_0x1e8d90);}})['catch'](handleError(_0x4c0472,null));};exports['getSystemAvatar']=function(_0x519383,_0x484f19,_0xeb3ee){var _0x23b562=path['join'](config[_0xf2e8('0x71')],'server/files/images/avatars/system_avatar.png');var _0x574b0e={'where':{'id':_0x519383['params']['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db[_0xf2e8('0x37')][_0xf2e8('0x4e')](_0x574b0e)[_0xf2e8('0x19')](handleEntityNotFound(_0x484f19,null))[_0xf2e8('0x19')](function(_0x2f5497){if(_0x2f5497){if(!_['isNil'](_0x2f5497[_0xf2e8('0x69')])){if(fs[_0xf2e8('0x6f')](path['join'](config[_0xf2e8('0x71')],_0xf2e8('0x76'),_0x2f5497['systemAvatar']))){_0x23b562=path[_0xf2e8('0x70')](config[_0xf2e8('0x71')],'server/files/images/avatars/',_0x2f5497[_0xf2e8('0x69')]);}}return _0x484f19[_0xf2e8('0x73')](_0x23b562);}})['catch'](handleError(_0x484f19,null));};exports[_0xf2e8('0x79')]=function(_0x1f6a25,_0x359ab0,_0x454eae){var _0x858009=require('user-agent-parser');var _0x210466=new _0x858009();var _0x357da8=_0x210466[_0xf2e8('0x7a')](_0x1f6a25[_0xf2e8('0x7b')][_0xf2e8('0x7c')])[_0xf2e8('0x7d')]();var _0x1730ef={'body':_0x1f6a25[_0xf2e8('0x50')],'channel':_0xf2e8('0x7e')};var _0x509703=[];var _0x28e934=[];var _0x23bcaa={};var _0x1f0cec=![];return db[_0xf2e8('0x7f')][_0xf2e8('0x58')]()[_0xf2e8('0x19')](function(_0x50dae0){if(!_0x50dae0){throw new db[(_0xf2e8('0x80'))]['ValidationError'](_0xf2e8('0x81'));}_0x509703=_[_0xf2e8('0x82')](_[_0xf2e8('0x3c')](_0x50dae0),[_0xf2e8('0x83'),'updatedAt']);_0x28e934=_[_0xf2e8('0x82')](_[_0xf2e8('0x3c')](_0x50dae0),['createdAt',_0xf2e8('0x84'),'CompanyId',_0xf2e8('0x85')]);if(_0x1f6a25[_0xf2e8('0x50')]['id']){delete _0x1f6a25[_0xf2e8('0x50')]['id'];}if(_['isNil'](_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0x86')])){throw new db[(_0xf2e8('0x80'))][(_0xf2e8('0x87'))]('from\x20is\x20mandatory');}if(_[_0xf2e8('0x6e')](_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0x50')])||_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0x50')]===''){throw new db[(_0xf2e8('0x80'))]['ValidationError'](_0xf2e8('0x88'));}if(_[_0xf2e8('0x6e')](_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0x89')])){throw new db[(_0xf2e8('0x80'))][(_0xf2e8('0x87'))](_0xf2e8('0x8a')+_0x28e934);}if(!_[_0xf2e8('0x8b')](_0x28e934,_0x1f6a25['body'][_0xf2e8('0x89')])){throw new db[(_0xf2e8('0x80'))][(_0xf2e8('0x87'))](_0xf2e8('0x8c')+_0x28e934);}_0x23bcaa[_0x1f6a25['body']['mapKey']]=_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0x86')];})['then'](function(){return db[_0xf2e8('0x37')][_0xf2e8('0x4e')]({'where':{'id':_0x1f6a25[_0xf2e8('0x57')]['id']},'include':[{'model':db[_0xf2e8('0x8d')],'as':_0xf2e8('0x8e'),'include':[{'model':db[_0xf2e8('0x7f')],'as':_0xf2e8('0x8f'),'where':_0x23bcaa,'limit':0x1,'order':[[_0xf2e8('0x84'),_0xf2e8('0x90')]]}]},{'model':db['ChatApplication'],'as':_0xf2e8('0x91')}]});})['then'](handleEntityNotFound(_0x359ab0,null))['then'](function(_0x9d6c79){if(_0x9d6c79&&_0x9d6c79[_0xf2e8('0x8e')]){_0x1730ef[_0xf2e8('0x92')]=_0x9d6c79;_0x1730ef[_0xf2e8('0x93')]=_0x9d6c79['Applications'];_0x1730ef[_0xf2e8('0x94')]=_0x9d6c79['List'];_0x1730ef['applications']=_[_0xf2e8('0x95')](_0x1730ef[_0xf2e8('0x93')],[_0xf2e8('0x96')],[_0xf2e8('0x97')]);if(_0x1730ef[_0xf2e8('0x92')][_0xf2e8('0x91')]){delete _0x1730ef[_0xf2e8('0x92')][_0xf2e8('0x91')];}if(_0x1730ef[_0xf2e8('0x92')]['List']&&_0x1730ef[_0xf2e8('0x92')]['List'][_0xf2e8('0x8f')][_0xf2e8('0x43')]){return _0x1730ef[_0xf2e8('0x92')][_0xf2e8('0x8e')][_0xf2e8('0x8f')][0x0];}var _0xbde6b5=_['defaults'](_0x1f6a25[_0xf2e8('0x50')],{'firstName':_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0x86')],'ListId':_0x9d6c79[_0xf2e8('0x85')]});_0xbde6b5[_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0x89')]]=_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0x86')];return db[_0xf2e8('0x7f')][_0xf2e8('0x4f')](_0xbde6b5,{'fields':_0x509703,'raw':!![]});}})[_0xf2e8('0x19')](handleEntityNotFound(_0x359ab0,null))[_0xf2e8('0x19')](function(_0x262f97){_0x1730ef['contact']=_0x262f97;var _0x570300=_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0x98')];if(_0x1f6a25[_0xf2e8('0x7b')]['cf-connecting-ip']){_0x570300=_0x1f6a25[_0xf2e8('0x7b')][_0xf2e8('0x99')];}else if(_0x1f6a25[_0xf2e8('0x7b')][_0xf2e8('0x9a')]){_0x570300=_['first'](_0x1f6a25[_0xf2e8('0x7b')]['x-forwarded-for'][_0xf2e8('0x9b')](','));}if(_0x262f97){var _0x33ab13={'ContactId':_0x262f97['id'],'ChatWebsiteId':_0x1f6a25[_0xf2e8('0x57')]['id'],'from':(_0x262f97['firstName']||'')+'\x20'+(_0x262f97[_0xf2e8('0x9c')]||''),'customerIp':_0x570300,'customerPort':_0x1f6a25[_0xf2e8('0x7b')]['x-real-port']?_0x1f6a25[_0xf2e8('0x7b')][_0xf2e8('0x9d')]:null,'referer':_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0x9e')],'browserName':_0x357da8[_0xf2e8('0x9f')][_0xf2e8('0x33')]&&_0x357da8[_0xf2e8('0x9f')][_0xf2e8('0xa0')]?util['format'](_0xf2e8('0xa1'),_0x357da8[_0xf2e8('0x9f')]['name'],_0x357da8[_0xf2e8('0x9f')]['version']):'unknown','browserVersion':_0x357da8[_0xf2e8('0x9f')]['version']||_0xf2e8('0xa2'),'osName':util['format']('%s\x20%s',_0x357da8['os'][_0xf2e8('0x33')],_0x357da8['os'][_0xf2e8('0xa0')]),'osVersion':_0x357da8['os'][_0xf2e8('0xa0')],'deviceModel':_0x357da8[_0xf2e8('0xa3')][_0xf2e8('0x3e')]&&_0x357da8[_0xf2e8('0xa3')][_0xf2e8('0xa4')]?util[_0xf2e8('0xa5')](_0xf2e8('0xa6'),_0x357da8[_0xf2e8('0xa3')][_0xf2e8('0x3e')],_0x357da8[_0xf2e8('0xa3')][_0xf2e8('0xa4')],_0x357da8[_0xf2e8('0xa3')][_0xf2e8('0x3a')]):null,'deviceVendor':_0x357da8[_0xf2e8('0xa3')]['vendor'],'deviceType':_0x357da8[_0xf2e8('0xa3')][_0xf2e8('0x3a')],'formData':JSON[_0xf2e8('0x1c')](_0x1f6a25[_0xf2e8('0x50')])};var _0x18e59c={'ChatWebsiteId':_0x1f6a25[_0xf2e8('0x57')]['id'],'closed':![]};if(_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0xa7')]){_0x18e59c['threadId']=_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0xa7')];return db[_0xf2e8('0xa8')]['find']({'where':_0x18e59c})[_0xf2e8('0x19')](function(_0x275564){if(_0x275564){return[_0x275564,![]];}_0x33ab13[_0xf2e8('0xa7')]=_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0xa7')];_0x33ab13[_0xf2e8('0xa9')]=_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0xa9')];return db[_0xf2e8('0xa8')][_0xf2e8('0x4f')](_0x33ab13)[_0xf2e8('0x19')](function(_0x2cd258){return[_0x2cd258,!![]];});});}_0x18e59c[_0xf2e8('0xaa')]=_0x262f97['id'];if(_0x1f6a25[_0xf2e8('0x50')]['interaction']&&_0x1f6a25['body'][_0xf2e8('0xab')]['id']){_0x18e59c['id']=_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0xab')]['id'];return db[_0xf2e8('0xa8')]['find']({'where':_0x18e59c})['then'](function(_0x97a84f){if(_0x97a84f){return[_0x97a84f,![]];}return db[_0xf2e8('0xa8')]['create'](_0x33ab13)[_0xf2e8('0x19')](function(_0x3e029a){return[_0x3e029a,!![]];});});}return db['ChatInteraction'][_0xf2e8('0x4f')](_0x33ab13)[_0xf2e8('0x19')](function(_0xe128fd){return[_0xe128fd,!![]];});}})[_0xf2e8('0xac')](function(_0x15b41d,_0xbc96ea){if(_0x15b41d){_0x1f0cec=_0xbc96ea;if(!_0xbc96ea){var _0x147bd4={'from':(_0x1730ef[_0xf2e8('0xad')]['firstName']||'')+'\x20'+(_0x1730ef[_0xf2e8('0xad')][_0xf2e8('0x9c')]||'')};if(_0x1f6a25[_0xf2e8('0x50')]['threadId']&&_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0xae')]&&_0x1f6a25[_0xf2e8('0x50')]['threadId']!=_0x1f6a25[_0xf2e8('0x50')]['messageId']){_0x147bd4['threadId']=_0x1f6a25['body'][_0xf2e8('0xae')];}return _0x15b41d[_0xf2e8('0x2e')](_0x147bd4);}else{return _0x15b41d;}}})[_0xf2e8('0x19')](function(_0x55c7c5){_0x1730ef[_0xf2e8('0xab')]=_0x55c7c5[_0xf2e8('0x52')]({'plain':!![]});_0x1730ef['interaction']['created']=_0x1f0cec;if(_0x1730ef['interaction'][_0xf2e8('0xaf')]){if(_0x1730ef[_0xf2e8('0x92')][_0xf2e8('0xb0')]){_0x1730ef[_0xf2e8('0x93')][_0xf2e8('0xb1')]({'id':0x0,'priority':_0x1730ef[_0xf2e8('0x93')]['length']+0x1,'app':_0xf2e8('0xb2'),'appdata':'unmanaged','interval':_0xf2e8('0xb3')});}}return db[_0xf2e8('0xb4')][_0xf2e8('0x4f')]({'body':_0x1f6a25[_0xf2e8('0x50')]['body'],'ChatWebsiteId':_0x1f6a25['params']['id'],'ChatInteractionId':_0x55c7c5['id'],'direction':'in','ContactId':_0x1730ef[_0xf2e8('0xad')]['id'],'AttachmentId':_0x1f6a25[_0xf2e8('0x50')][_0xf2e8('0xb5')]});})[_0xf2e8('0x19')](function(_0x5701d6){_0x1730ef[_0xf2e8('0x1f')]=_0x5701d6;if(_0x1730ef[_0xf2e8('0xab')][_0xf2e8('0xb6')]){return db[_0xf2e8('0xb7')]['find']({'attributes':['id',_0xf2e8('0x33')],'where':{'id':_0x1730ef[_0xf2e8('0xab')]['UserId']}})['then'](function(_0x49dbcc){if(_0x49dbcc){_0x1730ef['applications'][_0xf2e8('0xb8')]({'id':0x0,'priority':0x0,'app':_0xf2e8('0xb9'),'appdata':_0x49dbcc['name']+','+(_0x1730ef[_0xf2e8('0x92')]['waitForTheAssignedAgent']||0xa),'interval':'*,*,*,*'});_0x1730ef[_0xf2e8('0xba')]=!![];}return respondWithRpcPromise(_0xf2e8('0xbb'),_0xf2e8('0xbc'),_0x1730ef);});}return respondWithRpcPromise(_0xf2e8('0xbb'),_0xf2e8('0xbc'),_0x1730ef);})['then'](function(_0x20eccc){respondWithRpcPromise('EventManager','EventManager',{'event':_0xf2e8('0x79'),'message':_0x20eccc},client9002);return _0x20eccc;})['then'](respondWithResult(_0x359ab0,null))[_0xf2e8('0x22')](handleError(_0x359ab0,null));};exports['offline']=function(_0x1242fe,_0x227d3f,_0x4fad6f){var _0x153be8,_0x265b19,_0x19b702;var _0x3f3ebb=[];var _0x478dec=[];var _0x50299c={};var _0x3a326c=_0x1242fe[_0xf2e8('0xbd')]||[];var _0x467616=[];var _0x91f4b1;return db[_0xf2e8('0x7f')]['describe']()[_0xf2e8('0x19')](function(_0x1f0cd7){if(!_0x1f0cd7){throw new db[(_0xf2e8('0x80'))][(_0xf2e8('0x87'))](_0xf2e8('0x81'));}_0x478dec=_[_0xf2e8('0x82')](_[_0xf2e8('0x3c')](_0x1f0cd7),[_0xf2e8('0x83'),_0xf2e8('0x84')]);_0x3f3ebb=_['difference'](_[_0xf2e8('0x3c')](_0x1f0cd7),['createdAt','updatedAt',_0xf2e8('0xbe'),_0xf2e8('0x85')]);if(_0x1242fe[_0xf2e8('0x50')]['id']){delete _0x1242fe[_0xf2e8('0x50')]['id'];}if(_['isNil'](_0x1242fe[_0xf2e8('0x50')][_0xf2e8('0x86')])){throw _0x227d3f[_0xf2e8('0x24')](0x1f4)[_0xf2e8('0xbf')](new db[(_0xf2e8('0x80'))][(_0xf2e8('0x87'))](_0xf2e8('0xc0')));}if(_[_0xf2e8('0x6e')](_0x1242fe['body'][_0xf2e8('0x50')])||_0x1242fe[_0xf2e8('0x50')]['body']===''){throw _0x227d3f['status'](0x1f4)[_0xf2e8('0xbf')](new db[(_0xf2e8('0x80'))][(_0xf2e8('0x87'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0xf2e8('0x6e')](_0x1242fe[_0xf2e8('0x50')][_0xf2e8('0xc1')])){throw _0x227d3f[_0xf2e8('0x24')](0x1f4)[_0xf2e8('0xbf')](new db['Sequelize'][(_0xf2e8('0x87'))](_0xf2e8('0xc2')+_0x3f3ebb));}if(!_[_0xf2e8('0x8b')](_0x3f3ebb,_0x1242fe[_0xf2e8('0x50')][_0xf2e8('0xc1')])){throw _0x227d3f[_0xf2e8('0x24')](0x1f4)[_0xf2e8('0xbf')](new db['Sequelize'][(_0xf2e8('0x87'))](_0xf2e8('0xc3')+_0x3f3ebb));}_0x50299c[_0x1242fe[_0xf2e8('0x50')][_0xf2e8('0xc1')]]=_0x1242fe[_0xf2e8('0x50')]['from'];})[_0xf2e8('0x19')](function(){return db['ChatWebsite']['find']({'where':{'id':_0x1242fe[_0xf2e8('0x57')]['id']},'include':[{'model':db[_0xf2e8('0x8d')],'as':_0xf2e8('0x8e')},{'model':db[_0xf2e8('0xc4')],'as':'MailAccount'}]});})[_0xf2e8('0x19')](handleEntityNotFound(_0x227d3f,null))[_0xf2e8('0x19')](function(_0x193819){if(_0x193819&&_0x193819[_0xf2e8('0x8e')]){_0x265b19=_0x193819;var _0x8b12fc=_['defaults'](_0x1242fe['body'],{'firstName':_0x1242fe[_0xf2e8('0x50')][_0xf2e8('0x86')],'phone':_0x1242fe[_0xf2e8('0x50')][_0xf2e8('0x86')],'ListId':_0x193819[_0xf2e8('0x85')]});_0x8b12fc[_0x1242fe[_0xf2e8('0x50')]['mapKeyOffline']]=_0x1242fe[_0xf2e8('0x50')][_0xf2e8('0x86')];return db[_0xf2e8('0x7f')][_0xf2e8('0xc5')]({'where':_0x50299c,'defaults':_0x8b12fc});}})[_0xf2e8('0xac')](function(_0x1275d1){if(_0x1275d1){_0x19b702=_0x1275d1;var _0x37328a=fs[_0xf2e8('0xc6')](path['join'](config[_0xf2e8('0x71')],_0xf2e8('0xc7')),'utf8');var _0x4841b4=ejs['render'](_0x37328a,{'body':_[_0xf2e8('0xc8')](_0x1242fe[_0xf2e8('0x50')][_0xf2e8('0x50')]),'bodyTitle':_0x265b19[_0xf2e8('0xc9')]});return db[_0xf2e8('0xca')][_0xf2e8('0x4f')]({'body':_0x4841b4,'ContactId':_0x1275d1['id'],'ChatWebsiteId':_0x265b19['id']});}})['then'](function(_0x2c6aee){_0x91f4b1=_0x2c6aee;if(_0x3a326c[_0xf2e8('0x43')]){var _0x436551=_0x3a326c[_0xf2e8('0x36')](function(_0x2d1dd0){return{'name':_0x2d1dd0['originalname'],'basename':_0x2d1dd0[_0xf2e8('0x67')],'type':_0x2d1dd0['mimetype'],'ChatOfflineMessageId':_0x2c6aee['id']};});_0x467616=_0x436551[_0xf2e8('0x36')](_0x19cf9d=>{var _0x1127c6={'filename':_0x19cf9d[_0xf2e8('0x33')],'path':path[_0xf2e8('0x70')](config[_0xf2e8('0x71')],'server','files',_0xf2e8('0xcb'),_0xf2e8('0xcc'),_0x19cf9d[_0xf2e8('0xcd')])};return _0x1127c6;});if(!_0x265b19[_0xf2e8('0xce')]){return db[_0xf2e8('0xcf')][_0xf2e8('0xd0')](function(_0x522224){return db[_0xf2e8('0xd1')][_0xf2e8('0xd2')](_0x436551,{'transaction':_0x522224});});}}})[_0xf2e8('0x19')](function(){if(_0x91f4b1){_0x153be8=_0x91f4b1;return db[_0xf2e8('0xc4')][_0xf2e8('0x5a')]({'where':{'active':!![]},'include':[{'model':db[_0xf2e8('0xd3')],'as':_0xf2e8('0xd4'),'raw':!![]}]});}})[_0xf2e8('0x19')](function(_0x261433){if(_0x261433&&_0x261433[_0xf2e8('0xd4')]&&_0x265b19[_0xf2e8('0xd5')]&&_0x265b19[_0xf2e8('0xd6')]){var _0x472a11={'tls':{'rejectUnauthorized':![]}};if(_0x261433[_0xf2e8('0xd4')]['service']){_0x472a11[_0xf2e8('0xd7')]=_0x261433['Smtp']['service'];}else{_0x472a11[_0xf2e8('0xd8')]=_0x261433['Smtp'][_0xf2e8('0xd8')];_0x472a11['port']=_0x261433[_0xf2e8('0xd4')]['port'];_0x472a11[_0xf2e8('0xd9')]=_0x261433[_0xf2e8('0xd4')][_0xf2e8('0xd9')];}if(_0x261433[_0xf2e8('0xd4')]['authentication']){_0x472a11[_0xf2e8('0xda')]={'user':_0x261433[_0xf2e8('0xd4')]['user'],'pass':_0x261433[_0xf2e8('0xd4')][_0xf2e8('0xdb')]};}return respondWithRpcPromise(_0xf2e8('0xdc'),_0xf2e8('0xdd'),{'account':_0x472a11,'message':{'from':util[_0xf2e8('0xa5')](_0xf2e8('0xde'),_0x261433['name'],_0x261433[_0xf2e8('0xdf')]||_0x261433[_0xf2e8('0xd4')][_0xf2e8('0x51')]),'to':_0x265b19['forwardOfflineAddress'],'subject':_0x265b19[_0xf2e8('0xe0')],'html':_0x153be8[_0xf2e8('0x50')],'attachments':_0x467616}},client9003)[_0xf2e8('0x19')](function(){return _0x153be8;})[_0xf2e8('0x22')](function(_0xf76542){console[_0xf2e8('0x1d')](_0xf76542);});}})[_0xf2e8('0x19')](function(){if(_0x265b19&&_0x265b19[_0xf2e8('0xce')]&&_0x265b19['MailAccountId']){var _0x5c1d45=[];if(_0x3a326c[_0xf2e8('0x43')]){_0x5c1d45=_0x3a326c[_0xf2e8('0x36')](function(_0x3ba523){return{'name':_0x3ba523['originalname'],'basename':_0x3ba523[_0xf2e8('0x67')],'type':_0x3ba523[_0xf2e8('0xe1')],'ChatOfflineMessageId':_0x91f4b1['id']};});}var _0x37755f;if(!_[_0xf2e8('0x6e')](_0x265b19[_0xf2e8('0xe2')])){var _0x57f6bd=_[_0xf2e8('0x36')](_0x1242fe[_0xf2e8('0x50')],function(_0x3562cc){return _0x3562cc;});var _0x3e4e57=_[_0xf2e8('0xe3')](_0x57f6bd)[0x0];var _0x999f7e=_[_0xf2e8('0xe4')](_0x3e4e57,function(_0x457a1f){return _0x457a1f;});_0x37755f=_0x999f7e[0x1][_0x265b19['subjectOffline']];}var _0x36c4c8={'from':_0x19b702[_0xf2e8('0xdf')],'firstName':_0x19b702['firstName'],'lastName':_0x19b702[_0xf2e8('0x9c')],'mapKey':_0xf2e8('0xdf'),'message':{'from':_0x19b702['email'],'to':_0x265b19[_0xf2e8('0xc4')][_0xf2e8('0xdf')],'cc':'','subject':_[_0xf2e8('0x6e')](_0x37755f)?_0x265b19['offlineMessageSubject']:_0x37755f,'messageId':'','sentAt':new Date(),'attach':_0x5c1d45[_0xf2e8('0x43')],'attachments':_0x5c1d45,'originChannel':'Chat','ChatWebsiteId':_0x265b19['id'],'ChatOfflineMessageId':_0x153be8['id'],'originTo':_0x265b19['MailAccount']['email']},'body':_0x153be8[_0xf2e8('0x50')]};var _0x3464b5={'account':{'id':_0x265b19['MailAccountId']},'body':_0x36c4c8,'log':_0xf2e8('0xe5')};return respondWithRpcPromise(_0xf2e8('0xe5'),'notifyMail',_0x3464b5,client9001)[_0xf2e8('0x19')](function(){return _0x153be8;})['catch'](function(_0x3e9f46){console[_0xf2e8('0x1d')](_0x3e9f46);});}return;})['then'](function(){if(_0x153be8){return _0x153be8;}})['then'](respondWithResult(_0x227d3f,null))[_0xf2e8('0x22')](function(_0x55772a){console[_0xf2e8('0x1d')](_0xf2e8('0x22'),_0x55772a);for(var _0x361325 of _0x3a326c){var _0x2c5168=path[_0xf2e8('0x70')](config[_0xf2e8('0x71')],'server','files',_0xf2e8('0xcb'),_0xf2e8('0xcc'),_0x361325[_0xf2e8('0x67')]);fs_extra[_0xf2e8('0xe6')](_0x2c5168)['catch'](function(_0x439982){console[_0xf2e8('0x1d')]('Could\x20not\x20remove\x20attachment\x20file',_0x2c5168,_0x439982);});}});};exports[_0xf2e8('0xe7')]=function(_0x372b01,_0x3847ef,_0xa4a59){return db[_0xf2e8('0xa8')][_0xf2e8('0x4e')]({'where':{'id':_0x372b01['params']['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x3847ef,null))['then'](function(_0x35f9a7){if(_0x35f9a7){return _0x35f9a7[_0xf2e8('0xe7')](_0x372b01[_0xf2e8('0x50')][_0xf2e8('0xe8')],_[_0xf2e8('0xe9')](_0x372b01[_0xf2e8('0x50')],[_0xf2e8('0xe8'),'id'])||{});}})[_0xf2e8('0x19')](respondWithResult(_0x3847ef,null))[_0xf2e8('0x22')](handleError(_0x3847ef,null));};exports[_0xf2e8('0xea')]=function(_0x239235,_0x51632f,_0x33dcd5){var _0x402110={'raw':![],'where':{}};var _0x1bf156={};var _0x4f7482={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x239235[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x51632f,null))[_0xf2e8('0x19')](function(_0x55ba7c){if(_0x55ba7c){_0x1bf156[_0xf2e8('0x3e')]=_[_0xf2e8('0x3c')](db[_0xf2e8('0xa8')][_0xf2e8('0x38')]);_0x1bf156[_0xf2e8('0x42')]=_['keys'](_0x239235[_0xf2e8('0x42')]);_0x1bf156['filters']=_[_0xf2e8('0x40')](_0x1bf156[_0xf2e8('0x3e')],_0x1bf156[_0xf2e8('0x42')]);_0x402110[_0xf2e8('0x3f')]=_[_0xf2e8('0x40')](_0x1bf156[_0xf2e8('0x3e')],qs['fields'](_0x239235[_0xf2e8('0x42')][_0xf2e8('0x41')]));_0x402110[_0xf2e8('0x3f')]=_0x402110[_0xf2e8('0x3f')]['length']?_0x402110[_0xf2e8('0x3f')]:_0x1bf156[_0xf2e8('0x3e')];if(!_0x239235[_0xf2e8('0x42')]['hasOwnProperty'](_0xf2e8('0x44'))){_0x402110[_0xf2e8('0x28')]=qs['limit'](_0x239235[_0xf2e8('0x42')][_0xf2e8('0x28')]);_0x402110[_0xf2e8('0x26')]=qs[_0xf2e8('0x26')](_0x239235[_0xf2e8('0x42')][_0xf2e8('0x26')]);}_0x402110['order']=qs['sort'](_0x239235[_0xf2e8('0x42')]['sort']);_0x402110[_0xf2e8('0x46')]=qs[_0xf2e8('0x3d')](_[_0xf2e8('0x5d')](_0x239235[_0xf2e8('0x42')],_0x1bf156['filters']));_0x402110['where'][_0xf2e8('0x60')]=_0x55ba7c['id'];if(_0x239235[_0xf2e8('0x42')][_0xf2e8('0x49')]){_0x402110[_0xf2e8('0x46')]=_['merge'](_0x402110[_0xf2e8('0x46')],{'$or':_[_0xf2e8('0x36')](_0x402110['attributes'],function(_0x182a4e){var _0x8279c7={};_0x8279c7[_0x182a4e]={'$like':'%'+_0x239235[_0xf2e8('0x42')][_0xf2e8('0x49')]+'%'};return _0x8279c7;})});}_0x402110=_[_0xf2e8('0x47')]({},_0x402110,_0x239235[_0xf2e8('0x62')]);return db['ChatInteraction']['count']({'where':_0x402110[_0xf2e8('0x46')]})[_0xf2e8('0x19')](function(_0x4d815b){_0x4f7482[_0xf2e8('0x29')]=_0x4d815b;if(_0x239235['query'][_0xf2e8('0x4a')]){_0x402110['include']=[{'model':db[_0xf2e8('0x7f')],'as':_0xf2e8('0xeb'),'required':![]},{'model':db[_0xf2e8('0xb7')],'as':_0xf2e8('0xec'),'attributes':[_0xf2e8('0x33'),_0xf2e8('0xed'),_0xf2e8('0xee')],'required':![]},{'model':db[_0xf2e8('0xef')],'as':_0xf2e8('0xf0'),'attributes':['id',_0xf2e8('0x33'),'color'],'where':_0x239235[_0xf2e8('0x42')]['tag']?{'id':_0x239235[_0xf2e8('0x42')]['tag']}:undefined,'required':_0x239235[_0xf2e8('0x42')][_0xf2e8('0xf1')]?!![]:![]}];}return db[_0xf2e8('0xa8')]['findAll'](_0x402110);})[_0xf2e8('0x19')](function(_0xe9edf){_0x4f7482[_0xf2e8('0x63')]=_0xe9edf;return _0x4f7482;});}})[_0xf2e8('0x19')](respondWithFilteredResult(_0x51632f,_0x402110))[_0xf2e8('0x22')](handleError(_0x51632f,null));};function iftimePromise(_0x3a5565,_0x52c54b){return respondWithRpcPromise(_0xf2e8('0xf2'),'getSnippet',{'command':_0x52c54b[_0xf2e8('0xf3')]?util[_0xf2e8('0xa5')](_0xf2e8('0xf4'),_0x3a5565[_0xf2e8('0xf5')],_0x52c54b['timezone']):util[_0xf2e8('0xa5')](_0xf2e8('0xf6'),_0x3a5565[_0xf2e8('0xf5')])},client9002)[_0xf2e8('0x19')](function(_0x57a2ca){var _0x251e2b=_0x57a2ca&&_0x57a2ca[_0xf2e8('0xf7')](_0xf2e8('0xf8'))>=0x0?!![]:![];logger['info']('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x52c54b['id'],_0x3a5565['id'],_0x3a5565['interval'],_0x251e2b?_0xf2e8('0xf9'):'OFFLINE',_0x52c54b[_0xf2e8('0xf3')]?_0x52c54b['timezone']:_0xf2e8('0xfa'));return _0x251e2b;})[_0xf2e8('0x22')](function(_0x474a41){logger[_0xf2e8('0x1d')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x52c54b['id'],_0x3a5565['id'],_0x3a5565[_0xf2e8('0xf5')],util[_0xf2e8('0xfb')](_0x474a41,{'showHidden':![],'depth':null}),_0x52c54b[_0xf2e8('0xf3')]?_0x52c54b[_0xf2e8('0xf3')]:_0xf2e8('0xfa'));return![];});}exports[_0xf2e8('0xfc')]=function(_0x578cd7,_0x6ef633,_0x377b66){var _0x295b23=0x0;var _0x2013e4=0x0;var _0x30d20a=![];var _0x198c62;var _0x5efcd9;return db[_0xf2e8('0x37')][_0xf2e8('0x4e')]({'where':{'id':_0x578cd7[_0xf2e8('0x57')]['id']},'include':[{'model':db[_0xf2e8('0xfd')],'as':_0xf2e8('0xfd'),'include':[{'model':db['Interval'],'as':_0xf2e8('0xfe'),'attributes':['id','interval'],'raw':!![]}]}]})[_0xf2e8('0x19')](handleEntityNotFound(_0x6ef633,null))[_0xf2e8('0x19')](function(_0x438a01){if(_0x438a01){_0x198c62=_0x438a01;return _0x438a01[_0xf2e8('0xff')]({'raw':!![]});}})[_0xf2e8('0x19')](function(_0x2b91b7){if(_0x198c62){if(_0x2b91b7){_0x5efcd9=_0x2b91b7;}}return require(_0xf2e8('0x14'))[_0xf2e8('0x6c')]();})[_0xf2e8('0x19')](function(_0x15c8f3){if(_0x15c8f3){_0x2013e4=_0x15c8f3[_0xf2e8('0x100')];_0x30d20a=_0x15c8f3['custom'];}})[_0xf2e8('0x19')](function(){return db[_0xf2e8('0xa8')][_0xf2e8('0x29')]({'where':{'closed':![]}});})['then'](function(_0x7fb681){_0x295b23=_0x7fb681;if(_0x2013e4&&_0x7fb681>_0x2013e4){return db[_0xf2e8('0x101')][_0xf2e8('0x5a')]({'where':{'id':0x1}})[_0xf2e8('0x19')](function(_0x36f799){if(_0x36f799){_0x36f799[_0xf2e8('0x102')]('chatLicenseExceeded');}});}})[_0xf2e8('0x19')](function(){if(_0x198c62['Interval']&&_0x198c62[_0xf2e8('0xfd')][_0xf2e8('0xfe')]){var _0x354eb6=[];for(var _0x41f67c=0x0;_0x41f67c<_0x198c62[_0xf2e8('0xfd')][_0xf2e8('0xfe')][_0xf2e8('0x43')];_0x41f67c++){var _0x53264e=_0x198c62[_0xf2e8('0xfd')][_0xf2e8('0xfe')][_0x41f67c][_0xf2e8('0x52')]({'plain':!![]});_0x354eb6[_0xf2e8('0xb1')](iftimePromise(_0x53264e,_0x198c62));}return BPromise[_0xf2e8('0x103')](_0x354eb6)['then'](function(_0xd0215e){return _[_0xf2e8('0x104')](_0xd0215e);});}else{return!![];}})[_0xf2e8('0x19')](function(_0xcf0f0d){var _0x377560=fs[_0xf2e8('0xc6')](path[_0xf2e8('0x70')](config[_0xf2e8('0x71')],'server/files/chat/iframe.ejs'),'utf8');var _0x4be794={'remote':_0x198c62[_0xf2e8('0x105')],'query':querystring[_0xf2e8('0x1c')](_['merge'](_0x198c62[_0xf2e8('0x52')]({'plain':!![]}),{'customerIp':_0x578cd7[_0xf2e8('0x7b')][_0xf2e8('0x9a')]||_0x578cd7[_0xf2e8('0x7b')]['x-real-ip']||_0x578cd7['connection'][_0xf2e8('0x106')]||_0x578cd7['ip'],'referer':_0x578cd7[_0xf2e8('0x7b')][_0xf2e8('0x9e')],'openedInteractions':_0x295b23,'maxInteractions':_0x2013e4,'virtual':_0x30d20a[_0xf2e8('0x100')],'online':_0xcf0f0d,'custom':_0x30d20a}))[_0xf2e8('0x107')](/'/g,'\x5c\x27')};_0x6ef633[_0xf2e8('0xbf')](ejs['render'](Mustache['render'](_0x377560,_0x4be794),{'proactiveActions':_0x5efcd9,'alignment':_0x198c62[_0xf2e8('0x108')],'verticalAlignment':_0x198c62[_0xf2e8('0x109')],'div_color':_0x198c62[_0xf2e8('0x10a')],'text_color':_0x198c62[_0xf2e8('0x10b')],'button_color':_0x198c62[_0xf2e8('0x10c')],'background_color':_0x198c62['backgroundColor']}));})[_0xf2e8('0x22')](handleError(_0x6ef633,null));};exports[_0xf2e8('0x10d')]=function(_0xe3fd36,_0x14be73,_0x1a9b25){return db[_0xf2e8('0x37')][_0xf2e8('0x5a')]({'where':{'id':_0xe3fd36[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x14be73,null))[_0xf2e8('0x19')](function(_0x3eb548){if(_0x3eb548){return db[_0xf2e8('0xcf')][_0xf2e8('0xd0')](function(_0x3914b3){return db[_0xf2e8('0x10e')][_0xf2e8('0x2f')]({'where':{'ChatWebsiteId':_0xe3fd36[_0xf2e8('0x57')]['id']},'transaction':_0x3914b3})[_0xf2e8('0x19')](function(_0x2d7e8e){var _0x461efa=_[_0xf2e8('0x36')](_0xe3fd36[_0xf2e8('0x50')],function(_0x54d192){_0x54d192[_0xf2e8('0x60')]=_0xe3fd36[_0xf2e8('0x57')]['id'];return _0x54d192;});return db[_0xf2e8('0x10e')][_0xf2e8('0xd2')](_0x461efa,{'transaction':_0x3914b3});});})['then'](function(){return db[_0xf2e8('0x10e')][_0xf2e8('0x10f')]({'where':{'ChatWebsiteId':_0xe3fd36[_0xf2e8('0x57')]['id']},'order':'priority'});});}})[_0xf2e8('0x19')](respondWithResult(_0x14be73,null))['catch'](handleError(_0x14be73,null));};exports['getApplications']=function(_0x50387d,_0x457a38,_0xd4978f){var _0x55ef91={};var _0x561d0d={};var _0x236c32;var _0x4118d3;return db[_0xf2e8('0x37')]['findOne']({'where':{'id':_0x50387d['params']['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x457a38,null))[_0xf2e8('0x19')](function(_0x1147f4){if(_0x1147f4){_0x236c32=_0x1147f4;_0x561d0d[_0xf2e8('0x3e')]=_[_0xf2e8('0x3c')](db['ChatApplication'][_0xf2e8('0x38')]);_0x561d0d[_0xf2e8('0x42')]=_[_0xf2e8('0x3c')](_0x50387d[_0xf2e8('0x42')]);_0x561d0d[_0xf2e8('0x3d')]=_[_0xf2e8('0x40')](_0x561d0d[_0xf2e8('0x3e')],_0x561d0d[_0xf2e8('0x42')]);_0x55ef91[_0xf2e8('0x3f')]=_[_0xf2e8('0x40')](_0x561d0d[_0xf2e8('0x3e')],qs[_0xf2e8('0x41')](_0x50387d[_0xf2e8('0x42')][_0xf2e8('0x41')]));_0x55ef91[_0xf2e8('0x3f')]=_0x55ef91[_0xf2e8('0x3f')][_0xf2e8('0x43')]?_0x55ef91['attributes']:_0x561d0d[_0xf2e8('0x3e')];_0x55ef91[_0xf2e8('0x5c')]=qs[_0xf2e8('0x45')](_0x50387d[_0xf2e8('0x42')]['sort']);_0x55ef91[_0xf2e8('0x46')]=qs[_0xf2e8('0x3d')](_[_0xf2e8('0x5d')](_0x50387d[_0xf2e8('0x42')],_0x561d0d[_0xf2e8('0x3d')]));if(_0x50387d[_0xf2e8('0x42')][_0xf2e8('0x49')]){_0x55ef91[_0xf2e8('0x46')]=_[_0xf2e8('0x47')](_0x55ef91[_0xf2e8('0x46')],{'$or':_['map'](_0x55ef91['attributes'],function(_0x2c0a18){var _0x596d1d={};_0x596d1d[_0x2c0a18]={'$like':'%'+_0x50387d[_0xf2e8('0x42')][_0xf2e8('0x49')]+'%'};return _0x596d1d;})});}_0x55ef91=_[_0xf2e8('0x47')]({},_0x55ef91,_0x50387d[_0xf2e8('0x62')]);return _0x236c32[_0xf2e8('0x110')](_0x55ef91);}})['then'](function(_0x5fba06){if(_0x5fba06){_0x4118d3=_0x5fba06['length'];if(!_0x50387d['query'][_0xf2e8('0x5b')]('nolimit')){_0x55ef91[_0xf2e8('0x28')]=qs['limit'](_0x50387d[_0xf2e8('0x42')][_0xf2e8('0x28')]);_0x55ef91[_0xf2e8('0x26')]=qs[_0xf2e8('0x26')](_0x50387d[_0xf2e8('0x42')][_0xf2e8('0x26')]);}return _0x236c32['getApplications'](_0x55ef91);}})['then'](function(_0x1c31cf){if(_0x1c31cf){return _0x1c31cf?{'count':_0x4118d3,'rows':_0x1c31cf}:null;}})[_0xf2e8('0x19')](respondWithResult(_0x457a38,null))[_0xf2e8('0x22')](handleError(_0x457a38,null));};exports[_0xf2e8('0x111')]=function(_0x1bf0a7,_0xcaa812,_0x3a30e1){return db[_0xf2e8('0x112')]['find']({'where':{'id':_0x1bf0a7[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0xcaa812,null))[_0xf2e8('0x19')](function(_0xf0da7c){if(_0xf0da7c){return _0xf0da7c[_0xf2e8('0x111')](_0x1bf0a7[_0xf2e8('0x50')][_0xf2e8('0xe8')],_[_0xf2e8('0xe9')](_0x1bf0a7[_0xf2e8('0x50')],[_0xf2e8('0xe8'),'id'])||{});}})[_0xf2e8('0x19')](respondWithResult(_0xcaa812,null))[_0xf2e8('0x22')](handleError(_0xcaa812,null));};exports[_0xf2e8('0xff')]=function(_0x46c549,_0x6c9525,_0x573896){var _0x200bbb={};var _0x272ff5={};var _0x41e4e9;var _0x5846de;return db[_0xf2e8('0x37')][_0xf2e8('0x5a')]({'where':{'id':_0x46c549[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x6c9525,null))['then'](function(_0x254738){if(_0x254738){_0x41e4e9=_0x254738;_0x272ff5[_0xf2e8('0x3e')]=_['keys'](db[_0xf2e8('0x113')][_0xf2e8('0x38')]);_0x272ff5[_0xf2e8('0x42')]=_[_0xf2e8('0x3c')](_0x46c549[_0xf2e8('0x42')]);_0x272ff5[_0xf2e8('0x3d')]=_['intersection'](_0x272ff5['model'],_0x272ff5['query']);_0x200bbb['attributes']=_[_0xf2e8('0x40')](_0x272ff5['model'],qs[_0xf2e8('0x41')](_0x46c549[_0xf2e8('0x42')]['fields']));_0x200bbb['attributes']=_0x200bbb[_0xf2e8('0x3f')][_0xf2e8('0x43')]?_0x200bbb[_0xf2e8('0x3f')]:_0x272ff5[_0xf2e8('0x3e')];_0x200bbb[_0xf2e8('0x5c')]=qs[_0xf2e8('0x45')](_0x46c549['query'][_0xf2e8('0x45')]);_0x200bbb[_0xf2e8('0x46')]=qs[_0xf2e8('0x3d')](_[_0xf2e8('0x5d')](_0x46c549['query'],_0x272ff5[_0xf2e8('0x3d')]));if(_0x46c549[_0xf2e8('0x42')]['filter']){_0x200bbb[_0xf2e8('0x46')]=_['merge'](_0x200bbb[_0xf2e8('0x46')],{'$or':_[_0xf2e8('0x36')](_0x200bbb[_0xf2e8('0x3f')],function(_0x1e02d7){var _0x1b7ee4={};_0x1b7ee4[_0x1e02d7]={'$like':'%'+_0x46c549[_0xf2e8('0x42')][_0xf2e8('0x49')]+'%'};return _0x1b7ee4;})});}_0x200bbb=_[_0xf2e8('0x47')]({},_0x200bbb,_0x46c549['options']);return _0x41e4e9[_0xf2e8('0xff')](_0x200bbb);}})[_0xf2e8('0x19')](function(_0x4d47ef){if(_0x4d47ef){_0x5846de=_0x4d47ef[_0xf2e8('0x43')];if(!_0x46c549[_0xf2e8('0x42')]['hasOwnProperty'](_0xf2e8('0x44'))){_0x200bbb['limit']=qs[_0xf2e8('0x28')](_0x46c549[_0xf2e8('0x42')][_0xf2e8('0x28')]);_0x200bbb[_0xf2e8('0x26')]=qs[_0xf2e8('0x26')](_0x46c549[_0xf2e8('0x42')]['offset']);}return _0x41e4e9[_0xf2e8('0xff')](_0x200bbb);}})['then'](function(_0x1ed28b){if(_0x1ed28b){return _0x1ed28b?{'count':_0x5846de,'rows':_0x1ed28b}:null;}})[_0xf2e8('0x19')](respondWithResult(_0x6c9525,null))[_0xf2e8('0x22')](handleError(_0x6c9525,null));};exports[_0xf2e8('0x114')]=function(_0x529345,_0x26005f,_0x2f38bc){var _0x686883=_0x529345['query'][_0xf2e8('0x115')]===_0xf2e8('0x116')?_0xf2e8('0x117'):'onlineForm';return db[_0xf2e8('0x37')][_0xf2e8('0x4e')]({'attributes':['id',_0x686883],'where':{'id':_0x529345[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x26005f,null))['then'](function(_0x3b739f){if(_0x3b739f){var _0x2e345b=_0x3b739f[_0x686883];var _0x6461c1=_0x2e345b&&_0x2e345b[_0xf2e8('0x118')]?_0x2e345b[_0xf2e8('0x118')]:[];_0x26005f[_0xf2e8('0xbf')]({'fromKey':_[_0xf2e8('0x6e')](_0x2e345b[_0xf2e8('0x119')])?undefined:_0x2e345b[_0xf2e8('0x119')],'count':_0x6461c1[_0xf2e8('0x43')],'rows':_0x6461c1});}})[_0xf2e8('0x22')](handleError(_0x26005f,null));};exports[_0xf2e8('0x11a')]=function(_0x4b6855,_0x465126,_0x30a801){var _0x445792={'raw':![],'where':{}};var _0xe6bf38={};var _0x34d0fe={'count':0x0,'rows':[]};return db[_0xf2e8('0x37')]['findOne']({'where':{'id':_0x4b6855[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x465126,null))[_0xf2e8('0x19')](function(_0x39d2c8){if(_0x39d2c8){_0xe6bf38['model']=_[_0xf2e8('0x3c')](db[_0xf2e8('0xca')][_0xf2e8('0x38')]);_0xe6bf38['query']=_[_0xf2e8('0x3c')](_0x4b6855[_0xf2e8('0x42')]);_0xe6bf38[_0xf2e8('0x3d')]=_['intersection'](_0xe6bf38[_0xf2e8('0x3e')],_0xe6bf38['query']);_0x445792[_0xf2e8('0x3f')]=_[_0xf2e8('0x40')](_0xe6bf38[_0xf2e8('0x3e')],qs[_0xf2e8('0x41')](_0x4b6855['query'][_0xf2e8('0x41')]));_0x445792['attributes']=_0x445792[_0xf2e8('0x3f')][_0xf2e8('0x43')]?_0x445792[_0xf2e8('0x3f')]:_0xe6bf38['model'];if(!_0x4b6855[_0xf2e8('0x42')][_0xf2e8('0x5b')](_0xf2e8('0x44'))){_0x445792[_0xf2e8('0x28')]=qs[_0xf2e8('0x28')](_0x4b6855[_0xf2e8('0x42')][_0xf2e8('0x28')]);_0x445792[_0xf2e8('0x26')]=qs[_0xf2e8('0x26')](_0x4b6855[_0xf2e8('0x42')][_0xf2e8('0x26')]);}_0x445792[_0xf2e8('0x5c')]=qs[_0xf2e8('0x45')](_0x4b6855[_0xf2e8('0x42')][_0xf2e8('0x45')]);_0x445792[_0xf2e8('0x46')]=qs['filters'](_[_0xf2e8('0x5d')](_0x4b6855['query'],_0xe6bf38[_0xf2e8('0x3d')]));_0x445792[_0xf2e8('0x46')][_0xf2e8('0x60')]=_0x39d2c8['id'];if(_0x4b6855['query']['filter']){_0x445792[_0xf2e8('0x46')]=_['merge'](_0x445792[_0xf2e8('0x46')],{'$or':_[_0xf2e8('0x36')](_0x445792[_0xf2e8('0x3f')],function(_0x3706ad){var _0x69a3f2={};_0x69a3f2[_0x3706ad]={'$like':'%'+_0x4b6855['query'][_0xf2e8('0x49')]+'%'};return _0x69a3f2;})});}_0x445792=_[_0xf2e8('0x47')]({},_0x445792,_0x4b6855[_0xf2e8('0x62')]);return db[_0xf2e8('0xca')][_0xf2e8('0x29')]({'where':_0x445792[_0xf2e8('0x46')]})[_0xf2e8('0x19')](function(_0xecfcc6){_0x34d0fe['count']=_0xecfcc6;if(_0x4b6855[_0xf2e8('0x42')]['includeAll']){_0x445792[_0xf2e8('0x4b')]=[{'all':!![]}];}else{_0x445792['include']=[{'model':db['CmContact'],'as':_0xf2e8('0xeb'),'required':![]},{'model':db['Attachment'],'as':_0xf2e8('0x11b'),'required':![]}];}return db[_0xf2e8('0xca')][_0xf2e8('0x4c')](_0x445792);})[_0xf2e8('0x19')](function(_0x204ae2){_0x34d0fe[_0xf2e8('0x63')]=_0x204ae2;return _0x34d0fe;});}})['then'](respondWithFilteredResult(_0x465126,_0x445792))[_0xf2e8('0x22')](handleError(_0x465126,null));};exports[_0xf2e8('0x11c')]=function(_0x16b100,_0x2c2584,_0xfee106){return db[_0xf2e8('0x37')]['find']({'where':{'id':_0x16b100[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x2c2584,null))[_0xf2e8('0x19')](function(_0x36e7a3){if(_0x36e7a3){return _0x36e7a3['addAgents'](_0x16b100[_0xf2e8('0x50')][_0xf2e8('0xe8')],_[_0xf2e8('0xe9')](_0x16b100[_0xf2e8('0x50')],[_0xf2e8('0xe8'),'id'])||{})[_0xf2e8('0xac')](function(_0x18e5a5){for(var _0x3e3edf=0x0;_0x3e3edf<_0x16b100[_0xf2e8('0x50')]['ids'][_0xf2e8('0x43')];_0x3e3edf+=0x1){socket[_0xf2e8('0x11d')](_0xf2e8('0x11e'),{'UserId':Number(_0x16b100['body'][_0xf2e8('0xe8')][_0x3e3edf]),'ChatWebsiteId':Number(_0x16b100[_0xf2e8('0x57')]['id'])});}return _0x18e5a5;});}})['then'](respondWithResult(_0x2c2584,null))[_0xf2e8('0x22')](handleError(_0x2c2584,null));};exports[_0xf2e8('0x11f')]=function(_0x7d87ff,_0x3eedc0,_0x4f00a9){return db[_0xf2e8('0x37')][_0xf2e8('0x4e')]({'where':{'id':_0x7d87ff[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x3eedc0,null))[_0xf2e8('0x19')](function(_0x3b928c){if(_0x3b928c){return _0x3b928c[_0xf2e8('0x11f')](_0x7d87ff[_0xf2e8('0x42')]['ids'])['then'](function(){if(_[_0xf2e8('0x120')](_0x7d87ff[_0xf2e8('0x42')][_0xf2e8('0xe8')])){for(var _0x5681dd=0x0;_0x5681dd<_0x7d87ff[_0xf2e8('0x42')]['ids'][_0xf2e8('0x43')];_0x5681dd+=0x1){socket[_0xf2e8('0x11d')]('userChatWebsite:remove',{'UserId':Number(_0x7d87ff[_0xf2e8('0x42')][_0xf2e8('0xe8')][_0x5681dd]),'ChatWebsiteId':Number(_0x7d87ff[_0xf2e8('0x57')]['id'])});}}else{socket[_0xf2e8('0x11d')](_0xf2e8('0x121'),{'UserId':Number(_0x7d87ff['query']['ids']),'ChatWebsiteId':Number(_0x7d87ff['params']['id'])});}});}})['then'](respondWithStatusCode(_0x3eedc0,null))['catch'](handleError(_0x3eedc0,null));};exports[_0xf2e8('0x122')]=function(_0x5002c5,_0x45ae75,_0x4c1946){var _0x5100a3={};var _0x4f340b={};var _0x2efed7;var _0x231597;return db['ChatWebsite'][_0xf2e8('0x5a')]({'where':{'id':_0x5002c5[_0xf2e8('0x57')]['id']}})[_0xf2e8('0x19')](handleEntityNotFound(_0x45ae75,null))['then'](function(_0x5f0161){if(_0x5f0161){_0x2efed7=_0x5f0161;_0x4f340b[_0xf2e8('0x3e')]=_[_0xf2e8('0x3c')](db['User']['rawAttributes']);_0x4f340b[_0xf2e8('0x42')]=_[_0xf2e8('0x3c')](_0x5002c5[_0xf2e8('0x42')]);_0x4f340b[_0xf2e8('0x3d')]=_[_0xf2e8('0x40')](_0x4f340b[_0xf2e8('0x3e')],_0x4f340b['query']);_0x5100a3[_0xf2e8('0x3f')]=_[_0xf2e8('0x40')](_0x4f340b[_0xf2e8('0x3e')],qs[_0xf2e8('0x41')](_0x5002c5[_0xf2e8('0x42')][_0xf2e8('0x41')]));_0x5100a3['attributes']=_0x5100a3[_0xf2e8('0x3f')]['length']?_0x5100a3[_0xf2e8('0x3f')]:_0x4f340b[_0xf2e8('0x3e')];_0x5100a3[_0xf2e8('0x5c')]=qs[_0xf2e8('0x45')](_0x5002c5[_0xf2e8('0x42')][_0xf2e8('0x45')]);_0x5100a3['where']=qs[_0xf2e8('0x3d')](_[_0xf2e8('0x5d')](_0x5002c5[_0xf2e8('0x42')],_0x4f340b[_0xf2e8('0x3d')]));if(_0x5002c5[_0xf2e8('0x42')][_0xf2e8('0x49')]){_0x5100a3[_0xf2e8('0x46')]=_[_0xf2e8('0x47')](_0x5100a3[_0xf2e8('0x46')],{'$or':_['map'](_0x5100a3[_0xf2e8('0x3f')],function(_0x415280){var _0xbe0e76={};_0xbe0e76[_0x415280]={'$like':'%'+_0x5002c5[_0xf2e8('0x42')][_0xf2e8('0x49')]+'%'};return _0xbe0e76;})});}_0x5100a3=_[_0xf2e8('0x47')]({},_0x5100a3,_0x5002c5[_0xf2e8('0x62')]);return _0x2efed7[_0xf2e8('0x122')](_0x5100a3);}})[_0xf2e8('0x19')](function(_0x3f5bc4){if(_0x3f5bc4){_0x231597=_0x3f5bc4[_0xf2e8('0x43')];if(!_0x5002c5[_0xf2e8('0x42')]['hasOwnProperty']('nolimit')){_0x5100a3[_0xf2e8('0x28')]=qs[_0xf2e8('0x28')](_0x5002c5[_0xf2e8('0x42')][_0xf2e8('0x28')]);_0x5100a3[_0xf2e8('0x26')]=qs[_0xf2e8('0x26')](_0x5002c5['query'][_0xf2e8('0x26')]);}return _0x2efed7[_0xf2e8('0x122')](_0x5100a3);}})[_0xf2e8('0x19')](function(_0x3fbde9){if(_0x3fbde9){return _0x3fbde9?{'count':_0x231597,'rows':_0x3fbde9}:null;}})[_0xf2e8('0x19')](respondWithResult(_0x45ae75,null))['catch'](handleError(_0x45ae75,null));};
\ No newline at end of file
+var _0xbaf0=['userChatWebsite:remove','getAgents','mustache','util','path','ejs','fs-extra','lodash','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','socket.io-emitter','./chatWebsite.socket','register','html-to-text','jayson/promise','client','http','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','sendStatus','status','json','offset','undefined','limit','count','set','update','destroy','get','ChatWebsites','UserProfileResource','end','stack','name','send','Pause','mandatoryDispositionPause','ChatWebsite','rawAttributes','fieldName','model','map','keys','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','type','VIRTUAL','options','includeAll','include','rows','show','params','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getDispositions','findOne','Disposition','findAll','removeDispositions','ids','addAnswer','ChatWebsiteId','CannedAnswer','length','removeAnswers','addLogo','sitepic','file','filename','addAvatar','agentAvatar','addCustomerAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','getLicense','custom','isNil','server/files/images/logos/','download','server/files/images/avatars/default_avatar.png','existsSync','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','server/files/images/avatars/system_avatar.png','notify','headers','user-agent','getResult','chat','CmContact','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','from','Sequelize','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','includes','CmList','Contacts','DESC','Applications','List','account','applications','list','orderBy','priority','asc','ListId','contact','customerIp','cf-connecting-ip','first','x-forwarded-for','split','firstName','x-real-port','browser','format','%s\x20%s','version','unknown','device','vendor','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','lastName','messageId','created','unmanaged','*,*,*,*','AttachmentId','UserId','User','unshift','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','offline','mapKeyOffline','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','fromString','originalname','mimetype','server','files','attachments','offline-chat','basename','openNewInteraction','sequelize','Attachment','bulkCreate','MailServerOut','Smtp','forwardOffline','forwardOfflineAddress','service','host','port','secure','authentication','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','MailAccountId','subjectOffline','toPairsIn','mapValues','Chat','NotifyMailAccount','notifyMail','remove','addInteraction','Contact','Owner','fullname','internal','Tags','Command','iftime\x20%s,%s','interval','timezone','iftime\x20%s','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','OFFLINE','No\x20timezone','inspect','getSnippet','Interval','Intervals','getProactiveActions','../../config/license/util','virtual','License','increment','chatLicenseExceeded','push','all','server/files/chat/iframe.ejs','remote','referer','alignment','verticalAlignment','labelText','textColor','color_button','backgroundColor','addApplications','transaction','ISOLATION_LEVELS','READ_COMMITTED','ChatApplication','finally','getApplications','chatProactiveAction','addProactiveActions','omit','getFields','online','false','onlineForm','items','fromKey','Attachments','addAgents','emit','userChatWebsite:save','removeAgents'];(function(_0x32f261,_0x307d25){var _0x21656d=function(_0x3ff582){while(--_0x3ff582){_0x32f261['push'](_0x32f261['shift']());}};_0x21656d(++_0x307d25);}(_0xbaf0,0x12a));var _0x0baf=function(_0x432682,_0x253044){_0x432682=_0x432682-0x0;var _0x463d05=_0xbaf0[_0x432682];return _0x463d05;};'use strict';var BPromise=require('bluebird');var Mustache=require(_0x0baf('0x0'));var util=require(_0x0baf('0x1'));var path=require(_0x0baf('0x2'));var ejs=require(_0x0baf('0x3'));var fs=require('fs');var fs_extra=require(_0x0baf('0x4'));var _=require(_0x0baf('0x5'));var querystring=require('querystring');var Redis=require(_0x0baf('0x6'));var qs=require(_0x0baf('0x7'));var logger=require(_0x0baf('0x8'))(_0x0baf('0x9'));var config=require(_0x0baf('0xa'));var db=require(_0x0baf('0xb'))['db'];config[_0x0baf('0xc')]=_[_0x0baf('0xd')](config[_0x0baf('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x0baf('0xe'))(new Redis(config['redis']));require(_0x0baf('0xf'))[_0x0baf('0x10')](socket);var htmlToText=require(_0x0baf('0x11'));var jayson=require(_0x0baf('0x12'));var client=jayson[_0x0baf('0x13')][_0x0baf('0x14')]({'port':0x232c});var client9002=jayson[_0x0baf('0x13')][_0x0baf('0x14')]({'port':0x232a});var client9003=jayson[_0x0baf('0x13')][_0x0baf('0x14')]({'port':0x232b});var client9001=jayson[_0x0baf('0x13')]['http']({'port':0x2329});function respondWithRpcPromise(_0x5a53e2,_0x465dd7,_0xe4378c,_0x5db689){return new BPromise(function(_0x13df17,_0x5a0583){var _0x2ab33e=_0x5db689||client;return _0x2ab33e['request'](_0x5a53e2,_0xe4378c)[_0x0baf('0x15')](function(_0x1f50c3){logger[_0x0baf('0x16')](_0x0baf('0x17'),_0x465dd7,_0x0baf('0x18'));logger[_0x0baf('0x19')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x465dd7,'request\x20sent',JSON[_0x0baf('0x1a')](_0x1f50c3));if(_0x1f50c3[_0x0baf('0x1b')]){if(_0x1f50c3[_0x0baf('0x1b')][_0x0baf('0x1c')]===0x1f4){logger[_0x0baf('0x1b')](_0x0baf('0x17'),_0x465dd7,_0x1f50c3['error'][_0x0baf('0x1d')]);return _0x5a0583(_0x1f50c3[_0x0baf('0x1b')][_0x0baf('0x1d')]);}logger[_0x0baf('0x1b')](_0x0baf('0x17'),_0x465dd7,_0x1f50c3[_0x0baf('0x1b')]['message']);return _0x13df17(_0x1f50c3['error'][_0x0baf('0x1d')]);}else{logger[_0x0baf('0x16')](_0x0baf('0x17'),_0x465dd7,_0x0baf('0x18'));_0x13df17(_0x1f50c3[_0x0baf('0x1e')][_0x0baf('0x1d')]);}})[_0x0baf('0x1f')](function(_0x636a13){logger[_0x0baf('0x1b')](_0x0baf('0x17'),_0x465dd7,_0x636a13);_0x5a0583(_0x636a13);});});}function respondWithStatusCode(_0x54f2fa,_0x334bd6){_0x334bd6=_0x334bd6||0xcc;return function(_0x482522){if(_0x482522){return _0x54f2fa[_0x0baf('0x20')](_0x334bd6);}return _0x54f2fa['status'](_0x334bd6)['end']();};}function respondWithResult(_0x2ef0aa,_0x48a0e9){_0x48a0e9=_0x48a0e9||0xc8;return function(_0x4be1b9){if(_0x4be1b9){return _0x2ef0aa[_0x0baf('0x21')](_0x48a0e9)[_0x0baf('0x22')](_0x4be1b9);}};}function respondWithFilteredResult(_0x34e264,_0x19d9fd){return function(_0x3a1ba1){if(_0x3a1ba1){var _0x56b299=typeof _0x19d9fd[_0x0baf('0x23')]===_0x0baf('0x24')&&typeof _0x19d9fd[_0x0baf('0x25')]===_0x0baf('0x24');var _0x3843b8=_0x3a1ba1[_0x0baf('0x26')];var _0x453525=_0x56b299?0x0:_0x19d9fd['offset'];var _0x1590b4=_0x56b299?_0x3a1ba1[_0x0baf('0x26')]:_0x19d9fd[_0x0baf('0x23')]+_0x19d9fd[_0x0baf('0x25')];var _0x55c715;if(_0x1590b4>=_0x3843b8){_0x1590b4=_0x3843b8;_0x55c715=0xc8;}else{_0x55c715=0xce;}_0x34e264[_0x0baf('0x21')](_0x55c715);return _0x34e264[_0x0baf('0x27')]('Content-Range',_0x453525+'-'+_0x1590b4+'/'+_0x3843b8)[_0x0baf('0x22')](_0x3a1ba1);}return null;};}function saveUpdates(_0x32e4fb){return function(_0x478ce8){if(_0x478ce8){return _0x478ce8[_0x0baf('0x28')](_0x32e4fb)[_0x0baf('0x15')](function(_0x366924){return _0x366924;});}return null;};}function removeEntity(_0x213a6a){return function(_0x57476f){if(_0x57476f){return _0x57476f[_0x0baf('0x29')]()[_0x0baf('0x15')](function(){var _0x37be4e=_0x57476f[_0x0baf('0x2a')]({'plain':!![]});var _0x24ecee=_0x0baf('0x2b');return db[_0x0baf('0x2c')][_0x0baf('0x29')]({'where':{'type':_0x24ecee,'resourceId':_0x37be4e['id']}})[_0x0baf('0x15')](function(){return _0x57476f;});})[_0x0baf('0x15')](function(){_0x213a6a[_0x0baf('0x21')](0xcc)[_0x0baf('0x2d')]();});}};}function handleEntityNotFound(_0x45294a){return function(_0x3a3353){if(!_0x3a3353){_0x45294a['sendStatus'](0x194);}return _0x3a3353;};}function handleError(_0x2fd426,_0x53ae1d){_0x53ae1d=_0x53ae1d||0x1f4;return function(_0x1aa474){logger[_0x0baf('0x1b')](_0x1aa474[_0x0baf('0x2e')]);if(_0x1aa474[_0x0baf('0x2f')]){delete _0x1aa474['name'];}_0x2fd426[_0x0baf('0x21')](_0x53ae1d)[_0x0baf('0x30')](_0x1aa474);};}exports['index']=function(_0x23d890,_0x2447c2){var _0x62a2ed={'include':[{'model':db[_0x0baf('0x31')],'as':_0x0baf('0x32')}]},_0xbaa9a7={},_0x1f60bd={'count':0x0,'rows':[]};var _0x675461=_['map'](db[_0x0baf('0x33')][_0x0baf('0x34')],function(_0x5b991f){return{'name':_0x5b991f[_0x0baf('0x35')],'type':_0x5b991f['type']['key']};});_0xbaa9a7[_0x0baf('0x36')]=_[_0x0baf('0x37')](_0x675461,'name');_0xbaa9a7['query']=_[_0x0baf('0x38')](_0x23d890[_0x0baf('0x39')]);_0xbaa9a7[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0xbaa9a7[_0x0baf('0x36')],_0xbaa9a7[_0x0baf('0x39')]);_0x62a2ed[_0x0baf('0x3c')]=_[_0x0baf('0x3b')](_0xbaa9a7[_0x0baf('0x36')],qs[_0x0baf('0x3d')](_0x23d890[_0x0baf('0x39')][_0x0baf('0x3d')]));_0x62a2ed[_0x0baf('0x3c')]=_0x62a2ed[_0x0baf('0x3c')]['length']?_0x62a2ed[_0x0baf('0x3c')]:_0xbaa9a7[_0x0baf('0x36')];if(!_0x23d890['query'][_0x0baf('0x3e')](_0x0baf('0x3f'))){_0x62a2ed[_0x0baf('0x25')]=qs[_0x0baf('0x25')](_0x23d890[_0x0baf('0x39')][_0x0baf('0x25')]);_0x62a2ed['offset']=qs[_0x0baf('0x23')](_0x23d890[_0x0baf('0x39')]['offset']);}_0x62a2ed[_0x0baf('0x40')]=qs[_0x0baf('0x41')](_0x23d890[_0x0baf('0x39')][_0x0baf('0x41')]);_0x62a2ed['where']=qs[_0x0baf('0x3a')](_[_0x0baf('0x42')](_0x23d890[_0x0baf('0x39')],_0xbaa9a7[_0x0baf('0x3a')]),_0x675461);if(_0x23d890[_0x0baf('0x39')][_0x0baf('0x43')]){_0x62a2ed[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0x62a2ed[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0x675461,function(_0x56270e){if(_0x56270e[_0x0baf('0x46')]!==_0x0baf('0x47')){var _0x1daf1d={};_0x1daf1d[_0x56270e[_0x0baf('0x2f')]]={'$like':'%'+_0x23d890[_0x0baf('0x39')]['filter']+'%'};return _0x1daf1d;}})});}_0x62a2ed=_[_0x0baf('0x45')]({},_0x62a2ed,_0x23d890[_0x0baf('0x48')]);var _0x27c3ee={'where':_0x62a2ed[_0x0baf('0x44')]};return db[_0x0baf('0x33')]['count'](_0x27c3ee)[_0x0baf('0x15')](function(_0x85bedb){_0x1f60bd[_0x0baf('0x26')]=_0x85bedb;if(_0x23d890[_0x0baf('0x39')][_0x0baf('0x49')]){_0x62a2ed[_0x0baf('0x4a')]=[{'all':!![]}];}return db[_0x0baf('0x33')]['findAll'](_0x62a2ed);})[_0x0baf('0x15')](function(_0x167fb8){_0x1f60bd[_0x0baf('0x4b')]=_0x167fb8;return _0x1f60bd;})['then'](respondWithFilteredResult(_0x2447c2,_0x62a2ed))[_0x0baf('0x1f')](handleError(_0x2447c2,null));};exports[_0x0baf('0x4c')]=function(_0x10fa62,_0x3fabec){var _0x204d77={'raw':![],'where':{'id':_0x10fa62[_0x0baf('0x4d')]['id']},'include':[{'model':db['Pause'],'as':_0x0baf('0x32')}]},_0x1b71a3={};_0x1b71a3[_0x0baf('0x36')]=_[_0x0baf('0x38')](db[_0x0baf('0x33')][_0x0baf('0x34')]);_0x1b71a3[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x10fa62[_0x0baf('0x39')]);_0x1b71a3[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x1b71a3[_0x0baf('0x36')],_0x1b71a3['query']);_0x204d77['attributes']=_[_0x0baf('0x3b')](_0x1b71a3[_0x0baf('0x36')],qs[_0x0baf('0x3d')](_0x10fa62[_0x0baf('0x39')][_0x0baf('0x3d')]));_0x204d77[_0x0baf('0x3c')]=_0x204d77[_0x0baf('0x3c')]['length']?_0x204d77[_0x0baf('0x3c')]:_0x1b71a3[_0x0baf('0x36')];if(_0x10fa62[_0x0baf('0x39')][_0x0baf('0x49')]){_0x204d77[_0x0baf('0x4a')]=[{'all':!![]}];}_0x204d77=_[_0x0baf('0x45')]({},_0x204d77,_0x10fa62['options']);return db[_0x0baf('0x33')]['find'](_0x204d77)[_0x0baf('0x15')](handleEntityNotFound(_0x3fabec,null))['then'](respondWithResult(_0x3fabec,null))[_0x0baf('0x1f')](handleError(_0x3fabec,null));};exports['create']=function(_0x35b1a5,_0x4c035b){return db[_0x0baf('0x33')][_0x0baf('0x4e')](_0x35b1a5[_0x0baf('0x4f')],{})[_0x0baf('0x15')](function(_0x42a68b){var _0x576475=_0x35b1a5[_0x0baf('0x50')][_0x0baf('0x2a')]({'plain':!![]});if(!_0x576475)throw new Error(_0x0baf('0x51'));if(_0x576475[_0x0baf('0x52')]===_0x0baf('0x50')){var _0xa19b21=_0x42a68b['get']({'plain':!![]});var _0x402f4d=_0x0baf('0x2b');return db[_0x0baf('0x53')][_0x0baf('0x54')]({'where':{'name':_0x402f4d,'userProfileId':_0x576475[_0x0baf('0x55')]},'raw':!![]})[_0x0baf('0x15')](function(_0x3834a2){if(_0x3834a2&&_0x3834a2['autoAssociation']===0x0){return db['UserProfileResource'][_0x0baf('0x4e')]({'name':_0xa19b21[_0x0baf('0x2f')],'resourceId':_0xa19b21['id'],'type':_0x3834a2[_0x0baf('0x2f')],'sectionId':_0x3834a2['id']},{})[_0x0baf('0x15')](function(){return _0x42a68b;});}else{return _0x42a68b;}})[_0x0baf('0x1f')](function(_0x35221e){logger[_0x0baf('0x1b')](_0x0baf('0x56'),_0x35221e);throw _0x35221e;});}return _0x42a68b;})[_0x0baf('0x15')](respondWithResult(_0x4c035b,0xc9))['catch'](handleError(_0x4c035b,null));};exports[_0x0baf('0x28')]=function(_0x268be8,_0x3c2d03){if(_0x268be8[_0x0baf('0x4f')]['id']){delete _0x268be8[_0x0baf('0x4f')]['id'];}return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x268be8['params']['id']},'include':[{'model':db[_0x0baf('0x31')],'as':_0x0baf('0x32')}]})[_0x0baf('0x15')](handleEntityNotFound(_0x3c2d03,null))[_0x0baf('0x15')](saveUpdates(_0x268be8[_0x0baf('0x4f')],null))[_0x0baf('0x15')](respondWithResult(_0x3c2d03,null))[_0x0baf('0x1f')](handleError(_0x3c2d03,null));};exports[_0x0baf('0x29')]=function(_0x498405,_0x178495){return db['ChatWebsite'][_0x0baf('0x54')]({'where':{'id':_0x498405['params']['id']}})['then'](handleEntityNotFound(_0x178495,null))[_0x0baf('0x15')](removeEntity(_0x178495,null))['catch'](handleError(_0x178495,null));};exports[_0x0baf('0x57')]=function(_0x2b17f8,_0x49d713){return db[_0x0baf('0x33')][_0x0baf('0x57')]()[_0x0baf('0x15')](respondWithResult(_0x49d713,null))['catch'](handleError(_0x49d713,null));};exports['addDisposition']=function(_0x2438df,_0x7e8946){if(_0x2438df[_0x0baf('0x4f')]['id']){delete _0x2438df[_0x0baf('0x4f')]['id'];}return db[_0x0baf('0x33')]['find']({'where':{'id':_0x2438df[_0x0baf('0x4d')]['id']}})['then'](handleEntityNotFound(_0x7e8946,null))['then'](function(_0x59a0b2){if(_0x59a0b2){_0x2438df[_0x0baf('0x4f')]['ChatWebsiteId']=_0x59a0b2['id'];return db['Disposition'][_0x0baf('0x4e')](_0x2438df[_0x0baf('0x4f')]);}})[_0x0baf('0x15')](respondWithResult(_0x7e8946,null))[_0x0baf('0x1f')](handleError(_0x7e8946,null));};exports[_0x0baf('0x58')]=function(_0x27ddc7,_0x4c05d6){var _0xec3b32={'raw':![],'where':{}};var _0x1a0a67={};var _0x185473={'count':0x0,'rows':[]};return db[_0x0baf('0x33')][_0x0baf('0x59')]({'where':{'id':_0x27ddc7[_0x0baf('0x4d')]['id']}})['then'](handleEntityNotFound(_0x4c05d6,null))[_0x0baf('0x15')](function(_0x468363){if(_0x468363){_0x1a0a67[_0x0baf('0x36')]=_['keys'](db[_0x0baf('0x5a')][_0x0baf('0x34')]);_0x1a0a67[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x27ddc7[_0x0baf('0x39')]);_0x1a0a67[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x1a0a67['model'],_0x1a0a67['query']);_0xec3b32['attributes']=_[_0x0baf('0x3b')](_0x1a0a67[_0x0baf('0x36')],qs[_0x0baf('0x3d')](_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x3d')]));_0xec3b32[_0x0baf('0x3c')]=_0xec3b32['attributes']['length']?_0xec3b32[_0x0baf('0x3c')]:_0x1a0a67['model'];if(!_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x3e')]('nolimit')){_0xec3b32[_0x0baf('0x25')]=qs[_0x0baf('0x25')](_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x25')]);_0xec3b32[_0x0baf('0x23')]=qs[_0x0baf('0x23')](_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x23')]);}_0xec3b32[_0x0baf('0x40')]=qs['sort'](_0x27ddc7['query']['sort']);_0xec3b32['where']=qs['filters'](_[_0x0baf('0x42')](_0x27ddc7[_0x0baf('0x39')],_0x1a0a67[_0x0baf('0x3a')]));_0xec3b32[_0x0baf('0x44')]['ChatWebsiteId']=_0x468363['id'];if(_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x43')]){_0xec3b32['where']=_['merge'](_0xec3b32[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0xec3b32[_0x0baf('0x3c')],function(_0x442e5f){var _0x30b35e={};_0x30b35e[_0x442e5f]={'$like':'%'+_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x43')]+'%'};return _0x30b35e;})});}_0xec3b32=_[_0x0baf('0x45')]({},_0xec3b32,_0x27ddc7['options']);return db[_0x0baf('0x5a')][_0x0baf('0x26')]({'where':_0xec3b32['where']})[_0x0baf('0x15')](function(_0x2db4ec){_0x185473['count']=_0x2db4ec;if(_0x27ddc7[_0x0baf('0x39')][_0x0baf('0x49')]){_0xec3b32[_0x0baf('0x4a')]=[{'all':!![]}];}return db[_0x0baf('0x5a')][_0x0baf('0x5b')](_0xec3b32);})['then'](function(_0x4807fc){_0x185473[_0x0baf('0x4b')]=_0x4807fc;return _0x185473;});}})[_0x0baf('0x15')](respondWithFilteredResult(_0x4c05d6,_0xec3b32))['catch'](handleError(_0x4c05d6,null));};exports[_0x0baf('0x5c')]=function(_0x59dad5,_0x21ad25){return db['ChatWebsite'][_0x0baf('0x54')]({'where':{'id':_0x59dad5[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x21ad25,null))['then'](function(_0x3c2bc1){if(_0x3c2bc1){return _0x3c2bc1['removeDispositions'](_0x59dad5[_0x0baf('0x39')][_0x0baf('0x5d')]);}})[_0x0baf('0x15')](respondWithStatusCode(_0x21ad25,null))[_0x0baf('0x1f')](handleError(_0x21ad25,null));};exports[_0x0baf('0x5e')]=function(_0x52e845,_0x866e6e){if(_0x52e845[_0x0baf('0x4f')]['id']){delete _0x52e845['body']['id'];}return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x52e845[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x866e6e,null))[_0x0baf('0x15')](function(_0x250df2){if(_0x250df2){_0x52e845[_0x0baf('0x4f')][_0x0baf('0x5f')]=_0x250df2['id'];return db[_0x0baf('0x60')][_0x0baf('0x4e')](_0x52e845[_0x0baf('0x4f')]);}})[_0x0baf('0x15')](respondWithResult(_0x866e6e,null))['catch'](handleError(_0x866e6e,null));};exports['getAnswers']=function(_0x29a036,_0x322a09){var _0x384c29={'raw':![],'where':{}};var _0x52f267={};var _0x507783={'count':0x0,'rows':[]};return db[_0x0baf('0x33')][_0x0baf('0x59')]({'where':{'id':_0x29a036[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x322a09,null))[_0x0baf('0x15')](function(_0x3033c8){if(_0x3033c8){_0x52f267[_0x0baf('0x36')]=_[_0x0baf('0x38')](db[_0x0baf('0x60')]['rawAttributes']);_0x52f267[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x29a036[_0x0baf('0x39')]);_0x52f267[_0x0baf('0x3a')]=_['intersection'](_0x52f267['model'],_0x52f267['query']);_0x384c29[_0x0baf('0x3c')]=_[_0x0baf('0x3b')](_0x52f267['model'],qs['fields'](_0x29a036[_0x0baf('0x39')][_0x0baf('0x3d')]));_0x384c29['attributes']=_0x384c29[_0x0baf('0x3c')][_0x0baf('0x61')]?_0x384c29[_0x0baf('0x3c')]:_0x52f267[_0x0baf('0x36')];if(!_0x29a036[_0x0baf('0x39')][_0x0baf('0x3e')](_0x0baf('0x3f'))){_0x384c29[_0x0baf('0x25')]=qs[_0x0baf('0x25')](_0x29a036[_0x0baf('0x39')][_0x0baf('0x25')]);_0x384c29[_0x0baf('0x23')]=qs['offset'](_0x29a036[_0x0baf('0x39')][_0x0baf('0x23')]);}_0x384c29[_0x0baf('0x40')]=qs[_0x0baf('0x41')](_0x29a036[_0x0baf('0x39')][_0x0baf('0x41')]);_0x384c29['where']=qs[_0x0baf('0x3a')](_[_0x0baf('0x42')](_0x29a036[_0x0baf('0x39')],_0x52f267[_0x0baf('0x3a')]));_0x384c29[_0x0baf('0x44')]['ChatWebsiteId']=_0x3033c8['id'];if(_0x29a036[_0x0baf('0x39')][_0x0baf('0x43')]){_0x384c29[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0x384c29[_0x0baf('0x44')],{'$or':_['map'](_0x384c29['attributes'],function(_0xb5f4e5){var _0x5a2454={};_0x5a2454[_0xb5f4e5]={'$like':'%'+_0x29a036[_0x0baf('0x39')]['filter']+'%'};return _0x5a2454;})});}_0x384c29=_[_0x0baf('0x45')]({},_0x384c29,_0x29a036[_0x0baf('0x48')]);return db[_0x0baf('0x60')][_0x0baf('0x26')]({'where':_0x384c29['where']})[_0x0baf('0x15')](function(_0x106ffa){_0x507783[_0x0baf('0x26')]=_0x106ffa;if(_0x29a036['query']['includeAll']){_0x384c29['include']=[{'all':!![]}];}return db['CannedAnswer'][_0x0baf('0x5b')](_0x384c29);})[_0x0baf('0x15')](function(_0x2b7f13){_0x507783[_0x0baf('0x4b')]=_0x2b7f13;return _0x507783;});}})['then'](respondWithFilteredResult(_0x322a09,_0x384c29))[_0x0baf('0x1f')](handleError(_0x322a09,null));};exports[_0x0baf('0x62')]=function(_0x1843eb,_0x4b4ef8){return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x1843eb['params']['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x4b4ef8,null))['then'](function(_0x8a0a1b){if(_0x8a0a1b){return _0x8a0a1b[_0x0baf('0x62')](_0x1843eb[_0x0baf('0x39')][_0x0baf('0x5d')]);}})['then'](respondWithStatusCode(_0x4b4ef8,null))['catch'](handleError(_0x4b4ef8,null));};exports[_0x0baf('0x63')]=function(_0x4e1a7e,_0x3b4ae3){_0x4e1a7e[_0x0baf('0x4f')][_0x0baf('0x64')]=_0x4e1a7e[_0x0baf('0x65')][_0x0baf('0x66')];return db['ChatWebsite'][_0x0baf('0x54')]({'where':{'id':_0x4e1a7e['params']['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x3b4ae3,null))['then'](saveUpdates(_0x4e1a7e[_0x0baf('0x4f')],null))['then'](respondWithResult(_0x3b4ae3,null))[_0x0baf('0x1f')](handleError(_0x3b4ae3,null));};exports[_0x0baf('0x67')]=function(_0x443f62,_0x5033f3){_0x443f62['body'][_0x0baf('0x68')]=_0x443f62[_0x0baf('0x65')][_0x0baf('0x66')];return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x443f62[_0x0baf('0x4d')]['id']}})['then'](handleEntityNotFound(_0x5033f3,null))[_0x0baf('0x15')](saveUpdates(_0x443f62['body'],null))[_0x0baf('0x15')](respondWithResult(_0x5033f3,null))['catch'](handleError(_0x5033f3,null));};exports[_0x0baf('0x69')]=function(_0x4df797,_0x30f32b){_0x4df797['body'][_0x0baf('0x6a')]=_0x4df797[_0x0baf('0x65')]['filename'];return db['ChatWebsite'][_0x0baf('0x54')]({'where':{'id':_0x4df797[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x30f32b,null))[_0x0baf('0x15')](saveUpdates(_0x4df797['body'],null))['then'](respondWithResult(_0x30f32b,null))[_0x0baf('0x1f')](handleError(_0x30f32b,null));};exports[_0x0baf('0x6b')]=function(_0x116d52,_0x2c7417){_0x116d52[_0x0baf('0x4f')][_0x0baf('0x6c')]=_0x116d52[_0x0baf('0x65')][_0x0baf('0x66')];return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x116d52['params']['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x2c7417,null))['then'](saveUpdates(_0x116d52[_0x0baf('0x4f')],null))[_0x0baf('0x15')](respondWithResult(_0x2c7417,null))[_0x0baf('0x1f')](handleError(_0x2c7417,null));};exports[_0x0baf('0x6d')]=function(_0x4d7d29,_0x227fbd){var _0x647233=path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],_0x0baf('0x70'));var _0x2c2b77={'where':{'id':_0x4d7d29[_0x0baf('0x4d')]['id']},'attributes':['id',_0x0baf('0x64')],'raw':!![]};var _0xb61593=![];return require('../../config/license/util')[_0x0baf('0x71')]()[_0x0baf('0x15')](function(_0x4d501e){if(_0x4d501e){_0xb61593=_0x4d501e[_0x0baf('0x72')];}})[_0x0baf('0x15')](function(){return db[_0x0baf('0x33')][_0x0baf('0x54')](_0x2c2b77);})[_0x0baf('0x15')](handleEntityNotFound(_0x227fbd,null))[_0x0baf('0x15')](function(_0x3c5654){if(_0x3c5654){if(!_[_0x0baf('0x73')](_0x3c5654[_0x0baf('0x64')])){if(fs['existsSync'](path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],_0x0baf('0x74'),_0x3c5654[_0x0baf('0x64')]))&&_0xb61593){_0x647233=path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],'server/files/images/logos/',_0x3c5654[_0x0baf('0x64')]);}}return _0x227fbd[_0x0baf('0x75')](_0x647233);}})[_0x0baf('0x1f')](handleError(_0x227fbd,null));};exports['getAvatar']=function(_0x49855a,_0x5adbd9){var _0x1adb84=path[_0x0baf('0x6e')](config['root'],_0x0baf('0x76'));var _0x577536={'where':{'id':_0x49855a[_0x0baf('0x4d')]['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db[_0x0baf('0x33')][_0x0baf('0x54')](_0x577536)['then'](handleEntityNotFound(_0x5adbd9,null))[_0x0baf('0x15')](function(_0x290686){if(_0x290686){if(!_[_0x0baf('0x73')](_0x290686[_0x0baf('0x68')])){if(fs[_0x0baf('0x77')](path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],'server/files/images/avatars/',_0x290686[_0x0baf('0x68')]))){_0x1adb84=path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],_0x0baf('0x78'),_0x290686[_0x0baf('0x68')]);}}return _0x5adbd9[_0x0baf('0x75')](_0x1adb84);}})[_0x0baf('0x1f')](handleError(_0x5adbd9,null));};exports[_0x0baf('0x79')]=function(_0x4415c2,_0x46103a){var _0x308b3f=path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],_0x0baf('0x7a'));var _0x59dd6c={'where':{'id':_0x4415c2['params']['id']},'attributes':['id',_0x0baf('0x6a'),_0x0baf('0x7b')],'raw':!![]};return db[_0x0baf('0x33')][_0x0baf('0x54')](_0x59dd6c)['then'](handleEntityNotFound(_0x46103a,null))[_0x0baf('0x15')](function(_0xc6c049){if(_0xc6c049){if(!_[_0x0baf('0x73')](_0xc6c049[_0x0baf('0x6a')])){if(fs[_0x0baf('0x77')](path[_0x0baf('0x6e')](config['root'],_0x0baf('0x78'),_0xc6c049[_0x0baf('0x6a')]))&&_0xc6c049[_0x0baf('0x7b')]){_0x308b3f=path['join'](config[_0x0baf('0x6f')],_0x0baf('0x78'),_0xc6c049[_0x0baf('0x6a')]);}}return _0x46103a['download'](_0x308b3f);}})['catch'](handleError(_0x46103a,null));};exports['getSystemAvatar']=function(_0x11a85a,_0x51c895){var _0x2f0104=path[_0x0baf('0x6e')](config['root'],_0x0baf('0x7c'));var _0x5b5cd5={'where':{'id':_0x11a85a['params']['id']},'attributes':['id',_0x0baf('0x6c')],'raw':!![]};return db['ChatWebsite'][_0x0baf('0x54')](_0x5b5cd5)['then'](handleEntityNotFound(_0x51c895,null))['then'](function(_0x56c377){if(_0x56c377){if(!_[_0x0baf('0x73')](_0x56c377[_0x0baf('0x6c')])){if(fs[_0x0baf('0x77')](path[_0x0baf('0x6e')](config[_0x0baf('0x6f')],_0x0baf('0x78'),_0x56c377[_0x0baf('0x6c')]))){_0x2f0104=path['join'](config[_0x0baf('0x6f')],_0x0baf('0x78'),_0x56c377[_0x0baf('0x6c')]);}}return _0x51c895['download'](_0x2f0104);}})[_0x0baf('0x1f')](handleError(_0x51c895,null));};exports[_0x0baf('0x7d')]=function(_0x12311d,_0x52c7f7){var _0x25eccd=require('user-agent-parser');var _0x235bd5=new _0x25eccd();var _0x12ff07=_0x235bd5['setUA'](_0x12311d[_0x0baf('0x7e')][_0x0baf('0x7f')])[_0x0baf('0x80')]();var _0x1805ff={'body':_0x12311d['body'],'channel':_0x0baf('0x81')};var _0x39eb13=[];var _0x4d4eab=[];var _0x5054f9={};var _0x1ac8eb=![];return db[_0x0baf('0x82')][_0x0baf('0x57')]()[_0x0baf('0x15')](function(_0x4d4a7f){if(!_0x4d4a7f){throw new db['Sequelize'][(_0x0baf('0x83'))](_0x0baf('0x84'));}_0x39eb13=_[_0x0baf('0x85')](_[_0x0baf('0x38')](_0x4d4a7f),[_0x0baf('0x86'),'updatedAt']);_0x4d4eab=_[_0x0baf('0x85')](_[_0x0baf('0x38')](_0x4d4a7f),['createdAt',_0x0baf('0x87'),_0x0baf('0x88'),'ListId']);if(_0x12311d[_0x0baf('0x4f')]['id']){delete _0x12311d[_0x0baf('0x4f')]['id'];}if(_[_0x0baf('0x73')](_0x12311d[_0x0baf('0x4f')][_0x0baf('0x89')])){throw new db[(_0x0baf('0x8a'))][(_0x0baf('0x83'))](_0x0baf('0x8b'));}if(_['isNil'](_0x12311d[_0x0baf('0x4f')][_0x0baf('0x4f')])||_0x12311d[_0x0baf('0x4f')][_0x0baf('0x4f')]===''){throw new db['Sequelize'][(_0x0baf('0x83'))](_0x0baf('0x8c'));}if(_['isNil'](_0x12311d[_0x0baf('0x4f')][_0x0baf('0x8d')])){throw new db[(_0x0baf('0x8a'))][(_0x0baf('0x83'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4d4eab);}if(!_[_0x0baf('0x8e')](_0x4d4eab,_0x12311d[_0x0baf('0x4f')][_0x0baf('0x8d')])){throw new db[(_0x0baf('0x8a'))][(_0x0baf('0x83'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4d4eab);}_0x5054f9[_0x12311d[_0x0baf('0x4f')][_0x0baf('0x8d')]]=_0x12311d[_0x0baf('0x4f')]['from'];})[_0x0baf('0x15')](function(){return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x12311d[_0x0baf('0x4d')]['id']},'include':[{'model':db[_0x0baf('0x8f')],'as':'List','include':[{'model':db['CmContact'],'as':_0x0baf('0x90'),'where':_0x5054f9,'limit':0x1,'order':[[_0x0baf('0x87'),_0x0baf('0x91')]]}]},{'model':db['ChatApplication'],'as':_0x0baf('0x92')}]});})[_0x0baf('0x15')](handleEntityNotFound(_0x52c7f7,null))[_0x0baf('0x15')](function(_0x3cfb49){if(_0x3cfb49&&_0x3cfb49[_0x0baf('0x93')]){_0x1805ff[_0x0baf('0x94')]=_0x3cfb49;_0x1805ff[_0x0baf('0x95')]=_0x3cfb49[_0x0baf('0x92')];_0x1805ff[_0x0baf('0x96')]=_0x3cfb49[_0x0baf('0x93')];_0x1805ff['applications']=_[_0x0baf('0x97')](_0x1805ff[_0x0baf('0x95')],[_0x0baf('0x98')],[_0x0baf('0x99')]);if(_0x1805ff['account'][_0x0baf('0x92')]){delete _0x1805ff[_0x0baf('0x94')][_0x0baf('0x92')];}if(_0x1805ff['account'][_0x0baf('0x93')]&&_0x1805ff[_0x0baf('0x94')][_0x0baf('0x93')][_0x0baf('0x90')][_0x0baf('0x61')]){return _0x1805ff['account'][_0x0baf('0x93')][_0x0baf('0x90')][0x0];}var _0x53df55=_['defaults'](_0x12311d[_0x0baf('0x4f')],{'firstName':_0x12311d[_0x0baf('0x4f')][_0x0baf('0x89')],'ListId':_0x3cfb49[_0x0baf('0x9a')]});_0x53df55[_0x12311d[_0x0baf('0x4f')][_0x0baf('0x8d')]]=_0x12311d[_0x0baf('0x4f')]['from'];return db['CmContact'][_0x0baf('0x4e')](_0x53df55,{'fields':_0x39eb13,'raw':!![]});}})[_0x0baf('0x15')](handleEntityNotFound(_0x52c7f7,null))[_0x0baf('0x15')](function(_0x47de3f){_0x1805ff[_0x0baf('0x9b')]=_0x47de3f;var _0x3a6bf8=_0x12311d['body'][_0x0baf('0x9c')];if(_0x12311d[_0x0baf('0x7e')]['cf-connecting-ip']){_0x3a6bf8=_0x12311d[_0x0baf('0x7e')][_0x0baf('0x9d')];}else if(_0x12311d[_0x0baf('0x7e')]['x-forwarded-for']){_0x3a6bf8=_[_0x0baf('0x9e')](_0x12311d[_0x0baf('0x7e')][_0x0baf('0x9f')][_0x0baf('0xa0')](','));}if(_0x47de3f){var _0x3021f7={'ContactId':_0x47de3f['id'],'ChatWebsiteId':_0x12311d[_0x0baf('0x4d')]['id'],'from':(_0x47de3f[_0x0baf('0xa1')]||'')+'\x20'+(_0x47de3f['lastName']||''),'customerIp':_0x3a6bf8,'customerPort':_0x12311d[_0x0baf('0x7e')]['x-real-port']?_0x12311d[_0x0baf('0x7e')][_0x0baf('0xa2')]:null,'referer':_0x12311d['body']['referer'],'browserName':_0x12ff07[_0x0baf('0xa3')][_0x0baf('0x2f')]&&_0x12ff07[_0x0baf('0xa3')]['version']?util[_0x0baf('0xa4')](_0x0baf('0xa5'),_0x12ff07[_0x0baf('0xa3')][_0x0baf('0x2f')],_0x12ff07[_0x0baf('0xa3')][_0x0baf('0xa6')]):_0x0baf('0xa7'),'browserVersion':_0x12ff07[_0x0baf('0xa3')]['version']||'unknown','osName':util[_0x0baf('0xa4')](_0x0baf('0xa5'),_0x12ff07['os']['name'],_0x12ff07['os'][_0x0baf('0xa6')]),'osVersion':_0x12ff07['os'][_0x0baf('0xa6')],'deviceModel':_0x12ff07[_0x0baf('0xa8')][_0x0baf('0x36')]&&_0x12ff07[_0x0baf('0xa8')][_0x0baf('0xa9')]?util[_0x0baf('0xa4')]('%s\x20%s\x20%s',_0x12ff07[_0x0baf('0xa8')]['model'],_0x12ff07[_0x0baf('0xa8')][_0x0baf('0xa9')],_0x12ff07['device']['type']):null,'deviceVendor':_0x12ff07[_0x0baf('0xa8')][_0x0baf('0xa9')],'deviceType':_0x12ff07[_0x0baf('0xa8')][_0x0baf('0x46')],'formData':JSON[_0x0baf('0x1a')](_0x12311d[_0x0baf('0x4f')])};var _0x18f7bd={'ChatWebsiteId':_0x12311d['params']['id'],'closed':![]};if(_0x12311d['body']['threadId']){_0x18f7bd[_0x0baf('0xaa')]=_0x12311d['body'][_0x0baf('0xaa')];return db[_0x0baf('0xab')]['find']({'where':_0x18f7bd})['then'](function(_0x40785c){if(_0x40785c){return[_0x40785c,![]];}_0x3021f7[_0x0baf('0xaa')]=_0x12311d[_0x0baf('0x4f')][_0x0baf('0xaa')];_0x3021f7[_0x0baf('0xac')]=_0x12311d['body'][_0x0baf('0xac')];return db[_0x0baf('0xab')][_0x0baf('0x4e')](_0x3021f7)[_0x0baf('0x15')](function(_0xf784df){return[_0xf784df,!![]];});});}_0x18f7bd[_0x0baf('0xad')]=_0x47de3f['id'];if(_0x12311d['body'][_0x0baf('0xae')]&&_0x12311d[_0x0baf('0x4f')][_0x0baf('0xae')]['id']){_0x18f7bd['id']=_0x12311d['body'][_0x0baf('0xae')]['id'];return db[_0x0baf('0xab')]['find']({'where':_0x18f7bd})[_0x0baf('0x15')](function(_0xe93008){if(_0xe93008){return[_0xe93008,![]];}return db[_0x0baf('0xab')][_0x0baf('0x4e')](_0x3021f7)['then'](function(_0x4ffc8e){return[_0x4ffc8e,!![]];});});}return db[_0x0baf('0xab')][_0x0baf('0x4e')](_0x3021f7)['then'](function(_0x43022c){return[_0x43022c,!![]];});}})[_0x0baf('0xaf')](function(_0xcd88a1,_0x13ac02){if(_0xcd88a1){_0x1ac8eb=_0x13ac02;if(!_0x13ac02){var _0x122a1a={'from':(_0x1805ff['contact'][_0x0baf('0xa1')]||'')+'\x20'+(_0x1805ff[_0x0baf('0x9b')][_0x0baf('0xb0')]||'')};if(_0x12311d[_0x0baf('0x4f')]['threadId']&&_0x12311d[_0x0baf('0x4f')]['messageId']&&_0x12311d[_0x0baf('0x4f')][_0x0baf('0xaa')]!=_0x12311d[_0x0baf('0x4f')]['messageId']){_0x122a1a[_0x0baf('0xaa')]=_0x12311d[_0x0baf('0x4f')][_0x0baf('0xb1')];}return _0xcd88a1[_0x0baf('0x28')](_0x122a1a);}else{return _0xcd88a1;}}})[_0x0baf('0x15')](function(_0x2a72b3){_0x1805ff[_0x0baf('0xae')]=_0x2a72b3[_0x0baf('0x2a')]({'plain':!![]});_0x1805ff[_0x0baf('0xae')][_0x0baf('0xb2')]=_0x1ac8eb;if(_0x1805ff[_0x0baf('0xae')][_0x0baf('0xb2')]){if(_0x1805ff['account']['autoclose']){_0x1805ff[_0x0baf('0x95')]['push']({'id':0x0,'priority':_0x1805ff['applications']['length']+0x1,'app':'close','appdata':_0x0baf('0xb3'),'interval':_0x0baf('0xb4')});}}return db['ChatMessage']['create']({'body':_0x12311d['body']['body'],'ChatWebsiteId':_0x12311d[_0x0baf('0x4d')]['id'],'ChatInteractionId':_0x2a72b3['id'],'direction':'in','ContactId':_0x1805ff['contact']['id'],'AttachmentId':_0x12311d[_0x0baf('0x4f')][_0x0baf('0xb5')]});})[_0x0baf('0x15')](function(_0xa1b680){_0x1805ff[_0x0baf('0x1d')]=_0xa1b680;if(_0x1805ff[_0x0baf('0xae')][_0x0baf('0xb6')]){return db[_0x0baf('0xb7')]['find']({'attributes':['id','name'],'where':{'id':_0x1805ff[_0x0baf('0xae')][_0x0baf('0xb6')]}})['then'](function(_0x21a72d){if(_0x21a72d){_0x1805ff['applications'][_0x0baf('0xb8')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x21a72d['name']+','+(_0x1805ff[_0x0baf('0x94')][_0x0baf('0xb9')]||0xa),'interval':_0x0baf('0xb4')});_0x1805ff[_0x0baf('0xba')]=!![];}return respondWithRpcPromise(_0x0baf('0xbb'),_0x0baf('0xbc'),_0x1805ff);});}return respondWithRpcPromise(_0x0baf('0xbb'),_0x0baf('0xbc'),_0x1805ff);})[_0x0baf('0x15')](function(_0x3348c6){respondWithRpcPromise(_0x0baf('0xbd'),_0x0baf('0xbd'),{'event':_0x0baf('0x7d'),'message':_0x3348c6},client9002);return _0x3348c6;})[_0x0baf('0x15')](respondWithResult(_0x52c7f7,null))[_0x0baf('0x1f')](handleError(_0x52c7f7,null));};exports[_0x0baf('0xbe')]=function(_0x5b61ff,_0x3c78ca){var _0x1a016f,_0x5b9e60,_0x9f2b22;var _0x39526b=[];var _0x5ee76f={};var _0x186d83=_0x5b61ff['files']||[];var _0x3f816f=[];var _0x569bbb;return db[_0x0baf('0x82')]['describe']()[_0x0baf('0x15')](function(_0x298cb5){if(!_0x298cb5){throw new db[(_0x0baf('0x8a'))][(_0x0baf('0x83'))]('no\x20available\x20attributes');}_0x39526b=_[_0x0baf('0x85')](_[_0x0baf('0x38')](_0x298cb5),[_0x0baf('0x86'),_0x0baf('0x87'),'CompanyId','ListId']);if(_0x5b61ff[_0x0baf('0x4f')]['id']){delete _0x5b61ff[_0x0baf('0x4f')]['id'];}if(_[_0x0baf('0x73')](_0x5b61ff[_0x0baf('0x4f')]['from'])){throw _0x3c78ca[_0x0baf('0x21')](0x1f4)[_0x0baf('0x30')](new db[(_0x0baf('0x8a'))]['ValidationError']('from\x20is\x20mandatory'));}if(_[_0x0baf('0x73')](_0x5b61ff['body'][_0x0baf('0x4f')])||_0x5b61ff['body'][_0x0baf('0x4f')]===''){throw _0x3c78ca[_0x0baf('0x21')](0x1f4)[_0x0baf('0x30')](new db['Sequelize'][(_0x0baf('0x83'))](_0x0baf('0x8c')));}if(_['isNil'](_0x5b61ff['body'][_0x0baf('0xbf')])){throw _0x3c78ca['status'](0x1f4)[_0x0baf('0x30')](new db[(_0x0baf('0x8a'))]['ValidationError']('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x39526b));}if(!_[_0x0baf('0x8e')](_0x39526b,_0x5b61ff[_0x0baf('0x4f')]['mapKeyOffline'])){throw _0x3c78ca[_0x0baf('0x21')](0x1f4)['send'](new db[(_0x0baf('0x8a'))][(_0x0baf('0x83'))]('mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x39526b));}_0x5ee76f[_0x5b61ff[_0x0baf('0x4f')][_0x0baf('0xbf')]]=_0x5b61ff[_0x0baf('0x4f')][_0x0baf('0x89')];})[_0x0baf('0x15')](function(){return db['ChatWebsite'][_0x0baf('0x54')]({'where':{'id':_0x5b61ff['params']['id']},'include':[{'model':db['CmList'],'as':'List'},{'model':db[_0x0baf('0xc0')],'as':_0x0baf('0xc0')}]});})['then'](handleEntityNotFound(_0x3c78ca,null))[_0x0baf('0x15')](function(_0x58e1ae){if(_0x58e1ae&&_0x58e1ae['List']){_0x5b9e60=_0x58e1ae;var _0x30a982=_[_0x0baf('0xd')](_0x5b61ff[_0x0baf('0x4f')],{'firstName':_0x5b61ff[_0x0baf('0x4f')][_0x0baf('0x89')],'phone':_0x5b61ff[_0x0baf('0x4f')][_0x0baf('0x89')],'ListId':_0x58e1ae[_0x0baf('0x9a')]});_0x30a982[_0x5b61ff[_0x0baf('0x4f')][_0x0baf('0xbf')]]=_0x5b61ff['body'][_0x0baf('0x89')];return db[_0x0baf('0x82')][_0x0baf('0xc1')]({'where':_0x5ee76f,'defaults':_0x30a982});}})[_0x0baf('0xaf')](function(_0x1d1ed6){if(_0x1d1ed6){_0x9f2b22=_0x1d1ed6;var _0x57b26e=fs[_0x0baf('0xc2')](path['join'](config[_0x0baf('0x6f')],_0x0baf('0xc3')),_0x0baf('0xc4'));var _0x44f822=ejs[_0x0baf('0xc5')](_0x57b26e,{'body':_[_0x0baf('0xc6')](_0x5b61ff[_0x0baf('0x4f')]['body']),'bodyTitle':_0x5b9e60[_0x0baf('0xc7')]});return db[_0x0baf('0xc8')][_0x0baf('0x4e')]({'body':_0x44f822,'plainBody':htmlToText[_0x0baf('0xc9')](_0x44f822),'ContactId':_0x1d1ed6['id'],'ChatWebsiteId':_0x5b9e60['id']});}})[_0x0baf('0x15')](function(_0x130ad1){_0x569bbb=_0x130ad1;if(_0x186d83[_0x0baf('0x61')]){var _0x17ef4f=_0x186d83[_0x0baf('0x37')](function(_0x1ee4c7){return{'name':_0x1ee4c7[_0x0baf('0xca')],'basename':_0x1ee4c7[_0x0baf('0x66')],'type':_0x1ee4c7[_0x0baf('0xcb')],'ChatOfflineMessageId':_0x130ad1['id']};});_0x3f816f=_0x17ef4f[_0x0baf('0x37')](_0x37430c=>{var _0x3fffe8={'filename':_0x37430c[_0x0baf('0x2f')],'path':path[_0x0baf('0x6e')](config['root'],_0x0baf('0xcc'),_0x0baf('0xcd'),_0x0baf('0xce'),_0x0baf('0xcf'),_0x37430c[_0x0baf('0xd0')])};return _0x3fffe8;});if(!_0x5b9e60[_0x0baf('0xd1')]){return db[_0x0baf('0xd2')]['transaction'](function(_0xa7a73a){return db[_0x0baf('0xd3')][_0x0baf('0xd4')](_0x17ef4f,{'transaction':_0xa7a73a});});}}})[_0x0baf('0x15')](function(){if(_0x569bbb){_0x1a016f=_0x569bbb;return db[_0x0baf('0xc0')][_0x0baf('0x59')]({'where':{'active':!![]},'include':[{'model':db[_0x0baf('0xd5')],'as':'Smtp','raw':!![]}]});}})[_0x0baf('0x15')](function(_0x17b3a9){if(_0x17b3a9&&_0x17b3a9[_0x0baf('0xd6')]&&_0x5b9e60[_0x0baf('0xd7')]&&_0x5b9e60[_0x0baf('0xd8')]){var _0x1912ff={'tls':{'rejectUnauthorized':![]}};if(_0x17b3a9['Smtp'][_0x0baf('0xd9')]){_0x1912ff[_0x0baf('0xd9')]=_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0xd9')];}else{_0x1912ff[_0x0baf('0xda')]=_0x17b3a9['Smtp']['host'];_0x1912ff[_0x0baf('0xdb')]=_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0xdb')];_0x1912ff[_0x0baf('0xdc')]=_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0xdc')];}if(_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0xdd')]){_0x1912ff[_0x0baf('0xde')]={'user':_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0x50')],'pass':_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0xdf')]};}return respondWithRpcPromise(_0x0baf('0xe0'),_0x0baf('0xe1'),{'account':_0x1912ff,'message':{'from':util[_0x0baf('0xa4')](_0x0baf('0xe2'),_0x17b3a9[_0x0baf('0x2f')],_0x17b3a9[_0x0baf('0xe3')]||_0x17b3a9[_0x0baf('0xd6')][_0x0baf('0x50')]),'to':_0x5b9e60[_0x0baf('0xd8')],'subject':_0x5b9e60[_0x0baf('0xe4')],'html':_0x1a016f[_0x0baf('0x4f')],'attachments':_0x3f816f}},client9003)[_0x0baf('0x15')](function(){return _0x1a016f;})[_0x0baf('0x1f')](function(_0x1d4581){console['error'](_0x1d4581);});}})[_0x0baf('0x15')](function(){if(_0x5b9e60&&_0x5b9e60[_0x0baf('0xd1')]&&_0x5b9e60[_0x0baf('0xe5')]){var _0x14a397=[];if(_0x186d83[_0x0baf('0x61')]){_0x14a397=_0x186d83['map'](function(_0x3e3fba){return{'name':_0x3e3fba[_0x0baf('0xca')],'basename':_0x3e3fba[_0x0baf('0x66')],'type':_0x3e3fba[_0x0baf('0xcb')],'ChatOfflineMessageId':_0x569bbb['id']};});}var _0x1db841;if(!_[_0x0baf('0x73')](_0x5b9e60[_0x0baf('0xe6')])){var _0x237a20=_[_0x0baf('0x37')](_0x5b61ff[_0x0baf('0x4f')],function(_0xe840f2){return _0xe840f2;});var _0x12726d=_[_0x0baf('0xe7')](_0x237a20)[0x0];var _0x1b2278=_[_0x0baf('0xe8')](_0x12726d,function(_0x221aac){return _0x221aac;});_0x1db841=_0x1b2278[0x1][_0x5b9e60[_0x0baf('0xe6')]];}var _0x3e970a={'from':_0x9f2b22['email'],'firstName':_0x9f2b22[_0x0baf('0xa1')],'lastName':_0x9f2b22['lastName'],'mapKey':'email','message':{'from':_0x9f2b22[_0x0baf('0xe3')],'to':_0x5b9e60[_0x0baf('0xc0')][_0x0baf('0xe3')],'cc':'','subject':_['isNil'](_0x1db841)?_0x5b9e60[_0x0baf('0xe4')]:_0x1db841,'messageId':'','sentAt':new Date(),'attach':_0x14a397[_0x0baf('0x61')],'attachments':_0x14a397,'originChannel':_0x0baf('0xe9'),'ChatWebsiteId':_0x5b9e60['id'],'ChatOfflineMessageId':_0x1a016f['id'],'originTo':_0x5b9e60[_0x0baf('0xc0')][_0x0baf('0xe3')]},'body':_0x1a016f[_0x0baf('0x4f')]};var _0x49543e={'account':{'id':_0x5b9e60[_0x0baf('0xe5')]},'body':_0x3e970a,'log':_0x0baf('0xea')};return respondWithRpcPromise(_0x0baf('0xea'),_0x0baf('0xeb'),_0x49543e,client9001)[_0x0baf('0x15')](function(){return _0x1a016f;})[_0x0baf('0x1f')](function(_0x4c2bae){console[_0x0baf('0x1b')](_0x4c2bae);});}return;})['then'](function(){if(_0x1a016f){return _0x1a016f;}})[_0x0baf('0x15')](respondWithResult(_0x3c78ca,null))[_0x0baf('0x1f')](function(_0x47b168){console['error'](_0x0baf('0x1f'),_0x47b168);for(var _0x1de1dd of _0x186d83){var _0xf4da6a=path['join'](config[_0x0baf('0x6f')],_0x0baf('0xcc'),'files',_0x0baf('0xce'),_0x0baf('0xcf'),_0x1de1dd[_0x0baf('0x66')]);fs_extra[_0x0baf('0xec')](_0xf4da6a)[_0x0baf('0x1f')](function(_0x2759bb){console[_0x0baf('0x1b')]('Could\x20not\x20remove\x20attachment\x20file',_0xf4da6a,_0x2759bb);});}});};exports['addInteraction']=function(_0x131573,_0x1bd67f){return db[_0x0baf('0xab')][_0x0baf('0x54')]({'where':{'id':_0x131573[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x1bd67f,null))[_0x0baf('0x15')](function(_0x4316c5){if(_0x4316c5){return _0x4316c5[_0x0baf('0xed')](_0x131573[_0x0baf('0x4f')]['ids'],_['omit'](_0x131573[_0x0baf('0x4f')],[_0x0baf('0x5d'),'id'])||{});}})[_0x0baf('0x15')](respondWithResult(_0x1bd67f,null))['catch'](handleError(_0x1bd67f,null));};exports['getInteractions']=function(_0x3d740a,_0x2cb735){var _0xf82eb5={'raw':![],'where':{}};var _0x197bbe={};var _0x4a6a50={'count':0x0,'rows':[]};return db[_0x0baf('0x33')][_0x0baf('0x59')]({'where':{'id':_0x3d740a[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x2cb735,null))[_0x0baf('0x15')](function(_0x120c18){if(_0x120c18){_0x197bbe[_0x0baf('0x36')]=_[_0x0baf('0x38')](db['ChatInteraction'][_0x0baf('0x34')]);_0x197bbe[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x3d740a[_0x0baf('0x39')]);_0x197bbe[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x197bbe['model'],_0x197bbe[_0x0baf('0x39')]);_0xf82eb5[_0x0baf('0x3c')]=_['intersection'](_0x197bbe['model'],qs[_0x0baf('0x3d')](_0x3d740a['query'][_0x0baf('0x3d')]));_0xf82eb5[_0x0baf('0x3c')]=_0xf82eb5[_0x0baf('0x3c')][_0x0baf('0x61')]?_0xf82eb5['attributes']:_0x197bbe[_0x0baf('0x36')];if(!_0x3d740a[_0x0baf('0x39')][_0x0baf('0x3e')]('nolimit')){_0xf82eb5[_0x0baf('0x25')]=qs[_0x0baf('0x25')](_0x3d740a['query'][_0x0baf('0x25')]);_0xf82eb5['offset']=qs[_0x0baf('0x23')](_0x3d740a[_0x0baf('0x39')][_0x0baf('0x23')]);}_0xf82eb5[_0x0baf('0x40')]=qs['sort'](_0x3d740a[_0x0baf('0x39')][_0x0baf('0x41')]);_0xf82eb5['where']=qs[_0x0baf('0x3a')](_[_0x0baf('0x42')](_0x3d740a['query'],_0x197bbe[_0x0baf('0x3a')]));_0xf82eb5[_0x0baf('0x44')]['ChatWebsiteId']=_0x120c18['id'];if(_0x3d740a[_0x0baf('0x39')][_0x0baf('0x43')]){_0xf82eb5[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0xf82eb5[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0xf82eb5['attributes'],function(_0x181385){var _0x120f68={};_0x120f68[_0x181385]={'$like':'%'+_0x3d740a[_0x0baf('0x39')][_0x0baf('0x43')]+'%'};return _0x120f68;})});}_0xf82eb5=_[_0x0baf('0x45')]({},_0xf82eb5,_0x3d740a[_0x0baf('0x48')]);return db[_0x0baf('0xab')][_0x0baf('0x26')]({'where':_0xf82eb5[_0x0baf('0x44')]})[_0x0baf('0x15')](function(_0x72e44c){_0x4a6a50[_0x0baf('0x26')]=_0x72e44c;if(_0x3d740a[_0x0baf('0x39')][_0x0baf('0x49')]){_0xf82eb5[_0x0baf('0x4a')]=[{'model':db[_0x0baf('0x82')],'as':_0x0baf('0xee'),'required':![]},{'model':db[_0x0baf('0xb7')],'as':_0x0baf('0xef'),'attributes':[_0x0baf('0x2f'),_0x0baf('0xf0'),_0x0baf('0xf1')],'required':![]},{'model':db['Tag'],'as':_0x0baf('0xf2'),'attributes':['id',_0x0baf('0x2f'),'color'],'where':_0x3d740a['query']['tag']?{'id':_0x3d740a[_0x0baf('0x39')]['tag']}:undefined,'required':_0x3d740a['query']['tag']?!![]:![]}];}return db[_0x0baf('0xab')][_0x0baf('0x5b')](_0xf82eb5);})[_0x0baf('0x15')](function(_0x5ab269){_0x4a6a50[_0x0baf('0x4b')]=_0x5ab269;return _0x4a6a50;});}})['then'](respondWithFilteredResult(_0x2cb735,_0xf82eb5))['catch'](handleError(_0x2cb735,null));};function iftimePromise(_0x743f4b,_0xc93c2b){return respondWithRpcPromise(_0x0baf('0xf3'),'getSnippet',{'command':_0xc93c2b['timezone']?util[_0x0baf('0xa4')](_0x0baf('0xf4'),_0x743f4b[_0x0baf('0xf5')],_0xc93c2b[_0x0baf('0xf6')]):util[_0x0baf('0xa4')](_0x0baf('0xf7'),_0x743f4b['interval'])},client9002)['then'](function(_0x217cd8){var _0x21e3b1=_0x217cd8&&_0x217cd8['indexOf'](_0x0baf('0xf8'))>=0x0?!![]:![];logger[_0x0baf('0x16')](_0x0baf('0xf9'),_0xc93c2b['id'],_0x743f4b['id'],_0x743f4b[_0x0baf('0xf5')],_0x21e3b1?'ONLINE':_0x0baf('0xfa'),_0xc93c2b['timezone']?_0xc93c2b['timezone']:_0x0baf('0xfb'));return _0x21e3b1;})['catch'](function(_0x4a0f32){logger[_0x0baf('0x1b')](_0x0baf('0xf9'),_0xc93c2b['id'],_0x743f4b['id'],_0x743f4b['interval'],util[_0x0baf('0xfc')](_0x4a0f32,{'showHidden':![],'depth':null}),_0xc93c2b[_0x0baf('0xf6')]?_0xc93c2b[_0x0baf('0xf6')]:_0x0baf('0xfb'));return![];});}exports[_0x0baf('0xfd')]=function(_0x1ad92d,_0x532e4b){var _0x395ad5=0x0;var _0x47fcb1=0x0;var _0x2a4997=![];var _0x2997b3;var _0x4e0fc6;return db['ChatWebsite'][_0x0baf('0x54')]({'where':{'id':_0x1ad92d[_0x0baf('0x4d')]['id']},'include':[{'model':db['Interval'],'as':_0x0baf('0xfe'),'include':[{'model':db[_0x0baf('0xfe')],'as':_0x0baf('0xff'),'attributes':['id',_0x0baf('0xf5')],'raw':!![]}]}]})[_0x0baf('0x15')](handleEntityNotFound(_0x532e4b,null))[_0x0baf('0x15')](function(_0x20f37b){if(_0x20f37b){_0x2997b3=_0x20f37b;return _0x20f37b[_0x0baf('0x100')]({'raw':!![]});}})['then'](function(_0x3f136e){if(_0x2997b3){if(_0x3f136e){_0x4e0fc6=_0x3f136e;}}return require(_0x0baf('0x101'))['getLicense']();})['then'](function(_0x276d39){if(_0x276d39){_0x47fcb1=_0x276d39[_0x0baf('0x102')];_0x2a4997=_0x276d39['custom'];}})[_0x0baf('0x15')](function(){return db[_0x0baf('0xab')]['count']({'where':{'closed':![]}});})[_0x0baf('0x15')](function(_0x47825b){_0x395ad5=_0x47825b;if(_0x47fcb1&&_0x47825b>_0x47fcb1){return db[_0x0baf('0x103')][_0x0baf('0x59')]({'where':{'id':0x1}})[_0x0baf('0x15')](function(_0x9f5f16){if(_0x9f5f16){_0x9f5f16[_0x0baf('0x104')](_0x0baf('0x105'));}});}})[_0x0baf('0x15')](function(){if(_0x2997b3['Interval']&&_0x2997b3[_0x0baf('0xfe')][_0x0baf('0xff')]){var _0x547a10=[];for(var _0x4ef69a=0x0;_0x4ef69a<_0x2997b3[_0x0baf('0xfe')]['Intervals'][_0x0baf('0x61')];_0x4ef69a++){var _0x3752fd=_0x2997b3[_0x0baf('0xfe')][_0x0baf('0xff')][_0x4ef69a][_0x0baf('0x2a')]({'plain':!![]});_0x547a10[_0x0baf('0x106')](iftimePromise(_0x3752fd,_0x2997b3));}return BPromise[_0x0baf('0x107')](_0x547a10)[_0x0baf('0x15')](function(_0x148b9a){return _['some'](_0x148b9a);});}else{return!![];}})[_0x0baf('0x15')](function(_0x6721e9){var _0x2d4336=fs[_0x0baf('0xc2')](path['join'](config[_0x0baf('0x6f')],_0x0baf('0x108')),_0x0baf('0xc4'));var _0x550db0={'remote':_0x2997b3[_0x0baf('0x109')],'query':querystring[_0x0baf('0x1a')](_[_0x0baf('0x45')](_0x2997b3[_0x0baf('0x2a')]({'plain':!![]}),{'customerIp':_0x1ad92d['headers'][_0x0baf('0x9f')]||_0x1ad92d[_0x0baf('0x7e')]['x-real-ip']||_0x1ad92d['connection']['remoteAddress']||_0x1ad92d['ip'],'referer':_0x1ad92d[_0x0baf('0x7e')][_0x0baf('0x10a')],'openedInteractions':_0x395ad5,'maxInteractions':_0x47fcb1,'virtual':_0x2a4997[_0x0baf('0x102')],'online':_0x6721e9,'custom':_0x2a4997}))['replace'](/'/g,'\x5c\x27')};_0x532e4b[_0x0baf('0x30')](ejs[_0x0baf('0xc5')](Mustache[_0x0baf('0xc5')](_0x2d4336,_0x550db0),{'proactiveActions':_0x4e0fc6,'alignment':_0x2997b3[_0x0baf('0x10b')],'verticalAlignment':_0x2997b3[_0x0baf('0x10c')],'div_color':_0x2997b3['color'],'labelText':_0x2997b3[_0x0baf('0x10d')],'text_color':_0x2997b3[_0x0baf('0x10e')],'button_color':_0x2997b3[_0x0baf('0x10f')],'background_color':_0x2997b3[_0x0baf('0x110')]}));})[_0x0baf('0x1f')](handleError(_0x532e4b,null));};exports[_0x0baf('0x111')]=function(_0x5ab670,_0x4c4ffe){var _0x181980=_0x5ab670[_0x0baf('0x4d')]['id'];var _0x313e3e=_0x5ab670[_0x0baf('0x4f')];var _0x1cf4b5=0xc8;var _0x5d1985=null;return db[_0x0baf('0xd2')][_0x0baf('0x112')]({'isolationLevel':db[_0x0baf('0xd2')]['Transaction'][_0x0baf('0x113')][_0x0baf('0x114')]},function(_0x1e10a4){return db[_0x0baf('0x33')]['findOne']({'where':{'id':_0x181980},'transaction':_0x1e10a4})[_0x0baf('0x15')](function(_0x4d6e8e){if(_0x4d6e8e){return db[_0x0baf('0x115')][_0x0baf('0x29')]({'where':{'ChatWebsiteId':_0x181980},'transaction':_0x1e10a4})[_0x0baf('0x15')](function(){var _0x594a08=_['map'](_0x313e3e,function(_0x45e0ec){_0x45e0ec[_0x0baf('0x5f')]=_0x181980;return _0x45e0ec;});return db[_0x0baf('0x115')][_0x0baf('0xd4')](_0x594a08,{'transaction':_0x1e10a4});});}else{_0x1cf4b5=0x194;_0x5d1985=[];}});})['then'](function(){if(_0x1cf4b5!==0x194){return db['ChatApplication']['findAndCountAll']({'where':{'ChatWebsiteId':_0x181980},'order':_0x0baf('0x98')})[_0x0baf('0x15')](function(_0x46171d){_0x5d1985=_0x46171d;});}})['catch'](function(_0x2ba54d){_0x1cf4b5=0x1f4;logger[_0x0baf('0x1b')](_0x2ba54d[_0x0baf('0x2e')]);if(_0x2ba54d['name']){delete _0x2ba54d[_0x0baf('0x2f')];}_0x5d1985=_0x2ba54d;})[_0x0baf('0x116')](function(){if(_0x5d1985===null){_0x4c4ffe[_0x0baf('0x20')](_0x1cf4b5);}else{if(_0x1cf4b5===0x1f4){_0x4c4ffe['status'](_0x1cf4b5)['send'](_0x5d1985);}else{_0x4c4ffe['status'](_0x1cf4b5)['json'](_0x5d1985);}}});};exports[_0x0baf('0x117')]=function(_0x1c8b91,_0x3124bc){var _0x5ba16f={};var _0xcbc041={};var _0x5b1808;var _0x1abba8;return db[_0x0baf('0x33')]['findOne']({'where':{'id':_0x1c8b91['params']['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x3124bc,null))[_0x0baf('0x15')](function(_0xc0952d){if(_0xc0952d){_0x5b1808=_0xc0952d;_0xcbc041['model']=_[_0x0baf('0x38')](db[_0x0baf('0x115')]['rawAttributes']);_0xcbc041['query']=_[_0x0baf('0x38')](_0x1c8b91[_0x0baf('0x39')]);_0xcbc041[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0xcbc041[_0x0baf('0x36')],_0xcbc041[_0x0baf('0x39')]);_0x5ba16f[_0x0baf('0x3c')]=_[_0x0baf('0x3b')](_0xcbc041[_0x0baf('0x36')],qs[_0x0baf('0x3d')](_0x1c8b91[_0x0baf('0x39')][_0x0baf('0x3d')]));_0x5ba16f[_0x0baf('0x3c')]=_0x5ba16f[_0x0baf('0x3c')][_0x0baf('0x61')]?_0x5ba16f['attributes']:_0xcbc041[_0x0baf('0x36')];_0x5ba16f[_0x0baf('0x40')]=qs[_0x0baf('0x41')](_0x1c8b91['query']['sort']);_0x5ba16f[_0x0baf('0x44')]=qs[_0x0baf('0x3a')](_[_0x0baf('0x42')](_0x1c8b91[_0x0baf('0x39')],_0xcbc041[_0x0baf('0x3a')]));if(_0x1c8b91[_0x0baf('0x39')][_0x0baf('0x43')]){_0x5ba16f[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0x5ba16f[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0x5ba16f[_0x0baf('0x3c')],function(_0x4306bb){var _0x2c2d4b={};_0x2c2d4b[_0x4306bb]={'$like':'%'+_0x1c8b91[_0x0baf('0x39')]['filter']+'%'};return _0x2c2d4b;})});}_0x5ba16f=_[_0x0baf('0x45')]({},_0x5ba16f,_0x1c8b91[_0x0baf('0x48')]);return _0x5b1808[_0x0baf('0x117')](_0x5ba16f);}})[_0x0baf('0x15')](function(_0x4056b6){if(_0x4056b6){_0x1abba8=_0x4056b6[_0x0baf('0x61')];if(!_0x1c8b91[_0x0baf('0x39')]['hasOwnProperty']('nolimit')){_0x5ba16f[_0x0baf('0x25')]=qs['limit'](_0x1c8b91['query'][_0x0baf('0x25')]);_0x5ba16f['offset']=qs[_0x0baf('0x23')](_0x1c8b91[_0x0baf('0x39')][_0x0baf('0x23')]);}return _0x5b1808[_0x0baf('0x117')](_0x5ba16f);}})[_0x0baf('0x15')](function(_0x2a02e6){if(_0x2a02e6){return _0x2a02e6?{'count':_0x1abba8,'rows':_0x2a02e6}:null;}})[_0x0baf('0x15')](respondWithResult(_0x3124bc,null))[_0x0baf('0x1f')](handleError(_0x3124bc,null));};exports['addProactiveActions']=function(_0x4bcc76,_0xae7f71){return db[_0x0baf('0x118')][_0x0baf('0x54')]({'where':{'id':_0x4bcc76[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0xae7f71,null))['then'](function(_0x123037){if(_0x123037){return _0x123037[_0x0baf('0x119')](_0x4bcc76[_0x0baf('0x4f')][_0x0baf('0x5d')],_[_0x0baf('0x11a')](_0x4bcc76[_0x0baf('0x4f')],[_0x0baf('0x5d'),'id'])||{});}})[_0x0baf('0x15')](respondWithResult(_0xae7f71,null))[_0x0baf('0x1f')](handleError(_0xae7f71,null));};exports[_0x0baf('0x100')]=function(_0x238649,_0x30ef34){var _0x43c6a6={};var _0x2448dd={};var _0x4a999b;var _0x165555;return db[_0x0baf('0x33')][_0x0baf('0x59')]({'where':{'id':_0x238649[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x30ef34,null))['then'](function(_0x2723ea){if(_0x2723ea){_0x4a999b=_0x2723ea;_0x2448dd[_0x0baf('0x36')]=_[_0x0baf('0x38')](db['ChatProactiveAction']['rawAttributes']);_0x2448dd[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x238649['query']);_0x2448dd[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x2448dd['model'],_0x2448dd[_0x0baf('0x39')]);_0x43c6a6[_0x0baf('0x3c')]=_[_0x0baf('0x3b')](_0x2448dd[_0x0baf('0x36')],qs[_0x0baf('0x3d')](_0x238649[_0x0baf('0x39')][_0x0baf('0x3d')]));_0x43c6a6['attributes']=_0x43c6a6['attributes'][_0x0baf('0x61')]?_0x43c6a6['attributes']:_0x2448dd[_0x0baf('0x36')];_0x43c6a6[_0x0baf('0x40')]=qs[_0x0baf('0x41')](_0x238649['query'][_0x0baf('0x41')]);_0x43c6a6[_0x0baf('0x44')]=qs['filters'](_[_0x0baf('0x42')](_0x238649[_0x0baf('0x39')],_0x2448dd[_0x0baf('0x3a')]));if(_0x238649[_0x0baf('0x39')][_0x0baf('0x43')]){_0x43c6a6[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0x43c6a6[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0x43c6a6['attributes'],function(_0x2739c7){var _0x1bea85={};_0x1bea85[_0x2739c7]={'$like':'%'+_0x238649['query']['filter']+'%'};return _0x1bea85;})});}_0x43c6a6=_[_0x0baf('0x45')]({},_0x43c6a6,_0x238649[_0x0baf('0x48')]);return _0x4a999b[_0x0baf('0x100')](_0x43c6a6);}})[_0x0baf('0x15')](function(_0x34d2db){if(_0x34d2db){_0x165555=_0x34d2db['length'];if(!_0x238649['query'][_0x0baf('0x3e')]('nolimit')){_0x43c6a6[_0x0baf('0x25')]=qs['limit'](_0x238649[_0x0baf('0x39')][_0x0baf('0x25')]);_0x43c6a6[_0x0baf('0x23')]=qs['offset'](_0x238649[_0x0baf('0x39')][_0x0baf('0x23')]);}return _0x4a999b[_0x0baf('0x100')](_0x43c6a6);}})['then'](function(_0xb3a031){if(_0xb3a031){return _0xb3a031?{'count':_0x165555,'rows':_0xb3a031}:null;}})[_0x0baf('0x15')](respondWithResult(_0x30ef34,null))[_0x0baf('0x1f')](handleError(_0x30ef34,null));};exports[_0x0baf('0x11b')]=function(_0x3597fe,_0x132995){var _0x12c4bf=_0x3597fe[_0x0baf('0x39')][_0x0baf('0x11c')]===_0x0baf('0x11d')?'offlineForm':_0x0baf('0x11e');return db[_0x0baf('0x33')]['find']({'attributes':['id',_0x12c4bf],'where':{'id':_0x3597fe[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x132995,null))[_0x0baf('0x15')](function(_0xc2b22e){if(_0xc2b22e){var _0x51f903=_0xc2b22e[_0x12c4bf];var _0x423e9c=_0x51f903&&_0x51f903[_0x0baf('0x11f')]?_0x51f903[_0x0baf('0x11f')]:[];_0x132995['send']({'fromKey':_['isNil'](_0x51f903[_0x0baf('0x120')])?undefined:_0x51f903['fromKey'],'count':_0x423e9c[_0x0baf('0x61')],'rows':_0x423e9c});}})[_0x0baf('0x1f')](handleError(_0x132995,null));};exports['getOfflineMessages']=function(_0x53e81a,_0x572289){var _0x4fc936={'raw':![],'where':{}};var _0x423636={};var _0x51f03c={'count':0x0,'rows':[]};return db[_0x0baf('0x33')][_0x0baf('0x59')]({'where':{'id':_0x53e81a[_0x0baf('0x4d')]['id']}})['then'](handleEntityNotFound(_0x572289,null))['then'](function(_0xa010ed){if(_0xa010ed){_0x423636[_0x0baf('0x36')]=_['keys'](db[_0x0baf('0xc8')]['rawAttributes']);_0x423636[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x53e81a['query']);_0x423636[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x423636['model'],_0x423636[_0x0baf('0x39')]);_0x4fc936[_0x0baf('0x3c')]=_[_0x0baf('0x3b')](_0x423636[_0x0baf('0x36')],qs['fields'](_0x53e81a[_0x0baf('0x39')]['fields']));_0x4fc936[_0x0baf('0x3c')]=_0x4fc936[_0x0baf('0x3c')][_0x0baf('0x61')]?_0x4fc936['attributes']:_0x423636['model'];if(!_0x53e81a[_0x0baf('0x39')][_0x0baf('0x3e')](_0x0baf('0x3f'))){_0x4fc936['limit']=qs[_0x0baf('0x25')](_0x53e81a[_0x0baf('0x39')][_0x0baf('0x25')]);_0x4fc936['offset']=qs[_0x0baf('0x23')](_0x53e81a['query'][_0x0baf('0x23')]);}_0x4fc936[_0x0baf('0x40')]=qs[_0x0baf('0x41')](_0x53e81a[_0x0baf('0x39')][_0x0baf('0x41')]);_0x4fc936[_0x0baf('0x44')]=qs[_0x0baf('0x3a')](_[_0x0baf('0x42')](_0x53e81a[_0x0baf('0x39')],_0x423636['filters']));_0x4fc936[_0x0baf('0x44')][_0x0baf('0x5f')]=_0xa010ed['id'];if(_0x53e81a[_0x0baf('0x39')][_0x0baf('0x43')]){_0x4fc936[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0x4fc936[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0x4fc936[_0x0baf('0x3c')],function(_0x410e8e){var _0x54facf={};_0x54facf[_0x410e8e]={'$like':'%'+_0x53e81a[_0x0baf('0x39')][_0x0baf('0x43')]+'%'};return _0x54facf;})});}_0x4fc936=_['merge']({},_0x4fc936,_0x53e81a[_0x0baf('0x48')]);return db[_0x0baf('0xc8')][_0x0baf('0x26')]({'where':_0x4fc936[_0x0baf('0x44')]})[_0x0baf('0x15')](function(_0x1fb9f7){_0x51f03c[_0x0baf('0x26')]=_0x1fb9f7;if(_0x53e81a[_0x0baf('0x39')][_0x0baf('0x49')]){_0x4fc936['include']=[{'all':!![]}];}else{_0x4fc936[_0x0baf('0x4a')]=[{'model':db[_0x0baf('0x82')],'as':_0x0baf('0xee'),'required':![]},{'model':db[_0x0baf('0xd3')],'as':_0x0baf('0x121'),'required':![]}];}return db['ChatOfflineMessage']['findAll'](_0x4fc936);})[_0x0baf('0x15')](function(_0x58b532){_0x51f03c[_0x0baf('0x4b')]=_0x58b532;return _0x51f03c;});}})[_0x0baf('0x15')](respondWithFilteredResult(_0x572289,_0x4fc936))[_0x0baf('0x1f')](handleError(_0x572289,null));};exports[_0x0baf('0x122')]=function(_0x3a667a,_0x2629e9){return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x3a667a[_0x0baf('0x4d')]['id']}})['then'](handleEntityNotFound(_0x2629e9,null))['then'](function(_0x274787){if(_0x274787){return _0x274787[_0x0baf('0x122')](_0x3a667a[_0x0baf('0x4f')][_0x0baf('0x5d')],_['omit'](_0x3a667a[_0x0baf('0x4f')],['ids','id'])||{})[_0x0baf('0xaf')](function(_0x548f40){for(var _0x64dd21=0x0;_0x64dd21<_0x3a667a[_0x0baf('0x4f')][_0x0baf('0x5d')]['length'];_0x64dd21+=0x1){socket[_0x0baf('0x123')](_0x0baf('0x124'),{'UserId':Number(_0x3a667a['body']['ids'][_0x64dd21]),'ChatWebsiteId':Number(_0x3a667a['params']['id'])});}return _0x548f40;});}})['then'](respondWithResult(_0x2629e9,null))[_0x0baf('0x1f')](handleError(_0x2629e9,null));};exports[_0x0baf('0x125')]=function(_0x1c414,_0x27c810){return db[_0x0baf('0x33')][_0x0baf('0x54')]({'where':{'id':_0x1c414[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x27c810,null))[_0x0baf('0x15')](function(_0xfa0191){if(_0xfa0191){return _0xfa0191[_0x0baf('0x125')](_0x1c414[_0x0baf('0x39')]['ids'])[_0x0baf('0x15')](function(){if(_['isArray'](_0x1c414[_0x0baf('0x39')][_0x0baf('0x5d')])){for(var _0x93dcbd=0x0;_0x93dcbd<_0x1c414[_0x0baf('0x39')][_0x0baf('0x5d')][_0x0baf('0x61')];_0x93dcbd+=0x1){socket[_0x0baf('0x123')]('userChatWebsite:remove',{'UserId':Number(_0x1c414[_0x0baf('0x39')]['ids'][_0x93dcbd]),'ChatWebsiteId':Number(_0x1c414[_0x0baf('0x4d')]['id'])});}}else{socket[_0x0baf('0x123')](_0x0baf('0x126'),{'UserId':Number(_0x1c414[_0x0baf('0x39')][_0x0baf('0x5d')]),'ChatWebsiteId':Number(_0x1c414['params']['id'])});}});}})['then'](respondWithStatusCode(_0x27c810,null))[_0x0baf('0x1f')](handleError(_0x27c810,null));};exports[_0x0baf('0x127')]=function(_0x28c059,_0x51c9e0){var _0x52faae={};var _0x47868e={};var _0x2849c1;var _0x3dd487;return db[_0x0baf('0x33')][_0x0baf('0x59')]({'where':{'id':_0x28c059[_0x0baf('0x4d')]['id']}})[_0x0baf('0x15')](handleEntityNotFound(_0x51c9e0,null))[_0x0baf('0x15')](function(_0x393408){if(_0x393408){_0x2849c1=_0x393408;_0x47868e['model']=_['keys'](db[_0x0baf('0xb7')][_0x0baf('0x34')]);_0x47868e[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x28c059['query']);_0x47868e[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x47868e[_0x0baf('0x36')],_0x47868e['query']);_0x52faae[_0x0baf('0x3c')]=_[_0x0baf('0x3b')](_0x47868e[_0x0baf('0x36')],qs[_0x0baf('0x3d')](_0x28c059['query'][_0x0baf('0x3d')]));_0x52faae[_0x0baf('0x3c')]=_0x52faae[_0x0baf('0x3c')]['length']?_0x52faae[_0x0baf('0x3c')]:_0x47868e[_0x0baf('0x36')];_0x52faae['order']=qs[_0x0baf('0x41')](_0x28c059[_0x0baf('0x39')][_0x0baf('0x41')]);_0x52faae[_0x0baf('0x44')]=qs[_0x0baf('0x3a')](_['pick'](_0x28c059['query'],_0x47868e[_0x0baf('0x3a')]));if(_0x28c059['query'][_0x0baf('0x43')]){_0x52faae[_0x0baf('0x44')]=_[_0x0baf('0x45')](_0x52faae[_0x0baf('0x44')],{'$or':_[_0x0baf('0x37')](_0x52faae[_0x0baf('0x3c')],function(_0xe30e49){var _0x3a5d39={};_0x3a5d39[_0xe30e49]={'$like':'%'+_0x28c059[_0x0baf('0x39')][_0x0baf('0x43')]+'%'};return _0x3a5d39;})});}_0x52faae=_[_0x0baf('0x45')]({},_0x52faae,_0x28c059[_0x0baf('0x48')]);return _0x2849c1[_0x0baf('0x127')](_0x52faae);}})['then'](function(_0x1684e5){if(_0x1684e5){_0x3dd487=_0x1684e5[_0x0baf('0x61')];if(!_0x28c059[_0x0baf('0x39')][_0x0baf('0x3e')](_0x0baf('0x3f'))){_0x52faae[_0x0baf('0x25')]=qs[_0x0baf('0x25')](_0x28c059[_0x0baf('0x39')][_0x0baf('0x25')]);_0x52faae[_0x0baf('0x23')]=qs[_0x0baf('0x23')](_0x28c059[_0x0baf('0x39')]['offset']);}return _0x2849c1[_0x0baf('0x127')](_0x52faae);}})[_0x0baf('0x15')](function(_0x1ea92f){if(_0x1ea92f){return _0x1ea92f?{'count':_0x3dd487,'rows':_0x1ea92f}:null;}})['then'](respondWithResult(_0x51c9e0,null))[_0x0baf('0x1f')](handleError(_0x51c9e0,null));};
\ No newline at end of file