9a5592fd3c91c1de87dee212ef9ee54a2e1033f8
[motion-next.git] / server / api / chatWebsite / chatWebsite.controller.js
1 const a111_0x28b2=['request','bulkCreate','connection','customerAvatar','cf-connecting-ip','AttachmentId','agentAvatar','port','addProactiveActions','addAgents','isArray','util','render','asc','OFFLINE','request\x20sent','systemAvatar','status','replace','fullname','toPairs','utf8','customerIp','index','../../components/parsers/qs','alignment','List','filename','model','remote','sitepic','No\x20timezone','autoclose','includes','query','../../config/license/util','getResult','account','ChatWebsiteId','intersection','like','showCustomerAvatar','result','map','x-real-ip','setUA','getApplications','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','offlineForm','debug','getAnswers','push','include','then','merge','vendor','Start','getSnippet','mustache','role','first','name','attributes','getCustomerAvatar','Applications','message','userChatWebsite:save','agent','UserProfileResource','end','join','findAndCountAll','pick','readFileSync','Contact','true','file','secure','removeDispositions','addDisposition','findOrCreate','body','../../config/environment','notify','where','json','type','send','set','Command','stack','headers','rows','device','user','unknown','service','ChatInteraction','difference','nolimit','custom','items','from','addAnswer','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','catch','ids','offlineMessageBody','addCustomerAvatar','ChatWebsites','options','onlineForm','CmList','offset','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','VIRTUAL','UserId','omit','chatLicenseExceeded','getLicense','CmContact','ListId','mandatoryDispositionPause','key','CannedAnswer','email','License','ONLINE','update','EventManager','DESC','Owner','getLogo','path','destroy','*,*,*,*','register','Interval','server/files/images/avatars/system_avatar.png','emit','interval','list','%s\x20%s','getProactiveActions','error','created','rawAttributes','addInteraction','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','server/files/images/logos/','offlineMessageSubject','Content-Range','getAgents','existsSync','host','getOfflineMessages','fields','Tags','transaction','x-forwarded-for','offline','sendStatus','Pause','body\x20is\x20mandatory\x20and\x20not\x20empty','iftime\x20%s','includeAll','stringify','findOne','order','Smtp','filters','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','user-agent-parser','addLogo','version','server/files/images/avatars/default_avatar.png','api','forcedOwnership','externalUrl','undefined','chat','lastName','orderBy','./chatWebsite.socket','autoAssociation','get','sort','ChatApplication','updatedAt','ChatWebsite,\x20%s,\x20%s','Tag','browser','isNil','length','ChatMessage','params','info','getInteractions','fromKey','threadId','User','waitForTheAssignedAgent','SendMail','limit','timezone','some','applications','addAvatar','CompanyId','describe','chatProactiveAction','create','mapKeyOffline','ChatOfflineMessage','../../mysqldb','pass','server/files/images/logos/default_logo.svg','interaction','Intervals','show','removeAgents','color','createdAt','http','auth','userChatWebsite:remove','x-real-port','inspect','sequelize','client','keys','ChatWebsite','app','from\x20is\x20mandatory','no\x20available\x20attributes','findAll','online','forwardOfflineAddress','code','filter','server/files/templates/chatOfflineMessage.ejs','Disposition','firstName','mapKey','count','server/files/images/avatars/','tag','messageId','close','removeAnswers','startRouting','download','ContactId','format','defaults','files/chat/iframe.js','priority','fieldName','\x22%s\x22\x20<%s>','root','Contacts','contact','virtual'];(function(_0x3aa6d3,_0x28b2b0){const _0x306b34=function(_0x4dad45){while(--_0x4dad45){_0x3aa6d3['push'](_0x3aa6d3['shift']());}};_0x306b34(++_0x28b2b0);}(a111_0x28b2,0xbb));const a111_0x306b=function(_0x3aa6d3,_0x28b2b0){_0x3aa6d3=_0x3aa6d3-0x0;let _0x306b34=a111_0x28b2[_0x3aa6d3];return _0x306b34;};const _0x5a3283=a111_0x306b;'use strict';const Mustache=require(_0x5a3283('0x86')),util=require(_0x5a3283('0x57')),path=require(_0x5a3283('0xd1')),ejs=require('ejs'),fs=require('fs'),_=require('lodash'),querystring=require('querystring'),qs=require(_0x5a3283('0x64')),logger=require('../../config/logger')(_0x5a3283('0xfc')),config=require(_0x5a3283('0x9e')),db=require(_0x5a3283('0x1b'))['db'],{Op,ValidationError}=require(_0x5a3283('0x29')),{getSocket}=require('../../rediscache'),socket=getSocket();require(_0x5a3283('0x103'))[_0x5a3283('0xd4')](socket);const jayson=require('jayson/promise'),client=jayson[_0x5a3283('0x2a')][_0x5a3283('0x24')]({'port':0x232c}),client9002=jayson[_0x5a3283('0x2a')][_0x5a3283('0x24')]({'port':0x232a}),client9003=jayson[_0x5a3283('0x2a')][_0x5a3283('0x24')]({'port':0x232b});function respondWithRpcPromise(_0x4dad45,_0x540207,_0x51ab15,_0x3ddb4e){return new Promise(function(_0x5533a9,_0x2ad934){const _0x3b546c=a111_0x306b,_0x3c7c41=_0x3ddb4e||client;return _0x3c7c41[_0x3b546c('0x4c')](_0x4dad45,_0x51ab15)[_0x3b546c('0x81')](function(_0x18af41){const _0x4e3bab=_0x3b546c;logger['info'](_0x4e3bab('0x2'),_0x540207,_0x4e3bab('0x5b')),logger[_0x4e3bab('0x7d')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x540207,_0x4e3bab('0x5b'),JSON[_0x4e3bab('0xf2')](_0x18af41));if(_0x18af41[_0x4e3bab('0xdc')]){if(_0x18af41['error'][_0x4e3bab('0x33')]===0x1f4)return logger[_0x4e3bab('0xdc')](_0x4e3bab('0x2'),_0x540207,_0x18af41[_0x4e3bab('0xdc')][_0x4e3bab('0x8d')]),_0x2ad934(_0x18af41[_0x4e3bab('0xdc')][_0x4e3bab('0x8d')]);return logger['error'](_0x4e3bab('0x2'),_0x540207,_0x18af41[_0x4e3bab('0xdc')][_0x4e3bab('0x8d')]),_0x5533a9(_0x18af41['error'][_0x4e3bab('0x8d')]);}else logger[_0x4e3bab('0x9')](_0x4e3bab('0x2'),_0x540207,_0x4e3bab('0x5b')),_0x5533a9(_0x18af41[_0x4e3bab('0x76')][_0x4e3bab('0x8d')]);})['catch'](function(_0x5a5e45){const _0x5504df=_0x3b546c;logger['error'](_0x5504df('0x2'),_0x540207,_0x5a5e45),_0x2ad934(_0x5a5e45);});});}function respondWithStatusCode(_0x4cd773,_0x53c331){return _0x53c331=_0x53c331||0xcc,function(_0x39ae7a){const _0x4fa83c=a111_0x306b;if(_0x39ae7a)return _0x4cd773[_0x4fa83c('0xed')](_0x53c331);return _0x4cd773['status'](_0x53c331)[_0x4fa83c('0x91')]();};}function respondWithResult(_0x38542e,_0x35d613){return _0x35d613=_0x35d613||0xc8,function(_0x322cb1){const _0x263c3c=a111_0x306b;if(_0x322cb1)return _0x38542e['status'](_0x35d613)[_0x263c3c('0xa1')](_0x322cb1);};}function respondWithFilteredResult(_0x1e5d88,_0x54a08e){return function(_0x1a58eb){const _0x57fd84=a111_0x306b;if(_0x1a58eb){const _0x3fa105=_0x1a58eb[_0x57fd84('0x39')],_0x4d9802=_0x54a08e[_0x57fd84('0xbd')];let _0x551a1e=_0x54a08e['offset']+_0x54a08e[_0x57fd84('0x10')],_0x455f7f;return _0x551a1e>=_0x3fa105?(_0x551a1e=_0x3fa105,_0x455f7f=0xc8):_0x455f7f=0xce,_0x1e5d88[_0x57fd84('0x5d')](_0x455f7f),_0x1e5d88[_0x57fd84('0xa4')](_0x57fd84('0xe3'),_0x4d9802+'-'+_0x551a1e+'/'+_0x3fa105)[_0x57fd84('0xa1')](_0x1a58eb);}return null;};}function saveUpdates(_0x5a7c91){return function(_0x24eefd){const _0x5dd4e6=a111_0x306b;if(_0x24eefd)return _0x24eefd[_0x5dd4e6('0xcc')](_0x5a7c91)[_0x5dd4e6('0x81')](function(_0x51482a){return _0x51482a;});return null;};}function removeEntity(_0x4baca3){return function(_0x4e1669){const _0x36df99=a111_0x306b;if(_0x4e1669)return _0x4e1669[_0x36df99('0xd2')]()['then'](function(){const _0x3e8deb=_0x36df99,_0x119e75=_0x4e1669[_0x3e8deb('0x105')]({'plain':!![]}),_0x2deb38=_0x3e8deb('0xb9');return db[_0x3e8deb('0x90')][_0x3e8deb('0xd2')]({'where':{'type':_0x2deb38,'resourceId':_0x119e75['id']}})[_0x3e8deb('0x81')](function(){return _0x4e1669;});})[_0x36df99('0x81')](function(){const _0x3a4b52=_0x36df99;_0x4baca3[_0x3a4b52('0x5d')](0xcc)[_0x3a4b52('0x91')]();});};}function handleEntityNotFound(_0x3177df){return function(_0x5e8a27){return!_0x5e8a27&&_0x3177df['sendStatus'](0x194),_0x5e8a27;};}function handleError(_0x596ab0,_0x13060c){return _0x13060c=_0x13060c||0x1f4,function(_0xd48c27){const _0x19fee4=a111_0x306b;logger[_0x19fee4('0xdc')](_0xd48c27[_0x19fee4('0xa6')]),_0xd48c27[_0x19fee4('0x89')]&&delete _0xd48c27[_0x19fee4('0x89')],_0x596ab0[_0x19fee4('0x5d')](_0x13060c)[_0x19fee4('0xa3')](_0xd48c27);};}exports[_0x5a3283('0x63')]=function(_0x1e6cf1,_0x4ae124){const _0x215851=_0x5a3283;let _0x52a08a={'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]};const _0x365f53={},_0x36c82e={'count':0x0,'rows':[]},_0x1ca7eb=_['map'](db[_0x215851('0x2c')][_0x215851('0xde')],function(_0x785da8){const _0x385871=_0x215851;return{'name':_0x785da8[_0x385871('0x46')],'type':_0x785da8[_0x385871('0xa2')][_0x385871('0xc7')]};});_0x365f53[_0x215851('0x68')]=_[_0x215851('0x77')](_0x1ca7eb,_0x215851('0x89')),_0x365f53[_0x215851('0x6e')]=_[_0x215851('0x2b')](_0x1e6cf1[_0x215851('0x6e')]),_0x365f53[_0x215851('0xf6')]=_[_0x215851('0x73')](_0x365f53['model'],_0x365f53[_0x215851('0x6e')]),_0x52a08a[_0x215851('0x8a')]=_[_0x215851('0x73')](_0x365f53[_0x215851('0x68')],qs[_0x215851('0xe8')](_0x1e6cf1['query'][_0x215851('0xe8')])),_0x52a08a[_0x215851('0x8a')]=_0x52a08a[_0x215851('0x8a')]['length']?_0x52a08a[_0x215851('0x8a')]:_0x365f53[_0x215851('0x68')];typeof _0x1e6cf1[_0x215851('0x6e')][_0x215851('0xaf')]==='undefined'&&(_0x52a08a[_0x215851('0x10')]=qs['limit'](_0x1e6cf1[_0x215851('0x6e')][_0x215851('0x10')]),_0x52a08a[_0x215851('0xbd')]=qs[_0x215851('0xbd')](_0x1e6cf1[_0x215851('0x6e')][_0x215851('0xbd')]));_0x52a08a[_0x215851('0xf4')]=qs['sort'](_0x1e6cf1['query'][_0x215851('0x106')]),_0x52a08a[_0x215851('0xa0')]=qs[_0x215851('0xf6')](_[_0x215851('0x94')](_0x1e6cf1[_0x215851('0x6e')],_0x365f53[_0x215851('0xf6')]),_0x1ca7eb);_0x1e6cf1[_0x215851('0x6e')]['filter']&&(_0x52a08a['where']=_[_0x215851('0x82')](_0x52a08a[_0x215851('0xa0')],{[Op['or']]:_[_0x215851('0x77')](_0x1ca7eb,function(_0x428106){const _0x4d7d31=_0x215851;if(_0x428106['type']!==_0x4d7d31('0xbf')){const _0x54314d={};return _0x54314d[_0x428106[_0x4d7d31('0x89')]]={[Op[_0x4d7d31('0x74')]]:'%'+_0x1e6cf1[_0x4d7d31('0x6e')][_0x4d7d31('0x34')]+'%'},_0x54314d;}})}));_0x52a08a=_[_0x215851('0x82')]({},_0x52a08a,_0x1e6cf1[_0x215851('0xba')]);const _0x5b2d87={'where':_0x52a08a['where']};return db[_0x215851('0x2c')][_0x215851('0x39')](_0x5b2d87)['then'](function(_0xf3ead3){const _0x22ab3c=_0x215851;return _0x36c82e['count']=_0xf3ead3,_0x1e6cf1[_0x22ab3c('0x6e')]['includeAll']&&(_0x52a08a[_0x22ab3c('0x80')]=[{'all':!![]}]),db[_0x22ab3c('0x2c')][_0x22ab3c('0x30')](_0x52a08a);})[_0x215851('0x81')](function(_0x2a5778){const _0x3fe2b7=_0x215851;return _0x36c82e[_0x3fe2b7('0xa8')]=_0x2a5778,_0x36c82e;})[_0x215851('0x81')](respondWithFilteredResult(_0x4ae124,_0x52a08a))['catch'](handleError(_0x4ae124,null));},exports[_0x5a3283('0x20')]=function(_0x2d88e5,_0x54e918){const _0x48469f=_0x5a3283;let _0x42566e={'raw':![],'where':{'id':_0x2d88e5[_0x48469f('0x8')]['id']},'include':[{'model':db[_0x48469f('0xee')],'as':_0x48469f('0xc6')}]};const _0x4a416a={};return _0x4a416a['model']=_[_0x48469f('0x2b')](db['ChatWebsite'][_0x48469f('0xde')]),_0x4a416a[_0x48469f('0x6e')]=_['keys'](_0x2d88e5['query']),_0x4a416a['filters']=_['intersection'](_0x4a416a[_0x48469f('0x68')],_0x4a416a[_0x48469f('0x6e')]),_0x42566e[_0x48469f('0x8a')]=_[_0x48469f('0x73')](_0x4a416a['model'],qs['fields'](_0x2d88e5[_0x48469f('0x6e')][_0x48469f('0xe8')])),_0x42566e[_0x48469f('0x8a')]=_0x42566e[_0x48469f('0x8a')]['length']?_0x42566e[_0x48469f('0x8a')]:_0x4a416a[_0x48469f('0x68')],_0x2d88e5[_0x48469f('0x6e')][_0x48469f('0xf1')]&&(_0x42566e[_0x48469f('0x80')]=[{'all':!![]}]),_0x42566e=_[_0x48469f('0x82')]({},_0x42566e,_0x2d88e5[_0x48469f('0xba')]),db[_0x48469f('0x2c')][_0x48469f('0xf3')](_0x42566e)['then'](handleEntityNotFound(_0x54e918,null))[_0x48469f('0x81')](respondWithResult(_0x54e918,null))[_0x48469f('0xb5')](handleError(_0x54e918,null));},exports[_0x5a3283('0x18')]=function(_0x378a8d,_0x9b4152){const _0x5095cf=_0x5a3283;return db['ChatWebsite'][_0x5095cf('0x18')](_0x378a8d[_0x5095cf('0x9d')],{})[_0x5095cf('0x81')](function(_0xd36343){const _0x2cb525=_0x5095cf,_0x33cffa=_0x378a8d[_0x2cb525('0xaa')]['get']({'plain':!![]});if(!_0x33cffa)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x33cffa[_0x2cb525('0x87')]===_0x2cb525('0xaa')){const _0xf4d272=_0xd36343[_0x2cb525('0x105')]({'plain':!![]}),_0x4b8f28=_0x2cb525('0xb9');return db['UserProfileSection'][_0x2cb525('0xf3')]({'where':{'name':_0x4b8f28,'userProfileId':_0x33cffa['userProfileId']},'raw':!![]})[_0x2cb525('0x81')](function(_0x1a5fba){const _0x5d2aee=_0x2cb525;return _0x1a5fba&&_0x1a5fba[_0x5d2aee('0x104')]===0x0?db[_0x5d2aee('0x90')][_0x5d2aee('0x18')]({'name':_0xf4d272['name'],'resourceId':_0xf4d272['id'],'type':_0x1a5fba[_0x5d2aee('0x89')],'sectionId':_0x1a5fba['id']},{})[_0x5d2aee('0x81')](function(){return _0xd36343;}):_0xd36343;})[_0x2cb525('0xb5')](function(_0x2eb3c6){const _0x14c5f8=_0x2cb525;logger[_0x14c5f8('0xdc')](_0x14c5f8('0xb4'),_0x2eb3c6);throw _0x2eb3c6;});}return _0xd36343;})[_0x5095cf('0x81')](respondWithResult(_0x9b4152,0xc9))['catch'](handleError(_0x9b4152,null));},exports[_0x5a3283('0xcc')]=function(_0xb61a1b,_0x25aac9){const _0x2926de=_0x5a3283;return _0xb61a1b['body']['id']&&delete _0xb61a1b['body']['id'],db['ChatWebsite'][_0x2926de('0xf3')]({'where':{'id':_0xb61a1b[_0x2926de('0x8')]['id']},'include':[{'model':db[_0x2926de('0xee')],'as':_0x2926de('0xc6')}]})[_0x2926de('0x81')](handleEntityNotFound(_0x25aac9,null))[_0x2926de('0x81')](saveUpdates(_0xb61a1b[_0x2926de('0x9d')],null))[_0x2926de('0x81')](respondWithResult(_0x25aac9,null))[_0x2926de('0xb5')](handleError(_0x25aac9,null));},exports['destroy']=function(_0x1adc7c,_0x84a544){const _0x490f0e=_0x5a3283;return db[_0x490f0e('0x2c')][_0x490f0e('0xf3')]({'where':{'id':_0x1adc7c[_0x490f0e('0x8')]['id']}})[_0x490f0e('0x81')](handleEntityNotFound(_0x84a544,null))[_0x490f0e('0x81')](removeEntity(_0x84a544,null))['catch'](handleError(_0x84a544,null));},exports[_0x5a3283('0x16')]=function(_0x486dc7,_0x51bd11){const _0x119cd0=_0x5a3283;return db[_0x119cd0('0x2c')][_0x119cd0('0x16')]()['then'](respondWithResult(_0x51bd11,null))[_0x119cd0('0xb5')](handleError(_0x51bd11,null));},exports[_0x5a3283('0x9b')]=function(_0x342db9,_0x5e6435){const _0x397176=_0x5a3283;return _0x342db9[_0x397176('0x9d')]['id']&&delete _0x342db9[_0x397176('0x9d')]['id'],db[_0x397176('0x2c')][_0x397176('0xf3')]({'where':{'id':_0x342db9[_0x397176('0x8')]['id']}})[_0x397176('0x81')](handleEntityNotFound(_0x5e6435,null))[_0x397176('0x81')](function(_0x2bee66){const _0x40c525=_0x397176;if(_0x2bee66)return _0x342db9['body'][_0x40c525('0x72')]=_0x2bee66['id'],db[_0x40c525('0x36')][_0x40c525('0x18')](_0x342db9[_0x40c525('0x9d')]);})[_0x397176('0x81')](respondWithResult(_0x5e6435,null))[_0x397176('0xb5')](handleError(_0x5e6435,null));},exports['getDispositions']=function(_0x116200,_0x5d5674){const _0x557446=_0x5a3283;let _0x395c9d={'raw':![],'where':{}};const _0x4cf8f6={},_0x222c14={'count':0x0,'rows':[]};return db[_0x557446('0x2c')][_0x557446('0xf3')]({'where':{'id':_0x116200[_0x557446('0x8')]['id']}})[_0x557446('0x81')](handleEntityNotFound(_0x5d5674,null))[_0x557446('0x81')](function(_0x4b452b){const _0x3c6ddc=_0x557446;if(_0x4b452b)return _0x4cf8f6[_0x3c6ddc('0x68')]=_[_0x3c6ddc('0x2b')](db['Disposition'][_0x3c6ddc('0xde')]),_0x4cf8f6[_0x3c6ddc('0x6e')]=_[_0x3c6ddc('0x2b')](_0x116200[_0x3c6ddc('0x6e')]),_0x4cf8f6['filters']=_[_0x3c6ddc('0x73')](_0x4cf8f6[_0x3c6ddc('0x68')],_0x4cf8f6[_0x3c6ddc('0x6e')]),_0x395c9d[_0x3c6ddc('0x8a')]=_['intersection'](_0x4cf8f6[_0x3c6ddc('0x68')],qs[_0x3c6ddc('0xe8')](_0x116200[_0x3c6ddc('0x6e')][_0x3c6ddc('0xe8')])),_0x395c9d[_0x3c6ddc('0x8a')]=_0x395c9d[_0x3c6ddc('0x8a')][_0x3c6ddc('0x6')]?_0x395c9d[_0x3c6ddc('0x8a')]:_0x4cf8f6[_0x3c6ddc('0x68')],typeof _0x116200[_0x3c6ddc('0x6e')][_0x3c6ddc('0xaf')]===_0x3c6ddc('0xff')&&(_0x395c9d[_0x3c6ddc('0x10')]=qs[_0x3c6ddc('0x10')](_0x116200[_0x3c6ddc('0x6e')]['limit']),_0x395c9d[_0x3c6ddc('0xbd')]=qs[_0x3c6ddc('0xbd')](_0x116200[_0x3c6ddc('0x6e')][_0x3c6ddc('0xbd')])),_0x395c9d[_0x3c6ddc('0xf4')]=qs[_0x3c6ddc('0x106')](_0x116200[_0x3c6ddc('0x6e')][_0x3c6ddc('0x106')]),_0x395c9d[_0x3c6ddc('0xa0')]=qs['filters'](_[_0x3c6ddc('0x94')](_0x116200[_0x3c6ddc('0x6e')],_0x4cf8f6['filters'])),_0x395c9d['where']['ChatWebsiteId']=_0x4b452b['id'],_0x116200['query'][_0x3c6ddc('0x34')]&&(_0x395c9d[_0x3c6ddc('0xa0')]=_[_0x3c6ddc('0x82')](_0x395c9d[_0x3c6ddc('0xa0')],{[Op['or']]:_[_0x3c6ddc('0x77')](_0x395c9d[_0x3c6ddc('0x8a')],function(_0x53faaa){const _0x188e3f=_0x3c6ddc,_0x56a6cf={};return _0x56a6cf[_0x53faaa]={[Op[_0x188e3f('0x74')]]:'%'+_0x116200['query']['filter']+'%'},_0x56a6cf;})})),_0x395c9d=_[_0x3c6ddc('0x82')]({},_0x395c9d,_0x116200[_0x3c6ddc('0xba')]),db[_0x3c6ddc('0x36')][_0x3c6ddc('0x39')]({'where':_0x395c9d[_0x3c6ddc('0xa0')]})['then'](function(_0x10a2ee){const _0x481b41=_0x3c6ddc;return _0x222c14[_0x481b41('0x39')]=_0x10a2ee,_0x116200[_0x481b41('0x6e')][_0x481b41('0xf1')]&&(_0x395c9d[_0x481b41('0x80')]=[{'all':!![]}]),db[_0x481b41('0x36')]['findAll'](_0x395c9d);})[_0x3c6ddc('0x81')](function(_0x3ba640){const _0x5af318=_0x3c6ddc;return _0x222c14[_0x5af318('0xa8')]=_0x3ba640,_0x222c14;});})[_0x557446('0x81')](respondWithFilteredResult(_0x5d5674,_0x395c9d))[_0x557446('0xb5')](handleError(_0x5d5674,null));},exports[_0x5a3283('0x9a')]=function(_0x1f60c9,_0x22b316){const _0x3c1f04=_0x5a3283;return db['ChatWebsite'][_0x3c1f04('0xf3')]({'where':{'id':_0x1f60c9[_0x3c1f04('0x8')]['id']}})[_0x3c1f04('0x81')](handleEntityNotFound(_0x22b316,null))['then'](function(_0x134188){const _0x595811=_0x3c1f04;if(_0x134188)return _0x134188[_0x595811('0x9a')](_0x1f60c9[_0x595811('0x6e')][_0x595811('0xb6')]);})['then'](respondWithStatusCode(_0x22b316,null))[_0x3c1f04('0xb5')](handleError(_0x22b316,null));},exports[_0x5a3283('0xb3')]=function(_0x3720a5,_0x1ec7ad){const _0x1020d3=_0x5a3283;return _0x3720a5[_0x1020d3('0x9d')]['id']&&delete _0x3720a5['body']['id'],db['ChatWebsite'][_0x1020d3('0xf3')]({'where':{'id':_0x3720a5[_0x1020d3('0x8')]['id']}})[_0x1020d3('0x81')](handleEntityNotFound(_0x1ec7ad,null))[_0x1020d3('0x81')](function(_0x23719b){const _0x233484=_0x1020d3;if(_0x23719b)return _0x3720a5[_0x233484('0x9d')][_0x233484('0x72')]=_0x23719b['id'],db[_0x233484('0xc8')][_0x233484('0x18')](_0x3720a5['body']);})[_0x1020d3('0x81')](respondWithResult(_0x1ec7ad,null))[_0x1020d3('0xb5')](handleError(_0x1ec7ad,null));},exports[_0x5a3283('0x7e')]=function(_0x24422e,_0x566472){const _0x9849bf=_0x5a3283;let _0x2f701d={'raw':![],'where':{}};const _0x2718f8={},_0x3f3cad={'count':0x0,'rows':[]};return db[_0x9849bf('0x2c')][_0x9849bf('0xf3')]({'where':{'id':_0x24422e[_0x9849bf('0x8')]['id']}})[_0x9849bf('0x81')](handleEntityNotFound(_0x566472,null))[_0x9849bf('0x81')](function(_0xd73ed5){const _0x469dd7=_0x9849bf;if(_0xd73ed5)return _0x2718f8[_0x469dd7('0x68')]=_[_0x469dd7('0x2b')](db['CannedAnswer'][_0x469dd7('0xde')]),_0x2718f8[_0x469dd7('0x6e')]=_[_0x469dd7('0x2b')](_0x24422e['query']),_0x2718f8[_0x469dd7('0xf6')]=_[_0x469dd7('0x73')](_0x2718f8[_0x469dd7('0x68')],_0x2718f8['query']),_0x2f701d['attributes']=_['intersection'](_0x2718f8[_0x469dd7('0x68')],qs[_0x469dd7('0xe8')](_0x24422e[_0x469dd7('0x6e')][_0x469dd7('0xe8')])),_0x2f701d[_0x469dd7('0x8a')]=_0x2f701d[_0x469dd7('0x8a')][_0x469dd7('0x6')]?_0x2f701d[_0x469dd7('0x8a')]:_0x2718f8[_0x469dd7('0x68')],typeof _0x24422e[_0x469dd7('0x6e')][_0x469dd7('0xaf')]===_0x469dd7('0xff')&&(_0x2f701d[_0x469dd7('0x10')]=qs[_0x469dd7('0x10')](_0x24422e[_0x469dd7('0x6e')][_0x469dd7('0x10')]),_0x2f701d[_0x469dd7('0xbd')]=qs[_0x469dd7('0xbd')](_0x24422e[_0x469dd7('0x6e')][_0x469dd7('0xbd')])),_0x2f701d[_0x469dd7('0xf4')]=qs[_0x469dd7('0x106')](_0x24422e[_0x469dd7('0x6e')][_0x469dd7('0x106')]),_0x2f701d[_0x469dd7('0xa0')]=qs['filters'](_[_0x469dd7('0x94')](_0x24422e[_0x469dd7('0x6e')],_0x2718f8['filters'])),_0x2f701d[_0x469dd7('0xa0')][_0x469dd7('0x72')]=_0xd73ed5['id'],_0x24422e['query']['filter']&&(_0x2f701d[_0x469dd7('0xa0')]=_['merge'](_0x2f701d[_0x469dd7('0xa0')],{[Op['or']]:_[_0x469dd7('0x77')](_0x2f701d['attributes'],function(_0x22442d){const _0x35caa7=_0x469dd7,_0x3e2d58={};return _0x3e2d58[_0x22442d]={[Op[_0x35caa7('0x74')]]:'%'+_0x24422e['query'][_0x35caa7('0x34')]+'%'},_0x3e2d58;})})),_0x2f701d=_[_0x469dd7('0x82')]({},_0x2f701d,_0x24422e[_0x469dd7('0xba')]),db[_0x469dd7('0xc8')]['count']({'where':_0x2f701d[_0x469dd7('0xa0')]})['then'](function(_0x1c5ed5){const _0x51bb6d=_0x469dd7;return _0x3f3cad[_0x51bb6d('0x39')]=_0x1c5ed5,_0x24422e[_0x51bb6d('0x6e')][_0x51bb6d('0xf1')]&&(_0x2f701d['include']=[{'all':!![]}]),db['CannedAnswer'][_0x51bb6d('0x30')](_0x2f701d);})[_0x469dd7('0x81')](function(_0x4cd5de){const _0x233906=_0x469dd7;return _0x3f3cad[_0x233906('0xa8')]=_0x4cd5de,_0x3f3cad;});})['then'](respondWithFilteredResult(_0x566472,_0x2f701d))[_0x9849bf('0xb5')](handleError(_0x566472,null));},exports[_0x5a3283('0x3e')]=function(_0xa3cfe5,_0x34163c){const _0x27944e=_0x5a3283;return db[_0x27944e('0x2c')][_0x27944e('0xf3')]({'where':{'id':_0xa3cfe5[_0x27944e('0x8')]['id']}})[_0x27944e('0x81')](handleEntityNotFound(_0x34163c,null))[_0x27944e('0x81')](function(_0x372cf3){const _0x45ba04=_0x27944e;if(_0x372cf3)return _0x372cf3['removeAnswers'](_0xa3cfe5[_0x45ba04('0x6e')][_0x45ba04('0xb6')]);})['then'](respondWithStatusCode(_0x34163c,null))[_0x27944e('0xb5')](handleError(_0x34163c,null));},exports[_0x5a3283('0xf9')]=function(_0x49da0c,_0x3c690e){const _0x1c6c6b=_0x5a3283;return _0x49da0c[_0x1c6c6b('0x9d')]['sitepic']=_0x49da0c['file'][_0x1c6c6b('0x67')],db[_0x1c6c6b('0x2c')][_0x1c6c6b('0xf3')]({'where':{'id':_0x49da0c['params']['id']}})[_0x1c6c6b('0x81')](handleEntityNotFound(_0x3c690e,null))[_0x1c6c6b('0x81')](saveUpdates(_0x49da0c[_0x1c6c6b('0x9d')],null))[_0x1c6c6b('0x81')](respondWithResult(_0x3c690e,null))['catch'](handleError(_0x3c690e,null));},exports[_0x5a3283('0x14')]=function(_0x273474,_0x3821c8){const _0x133c5c=_0x5a3283;return _0x273474[_0x133c5c('0x9d')]['agentAvatar']=_0x273474[_0x133c5c('0x98')]['filename'],db[_0x133c5c('0x2c')]['findOne']({'where':{'id':_0x273474[_0x133c5c('0x8')]['id']}})[_0x133c5c('0x81')](handleEntityNotFound(_0x3821c8,null))['then'](saveUpdates(_0x273474[_0x133c5c('0x9d')],null))[_0x133c5c('0x81')](respondWithResult(_0x3821c8,null))['catch'](handleError(_0x3821c8,null));},exports[_0x5a3283('0xb8')]=function(_0x25f89b,_0xa5cc0f){const _0x12a1c9=_0x5a3283;return _0x25f89b[_0x12a1c9('0x9d')][_0x12a1c9('0x4f')]=_0x25f89b['file'][_0x12a1c9('0x67')],db['ChatWebsite'][_0x12a1c9('0xf3')]({'where':{'id':_0x25f89b[_0x12a1c9('0x8')]['id']}})[_0x12a1c9('0x81')](handleEntityNotFound(_0xa5cc0f,null))[_0x12a1c9('0x81')](saveUpdates(_0x25f89b[_0x12a1c9('0x9d')],null))[_0x12a1c9('0x81')](respondWithResult(_0xa5cc0f,null))[_0x12a1c9('0xb5')](handleError(_0xa5cc0f,null));},exports['addSystemAvatar']=function(_0x250b9c,_0x498068){const _0x563faa=_0x5a3283;return _0x250b9c[_0x563faa('0x9d')]['systemAvatar']=_0x250b9c[_0x563faa('0x98')][_0x563faa('0x67')],db[_0x563faa('0x2c')][_0x563faa('0xf3')]({'where':{'id':_0x250b9c[_0x563faa('0x8')]['id']}})[_0x563faa('0x81')](handleEntityNotFound(_0x498068,null))[_0x563faa('0x81')](saveUpdates(_0x250b9c['body'],null))[_0x563faa('0x81')](respondWithResult(_0x498068,null))[_0x563faa('0xb5')](handleError(_0x498068,null));},exports[_0x5a3283('0xd0')]=function(_0x103735,_0x7c802d){const _0x42d7b6=_0x5a3283;let _0xb7641=path[_0x42d7b6('0x92')](config[_0x42d7b6('0x48')],_0x42d7b6('0x1d'));const _0x50bebc={'where':{'id':_0x103735[_0x42d7b6('0x8')]['id']},'attributes':['id',_0x42d7b6('0x6a')],'raw':!![]};let _0x19c324=![];return require(_0x42d7b6('0x6f'))[_0x42d7b6('0xc3')]()[_0x42d7b6('0x81')](function(_0x5b9348){const _0x2822fa=_0x42d7b6;_0x5b9348&&(_0x19c324=_0x5b9348[_0x2822fa('0xb0')]);})[_0x42d7b6('0x81')](function(){return db['ChatWebsite']['findOne'](_0x50bebc);})[_0x42d7b6('0x81')](handleEntityNotFound(_0x7c802d,null))[_0x42d7b6('0x81')](function(_0x104551){const _0x5b3e69=_0x42d7b6;if(_0x104551)return!_[_0x5b3e69('0x5')](_0x104551[_0x5b3e69('0x6a')])&&(fs['existsSync'](path[_0x5b3e69('0x92')](config['root'],_0x5b3e69('0xe1'),_0x104551['sitepic']))&&_0x19c324&&(_0xb7641=path[_0x5b3e69('0x92')](config[_0x5b3e69('0x48')],_0x5b3e69('0xe1'),_0x104551['sitepic']))),_0x7c802d[_0x5b3e69('0x40')](_0xb7641);})[_0x42d7b6('0xb5')](handleError(_0x7c802d,null));},exports['getAvatar']=function(_0x33a845,_0x11868b){const _0x1bad35=_0x5a3283;let _0x2abff8=path[_0x1bad35('0x92')](config['root'],_0x1bad35('0xfb'));const _0x405b86={'where':{'id':_0x33a845[_0x1bad35('0x8')]['id']},'attributes':['id',_0x1bad35('0x52')],'raw':!![]};return db[_0x1bad35('0x2c')][_0x1bad35('0xf3')](_0x405b86)['then'](handleEntityNotFound(_0x11868b,null))[_0x1bad35('0x81')](function(_0x2b2b71){const _0x5510af=_0x1bad35;if(_0x2b2b71)return!_['isNil'](_0x2b2b71[_0x5510af('0x52')])&&(fs['existsSync'](path[_0x5510af('0x92')](config[_0x5510af('0x48')],_0x5510af('0x3a'),_0x2b2b71[_0x5510af('0x52')]))&&(_0x2abff8=path['join'](config[_0x5510af('0x48')],_0x5510af('0x3a'),_0x2b2b71[_0x5510af('0x52')]))),_0x11868b['download'](_0x2abff8);})['catch'](handleError(_0x11868b,null));},exports[_0x5a3283('0x8b')]=function(_0x1a156c,_0x114689){const _0x824963=_0x5a3283;let _0x521e6f=path[_0x824963('0x92')](config[_0x824963('0x48')],'server/files/images/avatars/customer_avatar.png');const _0x27e0ff={'where':{'id':_0x1a156c[_0x824963('0x8')]['id']},'attributes':['id',_0x824963('0x4f'),_0x824963('0x75')],'raw':!![]};return db['ChatWebsite'][_0x824963('0xf3')](_0x27e0ff)[_0x824963('0x81')](handleEntityNotFound(_0x114689,null))[_0x824963('0x81')](function(_0xf63132){const _0x305ba9=_0x824963;if(_0xf63132)return!_['isNil'](_0xf63132[_0x305ba9('0x4f')])&&(fs[_0x305ba9('0xe5')](path[_0x305ba9('0x92')](config['root'],_0x305ba9('0x3a'),_0xf63132['customerAvatar']))&&_0xf63132[_0x305ba9('0x75')]&&(_0x521e6f=path[_0x305ba9('0x92')](config[_0x305ba9('0x48')],'server/files/images/avatars/',_0xf63132[_0x305ba9('0x4f')]))),_0x114689[_0x305ba9('0x40')](_0x521e6f);})[_0x824963('0xb5')](handleError(_0x114689,null));},exports['getSystemAvatar']=function(_0x48c07c,_0x1f6f2f){const _0x49c272=_0x5a3283;let _0x28492f=path['join'](config[_0x49c272('0x48')],_0x49c272('0xd6'));const _0x54bd34={'where':{'id':_0x48c07c[_0x49c272('0x8')]['id']},'attributes':['id',_0x49c272('0x5c')],'raw':!![]};return db[_0x49c272('0x2c')][_0x49c272('0xf3')](_0x54bd34)[_0x49c272('0x81')](handleEntityNotFound(_0x1f6f2f,null))['then'](function(_0x18c1af){const _0x5a9ae3=_0x49c272;if(_0x18c1af)return!_['isNil'](_0x18c1af[_0x5a9ae3('0x5c')])&&(fs[_0x5a9ae3('0xe5')](path[_0x5a9ae3('0x92')](config['root'],_0x5a9ae3('0x3a'),_0x18c1af['systemAvatar']))&&(_0x28492f=path['join'](config[_0x5a9ae3('0x48')],_0x5a9ae3('0x3a'),_0x18c1af[_0x5a9ae3('0x5c')]))),_0x1f6f2f[_0x5a9ae3('0x40')](_0x28492f);})['catch'](handleError(_0x1f6f2f,null));},exports[_0x5a3283('0x9f')]=function(_0x25a3b9,_0x790ec0){const _0x2a37f0=_0x5a3283,_0x174d28=require(_0x2a37f0('0xf8')),_0x25b315=new _0x174d28(),_0x3bf17c=_0x25b315[_0x2a37f0('0x79')](_0x25a3b9[_0x2a37f0('0xa7')]['user-agent'])[_0x2a37f0('0x70')](),_0x59c602={'body':_0x25a3b9[_0x2a37f0('0x9d')],'channel':_0x2a37f0('0x100')};let _0x377814=[],_0x1dfce3=[];const _0x15f666={};let _0x592bc5=![];return db[_0x2a37f0('0xc4')][_0x2a37f0('0x16')]()['then'](function(_0x4071b3){const _0x30fb5a=_0x2a37f0;if(!_0x4071b3)throw new ValidationError(_0x30fb5a('0x2f'));_0x377814=_[_0x30fb5a('0xae')](_[_0x30fb5a('0x2b')](_0x4071b3),[_0x30fb5a('0x23'),_0x30fb5a('0x1')]),_0x1dfce3=_[_0x30fb5a('0xae')](_[_0x30fb5a('0x2b')](_0x4071b3),[_0x30fb5a('0x23'),'updatedAt',_0x30fb5a('0x15'),_0x30fb5a('0xc5')]);_0x25a3b9[_0x30fb5a('0x9d')]['id']&&delete _0x25a3b9[_0x30fb5a('0x9d')]['id'];if(_[_0x30fb5a('0x5')](_0x25a3b9['body'][_0x30fb5a('0xb2')]))throw new ValidationError(_0x30fb5a('0x2e'));if(_[_0x30fb5a('0x5')](_0x25a3b9[_0x30fb5a('0x9d')][_0x30fb5a('0x9d')])||_0x25a3b9[_0x30fb5a('0x9d')]['body']==='')throw new ValidationError(_0x30fb5a('0xef'));if(_['isNil'](_0x25a3b9[_0x30fb5a('0x9d')][_0x30fb5a('0x38')]))throw new ValidationError('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x1dfce3);if(!_['includes'](_0x1dfce3,_0x25a3b9[_0x30fb5a('0x9d')]['mapKey']))throw new ValidationError(_0x30fb5a('0x7b')+_0x1dfce3);_0x15f666[_0x25a3b9[_0x30fb5a('0x9d')]['mapKey']]=_0x25a3b9[_0x30fb5a('0x9d')]['from'];})[_0x2a37f0('0x81')](function(){const _0x551823=_0x2a37f0;return db[_0x551823('0x2c')]['findOne']({'where':{'id':_0x25a3b9[_0x551823('0x8')]['id']},'include':[{'model':db[_0x551823('0xbc')],'as':'List','include':[{'model':db[_0x551823('0xc4')],'as':_0x551823('0x49'),'where':_0x15f666,'limit':0x1,'order':[['updatedAt',_0x551823('0xce')]]}]},{'model':db[_0x551823('0x0')],'as':_0x551823('0x8c')}]});})[_0x2a37f0('0x81')](handleEntityNotFound(_0x790ec0,null))[_0x2a37f0('0x81')](function(_0x101c47){const _0x1859a7=_0x2a37f0;if(_0x101c47&&_0x101c47[_0x1859a7('0x66')]){_0x59c602[_0x1859a7('0x71')]=_0x101c47,_0x59c602['applications']=_0x101c47[_0x1859a7('0x8c')],_0x59c602[_0x1859a7('0xd9')]=_0x101c47[_0x1859a7('0x66')],_0x59c602['applications']=_[_0x1859a7('0x102')](_0x59c602[_0x1859a7('0x13')],['priority'],[_0x1859a7('0x59')]);_0x59c602[_0x1859a7('0x71')][_0x1859a7('0x8c')]&&delete _0x59c602[_0x1859a7('0x71')]['Applications'];if(_0x59c602['account'][_0x1859a7('0x66')]&&_0x59c602[_0x1859a7('0x71')]['List'][_0x1859a7('0x49')]['length'])return _0x59c602[_0x1859a7('0x71')]['List'][_0x1859a7('0x49')][0x0];const _0xdfa10b=_['defaults'](_0x25a3b9[_0x1859a7('0x9d')],{'firstName':_0x25a3b9[_0x1859a7('0x9d')][_0x1859a7('0xb2')],'ListId':_0x101c47[_0x1859a7('0xc5')]});return _0xdfa10b[_0x25a3b9[_0x1859a7('0x9d')][_0x1859a7('0x38')]]=_0x25a3b9[_0x1859a7('0x9d')][_0x1859a7('0xb2')],db[_0x1859a7('0xc4')][_0x1859a7('0x18')](_0xdfa10b,{'fields':_0x377814,'raw':!![]});}})['then'](handleEntityNotFound(_0x790ec0,null))[_0x2a37f0('0x81')](function(_0x1c5d30){const _0x29cbbc=_0x2a37f0;_0x59c602[_0x29cbbc('0x4a')]=_0x1c5d30;let _0x51316f=_0x25a3b9['body'][_0x29cbbc('0x62')];if(_0x25a3b9[_0x29cbbc('0xa7')][_0x29cbbc('0x50')])_0x51316f=_0x25a3b9[_0x29cbbc('0xa7')]['cf-connecting-ip'];else _0x25a3b9[_0x29cbbc('0xa7')][_0x29cbbc('0xeb')]&&(_0x51316f=_[_0x29cbbc('0x88')](_0x25a3b9['headers'][_0x29cbbc('0xeb')]['split'](',')));if(_0x1c5d30){const _0x1a7711={'ContactId':_0x1c5d30['id'],'ChatWebsiteId':_0x25a3b9['params']['id'],'from':(_0x1c5d30[_0x29cbbc('0x37')]||'')+'\x20'+(_0x1c5d30[_0x29cbbc('0x101')]||''),'customerIp':_0x51316f,'customerPort':_0x25a3b9[_0x29cbbc('0xa7')][_0x29cbbc('0x27')]?_0x25a3b9[_0x29cbbc('0xa7')][_0x29cbbc('0x27')]:null,'referer':_0x25a3b9['body']['referer'],'browserName':_0x3bf17c[_0x29cbbc('0x4')][_0x29cbbc('0x89')]&&_0x3bf17c[_0x29cbbc('0x4')][_0x29cbbc('0xfa')]?util[_0x29cbbc('0x42')](_0x29cbbc('0xda'),_0x3bf17c[_0x29cbbc('0x4')][_0x29cbbc('0x89')],_0x3bf17c[_0x29cbbc('0x4')][_0x29cbbc('0xfa')]):_0x29cbbc('0xab'),'browserVersion':_0x3bf17c[_0x29cbbc('0x4')][_0x29cbbc('0xfa')]||_0x29cbbc('0xab'),'osName':util[_0x29cbbc('0x42')]('%s\x20%s',_0x3bf17c['os'][_0x29cbbc('0x89')],_0x3bf17c['os'][_0x29cbbc('0xfa')]),'osVersion':_0x3bf17c['os'][_0x29cbbc('0xfa')],'deviceModel':_0x3bf17c[_0x29cbbc('0xa9')][_0x29cbbc('0x68')]&&_0x3bf17c[_0x29cbbc('0xa9')][_0x29cbbc('0x83')]?util['format']('%s\x20%s\x20%s',_0x3bf17c[_0x29cbbc('0xa9')]['model'],_0x3bf17c[_0x29cbbc('0xa9')][_0x29cbbc('0x83')],_0x3bf17c[_0x29cbbc('0xa9')]['type']):null,'deviceVendor':_0x3bf17c['device'][_0x29cbbc('0x83')],'deviceType':_0x3bf17c[_0x29cbbc('0xa9')][_0x29cbbc('0xa2')],'formData':JSON[_0x29cbbc('0xf2')](_0x25a3b9[_0x29cbbc('0x9d')])},_0x55de90={'ChatWebsiteId':_0x25a3b9[_0x29cbbc('0x8')]['id'],'closed':![]};if(_0x25a3b9['body']['threadId'])return _0x55de90[_0x29cbbc('0xc')]=_0x25a3b9[_0x29cbbc('0x9d')][_0x29cbbc('0xc')],db[_0x29cbbc('0xad')][_0x29cbbc('0xf3')]({'where':_0x55de90})[_0x29cbbc('0x81')](function(_0x3af3ca){const _0x1f87ff=_0x29cbbc;if(_0x3af3ca)return[_0x3af3ca,![]];return _0x1a7711[_0x1f87ff('0xc')]=_0x25a3b9[_0x1f87ff('0x9d')][_0x1f87ff('0xc')],_0x1a7711[_0x1f87ff('0xfe')]=_0x25a3b9[_0x1f87ff('0x9d')]['externalUrl'],db['ChatInteraction']['create'](_0x1a7711)[_0x1f87ff('0x81')](function(_0x33bee8){return[_0x33bee8,!![]];});});_0x55de90[_0x29cbbc('0x41')]=_0x1c5d30['id'];if(_0x25a3b9['body'][_0x29cbbc('0x1e')]&&_0x25a3b9['body'][_0x29cbbc('0x1e')]['id'])return _0x55de90['id']=_0x25a3b9[_0x29cbbc('0x9d')][_0x29cbbc('0x1e')]['id'],db['ChatInteraction'][_0x29cbbc('0xf3')]({'where':_0x55de90})['then'](function(_0x1d7f3b){const _0x3cc3ff=_0x29cbbc;if(_0x1d7f3b)return[_0x1d7f3b,![]];return db[_0x3cc3ff('0xad')][_0x3cc3ff('0x18')](_0x1a7711)[_0x3cc3ff('0x81')](function(_0x2b2902){return[_0x2b2902,!![]];});});return db['ChatInteraction']['create'](_0x1a7711)[_0x29cbbc('0x81')](function(_0x424a6f){return[_0x424a6f,!![]];});}})[_0x2a37f0('0x81')](function([_0xfc91f3,_0x380f5b]){const _0x21a354=_0x2a37f0;if(_0xfc91f3){_0x592bc5=_0x380f5b;if(!_0x380f5b){const _0x525bda={'from':(_0x59c602[_0x21a354('0x4a')][_0x21a354('0x37')]||'')+'\x20'+(_0x59c602[_0x21a354('0x4a')][_0x21a354('0x101')]||'')};return _0x25a3b9[_0x21a354('0x9d')][_0x21a354('0xc')]&&_0x25a3b9[_0x21a354('0x9d')][_0x21a354('0x3c')]&&_0x25a3b9[_0x21a354('0x9d')][_0x21a354('0xc')]!=_0x25a3b9[_0x21a354('0x9d')][_0x21a354('0x3c')]&&(_0x525bda['threadId']=_0x25a3b9['body'][_0x21a354('0x3c')]),_0xfc91f3[_0x21a354('0xcc')](_0x525bda);}else return _0xfc91f3;}})['then'](function(_0x52dbeb){const _0x5a4edc=_0x2a37f0;return _0x59c602['interaction']=_0x52dbeb[_0x5a4edc('0x105')]({'plain':!![]}),_0x59c602['interaction'][_0x5a4edc('0xdd')]=_0x592bc5,_0x59c602['interaction'][_0x5a4edc('0xdd')]&&(_0x59c602[_0x5a4edc('0x71')][_0x5a4edc('0x6c')]&&_0x59c602[_0x5a4edc('0x13')]['push']({'id':0x0,'priority':_0x59c602[_0x5a4edc('0x13')][_0x5a4edc('0x6')]+0x1,'app':_0x5a4edc('0x3d'),'appdata':'unmanaged','interval':'*,*,*,*'})),db[_0x5a4edc('0x7')][_0x5a4edc('0x18')]({'body':_0x25a3b9[_0x5a4edc('0x9d')][_0x5a4edc('0x9d')],'ChatWebsiteId':_0x25a3b9[_0x5a4edc('0x8')]['id'],'ChatInteractionId':_0x52dbeb['id'],'direction':'in','ContactId':_0x59c602['contact']['id'],'AttachmentId':_0x25a3b9[_0x5a4edc('0x9d')][_0x5a4edc('0x51')]});})[_0x2a37f0('0x81')](function(_0x1f90dd){const _0x216dfe=_0x2a37f0;_0x59c602[_0x216dfe('0x8d')]=_0x1f90dd;if(_0x59c602[_0x216dfe('0x1e')][_0x216dfe('0xc0')])return db[_0x216dfe('0xd')][_0x216dfe('0xf3')]({'attributes':['id',_0x216dfe('0x89')],'where':{'id':_0x59c602[_0x216dfe('0x1e')]['UserId']}})['then'](function(_0x27911f){const _0x3d292d=_0x216dfe;return _0x27911f&&(_0x59c602[_0x3d292d('0x13')]['unshift']({'id':0x0,'priority':0x0,'app':_0x3d292d('0x8f'),'appdata':_0x27911f[_0x3d292d('0x89')]+','+(_0x59c602['account'][_0x3d292d('0xe')]||0xa),'interval':_0x3d292d('0xd3')}),_0x59c602[_0x3d292d('0xfd')]=!![]),respondWithRpcPromise(_0x3d292d('0x84'),_0x3d292d('0x3f'),_0x59c602);});return respondWithRpcPromise(_0x216dfe('0x84'),'startRouting',_0x59c602);})['then'](function(_0x1980a2){const _0x5e3f4c=_0x2a37f0;return respondWithRpcPromise(_0x5e3f4c('0xcd'),_0x5e3f4c('0xcd'),{'event':_0x5e3f4c('0x9f'),'message':_0x1980a2},client9002),_0x1980a2;})[_0x2a37f0('0x81')](respondWithResult(_0x790ec0,null))[_0x2a37f0('0xb5')](handleError(_0x790ec0,null));},exports[_0x5a3283('0xec')]=function(_0x7dead7,_0x3c0bfb){const _0x84bdaf=_0x5a3283;let _0x5cfbf9,_0x123fb3,_0x2081f7=[];const _0x161d8d={};return db['CmContact'][_0x84bdaf('0x16')]()[_0x84bdaf('0x81')](function(_0x45e9b8){const _0x18776a=_0x84bdaf;if(!_0x45e9b8)throw new ValidationError('no\x20available\x20attributes');_0x2081f7=_[_0x18776a('0xae')](_[_0x18776a('0x2b')](_0x45e9b8),[_0x18776a('0x23'),_0x18776a('0x1'),_0x18776a('0x15'),_0x18776a('0xc5')]);_0x7dead7[_0x18776a('0x9d')]['id']&&delete _0x7dead7[_0x18776a('0x9d')]['id'];if(_[_0x18776a('0x5')](_0x7dead7[_0x18776a('0x9d')][_0x18776a('0xb2')]))throw _0x3c0bfb[_0x18776a('0x5d')](0x1f4)[_0x18776a('0xa3')](new ValidationError('from\x20is\x20mandatory'));if(_[_0x18776a('0x5')](_0x7dead7[_0x18776a('0x9d')]['body'])||_0x7dead7['body'][_0x18776a('0x9d')]==='')throw _0x3c0bfb['status'](0x1f4)[_0x18776a('0xa3')](new ValidationError(_0x18776a('0xef')));if(_['isNil'](_0x7dead7[_0x18776a('0x9d')][_0x18776a('0x19')]))throw _0x3c0bfb[_0x18776a('0x5d')](0x1f4)['send'](new ValidationError(_0x18776a('0xe0')+_0x2081f7));if(!_[_0x18776a('0x6d')](_0x2081f7,_0x7dead7[_0x18776a('0x9d')][_0x18776a('0x19')]))throw _0x3c0bfb[_0x18776a('0x5d')](0x1f4)[_0x18776a('0xa3')](new ValidationError(_0x18776a('0xbe')+_0x2081f7));_0x161d8d[_0x7dead7['body'][_0x18776a('0x19')]]=_0x7dead7['body'][_0x18776a('0xb2')];})[_0x84bdaf('0x81')](function(){const _0x105cee=_0x84bdaf;return db[_0x105cee('0x2c')][_0x105cee('0xf3')]({'where':{'id':_0x7dead7[_0x105cee('0x8')]['id']},'include':[{'model':db[_0x105cee('0xbc')],'as':_0x105cee('0x66')}]});})[_0x84bdaf('0x81')](handleEntityNotFound(_0x3c0bfb,null))[_0x84bdaf('0x81')](function(_0x272383){const _0x4969a1=_0x84bdaf;if(_0x272383&&_0x272383['List']){_0x123fb3=_0x272383;const _0x28d167=_[_0x4969a1('0x43')](_0x7dead7[_0x4969a1('0x9d')],{'firstName':_0x7dead7[_0x4969a1('0x9d')]['from'],'phone':_0x7dead7['body'][_0x4969a1('0xb2')],'ListId':_0x272383[_0x4969a1('0xc5')]});return _0x28d167[_0x7dead7[_0x4969a1('0x9d')][_0x4969a1('0x19')]]=_0x7dead7[_0x4969a1('0x9d')][_0x4969a1('0xb2')],db['CmContact'][_0x4969a1('0x9c')]({'where':_0x161d8d,'defaults':_0x28d167});}})[_0x84bdaf('0x81')](function([_0x133c6b]){const _0x2054b7=_0x84bdaf;if(_0x133c6b){const _0x50aad6=fs[_0x2054b7('0x95')](path[_0x2054b7('0x92')](config['root'],_0x2054b7('0x35')),_0x2054b7('0x61')),_0x5210d5=ejs[_0x2054b7('0x58')](_0x50aad6,{'body':_[_0x2054b7('0x60')](_0x7dead7[_0x2054b7('0x9d')]['body']),'bodyTitle':_0x123fb3[_0x2054b7('0xb7')]});return db[_0x2054b7('0x1a')][_0x2054b7('0x18')]({'body':_0x5210d5,'ContactId':_0x133c6b['id'],'ChatWebsiteId':_0x123fb3['id']});}})['then'](function(_0x3e2001){const _0x27ca31=_0x84bdaf;if(_0x3e2001)return _0x5cfbf9=_0x3e2001,db['MailAccount'][_0x27ca31('0xf3')]({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':'Smtp','raw':!![]}]});})[_0x84bdaf('0x81')](function(_0x1318a7){const _0x34a5e6=_0x84bdaf;if(_0x1318a7&&_0x1318a7[_0x34a5e6('0xf5')]&&_0x123fb3[_0x34a5e6('0x32')]){const _0x5f573f={'tls':{'rejectUnauthorized':![]}};return _0x1318a7[_0x34a5e6('0xf5')][_0x34a5e6('0xac')]?_0x5f573f[_0x34a5e6('0xac')]=_0x1318a7[_0x34a5e6('0xf5')][_0x34a5e6('0xac')]:(_0x5f573f[_0x34a5e6('0xe6')]=_0x1318a7[_0x34a5e6('0xf5')][_0x34a5e6('0xe6')],_0x5f573f['port']=_0x1318a7[_0x34a5e6('0xf5')][_0x34a5e6('0x53')],_0x5f573f['secure']=_0x1318a7[_0x34a5e6('0xf5')][_0x34a5e6('0x99')]),_0x1318a7[_0x34a5e6('0xf5')]['authentication']&&(_0x5f573f[_0x34a5e6('0x25')]={'user':_0x1318a7[_0x34a5e6('0xf5')][_0x34a5e6('0xaa')],'pass':_0x1318a7[_0x34a5e6('0xf5')][_0x34a5e6('0x1c')]}),respondWithRpcPromise(_0x34a5e6('0xf'),'sendMail',{'account':_0x5f573f,'message':{'from':util[_0x34a5e6('0x42')](_0x34a5e6('0x47'),_0x1318a7['name'],_0x1318a7[_0x34a5e6('0xc9')]||_0x1318a7[_0x34a5e6('0xf5')][_0x34a5e6('0xaa')]),'to':_0x123fb3['forwardOfflineAddress'],'subject':_0x123fb3[_0x34a5e6('0xe2')],'text':_0x5cfbf9['body']}},client9003)[_0x34a5e6('0x81')](function(){return _0x5cfbf9;})[_0x34a5e6('0xb5')](function(_0xbe3001){console['error'](_0xbe3001);});}})[_0x84bdaf('0x81')](function(){if(_0x5cfbf9)return _0x5cfbf9;})[_0x84bdaf('0x81')](respondWithResult(_0x3c0bfb,null))[_0x84bdaf('0xb5')](handleError(_0x3c0bfb,null));},exports['addInteraction']=function(_0x486a82,_0x51a603){const _0x3a0320=_0x5a3283;return db[_0x3a0320('0xad')][_0x3a0320('0xf3')]({'where':{'id':_0x486a82['params']['id']}})['then'](function(_0x2656b0){const _0x586ba4=_0x3a0320;if(_0x2656b0)return _0x2656b0[_0x586ba4('0xdf')](_0x486a82[_0x586ba4('0x9d')]['ids'],{'through':_[_0x586ba4('0xc1')](_0x486a82[_0x586ba4('0x9d')],[_0x586ba4('0xb6'),'id'])});})[_0x3a0320('0x81')](respondWithResult(_0x51a603,null))['catch'](handleError(_0x51a603,null));},exports[_0x5a3283('0xa')]=function(_0x545cfa,_0x8d9b92){const _0x62b696=_0x5a3283;let _0x504118={'raw':![],'where':{}};const _0x224fd4={},_0x4210be={'count':0x0,'rows':[]};return db[_0x62b696('0x2c')]['findOne']({'where':{'id':_0x545cfa[_0x62b696('0x8')]['id']}})['then'](handleEntityNotFound(_0x8d9b92,null))[_0x62b696('0x81')](function(_0x1fb70d){const _0x1b9fd9=_0x62b696;if(_0x1fb70d)return _0x224fd4['model']=_[_0x1b9fd9('0x2b')](db[_0x1b9fd9('0xad')][_0x1b9fd9('0xde')]),_0x224fd4['query']=_['keys'](_0x545cfa[_0x1b9fd9('0x6e')]),_0x224fd4[_0x1b9fd9('0xf6')]=_[_0x1b9fd9('0x73')](_0x224fd4[_0x1b9fd9('0x68')],_0x224fd4['query']),_0x504118[_0x1b9fd9('0x8a')]=_[_0x1b9fd9('0x73')](_0x224fd4[_0x1b9fd9('0x68')],qs[_0x1b9fd9('0xe8')](_0x545cfa['query']['fields'])),_0x504118[_0x1b9fd9('0x8a')]=_0x504118[_0x1b9fd9('0x8a')][_0x1b9fd9('0x6')]?_0x504118['attributes']:_0x224fd4[_0x1b9fd9('0x68')],typeof _0x545cfa[_0x1b9fd9('0x6e')]['nolimit']==='undefined'&&(_0x504118[_0x1b9fd9('0x10')]=qs[_0x1b9fd9('0x10')](_0x545cfa[_0x1b9fd9('0x6e')]['limit']),_0x504118[_0x1b9fd9('0xbd')]=qs[_0x1b9fd9('0xbd')](_0x545cfa[_0x1b9fd9('0x6e')][_0x1b9fd9('0xbd')])),_0x504118['order']=qs['sort'](_0x545cfa['query'][_0x1b9fd9('0x106')]),_0x504118['where']=qs[_0x1b9fd9('0xf6')](_[_0x1b9fd9('0x94')](_0x545cfa['query'],_0x224fd4['filters'])),_0x504118[_0x1b9fd9('0xa0')][_0x1b9fd9('0x72')]=_0x1fb70d['id'],_0x545cfa[_0x1b9fd9('0x6e')][_0x1b9fd9('0x34')]&&(_0x504118[_0x1b9fd9('0xa0')]=_[_0x1b9fd9('0x82')](_0x504118[_0x1b9fd9('0xa0')],{[Op['or']]:_[_0x1b9fd9('0x77')](_0x504118[_0x1b9fd9('0x8a')],function(_0x3b14f1){const _0x3ff4d1=_0x1b9fd9,_0x3b1395={};return _0x3b1395[_0x3b14f1]={[Op[_0x3ff4d1('0x74')]]:'%'+_0x545cfa[_0x3ff4d1('0x6e')][_0x3ff4d1('0x34')]+'%'},_0x3b1395;})})),_0x504118=_['merge']({},_0x504118,_0x545cfa[_0x1b9fd9('0xba')]),db[_0x1b9fd9('0xad')][_0x1b9fd9('0x39')]({'where':_0x504118[_0x1b9fd9('0xa0')]})[_0x1b9fd9('0x81')](function(_0x555293){const _0x5f5065=_0x1b9fd9;return _0x4210be[_0x5f5065('0x39')]=_0x555293,_0x545cfa['query'][_0x5f5065('0xf1')]&&(_0x504118[_0x5f5065('0x80')]=[{'model':db[_0x5f5065('0xc4')],'as':'Contact','required':![]},{'model':db[_0x5f5065('0xd')],'as':_0x5f5065('0xcf'),'attributes':[_0x5f5065('0x89'),_0x5f5065('0x5f'),'internal'],'required':![]},{'model':db[_0x5f5065('0x3')],'as':_0x5f5065('0xe9'),'attributes':['id',_0x5f5065('0x89'),_0x5f5065('0x22')],'where':_0x545cfa['query'][_0x5f5065('0x3b')]?{'id':_0x545cfa[_0x5f5065('0x6e')][_0x5f5065('0x3b')]}:undefined,'required':_0x545cfa[_0x5f5065('0x6e')][_0x5f5065('0x3b')]?!![]:![]}]),db[_0x5f5065('0xad')]['findAll'](_0x504118);})[_0x1b9fd9('0x81')](function(_0x20c855){return _0x4210be['rows']=_0x20c855,_0x4210be;});})[_0x62b696('0x81')](respondWithFilteredResult(_0x8d9b92,_0x504118))[_0x62b696('0xb5')](handleError(_0x8d9b92,null));};function iftimePromise(_0x1981c1,_0x311283){const _0x4bb113=_0x5a3283;return respondWithRpcPromise(_0x4bb113('0xa5'),_0x4bb113('0x85'),{'command':_0x311283[_0x4bb113('0x11')]?util[_0x4bb113('0x42')]('iftime\x20%s,%s',_0x1981c1[_0x4bb113('0xd8')],_0x311283[_0x4bb113('0x11')]):util['format'](_0x4bb113('0xf0'),_0x1981c1[_0x4bb113('0xd8')])},client9002)[_0x4bb113('0x81')](function(_0x590663){const _0x3af0f3=_0x4bb113,_0x3bef5e=_0x590663&&_0x590663['indexOf'](_0x3af0f3('0x97'))>=0x0?!![]:![];return logger[_0x3af0f3('0x9')](_0x3af0f3('0xf7'),_0x311283['id'],_0x1981c1['id'],_0x1981c1[_0x3af0f3('0xd8')],_0x3bef5e?_0x3af0f3('0xcb'):_0x3af0f3('0x5a'),_0x311283[_0x3af0f3('0x11')]?_0x311283[_0x3af0f3('0x11')]:_0x3af0f3('0x6b')),_0x3bef5e;})[_0x4bb113('0xb5')](function(_0x52dab3){const _0x4c1003=_0x4bb113;return logger[_0x4c1003('0xdc')](_0x4c1003('0xf7'),_0x311283['id'],_0x1981c1['id'],_0x1981c1[_0x4c1003('0xd8')],util[_0x4c1003('0x28')](_0x52dab3,{'showHidden':![],'depth':null}),_0x311283[_0x4c1003('0x11')]?_0x311283[_0x4c1003('0x11')]:_0x4c1003('0x6b')),![];});}exports[_0x5a3283('0x85')]=function(_0x159ced,_0x2b0a76){const _0x49723f=_0x5a3283;let _0x2955d1=0x0,_0x2c005a=0x0,_0x313d9e=![],_0x186d58,_0x4eddbd;return db['ChatWebsite'][_0x49723f('0xf3')]({'where':{'id':_0x159ced['params']['id']},'include':[{'model':db['Interval'],'as':_0x49723f('0xd5'),'include':[{'model':db[_0x49723f('0xd5')],'as':_0x49723f('0x1f'),'attributes':['id',_0x49723f('0xd8')],'raw':!![]}]}]})[_0x49723f('0x81')](handleEntityNotFound(_0x2b0a76,null))[_0x49723f('0x81')](function(_0x53794b){if(_0x53794b)return _0x186d58=_0x53794b,_0x53794b['getProactiveActions']({'raw':!![]});})[_0x49723f('0x81')](function(_0x2106d5){const _0x4cea7b=_0x49723f;return _0x186d58&&(_0x2106d5&&(_0x4eddbd=_0x2106d5)),require('../../config/license/util')[_0x4cea7b('0xc3')]();})[_0x49723f('0x81')](function(_0x44465f){const _0x481863=_0x49723f;_0x44465f&&(_0x2c005a=_0x44465f['virtual'],_0x313d9e=_0x44465f[_0x481863('0xb0')]);})[_0x49723f('0x81')](function(){const _0x4a61d0=_0x49723f;return db[_0x4a61d0('0xad')][_0x4a61d0('0x39')]({'where':{'closed':![]}});})[_0x49723f('0x81')](function(_0x527a56){const _0x371359=_0x49723f;_0x2955d1=_0x527a56;if(_0x2c005a&&_0x527a56>_0x2c005a)return db[_0x371359('0xca')][_0x371359('0xf3')]({'where':{'id':0x1}})[_0x371359('0x81')](function(_0x1c142e){const _0xa0f567=_0x371359;_0x1c142e&&_0x1c142e['increment'](_0xa0f567('0xc2'));});})['then'](function(){const _0x553e52=_0x49723f;if(_0x186d58[_0x553e52('0xd5')]&&_0x186d58[_0x553e52('0xd5')]['Intervals']){const _0x45f56b=[];for(let _0x5d54f4=0x0;_0x5d54f4<_0x186d58[_0x553e52('0xd5')][_0x553e52('0x1f')]['length'];_0x5d54f4++){const _0x4fdf30=_0x186d58[_0x553e52('0xd5')][_0x553e52('0x1f')][_0x5d54f4]['get']({'plain':!![]});_0x45f56b[_0x553e52('0x7f')](iftimePromise(_0x4fdf30,_0x186d58));}return Promise['all'](_0x45f56b)[_0x553e52('0x81')](function(_0x51144a){const _0x2073a7=_0x553e52;return _[_0x2073a7('0x12')](_0x51144a);});}else return!![];})[_0x49723f('0x81')](function(_0x17aa2a){const _0x59da17=_0x49723f,_0x3d9a7d=_0x159ced[_0x59da17('0x2d')][_0x59da17('0x105')]('chatVersion'),_0x2db846=fs[_0x59da17('0x95')](path[_0x59da17('0x92')](config['root'],_0x59da17('0x44')),_0x59da17('0x61')),_0x1a7271={'chatVersion':_0x3d9a7d,'remote':_0x186d58[_0x59da17('0x69')],'query':querystring[_0x59da17('0xf2')](_[_0x59da17('0x82')](_0x186d58[_0x59da17('0x105')]({'plain':!![]}),{'customerIp':_0x159ced[_0x59da17('0xa7')]['x-forwarded-for']||_0x159ced['headers'][_0x59da17('0x78')]||_0x159ced[_0x59da17('0x4e')]['remoteAddress']||_0x159ced['ip'],'referer':_0x159ced['headers']['referer'],'openedInteractions':_0x2955d1,'maxInteractions':_0x2c005a,'virtual':_0x313d9e[_0x59da17('0x4b')],'online':_0x17aa2a,'custom':_0x313d9e}))[_0x59da17('0x5e')](/'/g,'\x5c\x27')};_0x2b0a76[_0x59da17('0xa3')](ejs[_0x59da17('0x58')](Mustache[_0x59da17('0x58')](_0x2db846,_0x1a7271),{'proactiveActions':_0x4eddbd,'alignment':_0x186d58[_0x59da17('0x65')],'verticalAlignment':_0x186d58['verticalAlignment'],'div_color':_0x186d58[_0x59da17('0x22')],'text_color':_0x186d58['textColor']}));})[_0x49723f('0xb5')](handleError(_0x2b0a76,null));},exports['addApplications']=function(_0x5237c1,_0x165436){const _0x512d89=_0x5a3283;return db[_0x512d89('0x2c')][_0x512d89('0xf3')]({'where':{'id':_0x5237c1['params']['id']}})[_0x512d89('0x81')](handleEntityNotFound(_0x165436,null))['then'](function(_0x4b17ba){const _0x506b45=_0x512d89;if(_0x4b17ba)return db['sequelize'][_0x506b45('0xea')](function(_0x17001a){const _0x372d3b=_0x506b45;return db['ChatApplication'][_0x372d3b('0xd2')]({'where':{'ChatWebsiteId':_0x5237c1[_0x372d3b('0x8')]['id']},'transaction':_0x17001a})[_0x372d3b('0x81')](function(){const _0x104df4=_0x372d3b,_0x4fff14=_[_0x104df4('0x77')](_0x5237c1[_0x104df4('0x9d')],function(_0x1ec6b2){const _0x2ce539=_0x104df4;return _0x1ec6b2['ChatWebsiteId']=_0x5237c1[_0x2ce539('0x8')]['id'],_0x1ec6b2;});return db['ChatApplication'][_0x104df4('0x4d')](_0x4fff14,{'transaction':_0x17001a});});})[_0x506b45('0x81')](function(){const _0x40cab4=_0x506b45;return db[_0x40cab4('0x0')][_0x40cab4('0x93')]({'where':{'ChatWebsiteId':_0x5237c1[_0x40cab4('0x8')]['id']},'order':_0x40cab4('0x45')});});})[_0x512d89('0x81')](respondWithResult(_0x165436,null))['catch'](handleError(_0x165436,null));},exports['getApplications']=function(_0x30ba48,_0x37344a){const _0x12218a=_0x5a3283;let _0x26233c={};const _0x58601f={};let _0x2f5de7,_0x5747fb;return db['ChatWebsite'][_0x12218a('0xf3')]({'where':{'id':_0x30ba48[_0x12218a('0x8')]['id']}})[_0x12218a('0x81')](handleEntityNotFound(_0x37344a,null))['then'](function(_0x44e8c8){const _0x2f38b7=_0x12218a;if(_0x44e8c8)return _0x2f5de7=_0x44e8c8,_0x58601f[_0x2f38b7('0x68')]=_['keys'](db[_0x2f38b7('0x0')][_0x2f38b7('0xde')]),_0x58601f[_0x2f38b7('0x6e')]=_['keys'](_0x30ba48['query']),_0x58601f['filters']=_[_0x2f38b7('0x73')](_0x58601f[_0x2f38b7('0x68')],_0x58601f[_0x2f38b7('0x6e')]),_0x26233c['attributes']=_[_0x2f38b7('0x73')](_0x58601f['model'],qs[_0x2f38b7('0xe8')](_0x30ba48['query']['fields'])),_0x26233c[_0x2f38b7('0x8a')]=_0x26233c[_0x2f38b7('0x8a')][_0x2f38b7('0x6')]?_0x26233c[_0x2f38b7('0x8a')]:_0x58601f[_0x2f38b7('0x68')],_0x26233c[_0x2f38b7('0xf4')]=qs['sort'](_0x30ba48[_0x2f38b7('0x6e')][_0x2f38b7('0x106')]),_0x26233c[_0x2f38b7('0xa0')]=qs[_0x2f38b7('0xf6')](_[_0x2f38b7('0x94')](_0x30ba48[_0x2f38b7('0x6e')],_0x58601f[_0x2f38b7('0xf6')])),_0x30ba48[_0x2f38b7('0x6e')][_0x2f38b7('0x34')]&&(_0x26233c[_0x2f38b7('0xa0')]=_[_0x2f38b7('0x82')](_0x26233c[_0x2f38b7('0xa0')],{[Op['or']]:_['map'](_0x26233c[_0x2f38b7('0x8a')],function(_0x168eea){const _0x45f384=_0x2f38b7,_0x362fce={};return _0x362fce[_0x168eea]={[Op[_0x45f384('0x74')]]:'%'+_0x30ba48[_0x45f384('0x6e')][_0x45f384('0x34')]+'%'},_0x362fce;})})),_0x26233c=_[_0x2f38b7('0x82')]({},_0x26233c,_0x30ba48[_0x2f38b7('0xba')]),_0x2f5de7[_0x2f38b7('0x7a')](_0x26233c);})[_0x12218a('0x81')](function(_0xf6d9c4){const _0x2cb197=_0x12218a;if(_0xf6d9c4)return _0x5747fb=_0xf6d9c4['length'],typeof _0x30ba48[_0x2cb197('0x6e')]['nolimit']===_0x2cb197('0xff')&&(_0x26233c[_0x2cb197('0x10')]=qs[_0x2cb197('0x10')](_0x30ba48[_0x2cb197('0x6e')][_0x2cb197('0x10')]),_0x26233c[_0x2cb197('0xbd')]=qs[_0x2cb197('0xbd')](_0x30ba48[_0x2cb197('0x6e')][_0x2cb197('0xbd')])),_0x2f5de7['getApplications'](_0x26233c);})[_0x12218a('0x81')](function(_0x38d06d){if(_0x38d06d)return _0x38d06d?{'count':_0x5747fb,'rows':_0x38d06d}:null;})[_0x12218a('0x81')](respondWithResult(_0x37344a,null))[_0x12218a('0xb5')](handleError(_0x37344a,null));},exports[_0x5a3283('0x54')]=function(_0x23ccd8,_0x442868){const _0x2ea596=_0x5a3283;return db[_0x2ea596('0x17')]['findOne']({'where':{'id':_0x23ccd8[_0x2ea596('0x8')]['id']}})[_0x2ea596('0x81')](function(_0x44f8e2){const _0x2edcda=_0x2ea596;if(_0x44f8e2)return _0x44f8e2[_0x2edcda('0x54')](_0x23ccd8[_0x2edcda('0x9d')]['ids'],{'through':_[_0x2edcda('0xc1')](_0x23ccd8['body'],[_0x2edcda('0xb6'),'id'])});})[_0x2ea596('0x81')](respondWithResult(_0x442868,null))['catch'](handleError(_0x442868,null));},exports[_0x5a3283('0xdb')]=function(_0x4cd3b3,_0x12318a){const _0x150b31=_0x5a3283;let _0x2d8900={};const _0x48d837={};let _0x119454,_0x28945e;return db['ChatWebsite']['findOne']({'where':{'id':_0x4cd3b3[_0x150b31('0x8')]['id']}})['then'](handleEntityNotFound(_0x12318a,null))[_0x150b31('0x81')](function(_0xf0f809){const _0x311643=_0x150b31;if(_0xf0f809)return _0x119454=_0xf0f809,_0x48d837[_0x311643('0x68')]=_[_0x311643('0x2b')](db['ChatProactiveAction'][_0x311643('0xde')]),_0x48d837[_0x311643('0x6e')]=_[_0x311643('0x2b')](_0x4cd3b3['query']),_0x48d837[_0x311643('0xf6')]=_[_0x311643('0x73')](_0x48d837['model'],_0x48d837[_0x311643('0x6e')]),_0x2d8900[_0x311643('0x8a')]=_[_0x311643('0x73')](_0x48d837['model'],qs[_0x311643('0xe8')](_0x4cd3b3['query']['fields'])),_0x2d8900[_0x311643('0x8a')]=_0x2d8900[_0x311643('0x8a')][_0x311643('0x6')]?_0x2d8900[_0x311643('0x8a')]:_0x48d837[_0x311643('0x68')],_0x2d8900[_0x311643('0xf4')]=qs[_0x311643('0x106')](_0x4cd3b3[_0x311643('0x6e')]['sort']),_0x2d8900['where']=qs[_0x311643('0xf6')](_['pick'](_0x4cd3b3['query'],_0x48d837[_0x311643('0xf6')])),_0x4cd3b3[_0x311643('0x6e')]['filter']&&(_0x2d8900[_0x311643('0xa0')]=_['merge'](_0x2d8900[_0x311643('0xa0')],{[Op['or']]:_[_0x311643('0x77')](_0x2d8900[_0x311643('0x8a')],function(_0x1faa7a){const _0x341298=_0x311643,_0x17e4df={};return _0x17e4df[_0x1faa7a]={[Op[_0x341298('0x74')]]:'%'+_0x4cd3b3[_0x341298('0x6e')][_0x341298('0x34')]+'%'},_0x17e4df;})})),_0x2d8900=_[_0x311643('0x82')]({},_0x2d8900,_0x4cd3b3[_0x311643('0xba')]),_0x119454['getProactiveActions'](_0x2d8900);})[_0x150b31('0x81')](function(_0x54e71f){const _0x3699a8=_0x150b31;if(_0x54e71f)return _0x28945e=_0x54e71f[_0x3699a8('0x6')],typeof _0x4cd3b3[_0x3699a8('0x6e')][_0x3699a8('0xaf')]===_0x3699a8('0xff')&&(_0x2d8900[_0x3699a8('0x10')]=qs[_0x3699a8('0x10')](_0x4cd3b3[_0x3699a8('0x6e')][_0x3699a8('0x10')]),_0x2d8900[_0x3699a8('0xbd')]=qs[_0x3699a8('0xbd')](_0x4cd3b3[_0x3699a8('0x6e')][_0x3699a8('0xbd')])),_0x119454[_0x3699a8('0xdb')](_0x2d8900);})[_0x150b31('0x81')](function(_0xe5e5d4){if(_0xe5e5d4)return _0xe5e5d4?{'count':_0x28945e,'rows':_0xe5e5d4}:null;})[_0x150b31('0x81')](respondWithResult(_0x12318a,null))['catch'](handleError(_0x12318a,null));},exports['getFields']=function(_0x347f4d,_0x415185){const _0x3e3b22=_0x5a3283,_0x119180=_0x347f4d[_0x3e3b22('0x6e')][_0x3e3b22('0x31')]==='false'?_0x3e3b22('0x7c'):_0x3e3b22('0xbb');return db[_0x3e3b22('0x2c')][_0x3e3b22('0xf3')]({'attributes':['id',_0x119180],'where':{'id':_0x347f4d[_0x3e3b22('0x8')]['id']}})[_0x3e3b22('0x81')](handleEntityNotFound(_0x415185,null))[_0x3e3b22('0x81')](function(_0x2902f0){const _0x7fd2dd=_0x3e3b22;if(_0x2902f0){const _0x2877d4=_0x2902f0[_0x119180],_0x568c17=_0x2877d4&&_0x2877d4[_0x7fd2dd('0xb1')]?_0x2877d4[_0x7fd2dd('0xb1')]:[];_0x415185[_0x7fd2dd('0xa3')]({'fromKey':_[_0x7fd2dd('0x5')](_0x2877d4[_0x7fd2dd('0xb')])?undefined:_0x2877d4[_0x7fd2dd('0xb')],'count':_0x568c17[_0x7fd2dd('0x6')],'rows':_0x568c17});}})[_0x3e3b22('0xb5')](handleError(_0x415185,null));},exports[_0x5a3283('0xe7')]=function(_0x2b8a19,_0x54a608){const _0x385d5d=_0x5a3283;let _0x486436={'raw':![],'where':{}};const _0x14a692={},_0x373e65={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x385d5d('0xf3')]({'where':{'id':_0x2b8a19['params']['id']}})[_0x385d5d('0x81')](handleEntityNotFound(_0x54a608,null))[_0x385d5d('0x81')](function(_0x4742d8){const _0xbd0ada=_0x385d5d;if(_0x4742d8)return _0x14a692['model']=_[_0xbd0ada('0x2b')](db[_0xbd0ada('0x1a')][_0xbd0ada('0xde')]),_0x14a692['query']=_[_0xbd0ada('0x2b')](_0x2b8a19[_0xbd0ada('0x6e')]),_0x14a692[_0xbd0ada('0xf6')]=_[_0xbd0ada('0x73')](_0x14a692['model'],_0x14a692[_0xbd0ada('0x6e')]),_0x486436[_0xbd0ada('0x8a')]=_[_0xbd0ada('0x73')](_0x14a692[_0xbd0ada('0x68')],qs[_0xbd0ada('0xe8')](_0x2b8a19[_0xbd0ada('0x6e')]['fields'])),_0x486436[_0xbd0ada('0x8a')]=_0x486436[_0xbd0ada('0x8a')][_0xbd0ada('0x6')]?_0x486436[_0xbd0ada('0x8a')]:_0x14a692['model'],typeof _0x2b8a19[_0xbd0ada('0x6e')][_0xbd0ada('0xaf')]===_0xbd0ada('0xff')&&(_0x486436[_0xbd0ada('0x10')]=qs[_0xbd0ada('0x10')](_0x2b8a19['query'][_0xbd0ada('0x10')]),_0x486436['offset']=qs[_0xbd0ada('0xbd')](_0x2b8a19[_0xbd0ada('0x6e')][_0xbd0ada('0xbd')])),_0x486436[_0xbd0ada('0xf4')]=qs[_0xbd0ada('0x106')](_0x2b8a19['query'][_0xbd0ada('0x106')]),_0x486436['where']=qs['filters'](_['pick'](_0x2b8a19[_0xbd0ada('0x6e')],_0x14a692[_0xbd0ada('0xf6')])),_0x486436[_0xbd0ada('0xa0')][_0xbd0ada('0x72')]=_0x4742d8['id'],_0x2b8a19[_0xbd0ada('0x6e')][_0xbd0ada('0x34')]&&(_0x486436[_0xbd0ada('0xa0')]=_[_0xbd0ada('0x82')](_0x486436[_0xbd0ada('0xa0')],{[Op['or']]:_[_0xbd0ada('0x77')](_0x486436[_0xbd0ada('0x8a')],function(_0x1e6b3c){const _0x5f3640=_0xbd0ada,_0x776813={};return _0x776813[_0x1e6b3c]={[Op['like']]:'%'+_0x2b8a19['query'][_0x5f3640('0x34')]+'%'},_0x776813;})})),_0x486436=_[_0xbd0ada('0x82')]({},_0x486436,_0x2b8a19[_0xbd0ada('0xba')]),db['ChatOfflineMessage'][_0xbd0ada('0x39')]({'where':_0x486436['where']})[_0xbd0ada('0x81')](function(_0x1baa1d){const _0x4f75d7=_0xbd0ada;return _0x373e65[_0x4f75d7('0x39')]=_0x1baa1d,_0x2b8a19[_0x4f75d7('0x6e')][_0x4f75d7('0xf1')]?_0x486436[_0x4f75d7('0x80')]=[{'all':!![]}]:_0x486436['include']=[{'model':db[_0x4f75d7('0xc4')],'as':_0x4f75d7('0x96'),'required':![]}],db[_0x4f75d7('0x1a')][_0x4f75d7('0x30')](_0x486436);})[_0xbd0ada('0x81')](function(_0x13a4d3){const _0x379446=_0xbd0ada;return _0x373e65[_0x379446('0xa8')]=_0x13a4d3,_0x373e65;});})[_0x385d5d('0x81')](respondWithFilteredResult(_0x54a608,_0x486436))['catch'](handleError(_0x54a608,null));},exports[_0x5a3283('0x55')]=function(_0x197f93,_0x218ba2){const _0x2ae448=_0x5a3283;return db[_0x2ae448('0x2c')][_0x2ae448('0xf3')]({'where':{'id':_0x197f93[_0x2ae448('0x8')]['id']}})['then'](function(_0x4dac91){const _0x22801b=_0x2ae448;if(_0x4dac91)return _0x4dac91[_0x22801b('0x55')](_0x197f93['body'][_0x22801b('0xb6')],{'through':_[_0x22801b('0xc1')](_0x197f93[_0x22801b('0x9d')],[_0x22801b('0xb6'),'id'])})[_0x22801b('0x81')](function(_0x39cca8){const _0x561cb9=_0x22801b;for(let _0xd08a7d=0x0;_0xd08a7d<_0x197f93['body'][_0x561cb9('0xb6')]['length'];_0xd08a7d+=0x1){socket[_0x561cb9('0xd7')](_0x561cb9('0x8e'),{'UserId':_0x197f93['body'][_0x561cb9('0xb6')][_0xd08a7d],'ChatWebsiteId':_0x197f93['params']['id']});}return _0x39cca8;});})['then'](respondWithResult(_0x218ba2,null))['catch'](handleError(_0x218ba2,null));},exports[_0x5a3283('0x21')]=function(_0x9b71cf,_0x3fb4cb){const _0x610813=_0x5a3283;return db[_0x610813('0x2c')][_0x610813('0xf3')]({'where':{'id':_0x9b71cf[_0x610813('0x8')]['id']}})[_0x610813('0x81')](handleEntityNotFound(_0x3fb4cb,null))[_0x610813('0x81')](function(_0x282167){const _0x8eeb4d=_0x610813;if(_0x282167)return _0x282167[_0x8eeb4d('0x21')](_0x9b71cf['query'][_0x8eeb4d('0xb6')])['then'](function(){const _0x45bb7e=_0x8eeb4d;if(_[_0x45bb7e('0x56')](_0x9b71cf[_0x45bb7e('0x6e')][_0x45bb7e('0xb6')]))for(let _0x4356b3=0x0;_0x4356b3<_0x9b71cf[_0x45bb7e('0x6e')][_0x45bb7e('0xb6')]['length'];_0x4356b3+=0x1){socket[_0x45bb7e('0xd7')](_0x45bb7e('0x26'),{'UserId':Number(_0x9b71cf['query'][_0x45bb7e('0xb6')][_0x4356b3]),'ChatWebsiteId':Number(_0x9b71cf[_0x45bb7e('0x8')]['id'])});}else socket['emit']('userChatWebsite:remove',{'UserId':Number(_0x9b71cf[_0x45bb7e('0x6e')][_0x45bb7e('0xb6')]),'ChatWebsiteId':Number(_0x9b71cf[_0x45bb7e('0x8')]['id'])});});})['then'](respondWithStatusCode(_0x3fb4cb,null))[_0x610813('0xb5')](handleError(_0x3fb4cb,null));},exports[_0x5a3283('0xe4')]=function(_0x5199b8,_0x594ffd){const _0x2c1ac5=_0x5a3283;let _0x42dcca={};const _0x3535f5={};let _0x2deac2,_0x5aced9;return db[_0x2c1ac5('0x2c')]['findOne']({'where':{'id':_0x5199b8[_0x2c1ac5('0x8')]['id']}})[_0x2c1ac5('0x81')](handleEntityNotFound(_0x594ffd,null))[_0x2c1ac5('0x81')](function(_0x4e022b){const _0x4f18a7=_0x2c1ac5;if(_0x4e022b)return _0x2deac2=_0x4e022b,_0x3535f5[_0x4f18a7('0x68')]=_[_0x4f18a7('0x2b')](db[_0x4f18a7('0xd')][_0x4f18a7('0xde')]),_0x3535f5[_0x4f18a7('0x6e')]=_[_0x4f18a7('0x2b')](_0x5199b8[_0x4f18a7('0x6e')]),_0x3535f5[_0x4f18a7('0xf6')]=_[_0x4f18a7('0x73')](_0x3535f5[_0x4f18a7('0x68')],_0x3535f5[_0x4f18a7('0x6e')]),_0x42dcca[_0x4f18a7('0x8a')]=_[_0x4f18a7('0x73')](_0x3535f5[_0x4f18a7('0x68')],qs[_0x4f18a7('0xe8')](_0x5199b8[_0x4f18a7('0x6e')][_0x4f18a7('0xe8')])),_0x42dcca[_0x4f18a7('0x8a')]=_0x42dcca[_0x4f18a7('0x8a')]['length']?_0x42dcca[_0x4f18a7('0x8a')]:_0x3535f5['model'],_0x42dcca[_0x4f18a7('0xf4')]=qs['sort'](_0x5199b8[_0x4f18a7('0x6e')][_0x4f18a7('0x106')]),_0x42dcca[_0x4f18a7('0xa0')]=qs[_0x4f18a7('0xf6')](_[_0x4f18a7('0x94')](_0x5199b8[_0x4f18a7('0x6e')],_0x3535f5['filters'])),_0x5199b8[_0x4f18a7('0x6e')][_0x4f18a7('0x34')]&&(_0x42dcca[_0x4f18a7('0xa0')]=_[_0x4f18a7('0x82')](_0x42dcca[_0x4f18a7('0xa0')],{[Op['or']]:_[_0x4f18a7('0x77')](_0x42dcca[_0x4f18a7('0x8a')],function(_0x3bf1a3){const _0x5978d4=_0x4f18a7,_0xf0d76a={};return _0xf0d76a[_0x3bf1a3]={[Op[_0x5978d4('0x74')]]:'%'+_0x5199b8['query'][_0x5978d4('0x34')]+'%'},_0xf0d76a;})})),_0x42dcca=_[_0x4f18a7('0x82')]({},_0x42dcca,_0x5199b8['options']),_0x2deac2[_0x4f18a7('0xe4')](_0x42dcca);})['then'](function(_0x21c5cd){const _0x3dad8f=_0x2c1ac5;if(_0x21c5cd)return _0x5aced9=_0x21c5cd[_0x3dad8f('0x6')],typeof _0x5199b8['query'][_0x3dad8f('0xaf')]===_0x3dad8f('0xff')&&(_0x42dcca[_0x3dad8f('0x10')]=qs[_0x3dad8f('0x10')](_0x5199b8[_0x3dad8f('0x6e')][_0x3dad8f('0x10')]),_0x42dcca[_0x3dad8f('0xbd')]=qs[_0x3dad8f('0xbd')](_0x5199b8[_0x3dad8f('0x6e')]['offset'])),_0x2deac2[_0x3dad8f('0xe4')](_0x42dcca);})[_0x2c1ac5('0x81')](function(_0x64c493){if(_0x64c493)return _0x64c493?{'count':_0x5aced9,'rows':_0x64c493}:null;})[_0x2c1ac5('0x81')](respondWithResult(_0x594ffd,null))['catch'](handleError(_0x594ffd,null));};