Built motion from commit 449495f6.|2.6.27
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 2bfd6e3..b9ed79d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbe17=['offset','limit','Content-Range','reject','save','update','destroy','get','stack','name','send','index','Pause','mandatoryDispositionPause','ChatWebsite','rawAttributes','fieldName','type','key','model','map','query','keys','intersection','fields','attributes','length','order','sort','where','filters','filter','merge','VIRTUAL','options','includeAll','include','rows','show','params','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','ChatWebsites','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','ChatWebsiteId','Disposition','getDispositions','findOne','hasOwnProperty','nolimit','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','pick','findAll','removeAnswers','sitepic','file','agentAvatar','filename','addCustomerAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','root','../../config/license/util','custom','isNil','existsSync','server/files/images/logos/','download','join','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','user-agent-parser','setUA','headers','user-agent','getResult','CmContact','no\x20available\x20attributes','updatedAt','difference','createdAt','CompanyId','ListId','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','CmList','List','Contacts','DESC','Applications','applications','orderBy','priority','asc','account','customerIp','cf-connecting-ip','x-forwarded-for','first','split','firstName','lastName','x-real-port','browser','version','%s\x20%s','unknown','device','vendor','format','%s\x20%s\x20%s','threadId','ChatInteraction','externalUrl','interaction','spread','contact','messageId','created','autoclose','push','*,*,*,*','ChatMessage','AttachmentId','UserId','agent','forcedOwnership','Start','startRouting','EventManager','notify','offline','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','toPairs','MailAccount','MailServerOut','Smtp','service','host','port','secure','authentication','auth','pass','sendMail','\x22%s\x22\x20<%s>','email','forwardOfflineAddress','offlineMessageSubject','addInteraction','omit','getInteractions','Contact','User','Owner','fullname','internal','Tag','Tags','color','tag','Command','getSnippet','timezone','iftime\x20%s,%s','interval','iftime\x20%s','indexOf','true','ONLINE','OFFLINE','No\x20timezone','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','inspect','Interval','Intervals','getProactiveActions','getLicense','License','increment','all','some','server/files/chat/iframe.js','utf8','remote','x-real-ip','remoteAddress','referer','render','verticalAlignment','textColor','addApplications','sequelize','transaction','ChatApplication','bulkCreate','getApplications','addProactiveActions','chatProactiveAction','ChatProactiveAction','getFields','online','offlineForm','onlineForm','items','fromKey','getOfflineMessages','ChatOfflineMessage','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','ejs','squel','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','./chatWebsite.socket','register','jayson/promise','client','http','test','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','message','result','sendStatus','status','end','json','count'];(function(_0x3aaef5,_0x16cdc8){var _0x4c0ed5=function(_0x4f7046){while(--_0x4f7046){_0x3aaef5['push'](_0x3aaef5['shift']());}};_0x4c0ed5(++_0x16cdc8);}(_0xbe17,0xf3));var _0x7be1=function(_0x1957ae,_0x293c4f){_0x1957ae=_0x1957ae-0x0;var _0x5d4ba5=_0xbe17[_0x1957ae];return _0x5d4ba5;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x7be1('0x0'));var rimraf=require(_0x7be1('0x1'));var zipdir=require(_0x7be1('0x2'));var jsonpatch=require(_0x7be1('0x3'));var rp=require(_0x7be1('0x4'));var moment=require(_0x7be1('0x5'));var BPromise=require(_0x7be1('0x6'));var Mustache=require(_0x7be1('0x7'));var util=require('util');var path=require(_0x7be1('0x8'));var sox=require(_0x7be1('0x9'));var csv=require('to-csv');var ejs=require(_0x7be1('0xa'));var fs=require('fs');var _=require('lodash');var squel=require(_0x7be1('0xb'));var crypto=require(_0x7be1('0xc'));var jsforce=require(_0x7be1('0xd'));var deskjs=require(_0x7be1('0xe'));var toCsv=require(_0x7be1('0xf'));var querystring=require(_0x7be1('0x10'));var Papa=require('papaparse');var Redis=require(_0x7be1('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x7be1('0x12'));var as=require(_0x7be1('0x13'));var hardwareService=require(_0x7be1('0x14'));var logger=require('../../config/logger')('api');var utils=require(_0x7be1('0x15'));var config=require(_0x7be1('0x16'));var db=require(_0x7be1('0x17'))['db'];config[_0x7be1('0x18')]=_[_0x7be1('0x19')](config[_0x7be1('0x18')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x7be1('0x1a'))[_0x7be1('0x1b')](socket);var jayson=require(_0x7be1('0x1c'));var client=jayson[_0x7be1('0x1d')][_0x7be1('0x1e')]({'port':0x232c});var client9002=jayson[_0x7be1('0x1d')][_0x7be1('0x1e')]({'port':0x232a});var client9003=jayson[_0x7be1('0x1d')][_0x7be1('0x1e')]({'port':0x232b});function checkPasswordPattern(_0x178950,_0x5a04ee,_0x489fd8){if(_0x489fd8){var _0x338a75=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x338a75[_0x7be1('0x1f')](_0x5a04ee)){return _0x178950;}else{throw new db[(_0x7be1('0x20'))][(_0x7be1('0x21'))](_0x7be1('0x22'));}}else{return _0x178950;}}function respondWithRpcPromise(_0x4fd3fa,_0x3bbd40,_0x28fc94,_0x325b43){return new BPromise(function(_0x1a0a0a,_0x19fd4e){var _0x416a64=_0x325b43||client;return _0x416a64[_0x7be1('0x23')](_0x4fd3fa,_0x28fc94)[_0x7be1('0x24')](function(_0xb5f788){logger[_0x7be1('0x25')](_0x7be1('0x26'),_0x3bbd40,_0x7be1('0x27'));logger['debug'](_0x7be1('0x28'),_0x3bbd40,_0x7be1('0x27'),JSON[_0x7be1('0x29')](_0xb5f788));if(_0xb5f788[_0x7be1('0x2a')]){if(_0xb5f788[_0x7be1('0x2a')]['code']===0x1f4){logger[_0x7be1('0x2a')]('ChatWebsite,\x20%s,\x20%s',_0x3bbd40,_0xb5f788[_0x7be1('0x2a')]['message']);return _0x19fd4e(_0xb5f788[_0x7be1('0x2a')][_0x7be1('0x2b')]);}logger[_0x7be1('0x2a')](_0x7be1('0x26'),_0x3bbd40,_0xb5f788[_0x7be1('0x2a')][_0x7be1('0x2b')]);return _0x1a0a0a(_0xb5f788[_0x7be1('0x2a')][_0x7be1('0x2b')]);}else{logger[_0x7be1('0x25')](_0x7be1('0x26'),_0x3bbd40,'request\x20sent');_0x1a0a0a(_0xb5f788[_0x7be1('0x2c')][_0x7be1('0x2b')]);}})['catch'](function(_0x3a2c7a){logger['error'](_0x7be1('0x26'),_0x3bbd40,_0x3a2c7a);_0x19fd4e(_0x3a2c7a);});});}function respondWithStatusCode(_0x1f1216,_0x53a7d9){_0x53a7d9=_0x53a7d9||0xcc;return function(_0x31aeee){if(_0x31aeee){return _0x1f1216[_0x7be1('0x2d')](_0x53a7d9);}return _0x1f1216[_0x7be1('0x2e')](_0x53a7d9)[_0x7be1('0x2f')]();};}function respondWithResult(_0x4a1e73,_0x420cb0){_0x420cb0=_0x420cb0||0xc8;return function(_0xba0921){if(_0xba0921){return _0x4a1e73['status'](_0x420cb0)[_0x7be1('0x30')](_0xba0921);}};}function respondWithFilteredResult(_0x2519db,_0x1b5fe5){return function(_0x229bd1){if(_0x229bd1){var _0x34d433=_0x229bd1[_0x7be1('0x31')],_0x5a42b2=_0x1b5fe5['offset'],_0x2946c3=_0x1b5fe5[_0x7be1('0x32')]+_0x1b5fe5[_0x7be1('0x33')],_0x14f89f;if(_0x2946c3>=_0x34d433){_0x2946c3=_0x34d433;_0x14f89f=0xc8;}else{_0x14f89f=0xce;}_0x2519db[_0x7be1('0x2e')](_0x14f89f);return _0x2519db['set'](_0x7be1('0x34'),_0x5a42b2+'-'+_0x2946c3+'/'+_0x34d433)[_0x7be1('0x30')](_0x229bd1);}return null;};}function patchUpdates(_0x5f10c8){return function(_0x3a3664){try{jsonpatch['apply'](_0x3a3664,_0x5f10c8,!![]);}catch(_0x7371b9){return BPromise[_0x7be1('0x35')](_0x7371b9);}return _0x3a3664[_0x7be1('0x36')]();};}function saveUpdates(_0x1293ab,_0x417092){return function(_0x3bb77d){if(_0x3bb77d){return _0x3bb77d[_0x7be1('0x37')](_0x1293ab)['then'](function(_0x16c51a){return _0x16c51a;});}return null;};}function removeEntity(_0x4d6538,_0x2555bb){return function(_0x206d95){if(_0x206d95){return _0x206d95[_0x7be1('0x38')]()[_0x7be1('0x24')](function(){var _0x2a1236=_0x206d95[_0x7be1('0x39')]({'plain':!![]});var _0x3a41f7='ChatWebsites';return db['UserProfileResource'][_0x7be1('0x38')]({'where':{'type':_0x3a41f7,'resourceId':_0x2a1236['id']}})[_0x7be1('0x24')](function(){return _0x206d95;});})[_0x7be1('0x24')](function(){_0x4d6538['status'](0xcc)[_0x7be1('0x2f')]();});}};}function handleEntityNotFound(_0x3d060a,_0x3b22f9){return function(_0x584d13){if(!_0x584d13){_0x3d060a[_0x7be1('0x2d')](0x194);}return _0x584d13;};}function handleError(_0x1e66c4,_0x23e989){_0x23e989=_0x23e989||0x1f4;return function(_0x39b2c6){logger[_0x7be1('0x2a')](_0x39b2c6[_0x7be1('0x3a')]);if(_0x39b2c6[_0x7be1('0x3b')]){delete _0x39b2c6[_0x7be1('0x3b')];}_0x1e66c4['status'](_0x23e989)[_0x7be1('0x3c')](_0x39b2c6);};}exports[_0x7be1('0x3d')]=function(_0x1297ec,_0x4bfeb9){var _0xfd02f6={'include':[{'model':db[_0x7be1('0x3e')],'as':_0x7be1('0x3f')}]},_0x50029a={},_0x37864d={'count':0x0,'rows':[]};var _0x23cb2c=_['map'](db[_0x7be1('0x40')][_0x7be1('0x41')],function(_0x2a9c54){return{'name':_0x2a9c54[_0x7be1('0x42')],'type':_0x2a9c54[_0x7be1('0x43')][_0x7be1('0x44')]};});_0x50029a[_0x7be1('0x45')]=_[_0x7be1('0x46')](_0x23cb2c,'name');_0x50029a[_0x7be1('0x47')]=_[_0x7be1('0x48')](_0x1297ec[_0x7be1('0x47')]);_0x50029a['filters']=_[_0x7be1('0x49')](_0x50029a[_0x7be1('0x45')],_0x50029a[_0x7be1('0x47')]);_0xfd02f6['attributes']=_[_0x7be1('0x49')](_0x50029a['model'],qs[_0x7be1('0x4a')](_0x1297ec[_0x7be1('0x47')][_0x7be1('0x4a')]));_0xfd02f6['attributes']=_0xfd02f6[_0x7be1('0x4b')][_0x7be1('0x4c')]?_0xfd02f6[_0x7be1('0x4b')]:_0x50029a[_0x7be1('0x45')];if(!_0x1297ec[_0x7be1('0x47')]['hasOwnProperty']('nolimit')){_0xfd02f6['limit']=qs['limit'](_0x1297ec[_0x7be1('0x47')]['limit']);_0xfd02f6[_0x7be1('0x32')]=qs[_0x7be1('0x32')](_0x1297ec['query'][_0x7be1('0x32')]);}_0xfd02f6[_0x7be1('0x4d')]=qs[_0x7be1('0x4e')](_0x1297ec[_0x7be1('0x47')]['sort']);_0xfd02f6[_0x7be1('0x4f')]=qs[_0x7be1('0x50')](_['pick'](_0x1297ec['query'],_0x50029a[_0x7be1('0x50')]));if(_0x1297ec[_0x7be1('0x47')][_0x7be1('0x51')]){_0xfd02f6[_0x7be1('0x4f')]=_[_0x7be1('0x52')](_0xfd02f6[_0x7be1('0x4f')],{'$or':_['map'](_0x23cb2c,function(_0x272b9a){if(_0x272b9a[_0x7be1('0x43')]!==_0x7be1('0x53')){var _0x5e7054={};_0x5e7054[_0x272b9a[_0x7be1('0x3b')]]={'$like':'%'+_0x1297ec[_0x7be1('0x47')][_0x7be1('0x51')]+'%'};return _0x5e7054;}})});}_0xfd02f6=_[_0x7be1('0x52')]({},_0xfd02f6,_0x1297ec[_0x7be1('0x54')]);var _0x2cc9a0={'where':_0xfd02f6[_0x7be1('0x4f')]};return db[_0x7be1('0x40')][_0x7be1('0x31')](_0x2cc9a0)[_0x7be1('0x24')](function(_0x1a3998){_0x37864d[_0x7be1('0x31')]=_0x1a3998;if(_0x1297ec[_0x7be1('0x47')][_0x7be1('0x55')]){_0xfd02f6[_0x7be1('0x56')]=[{'all':!![]}];}return db['ChatWebsite']['findAll'](_0xfd02f6);})['then'](function(_0x5f26a7){_0x37864d[_0x7be1('0x57')]=_0x5f26a7;return _0x37864d;})['then'](respondWithFilteredResult(_0x4bfeb9,_0xfd02f6))['catch'](handleError(_0x4bfeb9,null));};exports[_0x7be1('0x58')]=function(_0x1d48ba,_0x53d8f5){var _0x181167={'raw':![],'where':{'id':_0x1d48ba[_0x7be1('0x59')]['id']},'include':[{'model':db[_0x7be1('0x3e')],'as':_0x7be1('0x3f')}]},_0x3f553e={};_0x3f553e['model']=_[_0x7be1('0x48')](db[_0x7be1('0x40')][_0x7be1('0x41')]);_0x3f553e[_0x7be1('0x47')]=_['keys'](_0x1d48ba[_0x7be1('0x47')]);_0x3f553e['filters']=_[_0x7be1('0x49')](_0x3f553e[_0x7be1('0x45')],_0x3f553e[_0x7be1('0x47')]);_0x181167[_0x7be1('0x4b')]=_['intersection'](_0x3f553e[_0x7be1('0x45')],qs['fields'](_0x1d48ba[_0x7be1('0x47')][_0x7be1('0x4a')]));_0x181167[_0x7be1('0x4b')]=_0x181167['attributes'][_0x7be1('0x4c')]?_0x181167['attributes']:_0x3f553e[_0x7be1('0x45')];if(_0x1d48ba['query']['includeAll']){_0x181167['include']=[{'all':!![]}];}_0x181167=_[_0x7be1('0x52')]({},_0x181167,_0x1d48ba[_0x7be1('0x54')]);return db[_0x7be1('0x40')][_0x7be1('0x5a')](_0x181167)[_0x7be1('0x24')](handleEntityNotFound(_0x53d8f5,null))[_0x7be1('0x24')](respondWithResult(_0x53d8f5,null))[_0x7be1('0x5b')](handleError(_0x53d8f5,null));};exports[_0x7be1('0x5c')]=function(_0xab1c07,_0x4a7d0c){return db['ChatWebsite'][_0x7be1('0x5c')](_0xab1c07[_0x7be1('0x5d')],{})[_0x7be1('0x24')](function(_0x44277a){var _0x24c887=_0xab1c07[_0x7be1('0x5e')][_0x7be1('0x39')]({'plain':!![]});if(!_0x24c887)throw new Error(_0x7be1('0x5f'));if(_0x24c887[_0x7be1('0x60')]===_0x7be1('0x5e')){var _0xda1191=_0x44277a[_0x7be1('0x39')]({'plain':!![]});var _0x3b1446=_0x7be1('0x61');return db[_0x7be1('0x62')][_0x7be1('0x5a')]({'where':{'name':_0x3b1446,'userProfileId':_0x24c887[_0x7be1('0x63')]},'raw':!![]})['then'](function(_0x3b017c){if(_0x3b017c&&_0x3b017c[_0x7be1('0x64')]===0x0){return db[_0x7be1('0x65')]['create']({'name':_0xda1191['name'],'resourceId':_0xda1191['id'],'type':_0x3b017c[_0x7be1('0x3b')],'sectionId':_0x3b017c['id']},{})[_0x7be1('0x24')](function(){return _0x44277a;});}else{return _0x44277a;}})['catch'](function(_0x3cbd07){logger[_0x7be1('0x2a')](_0x7be1('0x66'),_0x3cbd07);throw _0x3cbd07;});}return _0x44277a;})[_0x7be1('0x24')](respondWithResult(_0x4a7d0c,0xc9))[_0x7be1('0x5b')](handleError(_0x4a7d0c,null));};exports[_0x7be1('0x37')]=function(_0x56a284,_0x18c2ec){if(_0x56a284[_0x7be1('0x5d')]['id']){delete _0x56a284[_0x7be1('0x5d')]['id'];}return db[_0x7be1('0x40')][_0x7be1('0x5a')]({'where':{'id':_0x56a284[_0x7be1('0x59')]['id']},'include':[{'model':db[_0x7be1('0x3e')],'as':'mandatoryDispositionPause'}]})[_0x7be1('0x24')](handleEntityNotFound(_0x18c2ec,null))[_0x7be1('0x24')](saveUpdates(_0x56a284[_0x7be1('0x5d')],null))[_0x7be1('0x24')](respondWithResult(_0x18c2ec,null))[_0x7be1('0x5b')](handleError(_0x18c2ec,null));};exports['destroy']=function(_0x46656e,_0x174c8b){return db[_0x7be1('0x40')][_0x7be1('0x5a')]({'where':{'id':_0x46656e[_0x7be1('0x59')]['id']}})['then'](handleEntityNotFound(_0x174c8b,null))[_0x7be1('0x24')](removeEntity(_0x174c8b,null))[_0x7be1('0x5b')](handleError(_0x174c8b,null));};exports[_0x7be1('0x67')]=function(_0x1421f9,_0x555b0a){return db[_0x7be1('0x40')][_0x7be1('0x67')]()[_0x7be1('0x24')](respondWithResult(_0x555b0a,null))[_0x7be1('0x5b')](handleError(_0x555b0a,null));};exports['addDisposition']=function(_0x5a00a4,_0x56d1eb,_0x2b215d){if(_0x5a00a4[_0x7be1('0x5d')]['id']){delete _0x5a00a4[_0x7be1('0x5d')]['id'];}return db[_0x7be1('0x40')][_0x7be1('0x5a')]({'where':{'id':_0x5a00a4[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x56d1eb,null))[_0x7be1('0x24')](function(_0x40fa70){if(_0x40fa70){_0x5a00a4['body'][_0x7be1('0x68')]=_0x40fa70['id'];return db[_0x7be1('0x69')][_0x7be1('0x5c')](_0x5a00a4[_0x7be1('0x5d')]);}})[_0x7be1('0x24')](respondWithResult(_0x56d1eb,null))[_0x7be1('0x5b')](handleError(_0x56d1eb,null));};exports[_0x7be1('0x6a')]=function(_0x22cda8,_0x2d874d,_0x2bafb4){var _0x226433={'raw':![],'where':{}};var _0x49cedc={};var _0x1bdd83={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x7be1('0x6b')]({'where':{'id':_0x22cda8[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x2d874d,null))[_0x7be1('0x24')](function(_0x2f52c4){if(_0x2f52c4){_0x49cedc[_0x7be1('0x45')]=_['keys'](db[_0x7be1('0x69')][_0x7be1('0x41')]);_0x49cedc[_0x7be1('0x47')]=_[_0x7be1('0x48')](_0x22cda8[_0x7be1('0x47')]);_0x49cedc[_0x7be1('0x50')]=_[_0x7be1('0x49')](_0x49cedc[_0x7be1('0x45')],_0x49cedc[_0x7be1('0x47')]);_0x226433[_0x7be1('0x4b')]=_[_0x7be1('0x49')](_0x49cedc[_0x7be1('0x45')],qs[_0x7be1('0x4a')](_0x22cda8['query'][_0x7be1('0x4a')]));_0x226433[_0x7be1('0x4b')]=_0x226433[_0x7be1('0x4b')][_0x7be1('0x4c')]?_0x226433['attributes']:_0x49cedc[_0x7be1('0x45')];if(!_0x22cda8[_0x7be1('0x47')][_0x7be1('0x6c')](_0x7be1('0x6d'))){_0x226433[_0x7be1('0x33')]=qs[_0x7be1('0x33')](_0x22cda8[_0x7be1('0x47')][_0x7be1('0x33')]);_0x226433['offset']=qs[_0x7be1('0x32')](_0x22cda8['query'][_0x7be1('0x32')]);}_0x226433['order']=qs[_0x7be1('0x4e')](_0x22cda8[_0x7be1('0x47')][_0x7be1('0x4e')]);_0x226433['where']=qs[_0x7be1('0x50')](_['pick'](_0x22cda8[_0x7be1('0x47')],_0x49cedc['filters']));_0x226433[_0x7be1('0x4f')][_0x7be1('0x68')]=_0x2f52c4['id'];if(_0x22cda8[_0x7be1('0x47')]['filter']){_0x226433[_0x7be1('0x4f')]=_[_0x7be1('0x52')](_0x226433['where'],{'$or':_['map'](_0x226433[_0x7be1('0x4b')],function(_0x5da486){var _0x1c9013={};_0x1c9013[_0x5da486]={'$like':'%'+_0x22cda8[_0x7be1('0x47')][_0x7be1('0x51')]+'%'};return _0x1c9013;})});}_0x226433=_[_0x7be1('0x52')]({},_0x226433,_0x22cda8['options']);return db[_0x7be1('0x69')]['count']({'where':_0x226433[_0x7be1('0x4f')]})['then'](function(_0x55616e){_0x1bdd83[_0x7be1('0x31')]=_0x55616e;if(_0x22cda8['query']['includeAll']){_0x226433['include']=[{'all':!![]}];}return db[_0x7be1('0x69')]['findAll'](_0x226433);})[_0x7be1('0x24')](function(_0x197d41){_0x1bdd83[_0x7be1('0x57')]=_0x197d41;return _0x1bdd83;});}})[_0x7be1('0x24')](respondWithFilteredResult(_0x2d874d,_0x226433))['catch'](handleError(_0x2d874d,null));};exports[_0x7be1('0x6e')]=function(_0x586a2a,_0x1fa114,_0x232ece){return db[_0x7be1('0x40')][_0x7be1('0x5a')]({'where':{'id':_0x586a2a[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x1fa114,null))['then'](function(_0x128441){if(_0x128441){return _0x128441[_0x7be1('0x6e')](_0x586a2a[_0x7be1('0x47')][_0x7be1('0x6f')]);}})[_0x7be1('0x24')](respondWithStatusCode(_0x1fa114,null))[_0x7be1('0x5b')](handleError(_0x1fa114,null));};exports[_0x7be1('0x70')]=function(_0x55a8c9,_0x2f6b5f,_0x538f10){if(_0x55a8c9[_0x7be1('0x5d')]['id']){delete _0x55a8c9[_0x7be1('0x5d')]['id'];}return db[_0x7be1('0x40')][_0x7be1('0x5a')]({'where':{'id':_0x55a8c9[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x2f6b5f,null))['then'](function(_0x1fa0b2){if(_0x1fa0b2){_0x55a8c9['body'][_0x7be1('0x68')]=_0x1fa0b2['id'];return db[_0x7be1('0x71')][_0x7be1('0x5c')](_0x55a8c9[_0x7be1('0x5d')]);}})[_0x7be1('0x24')](respondWithResult(_0x2f6b5f,null))[_0x7be1('0x5b')](handleError(_0x2f6b5f,null));};exports[_0x7be1('0x72')]=function(_0x421e07,_0x583914,_0xcd7de1){var _0xd57101={'raw':![],'where':{}};var _0x253df2={};var _0xc52d54={'count':0x0,'rows':[]};return db[_0x7be1('0x40')][_0x7be1('0x6b')]({'where':{'id':_0x421e07[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x583914,null))['then'](function(_0x1e0481){if(_0x1e0481){_0x253df2[_0x7be1('0x45')]=_[_0x7be1('0x48')](db[_0x7be1('0x71')][_0x7be1('0x41')]);_0x253df2[_0x7be1('0x47')]=_[_0x7be1('0x48')](_0x421e07[_0x7be1('0x47')]);_0x253df2[_0x7be1('0x50')]=_[_0x7be1('0x49')](_0x253df2[_0x7be1('0x45')],_0x253df2['query']);_0xd57101[_0x7be1('0x4b')]=_[_0x7be1('0x49')](_0x253df2[_0x7be1('0x45')],qs[_0x7be1('0x4a')](_0x421e07[_0x7be1('0x47')]['fields']));_0xd57101['attributes']=_0xd57101[_0x7be1('0x4b')][_0x7be1('0x4c')]?_0xd57101[_0x7be1('0x4b')]:_0x253df2[_0x7be1('0x45')];if(!_0x421e07[_0x7be1('0x47')]['hasOwnProperty'](_0x7be1('0x6d'))){_0xd57101[_0x7be1('0x33')]=qs[_0x7be1('0x33')](_0x421e07['query'][_0x7be1('0x33')]);_0xd57101[_0x7be1('0x32')]=qs[_0x7be1('0x32')](_0x421e07[_0x7be1('0x47')]['offset']);}_0xd57101[_0x7be1('0x4d')]=qs['sort'](_0x421e07['query']['sort']);_0xd57101[_0x7be1('0x4f')]=qs[_0x7be1('0x50')](_[_0x7be1('0x73')](_0x421e07[_0x7be1('0x47')],_0x253df2[_0x7be1('0x50')]));_0xd57101[_0x7be1('0x4f')][_0x7be1('0x68')]=_0x1e0481['id'];if(_0x421e07[_0x7be1('0x47')][_0x7be1('0x51')]){_0xd57101['where']=_[_0x7be1('0x52')](_0xd57101['where'],{'$or':_[_0x7be1('0x46')](_0xd57101[_0x7be1('0x4b')],function(_0x2506f4){var _0x92e976={};_0x92e976[_0x2506f4]={'$like':'%'+_0x421e07['query'][_0x7be1('0x51')]+'%'};return _0x92e976;})});}_0xd57101=_['merge']({},_0xd57101,_0x421e07[_0x7be1('0x54')]);return db[_0x7be1('0x71')]['count']({'where':_0xd57101['where']})[_0x7be1('0x24')](function(_0x4add12){_0xc52d54[_0x7be1('0x31')]=_0x4add12;if(_0x421e07[_0x7be1('0x47')]['includeAll']){_0xd57101[_0x7be1('0x56')]=[{'all':!![]}];}return db[_0x7be1('0x71')][_0x7be1('0x74')](_0xd57101);})[_0x7be1('0x24')](function(_0x51bb9f){_0xc52d54[_0x7be1('0x57')]=_0x51bb9f;return _0xc52d54;});}})[_0x7be1('0x24')](respondWithFilteredResult(_0x583914,_0xd57101))[_0x7be1('0x5b')](handleError(_0x583914,null));};exports[_0x7be1('0x75')]=function(_0x4abbc2,_0x40ce49,_0x290d27){return db[_0x7be1('0x40')][_0x7be1('0x5a')]({'where':{'id':_0x4abbc2[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x40ce49,null))[_0x7be1('0x24')](function(_0x383e33){if(_0x383e33){return _0x383e33[_0x7be1('0x75')](_0x4abbc2['query'][_0x7be1('0x6f')]);}})[_0x7be1('0x24')](respondWithStatusCode(_0x40ce49,null))[_0x7be1('0x5b')](handleError(_0x40ce49,null));};exports['addLogo']=function(_0x22b094,_0x5449bc,_0x2dfef9){_0x22b094[_0x7be1('0x5d')][_0x7be1('0x76')]=_0x22b094[_0x7be1('0x77')]['filename'];return db[_0x7be1('0x40')]['find']({'where':{'id':_0x22b094[_0x7be1('0x59')]['id']}})['then'](handleEntityNotFound(_0x5449bc,null))[_0x7be1('0x24')](saveUpdates(_0x22b094[_0x7be1('0x5d')],null))['then'](respondWithResult(_0x5449bc,null))[_0x7be1('0x5b')](handleError(_0x5449bc,null));};exports['addAvatar']=function(_0x29b311,_0x28cb7f,_0x1bb23f){_0x29b311[_0x7be1('0x5d')][_0x7be1('0x78')]=_0x29b311[_0x7be1('0x77')][_0x7be1('0x79')];return db[_0x7be1('0x40')][_0x7be1('0x5a')]({'where':{'id':_0x29b311['params']['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x28cb7f,null))[_0x7be1('0x24')](saveUpdates(_0x29b311[_0x7be1('0x5d')],null))[_0x7be1('0x24')](respondWithResult(_0x28cb7f,null))[_0x7be1('0x5b')](handleError(_0x28cb7f,null));};exports[_0x7be1('0x7a')]=function(_0x282ef9,_0x2667e2,_0x229bcc){_0x282ef9[_0x7be1('0x5d')][_0x7be1('0x7b')]=_0x282ef9['file']['filename'];return db[_0x7be1('0x40')]['find']({'where':{'id':_0x282ef9[_0x7be1('0x59')]['id']}})['then'](handleEntityNotFound(_0x2667e2,null))[_0x7be1('0x24')](saveUpdates(_0x282ef9[_0x7be1('0x5d')],null))['then'](respondWithResult(_0x2667e2,null))[_0x7be1('0x5b')](handleError(_0x2667e2,null));};exports[_0x7be1('0x7c')]=function(_0x15207b,_0x123b87,_0x4a314a){_0x15207b[_0x7be1('0x5d')][_0x7be1('0x7d')]=_0x15207b[_0x7be1('0x77')][_0x7be1('0x79')];return db[_0x7be1('0x40')][_0x7be1('0x5a')]({'where':{'id':_0x15207b[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x123b87,null))[_0x7be1('0x24')](saveUpdates(_0x15207b[_0x7be1('0x5d')],null))[_0x7be1('0x24')](respondWithResult(_0x123b87,null))['catch'](handleError(_0x123b87,null));};exports[_0x7be1('0x7e')]=function(_0x332675,_0x2656aa,_0x3ec187){var _0x297a89=path['join'](config[_0x7be1('0x7f')],'server/files/images/logos/default_logo.png');var _0xecd7f5={'where':{'id':_0x332675[_0x7be1('0x59')]['id']},'attributes':['id',_0x7be1('0x76')],'raw':!![]};var _0x5ea4a3=![];return require(_0x7be1('0x80'))['getLicense']()[_0x7be1('0x24')](function(_0x1da9e7){if(_0x1da9e7){_0x5ea4a3=_0x1da9e7[_0x7be1('0x81')];}})[_0x7be1('0x24')](function(){return db[_0x7be1('0x40')][_0x7be1('0x5a')](_0xecd7f5);})[_0x7be1('0x24')](handleEntityNotFound(_0x2656aa,null))['then'](function(_0x3820ce){if(_0x3820ce){if(!_[_0x7be1('0x82')](_0x3820ce[_0x7be1('0x76')])){if(fs[_0x7be1('0x83')](path['join'](config['root'],_0x7be1('0x84'),_0x3820ce[_0x7be1('0x76')]))&&_0x5ea4a3){_0x297a89=path['join'](config['root'],_0x7be1('0x84'),_0x3820ce['sitepic']);}}return _0x2656aa[_0x7be1('0x85')](_0x297a89);}})[_0x7be1('0x5b')](handleError(_0x2656aa,null));};exports['getAvatar']=function(_0x5934b8,_0x3b8dcb,_0x426dc9){var _0x1b3d04=path[_0x7be1('0x86')](config['root'],_0x7be1('0x87'));var _0xc92e7d={'where':{'id':_0x5934b8['params']['id']},'attributes':['id',_0x7be1('0x78')],'raw':!![]};return db[_0x7be1('0x40')]['find'](_0xc92e7d)[_0x7be1('0x24')](handleEntityNotFound(_0x3b8dcb,null))[_0x7be1('0x24')](function(_0x474ffd){if(_0x474ffd){if(!_[_0x7be1('0x82')](_0x474ffd[_0x7be1('0x78')])){if(fs[_0x7be1('0x83')](path[_0x7be1('0x86')](config[_0x7be1('0x7f')],_0x7be1('0x88'),_0x474ffd[_0x7be1('0x78')]))){_0x1b3d04=path[_0x7be1('0x86')](config[_0x7be1('0x7f')],_0x7be1('0x88'),_0x474ffd[_0x7be1('0x78')]);}}return _0x3b8dcb[_0x7be1('0x85')](_0x1b3d04);}})[_0x7be1('0x5b')](handleError(_0x3b8dcb,null));};exports['getCustomerAvatar']=function(_0x2b13e0,_0x352aa9,_0x48b589){var _0x23fca5=path[_0x7be1('0x86')](config[_0x7be1('0x7f')],'server/files/images/avatars/customer_avatar.png');var _0x4d3868={'where':{'id':_0x2b13e0['params']['id']},'attributes':['id','customerAvatar',_0x7be1('0x89')],'raw':!![]};return db[_0x7be1('0x40')][_0x7be1('0x5a')](_0x4d3868)['then'](handleEntityNotFound(_0x352aa9,null))['then'](function(_0x303c90){if(_0x303c90){if(!_[_0x7be1('0x82')](_0x303c90[_0x7be1('0x7b')])){if(fs['existsSync'](path[_0x7be1('0x86')](config[_0x7be1('0x7f')],_0x7be1('0x88'),_0x303c90[_0x7be1('0x7b')]))&&_0x303c90[_0x7be1('0x89')]){_0x23fca5=path['join'](config[_0x7be1('0x7f')],_0x7be1('0x88'),_0x303c90[_0x7be1('0x7b')]);}}return _0x352aa9[_0x7be1('0x85')](_0x23fca5);}})[_0x7be1('0x5b')](handleError(_0x352aa9,null));};exports[_0x7be1('0x8a')]=function(_0x389271,_0x4ac163,_0x505307){var _0x4b76c=path['join'](config['root'],_0x7be1('0x8b'));var _0x5260ed={'where':{'id':_0x389271[_0x7be1('0x59')]['id']},'attributes':['id',_0x7be1('0x7d')],'raw':!![]};return db[_0x7be1('0x40')][_0x7be1('0x5a')](_0x5260ed)[_0x7be1('0x24')](handleEntityNotFound(_0x4ac163,null))[_0x7be1('0x24')](function(_0x66e3c8){if(_0x66e3c8){if(!_[_0x7be1('0x82')](_0x66e3c8[_0x7be1('0x7d')])){if(fs['existsSync'](path[_0x7be1('0x86')](config['root'],_0x7be1('0x88'),_0x66e3c8[_0x7be1('0x7d')]))){_0x4b76c=path['join'](config[_0x7be1('0x7f')],_0x7be1('0x88'),_0x66e3c8[_0x7be1('0x7d')]);}}return _0x4ac163['download'](_0x4b76c);}})[_0x7be1('0x5b')](handleError(_0x4ac163,null));};exports['notify']=function(_0x135d62,_0x55a336,_0x1b460b){var _0x5cf1c1=require(_0x7be1('0x8c'));var _0x22afc7=new _0x5cf1c1();var _0x310820=_0x22afc7[_0x7be1('0x8d')](_0x135d62[_0x7be1('0x8e')][_0x7be1('0x8f')])[_0x7be1('0x90')]();var _0x5f556b={'body':_0x135d62['body'],'channel':'chat'};var _0x16be4f=[];var _0x51becd=[];var _0x1fa05c={};var _0x53ec6c=![];return db[_0x7be1('0x91')]['describe']()[_0x7be1('0x24')](function(_0x2255d2){if(!_0x2255d2){throw new db['Sequelize'][(_0x7be1('0x21'))](_0x7be1('0x92'));}_0x16be4f=_['difference'](_[_0x7be1('0x48')](_0x2255d2),['createdAt',_0x7be1('0x93')]);_0x51becd=_[_0x7be1('0x94')](_[_0x7be1('0x48')](_0x2255d2),[_0x7be1('0x95'),_0x7be1('0x93'),_0x7be1('0x96'),_0x7be1('0x97')]);if(_0x135d62['body']['id']){delete _0x135d62['body']['id'];}if(_['isNil'](_0x135d62[_0x7be1('0x5d')][_0x7be1('0x98')])){throw new db[(_0x7be1('0x20'))]['ValidationError'](_0x7be1('0x99'));}if(_[_0x7be1('0x82')](_0x135d62['body'][_0x7be1('0x5d')])||_0x135d62[_0x7be1('0x5d')]['body']===''){throw new db[(_0x7be1('0x20'))]['ValidationError'](_0x7be1('0x9a'));}if(_[_0x7be1('0x82')](_0x135d62[_0x7be1('0x5d')][_0x7be1('0x9b')])){throw new db[(_0x7be1('0x20'))][(_0x7be1('0x21'))](_0x7be1('0x9c')+_0x51becd);}if(!_[_0x7be1('0x9d')](_0x51becd,_0x135d62[_0x7be1('0x5d')][_0x7be1('0x9b')])){throw new db[(_0x7be1('0x20'))][(_0x7be1('0x21'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x51becd);}_0x1fa05c[_0x135d62[_0x7be1('0x5d')]['mapKey']]=_0x135d62['body'][_0x7be1('0x98')];})[_0x7be1('0x24')](function(){return db[_0x7be1('0x40')][_0x7be1('0x5a')]({'where':{'id':_0x135d62[_0x7be1('0x59')]['id']},'include':[{'model':db[_0x7be1('0x9e')],'as':_0x7be1('0x9f'),'include':[{'model':db[_0x7be1('0x91')],'as':_0x7be1('0xa0'),'where':_0x1fa05c,'limit':0x1,'order':[[_0x7be1('0x93'),_0x7be1('0xa1')]]}]},{'model':db['ChatApplication'],'as':_0x7be1('0xa2')}]});})[_0x7be1('0x24')](handleEntityNotFound(_0x55a336,null))[_0x7be1('0x24')](function(_0x25ff74){if(_0x25ff74&&_0x25ff74[_0x7be1('0x9f')]){_0x5f556b['account']=_0x25ff74;_0x5f556b[_0x7be1('0xa3')]=_0x25ff74[_0x7be1('0xa2')];_0x5f556b['list']=_0x25ff74[_0x7be1('0x9f')];_0x5f556b['applications']=_[_0x7be1('0xa4')](_0x5f556b[_0x7be1('0xa3')],[_0x7be1('0xa5')],[_0x7be1('0xa6')]);if(_0x5f556b[_0x7be1('0xa7')][_0x7be1('0xa2')]){delete _0x5f556b[_0x7be1('0xa7')][_0x7be1('0xa2')];}if(_0x5f556b[_0x7be1('0xa7')][_0x7be1('0x9f')]&&_0x5f556b[_0x7be1('0xa7')]['List'][_0x7be1('0xa0')][_0x7be1('0x4c')]){return _0x5f556b[_0x7be1('0xa7')][_0x7be1('0x9f')]['Contacts'][0x0];}var _0x5adaaa=_[_0x7be1('0x19')](_0x135d62[_0x7be1('0x5d')],{'firstName':_0x135d62['body']['from'],'ListId':_0x25ff74[_0x7be1('0x97')]});_0x5adaaa[_0x135d62[_0x7be1('0x5d')][_0x7be1('0x9b')]]=_0x135d62[_0x7be1('0x5d')]['from'];return db[_0x7be1('0x91')][_0x7be1('0x5c')](_0x5adaaa,{'fields':_0x16be4f,'raw':!![]});}})['then'](handleEntityNotFound(_0x55a336,null))[_0x7be1('0x24')](function(_0x8e538f){_0x5f556b['contact']=_0x8e538f;var _0x1aa5da=_0x135d62['body'][_0x7be1('0xa8')];if(_0x135d62['headers'][_0x7be1('0xa9')]){_0x1aa5da=_0x135d62['headers']['cf-connecting-ip'];}else if(_0x135d62[_0x7be1('0x8e')][_0x7be1('0xaa')]){_0x1aa5da=_[_0x7be1('0xab')](_0x135d62[_0x7be1('0x8e')]['x-forwarded-for'][_0x7be1('0xac')](','));}if(_0x8e538f){var _0x371883={'ContactId':_0x8e538f['id'],'ChatWebsiteId':_0x135d62[_0x7be1('0x59')]['id'],'from':(_0x8e538f[_0x7be1('0xad')]||'')+'\x20'+(_0x8e538f[_0x7be1('0xae')]||''),'customerIp':_0x1aa5da,'customerPort':_0x135d62[_0x7be1('0x8e')][_0x7be1('0xaf')]?_0x135d62[_0x7be1('0x8e')]['x-real-port']:null,'referer':_0x135d62[_0x7be1('0x5d')]['referer'],'browserName':_0x310820[_0x7be1('0xb0')]['name']&&_0x310820[_0x7be1('0xb0')][_0x7be1('0xb1')]?util['format'](_0x7be1('0xb2'),_0x310820[_0x7be1('0xb0')][_0x7be1('0x3b')],_0x310820[_0x7be1('0xb0')]['version']):'unknown','browserVersion':_0x310820[_0x7be1('0xb0')][_0x7be1('0xb1')]||_0x7be1('0xb3'),'osName':util['format'](_0x7be1('0xb2'),_0x310820['os']['name'],_0x310820['os']['version']),'osVersion':_0x310820['os'][_0x7be1('0xb1')],'deviceModel':_0x310820[_0x7be1('0xb4')][_0x7be1('0x45')]&&_0x310820[_0x7be1('0xb4')][_0x7be1('0xb5')]?util[_0x7be1('0xb6')](_0x7be1('0xb7'),_0x310820['device'][_0x7be1('0x45')],_0x310820['device'][_0x7be1('0xb5')],_0x310820[_0x7be1('0xb4')][_0x7be1('0x43')]):null,'deviceVendor':_0x310820[_0x7be1('0xb4')][_0x7be1('0xb5')],'deviceType':_0x310820[_0x7be1('0xb4')]['type'],'formData':JSON[_0x7be1('0x29')](_0x135d62[_0x7be1('0x5d')])};var _0xdc1dc7={'ChatWebsiteId':_0x135d62['params']['id'],'closed':![]};if(_0x135d62[_0x7be1('0x5d')][_0x7be1('0xb8')]){_0xdc1dc7[_0x7be1('0xb8')]=_0x135d62[_0x7be1('0x5d')][_0x7be1('0xb8')];return db[_0x7be1('0xb9')]['find']({'where':_0xdc1dc7})[_0x7be1('0x24')](function(_0x120bbe){if(_0x120bbe){return[_0x120bbe,![]];}_0x371883['threadId']=_0x135d62[_0x7be1('0x5d')]['threadId'];_0x371883['externalUrl']=_0x135d62[_0x7be1('0x5d')][_0x7be1('0xba')];return db[_0x7be1('0xb9')][_0x7be1('0x5c')](_0x371883)[_0x7be1('0x24')](function(_0x44c33b){return[_0x44c33b,!![]];});});}_0xdc1dc7['ContactId']=_0x8e538f['id'];if(_0x135d62[_0x7be1('0x5d')][_0x7be1('0xbb')]&&_0x135d62[_0x7be1('0x5d')][_0x7be1('0xbb')]['id']){_0xdc1dc7['id']=_0x135d62[_0x7be1('0x5d')][_0x7be1('0xbb')]['id'];return db[_0x7be1('0xb9')][_0x7be1('0x5a')]({'where':_0xdc1dc7})[_0x7be1('0x24')](function(_0x399338){if(_0x399338){return[_0x399338,![]];}return db['ChatInteraction'][_0x7be1('0x5c')](_0x371883)[_0x7be1('0x24')](function(_0x2d302d){return[_0x2d302d,!![]];});});}return db['ChatInteraction'][_0x7be1('0x5c')](_0x371883)[_0x7be1('0x24')](function(_0x4f07d0){return[_0x4f07d0,!![]];});}})[_0x7be1('0xbc')](function(_0x3e4c09,_0x5a5f2e){if(_0x3e4c09){_0x53ec6c=_0x5a5f2e;if(!_0x5a5f2e){var _0x5cb91c={'from':(_0x5f556b[_0x7be1('0xbd')][_0x7be1('0xad')]||'')+'\x20'+(_0x5f556b[_0x7be1('0xbd')][_0x7be1('0xae')]||'')};if(_0x135d62['body'][_0x7be1('0xb8')]&&_0x135d62[_0x7be1('0x5d')]['messageId']&&_0x135d62[_0x7be1('0x5d')][_0x7be1('0xb8')]!=_0x135d62[_0x7be1('0x5d')][_0x7be1('0xbe')]){_0x5cb91c['threadId']=_0x135d62['body'][_0x7be1('0xbe')];}return _0x3e4c09['update'](_0x5cb91c);}else{return _0x3e4c09;}}})[_0x7be1('0x24')](function(_0x52d103){_0x5f556b[_0x7be1('0xbb')]=_0x52d103[_0x7be1('0x39')]({'plain':!![]});_0x5f556b[_0x7be1('0xbb')][_0x7be1('0xbf')]=_0x53ec6c;if(_0x5f556b[_0x7be1('0xbb')]['created']){if(_0x5f556b['account'][_0x7be1('0xc0')]){_0x5f556b[_0x7be1('0xa3')][_0x7be1('0xc1')]({'id':0x0,'priority':_0x5f556b[_0x7be1('0xa3')][_0x7be1('0x4c')]+0x1,'app':'close','appdata':'unmanaged','interval':_0x7be1('0xc2')});}}return db[_0x7be1('0xc3')][_0x7be1('0x5c')]({'body':_0x135d62[_0x7be1('0x5d')][_0x7be1('0x5d')],'ChatWebsiteId':_0x135d62[_0x7be1('0x59')]['id'],'ChatInteractionId':_0x52d103['id'],'direction':'in','ContactId':_0x5f556b[_0x7be1('0xbd')]['id'],'AttachmentId':_0x135d62['body'][_0x7be1('0xc4')]});})[_0x7be1('0x24')](function(_0x34af8d){_0x5f556b[_0x7be1('0x2b')]=_0x34af8d;if(_0x5f556b['interaction']['UserId']){return db['User'][_0x7be1('0x5a')]({'attributes':['id',_0x7be1('0x3b')],'where':{'id':_0x5f556b[_0x7be1('0xbb')][_0x7be1('0xc5')]}})['then'](function(_0x3d7045){if(_0x3d7045){_0x5f556b[_0x7be1('0xa3')]['unshift']({'id':0x0,'priority':0x0,'app':_0x7be1('0xc6'),'appdata':_0x3d7045['name']+','+(_0x5f556b[_0x7be1('0xa7')]['waitForTheAssignedAgent']||0xa),'interval':_0x7be1('0xc2')});_0x5f556b[_0x7be1('0xc7')]=!![];}return respondWithRpcPromise(_0x7be1('0xc8'),_0x7be1('0xc9'),_0x5f556b);});}return respondWithRpcPromise(_0x7be1('0xc8'),_0x7be1('0xc9'),_0x5f556b);})[_0x7be1('0x24')](function(_0x426327){respondWithRpcPromise(_0x7be1('0xca'),_0x7be1('0xca'),{'event':_0x7be1('0xcb'),'message':_0x426327},client9002);return _0x426327;})[_0x7be1('0x24')](respondWithResult(_0x55a336,null))[_0x7be1('0x5b')](handleError(_0x55a336,null));};exports[_0x7be1('0xcc')]=function(_0x143a97,_0x3da47d,_0x39fc7a){var _0x502d2f,_0x621aad,_0x72261b;var _0x485626=[];var _0x5d6a1f=[];var _0x5c22cf={};return db['CmContact'][_0x7be1('0x67')]()[_0x7be1('0x24')](function(_0x123643){if(!_0x123643){throw new db[(_0x7be1('0x20'))][(_0x7be1('0x21'))](_0x7be1('0x92'));}_0x5d6a1f=_[_0x7be1('0x94')](_[_0x7be1('0x48')](_0x123643),['createdAt',_0x7be1('0x93')]);_0x485626=_[_0x7be1('0x94')](_[_0x7be1('0x48')](_0x123643),[_0x7be1('0x95'),_0x7be1('0x93'),_0x7be1('0x96'),'ListId']);if(_0x143a97[_0x7be1('0x5d')]['id']){delete _0x143a97[_0x7be1('0x5d')]['id'];}if(_['isNil'](_0x143a97[_0x7be1('0x5d')]['from'])){throw _0x3da47d[_0x7be1('0x2e')](0x1f4)['send'](new db['Sequelize'][(_0x7be1('0x21'))](_0x7be1('0x99')));}if(_[_0x7be1('0x82')](_0x143a97[_0x7be1('0x5d')][_0x7be1('0x5d')])||_0x143a97[_0x7be1('0x5d')][_0x7be1('0x5d')]===''){throw _0x3da47d[_0x7be1('0x2e')](0x1f4)['send'](new db[(_0x7be1('0x20'))][(_0x7be1('0x21'))](_0x7be1('0x9a')));}if(_['isNil'](_0x143a97['body'][_0x7be1('0xcd')])){throw _0x3da47d[_0x7be1('0x2e')](0x1f4)[_0x7be1('0x3c')](new db['Sequelize'][(_0x7be1('0x21'))](_0x7be1('0xce')+_0x485626));}if(!_[_0x7be1('0x9d')](_0x485626,_0x143a97[_0x7be1('0x5d')][_0x7be1('0xcd')])){throw _0x3da47d[_0x7be1('0x2e')](0x1f4)[_0x7be1('0x3c')](new db['Sequelize'][(_0x7be1('0x21'))](_0x7be1('0xcf')+_0x485626));}_0x5c22cf[_0x143a97['body'][_0x7be1('0xcd')]]=_0x143a97[_0x7be1('0x5d')][_0x7be1('0x98')];})[_0x7be1('0x24')](function(){return db[_0x7be1('0x40')][_0x7be1('0x5a')]({'where':{'id':_0x143a97[_0x7be1('0x59')]['id']},'include':[{'model':db[_0x7be1('0x9e')],'as':_0x7be1('0x9f')}]});})[_0x7be1('0x24')](handleEntityNotFound(_0x3da47d,null))['then'](function(_0x5552a6){if(_0x5552a6&&_0x5552a6[_0x7be1('0x9f')]){_0x621aad=_0x5552a6;var _0x5cf2f0=_[_0x7be1('0x19')](_0x143a97['body'],{'firstName':_0x143a97[_0x7be1('0x5d')][_0x7be1('0x98')],'phone':_0x143a97[_0x7be1('0x5d')][_0x7be1('0x98')],'ListId':_0x5552a6['ListId']});_0x5cf2f0[_0x143a97['body'][_0x7be1('0xcd')]]=_0x143a97[_0x7be1('0x5d')][_0x7be1('0x98')];return db[_0x7be1('0x91')][_0x7be1('0xd0')]({'where':_0x5c22cf,'defaults':_0x5cf2f0});}})[_0x7be1('0xbc')](function(_0x213956){if(_0x213956){_0x72261b=_0x213956;var _0x2a23a4=fs[_0x7be1('0xd1')](path[_0x7be1('0x86')](config[_0x7be1('0x7f')],_0x7be1('0xd2')),'utf8');var _0x2f86de=ejs['render'](_0x2a23a4,{'body':_[_0x7be1('0xd3')](_0x143a97[_0x7be1('0x5d')][_0x7be1('0x5d')]),'bodyTitle':_0x621aad['offlineMessageBody']});return db['ChatOfflineMessage'][_0x7be1('0x5c')]({'body':_0x2f86de,'ContactId':_0x213956['id'],'ChatWebsiteId':_0x621aad['id']});}})['then'](function(_0x85e373){if(_0x85e373){_0x502d2f=_0x85e373;return db[_0x7be1('0xd4')][_0x7be1('0x6b')]({'where':{'service':!![]},'include':[{'model':db[_0x7be1('0xd5')],'as':_0x7be1('0xd6'),'raw':!![]}]});}})[_0x7be1('0x24')](function(_0x5f025e){if(_0x5f025e&&_0x5f025e['Smtp']&&_0x621aad['forwardOfflineAddress']){var _0x18ca54={'tls':{'rejectUnauthorized':![]}};if(_0x5f025e[_0x7be1('0xd6')]['service']){_0x18ca54['service']=_0x5f025e[_0x7be1('0xd6')][_0x7be1('0xd7')];}else{_0x18ca54[_0x7be1('0xd8')]=_0x5f025e[_0x7be1('0xd6')][_0x7be1('0xd8')];_0x18ca54[_0x7be1('0xd9')]=_0x5f025e[_0x7be1('0xd6')]['port'];_0x18ca54[_0x7be1('0xda')]=_0x5f025e['Smtp']['secure'];}if(_0x5f025e[_0x7be1('0xd6')][_0x7be1('0xdb')]){_0x18ca54[_0x7be1('0xdc')]={'user':_0x5f025e['Smtp'][_0x7be1('0x5e')],'pass':_0x5f025e[_0x7be1('0xd6')][_0x7be1('0xdd')]};}return respondWithRpcPromise('SendMail',_0x7be1('0xde'),{'account':_0x18ca54,'message':{'from':util['format'](_0x7be1('0xdf'),_0x5f025e['name'],_0x5f025e[_0x7be1('0xe0')]||_0x5f025e[_0x7be1('0xd6')]['user']),'to':_0x621aad[_0x7be1('0xe1')],'subject':_0x621aad[_0x7be1('0xe2')],'text':_0x502d2f['body']}},client9003)['then'](function(){return _0x502d2f;})[_0x7be1('0x5b')](function(_0x2d843b){console[_0x7be1('0x2a')](_0x2d843b);});}})['then'](function(){if(_0x502d2f){return _0x502d2f;}})[_0x7be1('0x24')](respondWithResult(_0x3da47d,null))[_0x7be1('0x5b')](handleError(_0x3da47d,null));};exports[_0x7be1('0xe3')]=function(_0x2890c9,_0x77a6e3,_0x4b4781){return db[_0x7be1('0xb9')][_0x7be1('0x5a')]({'where':{'id':_0x2890c9[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x77a6e3,null))[_0x7be1('0x24')](function(_0x5ded2f){if(_0x5ded2f){return _0x5ded2f[_0x7be1('0xe3')](_0x2890c9['body'][_0x7be1('0x6f')],_[_0x7be1('0xe4')](_0x2890c9[_0x7be1('0x5d')],[_0x7be1('0x6f'),'id'])||{});}})['then'](respondWithResult(_0x77a6e3,null))[_0x7be1('0x5b')](handleError(_0x77a6e3,null));};exports[_0x7be1('0xe5')]=function(_0x499be8,_0x4e2619,_0x4a9563){var _0x4d9f77={'raw':![],'where':{}};var _0x408ae9={};var _0x1b4fa9={'count':0x0,'rows':[]};return db[_0x7be1('0x40')]['findOne']({'where':{'id':_0x499be8[_0x7be1('0x59')]['id']}})['then'](handleEntityNotFound(_0x4e2619,null))[_0x7be1('0x24')](function(_0x51e8cb){if(_0x51e8cb){_0x408ae9[_0x7be1('0x45')]=_[_0x7be1('0x48')](db[_0x7be1('0xb9')][_0x7be1('0x41')]);_0x408ae9[_0x7be1('0x47')]=_['keys'](_0x499be8['query']);_0x408ae9[_0x7be1('0x50')]=_[_0x7be1('0x49')](_0x408ae9[_0x7be1('0x45')],_0x408ae9[_0x7be1('0x47')]);_0x4d9f77[_0x7be1('0x4b')]=_[_0x7be1('0x49')](_0x408ae9[_0x7be1('0x45')],qs['fields'](_0x499be8[_0x7be1('0x47')][_0x7be1('0x4a')]));_0x4d9f77[_0x7be1('0x4b')]=_0x4d9f77[_0x7be1('0x4b')][_0x7be1('0x4c')]?_0x4d9f77['attributes']:_0x408ae9[_0x7be1('0x45')];if(!_0x499be8[_0x7be1('0x47')][_0x7be1('0x6c')](_0x7be1('0x6d'))){_0x4d9f77[_0x7be1('0x33')]=qs[_0x7be1('0x33')](_0x499be8['query']['limit']);_0x4d9f77[_0x7be1('0x32')]=qs[_0x7be1('0x32')](_0x499be8[_0x7be1('0x47')][_0x7be1('0x32')]);}_0x4d9f77[_0x7be1('0x4d')]=qs['sort'](_0x499be8[_0x7be1('0x47')]['sort']);_0x4d9f77[_0x7be1('0x4f')]=qs[_0x7be1('0x50')](_[_0x7be1('0x73')](_0x499be8[_0x7be1('0x47')],_0x408ae9[_0x7be1('0x50')]));_0x4d9f77['where'][_0x7be1('0x68')]=_0x51e8cb['id'];if(_0x499be8[_0x7be1('0x47')][_0x7be1('0x51')]){_0x4d9f77[_0x7be1('0x4f')]=_[_0x7be1('0x52')](_0x4d9f77[_0x7be1('0x4f')],{'$or':_[_0x7be1('0x46')](_0x4d9f77[_0x7be1('0x4b')],function(_0x42eb70){var _0x35c67a={};_0x35c67a[_0x42eb70]={'$like':'%'+_0x499be8[_0x7be1('0x47')][_0x7be1('0x51')]+'%'};return _0x35c67a;})});}_0x4d9f77=_[_0x7be1('0x52')]({},_0x4d9f77,_0x499be8['options']);return db[_0x7be1('0xb9')][_0x7be1('0x31')]({'where':_0x4d9f77['where']})[_0x7be1('0x24')](function(_0x423e24){_0x1b4fa9[_0x7be1('0x31')]=_0x423e24;if(_0x499be8[_0x7be1('0x47')][_0x7be1('0x55')]){_0x4d9f77[_0x7be1('0x56')]=[{'model':db[_0x7be1('0x91')],'as':_0x7be1('0xe6'),'required':![]},{'model':db[_0x7be1('0xe7')],'as':_0x7be1('0xe8'),'attributes':[_0x7be1('0x3b'),_0x7be1('0xe9'),_0x7be1('0xea')],'required':![]},{'model':db[_0x7be1('0xeb')],'as':_0x7be1('0xec'),'attributes':['id',_0x7be1('0x3b'),_0x7be1('0xed')],'where':_0x499be8[_0x7be1('0x47')][_0x7be1('0xee')]?{'id':_0x499be8[_0x7be1('0x47')][_0x7be1('0xee')]}:undefined,'required':_0x499be8[_0x7be1('0x47')][_0x7be1('0xee')]?!![]:![]}];}return db[_0x7be1('0xb9')][_0x7be1('0x74')](_0x4d9f77);})[_0x7be1('0x24')](function(_0x5c14e8){_0x1b4fa9[_0x7be1('0x57')]=_0x5c14e8;return _0x1b4fa9;});}})[_0x7be1('0x24')](respondWithFilteredResult(_0x4e2619,_0x4d9f77))[_0x7be1('0x5b')](handleError(_0x4e2619,null));};function iftimePromise(_0x31c998,_0x2fe2cf){return respondWithRpcPromise(_0x7be1('0xef'),_0x7be1('0xf0'),{'command':_0x2fe2cf[_0x7be1('0xf1')]?util[_0x7be1('0xb6')](_0x7be1('0xf2'),_0x31c998[_0x7be1('0xf3')],_0x2fe2cf['timezone']):util['format'](_0x7be1('0xf4'),_0x31c998[_0x7be1('0xf3')])},client9002)[_0x7be1('0x24')](function(_0x40be56){var _0x401228=_0x40be56&&_0x40be56[_0x7be1('0xf5')](_0x7be1('0xf6'))>=0x0?!![]:![];logger['info']('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x2fe2cf['id'],_0x31c998['id'],_0x31c998[_0x7be1('0xf3')],_0x401228?_0x7be1('0xf7'):_0x7be1('0xf8'),_0x2fe2cf[_0x7be1('0xf1')]?_0x2fe2cf[_0x7be1('0xf1')]:_0x7be1('0xf9'));return _0x401228;})[_0x7be1('0x5b')](function(_0x52fc4b){logger[_0x7be1('0x2a')](_0x7be1('0xfa'),_0x2fe2cf['id'],_0x31c998['id'],_0x31c998['interval'],util[_0x7be1('0xfb')](_0x52fc4b,{'showHidden':![],'depth':null}),_0x2fe2cf[_0x7be1('0xf1')]?_0x2fe2cf[_0x7be1('0xf1')]:'No\x20timezone');return![];});}exports[_0x7be1('0xf0')]=function(_0x569889,_0x5defb5,_0x2b19e7){var _0xe1bb5b=0x0;var _0x5d268c=0x0;var _0x28fb74=![];var _0x3a7e7d;var _0x3e831c;return db[_0x7be1('0x40')]['find']({'where':{'id':_0x569889[_0x7be1('0x59')]['id']},'include':[{'model':db[_0x7be1('0xfc')],'as':'Interval','include':[{'model':db[_0x7be1('0xfc')],'as':_0x7be1('0xfd'),'attributes':['id',_0x7be1('0xf3')],'raw':!![]}]}]})[_0x7be1('0x24')](handleEntityNotFound(_0x5defb5,null))[_0x7be1('0x24')](function(_0x3143ee){if(_0x3143ee){_0x3a7e7d=_0x3143ee;return _0x3143ee[_0x7be1('0xfe')]({'raw':!![]});}})['then'](function(_0x4cd701){if(_0x3a7e7d){if(_0x4cd701){_0x3e831c=_0x4cd701;}}return require(_0x7be1('0x80'))[_0x7be1('0xff')]();})['then'](function(_0x8503b4){if(_0x8503b4){_0x5d268c=_0x8503b4['virtual'];_0x28fb74=_0x8503b4[_0x7be1('0x81')];}})[_0x7be1('0x24')](function(){return db['ChatInteraction'][_0x7be1('0x31')]({'where':{'closed':![]}});})['then'](function(_0x4738c3){_0xe1bb5b=_0x4738c3;if(_0x5d268c&&_0x4738c3>_0x5d268c){return db[_0x7be1('0x100')][_0x7be1('0x6b')]({'where':{'id':0x1}})[_0x7be1('0x24')](function(_0x524161){if(_0x524161){_0x524161[_0x7be1('0x101')]('chatLicenseExceeded');}});}})['then'](function(){if(_0x3a7e7d['Interval']&&_0x3a7e7d[_0x7be1('0xfc')][_0x7be1('0xfd')]){var _0x80d9c8=[];for(var _0x5afee9=0x0;_0x5afee9<_0x3a7e7d[_0x7be1('0xfc')][_0x7be1('0xfd')][_0x7be1('0x4c')];_0x5afee9++){var _0x47df54=_0x3a7e7d['Interval'][_0x7be1('0xfd')][_0x5afee9]['get']({'plain':!![]});_0x80d9c8[_0x7be1('0xc1')](iftimePromise(_0x47df54,_0x3a7e7d));}return BPromise[_0x7be1('0x102')](_0x80d9c8)[_0x7be1('0x24')](function(_0x123ee0){return _[_0x7be1('0x103')](_0x123ee0);});}else{return!![];}})[_0x7be1('0x24')](function(_0xce1f4b){var _0xbb416b=fs[_0x7be1('0xd1')](path[_0x7be1('0x86')](config['root'],_0x7be1('0x104')),_0x7be1('0x105'));var _0x130961={'remote':_0x3a7e7d[_0x7be1('0x106')],'query':querystring[_0x7be1('0x29')](_[_0x7be1('0x52')](_0x3a7e7d[_0x7be1('0x39')]({'plain':!![]}),{'customerIp':_0x569889['headers']['x-forwarded-for']||_0x569889[_0x7be1('0x8e')][_0x7be1('0x107')]||_0x569889['connection'][_0x7be1('0x108')]||_0x569889['ip'],'referer':_0x569889[_0x7be1('0x8e')][_0x7be1('0x109')],'openedInteractions':_0xe1bb5b,'maxInteractions':_0x5d268c,'virtual':_0x28fb74['virtual'],'online':_0xce1f4b,'custom':_0x28fb74}))['replace'](/'/g,'\x5c\x27')};_0x5defb5[_0x7be1('0x3c')](ejs[_0x7be1('0x10a')](Mustache[_0x7be1('0x10a')](_0xbb416b,_0x130961),{'proactiveActions':_0x3e831c,'alignment':_0x3a7e7d['alignment'],'verticalAlignment':_0x3a7e7d[_0x7be1('0x10b')],'div_color':_0x3a7e7d['color'],'text_color':_0x3a7e7d[_0x7be1('0x10c')]}));})[_0x7be1('0x5b')](handleError(_0x5defb5,null));};exports[_0x7be1('0x10d')]=function(_0x6bcfc4,_0x391213,_0x11c04d){return db[_0x7be1('0x40')]['findOne']({'where':{'id':_0x6bcfc4[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x391213,null))[_0x7be1('0x24')](function(_0x307973){if(_0x307973){return db[_0x7be1('0x10e')][_0x7be1('0x10f')](function(_0x9133){return db[_0x7be1('0x110')][_0x7be1('0x38')]({'where':{'ChatWebsiteId':_0x6bcfc4['params']['id']},'transaction':_0x9133})[_0x7be1('0x24')](function(_0x45985d){var _0x4a3d73=_[_0x7be1('0x46')](_0x6bcfc4[_0x7be1('0x5d')],function(_0x329d69){_0x329d69[_0x7be1('0x68')]=_0x6bcfc4[_0x7be1('0x59')]['id'];return _0x329d69;});return db[_0x7be1('0x110')][_0x7be1('0x111')](_0x4a3d73,{'transaction':_0x9133});});})[_0x7be1('0x24')](function(){return db[_0x7be1('0x110')]['findAndCountAll']({'where':{'ChatWebsiteId':_0x6bcfc4[_0x7be1('0x59')]['id']},'order':_0x7be1('0xa5')});});}})['then'](respondWithResult(_0x391213,null))[_0x7be1('0x5b')](handleError(_0x391213,null));};exports[_0x7be1('0x112')]=function(_0x22afe4,_0x11d16e,_0xc633cd){var _0x25e23c={};var _0x5937b8={};var _0xb1f89e;var _0xced815;return db[_0x7be1('0x40')][_0x7be1('0x6b')]({'where':{'id':_0x22afe4[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x11d16e,null))['then'](function(_0x3882b5){if(_0x3882b5){_0xb1f89e=_0x3882b5;_0x5937b8[_0x7be1('0x45')]=_[_0x7be1('0x48')](db['ChatApplication'][_0x7be1('0x41')]);_0x5937b8[_0x7be1('0x47')]=_[_0x7be1('0x48')](_0x22afe4[_0x7be1('0x47')]);_0x5937b8[_0x7be1('0x50')]=_[_0x7be1('0x49')](_0x5937b8[_0x7be1('0x45')],_0x5937b8[_0x7be1('0x47')]);_0x25e23c[_0x7be1('0x4b')]=_[_0x7be1('0x49')](_0x5937b8[_0x7be1('0x45')],qs[_0x7be1('0x4a')](_0x22afe4['query'][_0x7be1('0x4a')]));_0x25e23c[_0x7be1('0x4b')]=_0x25e23c[_0x7be1('0x4b')][_0x7be1('0x4c')]?_0x25e23c['attributes']:_0x5937b8[_0x7be1('0x45')];_0x25e23c[_0x7be1('0x4d')]=qs['sort'](_0x22afe4[_0x7be1('0x47')][_0x7be1('0x4e')]);_0x25e23c[_0x7be1('0x4f')]=qs[_0x7be1('0x50')](_[_0x7be1('0x73')](_0x22afe4[_0x7be1('0x47')],_0x5937b8[_0x7be1('0x50')]));if(_0x22afe4['query'][_0x7be1('0x51')]){_0x25e23c[_0x7be1('0x4f')]=_[_0x7be1('0x52')](_0x25e23c['where'],{'$or':_['map'](_0x25e23c[_0x7be1('0x4b')],function(_0x358b6d){var _0x27431a={};_0x27431a[_0x358b6d]={'$like':'%'+_0x22afe4[_0x7be1('0x47')][_0x7be1('0x51')]+'%'};return _0x27431a;})});}_0x25e23c=_[_0x7be1('0x52')]({},_0x25e23c,_0x22afe4[_0x7be1('0x54')]);return _0xb1f89e['getApplications'](_0x25e23c);}})[_0x7be1('0x24')](function(_0x67a634){if(_0x67a634){_0xced815=_0x67a634[_0x7be1('0x4c')];if(!_0x22afe4['query']['hasOwnProperty'](_0x7be1('0x6d'))){_0x25e23c[_0x7be1('0x33')]=qs[_0x7be1('0x33')](_0x22afe4[_0x7be1('0x47')][_0x7be1('0x33')]);_0x25e23c[_0x7be1('0x32')]=qs[_0x7be1('0x32')](_0x22afe4[_0x7be1('0x47')][_0x7be1('0x32')]);}return _0xb1f89e['getApplications'](_0x25e23c);}})[_0x7be1('0x24')](function(_0x390085){if(_0x390085){return _0x390085?{'count':_0xced815,'rows':_0x390085}:null;}})['then'](respondWithResult(_0x11d16e,null))[_0x7be1('0x5b')](handleError(_0x11d16e,null));};exports[_0x7be1('0x113')]=function(_0x33d04c,_0x10e798,_0x2c2523){return db[_0x7be1('0x114')]['find']({'where':{'id':_0x33d04c['params']['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x10e798,null))['then'](function(_0x53a157){if(_0x53a157){return _0x53a157[_0x7be1('0x113')](_0x33d04c['body'][_0x7be1('0x6f')],_[_0x7be1('0xe4')](_0x33d04c[_0x7be1('0x5d')],[_0x7be1('0x6f'),'id'])||{});}})[_0x7be1('0x24')](respondWithResult(_0x10e798,null))['catch'](handleError(_0x10e798,null));};exports[_0x7be1('0xfe')]=function(_0x2809e2,_0x567e8a,_0x194774){var _0x1438c1={};var _0x23630e={};var _0x38b944;var _0x227900;return db[_0x7be1('0x40')][_0x7be1('0x6b')]({'where':{'id':_0x2809e2['params']['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x567e8a,null))['then'](function(_0x5424b0){if(_0x5424b0){_0x38b944=_0x5424b0;_0x23630e[_0x7be1('0x45')]=_['keys'](db[_0x7be1('0x115')]['rawAttributes']);_0x23630e[_0x7be1('0x47')]=_['keys'](_0x2809e2['query']);_0x23630e[_0x7be1('0x50')]=_[_0x7be1('0x49')](_0x23630e[_0x7be1('0x45')],_0x23630e[_0x7be1('0x47')]);_0x1438c1[_0x7be1('0x4b')]=_['intersection'](_0x23630e[_0x7be1('0x45')],qs[_0x7be1('0x4a')](_0x2809e2[_0x7be1('0x47')][_0x7be1('0x4a')]));_0x1438c1[_0x7be1('0x4b')]=_0x1438c1[_0x7be1('0x4b')][_0x7be1('0x4c')]?_0x1438c1[_0x7be1('0x4b')]:_0x23630e[_0x7be1('0x45')];_0x1438c1['order']=qs[_0x7be1('0x4e')](_0x2809e2['query'][_0x7be1('0x4e')]);_0x1438c1[_0x7be1('0x4f')]=qs[_0x7be1('0x50')](_[_0x7be1('0x73')](_0x2809e2[_0x7be1('0x47')],_0x23630e['filters']));if(_0x2809e2[_0x7be1('0x47')][_0x7be1('0x51')]){_0x1438c1[_0x7be1('0x4f')]=_['merge'](_0x1438c1[_0x7be1('0x4f')],{'$or':_['map'](_0x1438c1[_0x7be1('0x4b')],function(_0x126338){var _0x361985={};_0x361985[_0x126338]={'$like':'%'+_0x2809e2[_0x7be1('0x47')][_0x7be1('0x51')]+'%'};return _0x361985;})});}_0x1438c1=_[_0x7be1('0x52')]({},_0x1438c1,_0x2809e2[_0x7be1('0x54')]);return _0x38b944['getProactiveActions'](_0x1438c1);}})[_0x7be1('0x24')](function(_0x38c06b){if(_0x38c06b){_0x227900=_0x38c06b['length'];if(!_0x2809e2['query'][_0x7be1('0x6c')](_0x7be1('0x6d'))){_0x1438c1[_0x7be1('0x33')]=qs[_0x7be1('0x33')](_0x2809e2['query'][_0x7be1('0x33')]);_0x1438c1[_0x7be1('0x32')]=qs['offset'](_0x2809e2[_0x7be1('0x47')]['offset']);}return _0x38b944[_0x7be1('0xfe')](_0x1438c1);}})[_0x7be1('0x24')](function(_0x47decc){if(_0x47decc){return _0x47decc?{'count':_0x227900,'rows':_0x47decc}:null;}})[_0x7be1('0x24')](respondWithResult(_0x567e8a,null))[_0x7be1('0x5b')](handleError(_0x567e8a,null));};exports[_0x7be1('0x116')]=function(_0x5d6dfa,_0x5eddb7,_0x4519d0){var _0x22254d=_0x5d6dfa['query'][_0x7be1('0x117')]==='false'?_0x7be1('0x118'):_0x7be1('0x119');return db[_0x7be1('0x40')][_0x7be1('0x5a')]({'attributes':['id',_0x22254d],'where':{'id':_0x5d6dfa[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x5eddb7,null))[_0x7be1('0x24')](function(_0x4eb49b){if(_0x4eb49b){var _0x2fd6b4=_0x4eb49b[_0x22254d];var _0x602411=_0x2fd6b4&&_0x2fd6b4['items']?_0x2fd6b4[_0x7be1('0x11a')]:[];_0x5eddb7[_0x7be1('0x3c')]({'fromKey':_[_0x7be1('0x82')](_0x2fd6b4[_0x7be1('0x11b')])?undefined:_0x2fd6b4[_0x7be1('0x11b')],'count':_0x602411['length'],'rows':_0x602411});}})['catch'](handleError(_0x5eddb7,null));};exports[_0x7be1('0x11c')]=function(_0x24aea8,_0x4c40fd,_0x265d92){var _0x1ed905={'raw':![],'where':{}};var _0x5e1e26={};var _0x283851={'count':0x0,'rows':[]};return db[_0x7be1('0x40')]['findOne']({'where':{'id':_0x24aea8[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x4c40fd,null))['then'](function(_0x2b6cb5){if(_0x2b6cb5){_0x5e1e26[_0x7be1('0x45')]=_[_0x7be1('0x48')](db['ChatOfflineMessage'][_0x7be1('0x41')]);_0x5e1e26[_0x7be1('0x47')]=_[_0x7be1('0x48')](_0x24aea8['query']);_0x5e1e26['filters']=_[_0x7be1('0x49')](_0x5e1e26[_0x7be1('0x45')],_0x5e1e26[_0x7be1('0x47')]);_0x1ed905[_0x7be1('0x4b')]=_['intersection'](_0x5e1e26[_0x7be1('0x45')],qs[_0x7be1('0x4a')](_0x24aea8[_0x7be1('0x47')]['fields']));_0x1ed905[_0x7be1('0x4b')]=_0x1ed905[_0x7be1('0x4b')][_0x7be1('0x4c')]?_0x1ed905['attributes']:_0x5e1e26['model'];if(!_0x24aea8[_0x7be1('0x47')]['hasOwnProperty'](_0x7be1('0x6d'))){_0x1ed905[_0x7be1('0x33')]=qs['limit'](_0x24aea8[_0x7be1('0x47')][_0x7be1('0x33')]);_0x1ed905['offset']=qs[_0x7be1('0x32')](_0x24aea8[_0x7be1('0x47')][_0x7be1('0x32')]);}_0x1ed905['order']=qs[_0x7be1('0x4e')](_0x24aea8[_0x7be1('0x47')][_0x7be1('0x4e')]);_0x1ed905[_0x7be1('0x4f')]=qs[_0x7be1('0x50')](_[_0x7be1('0x73')](_0x24aea8['query'],_0x5e1e26[_0x7be1('0x50')]));_0x1ed905[_0x7be1('0x4f')][_0x7be1('0x68')]=_0x2b6cb5['id'];if(_0x24aea8['query'][_0x7be1('0x51')]){_0x1ed905[_0x7be1('0x4f')]=_[_0x7be1('0x52')](_0x1ed905[_0x7be1('0x4f')],{'$or':_[_0x7be1('0x46')](_0x1ed905[_0x7be1('0x4b')],function(_0x8d1c44){var _0x569260={};_0x569260[_0x8d1c44]={'$like':'%'+_0x24aea8['query'][_0x7be1('0x51')]+'%'};return _0x569260;})});}_0x1ed905=_[_0x7be1('0x52')]({},_0x1ed905,_0x24aea8['options']);return db[_0x7be1('0x11d')][_0x7be1('0x31')]({'where':_0x1ed905['where']})[_0x7be1('0x24')](function(_0xf9dbf2){_0x283851[_0x7be1('0x31')]=_0xf9dbf2;if(_0x24aea8[_0x7be1('0x47')][_0x7be1('0x55')]){_0x1ed905[_0x7be1('0x56')]=[{'all':!![]}];}else{_0x1ed905['include']=[{'model':db[_0x7be1('0x91')],'as':_0x7be1('0xe6'),'required':![]}];}return db[_0x7be1('0x11d')][_0x7be1('0x74')](_0x1ed905);})[_0x7be1('0x24')](function(_0x14f9bd){_0x283851[_0x7be1('0x57')]=_0x14f9bd;return _0x283851;});}})[_0x7be1('0x24')](respondWithFilteredResult(_0x4c40fd,_0x1ed905))[_0x7be1('0x5b')](handleError(_0x4c40fd,null));};exports['addAgents']=function(_0x2ced1c,_0x3e1418,_0x1db8fb){return db['ChatWebsite'][_0x7be1('0x5a')]({'where':{'id':_0x2ced1c[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x3e1418,null))[_0x7be1('0x24')](function(_0x2b8a38){if(_0x2b8a38){return _0x2b8a38[_0x7be1('0x11e')](_0x2ced1c[_0x7be1('0x5d')]['ids'],_[_0x7be1('0xe4')](_0x2ced1c[_0x7be1('0x5d')],[_0x7be1('0x6f'),'id'])||{})['spread'](function(_0x25aefc){for(var _0x312ab0=0x0;_0x312ab0<_0x2ced1c[_0x7be1('0x5d')][_0x7be1('0x6f')][_0x7be1('0x4c')];_0x312ab0+=0x1){socket[_0x7be1('0x11f')](_0x7be1('0x120'),{'UserId':_0x2ced1c[_0x7be1('0x5d')][_0x7be1('0x6f')][_0x312ab0],'ChatWebsiteId':_0x2ced1c[_0x7be1('0x59')]['id']});}return _0x25aefc;});}})['then'](respondWithResult(_0x3e1418,null))[_0x7be1('0x5b')](handleError(_0x3e1418,null));};exports[_0x7be1('0x121')]=function(_0xedcf4c,_0x40e450,_0x14a09a){return db['ChatWebsite'][_0x7be1('0x5a')]({'where':{'id':_0xedcf4c[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x40e450,null))['then'](function(_0x2d4938){if(_0x2d4938){return _0x2d4938['removeAgents'](_0xedcf4c[_0x7be1('0x47')][_0x7be1('0x6f')])['then'](function(){if(_[_0x7be1('0x122')](_0xedcf4c['query'][_0x7be1('0x6f')])){for(var _0x57e5fb=0x0;_0x57e5fb<_0xedcf4c[_0x7be1('0x47')][_0x7be1('0x6f')][_0x7be1('0x4c')];_0x57e5fb+=0x1){socket[_0x7be1('0x11f')](_0x7be1('0x123'),{'UserId':Number(_0xedcf4c['query'][_0x7be1('0x6f')][_0x57e5fb]),'ChatWebsiteId':Number(_0xedcf4c['params']['id'])});}}else{socket[_0x7be1('0x11f')](_0x7be1('0x123'),{'UserId':Number(_0xedcf4c[_0x7be1('0x47')][_0x7be1('0x6f')]),'ChatWebsiteId':Number(_0xedcf4c['params']['id'])});}});}})[_0x7be1('0x24')](respondWithStatusCode(_0x40e450,null))['catch'](handleError(_0x40e450,null));};exports['getAgents']=function(_0x2d41da,_0x10ffc8,_0x57a54a){var _0x2c2bac={};var _0x411baf={};var _0x41926d;var _0xe0641e;return db[_0x7be1('0x40')][_0x7be1('0x6b')]({'where':{'id':_0x2d41da[_0x7be1('0x59')]['id']}})[_0x7be1('0x24')](handleEntityNotFound(_0x10ffc8,null))[_0x7be1('0x24')](function(_0x5bc3a){if(_0x5bc3a){_0x41926d=_0x5bc3a;_0x411baf[_0x7be1('0x45')]=_[_0x7be1('0x48')](db[_0x7be1('0xe7')][_0x7be1('0x41')]);_0x411baf[_0x7be1('0x47')]=_[_0x7be1('0x48')](_0x2d41da['query']);_0x411baf['filters']=_[_0x7be1('0x49')](_0x411baf[_0x7be1('0x45')],_0x411baf['query']);_0x2c2bac[_0x7be1('0x4b')]=_[_0x7be1('0x49')](_0x411baf['model'],qs[_0x7be1('0x4a')](_0x2d41da['query'][_0x7be1('0x4a')]));_0x2c2bac['attributes']=_0x2c2bac[_0x7be1('0x4b')][_0x7be1('0x4c')]?_0x2c2bac[_0x7be1('0x4b')]:_0x411baf[_0x7be1('0x45')];_0x2c2bac[_0x7be1('0x4d')]=qs[_0x7be1('0x4e')](_0x2d41da[_0x7be1('0x47')][_0x7be1('0x4e')]);_0x2c2bac['where']=qs[_0x7be1('0x50')](_['pick'](_0x2d41da[_0x7be1('0x47')],_0x411baf[_0x7be1('0x50')]));if(_0x2d41da[_0x7be1('0x47')][_0x7be1('0x51')]){_0x2c2bac[_0x7be1('0x4f')]=_[_0x7be1('0x52')](_0x2c2bac['where'],{'$or':_['map'](_0x2c2bac[_0x7be1('0x4b')],function(_0x3bee14){var _0x275334={};_0x275334[_0x3bee14]={'$like':'%'+_0x2d41da[_0x7be1('0x47')][_0x7be1('0x51')]+'%'};return _0x275334;})});}_0x2c2bac=_[_0x7be1('0x52')]({},_0x2c2bac,_0x2d41da[_0x7be1('0x54')]);return _0x41926d[_0x7be1('0x124')](_0x2c2bac);}})[_0x7be1('0x24')](function(_0xf1959a){if(_0xf1959a){_0xe0641e=_0xf1959a['length'];if(!_0x2d41da['query'][_0x7be1('0x6c')](_0x7be1('0x6d'))){_0x2c2bac['limit']=qs[_0x7be1('0x33')](_0x2d41da[_0x7be1('0x47')][_0x7be1('0x33')]);_0x2c2bac[_0x7be1('0x32')]=qs['offset'](_0x2d41da[_0x7be1('0x47')][_0x7be1('0x32')]);}return _0x41926d[_0x7be1('0x124')](_0x2c2bac);}})[_0x7be1('0x24')](function(_0x277ac9){if(_0x277ac9){return _0x277ac9?{'count':_0xe0641e,'rows':_0x277ac9}:null;}})[_0x7be1('0x24')](respondWithResult(_0x10ffc8,null))[_0x7be1('0x5b')](handleError(_0x10ffc8,null));};
\ No newline at end of file
+var _0xee46=['first','split','firstName','lastName','x-real-port','version','format','%s\x20%s','browser','unknown','device','model','vendor','%s\x20%s\x20%s','type','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','fieldName','keys','query','intersection','attributes','fields','length','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','find','create','address','body','\x22\x20is\x20not\x20a\x20valid\x20website\x20domain','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','describe','addDisposition','ChatWebsiteId','Disposition','hasOwnProperty','removeDispositions','ids','CannedAnswer','findOne','nolimit','removeAnswers','addLogo','sitepic','filename','addAvatar','file','addCustomerAvatar','systemAvatar','getLogo','join','root','../../config/license/util','custom','isNil','server/files/images/logos/','download','server/files/images/avatars/default_avatar.png','agentAvatar','existsSync','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','customerAvatar','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','Interval','timezone','ifTime','notify','chat','from','From\x20is\x20mandatory','mapKey','MapKey\x20is\x20mandatory','isEmpty','Body\x20is\x20mandatory','referer','CmContact','No\x20available\x20attributes','includes','createdAt','ListId','Invalid\x20MapKey\x20parameter.\x20Allowed\x20values:\x20','CmList','List','Contacts','updatedAt','DESC','ChatApplication','Applications','interval','Chat\x20Website\x20with\x20id\x20%s\x20not\x20found','applications','priority','list','contact','headers','threadId','closed','externalUrl','ChatInteraction','ContactId','interaction','messageId','created','account','autoclose','push','close','unmanaged','*,*,*,*','ChatMessage','UserId','User','unshift','agent','waitForTheAssignedAgent','forcedOwnership','queueId','waitForTheAssignedQueue','Start','startRouting','EventManager','files','Sequelize','ValidationError','no\x20available\x20attributes','CompanyId','send','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','spread','readFileSync','server/files/templates/chatOfflineMessage.ejs','render','toPairs','offlineMessageBody','fromString','originalname','mimetype','attachments','offline-chat','basename','openNewInteraction','transaction','Attachment','bulkCreate','MailServerOut','Smtp','CloudProvider','forwardOffline','forwardOfflineAddress','getSmtpOptions','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','subjectOffline','toPairsIn','mapValues','Chat','MailAccountId','NotifyMailAccount','notifyMail','addInteraction','fullname','internal','Tags','tag','getSnippet','getProactiveActions','getLicense','virtual','License','increment','chatLicenseExceeded','server/files/chat/iframe.ejs','3.9.0','origin','replace','testWebsiteWithWildcard','x-real-ip','connection','alignment','color','labelText','textColor','textButtonColor','backgroundColor','addApplications','sequelize','ISOLATION_LEVELS','READ_COMMITTED','findAndCountAll','stack','finally','getApplications','addProactiveActions','chatProactiveAction','omit','getFields','online','false','offlineForm','items','fromKey','ChatOfflineMessage','Attachments','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','util','path','ejs','fs-extra','lodash','querystring','ioredis','jayson/promise','../../components/parsers/qs','../../config/logger','api','../../config/environment','APIBadRequestError','../../errors/api','APINotFoundError','APIOutOfIntervalError','handleError','APIConflictError','./helpers/wildcard-expressions','URL','redis','defaults','localhost','socket.io-emitter','./chatWebsite.socket','register','client','http','then','info','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','ChatWebsite,\x20%s,\x20%s','message','result','catch','sendStatus','status','end','json','limit','undefined','count','offset','Content-Range','update','destroy','ChatWebsites','UserProfileResource','name','user-agent-parser','setUA','user-agent','customerIp','x-forwarded-for'];(function(_0x4fe5b5,_0x41efab){var _0x221fbe=function(_0x35fd94){while(--_0x35fd94){_0x4fe5b5['push'](_0x4fe5b5['shift']());}};_0x221fbe(++_0x41efab);}(_0xee46,0xf2));var _0x6ee4=function(_0x246251,_0x5974c0){_0x246251=_0x246251-0x0;var _0x58d5ee=_0xee46[_0x246251];return _0x58d5ee;};'use strict';var Mustache=require('mustache');var util=require(_0x6ee4('0x0'));var path=require(_0x6ee4('0x1'));var ejs=require(_0x6ee4('0x2'));var fs=require('fs');var fs_extra=require(_0x6ee4('0x3'));var _=require(_0x6ee4('0x4'));var querystring=require(_0x6ee4('0x5'));var htmlToText=require('html-to-text');var Redis=require(_0x6ee4('0x6'));var jayson=require(_0x6ee4('0x7'));var qs=require(_0x6ee4('0x8'));var logger=require(_0x6ee4('0x9'))(_0x6ee4('0xa'));var config=require(_0x6ee4('0xb'));var APIBadRequestError=require('../../errors/api')[_0x6ee4('0xc')];var APINotFoundError=require(_0x6ee4('0xd'))[_0x6ee4('0xe')];var APIOutOfIntervalError=require(_0x6ee4('0xd'))[_0x6ee4('0xf')];var APIHandleError=require(_0x6ee4('0xd'))[_0x6ee4('0x10')];var APIConflictError=require(_0x6ee4('0xd'))[_0x6ee4('0x11')];var wildcardUtils=require(_0x6ee4('0x12'));var URL=require('url')[_0x6ee4('0x13')];var db=require('../../mysqldb')['db'];config[_0x6ee4('0x14')]=_[_0x6ee4('0x15')](config['redis'],{'host':_0x6ee4('0x16'),'port':0x18eb});var socket=require(_0x6ee4('0x17'))(new Redis(config['redis']));require(_0x6ee4('0x18'))[_0x6ee4('0x19')](socket);var client=jayson[_0x6ee4('0x1a')]['http']({'port':0x232c});var client9002=jayson['client'][_0x6ee4('0x1b')]({'port':0x232a});var client9003=jayson[_0x6ee4('0x1a')][_0x6ee4('0x1b')]({'port':0x232b});var client9001=jayson[_0x6ee4('0x1a')][_0x6ee4('0x1b')]({'port':0x2329});function respondWithRpcPromise(_0x2eca80,_0x4af711,_0x2af5f8,_0x4ba6dc){return new Promise(function(_0x2886c2,_0x4c1192){var _0x9d4ae8=_0x4ba6dc||client;return _0x9d4ae8['request'](_0x2eca80,_0x2af5f8)[_0x6ee4('0x1c')](function(_0x3cdcae){logger[_0x6ee4('0x1d')]('ChatWebsite,\x20%s,\x20%s',_0x4af711,_0x6ee4('0x1e'));logger[_0x6ee4('0x1f')](_0x6ee4('0x20'),_0x4af711,'request\x20sent',JSON[_0x6ee4('0x21')](_0x3cdcae));if(_0x3cdcae[_0x6ee4('0x22')]){if(_0x3cdcae[_0x6ee4('0x22')][_0x6ee4('0x23')]===0x1f4){logger[_0x6ee4('0x22')](_0x6ee4('0x24'),_0x4af711,_0x3cdcae[_0x6ee4('0x22')][_0x6ee4('0x25')]);return _0x4c1192(_0x3cdcae[_0x6ee4('0x22')]['message']);}logger[_0x6ee4('0x22')](_0x6ee4('0x24'),_0x4af711,_0x3cdcae[_0x6ee4('0x22')][_0x6ee4('0x25')]);return _0x2886c2(_0x3cdcae[_0x6ee4('0x22')]['message']);}else{logger[_0x6ee4('0x1d')](_0x6ee4('0x24'),_0x4af711,_0x6ee4('0x1e'));_0x2886c2(_0x3cdcae[_0x6ee4('0x26')]['message']);}})[_0x6ee4('0x27')](function(_0x293d0b){logger[_0x6ee4('0x22')]('ChatWebsite,\x20%s,\x20%s',_0x4af711,_0x293d0b);_0x4c1192(_0x293d0b);});});}function respondWithStatusCode(_0x5639e5,_0x520dd2){_0x520dd2=_0x520dd2||0xcc;return function(_0x18efa3){if(_0x18efa3){return _0x5639e5[_0x6ee4('0x28')](_0x520dd2);}return _0x5639e5[_0x6ee4('0x29')](_0x520dd2)[_0x6ee4('0x2a')]();};}function respondWithResult(_0xf76d23,_0x22a43e){_0x22a43e=_0x22a43e||0xc8;return function(_0x5784a0){if(_0x5784a0){return _0xf76d23[_0x6ee4('0x29')](_0x22a43e)[_0x6ee4('0x2b')](_0x5784a0);}};}function respondWithFilteredResult(_0x2eab8a,_0x2fcb80){return function(_0x48b762){if(_0x48b762){var _0x2193b1=typeof _0x2fcb80['offset']==='undefined'&&typeof _0x2fcb80[_0x6ee4('0x2c')]===_0x6ee4('0x2d');var _0x11fafb=_0x48b762[_0x6ee4('0x2e')];var _0x4f1481=_0x2193b1?0x0:_0x2fcb80[_0x6ee4('0x2f')];var _0x1e53f9=_0x2193b1?_0x48b762[_0x6ee4('0x2e')]:_0x2fcb80[_0x6ee4('0x2f')]+_0x2fcb80[_0x6ee4('0x2c')];var _0x4da82d;if(_0x1e53f9>=_0x11fafb){_0x1e53f9=_0x11fafb;_0x4da82d=0xc8;}else{_0x4da82d=0xce;}_0x2eab8a['status'](_0x4da82d);return _0x2eab8a['set'](_0x6ee4('0x30'),_0x4f1481+'-'+_0x1e53f9+'/'+_0x11fafb)[_0x6ee4('0x2b')](_0x48b762);}return null;};}function saveUpdates(_0x33bcb0){return function(_0x132291){if(_0x132291){return _0x132291[_0x6ee4('0x31')](_0x33bcb0)[_0x6ee4('0x1c')](function(_0x19ed72){return _0x19ed72;});}return null;};}function removeEntity(_0x54b88c){return function(_0x5273bc){if(_0x5273bc){return _0x5273bc[_0x6ee4('0x32')]()[_0x6ee4('0x1c')](function(){var _0x2a6d38=_0x5273bc['get']({'plain':!![]});var _0x15d653=_0x6ee4('0x33');return db[_0x6ee4('0x34')][_0x6ee4('0x32')]({'where':{'type':_0x15d653,'resourceId':_0x2a6d38['id']}})[_0x6ee4('0x1c')](function(){return _0x5273bc;});})[_0x6ee4('0x1c')](function(){_0x54b88c['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x258e0f){return function(_0x2ec82f){if(!_0x2ec82f){_0x258e0f[_0x6ee4('0x28')](0x194);}return _0x2ec82f;};}function handleError(_0x5a6e44,_0x1de2b4){_0x1de2b4=_0x1de2b4||0x1f4;return function(_0x26abb0){logger[_0x6ee4('0x22')](_0x26abb0['stack']);if(_0x26abb0[_0x6ee4('0x35')]){delete _0x26abb0[_0x6ee4('0x35')];}_0x5a6e44[_0x6ee4('0x29')](_0x1de2b4)['send'](_0x26abb0);};}function createInteractionObject(_0x1215e5,_0x26e5cb,_0x42399c,_0x5eb568){var _0x5f0e3f=require(_0x6ee4('0x36'));var _0x45b871=new _0x5f0e3f();var _0x575e97=_0x45b871[_0x6ee4('0x37')](_0x42399c[_0x6ee4('0x38')])['getResult']();var _0x3b48e3=_0x26e5cb[_0x6ee4('0x39')];if(_0x42399c['cf-connecting-ip']){_0x3b48e3=_0x42399c['cf-connecting-ip'];}else if(_0x42399c[_0x6ee4('0x3a')]){_0x3b48e3=_[_0x6ee4('0x3b')](_0x42399c['x-forwarded-for'][_0x6ee4('0x3c')](','));}return{'ContactId':_0x5eb568['id'],'ChatWebsiteId':_0x1215e5,'from':(_0x5eb568[_0x6ee4('0x3d')]||'')+'\x20'+(_0x5eb568[_0x6ee4('0x3e')]||''),'customerIp':_0x3b48e3,'customerPort':_0x42399c[_0x6ee4('0x3f')]?_0x42399c[_0x6ee4('0x3f')]:null,'referer':_0x26e5cb['referer'],'browserName':_0x575e97['browser'][_0x6ee4('0x35')]&&_0x575e97['browser'][_0x6ee4('0x40')]?util[_0x6ee4('0x41')](_0x6ee4('0x42'),_0x575e97[_0x6ee4('0x43')][_0x6ee4('0x35')],_0x575e97[_0x6ee4('0x43')][_0x6ee4('0x40')]):_0x6ee4('0x44'),'browserVersion':_0x575e97[_0x6ee4('0x43')]['version']||'unknown','osName':util[_0x6ee4('0x41')](_0x6ee4('0x42'),_0x575e97['os'][_0x6ee4('0x35')],_0x575e97['os'][_0x6ee4('0x40')]),'osVersion':_0x575e97['os'][_0x6ee4('0x40')],'deviceModel':_0x575e97[_0x6ee4('0x45')][_0x6ee4('0x46')]&&_0x575e97[_0x6ee4('0x45')][_0x6ee4('0x47')]?util[_0x6ee4('0x41')](_0x6ee4('0x48'),_0x575e97[_0x6ee4('0x45')][_0x6ee4('0x46')],_0x575e97['device'][_0x6ee4('0x47')],_0x575e97['device'][_0x6ee4('0x49')]):null,'deviceVendor':_0x575e97[_0x6ee4('0x45')][_0x6ee4('0x47')],'deviceType':_0x575e97[_0x6ee4('0x45')][_0x6ee4('0x49')],'formData':JSON[_0x6ee4('0x21')](_0x26e5cb)};}exports['index']=function(_0x115a29,_0x19443c){var _0x314963={'include':[{'model':db[_0x6ee4('0x4a')],'as':_0x6ee4('0x4b')}]},_0x303510={},_0x5c4880={'count':0x0,'rows':[]};var _0xa5771a=_[_0x6ee4('0x4c')](db[_0x6ee4('0x4d')][_0x6ee4('0x4e')],function(_0x43b31d){return{'name':_0x43b31d[_0x6ee4('0x4f')],'type':_0x43b31d[_0x6ee4('0x49')]['key']};});_0x303510[_0x6ee4('0x46')]=_[_0x6ee4('0x4c')](_0xa5771a,_0x6ee4('0x35'));_0x303510['query']=_[_0x6ee4('0x50')](_0x115a29[_0x6ee4('0x51')]);_0x303510['filters']=_[_0x6ee4('0x52')](_0x303510[_0x6ee4('0x46')],_0x303510[_0x6ee4('0x51')]);_0x314963[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x303510[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x115a29[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x314963[_0x6ee4('0x53')]=_0x314963['attributes'][_0x6ee4('0x55')]?_0x314963['attributes']:_0x303510[_0x6ee4('0x46')];if(!_0x115a29[_0x6ee4('0x51')]['hasOwnProperty']('nolimit')){_0x314963[_0x6ee4('0x2c')]=qs['limit'](_0x115a29[_0x6ee4('0x51')][_0x6ee4('0x2c')]);_0x314963['offset']=qs['offset'](_0x115a29[_0x6ee4('0x51')]['offset']);}_0x314963[_0x6ee4('0x56')]=qs[_0x6ee4('0x57')](_0x115a29[_0x6ee4('0x51')]['sort']);_0x314963[_0x6ee4('0x58')]=qs[_0x6ee4('0x59')](_[_0x6ee4('0x5a')](_0x115a29['query'],_0x303510['filters']),_0xa5771a);if(_0x115a29[_0x6ee4('0x51')][_0x6ee4('0x5b')]){_0x314963[_0x6ee4('0x58')]=_[_0x6ee4('0x5c')](_0x314963[_0x6ee4('0x58')],{'$or':_[_0x6ee4('0x4c')](_0xa5771a,function(_0x51623b){if(_0x51623b[_0x6ee4('0x49')]!==_0x6ee4('0x5d')){var _0x1dfc51={};_0x1dfc51[_0x51623b[_0x6ee4('0x35')]]={'$like':'%'+_0x115a29[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x1dfc51;}})});}_0x314963=_[_0x6ee4('0x5c')]({},_0x314963,_0x115a29[_0x6ee4('0x5e')]);var _0x2dfbbe={'where':_0x314963[_0x6ee4('0x58')]};return db[_0x6ee4('0x4d')][_0x6ee4('0x2e')](_0x2dfbbe)[_0x6ee4('0x1c')](function(_0x37deb3){_0x5c4880[_0x6ee4('0x2e')]=_0x37deb3;if(_0x115a29[_0x6ee4('0x51')][_0x6ee4('0x5f')]){_0x314963[_0x6ee4('0x60')]=[{'all':!![]}];}return db['ChatWebsite'][_0x6ee4('0x61')](_0x314963);})['then'](function(_0x413aa2){_0x5c4880[_0x6ee4('0x62')]=_0x413aa2;return _0x5c4880;})[_0x6ee4('0x1c')](respondWithFilteredResult(_0x19443c,_0x314963))[_0x6ee4('0x27')](handleError(_0x19443c,null));};exports[_0x6ee4('0x63')]=function(_0x3f3480,_0x2683f1){var _0x3e6d47={'raw':![],'where':{'id':_0x3f3480[_0x6ee4('0x64')]['id']},'include':[{'model':db[_0x6ee4('0x4a')],'as':'mandatoryDispositionPause'}]},_0x3f209c={};_0x3f209c[_0x6ee4('0x46')]=_[_0x6ee4('0x50')](db[_0x6ee4('0x4d')]['rawAttributes']);_0x3f209c[_0x6ee4('0x51')]=_[_0x6ee4('0x50')](_0x3f3480[_0x6ee4('0x51')]);_0x3f209c[_0x6ee4('0x59')]=_[_0x6ee4('0x52')](_0x3f209c[_0x6ee4('0x46')],_0x3f209c[_0x6ee4('0x51')]);_0x3e6d47[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x3f209c[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x3f3480[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x3e6d47['attributes']=_0x3e6d47[_0x6ee4('0x53')][_0x6ee4('0x55')]?_0x3e6d47[_0x6ee4('0x53')]:_0x3f209c[_0x6ee4('0x46')];if(_0x3f3480[_0x6ee4('0x51')][_0x6ee4('0x5f')]){_0x3e6d47[_0x6ee4('0x60')]=[{'all':!![]}];}_0x3e6d47=_[_0x6ee4('0x5c')]({},_0x3e6d47,_0x3f3480[_0x6ee4('0x5e')]);return db['ChatWebsite'][_0x6ee4('0x65')](_0x3e6d47)[_0x6ee4('0x1c')](handleEntityNotFound(_0x2683f1,null))[_0x6ee4('0x1c')](respondWithResult(_0x2683f1,null))[_0x6ee4('0x27')](handleError(_0x2683f1,null));};exports[_0x6ee4('0x66')]=function(_0x569bab,_0x16d65c){if(!wildcardUtils['testWildcardValidity'](_0x569bab['body'][_0x6ee4('0x67')])){return handleError(_0x16d65c,null)(new APIBadRequestError('\x22'+_0x569bab[_0x6ee4('0x68')][_0x6ee4('0x67')]+_0x6ee4('0x69')));}return db[_0x6ee4('0x4d')][_0x6ee4('0x66')](_0x569bab['body'],{})[_0x6ee4('0x1c')](function(_0x16dae9){var _0x18fa52=_0x569bab[_0x6ee4('0x6a')][_0x6ee4('0x6b')]({'plain':!![]});if(!_0x18fa52)throw new Error(_0x6ee4('0x6c'));if(_0x18fa52['role']===_0x6ee4('0x6a')){var _0x34d4a7=_0x16dae9[_0x6ee4('0x6b')]({'plain':!![]});var _0x106156='ChatWebsites';return db[_0x6ee4('0x6d')][_0x6ee4('0x65')]({'where':{'name':_0x106156,'userProfileId':_0x18fa52[_0x6ee4('0x6e')]},'raw':!![]})[_0x6ee4('0x1c')](function(_0x3dcb65){if(_0x3dcb65&&_0x3dcb65['autoAssociation']===0x0){return db[_0x6ee4('0x34')][_0x6ee4('0x66')]({'name':_0x34d4a7[_0x6ee4('0x35')],'resourceId':_0x34d4a7['id'],'type':_0x3dcb65[_0x6ee4('0x35')],'sectionId':_0x3dcb65['id']},{})[_0x6ee4('0x1c')](function(){return _0x16dae9;});}else{return _0x16dae9;}})[_0x6ee4('0x27')](function(_0x49498f){logger[_0x6ee4('0x22')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x49498f);throw _0x49498f;});}return _0x16dae9;})[_0x6ee4('0x1c')](respondWithResult(_0x16d65c,0xc9))[_0x6ee4('0x27')](handleError(_0x16d65c,null));};exports[_0x6ee4('0x31')]=function(_0x372986,_0x5a70ba){if(!wildcardUtils['testWildcardValidity'](_0x372986['body'][_0x6ee4('0x67')])){return handleError(_0x5a70ba,null)(new APIBadRequestError('\x22'+_0x372986[_0x6ee4('0x68')]['address']+'\x22\x20is\x20not\x20a\x20valid\x20website\x20domain'));}if(_0x372986['body']['id']){delete _0x372986[_0x6ee4('0x68')]['id'];}return db[_0x6ee4('0x4d')]['find']({'where':{'id':_0x372986[_0x6ee4('0x64')]['id']},'include':[{'model':db['Pause'],'as':_0x6ee4('0x4b')}]})['then'](handleEntityNotFound(_0x5a70ba,null))['then'](saveUpdates(_0x372986[_0x6ee4('0x68')],null))['then'](respondWithResult(_0x5a70ba,null))['catch'](handleError(_0x5a70ba,null));};exports[_0x6ee4('0x32')]=function(_0x2d8684,_0x10cae9){return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x2d8684[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x10cae9,null))[_0x6ee4('0x1c')](removeEntity(_0x10cae9,null))[_0x6ee4('0x27')](handleError(_0x10cae9,null));};exports[_0x6ee4('0x6f')]=function(_0x102d59,_0x323292){return db[_0x6ee4('0x4d')][_0x6ee4('0x6f')]()[_0x6ee4('0x1c')](respondWithResult(_0x323292,null))[_0x6ee4('0x27')](handleError(_0x323292,null));};exports[_0x6ee4('0x70')]=function(_0x7a3961,_0x5d7b71){if(_0x7a3961[_0x6ee4('0x68')]['id']){delete _0x7a3961['body']['id'];}return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x7a3961['params']['id']}})['then'](handleEntityNotFound(_0x5d7b71,null))['then'](function(_0x723769){if(_0x723769){_0x7a3961['body'][_0x6ee4('0x71')]=_0x723769['id'];return db[_0x6ee4('0x72')][_0x6ee4('0x66')](_0x7a3961[_0x6ee4('0x68')]);}})['then'](respondWithResult(_0x5d7b71,null))[_0x6ee4('0x27')](handleError(_0x5d7b71,null));};exports['getDispositions']=function(_0x58ac9e,_0x5ab1e5){var _0x48ee5f={'raw':![],'where':{}};var _0x12c941={};var _0x257a2a={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x58ac9e[_0x6ee4('0x64')]['id']}})['then'](handleEntityNotFound(_0x5ab1e5,null))[_0x6ee4('0x1c')](function(_0x5c6143){if(_0x5c6143){_0x12c941[_0x6ee4('0x46')]=_[_0x6ee4('0x50')](db[_0x6ee4('0x72')][_0x6ee4('0x4e')]);_0x12c941[_0x6ee4('0x51')]=_[_0x6ee4('0x50')](_0x58ac9e[_0x6ee4('0x51')]);_0x12c941['filters']=_[_0x6ee4('0x52')](_0x12c941[_0x6ee4('0x46')],_0x12c941[_0x6ee4('0x51')]);_0x48ee5f[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x12c941[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x58ac9e['query'][_0x6ee4('0x54')]));_0x48ee5f[_0x6ee4('0x53')]=_0x48ee5f['attributes'][_0x6ee4('0x55')]?_0x48ee5f['attributes']:_0x12c941['model'];if(!_0x58ac9e['query'][_0x6ee4('0x73')]('nolimit')){_0x48ee5f[_0x6ee4('0x2c')]=qs[_0x6ee4('0x2c')](_0x58ac9e[_0x6ee4('0x51')][_0x6ee4('0x2c')]);_0x48ee5f['offset']=qs['offset'](_0x58ac9e['query'][_0x6ee4('0x2f')]);}_0x48ee5f[_0x6ee4('0x56')]=qs['sort'](_0x58ac9e[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x48ee5f[_0x6ee4('0x58')]=qs['filters'](_['pick'](_0x58ac9e[_0x6ee4('0x51')],_0x12c941[_0x6ee4('0x59')]));_0x48ee5f[_0x6ee4('0x58')][_0x6ee4('0x71')]=_0x5c6143['id'];if(_0x58ac9e[_0x6ee4('0x51')][_0x6ee4('0x5b')]){_0x48ee5f[_0x6ee4('0x58')]=_[_0x6ee4('0x5c')](_0x48ee5f[_0x6ee4('0x58')],{'$or':_['map'](_0x48ee5f[_0x6ee4('0x53')],function(_0x56ff80){var _0x332e43={};_0x332e43[_0x56ff80]={'$like':'%'+_0x58ac9e[_0x6ee4('0x51')]['filter']+'%'};return _0x332e43;})});}_0x48ee5f=_[_0x6ee4('0x5c')]({},_0x48ee5f,_0x58ac9e[_0x6ee4('0x5e')]);return db[_0x6ee4('0x72')][_0x6ee4('0x2e')]({'where':_0x48ee5f['where']})[_0x6ee4('0x1c')](function(_0xcb434d){_0x257a2a[_0x6ee4('0x2e')]=_0xcb434d;if(_0x58ac9e['query'][_0x6ee4('0x5f')]){_0x48ee5f[_0x6ee4('0x60')]=[{'all':!![]}];}return db[_0x6ee4('0x72')]['findAll'](_0x48ee5f);})[_0x6ee4('0x1c')](function(_0x1e9a22){_0x257a2a[_0x6ee4('0x62')]=_0x1e9a22;return _0x257a2a;});}})[_0x6ee4('0x1c')](respondWithFilteredResult(_0x5ab1e5,_0x48ee5f))[_0x6ee4('0x27')](handleError(_0x5ab1e5,null));};exports[_0x6ee4('0x74')]=function(_0x5c4995,_0x386a3e){return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x5c4995['params']['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x386a3e,null))[_0x6ee4('0x1c')](function(_0x277498){if(_0x277498){return _0x277498[_0x6ee4('0x74')](_0x5c4995['query'][_0x6ee4('0x75')]);}})[_0x6ee4('0x1c')](respondWithStatusCode(_0x386a3e,null))[_0x6ee4('0x27')](handleError(_0x386a3e,null));};exports['addAnswer']=function(_0x44d112,_0x846410){if(_0x44d112[_0x6ee4('0x68')]['id']){delete _0x44d112['body']['id'];}return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x44d112[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x846410,null))['then'](function(_0x4f3531){if(_0x4f3531){_0x44d112['body']['ChatWebsiteId']=_0x4f3531['id'];return db[_0x6ee4('0x76')][_0x6ee4('0x66')](_0x44d112[_0x6ee4('0x68')]);}})['then'](respondWithResult(_0x846410,null))[_0x6ee4('0x27')](handleError(_0x846410,null));};exports['getAnswers']=function(_0x3afdd7,_0x16c52a){var _0x472665={'raw':![],'where':{}};var _0x1435ba={};var _0x5daf9c={'count':0x0,'rows':[]};return db[_0x6ee4('0x4d')][_0x6ee4('0x77')]({'where':{'id':_0x3afdd7[_0x6ee4('0x64')]['id']}})['then'](handleEntityNotFound(_0x16c52a,null))[_0x6ee4('0x1c')](function(_0x2b15cb){if(_0x2b15cb){_0x1435ba[_0x6ee4('0x46')]=_['keys'](db[_0x6ee4('0x76')][_0x6ee4('0x4e')]);_0x1435ba[_0x6ee4('0x51')]=_['keys'](_0x3afdd7[_0x6ee4('0x51')]);_0x1435ba[_0x6ee4('0x59')]=_[_0x6ee4('0x52')](_0x1435ba['model'],_0x1435ba[_0x6ee4('0x51')]);_0x472665[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x1435ba[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x3afdd7[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x472665[_0x6ee4('0x53')]=_0x472665[_0x6ee4('0x53')][_0x6ee4('0x55')]?_0x472665[_0x6ee4('0x53')]:_0x1435ba[_0x6ee4('0x46')];if(!_0x3afdd7[_0x6ee4('0x51')]['hasOwnProperty'](_0x6ee4('0x78'))){_0x472665['limit']=qs[_0x6ee4('0x2c')](_0x3afdd7['query'][_0x6ee4('0x2c')]);_0x472665['offset']=qs['offset'](_0x3afdd7[_0x6ee4('0x51')]['offset']);}_0x472665['order']=qs['sort'](_0x3afdd7[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x472665[_0x6ee4('0x58')]=qs[_0x6ee4('0x59')](_[_0x6ee4('0x5a')](_0x3afdd7[_0x6ee4('0x51')],_0x1435ba[_0x6ee4('0x59')]));_0x472665[_0x6ee4('0x58')]['ChatWebsiteId']=_0x2b15cb['id'];if(_0x3afdd7[_0x6ee4('0x51')]['filter']){_0x472665[_0x6ee4('0x58')]=_[_0x6ee4('0x5c')](_0x472665[_0x6ee4('0x58')],{'$or':_['map'](_0x472665[_0x6ee4('0x53')],function(_0xf66acb){var _0x5218fc={};_0x5218fc[_0xf66acb]={'$like':'%'+_0x3afdd7[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x5218fc;})});}_0x472665=_[_0x6ee4('0x5c')]({},_0x472665,_0x3afdd7[_0x6ee4('0x5e')]);return db[_0x6ee4('0x76')]['count']({'where':_0x472665[_0x6ee4('0x58')]})[_0x6ee4('0x1c')](function(_0x263fa3){_0x5daf9c[_0x6ee4('0x2e')]=_0x263fa3;if(_0x3afdd7[_0x6ee4('0x51')][_0x6ee4('0x5f')]){_0x472665[_0x6ee4('0x60')]=[{'all':!![]}];}return db[_0x6ee4('0x76')][_0x6ee4('0x61')](_0x472665);})[_0x6ee4('0x1c')](function(_0x32b797){_0x5daf9c['rows']=_0x32b797;return _0x5daf9c;});}})['then'](respondWithFilteredResult(_0x16c52a,_0x472665))[_0x6ee4('0x27')](handleError(_0x16c52a,null));};exports[_0x6ee4('0x79')]=function(_0xe4fc98,_0x4328ef){return db['ChatWebsite'][_0x6ee4('0x65')]({'where':{'id':_0xe4fc98[_0x6ee4('0x64')]['id']}})['then'](handleEntityNotFound(_0x4328ef,null))['then'](function(_0x34b30b){if(_0x34b30b){return _0x34b30b[_0x6ee4('0x79')](_0xe4fc98[_0x6ee4('0x51')]['ids']);}})[_0x6ee4('0x1c')](respondWithStatusCode(_0x4328ef,null))[_0x6ee4('0x27')](handleError(_0x4328ef,null));};exports[_0x6ee4('0x7a')]=function(_0x4c284e,_0x427c09){_0x4c284e[_0x6ee4('0x68')][_0x6ee4('0x7b')]=_0x4c284e['file'][_0x6ee4('0x7c')];return db['ChatWebsite'][_0x6ee4('0x65')]({'where':{'id':_0x4c284e[_0x6ee4('0x64')]['id']}})['then'](handleEntityNotFound(_0x427c09,null))[_0x6ee4('0x1c')](saveUpdates(_0x4c284e[_0x6ee4('0x68')],null))[_0x6ee4('0x1c')](respondWithResult(_0x427c09,null))[_0x6ee4('0x27')](handleError(_0x427c09,null));};exports[_0x6ee4('0x7d')]=function(_0x33b36b,_0x3e71d4){_0x33b36b[_0x6ee4('0x68')]['agentAvatar']=_0x33b36b[_0x6ee4('0x7e')]['filename'];return db[_0x6ee4('0x4d')]['find']({'where':{'id':_0x33b36b[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x3e71d4,null))[_0x6ee4('0x1c')](saveUpdates(_0x33b36b[_0x6ee4('0x68')],null))[_0x6ee4('0x1c')](respondWithResult(_0x3e71d4,null))[_0x6ee4('0x27')](handleError(_0x3e71d4,null));};exports[_0x6ee4('0x7f')]=function(_0x1f8542,_0x5401bd){_0x1f8542[_0x6ee4('0x68')]['customerAvatar']=_0x1f8542[_0x6ee4('0x7e')]['filename'];return db[_0x6ee4('0x4d')]['find']({'where':{'id':_0x1f8542['params']['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x5401bd,null))[_0x6ee4('0x1c')](saveUpdates(_0x1f8542[_0x6ee4('0x68')],null))['then'](respondWithResult(_0x5401bd,null))['catch'](handleError(_0x5401bd,null));};exports['addSystemAvatar']=function(_0x44f74b,_0x2d2d47){_0x44f74b[_0x6ee4('0x68')][_0x6ee4('0x80')]=_0x44f74b[_0x6ee4('0x7e')][_0x6ee4('0x7c')];return db[_0x6ee4('0x4d')]['find']({'where':{'id':_0x44f74b[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x2d2d47,null))[_0x6ee4('0x1c')](saveUpdates(_0x44f74b[_0x6ee4('0x68')],null))['then'](respondWithResult(_0x2d2d47,null))['catch'](handleError(_0x2d2d47,null));};exports[_0x6ee4('0x81')]=function(_0x2c366f,_0x52509d){var _0x2b57da=path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],'server/files/images/logos/default_logo.svg');var _0x2b54b8={'where':{'id':_0x2c366f[_0x6ee4('0x64')]['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x48ac0b=![];return require(_0x6ee4('0x84'))['getLicense']()[_0x6ee4('0x1c')](function(_0x47725e){if(_0x47725e){_0x48ac0b=_0x47725e[_0x6ee4('0x85')];}})[_0x6ee4('0x1c')](function(){return db[_0x6ee4('0x4d')][_0x6ee4('0x65')](_0x2b54b8);})['then'](handleEntityNotFound(_0x52509d,null))[_0x6ee4('0x1c')](function(_0x2e0cda){if(_0x2e0cda){if(!_[_0x6ee4('0x86')](_0x2e0cda[_0x6ee4('0x7b')])){if(fs['existsSync'](path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],_0x6ee4('0x87'),_0x2e0cda[_0x6ee4('0x7b')]))&&_0x48ac0b){_0x2b57da=path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],_0x6ee4('0x87'),_0x2e0cda['sitepic']);}}return _0x52509d[_0x6ee4('0x88')](_0x2b57da);}})[_0x6ee4('0x27')](handleError(_0x52509d,null));};exports['getAvatar']=function(_0x4390c7,_0x37c866){var _0x434dab=path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],_0x6ee4('0x89'));var _0x341b73={'where':{'id':_0x4390c7[_0x6ee4('0x64')]['id']},'attributes':['id',_0x6ee4('0x8a')],'raw':!![]};return db[_0x6ee4('0x4d')]['find'](_0x341b73)[_0x6ee4('0x1c')](handleEntityNotFound(_0x37c866,null))['then'](function(_0x5a5852){if(_0x5a5852){if(!_[_0x6ee4('0x86')](_0x5a5852[_0x6ee4('0x8a')])){if(fs[_0x6ee4('0x8b')](path[_0x6ee4('0x82')](config['root'],'server/files/images/avatars/',_0x5a5852[_0x6ee4('0x8a')]))){_0x434dab=path['join'](config[_0x6ee4('0x83')],_0x6ee4('0x8c'),_0x5a5852[_0x6ee4('0x8a')]);}}return _0x37c866[_0x6ee4('0x88')](_0x434dab);}})[_0x6ee4('0x27')](handleError(_0x37c866,null));};exports[_0x6ee4('0x8d')]=function(_0x3a02fa,_0x47c5ec){var _0x42f9f1=path['join'](config[_0x6ee4('0x83')],_0x6ee4('0x8e'));var _0x1bbd7c={'where':{'id':_0x3a02fa[_0x6ee4('0x64')]['id']},'attributes':['id',_0x6ee4('0x8f'),_0x6ee4('0x90')],'raw':!![]};return db[_0x6ee4('0x4d')][_0x6ee4('0x65')](_0x1bbd7c)[_0x6ee4('0x1c')](handleEntityNotFound(_0x47c5ec,null))[_0x6ee4('0x1c')](function(_0xee57a5){if(_0xee57a5){if(!_[_0x6ee4('0x86')](_0xee57a5['customerAvatar'])){if(fs[_0x6ee4('0x8b')](path[_0x6ee4('0x82')](config['root'],'server/files/images/avatars/',_0xee57a5['customerAvatar']))&&_0xee57a5[_0x6ee4('0x90')]){_0x42f9f1=path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],_0x6ee4('0x8c'),_0xee57a5[_0x6ee4('0x8f')]);}}return _0x47c5ec[_0x6ee4('0x88')](_0x42f9f1);}})[_0x6ee4('0x27')](handleError(_0x47c5ec,null));};exports[_0x6ee4('0x91')]=function(_0x111c35,_0x5eaa62){var _0x4135d9=path[_0x6ee4('0x82')](config['root'],_0x6ee4('0x92'));var _0x1e4fbf={'where':{'id':_0x111c35[_0x6ee4('0x64')]['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db['ChatWebsite'][_0x6ee4('0x65')](_0x1e4fbf)[_0x6ee4('0x1c')](handleEntityNotFound(_0x5eaa62,null))[_0x6ee4('0x1c')](function(_0x400c11){if(_0x400c11){if(!_['isNil'](_0x400c11[_0x6ee4('0x80')])){if(fs[_0x6ee4('0x8b')](path['join'](config[_0x6ee4('0x83')],'server/files/images/avatars/',_0x400c11[_0x6ee4('0x80')]))){_0x4135d9=path['join'](config[_0x6ee4('0x83')],'server/files/images/avatars/',_0x400c11[_0x6ee4('0x80')]);}}return _0x5eaa62[_0x6ee4('0x88')](_0x4135d9);}})['catch'](handleError(_0x5eaa62,null));};function checkWebsiteInterval(_0x3acc94){var _0x87f63b=_0x3acc94[_0x6ee4('0x93')];if(!_0x87f63b){return Promise['resolve'](_0x3acc94);}var _0x4c3d02=_0x3acc94[_0x6ee4('0x94')]||undefined;return _0x87f63b[_0x6ee4('0x95')](_0x4c3d02)[_0x6ee4('0x1c')](function(_0x1b65f8){if(!_0x1b65f8){throw new APIOutOfIntervalError();}return _0x3acc94;});}exports[_0x6ee4('0x96')]=function(_0x4e858a,_0x451975){var _0x1dbf0e={'body':_0x4e858a[_0x6ee4('0x68')],'channel':_0x6ee4('0x97')};var _0x2e377c=[];var _0x57a6c4=[];var _0x48df37={};var _0x433eed=![];if(_0x4e858a[_0x6ee4('0x68')]['id']){delete _0x4e858a[_0x6ee4('0x68')]['id'];}if(_[_0x6ee4('0x86')](_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x98')])){throw new APIBadRequestError(_0x6ee4('0x99'));}if(_[_0x6ee4('0x86')](_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x9a')])){throw new APIBadRequestError(_0x6ee4('0x9b'));}if(_[_0x6ee4('0x9c')](_0x4e858a['body']['body'])){throw new APIBadRequestError(_0x6ee4('0x9d'));}var _0x102a15=_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x39')]&&_0x4e858a['body'][_0x6ee4('0x9e')];return db[_0x6ee4('0x9f')]['describe']()['then'](function(_0x5abd81){if(!_0x5abd81){throw new Error(_0x6ee4('0xa0'));}_0x2e377c=Object['keys'](_0x5abd81)[_0x6ee4('0x5b')](function(_0x4d4b90){return!['createdAt','updatedAt'][_0x6ee4('0xa1')](_0x4d4b90);});_0x57a6c4=Object[_0x6ee4('0x50')](_0x5abd81)['filter'](function(_0x587b72){return![_0x6ee4('0xa2'),'updatedAt','CompanyId',_0x6ee4('0xa3')][_0x6ee4('0xa1')](_0x587b72);});if(!_[_0x6ee4('0xa1')](_0x57a6c4,_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x9a')])){throw new APIBadRequestError(_0x6ee4('0xa4')+_0x57a6c4[_0x6ee4('0x82')](',\x20'));}_0x48df37[_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x9a')]]=_0x4e858a[_0x6ee4('0x68')]['from'];})['then'](function(){return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x4e858a[_0x6ee4('0x64')]['id']},'include':[{'model':db[_0x6ee4('0xa5')],'as':_0x6ee4('0xa6'),'include':[{'model':db['CmContact'],'as':_0x6ee4('0xa7'),'where':_0x48df37,'limit':0x1,'order':[[_0x6ee4('0xa8'),_0x6ee4('0xa9')]]}]},{'model':db[_0x6ee4('0xaa')],'as':_0x6ee4('0xab')},{'model':db[_0x6ee4('0x93')],'as':'Interval','include':[{'model':db['Interval'],'as':'Intervals','attributes':['id',_0x6ee4('0xac')],'raw':!![]}]}]});})[_0x6ee4('0x1c')](function(_0x197ba5){if(!_0x197ba5){throw new APINotFoundError(util[_0x6ee4('0x41')](_0x6ee4('0xad'),_0x4e858a['params']['id']));}if(_0x102a15){return checkWebsiteInterval(_0x197ba5);}return _0x197ba5;})[_0x6ee4('0x1c')](function(_0xe860e6){_0x1dbf0e['account']=_0xe860e6;_0x1dbf0e[_0x6ee4('0xae')]=_['orderBy'](_0xe860e6[_0x6ee4('0xab')],[_0x6ee4('0xaf')],['asc']);if(_0x1dbf0e['account'][_0x6ee4('0xab')]){delete _0x1dbf0e['account'][_0x6ee4('0xab')];}_0x1dbf0e['list']=_0xe860e6['List']||{'id':_0xe860e6[_0x6ee4('0xa3')]};if(_0x1dbf0e[_0x6ee4('0xb0')]&&_0x1dbf0e[_0x6ee4('0xb0')][_0x6ee4('0xa7')][_0x6ee4('0x55')]){return _0x1dbf0e['list'][_0x6ee4('0xa7')][0x0];}var _0x230535=_[_0x6ee4('0x15')](_0x4e858a[_0x6ee4('0x68')],{'firstName':_0x4e858a['body'][_0x6ee4('0x98')],'ListId':_0xe860e6[_0x6ee4('0xa3')]});_0x230535[_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x9a')]]=_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x98')];return db[_0x6ee4('0x9f')]['create'](_0x230535,{'fields':_0x2e377c,'raw':!![]});})['then'](function(_0x110c18){_0x1dbf0e[_0x6ee4('0xb1')]=_0x110c18;var _0x40e45f=createInteractionObject(_0x4e858a[_0x6ee4('0x64')]['id'],_0x4e858a['body'],_0x4e858a[_0x6ee4('0xb2')],_0x110c18);var _0x698ed8={'ChatWebsiteId':_0x4e858a[_0x6ee4('0x64')]['id']};if(_0x4e858a['body'][_0x6ee4('0xb3')]){_0x698ed8['threadId']=_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb3')];_0x698ed8[_0x6ee4('0xb4')]=![];return db['ChatInteraction'][_0x6ee4('0x65')]({'where':_0x698ed8})['then'](function(_0x19d48e){var _0x38d053=_0x4e858a[_0x6ee4('0x68')]['customerIp']&&_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x9e')];if(_0x19d48e){_0x433eed=!![];return _0x19d48e;}else if(!_0x38d053&&_0x19d48e&&_0x19d48e[_0x6ee4('0xb4')]){throw new APIConflictError('Writing\x20on\x20closed\x20interaction');}_0x40e45f[_0x6ee4('0xb3')]=_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb3')];_0x40e45f['externalUrl']=_0x4e858a['body'][_0x6ee4('0xb5')];return db[_0x6ee4('0xb6')]['create'](_0x40e45f);});}_0x698ed8[_0x6ee4('0xb7')]=_0x110c18['id'];if(_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb8')]&&_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb8')]['id']){_0x698ed8['id']=_0x4e858a[_0x6ee4('0x68')]['interaction']['id'];return db[_0x6ee4('0xb6')][_0x6ee4('0x65')]({'where':_0x698ed8})[_0x6ee4('0x1c')](function(_0x545ea5){var _0x3bd78c=_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x39')]&&_0x4e858a['body'][_0x6ee4('0x9e')];if(!_0x3bd78c&&_0x545ea5&&_0x545ea5[_0x6ee4('0xb4')]){throw new APIConflictError('Writing\x20on\x20closed\x20interaction');}else if(_0x545ea5){_0x433eed=!![];return _0x545ea5;}else{return db[_0x6ee4('0xb6')][_0x6ee4('0x66')](_0x40e45f);}});}return db['ChatInteraction'][_0x6ee4('0x66')](_0x40e45f);})[_0x6ee4('0x1c')](function(_0x5844cd){if(!_0x433eed){return _0x5844cd;}var _0x13a5d9={'from':(_0x1dbf0e['contact'][_0x6ee4('0x3d')]||'')+'\x20'+(_0x1dbf0e[_0x6ee4('0xb1')]['lastName']||'')};if(_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb3')]&&_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb9')]&&_0x4e858a['body']['threadId']!=_0x4e858a['body'][_0x6ee4('0xb9')]){_0x13a5d9[_0x6ee4('0xb3')]=_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb9')];}return _0x5844cd[_0x6ee4('0x31')](_0x13a5d9);})[_0x6ee4('0x1c')](function(_0x30d491){_0x1dbf0e['interaction']=_0x30d491[_0x6ee4('0x6b')]({'plain':!![]});_0x1dbf0e[_0x6ee4('0xb8')][_0x6ee4('0xba')]=!_0x433eed;if(_0x1dbf0e['interaction'][_0x6ee4('0xba')]){if(_0x1dbf0e[_0x6ee4('0xbb')][_0x6ee4('0xbc')]){_0x1dbf0e[_0x6ee4('0xae')][_0x6ee4('0xbd')]({'id':0x0,'priority':_0x1dbf0e[_0x6ee4('0xae')][_0x6ee4('0x55')]+0x1,'app':_0x6ee4('0xbe'),'appdata':_0x6ee4('0xbf'),'interval':_0x6ee4('0xc0')});}}return db[_0x6ee4('0xc1')][_0x6ee4('0x66')]({'body':_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x68')],'ChatWebsiteId':_0x4e858a[_0x6ee4('0x64')]['id'],'ChatInteractionId':_0x30d491['id'],'direction':'in','ContactId':_0x1dbf0e[_0x6ee4('0xb1')]['id'],'AttachmentId':_0x4e858a[_0x6ee4('0x68')]['AttachmentId']});})[_0x6ee4('0x1c')](function(_0x1afa76){_0x1dbf0e['message']=_0x1afa76;if(!_0x1dbf0e[_0x6ee4('0xb8')][_0x6ee4('0xc2')]){return;}return db[_0x6ee4('0xc3')][_0x6ee4('0x65')]({'attributes':['id',_0x6ee4('0x35')],'where':{'id':_0x1dbf0e[_0x6ee4('0xb8')][_0x6ee4('0xc2')]}});})[_0x6ee4('0x1c')](function(_0x1bfe88){if(_0x1bfe88){_0x1dbf0e[_0x6ee4('0xae')][_0x6ee4('0xc4')]({'id':0x0,'priority':0x0,'app':_0x6ee4('0xc5'),'appdata':_0x1bfe88[_0x6ee4('0x35')]+','+(_0x1dbf0e[_0x6ee4('0xbb')][_0x6ee4('0xc6')]||0xa),'interval':'*,*,*,*'});_0x1dbf0e[_0x6ee4('0xc7')]=!![];}if(!_0x1dbf0e[_0x6ee4('0xb8')][_0x6ee4('0xc8')]){return;}return db['ChatQueue'][_0x6ee4('0x65')]({'attributes':['id',_0x6ee4('0x35')],'where':{'id':_0x1dbf0e[_0x6ee4('0xb8')][_0x6ee4('0xc8')]}});})[_0x6ee4('0x1c')](function(_0x5da74e){if(_0x5da74e){_0x1dbf0e[_0x6ee4('0xae')]['unshift']({'id':0x0,'priority':0x1,'app':'queue','appdata':_0x5da74e[_0x6ee4('0x35')]+','+(_0x1dbf0e['account'][_0x6ee4('0xc9')]||0x12c),'interval':_0x6ee4('0xc0')});}return respondWithRpcPromise(_0x6ee4('0xca'),_0x6ee4('0xcb'),_0x1dbf0e);})[_0x6ee4('0x1c')](function(_0x5c40e1){respondWithRpcPromise(_0x6ee4('0xcc'),_0x6ee4('0xcc'),{'event':_0x6ee4('0x96'),'message':_0x5c40e1},client9002);return _0x5c40e1;})['then'](respondWithResult(_0x451975,null))[_0x6ee4('0x27')](APIHandleError(_0x451975));};exports['offline']=function(_0x1b1097,_0x49c69e){var _0x5b7182,_0x545a2c,_0x51e539;var _0x18a528=[];var _0xe34109={};var _0x588f32=_0x1b1097[_0x6ee4('0xcd')]||[];var _0x55d681=[];var _0x15d330;return db[_0x6ee4('0x9f')][_0x6ee4('0x6f')]()[_0x6ee4('0x1c')](function(_0x151773){if(!_0x151773){throw new db[(_0x6ee4('0xce'))][(_0x6ee4('0xcf'))](_0x6ee4('0xd0'));}_0x18a528=_['difference'](_[_0x6ee4('0x50')](_0x151773),[_0x6ee4('0xa2'),_0x6ee4('0xa8'),_0x6ee4('0xd1'),_0x6ee4('0xa3')]);if(_0x1b1097['body']['id']){delete _0x1b1097[_0x6ee4('0x68')]['id'];}if(_[_0x6ee4('0x86')](_0x1b1097['body'][_0x6ee4('0x98')])){throw _0x49c69e['status'](0x1f4)[_0x6ee4('0xd2')](new db[(_0x6ee4('0xce'))][(_0x6ee4('0xcf'))](_0x6ee4('0xd3')));}if(_[_0x6ee4('0x86')](_0x1b1097[_0x6ee4('0x68')]['body'])||_0x1b1097[_0x6ee4('0x68')][_0x6ee4('0x68')]===''){throw _0x49c69e['status'](0x1f4)['send'](new db[(_0x6ee4('0xce'))][(_0x6ee4('0xcf'))](_0x6ee4('0xd4')));}if(_[_0x6ee4('0x86')](_0x1b1097['body'][_0x6ee4('0xd5')])){throw _0x49c69e[_0x6ee4('0x29')](0x1f4)[_0x6ee4('0xd2')](new db[(_0x6ee4('0xce'))][(_0x6ee4('0xcf'))](_0x6ee4('0xd6')+_0x18a528));}if(!_['includes'](_0x18a528,_0x1b1097[_0x6ee4('0x68')][_0x6ee4('0xd5')])){throw _0x49c69e[_0x6ee4('0x29')](0x1f4)[_0x6ee4('0xd2')](new db[(_0x6ee4('0xce'))][(_0x6ee4('0xcf'))]('mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x18a528));}_0xe34109[_0x1b1097['body'][_0x6ee4('0xd5')]]=_0x1b1097[_0x6ee4('0x68')]['from'];})[_0x6ee4('0x1c')](function(){return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x1b1097[_0x6ee4('0x64')]['id']},'include':[{'model':db[_0x6ee4('0xa5')],'as':_0x6ee4('0xa6')},{'model':db[_0x6ee4('0xd7')],'as':_0x6ee4('0xd7')}]});})[_0x6ee4('0x1c')](handleEntityNotFound(_0x49c69e,null))['then'](function(_0x1d06e3){if(_0x1d06e3&&_0x1d06e3['List']){_0x545a2c=_0x1d06e3;var _0x265a0c=_[_0x6ee4('0x15')](_0x1b1097[_0x6ee4('0x68')],{'firstName':_0x1b1097[_0x6ee4('0x68')][_0x6ee4('0x98')],'phone':_0x1b1097['body']['from'],'ListId':_0x1d06e3[_0x6ee4('0xa3')]});_0x265a0c[_0x1b1097['body'][_0x6ee4('0xd5')]]=_0x1b1097[_0x6ee4('0x68')][_0x6ee4('0x98')];return db[_0x6ee4('0x9f')]['findOrCreate']({'where':_0xe34109,'defaults':_0x265a0c});}})[_0x6ee4('0xd8')](function(_0x521c4b){if(_0x521c4b){_0x51e539=_0x521c4b;var _0x3eef07=fs[_0x6ee4('0xd9')](path['join'](config[_0x6ee4('0x83')],_0x6ee4('0xda')),'utf8');var _0x5d3c6d=ejs[_0x6ee4('0xdb')](_0x3eef07,{'body':_[_0x6ee4('0xdc')](_0x1b1097[_0x6ee4('0x68')][_0x6ee4('0x68')]),'bodyTitle':_0x545a2c[_0x6ee4('0xdd')]});return db['ChatOfflineMessage'][_0x6ee4('0x66')]({'body':_0x5d3c6d,'plainBody':htmlToText[_0x6ee4('0xde')](_0x5d3c6d),'ContactId':_0x521c4b['id'],'ChatWebsiteId':_0x545a2c['id']});}})[_0x6ee4('0x1c')](function(_0x1ac102){_0x15d330=_0x1ac102;if(_0x588f32['length']){var _0x4bafe4=_0x588f32[_0x6ee4('0x4c')](function(_0x517722){return{'name':_0x517722[_0x6ee4('0xdf')],'basename':_0x517722[_0x6ee4('0x7c')],'type':_0x517722[_0x6ee4('0xe0')],'ChatOfflineMessageId':_0x1ac102['id']};});_0x55d681=_0x4bafe4[_0x6ee4('0x4c')](_0x133982=>{var _0xcbcaa7={'filename':_0x133982[_0x6ee4('0x35')],'path':path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],'server',_0x6ee4('0xcd'),_0x6ee4('0xe1'),_0x6ee4('0xe2'),_0x133982[_0x6ee4('0xe3')])};return _0xcbcaa7;});if(!_0x545a2c[_0x6ee4('0xe4')]){return db['sequelize'][_0x6ee4('0xe5')](function(_0x31b6c6){return db[_0x6ee4('0xe6')][_0x6ee4('0xe7')](_0x4bafe4,{'transaction':_0x31b6c6});});}}})[_0x6ee4('0x1c')](function(){if(_0x15d330){_0x5b7182=_0x15d330;return db[_0x6ee4('0xd7')][_0x6ee4('0x77')]({'where':{'service':!![]},'include':[{'model':db[_0x6ee4('0xe8')],'as':_0x6ee4('0xe9'),'raw':!![],'include':[{'model':db[_0x6ee4('0xea')],'as':'CloudProvider','raw':!![]}]}]});}})['then'](function(_0x566f57){if(_0x566f57&&_0x566f57['Smtp']&&_0x545a2c[_0x6ee4('0xeb')]&&_0x545a2c[_0x6ee4('0xec')]){var _0x59f2cd=_0x566f57[_0x6ee4('0xed')]();return respondWithRpcPromise(_0x6ee4('0xee'),_0x6ee4('0xef'),{'account':_0x59f2cd,'message':{'from':util['format'](_0x6ee4('0xf0'),_0x566f57[_0x6ee4('0x35')],_0x566f57[_0x6ee4('0xf1')]||_0x566f57[_0x6ee4('0xe9')]['user']),'to':_0x545a2c[_0x6ee4('0xec')],'subject':_0x545a2c[_0x6ee4('0xf2')],'html':_0x5b7182[_0x6ee4('0x68')],'attachments':_0x55d681}},client9003)[_0x6ee4('0x1c')](function(){return _0x5b7182;})['catch'](function(_0x100a5b){logger[_0x6ee4('0x22')](_0x100a5b);});}})[_0x6ee4('0x1c')](function(){if(_0x545a2c&&_0x545a2c[_0x6ee4('0xe4')]&&_0x545a2c['MailAccountId']){var _0x4f5c9e=[];if(_0x588f32['length']){_0x4f5c9e=_0x588f32[_0x6ee4('0x4c')](function(_0x43b99f){return{'name':_0x43b99f[_0x6ee4('0xdf')],'basename':_0x43b99f[_0x6ee4('0x7c')],'type':_0x43b99f[_0x6ee4('0xe0')],'ChatOfflineMessageId':_0x15d330['id']};});}var _0x37137e;if(!_[_0x6ee4('0x86')](_0x545a2c[_0x6ee4('0xf3')])){var _0x18cc73=_[_0x6ee4('0x4c')](_0x1b1097[_0x6ee4('0x68')],function(_0x54aec7){return _0x54aec7;});var _0x4580cd=_[_0x6ee4('0xf4')](_0x18cc73)[0x0];var _0x2c5aba=_[_0x6ee4('0xf5')](_0x4580cd,function(_0xbcc979){return _0xbcc979;});_0x37137e=_0x2c5aba[0x1][_0x545a2c[_0x6ee4('0xf3')]];}var _0x19ef93={'from':_0x51e539[_0x6ee4('0xf1')],'firstName':_0x51e539[_0x6ee4('0x3d')],'lastName':_0x51e539['lastName'],'mapKey':_0x6ee4('0xf1'),'message':{'from':_0x51e539['email'],'to':_0x545a2c[_0x6ee4('0xd7')][_0x6ee4('0xf1')],'cc':'','subject':_[_0x6ee4('0x86')](_0x37137e)?_0x545a2c[_0x6ee4('0xf2')]:_0x37137e,'messageId':'','sentAt':new Date(),'attach':_0x4f5c9e[_0x6ee4('0x55')],'attachments':_0x4f5c9e,'originChannel':_0x6ee4('0xf6'),'ChatWebsiteId':_0x545a2c['id'],'ChatOfflineMessageId':_0x5b7182['id'],'originTo':_0x545a2c[_0x6ee4('0xd7')]['email']},'body':_0x5b7182[_0x6ee4('0x68')]};var _0xc8a872={'account':{'id':_0x545a2c[_0x6ee4('0xf7')]},'body':_0x19ef93,'log':'NotifyMailAccount'};return respondWithRpcPromise(_0x6ee4('0xf8'),_0x6ee4('0xf9'),_0xc8a872,client9001)[_0x6ee4('0x1c')](function(){return _0x5b7182;})[_0x6ee4('0x27')](function(_0x321d72){logger[_0x6ee4('0x22')](_0x321d72);});}return;})[_0x6ee4('0x1c')](function(){if(_0x5b7182){return _0x5b7182;}})[_0x6ee4('0x1c')](respondWithResult(_0x49c69e,null))[_0x6ee4('0x27')](function(){for(var _0x4d1406 of _0x588f32){var _0x3cdc9e=path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],'server','files',_0x6ee4('0xe1'),_0x6ee4('0xe2'),_0x4d1406['filename']);fs_extra['remove'](_0x3cdc9e)['catch'](function(_0x4af932){logger[_0x6ee4('0x22')]('Could\x20not\x20remove\x20attachment\x20file',_0x3cdc9e,_0x4af932);});}});};exports[_0x6ee4('0xfa')]=function(_0x1561e8,_0x1200f8){return db[_0x6ee4('0xb6')][_0x6ee4('0x65')]({'where':{'id':_0x1561e8['params']['id']}})['then'](handleEntityNotFound(_0x1200f8,null))[_0x6ee4('0x1c')](function(_0x3d7a6a){if(_0x3d7a6a){return _0x3d7a6a[_0x6ee4('0xfa')](_0x1561e8[_0x6ee4('0x68')][_0x6ee4('0x75')],_['omit'](_0x1561e8[_0x6ee4('0x68')],[_0x6ee4('0x75'),'id'])||{});}})[_0x6ee4('0x1c')](respondWithResult(_0x1200f8,null))[_0x6ee4('0x27')](handleError(_0x1200f8,null));};exports['getInteractions']=function(_0x1ad77b,_0x17f2df){var _0x432ec7={'raw':![],'where':{}};var _0x547298={};var _0x21e7be={'count':0x0,'rows':[]};return db[_0x6ee4('0x4d')]['findOne']({'where':{'id':_0x1ad77b[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x17f2df,null))[_0x6ee4('0x1c')](function(_0x141220){if(_0x141220){_0x547298['model']=_[_0x6ee4('0x50')](db[_0x6ee4('0xb6')][_0x6ee4('0x4e')]);_0x547298[_0x6ee4('0x51')]=_[_0x6ee4('0x50')](_0x1ad77b[_0x6ee4('0x51')]);_0x547298['filters']=_[_0x6ee4('0x52')](_0x547298[_0x6ee4('0x46')],_0x547298[_0x6ee4('0x51')]);_0x432ec7[_0x6ee4('0x53')]=_['intersection'](_0x547298[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x432ec7[_0x6ee4('0x53')]=_0x432ec7[_0x6ee4('0x53')]['length']?_0x432ec7[_0x6ee4('0x53')]:_0x547298[_0x6ee4('0x46')];if(!_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x73')](_0x6ee4('0x78'))){_0x432ec7[_0x6ee4('0x2c')]=qs[_0x6ee4('0x2c')](_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x2c')]);_0x432ec7[_0x6ee4('0x2f')]=qs['offset'](_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x2f')]);}_0x432ec7['order']=qs[_0x6ee4('0x57')](_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x432ec7[_0x6ee4('0x58')]=qs[_0x6ee4('0x59')](_['pick'](_0x1ad77b[_0x6ee4('0x51')],_0x547298[_0x6ee4('0x59')]));_0x432ec7[_0x6ee4('0x58')][_0x6ee4('0x71')]=_0x141220['id'];if(_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x5b')]){_0x432ec7[_0x6ee4('0x58')]=_['merge'](_0x432ec7[_0x6ee4('0x58')],{'$or':_[_0x6ee4('0x4c')](_0x432ec7[_0x6ee4('0x53')],function(_0x142d8f){var _0x39ddb6={};_0x39ddb6[_0x142d8f]={'$like':'%'+_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x39ddb6;})});}_0x432ec7=_[_0x6ee4('0x5c')]({},_0x432ec7,_0x1ad77b[_0x6ee4('0x5e')]);return db[_0x6ee4('0xb6')]['count']({'where':_0x432ec7['where']})[_0x6ee4('0x1c')](function(_0x3fc60e){_0x21e7be[_0x6ee4('0x2e')]=_0x3fc60e;if(_0x1ad77b[_0x6ee4('0x51')]['includeAll']){_0x432ec7[_0x6ee4('0x60')]=[{'model':db[_0x6ee4('0x9f')],'as':'Contact','required':![]},{'model':db[_0x6ee4('0xc3')],'as':'Owner','attributes':[_0x6ee4('0x35'),_0x6ee4('0xfb'),_0x6ee4('0xfc')],'required':![]},{'model':db['Tag'],'as':_0x6ee4('0xfd'),'attributes':['id',_0x6ee4('0x35'),'color'],'where':_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0xfe')]?{'id':_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0xfe')]}:undefined,'required':_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0xfe')]?!![]:![]}];}return db[_0x6ee4('0xb6')][_0x6ee4('0x61')](_0x432ec7);})[_0x6ee4('0x1c')](function(_0x17d405){_0x21e7be[_0x6ee4('0x62')]=_0x17d405;return _0x21e7be;});}})[_0x6ee4('0x1c')](respondWithFilteredResult(_0x17f2df,_0x432ec7))['catch'](handleError(_0x17f2df,null));};exports[_0x6ee4('0xff')]=function(_0x588fb3,_0x45d4f0){var _0x415189=0x0;var _0xfce68e=0x0;var _0x4f6186=![];var _0xd20adc;var _0x1b6033;return db['ChatWebsite'][_0x6ee4('0x65')]({'where':{'id':_0x588fb3['params']['id']},'include':[{'model':db['Interval'],'as':'Interval','include':[{'model':db[_0x6ee4('0x93')],'as':'Intervals','attributes':['id',_0x6ee4('0xac')]}]}]})[_0x6ee4('0x1c')](handleEntityNotFound(_0x45d4f0,null))['then'](function(_0x58a21b){if(_0x58a21b){_0xd20adc=_0x58a21b;return _0x58a21b[_0x6ee4('0x100')]({'raw':!![]});}})['then'](function(_0x453fdb){if(_0xd20adc){if(_0x453fdb){_0x1b6033=_0x453fdb;}}return require(_0x6ee4('0x84'))[_0x6ee4('0x101')]();})[_0x6ee4('0x1c')](function(_0x55d59a){if(_0x55d59a){_0xfce68e=_0x55d59a[_0x6ee4('0x102')];_0x4f6186=_0x55d59a['custom'];}})[_0x6ee4('0x1c')](function(){return db[_0x6ee4('0xb6')]['count']({'where':{'closed':![]}});})['then'](function(_0x23a8ab){_0x415189=_0x23a8ab;if(_0xfce68e&&_0x23a8ab>_0xfce68e){return db[_0x6ee4('0x103')]['findOne']({'where':{'id':0x1}})['then'](function(_0x4267c4){if(_0x4267c4){_0x4267c4[_0x6ee4('0x104')](_0x6ee4('0x105'));}});}})[_0x6ee4('0x1c')](function(){var _0x5a5a66=_0xd20adc['Interval'];var _0x16bd8e=_0xd20adc[_0x6ee4('0x94')]||undefined;return _0x5a5a66?_0x5a5a66[_0x6ee4('0x95')](_0x16bd8e):!![];})[_0x6ee4('0x1c')](function(_0x45a2be){var _0x37f43f=fs[_0x6ee4('0xd9')](path[_0x6ee4('0x82')](config['root'],_0x6ee4('0x106')),'utf8');var _0x2b3189=_0x6ee4('0x107');var _0x58b943=![];try{const _0x32ac65=new URL(_0xd20adc['address']);_0xd20adc[_0x6ee4('0x67')]=_0x32ac65[_0x6ee4('0x108')];}catch(_0x40e571){}var _0x2b8971;if(_0x588fb3[_0x6ee4('0xb2')][_0x6ee4('0x9e')]){_0x588fb3[_0x6ee4('0xb2')][_0x6ee4('0x9e')]=_0x588fb3[_0x6ee4('0xb2')][_0x6ee4('0x9e')][_0x6ee4('0x109')](/\/$/,'');_0x2b8971=wildcardUtils[_0x6ee4('0x10a')](_0xd20adc[_0x6ee4('0x67')],_0x588fb3['headers'][_0x6ee4('0x9e')]);}else{_0x588fb3['headers'][_0x6ee4('0x9e')]=_0xd20adc['address'];_0x2b8971=!![];}var _0x1a1523={'chatVersion':_0x2b3189,'chatWebsiteAddressOrigin':_0x2b8971?_0x588fb3[_0x6ee4('0xb2')][_0x6ee4('0x9e')]:_0xd20adc['address'],'remote':_0xd20adc['remote'],'query':querystring[_0x6ee4('0x21')](_[_0x6ee4('0x5c')](_0xd20adc['get']({'plain':!![]}),{'customerIp':_0x588fb3[_0x6ee4('0xb2')][_0x6ee4('0x3a')]||_0x588fb3[_0x6ee4('0xb2')][_0x6ee4('0x10b')]||_0x588fb3[_0x6ee4('0x10c')]['remoteAddress']||_0x588fb3['ip'],'referer':_0x588fb3['headers'][_0x6ee4('0x9e')],'openedInteractions':_0x415189,'maxInteractions':_0xfce68e,'virtual':_0x4f6186['virtual'],'online':_0x45a2be,'custom':_0x4f6186,'address':_0x2b8971?_0x588fb3['headers'][_0x6ee4('0x9e')]:null}))[_0x6ee4('0x109')](/'/g,'\x5c\x27')};_0x45d4f0[_0x6ee4('0xd2')](ejs['render'](Mustache[_0x6ee4('0xdb')](_0x37f43f,_0x1a1523),{'proactiveActions':_0x1b6033,'alignment':_0xd20adc[_0x6ee4('0x10d')],'verticalAlignment':_0xd20adc['verticalAlignment'],'div_color':_0xd20adc[_0x6ee4('0x10e')],'labelText':_0xd20adc[_0x6ee4('0x10f')],'text_color':_0xd20adc[_0x6ee4('0x110')],'text_button_color':_0xd20adc[_0x6ee4('0x111')],'button_color':_0xd20adc['color_button'],'background_color':_0xd20adc[_0x6ee4('0x112')],'hideWhenOffline':_0xd20adc['hideWhenOffline'],'intervalId':_0xd20adc['IntervalId'],'isDevelopment':_0x58b943,'chatVersion':_0x2b3189}));})[_0x6ee4('0x27')](handleError(_0x45d4f0,null));};exports[_0x6ee4('0x113')]=function(_0x2c4419,_0x2857e3){var _0x4eb1a2=_0x2c4419[_0x6ee4('0x64')]['id'];var _0x44be61=_0x2c4419['body'];var _0x384df0=0xc8;var _0x22e51b=null;return db[_0x6ee4('0x114')][_0x6ee4('0xe5')]({'isolationLevel':db[_0x6ee4('0x114')]['Transaction'][_0x6ee4('0x115')][_0x6ee4('0x116')]},function(_0x481021){return db[_0x6ee4('0x4d')]['findOne']({'where':{'id':_0x4eb1a2},'transaction':_0x481021})[_0x6ee4('0x1c')](function(_0x439277){if(_0x439277){return db[_0x6ee4('0xaa')][_0x6ee4('0x32')]({'where':{'ChatWebsiteId':_0x4eb1a2},'transaction':_0x481021})[_0x6ee4('0x1c')](function(){var _0x386398=_['map'](_0x44be61,function(_0x8fdaa3){_0x8fdaa3[_0x6ee4('0x71')]=_0x4eb1a2;return _0x8fdaa3;});return db[_0x6ee4('0xaa')]['bulkCreate'](_0x386398,{'transaction':_0x481021});});}else{_0x384df0=0x194;_0x22e51b=[];}});})[_0x6ee4('0x1c')](function(){if(_0x384df0!==0x194){return db[_0x6ee4('0xaa')][_0x6ee4('0x117')]({'where':{'ChatWebsiteId':_0x4eb1a2},'order':_0x6ee4('0xaf')})[_0x6ee4('0x1c')](function(_0x355c45){_0x22e51b=_0x355c45;});}})[_0x6ee4('0x27')](function(_0x24f4e0){_0x384df0=0x1f4;logger[_0x6ee4('0x22')](_0x24f4e0[_0x6ee4('0x118')]);if(_0x24f4e0[_0x6ee4('0x35')]){delete _0x24f4e0[_0x6ee4('0x35')];}_0x22e51b=_0x24f4e0;})[_0x6ee4('0x119')](function(){if(_0x22e51b===null){_0x2857e3[_0x6ee4('0x28')](_0x384df0);}else{if(_0x384df0===0x1f4){_0x2857e3['status'](_0x384df0)[_0x6ee4('0xd2')](_0x22e51b);}else{_0x2857e3[_0x6ee4('0x29')](_0x384df0)['json'](_0x22e51b);}}});};exports[_0x6ee4('0x11a')]=function(_0x2d1dfa,_0x29b280){var _0x3c029f={};var _0x2a4beb={};var _0x308981;var _0x999e20;return db[_0x6ee4('0x4d')][_0x6ee4('0x77')]({'where':{'id':_0x2d1dfa[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x29b280,null))[_0x6ee4('0x1c')](function(_0x379cb1){if(_0x379cb1){_0x308981=_0x379cb1;_0x2a4beb['model']=_[_0x6ee4('0x50')](db[_0x6ee4('0xaa')]['rawAttributes']);_0x2a4beb['query']=_['keys'](_0x2d1dfa[_0x6ee4('0x51')]);_0x2a4beb[_0x6ee4('0x59')]=_['intersection'](_0x2a4beb[_0x6ee4('0x46')],_0x2a4beb[_0x6ee4('0x51')]);_0x3c029f[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x2a4beb[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x3c029f[_0x6ee4('0x53')]=_0x3c029f[_0x6ee4('0x53')][_0x6ee4('0x55')]?_0x3c029f[_0x6ee4('0x53')]:_0x2a4beb['model'];_0x3c029f['order']=qs[_0x6ee4('0x57')](_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x3c029f[_0x6ee4('0x58')]=qs[_0x6ee4('0x59')](_[_0x6ee4('0x5a')](_0x2d1dfa['query'],_0x2a4beb['filters']));if(_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x5b')]){_0x3c029f['where']=_[_0x6ee4('0x5c')](_0x3c029f[_0x6ee4('0x58')],{'$or':_[_0x6ee4('0x4c')](_0x3c029f[_0x6ee4('0x53')],function(_0x4e3df0){var _0x5417c3={};_0x5417c3[_0x4e3df0]={'$like':'%'+_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x5417c3;})});}_0x3c029f=_[_0x6ee4('0x5c')]({},_0x3c029f,_0x2d1dfa['options']);return _0x308981['getApplications'](_0x3c029f);}})[_0x6ee4('0x1c')](function(_0x386c43){if(_0x386c43){_0x999e20=_0x386c43[_0x6ee4('0x55')];if(!_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x73')](_0x6ee4('0x78'))){_0x3c029f[_0x6ee4('0x2c')]=qs[_0x6ee4('0x2c')](_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x2c')]);_0x3c029f[_0x6ee4('0x2f')]=qs[_0x6ee4('0x2f')](_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x2f')]);}return _0x308981[_0x6ee4('0x11a')](_0x3c029f);}})[_0x6ee4('0x1c')](function(_0x59fa6a){if(_0x59fa6a){return _0x59fa6a?{'count':_0x999e20,'rows':_0x59fa6a}:null;}})[_0x6ee4('0x1c')](respondWithResult(_0x29b280,null))[_0x6ee4('0x27')](handleError(_0x29b280,null));};exports[_0x6ee4('0x11b')]=function(_0x5b2f95,_0x470cfc){return db[_0x6ee4('0x11c')][_0x6ee4('0x65')]({'where':{'id':_0x5b2f95[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x470cfc,null))[_0x6ee4('0x1c')](function(_0x5bac39){if(_0x5bac39){return _0x5bac39[_0x6ee4('0x11b')](_0x5b2f95[_0x6ee4('0x68')][_0x6ee4('0x75')],_[_0x6ee4('0x11d')](_0x5b2f95['body'],[_0x6ee4('0x75'),'id'])||{});}})[_0x6ee4('0x1c')](respondWithResult(_0x470cfc,null))[_0x6ee4('0x27')](handleError(_0x470cfc,null));};exports[_0x6ee4('0x100')]=function(_0x49528d,_0x482582){var _0x36d87f={};var _0x36b2d={};var _0x4f4455;var _0x337c0f;return db['ChatWebsite'][_0x6ee4('0x77')]({'where':{'id':_0x49528d[_0x6ee4('0x64')]['id']}})['then'](handleEntityNotFound(_0x482582,null))[_0x6ee4('0x1c')](function(_0x51ed20){if(_0x51ed20){_0x4f4455=_0x51ed20;_0x36b2d['model']=_[_0x6ee4('0x50')](db['ChatProactiveAction'][_0x6ee4('0x4e')]);_0x36b2d[_0x6ee4('0x51')]=_[_0x6ee4('0x50')](_0x49528d[_0x6ee4('0x51')]);_0x36b2d['filters']=_['intersection'](_0x36b2d[_0x6ee4('0x46')],_0x36b2d[_0x6ee4('0x51')]);_0x36d87f[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x36b2d[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x49528d[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x36d87f[_0x6ee4('0x53')]=_0x36d87f[_0x6ee4('0x53')][_0x6ee4('0x55')]?_0x36d87f[_0x6ee4('0x53')]:_0x36b2d['model'];_0x36d87f['order']=qs['sort'](_0x49528d[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x36d87f['where']=qs[_0x6ee4('0x59')](_['pick'](_0x49528d[_0x6ee4('0x51')],_0x36b2d['filters']));if(_0x49528d[_0x6ee4('0x51')][_0x6ee4('0x5b')]){_0x36d87f['where']=_['merge'](_0x36d87f[_0x6ee4('0x58')],{'$or':_[_0x6ee4('0x4c')](_0x36d87f[_0x6ee4('0x53')],function(_0x2ad2ef){var _0x5111ac={};_0x5111ac[_0x2ad2ef]={'$like':'%'+_0x49528d[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x5111ac;})});}_0x36d87f=_[_0x6ee4('0x5c')]({},_0x36d87f,_0x49528d[_0x6ee4('0x5e')]);return _0x4f4455[_0x6ee4('0x100')](_0x36d87f);}})['then'](function(_0x1e80d1){if(_0x1e80d1){_0x337c0f=_0x1e80d1[_0x6ee4('0x55')];if(!_0x49528d[_0x6ee4('0x51')][_0x6ee4('0x73')](_0x6ee4('0x78'))){_0x36d87f[_0x6ee4('0x2c')]=qs[_0x6ee4('0x2c')](_0x49528d[_0x6ee4('0x51')]['limit']);_0x36d87f[_0x6ee4('0x2f')]=qs[_0x6ee4('0x2f')](_0x49528d['query'][_0x6ee4('0x2f')]);}return _0x4f4455[_0x6ee4('0x100')](_0x36d87f);}})['then'](function(_0x31683d){if(_0x31683d){return _0x31683d?{'count':_0x337c0f,'rows':_0x31683d}:null;}})[_0x6ee4('0x1c')](respondWithResult(_0x482582,null))[_0x6ee4('0x27')](handleError(_0x482582,null));};exports[_0x6ee4('0x11e')]=function(_0x14d9dd,_0x2e6160){var _0x4338d2=_0x14d9dd['query'][_0x6ee4('0x11f')]===_0x6ee4('0x120')?_0x6ee4('0x121'):'onlineForm';return db['ChatWebsite'][_0x6ee4('0x65')]({'attributes':['id',_0x4338d2],'where':{'id':_0x14d9dd[_0x6ee4('0x64')]['id']}})['then'](handleEntityNotFound(_0x2e6160,null))[_0x6ee4('0x1c')](function(_0x8083c7){if(_0x8083c7){var _0x2fe4bb=_0x8083c7[_0x4338d2];var _0x1504da=_0x2fe4bb&&_0x2fe4bb[_0x6ee4('0x122')]?_0x2fe4bb['items']:[];_0x2e6160['send']({'fromKey':_[_0x6ee4('0x86')](_0x2fe4bb[_0x6ee4('0x123')])?undefined:_0x2fe4bb[_0x6ee4('0x123')],'count':_0x1504da[_0x6ee4('0x55')],'rows':_0x1504da});}})[_0x6ee4('0x27')](handleError(_0x2e6160,null));};exports['getOfflineMessages']=function(_0x2a75b3,_0x16c23b){var _0x4ca942={'raw':![],'where':{}};var _0x2e4e99={};var _0x709458={'count':0x0,'rows':[]};return db[_0x6ee4('0x4d')]['findOne']({'where':{'id':_0x2a75b3[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x16c23b,null))[_0x6ee4('0x1c')](function(_0x26a59c){if(_0x26a59c){_0x2e4e99[_0x6ee4('0x46')]=_[_0x6ee4('0x50')](db[_0x6ee4('0x124')][_0x6ee4('0x4e')]);_0x2e4e99[_0x6ee4('0x51')]=_[_0x6ee4('0x50')](_0x2a75b3[_0x6ee4('0x51')]);_0x2e4e99['filters']=_[_0x6ee4('0x52')](_0x2e4e99[_0x6ee4('0x46')],_0x2e4e99[_0x6ee4('0x51')]);_0x4ca942[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x2e4e99[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x2a75b3[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x4ca942['attributes']=_0x4ca942[_0x6ee4('0x53')]['length']?_0x4ca942[_0x6ee4('0x53')]:_0x2e4e99[_0x6ee4('0x46')];if(!_0x2a75b3[_0x6ee4('0x51')][_0x6ee4('0x73')](_0x6ee4('0x78'))){_0x4ca942[_0x6ee4('0x2c')]=qs[_0x6ee4('0x2c')](_0x2a75b3['query'][_0x6ee4('0x2c')]);_0x4ca942[_0x6ee4('0x2f')]=qs['offset'](_0x2a75b3['query']['offset']);}_0x4ca942[_0x6ee4('0x56')]=qs[_0x6ee4('0x57')](_0x2a75b3[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x4ca942[_0x6ee4('0x58')]=qs[_0x6ee4('0x59')](_[_0x6ee4('0x5a')](_0x2a75b3[_0x6ee4('0x51')],_0x2e4e99[_0x6ee4('0x59')]));_0x4ca942['where']['ChatWebsiteId']=_0x26a59c['id'];if(_0x2a75b3[_0x6ee4('0x51')][_0x6ee4('0x5b')]){_0x4ca942[_0x6ee4('0x58')]=_[_0x6ee4('0x5c')](_0x4ca942[_0x6ee4('0x58')],{'$or':_[_0x6ee4('0x4c')](_0x4ca942['attributes'],function(_0x2067ad){var _0x369057={};_0x369057[_0x2067ad]={'$like':'%'+_0x2a75b3[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x369057;})});}_0x4ca942=_[_0x6ee4('0x5c')]({},_0x4ca942,_0x2a75b3['options']);return db[_0x6ee4('0x124')]['count']({'where':_0x4ca942[_0x6ee4('0x58')]})['then'](function(_0x338963){_0x709458['count']=_0x338963;if(_0x2a75b3['query']['includeAll']){_0x4ca942[_0x6ee4('0x60')]=[{'all':!![]}];}else{_0x4ca942[_0x6ee4('0x60')]=[{'model':db['CmContact'],'as':'Contact','required':![]},{'model':db[_0x6ee4('0xe6')],'as':_0x6ee4('0x125'),'required':![]}];}return db[_0x6ee4('0x124')][_0x6ee4('0x61')](_0x4ca942);})[_0x6ee4('0x1c')](function(_0x23e500){_0x709458[_0x6ee4('0x62')]=_0x23e500;return _0x709458;});}})['then'](respondWithFilteredResult(_0x16c23b,_0x4ca942))[_0x6ee4('0x27')](handleError(_0x16c23b,null));};exports[_0x6ee4('0x126')]=function(_0x5002fe,_0x488e31){return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x5002fe[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x488e31,null))[_0x6ee4('0x1c')](function(_0xed8a33){if(_0xed8a33){return _0xed8a33[_0x6ee4('0x126')](_0x5002fe[_0x6ee4('0x68')][_0x6ee4('0x75')],_['omit'](_0x5002fe['body'],[_0x6ee4('0x75'),'id'])||{})[_0x6ee4('0xd8')](function(_0x3d250d){for(var _0xdf9e70=0x0;_0xdf9e70<_0x5002fe[_0x6ee4('0x68')][_0x6ee4('0x75')]['length'];_0xdf9e70+=0x1){socket[_0x6ee4('0x127')](_0x6ee4('0x128'),{'UserId':Number(_0x5002fe['body'][_0x6ee4('0x75')][_0xdf9e70]),'ChatWebsiteId':Number(_0x5002fe[_0x6ee4('0x64')]['id'])});}return _0x3d250d;});}})[_0x6ee4('0x1c')](respondWithResult(_0x488e31,null))['catch'](handleError(_0x488e31,null));};exports[_0x6ee4('0x129')]=function(_0x199807,_0x1bb4a2){return db[_0x6ee4('0x4d')]['find']({'where':{'id':_0x199807[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x1bb4a2,null))[_0x6ee4('0x1c')](function(_0x3fe511){if(_0x3fe511){return _0x3fe511[_0x6ee4('0x129')](_0x199807['query']['ids'])[_0x6ee4('0x1c')](function(){if(_[_0x6ee4('0x12a')](_0x199807[_0x6ee4('0x51')][_0x6ee4('0x75')])){for(var _0x2a01ed=0x0;_0x2a01ed<_0x199807[_0x6ee4('0x51')]['ids'][_0x6ee4('0x55')];_0x2a01ed+=0x1){socket[_0x6ee4('0x127')](_0x6ee4('0x12b'),{'UserId':Number(_0x199807[_0x6ee4('0x51')]['ids'][_0x2a01ed]),'ChatWebsiteId':Number(_0x199807[_0x6ee4('0x64')]['id'])});}}else{socket[_0x6ee4('0x127')](_0x6ee4('0x12b'),{'UserId':Number(_0x199807[_0x6ee4('0x51')][_0x6ee4('0x75')]),'ChatWebsiteId':Number(_0x199807[_0x6ee4('0x64')]['id'])});}});}})[_0x6ee4('0x1c')](respondWithStatusCode(_0x1bb4a2,null))[_0x6ee4('0x27')](handleError(_0x1bb4a2,null));};exports[_0x6ee4('0x12c')]=function(_0x31dfe6,_0x4bce61){var _0x3952e7={};var _0x5012f6={};var _0x2eed44;var _0x5eada9;return db[_0x6ee4('0x4d')][_0x6ee4('0x77')]({'where':{'id':_0x31dfe6[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x4bce61,null))[_0x6ee4('0x1c')](function(_0x3a75b1){if(_0x3a75b1){_0x2eed44=_0x3a75b1;_0x5012f6[_0x6ee4('0x46')]=_['keys'](db[_0x6ee4('0xc3')][_0x6ee4('0x4e')]);_0x5012f6[_0x6ee4('0x51')]=_[_0x6ee4('0x50')](_0x31dfe6[_0x6ee4('0x51')]);_0x5012f6['filters']=_[_0x6ee4('0x52')](_0x5012f6[_0x6ee4('0x46')],_0x5012f6[_0x6ee4('0x51')]);_0x3952e7[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x5012f6[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x31dfe6[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x3952e7[_0x6ee4('0x53')]=_0x3952e7[_0x6ee4('0x53')]['length']?_0x3952e7['attributes']:_0x5012f6['model'];_0x3952e7[_0x6ee4('0x56')]=qs['sort'](_0x31dfe6[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x3952e7[_0x6ee4('0x58')]=qs['filters'](_[_0x6ee4('0x5a')](_0x31dfe6[_0x6ee4('0x51')],_0x5012f6[_0x6ee4('0x59')]));if(_0x31dfe6[_0x6ee4('0x51')]['filter']){_0x3952e7['where']=_[_0x6ee4('0x5c')](_0x3952e7[_0x6ee4('0x58')],{'$or':_[_0x6ee4('0x4c')](_0x3952e7[_0x6ee4('0x53')],function(_0x288f14){var _0x3309af={};_0x3309af[_0x288f14]={'$like':'%'+_0x31dfe6[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x3309af;})});}_0x3952e7=_[_0x6ee4('0x5c')]({},_0x3952e7,_0x31dfe6[_0x6ee4('0x5e')]);return _0x2eed44['getAgents'](_0x3952e7);}})[_0x6ee4('0x1c')](function(_0x15250f){if(_0x15250f){_0x5eada9=_0x15250f[_0x6ee4('0x55')];if(!_0x31dfe6[_0x6ee4('0x51')][_0x6ee4('0x73')](_0x6ee4('0x78'))){_0x3952e7['limit']=qs[_0x6ee4('0x2c')](_0x31dfe6[_0x6ee4('0x51')][_0x6ee4('0x2c')]);_0x3952e7[_0x6ee4('0x2f')]=qs['offset'](_0x31dfe6['query']['offset']);}return _0x2eed44[_0x6ee4('0x12c')](_0x3952e7);}})[_0x6ee4('0x1c')](function(_0x4d839e){if(_0x4d839e){return _0x4d839e?{'count':_0x5eada9,'rows':_0x4d839e}:null;}})[_0x6ee4('0x1c')](respondWithResult(_0x4bce61,null))[_0x6ee4('0x27')](handleError(_0x4bce61,null));};
\ No newline at end of file