Built motion from commit b517aaa2a6638133380e4d135c64a80893061362. Version 3.0.0...
[motion-next.git] / server / api / openchannelAccount / openchannelAccount.controller.js
index e0f7633..a55fbfe 100644 (file)
@@ -1 +1 @@
-const a468_0x1c50=['user','isArray','merge','from','code','from\x20is\x20mandatory','then','params','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','mapKey','filter','forcedOwnership','sequelize','like','result','Contacts','catch','ids','set','CannedAnswer','UserProfileResource','where','Applications','attributes','keys','created','removeAgents','findAll','ValidationError','emit','rows','request\x20sent','count','createdAt','getAgents','include','omit','lastName','status','lodash','unshift','map','info','key','removeDispositions','../../rediscache','role','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','addDisposition','CmList','json','filters','startRouting','transaction','destroy','firstName','OpenchannelAccount','get','send','name','debug','externalUrl','updatedAt','fields','includes','body','body\x20is\x20mandatory\x20and\x20not\x20empty','openchannel','request','Pause','color','applications','sort','model','stringify','OpenchannelAccounts','messageId','notify','userProfileId','OpenchannelAccount,\x20%s,\x20%s','limit','OpenchannelAccountId','defaults','DESC','fieldName','describe','interaction','Tags','error','difference','account','client','message','end','Content-Range','List','create','fullname','Owner','../../config/logger','push','undefined','*,*,*,*','userOpenchannelAccount:remove','addAgents','isNil','CompanyId','offset','priority','query','OpenchannelMessage','threadId','type','getAnswers','options','removeAnswers','intersection','Sequelize','contact','length','Disposition','order','findOne','autoAssociation','dataValues','jayson/promise','orderBy','OpenchannelInteraction','http','ListId','sendStatus','update','CmContact','autoclose','stack','includeAll','getApplications','addApplications','findAndCountAll','show','OpenchannelApplication','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','User','nolimit','rawAttributes','waitForTheAssignedAgent','unmanaged','Start','EventManager','out','pick','mandatoryDispositionPause','Messages'];(function(_0x2d40ba,_0x1c5010){const _0x1581aa=function(_0x46c317){while(--_0x46c317){_0x2d40ba['push'](_0x2d40ba['shift']());}};_0x1581aa(++_0x1c5010);}(a468_0x1c50,0x1b4));const a468_0x1581=function(_0x2d40ba,_0x1c5010){_0x2d40ba=_0x2d40ba-0x0;let _0x1581aa=a468_0x1c50[_0x2d40ba];return _0x1581aa;};const _0x41bf55=a468_0x1581;'use strict';const _=require(_0x41bf55('0x3e')),qs=require('../../components/parsers/qs'),logger=require(_0x41bf55('0x7a'))('api'),{getSocket}=require(_0x41bf55('0x44')),socket=getSocket(),db=require('../../mysqldb')['db'],{Op}=require('sequelize');require('./openchannelAccount.socket')['register'](socket);const jayson=require(_0x41bf55('0x94')),client=jayson[_0x41bf55('0x72')][_0x41bf55('0x97')]({'port':0x232c}),client9002=jayson[_0x41bf55('0x72')][_0x41bf55('0x97')]({'port':0x232a});function respondWithRpcPromise(_0x46c317,_0x1518b0,_0x259bff,_0xc3776b){return new Promise(function(_0x33ae2e,_0x8ca04a){const _0x25c890=a468_0x1581,_0x2b9044=_0xc3776b||client;return _0x2b9044[_0x25c890('0x5b')](_0x46c317,_0x259bff)[_0x25c890('0x1d')](function(_0x3fa2a6){const _0x23e687=_0x25c890;logger[_0x23e687('0x41')](_0x23e687('0x66'),_0x1518b0,_0x23e687('0x36')),logger[_0x23e687('0x53')]('OpenchannelAccount,\x20%s,\x20%s,\x20%s',_0x1518b0,_0x23e687('0x36'),JSON[_0x23e687('0x61')](_0x3fa2a6));if(_0x3fa2a6[_0x23e687('0x6f')]){if(_0x3fa2a6['error'][_0x23e687('0x1b')]===0x1f4)return logger['error'](_0x23e687('0x66'),_0x1518b0,_0x3fa2a6['error'][_0x23e687('0x73')]),_0x8ca04a(_0x3fa2a6['error'][_0x23e687('0x73')]);return logger[_0x23e687('0x6f')]('OpenchannelAccount,\x20%s,\x20%s',_0x1518b0,_0x3fa2a6['error'][_0x23e687('0x73')]),_0x33ae2e(_0x3fa2a6[_0x23e687('0x6f')][_0x23e687('0x73')]);}else logger[_0x23e687('0x41')](_0x23e687('0x66'),_0x1518b0,_0x23e687('0x36')),_0x33ae2e(_0x3fa2a6[_0x23e687('0x25')][_0x23e687('0x73')]);})[_0x25c890('0x27')](function(_0x1c05aa){const _0x45cd99=_0x25c890;logger[_0x45cd99('0x6f')](_0x45cd99('0x66'),_0x1518b0,_0x1c05aa),_0x8ca04a(_0x1c05aa);});});}function respondWithStatusCode(_0x28e726,_0x2f8525){return _0x2f8525=_0x2f8525||0xcc,function(_0x1be187){const _0x503384=a468_0x1581;if(_0x1be187)return _0x28e726[_0x503384('0x0')](_0x2f8525);return _0x28e726[_0x503384('0x3d')](_0x2f8525)[_0x503384('0x74')]();};}function respondWithResult(_0x433bad,_0x55a471){return _0x55a471=_0x55a471||0xc8,function(_0x1a4e8a){const _0x405d46=a468_0x1581;if(_0x1a4e8a)return _0x433bad['status'](_0x55a471)[_0x405d46('0x49')](_0x1a4e8a);};}function respondWithFilteredResult(_0x3624eb,_0x364c29){return function(_0x4682c7){const _0xe1e1af=a468_0x1581;if(_0x4682c7){const _0xbab0d=_0x4682c7[_0xe1e1af('0x37')],_0x5e352c=_0x364c29['offset'];let _0xdb56da=_0x364c29[_0xe1e1af('0x82')]+_0x364c29['limit'],_0x1f661f;return _0xdb56da>=_0xbab0d?(_0xdb56da=_0xbab0d,_0x1f661f=0xc8):_0x1f661f=0xce,_0x3624eb[_0xe1e1af('0x3d')](_0x1f661f),_0x3624eb[_0xe1e1af('0x29')](_0xe1e1af('0x75'),_0x5e352c+'-'+_0xdb56da+'/'+_0xbab0d)[_0xe1e1af('0x49')](_0x4682c7);}return null;};}function saveUpdates(_0x359fa7){return function(_0x38b0a3){const _0x1dfa8c=a468_0x1581;if(_0x38b0a3)return _0x38b0a3[_0x1dfa8c('0x1')](_0x359fa7)[_0x1dfa8c('0x1d')](function(_0xbda237){return _0xbda237;});return null;};}function removeEntity(_0x1309c5){return function(_0x537b0e){const _0x4a2300=a468_0x1581;if(_0x537b0e)return _0x537b0e[_0x4a2300('0x4d')]()[_0x4a2300('0x1d')](function(){const _0x3e3180=_0x4a2300,_0x472254=_0x537b0e['get']({'plain':!![]}),_0xbceae7=_0x3e3180('0x62');return db[_0x3e3180('0x2b')][_0x3e3180('0x4d')]({'where':{'type':_0xbceae7,'resourceId':_0x472254['id']}})[_0x3e3180('0x1d')](function(){return _0x537b0e;});})[_0x4a2300('0x1d')](function(){const _0x5f201e=_0x4a2300;_0x1309c5[_0x5f201e('0x3d')](0xcc)[_0x5f201e('0x74')]();});};}function handleEntityNotFound(_0x21ac86){return function(_0x28c480){return!_0x28c480&&_0x21ac86['sendStatus'](0x194),_0x28c480;};}function handleError(_0x3ca866,_0x2e7dbd){return _0x2e7dbd=_0x2e7dbd||0x1f4,function(_0x2467c0){const _0x4342cb=a468_0x1581;logger['error'](_0x2467c0[_0x4342cb('0x4')]),_0x2467c0[_0x4342cb('0x52')]&&delete _0x2467c0[_0x4342cb('0x52')],_0x3ca866[_0x4342cb('0x3d')](_0x2e7dbd)[_0x4342cb('0x51')](_0x2467c0);};}exports['index']=function(_0x5850bd,_0x410789){const _0x1303b2=_0x41bf55;let _0x496158={'include':[{'model':db[_0x1303b2('0x5c')],'as':_0x1303b2('0x15')}]};const _0x330bf4={},_0x3907f7={'count':0x0,'rows':[]},_0x42e39e=_[_0x1303b2('0x40')](db['OpenchannelAccount'][_0x1303b2('0xe')],function(_0x2d5db1){const _0x4e0857=_0x1303b2;return{'name':_0x2d5db1[_0x4e0857('0x6b')],'type':_0x2d5db1[_0x4e0857('0x87')][_0x4e0857('0x42')]};});_0x330bf4['model']=_[_0x1303b2('0x40')](_0x42e39e,_0x1303b2('0x52')),_0x330bf4['query']=_[_0x1303b2('0x2f')](_0x5850bd[_0x1303b2('0x84')]),_0x330bf4[_0x1303b2('0x4a')]=_['intersection'](_0x330bf4[_0x1303b2('0x60')],_0x330bf4[_0x1303b2('0x84')]),_0x496158['attributes']=_[_0x1303b2('0x8b')](_0x330bf4[_0x1303b2('0x60')],qs['fields'](_0x5850bd[_0x1303b2('0x84')][_0x1303b2('0x56')])),_0x496158['attributes']=_0x496158[_0x1303b2('0x2e')][_0x1303b2('0x8e')]?_0x496158['attributes']:_0x330bf4[_0x1303b2('0x60')];typeof _0x5850bd[_0x1303b2('0x84')][_0x1303b2('0xd')]===_0x1303b2('0x7c')&&(_0x496158[_0x1303b2('0x67')]=qs[_0x1303b2('0x67')](_0x5850bd[_0x1303b2('0x84')][_0x1303b2('0x67')]),_0x496158[_0x1303b2('0x82')]=qs[_0x1303b2('0x82')](_0x5850bd[_0x1303b2('0x84')][_0x1303b2('0x82')]));_0x496158[_0x1303b2('0x90')]=qs[_0x1303b2('0x5f')](_0x5850bd[_0x1303b2('0x84')][_0x1303b2('0x5f')]),_0x496158['where']=qs[_0x1303b2('0x4a')](_[_0x1303b2('0x14')](_0x5850bd['query'],_0x330bf4['filters']),_0x42e39e);_0x5850bd[_0x1303b2('0x84')][_0x1303b2('0x21')]&&(_0x496158[_0x1303b2('0x2c')]=_[_0x1303b2('0x19')](_0x496158['where'],{[Op['or']]:_[_0x1303b2('0x40')](_0x42e39e,function(_0x2edf08){const _0x3c07ed=_0x1303b2;if(_0x2edf08[_0x3c07ed('0x87')]!=='VIRTUAL'){const _0x410f48={};return _0x410f48[_0x2edf08[_0x3c07ed('0x52')]]={[Op[_0x3c07ed('0x24')]]:'%'+_0x5850bd[_0x3c07ed('0x84')]['filter']+'%'},_0x410f48;}})}));_0x496158=_[_0x1303b2('0x19')]({},_0x496158,_0x5850bd[_0x1303b2('0x89')]);const _0x376bd1={'where':_0x496158[_0x1303b2('0x2c')]};return db[_0x1303b2('0x4f')][_0x1303b2('0x37')](_0x376bd1)[_0x1303b2('0x1d')](function(_0x262c6b){const _0x2d7dfc=_0x1303b2;return _0x3907f7[_0x2d7dfc('0x37')]=_0x262c6b,_0x5850bd[_0x2d7dfc('0x84')][_0x2d7dfc('0x5')]&&(_0x496158[_0x2d7dfc('0x3a')]=[{'all':!![]}]),db[_0x2d7dfc('0x4f')]['findAll'](_0x496158);})[_0x1303b2('0x1d')](function(_0x18ba8c){const _0x13faf5=_0x1303b2;return _0x3907f7[_0x13faf5('0x35')]=_0x18ba8c,_0x3907f7;})[_0x1303b2('0x1d')](respondWithFilteredResult(_0x410789,_0x496158))[_0x1303b2('0x27')](handleError(_0x410789,null));},exports[_0x41bf55('0x9')]=function(_0x1ee686,_0x188164){const _0x5d5edc=_0x41bf55;let _0x195f9b={'raw':![],'where':{'id':_0x1ee686['params']['id']},'include':[{'model':db[_0x5d5edc('0x5c')],'as':'mandatoryDispositionPause'}]};const _0x3119dd={};return _0x3119dd['model']=_[_0x5d5edc('0x2f')](db[_0x5d5edc('0x4f')][_0x5d5edc('0xe')]),_0x3119dd[_0x5d5edc('0x84')]=_[_0x5d5edc('0x2f')](_0x1ee686[_0x5d5edc('0x84')]),_0x3119dd[_0x5d5edc('0x4a')]=_[_0x5d5edc('0x8b')](_0x3119dd[_0x5d5edc('0x60')],_0x3119dd[_0x5d5edc('0x84')]),_0x195f9b[_0x5d5edc('0x2e')]=_['intersection'](_0x3119dd[_0x5d5edc('0x60')],qs['fields'](_0x1ee686['query']['fields'])),_0x195f9b[_0x5d5edc('0x2e')]=_0x195f9b[_0x5d5edc('0x2e')][_0x5d5edc('0x8e')]?_0x195f9b[_0x5d5edc('0x2e')]:_0x3119dd[_0x5d5edc('0x60')],_0x1ee686['query'][_0x5d5edc('0x5')]&&(_0x195f9b[_0x5d5edc('0x3a')]=[{'all':!![]}]),_0x195f9b=_['merge']({},_0x195f9b,_0x1ee686[_0x5d5edc('0x89')]),db[_0x5d5edc('0x4f')][_0x5d5edc('0x91')](_0x195f9b)['then'](handleEntityNotFound(_0x188164,null))[_0x5d5edc('0x1d')](respondWithResult(_0x188164,null))[_0x5d5edc('0x27')](handleError(_0x188164,null));},exports[_0x41bf55('0x77')]=function(_0x5d31cf,_0x534ed2){const _0xf22daf=_0x41bf55;return db[_0xf22daf('0x4f')][_0xf22daf('0x77')](_0x5d31cf['body'],{})['then'](function(_0x2e08c1){const _0x2463aa=_0xf22daf,_0x5d2f4e=_0x5d31cf[_0x2463aa('0x17')][_0x2463aa('0x50')]({'plain':!![]});if(!_0x5d2f4e)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x5d2f4e[_0x2463aa('0x45')]===_0x2463aa('0x17')){const _0x3b55a1=_0x2e08c1[_0x2463aa('0x50')]({'plain':!![]}),_0x3aadec=_0x2463aa('0x62');return db['UserProfileSection'][_0x2463aa('0x91')]({'where':{'name':_0x3aadec,'userProfileId':_0x5d2f4e[_0x2463aa('0x65')]},'raw':!![]})[_0x2463aa('0x1d')](function(_0x1e2a00){const _0xcbd739=_0x2463aa;return _0x1e2a00&&_0x1e2a00[_0xcbd739('0x92')]===0x0?db[_0xcbd739('0x2b')][_0xcbd739('0x77')]({'name':_0x3b55a1[_0xcbd739('0x52')],'resourceId':_0x3b55a1['id'],'type':_0x1e2a00[_0xcbd739('0x52')],'sectionId':_0x1e2a00['id']},{})[_0xcbd739('0x1d')](function(){return _0x2e08c1;}):_0x2e08c1;})[_0x2463aa('0x27')](function(_0x58109f){const _0x1711ac=_0x2463aa;logger[_0x1711ac('0x6f')](_0x1711ac('0xb'),_0x58109f);throw _0x58109f;});}return _0x2e08c1;})[_0xf22daf('0x1d')](respondWithResult(_0x534ed2,0xc9))[_0xf22daf('0x27')](handleError(_0x534ed2,null));},exports[_0x41bf55('0x1')]=function(_0x6a0eb4,_0x134b0f){const _0x311578=_0x41bf55;return _0x6a0eb4[_0x311578('0x58')]['id']&&delete _0x6a0eb4['body']['id'],db['OpenchannelAccount']['findOne']({'where':{'id':_0x6a0eb4[_0x311578('0x1e')]['id']},'include':[{'model':db[_0x311578('0x5c')],'as':_0x311578('0x15')}]})[_0x311578('0x1d')](handleEntityNotFound(_0x134b0f,null))[_0x311578('0x1d')](saveUpdates(_0x6a0eb4[_0x311578('0x58')],null))[_0x311578('0x1d')](respondWithResult(_0x134b0f,null))['catch'](handleError(_0x134b0f,null));},exports['destroy']=function(_0x275a48,_0x135c6a){const _0x2f89e9=_0x41bf55;return db[_0x2f89e9('0x4f')]['findOne']({'where':{'id':_0x275a48[_0x2f89e9('0x1e')]['id']}})[_0x2f89e9('0x1d')](handleEntityNotFound(_0x135c6a,null))[_0x2f89e9('0x1d')](removeEntity(_0x135c6a,null))[_0x2f89e9('0x27')](handleError(_0x135c6a,null));},exports[_0x41bf55('0x6c')]=function(_0x26a7f3,_0x240bc3){const _0x25a6b9=_0x41bf55;return db[_0x25a6b9('0x4f')][_0x25a6b9('0x6c')]()[_0x25a6b9('0x1d')](respondWithResult(_0x240bc3,null))[_0x25a6b9('0x27')](handleError(_0x240bc3,null));},exports[_0x41bf55('0x47')]=function(_0x59ea34,_0x5bbeed){const _0x2e6c78=_0x41bf55;return _0x59ea34[_0x2e6c78('0x58')]['id']&&delete _0x59ea34[_0x2e6c78('0x58')]['id'],db[_0x2e6c78('0x4f')]['findOne']({'where':{'id':_0x59ea34['params']['id']}})[_0x2e6c78('0x1d')](handleEntityNotFound(_0x5bbeed,null))[_0x2e6c78('0x1d')](function(_0x2a2d1a){const _0x1019de=_0x2e6c78;if(_0x2a2d1a)return _0x59ea34[_0x1019de('0x58')][_0x1019de('0x68')]=_0x2a2d1a['id'],db[_0x1019de('0x8f')][_0x1019de('0x77')](_0x59ea34[_0x1019de('0x58')]);})['then'](respondWithResult(_0x5bbeed,null))['catch'](handleError(_0x5bbeed,null));},exports['getDispositions']=function(_0x2aa5aa,_0x1f226c){const _0x385a78=_0x41bf55;let _0x91f1c8={'raw':![],'where':{}};const _0x133ce7={},_0xdc68ff={'count':0x0,'rows':[]};return db[_0x385a78('0x4f')][_0x385a78('0x91')]({'where':{'id':_0x2aa5aa[_0x385a78('0x1e')]['id']}})[_0x385a78('0x1d')](handleEntityNotFound(_0x1f226c,null))['then'](function(_0x23264b){const _0x24d1ab=_0x385a78;if(_0x23264b)return _0x133ce7[_0x24d1ab('0x60')]=_[_0x24d1ab('0x2f')](db['Disposition'][_0x24d1ab('0xe')]),_0x133ce7['query']=_['keys'](_0x2aa5aa[_0x24d1ab('0x84')]),_0x133ce7[_0x24d1ab('0x4a')]=_[_0x24d1ab('0x8b')](_0x133ce7[_0x24d1ab('0x60')],_0x133ce7['query']),_0x91f1c8[_0x24d1ab('0x2e')]=_[_0x24d1ab('0x8b')](_0x133ce7[_0x24d1ab('0x60')],qs[_0x24d1ab('0x56')](_0x2aa5aa['query'][_0x24d1ab('0x56')])),_0x91f1c8['attributes']=_0x91f1c8[_0x24d1ab('0x2e')][_0x24d1ab('0x8e')]?_0x91f1c8[_0x24d1ab('0x2e')]:_0x133ce7['model'],typeof _0x2aa5aa[_0x24d1ab('0x84')][_0x24d1ab('0xd')]===_0x24d1ab('0x7c')&&(_0x91f1c8['limit']=qs['limit'](_0x2aa5aa['query'][_0x24d1ab('0x67')]),_0x91f1c8[_0x24d1ab('0x82')]=qs[_0x24d1ab('0x82')](_0x2aa5aa[_0x24d1ab('0x84')]['offset'])),_0x91f1c8[_0x24d1ab('0x90')]=qs[_0x24d1ab('0x5f')](_0x2aa5aa[_0x24d1ab('0x84')]['sort']),_0x91f1c8[_0x24d1ab('0x2c')]=qs['filters'](_[_0x24d1ab('0x14')](_0x2aa5aa[_0x24d1ab('0x84')],_0x133ce7[_0x24d1ab('0x4a')])),_0x91f1c8[_0x24d1ab('0x2c')][_0x24d1ab('0x68')]=_0x23264b['id'],_0x2aa5aa[_0x24d1ab('0x84')][_0x24d1ab('0x21')]&&(_0x91f1c8[_0x24d1ab('0x2c')]=_['merge'](_0x91f1c8[_0x24d1ab('0x2c')],{[Op['or']]:_[_0x24d1ab('0x40')](_0x91f1c8[_0x24d1ab('0x2e')],function(_0x40f6e0){const _0x895cfc=_0x24d1ab,_0xb83757={};return _0xb83757[_0x40f6e0]={[Op['like']]:'%'+_0x2aa5aa[_0x895cfc('0x84')][_0x895cfc('0x21')]+'%'},_0xb83757;})})),_0x91f1c8=_[_0x24d1ab('0x19')]({},_0x91f1c8,_0x2aa5aa[_0x24d1ab('0x89')]),db[_0x24d1ab('0x8f')][_0x24d1ab('0x37')]({'where':_0x91f1c8[_0x24d1ab('0x2c')]})[_0x24d1ab('0x1d')](function(_0x3e3246){const _0x23c7c5=_0x24d1ab;return _0xdc68ff[_0x23c7c5('0x37')]=_0x3e3246,_0x2aa5aa[_0x23c7c5('0x84')][_0x23c7c5('0x5')]&&(_0x91f1c8[_0x23c7c5('0x3a')]=[{'all':!![]}]),db['Disposition'][_0x23c7c5('0x32')](_0x91f1c8);})[_0x24d1ab('0x1d')](function(_0x728aff){const _0x5e762f=_0x24d1ab;return _0xdc68ff[_0x5e762f('0x35')]=_0x728aff,_0xdc68ff;});})[_0x385a78('0x1d')](respondWithFilteredResult(_0x1f226c,_0x91f1c8))[_0x385a78('0x27')](handleError(_0x1f226c,null));},exports[_0x41bf55('0x43')]=function(_0xc80c23,_0x45cc5f){const _0x183a9b=_0x41bf55;return db['OpenchannelAccount'][_0x183a9b('0x91')]({'where':{'id':_0xc80c23['params']['id']}})[_0x183a9b('0x1d')](handleEntityNotFound(_0x45cc5f,null))[_0x183a9b('0x1d')](function(_0x27994b){const _0x4c499f=_0x183a9b;if(_0x27994b)return _0x27994b['removeDispositions'](_0xc80c23[_0x4c499f('0x84')][_0x4c499f('0x28')]);})[_0x183a9b('0x1d')](respondWithStatusCode(_0x45cc5f,null))[_0x183a9b('0x27')](handleError(_0x45cc5f,null));},exports['addAnswer']=function(_0x573bb6,_0x5b999f){const _0x33599a=_0x41bf55;return _0x573bb6[_0x33599a('0x58')]['id']&&delete _0x573bb6[_0x33599a('0x58')]['id'],db[_0x33599a('0x4f')][_0x33599a('0x91')]({'where':{'id':_0x573bb6[_0x33599a('0x1e')]['id']}})[_0x33599a('0x1d')](handleEntityNotFound(_0x5b999f,null))['then'](function(_0x453bb2){const _0x536f2c=_0x33599a;if(_0x453bb2)return _0x573bb6[_0x536f2c('0x58')]['OpenchannelAccountId']=_0x453bb2['id'],db[_0x536f2c('0x2a')][_0x536f2c('0x77')](_0x573bb6[_0x536f2c('0x58')]);})['then'](respondWithResult(_0x5b999f,null))[_0x33599a('0x27')](handleError(_0x5b999f,null));},exports[_0x41bf55('0x88')]=function(_0x5758f7,_0x30c07a){const _0x36e93d=_0x41bf55;let _0xf319f0={'raw':![],'where':{}};const _0x24afd0={},_0x30f3ad={'count':0x0,'rows':[]};return db[_0x36e93d('0x4f')][_0x36e93d('0x91')]({'where':{'id':_0x5758f7['params']['id']}})[_0x36e93d('0x1d')](handleEntityNotFound(_0x30c07a,null))['then'](function(_0x3ff961){const _0x122269=_0x36e93d;if(_0x3ff961)return _0x24afd0[_0x122269('0x60')]=_[_0x122269('0x2f')](db[_0x122269('0x2a')]['rawAttributes']),_0x24afd0[_0x122269('0x84')]=_[_0x122269('0x2f')](_0x5758f7[_0x122269('0x84')]),_0x24afd0[_0x122269('0x4a')]=_[_0x122269('0x8b')](_0x24afd0[_0x122269('0x60')],_0x24afd0[_0x122269('0x84')]),_0xf319f0['attributes']=_[_0x122269('0x8b')](_0x24afd0[_0x122269('0x60')],qs[_0x122269('0x56')](_0x5758f7[_0x122269('0x84')][_0x122269('0x56')])),_0xf319f0[_0x122269('0x2e')]=_0xf319f0[_0x122269('0x2e')]['length']?_0xf319f0[_0x122269('0x2e')]:_0x24afd0[_0x122269('0x60')],typeof _0x5758f7[_0x122269('0x84')][_0x122269('0xd')]===_0x122269('0x7c')&&(_0xf319f0[_0x122269('0x67')]=qs[_0x122269('0x67')](_0x5758f7[_0x122269('0x84')][_0x122269('0x67')]),_0xf319f0[_0x122269('0x82')]=qs[_0x122269('0x82')](_0x5758f7[_0x122269('0x84')][_0x122269('0x82')])),_0xf319f0[_0x122269('0x90')]=qs[_0x122269('0x5f')](_0x5758f7[_0x122269('0x84')][_0x122269('0x5f')]),_0xf319f0[_0x122269('0x2c')]=qs[_0x122269('0x4a')](_['pick'](_0x5758f7['query'],_0x24afd0['filters'])),_0xf319f0[_0x122269('0x2c')][_0x122269('0x68')]=_0x3ff961['id'],_0x5758f7[_0x122269('0x84')][_0x122269('0x21')]&&(_0xf319f0['where']=_[_0x122269('0x19')](_0xf319f0[_0x122269('0x2c')],{[Op['or']]:_[_0x122269('0x40')](_0xf319f0[_0x122269('0x2e')],function(_0x2b7701){const _0x59ce70=_0x122269,_0x2dac79={};return _0x2dac79[_0x2b7701]={[Op[_0x59ce70('0x24')]]:'%'+_0x5758f7[_0x59ce70('0x84')]['filter']+'%'},_0x2dac79;})})),_0xf319f0=_[_0x122269('0x19')]({},_0xf319f0,_0x5758f7[_0x122269('0x89')]),db[_0x122269('0x2a')][_0x122269('0x37')]({'where':_0xf319f0[_0x122269('0x2c')]})[_0x122269('0x1d')](function(_0x26fe02){const _0x177dbd=_0x122269;return _0x30f3ad['count']=_0x26fe02,_0x5758f7[_0x177dbd('0x84')]['includeAll']&&(_0xf319f0['include']=[{'all':!![]}]),db[_0x177dbd('0x2a')][_0x177dbd('0x32')](_0xf319f0);})[_0x122269('0x1d')](function(_0x48daa1){const _0x15493f=_0x122269;return _0x30f3ad[_0x15493f('0x35')]=_0x48daa1,_0x30f3ad;});})['then'](respondWithFilteredResult(_0x30c07a,_0xf319f0))[_0x36e93d('0x27')](handleError(_0x30c07a,null));},exports['removeAnswers']=function(_0x12c203,_0x47dd10){const _0x3709bd=_0x41bf55;return db['OpenchannelAccount']['findOne']({'where':{'id':_0x12c203['params']['id']}})[_0x3709bd('0x1d')](handleEntityNotFound(_0x47dd10,null))[_0x3709bd('0x1d')](function(_0x11ad8a){const _0x3aefcb=_0x3709bd;if(_0x11ad8a)return _0x11ad8a[_0x3aefcb('0x8a')](_0x12c203[_0x3aefcb('0x84')][_0x3aefcb('0x28')]);})[_0x3709bd('0x1d')](respondWithStatusCode(_0x47dd10,null))[_0x3709bd('0x27')](handleError(_0x47dd10,null));},exports[_0x41bf55('0x64')]=function(_0x22782b,_0x3b076a){const _0x2b4ff7=_0x41bf55,_0x58a32e={'body':_0x22782b[_0x2b4ff7('0x58')],'channel':_0x2b4ff7('0x5a')};let _0x5a43b2=[],_0x365d73=[];const _0x4a4e77={};let _0x3cc182=![];return db[_0x2b4ff7('0x2')][_0x2b4ff7('0x6c')]()[_0x2b4ff7('0x1d')](function(_0x5e48f2){const _0x5bcdc7=_0x2b4ff7;if(!_0x5e48f2)throw new db[(_0x5bcdc7('0x8c'))][(_0x5bcdc7('0x33'))]('no\x20available\x20attributes');_0x5a43b2=_['difference'](_[_0x5bcdc7('0x2f')](_0x5e48f2),[_0x5bcdc7('0x38'),'updatedAt']),_0x365d73=_[_0x5bcdc7('0x70')](_[_0x5bcdc7('0x2f')](_0x5e48f2),['createdAt',_0x5bcdc7('0x55'),_0x5bcdc7('0x81'),_0x5bcdc7('0x98')]);_0x22782b[_0x5bcdc7('0x58')]['id']&&delete _0x22782b['body']['id'];if(_[_0x5bcdc7('0x80')](_0x22782b[_0x5bcdc7('0x58')][_0x5bcdc7('0x1a')]))throw new db[(_0x5bcdc7('0x8c'))][(_0x5bcdc7('0x33'))](_0x5bcdc7('0x1c'));if(_[_0x5bcdc7('0x80')](_0x22782b[_0x5bcdc7('0x58')]['body'])||_0x22782b['body'][_0x5bcdc7('0x58')]==='')throw new db['Sequelize'][(_0x5bcdc7('0x33'))](_0x5bcdc7('0x59'));if(_['isNil'](_0x22782b['body'][_0x5bcdc7('0x20')]))throw new db['Sequelize']['ValidationError'](_0x5bcdc7('0x46')+_0x365d73);if(!_[_0x5bcdc7('0x57')](_0x365d73,_0x22782b[_0x5bcdc7('0x58')][_0x5bcdc7('0x20')]))throw new db[(_0x5bcdc7('0x8c'))][(_0x5bcdc7('0x33'))](_0x5bcdc7('0x1f')+_0x365d73);_0x4a4e77[_0x22782b[_0x5bcdc7('0x58')]['mapKey']]=_0x22782b['body']['from'];})[_0x2b4ff7('0x1d')](function(){const _0x16ffff=_0x2b4ff7;return db[_0x16ffff('0x4f')][_0x16ffff('0x91')]({'where':{'id':_0x22782b[_0x16ffff('0x1e')]['id']},'include':[{'model':db['CmList'],'as':'List','include':[{'model':db['CmContact'],'as':_0x16ffff('0x26'),'where':_0x4a4e77,'limit':0x1,'order':[[_0x16ffff('0x55'),_0x16ffff('0x6a')]]}]},{'model':db[_0x16ffff('0xa')],'as':_0x16ffff('0x2d')}]});})[_0x2b4ff7('0x1d')](handleEntityNotFound(_0x3b076a,null))[_0x2b4ff7('0x1d')](function(_0x130f76){const _0x2baf64=_0x2b4ff7;if(_0x130f76&&_0x130f76[_0x2baf64('0x76')]){_0x58a32e[_0x2baf64('0x71')]=_0x130f76,_0x58a32e[_0x2baf64('0x5e')]=_0x130f76[_0x2baf64('0x2d')],_0x58a32e['list']=_0x130f76[_0x2baf64('0x76')],_0x58a32e[_0x2baf64('0x5e')]=_[_0x2baf64('0x95')](_0x58a32e[_0x2baf64('0x5e')],['priority'],['asc']);_0x58a32e[_0x2baf64('0x71')][_0x2baf64('0x2d')]&&delete _0x58a32e[_0x2baf64('0x71')]['Applications'];if(_0x58a32e[_0x2baf64('0x71')][_0x2baf64('0x76')]&&_0x58a32e['account']['List'][_0x2baf64('0x26')][_0x2baf64('0x8e')])return _0x58a32e[_0x2baf64('0x71')]['List'][_0x2baf64('0x26')][0x0];const _0x36fe5d=_[_0x2baf64('0x69')](_0x22782b[_0x2baf64('0x58')],{'firstName':_0x22782b[_0x2baf64('0x58')][_0x2baf64('0x1a')],'ListId':_0x130f76[_0x2baf64('0x98')]});return _0x36fe5d[_0x22782b[_0x2baf64('0x58')][_0x2baf64('0x20')]]=_0x22782b[_0x2baf64('0x58')]['from'],db[_0x2baf64('0x2')]['create'](_0x36fe5d,{'fields':_0x5a43b2,'raw':!![]});}})[_0x2b4ff7('0x1d')](handleEntityNotFound(_0x3b076a,null))[_0x2b4ff7('0x1d')](function(_0x1c06ce){const _0x140f48=_0x2b4ff7;_0x58a32e[_0x140f48('0x8d')]=_0x1c06ce;if(_0x1c06ce){const _0x269d34={'ContactId':_0x1c06ce['id'],'OpenchannelAccountId':_0x22782b[_0x140f48('0x1e')]['id'],'from':(_0x1c06ce[_0x140f48('0x4e')]||'')+'\x20'+(_0x1c06ce[_0x140f48('0x3c')]||'')},_0x1ca169={'OpenchannelAccountId':_0x22782b[_0x140f48('0x1e')]['id'],'closed':![]};if(_0x22782b[_0x140f48('0x58')]['threadId'])return _0x1ca169[_0x140f48('0x86')]=_0x22782b[_0x140f48('0x58')][_0x140f48('0x86')],db[_0x140f48('0x96')]['findOne']({'where':_0x1ca169})['then'](function(_0x49c772){const _0x28a878=_0x140f48;if(_0x49c772)return[_0x49c772,![]];return _0x269d34[_0x28a878('0x86')]=_0x22782b[_0x28a878('0x58')][_0x28a878('0x86')],_0x269d34['externalUrl']=_0x22782b['body'][_0x28a878('0x54')],db['OpenchannelInteraction']['create'](_0x269d34)[_0x28a878('0x1d')](function(_0x2e4e7c){return[_0x2e4e7c,!![]];});});else _0x1ca169[_0x140f48('0x86')]=null;return _0x1ca169['ContactId']=_0x1c06ce['id'],db[_0x140f48('0x96')][_0x140f48('0x91')]({'where':_0x1ca169})[_0x140f48('0x1d')](function(_0x4ad8be){const _0x515f16=_0x140f48;if(_0x4ad8be)return[_0x4ad8be,![]];return db[_0x515f16('0x96')][_0x515f16('0x77')](_0x269d34)['then'](function(_0x425af6){return[_0x425af6,!![]];});});}})[_0x2b4ff7('0x1d')](function([_0x2ebb77,_0x323cfa]){const _0x3691f7=_0x2b4ff7;if(_0x2ebb77){_0x3cc182=_0x323cfa;if(!_0x323cfa){const _0x4d97e5={'from':(_0x58a32e[_0x3691f7('0x8d')][_0x3691f7('0x4e')]||'')+'\x20'+(_0x58a32e[_0x3691f7('0x8d')][_0x3691f7('0x3c')]||'')};return _0x22782b[_0x3691f7('0x58')][_0x3691f7('0x86')]&&_0x22782b['body']['messageId']&&_0x22782b['body'][_0x3691f7('0x86')]!=_0x22782b['body'][_0x3691f7('0x63')]&&(_0x4d97e5[_0x3691f7('0x86')]=_0x22782b[_0x3691f7('0x58')]['messageId']),_0x2ebb77[_0x3691f7('0x1')](_0x4d97e5);}else return _0x2ebb77;}})[_0x2b4ff7('0x1d')](function(_0x539d3d){const _0x1be981=_0x2b4ff7;return _0x58a32e[_0x1be981('0x6d')]=_0x539d3d[_0x1be981('0x50')]({'plain':!![]}),_0x58a32e[_0x1be981('0x6d')][_0x1be981('0x30')]=_0x3cc182,_0x58a32e['interaction'][_0x1be981('0x30')]&&(_0x58a32e[_0x1be981('0x71')][_0x1be981('0x3')]&&_0x58a32e[_0x1be981('0x5e')][_0x1be981('0x7b')]({'id':0x0,'priority':_0x58a32e[_0x1be981('0x5e')]['length']+0x1,'app':'close','appdata':_0x1be981('0x10'),'interval':_0x1be981('0x7d')})),db[_0x1be981('0x85')][_0x1be981('0x77')]({'body':_0x22782b[_0x1be981('0x58')][_0x1be981('0x58')],'OpenchannelAccountId':_0x22782b[_0x1be981('0x1e')]['id'],'OpenchannelInteractionId':_0x539d3d['id'],'direction':'in','ContactId':_0x58a32e[_0x1be981('0x8d')]['id'],'AttachmentId':_0x22782b['body']['AttachmentId']});})['then'](function(_0x212b57){const _0x116773=_0x2b4ff7;_0x58a32e['message']=_0x212b57;if(_0x58a32e[_0x116773('0x6d')]['UserId'])return db[_0x116773('0xc')][_0x116773('0x91')]({'attributes':['id',_0x116773('0x52')],'where':{'id':_0x58a32e[_0x116773('0x6d')]['UserId']}})['then'](function(_0x390ce6){const _0x28a7ce=_0x116773;return _0x390ce6&&(_0x58a32e[_0x28a7ce('0x5e')][_0x28a7ce('0x3f')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x390ce6[_0x28a7ce('0x52')]+','+(_0x58a32e['account'][_0x28a7ce('0xf')]||0xa),'interval':_0x28a7ce('0x7d')}),_0x58a32e[_0x28a7ce('0x22')]=![]),respondWithRpcPromise(_0x28a7ce('0x11'),_0x28a7ce('0x4b'),_0x58a32e);});return respondWithRpcPromise('Start',_0x116773('0x4b'),_0x58a32e);})[_0x2b4ff7('0x1d')](function(_0x562df9){const _0x55e9f4=_0x2b4ff7;return respondWithRpcPromise('EventManager',_0x55e9f4('0x12'),{'event':_0x55e9f4('0x64'),'message':_0x562df9},client9002),_0x562df9;})[_0x2b4ff7('0x1d')](respondWithResult(_0x3b076a,null))[_0x2b4ff7('0x27')](handleError(_0x3b076a,null));},exports[_0x41bf55('0x7')]=function(_0xee34a1,_0x5807aa){const _0x32a26b=_0x41bf55;return db[_0x32a26b('0x4f')][_0x32a26b('0x91')]({'where':{'id':_0xee34a1[_0x32a26b('0x1e')]['id']}})[_0x32a26b('0x1d')](handleEntityNotFound(_0x5807aa,null))['then'](function(_0x5beb00){const _0x4983f1=_0x32a26b;if(_0x5beb00)return db[_0x4983f1('0x23')][_0x4983f1('0x4c')](function(_0x69050a){const _0x2ec163=_0x4983f1;return db[_0x2ec163('0xa')][_0x2ec163('0x4d')]({'where':{'OpenchannelAccountId':_0xee34a1[_0x2ec163('0x1e')]['id']},'transaction':_0x69050a})[_0x2ec163('0x1d')](function(){const _0x34224f=_0x2ec163,_0x59c5d8=_[_0x34224f('0x40')](_0xee34a1['body'],function(_0x5d1c48){const _0x4f28f1=_0x34224f;return _0x5d1c48[_0x4f28f1('0x68')]=_0xee34a1[_0x4f28f1('0x1e')]['id'],_0x5d1c48;});return db['OpenchannelApplication']['bulkCreate'](_0x59c5d8,{'transaction':_0x69050a});});})[_0x4983f1('0x1d')](function(){const _0x206a62=_0x4983f1;return db[_0x206a62('0xa')][_0x206a62('0x8')]({'where':{'OpenchannelAccountId':_0xee34a1[_0x206a62('0x1e')]['id']},'order':_0x206a62('0x83')});});})[_0x32a26b('0x1d')](respondWithResult(_0x5807aa,null))[_0x32a26b('0x27')](handleError(_0x5807aa,null));},exports[_0x41bf55('0x6')]=function(_0x1bb690,_0x47d8f9){const _0x3b0b30=_0x41bf55;let _0x390da2={};const _0x4088ef={};let _0x5586a1,_0x253649;return db[_0x3b0b30('0x4f')][_0x3b0b30('0x91')]({'where':{'id':_0x1bb690[_0x3b0b30('0x1e')]['id']}})[_0x3b0b30('0x1d')](handleEntityNotFound(_0x47d8f9,null))[_0x3b0b30('0x1d')](function(_0x57b197){const _0x77535c=_0x3b0b30;if(_0x57b197)return _0x5586a1=_0x57b197,_0x4088ef[_0x77535c('0x60')]=_[_0x77535c('0x2f')](db[_0x77535c('0xa')][_0x77535c('0xe')]),_0x4088ef['query']=_['keys'](_0x1bb690['query']),_0x4088ef['filters']=_[_0x77535c('0x8b')](_0x4088ef[_0x77535c('0x60')],_0x4088ef[_0x77535c('0x84')]),_0x390da2[_0x77535c('0x2e')]=_[_0x77535c('0x8b')](_0x4088ef[_0x77535c('0x60')],qs['fields'](_0x1bb690[_0x77535c('0x84')][_0x77535c('0x56')])),_0x390da2[_0x77535c('0x2e')]=_0x390da2[_0x77535c('0x2e')][_0x77535c('0x8e')]?_0x390da2[_0x77535c('0x2e')]:_0x4088ef[_0x77535c('0x60')],_0x390da2[_0x77535c('0x90')]=qs[_0x77535c('0x5f')](_0x1bb690[_0x77535c('0x84')][_0x77535c('0x5f')]),_0x390da2[_0x77535c('0x2c')]=qs[_0x77535c('0x4a')](_[_0x77535c('0x14')](_0x1bb690[_0x77535c('0x84')],_0x4088ef[_0x77535c('0x4a')])),_0x1bb690['query']['filter']&&(_0x390da2[_0x77535c('0x2c')]=_[_0x77535c('0x19')](_0x390da2[_0x77535c('0x2c')],{[Op['or']]:_[_0x77535c('0x40')](_0x390da2[_0x77535c('0x2e')],function(_0x5a39fd){const _0x11444d=_0x77535c,_0x2c225a={};return _0x2c225a[_0x5a39fd]={[Op[_0x11444d('0x24')]]:'%'+_0x1bb690['query'][_0x11444d('0x21')]+'%'},_0x2c225a;})})),_0x390da2=_['merge']({},_0x390da2,_0x1bb690['options']),_0x5586a1[_0x77535c('0x6')](_0x390da2);})['then'](function(_0x1a08fa){const _0x4eb2a1=_0x3b0b30;if(_0x1a08fa)return _0x253649=_0x1a08fa[_0x4eb2a1('0x8e')],typeof _0x1bb690[_0x4eb2a1('0x84')][_0x4eb2a1('0xd')]===_0x4eb2a1('0x7c')&&(_0x390da2['limit']=qs[_0x4eb2a1('0x67')](_0x1bb690[_0x4eb2a1('0x84')][_0x4eb2a1('0x67')]),_0x390da2[_0x4eb2a1('0x82')]=qs[_0x4eb2a1('0x82')](_0x1bb690[_0x4eb2a1('0x84')][_0x4eb2a1('0x82')])),_0x5586a1[_0x4eb2a1('0x6')](_0x390da2);})[_0x3b0b30('0x1d')](function(_0x31df35){if(_0x31df35)return _0x31df35?{'count':_0x253649,'rows':_0x31df35}:null;})[_0x3b0b30('0x1d')](respondWithResult(_0x47d8f9,null))['catch'](handleError(_0x47d8f9,null));},exports['getInteractions']=function(_0x3058b0,_0x24264f){const _0x453645=_0x41bf55;let _0x542739={'raw':![],'where':{}};const _0x49fbbb={},_0x28499e={'count':0x0,'rows':[]};return db[_0x453645('0x4f')][_0x453645('0x91')]({'where':{'id':_0x3058b0[_0x453645('0x1e')]['id']}})[_0x453645('0x1d')](handleEntityNotFound(_0x24264f,null))[_0x453645('0x1d')](function(_0x2df369){const _0x5dc38d=_0x453645;if(_0x2df369)return _0x49fbbb[_0x5dc38d('0x60')]=_[_0x5dc38d('0x2f')](db['OpenchannelInteraction'][_0x5dc38d('0xe')]),_0x49fbbb[_0x5dc38d('0x84')]=_[_0x5dc38d('0x2f')](_0x3058b0['query']),_0x49fbbb['filters']=_[_0x5dc38d('0x8b')](_0x49fbbb[_0x5dc38d('0x60')],_0x49fbbb['query']),_0x542739[_0x5dc38d('0x2e')]=_['intersection'](_0x49fbbb['model'],qs['fields'](_0x3058b0[_0x5dc38d('0x84')]['fields'])),_0x542739[_0x5dc38d('0x2e')]=_0x542739['attributes'][_0x5dc38d('0x8e')]?_0x542739[_0x5dc38d('0x2e')]:_0x49fbbb[_0x5dc38d('0x60')],typeof _0x3058b0['query'][_0x5dc38d('0xd')]===_0x5dc38d('0x7c')&&(_0x542739[_0x5dc38d('0x67')]=qs[_0x5dc38d('0x67')](_0x3058b0[_0x5dc38d('0x84')][_0x5dc38d('0x67')]),_0x542739['offset']=qs[_0x5dc38d('0x82')](_0x3058b0[_0x5dc38d('0x84')][_0x5dc38d('0x82')])),_0x542739['order']=qs[_0x5dc38d('0x5f')](_0x3058b0['query']['sort']),_0x542739['where']=qs[_0x5dc38d('0x4a')](_[_0x5dc38d('0x14')](_0x3058b0[_0x5dc38d('0x84')],_0x49fbbb[_0x5dc38d('0x4a')])),_0x542739[_0x5dc38d('0x2c')][_0x5dc38d('0x68')]=_0x2df369['id'],_0x3058b0[_0x5dc38d('0x84')][_0x5dc38d('0x21')]&&(_0x542739[_0x5dc38d('0x2c')]=_[_0x5dc38d('0x19')](_0x542739['where'],{[Op['or']]:_['map'](_0x542739[_0x5dc38d('0x2e')],function(_0x2f6e75){const _0x10daf1=_0x5dc38d,_0x42fe58={};return _0x42fe58[_0x2f6e75]={[Op[_0x10daf1('0x24')]]:'%'+_0x3058b0[_0x10daf1('0x84')][_0x10daf1('0x21')]+'%'},_0x42fe58;})})),_0x542739=_[_0x5dc38d('0x19')]({},_0x542739,_0x3058b0[_0x5dc38d('0x89')]),db[_0x5dc38d('0x96')][_0x5dc38d('0x37')]({'where':_0x542739[_0x5dc38d('0x2c')]})[_0x5dc38d('0x1d')](function(_0x190a2a){const _0xf723b1=_0x5dc38d;return _0x28499e[_0xf723b1('0x37')]=_0x190a2a,_0x3058b0[_0xf723b1('0x84')][_0xf723b1('0x5')]&&(_0x542739[_0xf723b1('0x3a')]=[{'model':db[_0xf723b1('0x2')],'as':'Contact','required':![]},{'model':db[_0xf723b1('0xc')],'as':_0xf723b1('0x79'),'attributes':[_0xf723b1('0x52'),_0xf723b1('0x78'),'internal'],'required':![]},{'model':db['Tag'],'as':_0xf723b1('0x6e'),'attributes':['id',_0xf723b1('0x52'),_0xf723b1('0x5d')],'where':_0x3058b0[_0xf723b1('0x84')]['tag']?{'id':_0x3058b0[_0xf723b1('0x84')]['tag']}:undefined,'required':_0x3058b0['query']['tag']?!![]:![]}]),db[_0xf723b1('0x96')][_0xf723b1('0x32')](_0x542739);})[_0x5dc38d('0x1d')](function(_0x52d636){return _0x28499e['rows']=_0x52d636,_0x28499e;});})[_0x453645('0x1d')](respondWithFilteredResult(_0x24264f,_0x542739))[_0x453645('0x27')](handleError(_0x24264f,null));},exports[_0x41bf55('0x7f')]=function(_0x4aaae6,_0x49ecdc){const _0x42d497=_0x41bf55;return db[_0x42d497('0x4f')][_0x42d497('0x91')]({'where':{'id':_0x4aaae6[_0x42d497('0x1e')]['id']}})[_0x42d497('0x1d')](function(_0x57ff1e){const _0x324a17=_0x42d497;if(_0x57ff1e)return _0x57ff1e[_0x324a17('0x7f')](_0x4aaae6[_0x324a17('0x58')]['ids'],{'through':_[_0x324a17('0x3b')](_0x4aaae6[_0x324a17('0x58')],['ids','id'])})[_0x324a17('0x1d')](function(_0x31ca52){const _0x389e63=_0x324a17;for(let _0x3d27ca=0x0;_0x3d27ca<_0x4aaae6[_0x389e63('0x58')][_0x389e63('0x28')][_0x389e63('0x8e')];_0x3d27ca+=0x1){socket['emit']('userOpenchannelAccount:save',{'UserId':_0x4aaae6[_0x389e63('0x58')]['ids'][_0x3d27ca],'OpenchannelAccountId':_0x4aaae6[_0x389e63('0x1e')]['id']});}return _0x31ca52;});})[_0x42d497('0x1d')](respondWithResult(_0x49ecdc,null))['catch'](handleError(_0x49ecdc,null));},exports['removeAgents']=function(_0xc7a389,_0x23a79e){const _0x26210a=_0x41bf55;return db['OpenchannelAccount']['findOne']({'where':{'id':_0xc7a389[_0x26210a('0x1e')]['id']}})['then'](handleEntityNotFound(_0x23a79e,null))[_0x26210a('0x1d')](function(_0x3fbc6e){const _0x29878e=_0x26210a;if(_0x3fbc6e)return _0x3fbc6e[_0x29878e('0x31')](_0xc7a389['query'][_0x29878e('0x28')])[_0x29878e('0x1d')](function(){const _0x62db10=_0x29878e;if(_[_0x62db10('0x18')](_0xc7a389['query'][_0x62db10('0x28')]))for(let _0x3fb790=0x0;_0x3fb790<_0xc7a389[_0x62db10('0x84')]['ids'][_0x62db10('0x8e')];_0x3fb790+=0x1){socket['emit'](_0x62db10('0x7e'),{'UserId':Number(_0xc7a389[_0x62db10('0x84')]['ids'][_0x3fb790]),'OpenchannelAccountId':Number(_0xc7a389[_0x62db10('0x1e')]['id'])});}else socket[_0x62db10('0x34')](_0x62db10('0x7e'),{'UserId':Number(_0xc7a389[_0x62db10('0x84')][_0x62db10('0x28')]),'OpenchannelAccountId':Number(_0xc7a389[_0x62db10('0x1e')]['id'])});});})['then'](respondWithStatusCode(_0x23a79e,null))[_0x26210a('0x27')](handleError(_0x23a79e,null));},exports['getAgents']=function(_0x551309,_0x5c0886){const _0x37aee1=_0x41bf55;let _0x11690a={};const _0x1e6ef4={};let _0x2b39b,_0x540edb;return db['OpenchannelAccount'][_0x37aee1('0x91')]({'where':{'id':_0x551309[_0x37aee1('0x1e')]['id']}})[_0x37aee1('0x1d')](handleEntityNotFound(_0x5c0886,null))[_0x37aee1('0x1d')](function(_0x55607f){const _0x1a698c=_0x37aee1;if(_0x55607f)return _0x2b39b=_0x55607f,_0x1e6ef4[_0x1a698c('0x60')]=_[_0x1a698c('0x2f')](db[_0x1a698c('0xc')][_0x1a698c('0xe')]),_0x1e6ef4['query']=_[_0x1a698c('0x2f')](_0x551309[_0x1a698c('0x84')]),_0x1e6ef4['filters']=_['intersection'](_0x1e6ef4[_0x1a698c('0x60')],_0x1e6ef4[_0x1a698c('0x84')]),_0x11690a['attributes']=_[_0x1a698c('0x8b')](_0x1e6ef4[_0x1a698c('0x60')],qs['fields'](_0x551309[_0x1a698c('0x84')]['fields'])),_0x11690a[_0x1a698c('0x2e')]=_0x11690a[_0x1a698c('0x2e')]['length']?_0x11690a[_0x1a698c('0x2e')]:_0x1e6ef4['model'],_0x11690a[_0x1a698c('0x90')]=qs['sort'](_0x551309['query'][_0x1a698c('0x5f')]),_0x11690a[_0x1a698c('0x2c')]=qs[_0x1a698c('0x4a')](_[_0x1a698c('0x14')](_0x551309[_0x1a698c('0x84')],_0x1e6ef4['filters'])),_0x551309[_0x1a698c('0x84')][_0x1a698c('0x21')]&&(_0x11690a['where']=_[_0x1a698c('0x19')](_0x11690a[_0x1a698c('0x2c')],{[Op['or']]:_[_0x1a698c('0x40')](_0x11690a[_0x1a698c('0x2e')],function(_0x170875){const _0x288455=_0x1a698c,_0x15c0a8={};return _0x15c0a8[_0x170875]={[Op[_0x288455('0x24')]]:'%'+_0x551309['query']['filter']+'%'},_0x15c0a8;})})),_0x11690a=_[_0x1a698c('0x19')]({},_0x11690a,_0x551309[_0x1a698c('0x89')]),_0x2b39b['getAgents'](_0x11690a);})[_0x37aee1('0x1d')](function(_0x5bb0a6){const _0x49ed73=_0x37aee1;if(_0x5bb0a6)return _0x540edb=_0x5bb0a6[_0x49ed73('0x8e')],typeof _0x551309['query'][_0x49ed73('0xd')]===_0x49ed73('0x7c')&&(_0x11690a['limit']=qs[_0x49ed73('0x67')](_0x551309[_0x49ed73('0x84')][_0x49ed73('0x67')]),_0x11690a['offset']=qs['offset'](_0x551309[_0x49ed73('0x84')][_0x49ed73('0x82')])),_0x2b39b[_0x49ed73('0x39')](_0x11690a);})[_0x37aee1('0x1d')](function(_0x1cf5c0){if(_0x1cf5c0)return _0x1cf5c0?{'count':_0x540edb,'rows':_0x1cf5c0}:null;})[_0x37aee1('0x1d')](respondWithResult(_0x5c0886,null))[_0x37aee1('0x27')](handleError(_0x5c0886,null));},exports[_0x41bf55('0x51')]=function(_0x3307a4,_0x4ff15b){const _0x163a04=_0x41bf55;let _0x4aae85,_0x487287;if(_[_0x163a04('0x80')](_0x3307a4[_0x163a04('0x58')]['body'])||_0x3307a4['body']['body']==='')throw new db[(_0x163a04('0x8c'))]['ValidationError'](_0x163a04('0x59'));if(_[_0x163a04('0x80')](_0x3307a4[_0x163a04('0x58')]['to'])){}const _0x1e7e60=_0x3307a4[_0x163a04('0x58')]['to'];return db[_0x163a04('0x4f')][_0x163a04('0x91')]({'where':{'id':_0x3307a4[_0x163a04('0x1e')]['id']}})[_0x163a04('0x1d')](handleEntityNotFound(_0x4ff15b,null))[_0x163a04('0x1d')](function(_0x11265e){const _0x5abfa7=_0x163a04;if(_0x11265e)return db[_0x5abfa7('0x4f')][_0x5abfa7('0x91')]({'where':{'id':_0x11265e['id']},'include':[{'model':db[_0x5abfa7('0x48')],'as':'List','include':[{'model':db[_0x5abfa7('0x2')],'as':_0x5abfa7('0x26'),'where':{[_0x11265e['mapKey']]:_0x1e7e60},'limit':0x1,'order':[[_0x5abfa7('0x55'),_0x5abfa7('0x6a')]]}]}]})[_0x5abfa7('0x1d')](handleEntityNotFound(_0x4ff15b,null))[_0x5abfa7('0x1d')](function(_0x3de046){const _0x5b47dd=_0x5abfa7;if(_0x3de046&&_0x3de046[_0x5b47dd('0x76')]){_0x4aae85=_0x3de046['get']({'plain':!![]});if(_0x4aae85['List']&&_0x4aae85[_0x5b47dd('0x76')][_0x5b47dd('0x26')][_0x5b47dd('0x8e')])return _0x4aae85[_0x5b47dd('0x76')][_0x5b47dd('0x26')][0x0];return db['CmContact'][_0x5b47dd('0x77')](_['defaults'](_0x3307a4[_0x5b47dd('0x58')],{'firstName':_0x1e7e60,[_0x3de046[_0x5b47dd('0x20')]]:_0x1e7e60,'phone':_0x1e7e60,'ListId':_0x4aae85[_0x5b47dd('0x98')]}));}})['then'](handleEntityNotFound(_0x4ff15b,null))[_0x5abfa7('0x1d')](function(_0x1f0d12){const _0x4b8794=_0x5abfa7;if(_0x1f0d12)return _0x487287=_0x1f0d12,db[_0x4b8794('0x96')][_0x4b8794('0x91')]({'where':{'ContactId':_0x487287['id'],'closed':![],'OpenchannelAccountId':_0x4aae85['id']}})[_0x4b8794('0x1d')](function(_0x3bbd97){const _0x1e5c10=_0x4b8794;if(_0x3bbd97)return[_0x3bbd97,![]];return db[_0x1e5c10('0x96')][_0x1e5c10('0x77')]({'UserId':_0x3307a4['user']['id'],'ContactId':_0x487287['id'],'OpenchannelAccountId':_0x4aae85['id'],'lastMsgDirection':_0x1e5c10('0x13'),'Messages':[_[_0x1e5c10('0x19')](_0x3307a4[_0x1e5c10('0x58')],{'read':![],'body':_0x3307a4[_0x1e5c10('0x58')][_0x1e5c10('0x58')],'OpenchannelAccountId':_0x4aae85['id'],'UserId':_0x3307a4['user']['id'],'ContactId':_0x487287['id']})]},{'include':[{'model':db[_0x1e5c10('0x85')],'as':'Messages'}]})['then'](function(_0x595e4a){return[_0x595e4a,!![]];});});})[_0x5abfa7('0x1d')](function([_0x59a68f,_0xa4bd07]){const _0x345d35=_0x5abfa7;if(_0xa4bd07)return _0x59a68f;return db['OpenchannelMessage'][_0x345d35('0x77')](_[_0x345d35('0x19')](_0x3307a4[_0x345d35('0x58')],{'read':![],'body':_0x3307a4[_0x345d35('0x58')]['body'],'OpenchannelAccountId':_0x4aae85['id'],'OpenchannelInteractionId':_0x59a68f['id'],'UserId':_0x3307a4[_0x345d35('0x17')]['id'],'ContactId':_0x487287['id']}))['then'](function(_0x3f9262){const _0x5251e5=_0x345d35;return _0x59a68f['dataValues'][_0x5251e5('0x16')]=[],_0x59a68f[_0x5251e5('0x93')][_0x5251e5('0x16')][_0x5251e5('0x7b')](_0x3f9262[_0x5251e5('0x93')]),_0x59a68f;});});})[_0x163a04('0x1d')](respondWithResult(_0x4ff15b,null))[_0x163a04('0x27')](handleError(_0x4ff15b,null));};
\ No newline at end of file
+const a468_0x4dad=['Sequelize','mandatoryDispositionPause','push','jayson/promise','Applications','ids','OpenchannelInteraction','defaults','body','keys','type','agent','model','ListId','status','count','filters','CompanyId','from','tag','isArray','include','role','OpenchannelApplication','undefined','threadId','created','user','removeDispositions','out','attributes','interaction','Disposition','merge','OpenchannelMessage','offset','query','from\x20is\x20mandatory','sendStatus','json','pick','VIRTUAL','difference','emit','firstName','name','info','forcedOwnership','destroy','CannedAnswer','lastName','Start','limit','filter','*,*,*,*','Tag','removeAgents','stack','Contacts','autoAssociation','describe','messageId','where','like','Contact','OpenchannelAccounts','fields','message','OpenchannelAccount,\x20%s,\x20%s,\x20%s','addAnswer','Pause','order','unmanaged','createdAt','addDisposition','options','getDispositions','catch','includeAll','addAgents','../../components/parsers/qs','create','OpenchannelAccount','notify','set','end','sequelize','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','fullname','close','lodash','OpenchannelAccount,\x20%s,\x20%s','externalUrl','removeAnswers','then','intersection','api','update','getAgents','omit','request\x20sent','map','EventManager','get','getAnswers','dataValues','priority','applications','userOpenchannelAccount:save','request','nolimit','rows','getApplications','Messages','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','code','UserId','isNil','transaction','userOpenchannelAccount:remove','debug','sort','fieldName','stringify','User','send','params','openchannel','error','OpenchannelAccountId','Owner','AttachmentId','client','contact','rawAttributes','findAll','updatedAt','../../config/logger','Tags','startRouting','List','account','autoclose','findAndCountAll','length','CmList','ValidationError','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','userProfileId','body\x20is\x20mandatory\x20and\x20not\x20empty','CmContact','findOne','mapKey','UserProfileResource'];(function(_0x507f78,_0x4dad2b){const _0x468dfa=function(_0x3cf547){while(--_0x3cf547){_0x507f78['push'](_0x507f78['shift']());}};_0x468dfa(++_0x4dad2b);}(a468_0x4dad,0xb2));const a468_0x468d=function(_0x507f78,_0x4dad2b){_0x507f78=_0x507f78-0x0;let _0x468dfa=a468_0x4dad[_0x507f78];return _0x468dfa;};const _0x203747=a468_0x468d;'use strict';const _=require(_0x203747('0x42')),qs=require(_0x203747('0x38')),logger=require(_0x203747('0x71'))(_0x203747('0x48')),{getSocket}=require('../../rediscache'),socket=getSocket(),db=require('../../mysqldb')['db'],{Op}=require(_0x203747('0x3e'));require('./openchannelAccount.socket')['register'](socket);const jayson=require(_0x203747('0x85')),client=jayson[_0x203747('0x6c')]['http']({'port':0x232c}),client9002=jayson[_0x203747('0x6c')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3cf547,_0x2e115f,_0x5dade7,_0x5d0d04){return new Promise(function(_0x1f7d66,_0xb3b9f){const _0x5e7815=a468_0x468d,_0x1d6cc7=_0x5d0d04||client;return _0x1d6cc7[_0x5e7815('0x55')](_0x3cf547,_0x5dade7)['then'](function(_0x54026e){const _0x51c875=_0x5e7815;logger['info'](_0x51c875('0x43'),_0x2e115f,'request\x20sent'),logger[_0x51c875('0x60')](_0x51c875('0x2c'),_0x2e115f,_0x51c875('0x4c'),JSON[_0x51c875('0x63')](_0x54026e));if(_0x54026e[_0x51c875('0x68')]){if(_0x54026e[_0x51c875('0x68')][_0x51c875('0x5b')]===0x1f4)return logger[_0x51c875('0x68')](_0x51c875('0x43'),_0x2e115f,_0x54026e[_0x51c875('0x68')][_0x51c875('0x2b')]),_0xb3b9f(_0x54026e[_0x51c875('0x68')][_0x51c875('0x2b')]);return logger[_0x51c875('0x68')](_0x51c875('0x43'),_0x2e115f,_0x54026e[_0x51c875('0x68')][_0x51c875('0x2b')]),_0x1f7d66(_0x54026e['error']['message']);}else logger[_0x51c875('0x16')](_0x51c875('0x43'),_0x2e115f,_0x51c875('0x4c')),_0x1f7d66(_0x54026e['result'][_0x51c875('0x2b')]);})[_0x5e7815('0x35')](function(_0x53aa82){const _0x3e0ff7=_0x5e7815;logger[_0x3e0ff7('0x68')](_0x3e0ff7('0x43'),_0x2e115f,_0x53aa82),_0xb3b9f(_0x53aa82);});});}function respondWithStatusCode(_0x1a5fca,_0x109e7e){return _0x109e7e=_0x109e7e||0xcc,function(_0x398b38){const _0x442909=a468_0x468d;if(_0x398b38)return _0x1a5fca[_0x442909('0xe')](_0x109e7e);return _0x1a5fca['status'](_0x109e7e)['end']();};}function respondWithResult(_0x1b41ab,_0x483e6f){return _0x483e6f=_0x483e6f||0xc8,function(_0x33be84){const _0x3818dd=a468_0x468d;if(_0x33be84)return _0x1b41ab[_0x3818dd('0x90')](_0x483e6f)[_0x3818dd('0xf')](_0x33be84);};}function respondWithFilteredResult(_0x5a91c2,_0x3085cc){return function(_0x2072a1){const _0xdac569=a468_0x468d;if(_0x2072a1){const _0x74541a=_0x2072a1[_0xdac569('0x91')],_0x4cc717=_0x3085cc[_0xdac569('0xb')];let _0x31e905=_0x3085cc[_0xdac569('0xb')]+_0x3085cc['limit'],_0x402a97;return _0x31e905>=_0x74541a?(_0x31e905=_0x74541a,_0x402a97=0xc8):_0x402a97=0xce,_0x5a91c2[_0xdac569('0x90')](_0x402a97),_0x5a91c2[_0xdac569('0x3c')]('Content-Range',_0x4cc717+'-'+_0x31e905+'/'+_0x74541a)['json'](_0x2072a1);}return null;};}function saveUpdates(_0x16fe39){return function(_0x232f53){const _0x476fe1=a468_0x468d;if(_0x232f53)return _0x232f53[_0x476fe1('0x49')](_0x16fe39)[_0x476fe1('0x46')](function(_0x12ac38){return _0x12ac38;});return null;};}function removeEntity(_0x1a2ea){return function(_0x2cf846){const _0x4cc904=a468_0x468d;if(_0x2cf846)return _0x2cf846[_0x4cc904('0x18')]()[_0x4cc904('0x46')](function(){const _0x41b0ae=_0x4cc904,_0x59c1dd=_0x2cf846[_0x41b0ae('0x4f')]({'plain':!![]}),_0x3ffe06=_0x41b0ae('0x29');return db[_0x41b0ae('0x81')][_0x41b0ae('0x18')]({'where':{'type':_0x3ffe06,'resourceId':_0x59c1dd['id']}})[_0x41b0ae('0x46')](function(){return _0x2cf846;});})[_0x4cc904('0x46')](function(){const _0x56d34e=_0x4cc904;_0x1a2ea[_0x56d34e('0x90')](0xcc)[_0x56d34e('0x3d')]();});};}function handleEntityNotFound(_0x2c192a){return function(_0x1ca886){const _0x4d3737=a468_0x468d;return!_0x1ca886&&_0x2c192a[_0x4d3737('0xe')](0x194),_0x1ca886;};}function handleError(_0x5c6e40,_0x2c77f4){return _0x2c77f4=_0x2c77f4||0x1f4,function(_0x4c032e){const _0x526733=a468_0x468d;logger[_0x526733('0x68')](_0x4c032e[_0x526733('0x21')]),_0x4c032e[_0x526733('0x15')]&&delete _0x4c032e[_0x526733('0x15')],_0x5c6e40['status'](_0x2c77f4)[_0x526733('0x65')](_0x4c032e);};}exports['index']=function(_0x4a42d2,_0x309ce3){const _0x25b110=_0x203747;let _0xb0c483={'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]};const _0x533099={},_0xc9b5e0={'count':0x0,'rows':[]},_0x3a19d8=_[_0x25b110('0x4d')](db[_0x25b110('0x3a')][_0x25b110('0x6e')],function(_0x16342b){const _0x57ffa0=_0x25b110;return{'name':_0x16342b[_0x57ffa0('0x62')],'type':_0x16342b[_0x57ffa0('0x8c')]['key']};});_0x533099[_0x25b110('0x8e')]=_[_0x25b110('0x4d')](_0x3a19d8,_0x25b110('0x15')),_0x533099[_0x25b110('0xc')]=_[_0x25b110('0x8b')](_0x4a42d2[_0x25b110('0xc')]),_0x533099['filters']=_[_0x25b110('0x47')](_0x533099['model'],_0x533099[_0x25b110('0xc')]),_0xb0c483['attributes']=_[_0x25b110('0x47')](_0x533099[_0x25b110('0x8e')],qs['fields'](_0x4a42d2[_0x25b110('0xc')][_0x25b110('0x2a')])),_0xb0c483[_0x25b110('0x6')]=_0xb0c483[_0x25b110('0x6')][_0x25b110('0x78')]?_0xb0c483['attributes']:_0x533099[_0x25b110('0x8e')];typeof _0x4a42d2[_0x25b110('0xc')]['nolimit']===_0x25b110('0x0')&&(_0xb0c483[_0x25b110('0x1c')]=qs[_0x25b110('0x1c')](_0x4a42d2['query']['limit']),_0xb0c483[_0x25b110('0xb')]=qs[_0x25b110('0xb')](_0x4a42d2[_0x25b110('0xc')][_0x25b110('0xb')]));_0xb0c483['order']=qs['sort'](_0x4a42d2[_0x25b110('0xc')]['sort']),_0xb0c483[_0x25b110('0x26')]=qs['filters'](_[_0x25b110('0x10')](_0x4a42d2[_0x25b110('0xc')],_0x533099[_0x25b110('0x92')]),_0x3a19d8);_0x4a42d2['query']['filter']&&(_0xb0c483[_0x25b110('0x26')]=_[_0x25b110('0x9')](_0xb0c483[_0x25b110('0x26')],{[Op['or']]:_[_0x25b110('0x4d')](_0x3a19d8,function(_0xcb3740){const _0x31c413=_0x25b110;if(_0xcb3740[_0x31c413('0x8c')]!==_0x31c413('0x11')){const _0x373a4d={};return _0x373a4d[_0xcb3740[_0x31c413('0x15')]]={[Op[_0x31c413('0x27')]]:'%'+_0x4a42d2['query'][_0x31c413('0x1d')]+'%'},_0x373a4d;}})}));_0xb0c483=_['merge']({},_0xb0c483,_0x4a42d2[_0x25b110('0x33')]);const _0x5e1030={'where':_0xb0c483['where']};return db[_0x25b110('0x3a')][_0x25b110('0x91')](_0x5e1030)[_0x25b110('0x46')](function(_0x18b671){const _0x2f8b7a=_0x25b110;return _0xc9b5e0[_0x2f8b7a('0x91')]=_0x18b671,_0x4a42d2[_0x2f8b7a('0xc')][_0x2f8b7a('0x36')]&&(_0xb0c483[_0x2f8b7a('0x97')]=[{'all':!![]}]),db['OpenchannelAccount'][_0x2f8b7a('0x6f')](_0xb0c483);})[_0x25b110('0x46')](function(_0x559b16){const _0x1da389=_0x25b110;return _0xc9b5e0[_0x1da389('0x57')]=_0x559b16,_0xc9b5e0;})[_0x25b110('0x46')](respondWithFilteredResult(_0x309ce3,_0xb0c483))[_0x25b110('0x35')](handleError(_0x309ce3,null));},exports['show']=function(_0x48fa5d,_0xa8d6b0){const _0x4e7c4d=_0x203747;let _0x4801f3={'raw':![],'where':{'id':_0x48fa5d['params']['id']},'include':[{'model':db[_0x4e7c4d('0x2e')],'as':_0x4e7c4d('0x83')}]};const _0x2aae48={};return _0x2aae48[_0x4e7c4d('0x8e')]=_[_0x4e7c4d('0x8b')](db[_0x4e7c4d('0x3a')][_0x4e7c4d('0x6e')]),_0x2aae48[_0x4e7c4d('0xc')]=_[_0x4e7c4d('0x8b')](_0x48fa5d[_0x4e7c4d('0xc')]),_0x2aae48['filters']=_['intersection'](_0x2aae48[_0x4e7c4d('0x8e')],_0x2aae48[_0x4e7c4d('0xc')]),_0x4801f3[_0x4e7c4d('0x6')]=_[_0x4e7c4d('0x47')](_0x2aae48[_0x4e7c4d('0x8e')],qs[_0x4e7c4d('0x2a')](_0x48fa5d[_0x4e7c4d('0xc')][_0x4e7c4d('0x2a')])),_0x4801f3[_0x4e7c4d('0x6')]=_0x4801f3['attributes'][_0x4e7c4d('0x78')]?_0x4801f3[_0x4e7c4d('0x6')]:_0x2aae48['model'],_0x48fa5d[_0x4e7c4d('0xc')][_0x4e7c4d('0x36')]&&(_0x4801f3[_0x4e7c4d('0x97')]=[{'all':!![]}]),_0x4801f3=_[_0x4e7c4d('0x9')]({},_0x4801f3,_0x48fa5d[_0x4e7c4d('0x33')]),db[_0x4e7c4d('0x3a')][_0x4e7c4d('0x7f')](_0x4801f3)['then'](handleEntityNotFound(_0xa8d6b0,null))[_0x4e7c4d('0x46')](respondWithResult(_0xa8d6b0,null))[_0x4e7c4d('0x35')](handleError(_0xa8d6b0,null));},exports['create']=function(_0xc69165,_0x1674dc){const _0x3cff8c=_0x203747;return db[_0x3cff8c('0x3a')]['create'](_0xc69165[_0x3cff8c('0x8a')],{})[_0x3cff8c('0x46')](function(_0x3afaec){const _0x35ad0e=_0x3cff8c,_0x4b06ab=_0xc69165[_0x35ad0e('0x3')][_0x35ad0e('0x4f')]({'plain':!![]});if(!_0x4b06ab)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4b06ab[_0x35ad0e('0x98')]===_0x35ad0e('0x3')){const _0x110498=_0x3afaec['get']({'plain':!![]}),_0x5db0af=_0x35ad0e('0x29');return db['UserProfileSection'][_0x35ad0e('0x7f')]({'where':{'name':_0x5db0af,'userProfileId':_0x4b06ab[_0x35ad0e('0x7c')]},'raw':!![]})[_0x35ad0e('0x46')](function(_0x7654be){const _0x1ae6d9=_0x35ad0e;return _0x7654be&&_0x7654be[_0x1ae6d9('0x23')]===0x0?db['UserProfileResource'][_0x1ae6d9('0x39')]({'name':_0x110498[_0x1ae6d9('0x15')],'resourceId':_0x110498['id'],'type':_0x7654be[_0x1ae6d9('0x15')],'sectionId':_0x7654be['id']},{})[_0x1ae6d9('0x46')](function(){return _0x3afaec;}):_0x3afaec;})['catch'](function(_0x52c0d0){const _0x493fbd=_0x35ad0e;logger['error'](_0x493fbd('0x3f'),_0x52c0d0);throw _0x52c0d0;});}return _0x3afaec;})['then'](respondWithResult(_0x1674dc,0xc9))[_0x3cff8c('0x35')](handleError(_0x1674dc,null));},exports[_0x203747('0x49')]=function(_0x583dfd,_0x41d923){const _0x815c71=_0x203747;return _0x583dfd[_0x815c71('0x8a')]['id']&&delete _0x583dfd[_0x815c71('0x8a')]['id'],db[_0x815c71('0x3a')][_0x815c71('0x7f')]({'where':{'id':_0x583dfd[_0x815c71('0x66')]['id']},'include':[{'model':db[_0x815c71('0x2e')],'as':'mandatoryDispositionPause'}]})['then'](handleEntityNotFound(_0x41d923,null))[_0x815c71('0x46')](saveUpdates(_0x583dfd['body'],null))[_0x815c71('0x46')](respondWithResult(_0x41d923,null))[_0x815c71('0x35')](handleError(_0x41d923,null));},exports[_0x203747('0x18')]=function(_0x4b5a4d,_0x34a821){const _0x5bb59e=_0x203747;return db['OpenchannelAccount'][_0x5bb59e('0x7f')]({'where':{'id':_0x4b5a4d[_0x5bb59e('0x66')]['id']}})[_0x5bb59e('0x46')](handleEntityNotFound(_0x34a821,null))[_0x5bb59e('0x46')](removeEntity(_0x34a821,null))[_0x5bb59e('0x35')](handleError(_0x34a821,null));},exports[_0x203747('0x24')]=function(_0x183ba8,_0x41d05a){const _0x224f4b=_0x203747;return db['OpenchannelAccount'][_0x224f4b('0x24')]()['then'](respondWithResult(_0x41d05a,null))[_0x224f4b('0x35')](handleError(_0x41d05a,null));},exports[_0x203747('0x32')]=function(_0xbf1970,_0x3de8ff){const _0x3f3644=_0x203747;return _0xbf1970[_0x3f3644('0x8a')]['id']&&delete _0xbf1970[_0x3f3644('0x8a')]['id'],db[_0x3f3644('0x3a')][_0x3f3644('0x7f')]({'where':{'id':_0xbf1970[_0x3f3644('0x66')]['id']}})['then'](handleEntityNotFound(_0x3de8ff,null))[_0x3f3644('0x46')](function(_0x1906c5){const _0x486218=_0x3f3644;if(_0x1906c5)return _0xbf1970[_0x486218('0x8a')][_0x486218('0x69')]=_0x1906c5['id'],db[_0x486218('0x8')][_0x486218('0x39')](_0xbf1970[_0x486218('0x8a')]);})['then'](respondWithResult(_0x3de8ff,null))[_0x3f3644('0x35')](handleError(_0x3de8ff,null));},exports[_0x203747('0x34')]=function(_0x494929,_0x2e604d){const _0x10ab5c=_0x203747;let _0x2a7112={'raw':![],'where':{}};const _0x178ac4={},_0x59ac88={'count':0x0,'rows':[]};return db[_0x10ab5c('0x3a')][_0x10ab5c('0x7f')]({'where':{'id':_0x494929['params']['id']}})[_0x10ab5c('0x46')](handleEntityNotFound(_0x2e604d,null))[_0x10ab5c('0x46')](function(_0x48ca63){const _0x5b33cc=_0x10ab5c;if(_0x48ca63)return _0x178ac4[_0x5b33cc('0x8e')]=_[_0x5b33cc('0x8b')](db[_0x5b33cc('0x8')][_0x5b33cc('0x6e')]),_0x178ac4[_0x5b33cc('0xc')]=_['keys'](_0x494929[_0x5b33cc('0xc')]),_0x178ac4['filters']=_[_0x5b33cc('0x47')](_0x178ac4['model'],_0x178ac4['query']),_0x2a7112[_0x5b33cc('0x6')]=_[_0x5b33cc('0x47')](_0x178ac4[_0x5b33cc('0x8e')],qs['fields'](_0x494929[_0x5b33cc('0xc')][_0x5b33cc('0x2a')])),_0x2a7112[_0x5b33cc('0x6')]=_0x2a7112[_0x5b33cc('0x6')][_0x5b33cc('0x78')]?_0x2a7112['attributes']:_0x178ac4[_0x5b33cc('0x8e')],typeof _0x494929[_0x5b33cc('0xc')][_0x5b33cc('0x56')]==='undefined'&&(_0x2a7112[_0x5b33cc('0x1c')]=qs[_0x5b33cc('0x1c')](_0x494929[_0x5b33cc('0xc')][_0x5b33cc('0x1c')]),_0x2a7112['offset']=qs[_0x5b33cc('0xb')](_0x494929[_0x5b33cc('0xc')]['offset'])),_0x2a7112[_0x5b33cc('0x2f')]=qs[_0x5b33cc('0x61')](_0x494929[_0x5b33cc('0xc')]['sort']),_0x2a7112[_0x5b33cc('0x26')]=qs[_0x5b33cc('0x92')](_['pick'](_0x494929[_0x5b33cc('0xc')],_0x178ac4['filters'])),_0x2a7112[_0x5b33cc('0x26')]['OpenchannelAccountId']=_0x48ca63['id'],_0x494929[_0x5b33cc('0xc')][_0x5b33cc('0x1d')]&&(_0x2a7112[_0x5b33cc('0x26')]=_[_0x5b33cc('0x9')](_0x2a7112[_0x5b33cc('0x26')],{[Op['or']]:_[_0x5b33cc('0x4d')](_0x2a7112[_0x5b33cc('0x6')],function(_0x4fb78d){const _0x583a8a=_0x5b33cc,_0x492b67={};return _0x492b67[_0x4fb78d]={[Op['like']]:'%'+_0x494929['query'][_0x583a8a('0x1d')]+'%'},_0x492b67;})})),_0x2a7112=_['merge']({},_0x2a7112,_0x494929[_0x5b33cc('0x33')]),db['Disposition'][_0x5b33cc('0x91')]({'where':_0x2a7112[_0x5b33cc('0x26')]})['then'](function(_0x41fb86){const _0x52aa09=_0x5b33cc;return _0x59ac88[_0x52aa09('0x91')]=_0x41fb86,_0x494929[_0x52aa09('0xc')][_0x52aa09('0x36')]&&(_0x2a7112['include']=[{'all':!![]}]),db[_0x52aa09('0x8')][_0x52aa09('0x6f')](_0x2a7112);})['then'](function(_0x37e702){const _0x261783=_0x5b33cc;return _0x59ac88[_0x261783('0x57')]=_0x37e702,_0x59ac88;});})['then'](respondWithFilteredResult(_0x2e604d,_0x2a7112))['catch'](handleError(_0x2e604d,null));},exports[_0x203747('0x4')]=function(_0x13368d,_0x5f02e0){const _0x4257fc=_0x203747;return db[_0x4257fc('0x3a')]['findOne']({'where':{'id':_0x13368d[_0x4257fc('0x66')]['id']}})[_0x4257fc('0x46')](handleEntityNotFound(_0x5f02e0,null))['then'](function(_0x1f762b){const _0x11a295=_0x4257fc;if(_0x1f762b)return _0x1f762b[_0x11a295('0x4')](_0x13368d[_0x11a295('0xc')][_0x11a295('0x87')]);})[_0x4257fc('0x46')](respondWithStatusCode(_0x5f02e0,null))[_0x4257fc('0x35')](handleError(_0x5f02e0,null));},exports[_0x203747('0x2d')]=function(_0x5e77ee,_0x4389e9){const _0x100201=_0x203747;return _0x5e77ee[_0x100201('0x8a')]['id']&&delete _0x5e77ee[_0x100201('0x8a')]['id'],db[_0x100201('0x3a')][_0x100201('0x7f')]({'where':{'id':_0x5e77ee['params']['id']}})[_0x100201('0x46')](handleEntityNotFound(_0x4389e9,null))[_0x100201('0x46')](function(_0x5ba1b1){const _0x3fa64f=_0x100201;if(_0x5ba1b1)return _0x5e77ee[_0x3fa64f('0x8a')][_0x3fa64f('0x69')]=_0x5ba1b1['id'],db[_0x3fa64f('0x19')][_0x3fa64f('0x39')](_0x5e77ee[_0x3fa64f('0x8a')]);})[_0x100201('0x46')](respondWithResult(_0x4389e9,null))['catch'](handleError(_0x4389e9,null));},exports[_0x203747('0x50')]=function(_0x51dd0a,_0x182002){const _0x4278f9=_0x203747;let _0xf9963e={'raw':![],'where':{}};const _0x12cadf={},_0x570f46={'count':0x0,'rows':[]};return db[_0x4278f9('0x3a')][_0x4278f9('0x7f')]({'where':{'id':_0x51dd0a['params']['id']}})[_0x4278f9('0x46')](handleEntityNotFound(_0x182002,null))['then'](function(_0xe4026a){const _0x1c8eaf=_0x4278f9;if(_0xe4026a)return _0x12cadf[_0x1c8eaf('0x8e')]=_[_0x1c8eaf('0x8b')](db[_0x1c8eaf('0x19')][_0x1c8eaf('0x6e')]),_0x12cadf['query']=_[_0x1c8eaf('0x8b')](_0x51dd0a[_0x1c8eaf('0xc')]),_0x12cadf[_0x1c8eaf('0x92')]=_[_0x1c8eaf('0x47')](_0x12cadf[_0x1c8eaf('0x8e')],_0x12cadf['query']),_0xf9963e[_0x1c8eaf('0x6')]=_['intersection'](_0x12cadf['model'],qs[_0x1c8eaf('0x2a')](_0x51dd0a['query'][_0x1c8eaf('0x2a')])),_0xf9963e['attributes']=_0xf9963e[_0x1c8eaf('0x6')][_0x1c8eaf('0x78')]?_0xf9963e[_0x1c8eaf('0x6')]:_0x12cadf[_0x1c8eaf('0x8e')],typeof _0x51dd0a[_0x1c8eaf('0xc')][_0x1c8eaf('0x56')]==='undefined'&&(_0xf9963e['limit']=qs[_0x1c8eaf('0x1c')](_0x51dd0a[_0x1c8eaf('0xc')][_0x1c8eaf('0x1c')]),_0xf9963e[_0x1c8eaf('0xb')]=qs[_0x1c8eaf('0xb')](_0x51dd0a[_0x1c8eaf('0xc')][_0x1c8eaf('0xb')])),_0xf9963e[_0x1c8eaf('0x2f')]=qs[_0x1c8eaf('0x61')](_0x51dd0a['query'][_0x1c8eaf('0x61')]),_0xf9963e[_0x1c8eaf('0x26')]=qs['filters'](_[_0x1c8eaf('0x10')](_0x51dd0a['query'],_0x12cadf['filters'])),_0xf9963e[_0x1c8eaf('0x26')][_0x1c8eaf('0x69')]=_0xe4026a['id'],_0x51dd0a[_0x1c8eaf('0xc')][_0x1c8eaf('0x1d')]&&(_0xf9963e[_0x1c8eaf('0x26')]=_['merge'](_0xf9963e['where'],{[Op['or']]:_['map'](_0xf9963e[_0x1c8eaf('0x6')],function(_0x1a5152){const _0x5557f4=_0x1c8eaf,_0x70b840={};return _0x70b840[_0x1a5152]={[Op['like']]:'%'+_0x51dd0a[_0x5557f4('0xc')][_0x5557f4('0x1d')]+'%'},_0x70b840;})})),_0xf9963e=_[_0x1c8eaf('0x9')]({},_0xf9963e,_0x51dd0a[_0x1c8eaf('0x33')]),db[_0x1c8eaf('0x19')][_0x1c8eaf('0x91')]({'where':_0xf9963e[_0x1c8eaf('0x26')]})['then'](function(_0x45c4fe){const _0x37949b=_0x1c8eaf;return _0x570f46[_0x37949b('0x91')]=_0x45c4fe,_0x51dd0a[_0x37949b('0xc')][_0x37949b('0x36')]&&(_0xf9963e[_0x37949b('0x97')]=[{'all':!![]}]),db[_0x37949b('0x19')][_0x37949b('0x6f')](_0xf9963e);})[_0x1c8eaf('0x46')](function(_0x1dadb8){const _0x2ee5cf=_0x1c8eaf;return _0x570f46[_0x2ee5cf('0x57')]=_0x1dadb8,_0x570f46;});})['then'](respondWithFilteredResult(_0x182002,_0xf9963e))[_0x4278f9('0x35')](handleError(_0x182002,null));},exports[_0x203747('0x45')]=function(_0x4910e1,_0x1af244){const _0x293704=_0x203747;return db[_0x293704('0x3a')][_0x293704('0x7f')]({'where':{'id':_0x4910e1[_0x293704('0x66')]['id']}})[_0x293704('0x46')](handleEntityNotFound(_0x1af244,null))['then'](function(_0xb9d806){const _0x537271=_0x293704;if(_0xb9d806)return _0xb9d806['removeAnswers'](_0x4910e1[_0x537271('0xc')][_0x537271('0x87')]);})['then'](respondWithStatusCode(_0x1af244,null))[_0x293704('0x35')](handleError(_0x1af244,null));},exports[_0x203747('0x3b')]=function(_0x431d9c,_0x66cd9){const _0x51407b=_0x203747,_0x15e2ba={'body':_0x431d9c['body'],'channel':_0x51407b('0x67')};let _0x2efcf7=[],_0x91e428=[];const _0x2b4bb7={};let _0x4cb4b2=![];return db[_0x51407b('0x7e')][_0x51407b('0x24')]()[_0x51407b('0x46')](function(_0x5ad41a){const _0x1c8381=_0x51407b;if(!_0x5ad41a)throw new db[(_0x1c8381('0x82'))]['ValidationError']('no\x20available\x20attributes');_0x2efcf7=_[_0x1c8381('0x12')](_[_0x1c8381('0x8b')](_0x5ad41a),[_0x1c8381('0x31'),_0x1c8381('0x70')]),_0x91e428=_[_0x1c8381('0x12')](_['keys'](_0x5ad41a),[_0x1c8381('0x31'),_0x1c8381('0x70'),_0x1c8381('0x93'),_0x1c8381('0x8f')]);_0x431d9c[_0x1c8381('0x8a')]['id']&&delete _0x431d9c['body']['id'];if(_['isNil'](_0x431d9c[_0x1c8381('0x8a')][_0x1c8381('0x94')]))throw new db[(_0x1c8381('0x82'))]['ValidationError'](_0x1c8381('0xd'));if(_[_0x1c8381('0x5d')](_0x431d9c[_0x1c8381('0x8a')][_0x1c8381('0x8a')])||_0x431d9c[_0x1c8381('0x8a')][_0x1c8381('0x8a')]==='')throw new db[(_0x1c8381('0x82'))][(_0x1c8381('0x7a'))](_0x1c8381('0x7d'));if(_[_0x1c8381('0x5d')](_0x431d9c[_0x1c8381('0x8a')][_0x1c8381('0x80')]))throw new db[(_0x1c8381('0x82'))][(_0x1c8381('0x7a'))](_0x1c8381('0x5a')+_0x91e428);if(!_['includes'](_0x91e428,_0x431d9c['body'][_0x1c8381('0x80')]))throw new db[(_0x1c8381('0x82'))][(_0x1c8381('0x7a'))](_0x1c8381('0x7b')+_0x91e428);_0x2b4bb7[_0x431d9c[_0x1c8381('0x8a')][_0x1c8381('0x80')]]=_0x431d9c['body'][_0x1c8381('0x94')];})['then'](function(){const _0x2c6106=_0x51407b;return db['OpenchannelAccount']['findOne']({'where':{'id':_0x431d9c['params']['id']},'include':[{'model':db['CmList'],'as':_0x2c6106('0x74'),'include':[{'model':db['CmContact'],'as':_0x2c6106('0x22'),'where':_0x2b4bb7,'limit':0x1,'order':[[_0x2c6106('0x70'),'DESC']]}]},{'model':db[_0x2c6106('0x99')],'as':'Applications'}]});})[_0x51407b('0x46')](handleEntityNotFound(_0x66cd9,null))[_0x51407b('0x46')](function(_0x520590){const _0xcf88fd=_0x51407b;if(_0x520590&&_0x520590['List']){_0x15e2ba[_0xcf88fd('0x75')]=_0x520590,_0x15e2ba[_0xcf88fd('0x53')]=_0x520590['Applications'],_0x15e2ba['list']=_0x520590[_0xcf88fd('0x74')],_0x15e2ba[_0xcf88fd('0x53')]=_['orderBy'](_0x15e2ba[_0xcf88fd('0x53')],['priority'],['asc']);_0x15e2ba[_0xcf88fd('0x75')][_0xcf88fd('0x86')]&&delete _0x15e2ba[_0xcf88fd('0x75')][_0xcf88fd('0x86')];if(_0x15e2ba[_0xcf88fd('0x75')][_0xcf88fd('0x74')]&&_0x15e2ba[_0xcf88fd('0x75')][_0xcf88fd('0x74')][_0xcf88fd('0x22')][_0xcf88fd('0x78')])return _0x15e2ba[_0xcf88fd('0x75')]['List'][_0xcf88fd('0x22')][0x0];const _0x236675=_['defaults'](_0x431d9c['body'],{'firstName':_0x431d9c[_0xcf88fd('0x8a')][_0xcf88fd('0x94')],'ListId':_0x520590[_0xcf88fd('0x8f')]});return _0x236675[_0x431d9c[_0xcf88fd('0x8a')][_0xcf88fd('0x80')]]=_0x431d9c['body'][_0xcf88fd('0x94')],db['CmContact'][_0xcf88fd('0x39')](_0x236675,{'fields':_0x2efcf7,'raw':!![]});}})[_0x51407b('0x46')](handleEntityNotFound(_0x66cd9,null))[_0x51407b('0x46')](function(_0x13cf13){const _0x32b9ad=_0x51407b;_0x15e2ba[_0x32b9ad('0x6d')]=_0x13cf13;if(_0x13cf13){const _0x52489b={'ContactId':_0x13cf13['id'],'OpenchannelAccountId':_0x431d9c['params']['id'],'from':(_0x13cf13[_0x32b9ad('0x14')]||'')+'\x20'+(_0x13cf13['lastName']||'')},_0x517505={'OpenchannelAccountId':_0x431d9c[_0x32b9ad('0x66')]['id'],'closed':![]};if(_0x431d9c[_0x32b9ad('0x8a')]['threadId'])return _0x517505[_0x32b9ad('0x1')]=_0x431d9c[_0x32b9ad('0x8a')][_0x32b9ad('0x1')],db[_0x32b9ad('0x88')][_0x32b9ad('0x7f')]({'where':_0x517505})[_0x32b9ad('0x46')](function(_0x48a202){const _0x33a181=_0x32b9ad;if(_0x48a202)return[_0x48a202,![]];return _0x52489b[_0x33a181('0x1')]=_0x431d9c['body'][_0x33a181('0x1')],_0x52489b[_0x33a181('0x44')]=_0x431d9c['body']['externalUrl'],db['OpenchannelInteraction'][_0x33a181('0x39')](_0x52489b)[_0x33a181('0x46')](function(_0x17f8ce){return[_0x17f8ce,!![]];});});else _0x517505[_0x32b9ad('0x1')]=null;return _0x517505['ContactId']=_0x13cf13['id'],db[_0x32b9ad('0x88')]['findOne']({'where':_0x517505})[_0x32b9ad('0x46')](function(_0x40bb0f){const _0x349e55=_0x32b9ad;if(_0x40bb0f)return[_0x40bb0f,![]];return db[_0x349e55('0x88')][_0x349e55('0x39')](_0x52489b)['then'](function(_0xd52c14){return[_0xd52c14,!![]];});});}})['then'](function([_0x4ec62f,_0x4582e7]){const _0x40b13f=_0x51407b;if(_0x4ec62f){_0x4cb4b2=_0x4582e7;if(!_0x4582e7){const _0xe3f789={'from':(_0x15e2ba['contact'][_0x40b13f('0x14')]||'')+'\x20'+(_0x15e2ba[_0x40b13f('0x6d')][_0x40b13f('0x1a')]||'')};return _0x431d9c[_0x40b13f('0x8a')][_0x40b13f('0x1')]&&_0x431d9c[_0x40b13f('0x8a')][_0x40b13f('0x25')]&&_0x431d9c[_0x40b13f('0x8a')][_0x40b13f('0x1')]!=_0x431d9c[_0x40b13f('0x8a')]['messageId']&&(_0xe3f789[_0x40b13f('0x1')]=_0x431d9c[_0x40b13f('0x8a')][_0x40b13f('0x25')]),_0x4ec62f[_0x40b13f('0x49')](_0xe3f789);}else return _0x4ec62f;}})[_0x51407b('0x46')](function(_0x1db19c){const _0x122242=_0x51407b;return _0x15e2ba['interaction']=_0x1db19c[_0x122242('0x4f')]({'plain':!![]}),_0x15e2ba['interaction'][_0x122242('0x2')]=_0x4cb4b2,_0x15e2ba['interaction'][_0x122242('0x2')]&&(_0x15e2ba[_0x122242('0x75')][_0x122242('0x76')]&&_0x15e2ba[_0x122242('0x53')][_0x122242('0x84')]({'id':0x0,'priority':_0x15e2ba[_0x122242('0x53')][_0x122242('0x78')]+0x1,'app':_0x122242('0x41'),'appdata':_0x122242('0x30'),'interval':_0x122242('0x1e')})),db[_0x122242('0xa')][_0x122242('0x39')]({'body':_0x431d9c[_0x122242('0x8a')][_0x122242('0x8a')],'OpenchannelAccountId':_0x431d9c[_0x122242('0x66')]['id'],'OpenchannelInteractionId':_0x1db19c['id'],'direction':'in','ContactId':_0x15e2ba[_0x122242('0x6d')]['id'],'AttachmentId':_0x431d9c[_0x122242('0x8a')][_0x122242('0x6b')]});})[_0x51407b('0x46')](function(_0x1a6c74){const _0x542466=_0x51407b;_0x15e2ba[_0x542466('0x2b')]=_0x1a6c74;if(_0x15e2ba[_0x542466('0x7')]['UserId'])return db[_0x542466('0x64')][_0x542466('0x7f')]({'attributes':['id',_0x542466('0x15')],'where':{'id':_0x15e2ba['interaction'][_0x542466('0x5c')]}})['then'](function(_0x5f300d){const _0x49c7b4=_0x542466;return _0x5f300d&&(_0x15e2ba[_0x49c7b4('0x53')]['unshift']({'id':0x0,'priority':0x0,'app':_0x49c7b4('0x8d'),'appdata':_0x5f300d['name']+','+(_0x15e2ba['account']['waitForTheAssignedAgent']||0xa),'interval':_0x49c7b4('0x1e')}),_0x15e2ba[_0x49c7b4('0x17')]=![]),respondWithRpcPromise(_0x49c7b4('0x1b'),_0x49c7b4('0x73'),_0x15e2ba);});return respondWithRpcPromise('Start','startRouting',_0x15e2ba);})[_0x51407b('0x46')](function(_0x5e7591){const _0x2c89b6=_0x51407b;return respondWithRpcPromise(_0x2c89b6('0x4e'),'EventManager',{'event':_0x2c89b6('0x3b'),'message':_0x5e7591},client9002),_0x5e7591;})[_0x51407b('0x46')](respondWithResult(_0x66cd9,null))[_0x51407b('0x35')](handleError(_0x66cd9,null));},exports['addApplications']=function(_0x460318,_0x4dd177){const _0x41c90f=_0x203747;return db[_0x41c90f('0x3a')][_0x41c90f('0x7f')]({'where':{'id':_0x460318['params']['id']}})[_0x41c90f('0x46')](handleEntityNotFound(_0x4dd177,null))[_0x41c90f('0x46')](function(_0x437183){const _0xeef404=_0x41c90f;if(_0x437183)return db[_0xeef404('0x3e')][_0xeef404('0x5e')](function(_0x3f5dd9){const _0x5d1546=_0xeef404;return db[_0x5d1546('0x99')][_0x5d1546('0x18')]({'where':{'OpenchannelAccountId':_0x460318[_0x5d1546('0x66')]['id']},'transaction':_0x3f5dd9})[_0x5d1546('0x46')](function(){const _0xbf5284=_0x5d1546,_0x59f1db=_['map'](_0x460318[_0xbf5284('0x8a')],function(_0x2d996f){const _0x4aab18=_0xbf5284;return _0x2d996f[_0x4aab18('0x69')]=_0x460318['params']['id'],_0x2d996f;});return db[_0xbf5284('0x99')]['bulkCreate'](_0x59f1db,{'transaction':_0x3f5dd9});});})[_0xeef404('0x46')](function(){const _0x358317=_0xeef404;return db[_0x358317('0x99')][_0x358317('0x77')]({'where':{'OpenchannelAccountId':_0x460318[_0x358317('0x66')]['id']},'order':_0x358317('0x52')});});})[_0x41c90f('0x46')](respondWithResult(_0x4dd177,null))[_0x41c90f('0x35')](handleError(_0x4dd177,null));},exports[_0x203747('0x58')]=function(_0x131f81,_0x400864){const _0x7611ee=_0x203747;let _0x11db40={};const _0x414538={};let _0x1fb899,_0xfe962;return db[_0x7611ee('0x3a')]['findOne']({'where':{'id':_0x131f81[_0x7611ee('0x66')]['id']}})[_0x7611ee('0x46')](handleEntityNotFound(_0x400864,null))[_0x7611ee('0x46')](function(_0x10e307){const _0x247b4c=_0x7611ee;if(_0x10e307)return _0x1fb899=_0x10e307,_0x414538['model']=_['keys'](db['OpenchannelApplication']['rawAttributes']),_0x414538['query']=_['keys'](_0x131f81[_0x247b4c('0xc')]),_0x414538[_0x247b4c('0x92')]=_[_0x247b4c('0x47')](_0x414538[_0x247b4c('0x8e')],_0x414538['query']),_0x11db40[_0x247b4c('0x6')]=_['intersection'](_0x414538['model'],qs[_0x247b4c('0x2a')](_0x131f81[_0x247b4c('0xc')]['fields'])),_0x11db40[_0x247b4c('0x6')]=_0x11db40[_0x247b4c('0x6')][_0x247b4c('0x78')]?_0x11db40['attributes']:_0x414538['model'],_0x11db40[_0x247b4c('0x2f')]=qs['sort'](_0x131f81[_0x247b4c('0xc')]['sort']),_0x11db40[_0x247b4c('0x26')]=qs[_0x247b4c('0x92')](_[_0x247b4c('0x10')](_0x131f81[_0x247b4c('0xc')],_0x414538[_0x247b4c('0x92')])),_0x131f81['query'][_0x247b4c('0x1d')]&&(_0x11db40[_0x247b4c('0x26')]=_[_0x247b4c('0x9')](_0x11db40[_0x247b4c('0x26')],{[Op['or']]:_[_0x247b4c('0x4d')](_0x11db40[_0x247b4c('0x6')],function(_0x38b291){const _0xbe0311=_0x247b4c,_0x285b40={};return _0x285b40[_0x38b291]={[Op['like']]:'%'+_0x131f81[_0xbe0311('0xc')][_0xbe0311('0x1d')]+'%'},_0x285b40;})})),_0x11db40=_[_0x247b4c('0x9')]({},_0x11db40,_0x131f81['options']),_0x1fb899['getApplications'](_0x11db40);})[_0x7611ee('0x46')](function(_0x34bc09){const _0x138867=_0x7611ee;if(_0x34bc09)return _0xfe962=_0x34bc09[_0x138867('0x78')],typeof _0x131f81['query']['nolimit']==='undefined'&&(_0x11db40[_0x138867('0x1c')]=qs[_0x138867('0x1c')](_0x131f81[_0x138867('0xc')][_0x138867('0x1c')]),_0x11db40[_0x138867('0xb')]=qs[_0x138867('0xb')](_0x131f81[_0x138867('0xc')]['offset'])),_0x1fb899['getApplications'](_0x11db40);})[_0x7611ee('0x46')](function(_0x1fde95){if(_0x1fde95)return _0x1fde95?{'count':_0xfe962,'rows':_0x1fde95}:null;})['then'](respondWithResult(_0x400864,null))['catch'](handleError(_0x400864,null));},exports['getInteractions']=function(_0x29b178,_0x5d372b){const _0xe45de6=_0x203747;let _0x19753d={'raw':![],'where':{}};const _0x49c17f={},_0x41c1d7={'count':0x0,'rows':[]};return db[_0xe45de6('0x3a')][_0xe45de6('0x7f')]({'where':{'id':_0x29b178[_0xe45de6('0x66')]['id']}})[_0xe45de6('0x46')](handleEntityNotFound(_0x5d372b,null))[_0xe45de6('0x46')](function(_0x40e132){const _0xd824b=_0xe45de6;if(_0x40e132)return _0x49c17f[_0xd824b('0x8e')]=_[_0xd824b('0x8b')](db[_0xd824b('0x88')][_0xd824b('0x6e')]),_0x49c17f[_0xd824b('0xc')]=_['keys'](_0x29b178[_0xd824b('0xc')]),_0x49c17f[_0xd824b('0x92')]=_[_0xd824b('0x47')](_0x49c17f[_0xd824b('0x8e')],_0x49c17f[_0xd824b('0xc')]),_0x19753d[_0xd824b('0x6')]=_[_0xd824b('0x47')](_0x49c17f['model'],qs[_0xd824b('0x2a')](_0x29b178[_0xd824b('0xc')][_0xd824b('0x2a')])),_0x19753d['attributes']=_0x19753d['attributes'][_0xd824b('0x78')]?_0x19753d[_0xd824b('0x6')]:_0x49c17f[_0xd824b('0x8e')],typeof _0x29b178[_0xd824b('0xc')][_0xd824b('0x56')]==='undefined'&&(_0x19753d['limit']=qs['limit'](_0x29b178[_0xd824b('0xc')][_0xd824b('0x1c')]),_0x19753d[_0xd824b('0xb')]=qs[_0xd824b('0xb')](_0x29b178[_0xd824b('0xc')][_0xd824b('0xb')])),_0x19753d[_0xd824b('0x2f')]=qs[_0xd824b('0x61')](_0x29b178['query'][_0xd824b('0x61')]),_0x19753d[_0xd824b('0x26')]=qs['filters'](_['pick'](_0x29b178[_0xd824b('0xc')],_0x49c17f['filters'])),_0x19753d[_0xd824b('0x26')][_0xd824b('0x69')]=_0x40e132['id'],_0x29b178[_0xd824b('0xc')][_0xd824b('0x1d')]&&(_0x19753d[_0xd824b('0x26')]=_[_0xd824b('0x9')](_0x19753d[_0xd824b('0x26')],{[Op['or']]:_[_0xd824b('0x4d')](_0x19753d[_0xd824b('0x6')],function(_0x448c44){const _0x2cb2f9=_0xd824b,_0x4bd24d={};return _0x4bd24d[_0x448c44]={[Op[_0x2cb2f9('0x27')]]:'%'+_0x29b178[_0x2cb2f9('0xc')][_0x2cb2f9('0x1d')]+'%'},_0x4bd24d;})})),_0x19753d=_[_0xd824b('0x9')]({},_0x19753d,_0x29b178['options']),db[_0xd824b('0x88')][_0xd824b('0x91')]({'where':_0x19753d[_0xd824b('0x26')]})[_0xd824b('0x46')](function(_0x410a50){const _0x2205d0=_0xd824b;return _0x41c1d7[_0x2205d0('0x91')]=_0x410a50,_0x29b178[_0x2205d0('0xc')][_0x2205d0('0x36')]&&(_0x19753d[_0x2205d0('0x97')]=[{'model':db[_0x2205d0('0x7e')],'as':_0x2205d0('0x28'),'required':![]},{'model':db['User'],'as':_0x2205d0('0x6a'),'attributes':[_0x2205d0('0x15'),_0x2205d0('0x40'),'internal'],'required':![]},{'model':db[_0x2205d0('0x1f')],'as':_0x2205d0('0x72'),'attributes':['id',_0x2205d0('0x15'),'color'],'where':_0x29b178[_0x2205d0('0xc')][_0x2205d0('0x95')]?{'id':_0x29b178[_0x2205d0('0xc')][_0x2205d0('0x95')]}:undefined,'required':_0x29b178['query'][_0x2205d0('0x95')]?!![]:![]}]),db[_0x2205d0('0x88')][_0x2205d0('0x6f')](_0x19753d);})['then'](function(_0x1f93dd){const _0x258067=_0xd824b;return _0x41c1d7[_0x258067('0x57')]=_0x1f93dd,_0x41c1d7;});})['then'](respondWithFilteredResult(_0x5d372b,_0x19753d))[_0xe45de6('0x35')](handleError(_0x5d372b,null));},exports[_0x203747('0x37')]=function(_0x3175da,_0x51bb79){const _0x48c3ba=_0x203747;return db[_0x48c3ba('0x3a')]['findOne']({'where':{'id':_0x3175da['params']['id']}})[_0x48c3ba('0x46')](function(_0x1c0ccb){const _0x10b06b=_0x48c3ba;if(_0x1c0ccb)return _0x1c0ccb[_0x10b06b('0x37')](_0x3175da[_0x10b06b('0x8a')][_0x10b06b('0x87')],{'through':_[_0x10b06b('0x4b')](_0x3175da[_0x10b06b('0x8a')],[_0x10b06b('0x87'),'id'])})[_0x10b06b('0x46')](function(_0x5beb52){const _0x10bba6=_0x10b06b;for(let _0x543acb=0x0;_0x543acb<_0x3175da['body'][_0x10bba6('0x87')]['length'];_0x543acb+=0x1){socket[_0x10bba6('0x13')](_0x10bba6('0x54'),{'UserId':_0x3175da[_0x10bba6('0x8a')][_0x10bba6('0x87')][_0x543acb],'OpenchannelAccountId':_0x3175da[_0x10bba6('0x66')]['id']});}return _0x5beb52;});})[_0x48c3ba('0x46')](respondWithResult(_0x51bb79,null))[_0x48c3ba('0x35')](handleError(_0x51bb79,null));},exports[_0x203747('0x20')]=function(_0xdff1a4,_0x3170ba){const _0x5262cd=_0x203747;return db[_0x5262cd('0x3a')]['findOne']({'where':{'id':_0xdff1a4[_0x5262cd('0x66')]['id']}})['then'](handleEntityNotFound(_0x3170ba,null))[_0x5262cd('0x46')](function(_0x2e2d62){const _0x277e32=_0x5262cd;if(_0x2e2d62)return _0x2e2d62[_0x277e32('0x20')](_0xdff1a4['query'][_0x277e32('0x87')])[_0x277e32('0x46')](function(){const _0x3c83b7=_0x277e32;if(_[_0x3c83b7('0x96')](_0xdff1a4[_0x3c83b7('0xc')][_0x3c83b7('0x87')]))for(let _0x5ec3cd=0x0;_0x5ec3cd<_0xdff1a4[_0x3c83b7('0xc')][_0x3c83b7('0x87')]['length'];_0x5ec3cd+=0x1){socket[_0x3c83b7('0x13')](_0x3c83b7('0x5f'),{'UserId':Number(_0xdff1a4[_0x3c83b7('0xc')][_0x3c83b7('0x87')][_0x5ec3cd]),'OpenchannelAccountId':Number(_0xdff1a4[_0x3c83b7('0x66')]['id'])});}else socket[_0x3c83b7('0x13')]('userOpenchannelAccount:remove',{'UserId':Number(_0xdff1a4[_0x3c83b7('0xc')][_0x3c83b7('0x87')]),'OpenchannelAccountId':Number(_0xdff1a4[_0x3c83b7('0x66')]['id'])});});})[_0x5262cd('0x46')](respondWithStatusCode(_0x3170ba,null))[_0x5262cd('0x35')](handleError(_0x3170ba,null));},exports[_0x203747('0x4a')]=function(_0x43442a,_0x3c44c7){const _0x411907=_0x203747;let _0x40e100={};const _0x51520d={};let _0x3000ea,_0x44954d;return db['OpenchannelAccount'][_0x411907('0x7f')]({'where':{'id':_0x43442a[_0x411907('0x66')]['id']}})[_0x411907('0x46')](handleEntityNotFound(_0x3c44c7,null))[_0x411907('0x46')](function(_0x518cdd){const _0x3d9a62=_0x411907;if(_0x518cdd)return _0x3000ea=_0x518cdd,_0x51520d[_0x3d9a62('0x8e')]=_['keys'](db[_0x3d9a62('0x64')][_0x3d9a62('0x6e')]),_0x51520d[_0x3d9a62('0xc')]=_[_0x3d9a62('0x8b')](_0x43442a[_0x3d9a62('0xc')]),_0x51520d[_0x3d9a62('0x92')]=_[_0x3d9a62('0x47')](_0x51520d[_0x3d9a62('0x8e')],_0x51520d[_0x3d9a62('0xc')]),_0x40e100['attributes']=_[_0x3d9a62('0x47')](_0x51520d['model'],qs[_0x3d9a62('0x2a')](_0x43442a[_0x3d9a62('0xc')][_0x3d9a62('0x2a')])),_0x40e100[_0x3d9a62('0x6')]=_0x40e100['attributes'][_0x3d9a62('0x78')]?_0x40e100[_0x3d9a62('0x6')]:_0x51520d[_0x3d9a62('0x8e')],_0x40e100[_0x3d9a62('0x2f')]=qs[_0x3d9a62('0x61')](_0x43442a[_0x3d9a62('0xc')][_0x3d9a62('0x61')]),_0x40e100[_0x3d9a62('0x26')]=qs[_0x3d9a62('0x92')](_[_0x3d9a62('0x10')](_0x43442a[_0x3d9a62('0xc')],_0x51520d['filters'])),_0x43442a[_0x3d9a62('0xc')]['filter']&&(_0x40e100[_0x3d9a62('0x26')]=_[_0x3d9a62('0x9')](_0x40e100[_0x3d9a62('0x26')],{[Op['or']]:_[_0x3d9a62('0x4d')](_0x40e100[_0x3d9a62('0x6')],function(_0x59894e){const _0xa53eb3=_0x3d9a62,_0x57e438={};return _0x57e438[_0x59894e]={[Op[_0xa53eb3('0x27')]]:'%'+_0x43442a[_0xa53eb3('0xc')][_0xa53eb3('0x1d')]+'%'},_0x57e438;})})),_0x40e100=_[_0x3d9a62('0x9')]({},_0x40e100,_0x43442a[_0x3d9a62('0x33')]),_0x3000ea['getAgents'](_0x40e100);})[_0x411907('0x46')](function(_0x463142){const _0x42b1fa=_0x411907;if(_0x463142)return _0x44954d=_0x463142[_0x42b1fa('0x78')],typeof _0x43442a['query'][_0x42b1fa('0x56')]==='undefined'&&(_0x40e100[_0x42b1fa('0x1c')]=qs[_0x42b1fa('0x1c')](_0x43442a[_0x42b1fa('0xc')]['limit']),_0x40e100[_0x42b1fa('0xb')]=qs[_0x42b1fa('0xb')](_0x43442a[_0x42b1fa('0xc')][_0x42b1fa('0xb')])),_0x3000ea[_0x42b1fa('0x4a')](_0x40e100);})['then'](function(_0x1d0b30){if(_0x1d0b30)return _0x1d0b30?{'count':_0x44954d,'rows':_0x1d0b30}:null;})[_0x411907('0x46')](respondWithResult(_0x3c44c7,null))[_0x411907('0x35')](handleError(_0x3c44c7,null));},exports['send']=function(_0x443139,_0x1db1e8){const _0xe99c7a=_0x203747;let _0x3d1647,_0x503357;if(_[_0xe99c7a('0x5d')](_0x443139[_0xe99c7a('0x8a')][_0xe99c7a('0x8a')])||_0x443139[_0xe99c7a('0x8a')]['body']==='')throw new db['Sequelize'][(_0xe99c7a('0x7a'))](_0xe99c7a('0x7d'));if(_['isNil'](_0x443139[_0xe99c7a('0x8a')]['to'])){}const _0x549735=_0x443139[_0xe99c7a('0x8a')]['to'];return db[_0xe99c7a('0x3a')]['findOne']({'where':{'id':_0x443139[_0xe99c7a('0x66')]['id']}})[_0xe99c7a('0x46')](handleEntityNotFound(_0x1db1e8,null))[_0xe99c7a('0x46')](function(_0x5e3246){const _0x29109e=_0xe99c7a;if(_0x5e3246)return db[_0x29109e('0x3a')][_0x29109e('0x7f')]({'where':{'id':_0x5e3246['id']},'include':[{'model':db[_0x29109e('0x79')],'as':'List','include':[{'model':db['CmContact'],'as':'Contacts','where':{[_0x5e3246[_0x29109e('0x80')]]:_0x549735},'limit':0x1,'order':[[_0x29109e('0x70'),'DESC']]}]}]})[_0x29109e('0x46')](handleEntityNotFound(_0x1db1e8,null))['then'](function(_0x8a3b11){const _0x1d60d7=_0x29109e;if(_0x8a3b11&&_0x8a3b11[_0x1d60d7('0x74')]){_0x3d1647=_0x8a3b11[_0x1d60d7('0x4f')]({'plain':!![]});if(_0x3d1647[_0x1d60d7('0x74')]&&_0x3d1647[_0x1d60d7('0x74')][_0x1d60d7('0x22')][_0x1d60d7('0x78')])return _0x3d1647['List'][_0x1d60d7('0x22')][0x0];return db[_0x1d60d7('0x7e')][_0x1d60d7('0x39')](_[_0x1d60d7('0x89')](_0x443139[_0x1d60d7('0x8a')],{'firstName':_0x549735,[_0x8a3b11[_0x1d60d7('0x80')]]:_0x549735,'phone':_0x549735,'ListId':_0x3d1647[_0x1d60d7('0x8f')]}));}})[_0x29109e('0x46')](handleEntityNotFound(_0x1db1e8,null))['then'](function(_0x421a4d){const _0x284e53=_0x29109e;if(_0x421a4d)return _0x503357=_0x421a4d,db[_0x284e53('0x88')]['findOne']({'where':{'ContactId':_0x503357['id'],'closed':![],'OpenchannelAccountId':_0x3d1647['id']}})[_0x284e53('0x46')](function(_0xac7692){const _0x39d572=_0x284e53;if(_0xac7692)return[_0xac7692,![]];return db[_0x39d572('0x88')][_0x39d572('0x39')]({'UserId':_0x443139[_0x39d572('0x3')]['id'],'ContactId':_0x503357['id'],'OpenchannelAccountId':_0x3d1647['id'],'lastMsgDirection':_0x39d572('0x5'),'Messages':[_[_0x39d572('0x9')](_0x443139[_0x39d572('0x8a')],{'read':![],'body':_0x443139[_0x39d572('0x8a')]['body'],'OpenchannelAccountId':_0x3d1647['id'],'UserId':_0x443139[_0x39d572('0x3')]['id'],'ContactId':_0x503357['id']})]},{'include':[{'model':db['OpenchannelMessage'],'as':_0x39d572('0x59')}]})[_0x39d572('0x46')](function(_0x5a3d1f){return[_0x5a3d1f,!![]];});});})[_0x29109e('0x46')](function([_0x24e0b1,_0x5284a1]){const _0x279b56=_0x29109e;if(_0x5284a1)return _0x24e0b1;return db[_0x279b56('0xa')][_0x279b56('0x39')](_['merge'](_0x443139[_0x279b56('0x8a')],{'read':![],'body':_0x443139[_0x279b56('0x8a')][_0x279b56('0x8a')],'OpenchannelAccountId':_0x3d1647['id'],'OpenchannelInteractionId':_0x24e0b1['id'],'UserId':_0x443139['user']['id'],'ContactId':_0x503357['id']}))[_0x279b56('0x46')](function(_0x313e30){const _0x1c8024=_0x279b56;return _0x24e0b1[_0x1c8024('0x51')][_0x1c8024('0x59')]=[],_0x24e0b1[_0x1c8024('0x51')][_0x1c8024('0x59')][_0x1c8024('0x84')](_0x313e30[_0x1c8024('0x51')]),_0x24e0b1;});});})[_0xe99c7a('0x46')](respondWithResult(_0x1db1e8,null))['catch'](handleError(_0x1db1e8,null));};
\ No newline at end of file