Built motion from commit (unavailable).|2.4.3
[motion2.git] / server / api / rpc / rpc.controller.js
index 2dd03f4..8c45b9d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6cfd=['*,*,*,*','Channel\x20field\x20is\x20mandatory','channel','chat','User','Agent\x20not\x20found','update','From','TransferReport','agentTransferTimeout','bluebird','moment','lodash','util','../../mysqldb','../../config/logger','api','jayson/promise','client','http','request','then','error','code','message','catch','status','json','sendStatus','stack','name','send','isNil','rows','find','voiceChannels','VoiceChannels','query','voiceChannelMixMonitor','VoiceChannelMixMonitor','merge','params','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','voiceQueues','VoiceQueues','voiceQueuesPreview','VoiceQueuesPreview','voiceQueuesChannels','VoiceQueuesChannels','voiceQueuesChannel','VoiceQueuesChannel','voiceQueuesChannelHangup','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','outbound','OutboundChannels','agents','Agents','agentCapacity','body','user','interaction','MemberReport','INTERACTION','length','format','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','findOrCreate','interface','SIP/%s','agent','internal','capacity','telephones','Telephones','Trunks','Campaigns','ChatQueues','showChatQueues','mailQueues','MailQueues','showMailQueues','mailAccounts','openchannelQueues','OpenchannelQueues','showOpenchannelQueues','smsQueues','SmsQueues','showSmsQueues','faxQueues','FaxQueues','showFaxQueues','FaxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','SmsQueuesWaitingInteractions','faxQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','capitalize','Website','Account','Queue','Message','findOne','messageId','Interaction','\x20Message\x20not\x20found','queue','MessageId','create','Start'];(function(_0x3539b2,_0x5e4e1e){var _0x33667f=function(_0x40907b){while(--_0x40907b){_0x3539b2['push'](_0x3539b2['shift']());}};_0x33667f(++_0x5e4e1e);}(_0x6cfd,0x7c));var _0xd6cf=function(_0x48ef7e,_0x5d765c){_0x48ef7e=_0x48ef7e-0x0;var _0x3bdacc=_0x6cfd[_0x48ef7e];return _0x3bdacc;};'use strict';var BPromise=require(_0xd6cf('0x0'));var moment=require(_0xd6cf('0x1'));var _=require(_0xd6cf('0x2'));var util=require(_0xd6cf('0x3'));var db=require(_0xd6cf('0x4'))['db'];var logger=require(_0xd6cf('0x5'))(_0xd6cf('0x6'));var jayson=require(_0xd6cf('0x7'));var amiClient=jayson[_0xd6cf('0x8')][_0xd6cf('0x9')]({'port':0x232a});var mailClient=jayson[_0xd6cf('0x8')]['http']({'port':0x232b});var routingClient=jayson['client'][_0xd6cf('0x9')]({'port':0x232c});function respondWithRpcPromise(_0x7dce85,_0x4223a3,_0xa70433){return new BPromise(function(_0x7fa344,_0x14a734){var _0x52628d=_0xa70433?_0xa70433:amiClient;return _0x52628d[_0xd6cf('0xa')](_0x7dce85,_0x4223a3)[_0xd6cf('0xb')](function(_0x1e1c32){if(_0x1e1c32['error']){if(_0x1e1c32[_0xd6cf('0xc')][_0xd6cf('0xd')]===0x1f4){return _0x14a734(_0x1e1c32[_0xd6cf('0xc')][_0xd6cf('0xe')]);}return _0x7fa344(_0x1e1c32[_0xd6cf('0xc')][_0xd6cf('0xe')]);}else{_0x7fa344(_0x1e1c32['result']);}})[_0xd6cf('0xf')](function(_0x546a4d){_0x14a734(_0x546a4d);});});}function respondWithResult(_0x5c8b64,_0x505987){_0x505987=_0x505987||0xc8;return function(_0x43f942){if(_0x43f942){return _0x5c8b64[_0xd6cf('0x10')](_0x505987)[_0xd6cf('0x11')](_0x43f942);}return _0x5c8b64[_0xd6cf('0x12')](0x194);};}function handleError(_0x3a6d29,_0x4d77c7){_0x4d77c7=_0x4d77c7||0x1f4;return function(_0x2dcd68){logger[_0xd6cf('0xc')](_0x2dcd68[_0xd6cf('0x13')]);if(_0x2dcd68[_0xd6cf('0x14')]){delete _0x2dcd68[_0xd6cf('0x14')];}_0x3a6d29['status'](_0x4d77c7)[_0xd6cf('0x15')](_0x2dcd68);};}function findById(_0x138422){return function(_0x2a21e0){if(!_[_0xd6cf('0x16')](_0x138422)&&!_[_0xd6cf('0x16')](_0x2a21e0)&&!_[_0xd6cf('0x16')](_0x2a21e0[_0xd6cf('0x17')])){return _[_0xd6cf('0x18')](_0x2a21e0[_0xd6cf('0x17')],function(_0x1c946c){return _0x1c946c['id']==_0x138422;});}return null;};}exports[_0xd6cf('0x19')]=function(_0x40da9d,_0x58041c){return respondWithRpcPromise(_0xd6cf('0x1a'),_0x40da9d[_0xd6cf('0x1b')])['then'](respondWithResult(_0x58041c,null))[_0xd6cf('0xf')](handleError(_0x58041c,null));};exports[_0xd6cf('0x1c')]=function(_0x1700a4,_0x34db5c){return respondWithRpcPromise(_0xd6cf('0x1d'),_[_0xd6cf('0x1e')](_0x1700a4[_0xd6cf('0x1b')],_0x1700a4[_0xd6cf('0x1f')]))['then'](respondWithResult(_0x34db5c,null))[_0xd6cf('0xf')](handleError(_0x34db5c,null));};exports[_0xd6cf('0x20')]=function(_0x361914,_0xcf3f09){return respondWithRpcPromise(_0xd6cf('0x21'),_[_0xd6cf('0x1e')](_0x361914[_0xd6cf('0x1b')],_0x361914[_0xd6cf('0x1f')]))[_0xd6cf('0xb')](respondWithResult(_0xcf3f09,null))[_0xd6cf('0xf')](handleError(_0xcf3f09,null));};exports[_0xd6cf('0x22')]=function(_0x1011e4,_0x547226){return respondWithRpcPromise(_0xd6cf('0x23'),_0x1011e4['query'])[_0xd6cf('0xb')](respondWithResult(_0x547226,null))[_0xd6cf('0xf')](handleError(_0x547226,null));};exports['showVoiceQueues']=function(_0x5d1a29,_0x5cf506){return respondWithRpcPromise(_0xd6cf('0x23'),_0x5d1a29[_0xd6cf('0x1b')])[_0xd6cf('0xb')](findById(_0x5d1a29[_0xd6cf('0x1f')]['id']))[_0xd6cf('0xb')](respondWithResult(_0x5cf506,null))['catch'](handleError(_0x5cf506,null));};exports[_0xd6cf('0x24')]=function(_0x506544,_0x2d6b1b){return respondWithRpcPromise(_0xd6cf('0x25'),_[_0xd6cf('0x1e')](_0x506544['query'],_0x506544[_0xd6cf('0x1f')]))[_0xd6cf('0xb')](respondWithResult(_0x2d6b1b,null))[_0xd6cf('0xf')](handleError(_0x2d6b1b,null));};exports[_0xd6cf('0x26')]=function(_0x1438b8,_0x46e51b){return respondWithRpcPromise(_0xd6cf('0x27'),_0x1438b8[_0xd6cf('0x1b')])[_0xd6cf('0xb')](respondWithResult(_0x46e51b,null))[_0xd6cf('0xf')](handleError(_0x46e51b,null));};exports[_0xd6cf('0x28')]=function(_0x5b57db,_0x43234e){return respondWithRpcPromise(_0xd6cf('0x29'),_[_0xd6cf('0x1e')](_0x5b57db[_0xd6cf('0x1b')],_0x5b57db[_0xd6cf('0x1f')]))['then'](respondWithResult(_0x43234e,null))[_0xd6cf('0xf')](handleError(_0x43234e,null));};exports[_0xd6cf('0x2a')]=function(_0x36e36a,_0x212141){return respondWithRpcPromise('VoiceQueuesChannelHangup',_[_0xd6cf('0x1e')](_0x36e36a[_0xd6cf('0x1b')],_0x36e36a[_0xd6cf('0x1f')]))[_0xd6cf('0xb')](respondWithResult(_0x212141,null))['catch'](handleError(_0x212141,null));};exports[_0xd6cf('0x2b')]=function(_0x3aaad7,_0x411d2e){return respondWithRpcPromise(_0xd6cf('0x2c'),_[_0xd6cf('0x1e')](_0x3aaad7[_0xd6cf('0x1b')],_0x3aaad7[_0xd6cf('0x1f')]))[_0xd6cf('0xb')](respondWithResult(_0x411d2e,null))[_0xd6cf('0xf')](handleError(_0x411d2e,null));};exports[_0xd6cf('0x2d')]=function(_0x3c1ed4,_0x295df9){return respondWithRpcPromise('Outbound',_0x3c1ed4[_0xd6cf('0x1b')])[_0xd6cf('0xb')](respondWithResult(_0x295df9,null))['catch'](handleError(_0x295df9,null));};exports['outboundChannels']=function(_0x40d08a,_0xd76349){return respondWithRpcPromise(_0xd6cf('0x2e'),_0x40d08a[_0xd6cf('0x1b')])['then'](respondWithResult(_0xd76349,null))[_0xd6cf('0xf')](handleError(_0xd76349,null));};exports[_0xd6cf('0x2f')]=function(_0x4da9bb,_0x580eb7){var _0x59def8;return respondWithRpcPromise(_0xd6cf('0x30'),_0x4da9bb[_0xd6cf('0x1b')])[_0xd6cf('0xb')](function(_0x2edf96){_0x59def8=_0x2edf96;return respondWithRpcPromise(_0xd6cf('0x30'),_0x4da9bb[_0xd6cf('0x1b')],routingClient);})['then'](function(_0x50bcac){return _[_0xd6cf('0x1e')]({},_0x50bcac,_0x59def8);})[_0xd6cf('0xb')](respondWithResult(_0x580eb7,null))['catch'](handleError(_0x580eb7,null));};exports[_0xd6cf('0x31')]=function(_0x72cd4e,_0xf5b462){if(_0x72cd4e[_0xd6cf('0x32')]&&_0x72cd4e[_0xd6cf('0x32')]['interaction']&&_0x72cd4e[_0xd6cf('0x33')]&&_0x72cd4e[_0xd6cf('0x33')][_0xd6cf('0x14')]){for(var _0x518367 in _0x72cd4e[_0xd6cf('0x32')][_0xd6cf('0x34')]){if(_0x72cd4e[_0xd6cf('0x32')][_0xd6cf('0x34')]['hasOwnProperty'](_0x518367)){db[_0xd6cf('0x35')]['findAll']({'where':{'channel':_0x518367,'membername':_0x72cd4e[_0xd6cf('0x33')][_0xd6cf('0x14')],'type':_0xd6cf('0x36'),'exitAt':null,'uniqueid':_0x72cd4e[_0xd6cf('0x32')][_0xd6cf('0x34')][_0x518367]&&_0x72cd4e[_0xd6cf('0x32')]['interaction'][_0x518367][_0xd6cf('0x37')]?{'$notIn':_0x72cd4e[_0xd6cf('0x32')][_0xd6cf('0x34')][_0x518367]}:{'$ne':null}}})['then'](function(_0x4bc07f){var _0x2ab0ad=moment()[_0xd6cf('0x38')](_0xd6cf('0x39'));for(var _0x5b0801=0x0,_0x509427=_0x4bc07f[_0xd6cf('0x37')];_0x5b0801<_0x509427;_0x5b0801+=0x1){_0x4bc07f[_0x5b0801][_0xd6cf('0x3a')]({'exitAt':_0x2ab0ad});}});for(var _0x2e637a=0x0;_0x2e637a<_0x72cd4e[_0xd6cf('0x32')]['interaction'][_0x518367][_0xd6cf('0x37')];_0x2e637a+=0x1){db[_0xd6cf('0x35')][_0xd6cf('0x3b')]({'where':{'channel':_0x518367,'membername':_0x72cd4e[_0xd6cf('0x33')][_0xd6cf('0x14')],'type':'INTERACTION','uniqueid':_0x72cd4e[_0xd6cf('0x32')]['interaction'][_0x518367][_0x2e637a],'exitAt':null},'defaults':{'channel':_0x518367,'membername':_0x72cd4e[_0xd6cf('0x33')][_0xd6cf('0x14')],'interface':_[_0xd6cf('0x16')](_0x72cd4e[_0xd6cf('0x33')][_0xd6cf('0x3c')])?util[_0xd6cf('0x38')](_0xd6cf('0x3d'),_0x72cd4e[_0xd6cf('0x33')]['name']):_0x72cd4e[_0xd6cf('0x33')][_0xd6cf('0x3c')],'type':_0xd6cf('0x36'),'enterAt':moment()[_0xd6cf('0x38')](_0xd6cf('0x39')),'role':_0xd6cf('0x3e'),'internal':_0x72cd4e[_0xd6cf('0x33')][_0xd6cf('0x3f')],'uniqueid':_0x72cd4e['body'][_0xd6cf('0x34')][_0x518367][_0x2e637a]}});}}}}return respondWithRpcPromise('AgentCapacity',{'id':_0x72cd4e[_0xd6cf('0x1f')]['id'],'capacity':_0x72cd4e[_0xd6cf('0x32')][_0xd6cf('0x40')]},routingClient)['then'](respondWithResult(_0xf5b462,null))[_0xd6cf('0xf')](handleError(_0xf5b462,null));};exports[_0xd6cf('0x41')]=function(_0x43d7e2,_0x1291c9){return respondWithRpcPromise(_0xd6cf('0x42'),_0x43d7e2[_0xd6cf('0x1b')])[_0xd6cf('0xb')](respondWithResult(_0x1291c9,null))[_0xd6cf('0xf')](handleError(_0x1291c9,null));};exports['trunks']=function(_0x1f9b6e,_0x2e8a48){return respondWithRpcPromise(_0xd6cf('0x43'),_0x1f9b6e[_0xd6cf('0x1b')])['then'](respondWithResult(_0x2e8a48,null))[_0xd6cf('0xf')](handleError(_0x2e8a48,null));};exports['campaigns']=function(_0x1b61c7,_0x5ebe0a){return respondWithRpcPromise(_0xd6cf('0x44'),_0x1b61c7['query'])['then'](respondWithResult(_0x5ebe0a,null))[_0xd6cf('0xf')](handleError(_0x5ebe0a,null));};exports['chatQueues']=function(_0x503569,_0x4ad68c){return respondWithRpcPromise(_0xd6cf('0x45'),_0x503569[_0xd6cf('0x1b')],routingClient)[_0xd6cf('0xb')](respondWithResult(_0x4ad68c,null))[_0xd6cf('0xf')](handleError(_0x4ad68c,null));};exports[_0xd6cf('0x46')]=function(_0xf88166,_0x3c3240){return respondWithRpcPromise(_0xd6cf('0x45'),_0xf88166['query'],routingClient)[_0xd6cf('0xb')](findById(_0xf88166[_0xd6cf('0x1f')]['id']))[_0xd6cf('0xb')](respondWithResult(_0x3c3240,null))[_0xd6cf('0xf')](handleError(_0x3c3240,null));};exports[_0xd6cf('0x47')]=function(_0x4fad7d,_0x2d3643){return respondWithRpcPromise(_0xd6cf('0x48'),_0x4fad7d[_0xd6cf('0x1b')],routingClient)[_0xd6cf('0xb')](respondWithResult(_0x2d3643,null))[_0xd6cf('0xf')](handleError(_0x2d3643,null));};exports[_0xd6cf('0x49')]=function(_0x4a1031,_0x3c30fb){return respondWithRpcPromise(_0xd6cf('0x48'),_0x4a1031[_0xd6cf('0x1b')],routingClient)[_0xd6cf('0xb')](findById(_0x4a1031['params']['id']))[_0xd6cf('0xb')](respondWithResult(_0x3c30fb,null))[_0xd6cf('0xf')](handleError(_0x3c30fb,null));};exports[_0xd6cf('0x4a')]=function(_0x252bac,_0x40ef12){return respondWithRpcPromise('MailAccounts',_0x252bac['query'],mailClient)[_0xd6cf('0xb')](respondWithResult(_0x40ef12,null))['catch'](handleError(_0x40ef12,null));};exports[_0xd6cf('0x4b')]=function(_0x3bada9,_0x902ff){return respondWithRpcPromise(_0xd6cf('0x4c'),_0x3bada9['query'],routingClient)[_0xd6cf('0xb')](respondWithResult(_0x902ff,null))[_0xd6cf('0xf')](handleError(_0x902ff,null));};exports[_0xd6cf('0x4d')]=function(_0x5ca809,_0x3b8627){return respondWithRpcPromise(_0xd6cf('0x4c'),_0x5ca809[_0xd6cf('0x1b')],routingClient)['then'](findById(_0x5ca809[_0xd6cf('0x1f')]['id']))['then'](respondWithResult(_0x3b8627,null))[_0xd6cf('0xf')](handleError(_0x3b8627,null));};exports[_0xd6cf('0x4e')]=function(_0x3938d4,_0x39718b){return respondWithRpcPromise(_0xd6cf('0x4f'),_0x3938d4[_0xd6cf('0x1b')],routingClient)['then'](respondWithResult(_0x39718b,null))[_0xd6cf('0xf')](handleError(_0x39718b,null));};exports[_0xd6cf('0x50')]=function(_0x4892dc,_0x127fb1){return respondWithRpcPromise('SmsQueues',_0x4892dc[_0xd6cf('0x1b')],routingClient)[_0xd6cf('0xb')](findById(_0x4892dc[_0xd6cf('0x1f')]['id']))['then'](respondWithResult(_0x127fb1,null))[_0xd6cf('0xf')](handleError(_0x127fb1,null));};exports[_0xd6cf('0x51')]=function(_0x1e4ce2,_0x1372b2){return respondWithRpcPromise(_0xd6cf('0x52'),_0x1e4ce2[_0xd6cf('0x1b')],routingClient)[_0xd6cf('0xb')](respondWithResult(_0x1372b2,null))[_0xd6cf('0xf')](handleError(_0x1372b2,null));};exports[_0xd6cf('0x53')]=function(_0x3ca0cd,_0x546b24){return respondWithRpcPromise(_0xd6cf('0x52'),_0x3ca0cd[_0xd6cf('0x1b')],routingClient)[_0xd6cf('0xb')](findById(_0x3ca0cd[_0xd6cf('0x1f')]['id']))[_0xd6cf('0xb')](respondWithResult(_0x546b24,null))['catch'](handleError(_0x546b24,null));};exports['faxAccounts']=function(_0x1a4246,_0x350903){return respondWithRpcPromise(_0xd6cf('0x54'),_0x1a4246[_0xd6cf('0x1b')])['then'](respondWithResult(_0x350903,null))[_0xd6cf('0xf')](handleError(_0x350903,null));};exports[_0xd6cf('0x55')]=function(_0x515182,_0x2efa88){return respondWithRpcPromise(_0xd6cf('0x56'),_0x515182[_0xd6cf('0x1b')],routingClient)['then'](respondWithResult(_0x2efa88,null))['catch'](handleError(_0x2efa88,null));};exports['mailQueuesWaitingInteractions']=function(_0x59c996,_0x4cdcdf){return respondWithRpcPromise('MailQueuesWaitingInteractions',_0x59c996[_0xd6cf('0x1b')],routingClient)[_0xd6cf('0xb')](respondWithResult(_0x4cdcdf,null))[_0xd6cf('0xf')](handleError(_0x4cdcdf,null));};exports['openchannelQueuesWaitingInteractions']=function(_0x3cfaf5,_0x131465){return respondWithRpcPromise('OpenchannelQueuesWaitingInteractions',_0x3cfaf5['query'],routingClient)[_0xd6cf('0xb')](respondWithResult(_0x131465,null))[_0xd6cf('0xf')](handleError(_0x131465,null));};exports['smsQueuesWaitingInteractions']=function(_0x5501a5,_0x48cb35){return respondWithRpcPromise(_0xd6cf('0x57'),_0x5501a5[_0xd6cf('0x1b')],routingClient)[_0xd6cf('0xb')](respondWithResult(_0x48cb35,null))[_0xd6cf('0xf')](handleError(_0x48cb35,null));};exports[_0xd6cf('0x58')]=function(_0x5d3bf6,_0x3cbf69){return respondWithRpcPromise(_0xd6cf('0x59'),_0x5d3bf6[_0xd6cf('0x1b')],routingClient)['then'](respondWithResult(_0x3cbf69,null))[_0xd6cf('0xf')](handleError(_0x3cbf69,null));};exports[_0xd6cf('0x5a')]=function(_0x4ad410){return function(_0x461594,_0xcc75e5){var _0x108afd,_0x26eca2;var _0x47017b=_[_0xd6cf('0x5b')](_0x4ad410);var _0x471036=_0x4ad410==='chat'?_0xd6cf('0x5c'):_0xd6cf('0x5d');return db[_0x47017b+_0xd6cf('0x5e')]['findOne']({'raw':!![],'where':{'id':_0x461594[_0xd6cf('0x1f')]['id']}})['then'](function(_0x2053a4){if(_[_0xd6cf('0x16')](_0x2053a4)){throw new Error(_0x47017b+'\x20Queue\x20not\x20found');}_0x108afd=_0x2053a4;return db[_0x47017b+_0xd6cf('0x5f')][_0xd6cf('0x60')]({'where':{'id':_0x461594[_0xd6cf('0x32')][_0xd6cf('0x61')]},'include':[{'model':db[_0x47017b+_0xd6cf('0x62')],'as':_0xd6cf('0x62')},{'model':db[_0x47017b+_0x471036],'as':_0xd6cf('0x5d')}]});})[_0xd6cf('0xb')](function(_0x2f65d6){if(_[_0xd6cf('0x16')](_0x2f65d6)){throw new Error(_0x47017b+_0xd6cf('0x63'));}_0x26eca2=_0x2f65d6;return _0x2f65d6['update']({'read':0x0,'readAt':null,'UserId':null});})[_0xd6cf('0xb')](function(){var _0x2d3ac0={'uniqueid':_0x4ad410+'.'+_0x26eca2['id']+'.'+_0x26eca2['Interaction']['id'],'FromUserId':_0x461594['user']['id'],'type':_0xd6cf('0x64')};_0x2d3ac0[_0x47017b+_0xd6cf('0x65')]=_0x26eca2['id'];_0x2d3ac0[_0x47017b+'InteractionId']=_0x26eca2[_0xd6cf('0x62')]['id'];_0x2d3ac0['From'+_0x47017b+_0x471036+'Id']=_0x26eca2['Account']['id'];_0x2d3ac0['To'+_0x47017b+'QueueId']=_0x108afd['id'];return db[_0x47017b+'TransferReport'][_0xd6cf('0x66')](_0x2d3ac0);})[_0xd6cf('0xb')](function(){return respondWithRpcPromise(_0xd6cf('0x67'),{'channel':_0x4ad410,'interaction':_0x26eca2[_0xd6cf('0x62')],'message':_0x26eca2,'account':_0x26eca2[_0xd6cf('0x5d')],'applications':[{'id':0x0,'priority':0x1,'app':_0xd6cf('0x64'),'appdata':_0x108afd['name']+','+(_0x26eca2[_0xd6cf('0x5d')]['queueTransferTimeout']||0x12c),'interval':_0xd6cf('0x68')}]},routingClient);})[_0xd6cf('0xb')](respondWithResult(_0xcc75e5,null))[_0xd6cf('0xf')](handleError(_0xcc75e5,null));};};exports['agentNotify']=function(_0x2a2c06,_0x54834a){var _0x473d43,_0x3734f4;if(_['isNil'](_0x2a2c06[_0xd6cf('0x32')]['channel'])){throw new Error(_0xd6cf('0x69'));}var _0x1a974c=_0x2a2c06[_0xd6cf('0x32')][_0xd6cf('0x6a')];var _0x48d3df=_[_0xd6cf('0x5b')](_0x1a974c);var _0x379d61=_0x1a974c===_0xd6cf('0x6b')?_0xd6cf('0x5c'):_0xd6cf('0x5d');return db[_0xd6cf('0x6c')][_0xd6cf('0x60')]({'raw':!![],'where':{'id':_0x2a2c06['params']['id'],'role':'agent'}})[_0xd6cf('0xb')](function(_0xe47c3e){if(_[_0xd6cf('0x16')](_0xe47c3e)){throw new Error(_0xd6cf('0x6d'));}_0x473d43=_0xe47c3e;return db[_0x48d3df+_0xd6cf('0x5f')]['findOne']({'where':{'id':_0x2a2c06[_0xd6cf('0x32')]['messageId']},'include':[{'model':db[_0x48d3df+_0xd6cf('0x62')],'as':_0xd6cf('0x62')},{'model':db[_0x48d3df+_0x379d61],'as':_0xd6cf('0x5d')}]});})[_0xd6cf('0xb')](function(_0x47cfae){if(_[_0xd6cf('0x16')](_0x47cfae)){throw new Error(_0x48d3df+_0xd6cf('0x63'));}_0x3734f4=_0x47cfae;return _0x47cfae[_0xd6cf('0x6e')]({'read':0x0,'readAt':null,'UserId':null});})[_0xd6cf('0xb')](function(){var _0xccb380={'uniqueid':_0x1a974c+'.'+_0x3734f4['id']+'.'+_0x3734f4[_0xd6cf('0x62')]['id'],'FromUserId':_0x2a2c06['user']['id'],'type':'queue','ToUserId':_0x473d43['id']};_0xccb380[_0x48d3df+_0xd6cf('0x65')]=_0x3734f4['id'];_0xccb380[_0x48d3df+'InteractionId']=_0x3734f4[_0xd6cf('0x62')]['id'];_0xccb380[_0xd6cf('0x6f')+_0x48d3df+_0x379d61+'Id']=_0x3734f4[_0xd6cf('0x5d')]['id'];return db[_0x48d3df+_0xd6cf('0x70')]['create'](_0xccb380);})[_0xd6cf('0xb')](function(){return respondWithRpcPromise('Start',{'channel':_0x1a974c,'interaction':_0x3734f4['Interaction'],'message':_0x3734f4,'account':_0x3734f4[_0xd6cf('0x5d')],'applications':[{'id':0x0,'priority':0x1,'app':_0xd6cf('0x3e'),'appdata':_0x473d43['name']+','+(_0x3734f4[_0xd6cf('0x5d')][_0xd6cf('0x71')]||0x12c),'interval':_0xd6cf('0x68')}]},routingClient);})[_0xd6cf('0xb')](respondWithResult(_0x54834a,null))[_0xd6cf('0xf')](handleError(_0x54834a,null));};
\ No newline at end of file
+var _0x4f05=['jayson/promise','client','request','error','message','catch','status','sendStatus','name','send','isNil','rows','find','voiceChannels','query','then','voiceChannelMixMonitor','VoiceChannelMixMonitor','merge','params','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','voiceQueues','VoiceQueues','showVoiceQueues','VoiceQueuesPreview','voiceQueuesChannels','VoiceQueuesChannels','voiceQueuesChannel','voiceQueuesChannelHangup','voiceQueuesChannelRedirect','Outbound','outboundChannels','OutboundChannels','agents','Agents','agentCapacity','body','interaction','hasOwnProperty','MemberReport','findAll','user','length','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','INTERACTION','interface','format','SIP/%s','agent','internal','AgentCapacity','telephones','Telephones','trunks','campaigns','chatQueues','ChatQueues','mailQueues','MailQueues','mailAccounts','MailAccounts','openchannelQueues','OpenchannelQueues','showOpenchannelQueues','smsQueues','showSmsQueues','SmsQueues','faxQueues','FaxQueues','showFaxQueues','faxAccounts','FaxAccounts','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','MailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','queueNotify','capitalize','Account','Queue','findOne','\x20Queue\x20not\x20found','Message','messageId','Interaction','\x20Message\x20not\x20found','update','queue','MessageId','create','Start','queueTransferTimeout','agentNotify','channel','chat','Website','User','Agent\x20not\x20found','InteractionId','From','TransferReport','agentTransferTimeout','bluebird','lodash','util','../../mysqldb','../../config/logger','api'];(function(_0x142ec2,_0x5bb03d){var _0x45ef4e=function(_0x4bc513){while(--_0x4bc513){_0x142ec2['push'](_0x142ec2['shift']());}};_0x45ef4e(++_0x5bb03d);}(_0x4f05,0x1be));var _0x54f0=function(_0x15bc81,_0x4d4f77){_0x15bc81=_0x15bc81-0x0;var _0x59440e=_0x4f05[_0x15bc81];return _0x59440e;};'use strict';var BPromise=require(_0x54f0('0x0'));var moment=require('moment');var _=require(_0x54f0('0x1'));var util=require(_0x54f0('0x2'));var db=require(_0x54f0('0x3'))['db'];var logger=require(_0x54f0('0x4'))(_0x54f0('0x5'));var jayson=require(_0x54f0('0x6'));var amiClient=jayson[_0x54f0('0x7')]['http']({'port':0x232a});var mailClient=jayson[_0x54f0('0x7')]['http']({'port':0x232b});var routingClient=jayson[_0x54f0('0x7')]['http']({'port':0x232c});function respondWithRpcPromise(_0x4e707d,_0x33c4f2,_0x2a54e0){return new BPromise(function(_0x544794,_0x5d20b2){var _0x9f6b24=_0x2a54e0?_0x2a54e0:amiClient;return _0x9f6b24[_0x54f0('0x8')](_0x4e707d,_0x33c4f2)['then'](function(_0xdbe446){if(_0xdbe446[_0x54f0('0x9')]){if(_0xdbe446['error']['code']===0x1f4){return _0x5d20b2(_0xdbe446[_0x54f0('0x9')][_0x54f0('0xa')]);}return _0x544794(_0xdbe446[_0x54f0('0x9')][_0x54f0('0xa')]);}else{_0x544794(_0xdbe446['result']);}})[_0x54f0('0xb')](function(_0x369cc6){_0x5d20b2(_0x369cc6);});});}function respondWithResult(_0x4076f9,_0x2c0167){_0x2c0167=_0x2c0167||0xc8;return function(_0x79fef7){if(_0x79fef7){return _0x4076f9[_0x54f0('0xc')](_0x2c0167)['json'](_0x79fef7);}return _0x4076f9[_0x54f0('0xd')](0x194);};}function handleError(_0x508f1e,_0x4ed021){_0x4ed021=_0x4ed021||0x1f4;return function(_0x53407f){logger[_0x54f0('0x9')](_0x53407f['stack']);if(_0x53407f['name']){delete _0x53407f[_0x54f0('0xe')];}_0x508f1e[_0x54f0('0xc')](_0x4ed021)[_0x54f0('0xf')](_0x53407f);};}function findById(_0x488392){return function(_0x6581fd){if(!_['isNil'](_0x488392)&&!_[_0x54f0('0x10')](_0x6581fd)&&!_['isNil'](_0x6581fd[_0x54f0('0x11')])){return _[_0x54f0('0x12')](_0x6581fd[_0x54f0('0x11')],function(_0x1237d5){return _0x1237d5['id']==_0x488392;});}return null;};}exports[_0x54f0('0x13')]=function(_0x5c57ae,_0x35a1fd){return respondWithRpcPromise('VoiceChannels',_0x5c57ae[_0x54f0('0x14')])[_0x54f0('0x15')](respondWithResult(_0x35a1fd,null))['catch'](handleError(_0x35a1fd,null));};exports[_0x54f0('0x16')]=function(_0x2b9b47,_0x1425a5){return respondWithRpcPromise(_0x54f0('0x17'),_[_0x54f0('0x18')](_0x2b9b47[_0x54f0('0x14')],_0x2b9b47[_0x54f0('0x19')]))[_0x54f0('0x15')](respondWithResult(_0x1425a5,null))['catch'](handleError(_0x1425a5,null));};exports[_0x54f0('0x1a')]=function(_0x2fb6d7,_0x413ca7){return respondWithRpcPromise(_0x54f0('0x1b'),_[_0x54f0('0x18')](_0x2fb6d7['query'],_0x2fb6d7[_0x54f0('0x19')]))[_0x54f0('0x15')](respondWithResult(_0x413ca7,null))[_0x54f0('0xb')](handleError(_0x413ca7,null));};exports[_0x54f0('0x1c')]=function(_0x28de1f,_0x3fb41d){return respondWithRpcPromise(_0x54f0('0x1d'),_0x28de1f[_0x54f0('0x14')])['then'](respondWithResult(_0x3fb41d,null))[_0x54f0('0xb')](handleError(_0x3fb41d,null));};exports[_0x54f0('0x1e')]=function(_0x34db77,_0x59a95d){return respondWithRpcPromise('VoiceQueues',_0x34db77[_0x54f0('0x14')])[_0x54f0('0x15')](findById(_0x34db77[_0x54f0('0x19')]['id']))[_0x54f0('0x15')](respondWithResult(_0x59a95d,null))[_0x54f0('0xb')](handleError(_0x59a95d,null));};exports['voiceQueuesPreview']=function(_0x35949e,_0x19fe07){return respondWithRpcPromise(_0x54f0('0x1f'),_['merge'](_0x35949e[_0x54f0('0x14')],_0x35949e[_0x54f0('0x19')]))[_0x54f0('0x15')](respondWithResult(_0x19fe07,null))[_0x54f0('0xb')](handleError(_0x19fe07,null));};exports[_0x54f0('0x20')]=function(_0x2414b4,_0x1794bb){return respondWithRpcPromise(_0x54f0('0x21'),_0x2414b4[_0x54f0('0x14')])[_0x54f0('0x15')](respondWithResult(_0x1794bb,null))['catch'](handleError(_0x1794bb,null));};exports[_0x54f0('0x22')]=function(_0x34d066,_0x3523f8){return respondWithRpcPromise('VoiceQueuesChannel',_['merge'](_0x34d066['query'],_0x34d066['params']))['then'](respondWithResult(_0x3523f8,null))[_0x54f0('0xb')](handleError(_0x3523f8,null));};exports[_0x54f0('0x23')]=function(_0x503593,_0x13f08d){return respondWithRpcPromise('VoiceQueuesChannelHangup',_[_0x54f0('0x18')](_0x503593[_0x54f0('0x14')],_0x503593[_0x54f0('0x19')]))[_0x54f0('0x15')](respondWithResult(_0x13f08d,null))[_0x54f0('0xb')](handleError(_0x13f08d,null));};exports[_0x54f0('0x24')]=function(_0x891282,_0x1e8e45){return respondWithRpcPromise('VoiceQueuesChannelRedirect',_[_0x54f0('0x18')](_0x891282[_0x54f0('0x14')],_0x891282[_0x54f0('0x19')]))[_0x54f0('0x15')](respondWithResult(_0x1e8e45,null))['catch'](handleError(_0x1e8e45,null));};exports['outbound']=function(_0xc2ad2a,_0x32ffa1){return respondWithRpcPromise(_0x54f0('0x25'),_0xc2ad2a[_0x54f0('0x14')])['then'](respondWithResult(_0x32ffa1,null))['catch'](handleError(_0x32ffa1,null));};exports[_0x54f0('0x26')]=function(_0x24109d,_0x10f5a4){return respondWithRpcPromise(_0x54f0('0x27'),_0x24109d[_0x54f0('0x14')])[_0x54f0('0x15')](respondWithResult(_0x10f5a4,null))[_0x54f0('0xb')](handleError(_0x10f5a4,null));};exports[_0x54f0('0x28')]=function(_0xdd06c6,_0x24c37a){var _0xdece4d;return respondWithRpcPromise(_0x54f0('0x29'),_0xdd06c6[_0x54f0('0x14')])[_0x54f0('0x15')](function(_0x224137){_0xdece4d=_0x224137;return respondWithRpcPromise('Agents',_0xdd06c6[_0x54f0('0x14')],routingClient);})['then'](function(_0x198818){return _[_0x54f0('0x18')]({},_0x198818,_0xdece4d);})['then'](respondWithResult(_0x24c37a,null))[_0x54f0('0xb')](handleError(_0x24c37a,null));};exports[_0x54f0('0x2a')]=function(_0x1ddb7b,_0x5716e9){if(_0x1ddb7b['body']&&_0x1ddb7b[_0x54f0('0x2b')][_0x54f0('0x2c')]&&_0x1ddb7b['user']&&_0x1ddb7b['user'][_0x54f0('0xe')]){for(var _0x29b743 in _0x1ddb7b[_0x54f0('0x2b')][_0x54f0('0x2c')]){if(_0x1ddb7b[_0x54f0('0x2b')]['interaction'][_0x54f0('0x2d')](_0x29b743)){db[_0x54f0('0x2e')][_0x54f0('0x2f')]({'where':{'channel':_0x29b743,'membername':_0x1ddb7b[_0x54f0('0x30')][_0x54f0('0xe')],'type':'INTERACTION','exitAt':null,'uniqueid':_0x1ddb7b[_0x54f0('0x2b')][_0x54f0('0x2c')][_0x29b743]&&_0x1ddb7b['body'][_0x54f0('0x2c')][_0x29b743][_0x54f0('0x31')]?{'$notIn':_0x1ddb7b[_0x54f0('0x2b')]['interaction'][_0x29b743]}:{'$ne':null}}})[_0x54f0('0x15')](function(_0x4bcec8){var _0x3990cd=moment()['format'](_0x54f0('0x32'));for(var _0x54227b=0x0,_0x25bd4a=_0x4bcec8[_0x54f0('0x31')];_0x54227b<_0x25bd4a;_0x54227b+=0x1){_0x4bcec8[_0x54227b][_0x54f0('0x33')]({'exitAt':_0x3990cd});}});for(var _0x49fe2c=0x0;_0x49fe2c<_0x1ddb7b['body'][_0x54f0('0x2c')][_0x29b743][_0x54f0('0x31')];_0x49fe2c+=0x1){db[_0x54f0('0x2e')]['findOrCreate']({'where':{'channel':_0x29b743,'membername':_0x1ddb7b[_0x54f0('0x30')]['name'],'type':_0x54f0('0x34'),'uniqueid':_0x1ddb7b['body'][_0x54f0('0x2c')][_0x29b743][_0x49fe2c],'exitAt':null},'defaults':{'channel':_0x29b743,'membername':_0x1ddb7b['user'][_0x54f0('0xe')],'interface':_[_0x54f0('0x10')](_0x1ddb7b[_0x54f0('0x30')][_0x54f0('0x35')])?util[_0x54f0('0x36')](_0x54f0('0x37'),_0x1ddb7b[_0x54f0('0x30')][_0x54f0('0xe')]):_0x1ddb7b[_0x54f0('0x30')][_0x54f0('0x35')],'type':_0x54f0('0x34'),'enterAt':moment()[_0x54f0('0x36')](_0x54f0('0x32')),'role':_0x54f0('0x38'),'internal':_0x1ddb7b['user'][_0x54f0('0x39')],'uniqueid':_0x1ddb7b['body'][_0x54f0('0x2c')][_0x29b743][_0x49fe2c]}});}}}}return respondWithRpcPromise(_0x54f0('0x3a'),{'id':_0x1ddb7b[_0x54f0('0x19')]['id'],'capacity':_0x1ddb7b[_0x54f0('0x2b')]['capacity']},routingClient)[_0x54f0('0x15')](respondWithResult(_0x5716e9,null))[_0x54f0('0xb')](handleError(_0x5716e9,null));};exports[_0x54f0('0x3b')]=function(_0x2b9404,_0x37bad2){return respondWithRpcPromise(_0x54f0('0x3c'),_0x2b9404[_0x54f0('0x14')])[_0x54f0('0x15')](respondWithResult(_0x37bad2,null))['catch'](handleError(_0x37bad2,null));};exports[_0x54f0('0x3d')]=function(_0x26ddf8,_0x3aa641){return respondWithRpcPromise('Trunks',_0x26ddf8[_0x54f0('0x14')])['then'](respondWithResult(_0x3aa641,null))['catch'](handleError(_0x3aa641,null));};exports[_0x54f0('0x3e')]=function(_0x568083,_0x34232e){return respondWithRpcPromise('Campaigns',_0x568083[_0x54f0('0x14')])[_0x54f0('0x15')](respondWithResult(_0x34232e,null))[_0x54f0('0xb')](handleError(_0x34232e,null));};exports[_0x54f0('0x3f')]=function(_0x251be0,_0x59e2ea){return respondWithRpcPromise(_0x54f0('0x40'),_0x251be0[_0x54f0('0x14')],routingClient)['then'](respondWithResult(_0x59e2ea,null))['catch'](handleError(_0x59e2ea,null));};exports['showChatQueues']=function(_0x1df643,_0x44b9cb){return respondWithRpcPromise(_0x54f0('0x40'),_0x1df643[_0x54f0('0x14')],routingClient)[_0x54f0('0x15')](findById(_0x1df643[_0x54f0('0x19')]['id']))[_0x54f0('0x15')](respondWithResult(_0x44b9cb,null))[_0x54f0('0xb')](handleError(_0x44b9cb,null));};exports[_0x54f0('0x41')]=function(_0x1af371,_0x53aaf4){return respondWithRpcPromise(_0x54f0('0x42'),_0x1af371[_0x54f0('0x14')],routingClient)[_0x54f0('0x15')](respondWithResult(_0x53aaf4,null))[_0x54f0('0xb')](handleError(_0x53aaf4,null));};exports['showMailQueues']=function(_0x5d4211,_0x2eed9b){return respondWithRpcPromise(_0x54f0('0x42'),_0x5d4211[_0x54f0('0x14')],routingClient)[_0x54f0('0x15')](findById(_0x5d4211[_0x54f0('0x19')]['id']))[_0x54f0('0x15')](respondWithResult(_0x2eed9b,null))[_0x54f0('0xb')](handleError(_0x2eed9b,null));};exports[_0x54f0('0x43')]=function(_0xcdcf11,_0x16a6f4){return respondWithRpcPromise(_0x54f0('0x44'),_0xcdcf11[_0x54f0('0x14')],mailClient)[_0x54f0('0x15')](respondWithResult(_0x16a6f4,null))[_0x54f0('0xb')](handleError(_0x16a6f4,null));};exports[_0x54f0('0x45')]=function(_0x1f06d8,_0x431f6b){return respondWithRpcPromise(_0x54f0('0x46'),_0x1f06d8[_0x54f0('0x14')],routingClient)['then'](respondWithResult(_0x431f6b,null))['catch'](handleError(_0x431f6b,null));};exports[_0x54f0('0x47')]=function(_0x37baed,_0x296f4e){return respondWithRpcPromise('OpenchannelQueues',_0x37baed[_0x54f0('0x14')],routingClient)[_0x54f0('0x15')](findById(_0x37baed[_0x54f0('0x19')]['id']))[_0x54f0('0x15')](respondWithResult(_0x296f4e,null))[_0x54f0('0xb')](handleError(_0x296f4e,null));};exports[_0x54f0('0x48')]=function(_0x4aa530,_0x2f2c04){return respondWithRpcPromise('SmsQueues',_0x4aa530[_0x54f0('0x14')],routingClient)[_0x54f0('0x15')](respondWithResult(_0x2f2c04,null))[_0x54f0('0xb')](handleError(_0x2f2c04,null));};exports[_0x54f0('0x49')]=function(_0x3164b0,_0x5908a5){return respondWithRpcPromise(_0x54f0('0x4a'),_0x3164b0['query'],routingClient)[_0x54f0('0x15')](findById(_0x3164b0['params']['id']))['then'](respondWithResult(_0x5908a5,null))[_0x54f0('0xb')](handleError(_0x5908a5,null));};exports[_0x54f0('0x4b')]=function(_0x3169fb,_0x247ee1){return respondWithRpcPromise(_0x54f0('0x4c'),_0x3169fb['query'],routingClient)[_0x54f0('0x15')](respondWithResult(_0x247ee1,null))[_0x54f0('0xb')](handleError(_0x247ee1,null));};exports[_0x54f0('0x4d')]=function(_0x2df358,_0x54381d){return respondWithRpcPromise(_0x54f0('0x4c'),_0x2df358['query'],routingClient)[_0x54f0('0x15')](findById(_0x2df358['params']['id']))[_0x54f0('0x15')](respondWithResult(_0x54381d,null))[_0x54f0('0xb')](handleError(_0x54381d,null));};exports[_0x54f0('0x4e')]=function(_0x3a629c,_0x49ad1a){return respondWithRpcPromise(_0x54f0('0x4f'),_0x3a629c[_0x54f0('0x14')])['then'](respondWithResult(_0x49ad1a,null))['catch'](handleError(_0x49ad1a,null));};exports['chatQueuesWaitingInteractions']=function(_0x119831,_0xfaf05c){return respondWithRpcPromise(_0x54f0('0x50'),_0x119831[_0x54f0('0x14')],routingClient)['then'](respondWithResult(_0xfaf05c,null))['catch'](handleError(_0xfaf05c,null));};exports[_0x54f0('0x51')]=function(_0x564b92,_0x461419){return respondWithRpcPromise(_0x54f0('0x52'),_0x564b92[_0x54f0('0x14')],routingClient)[_0x54f0('0x15')](respondWithResult(_0x461419,null))[_0x54f0('0xb')](handleError(_0x461419,null));};exports[_0x54f0('0x53')]=function(_0x72fdf6,_0x50ff73){return respondWithRpcPromise(_0x54f0('0x54'),_0x72fdf6[_0x54f0('0x14')],routingClient)[_0x54f0('0x15')](respondWithResult(_0x50ff73,null))[_0x54f0('0xb')](handleError(_0x50ff73,null));};exports[_0x54f0('0x55')]=function(_0x3ba6ae,_0x441b1d){return respondWithRpcPromise(_0x54f0('0x56'),_0x3ba6ae[_0x54f0('0x14')],routingClient)['then'](respondWithResult(_0x441b1d,null))[_0x54f0('0xb')](handleError(_0x441b1d,null));};exports['faxQueuesWaitingInteractions']=function(_0x2c0157,_0xc64f6e){return respondWithRpcPromise('FaxQueuesWaitingInteractions',_0x2c0157['query'],routingClient)[_0x54f0('0x15')](respondWithResult(_0xc64f6e,null))[_0x54f0('0xb')](handleError(_0xc64f6e,null));};exports[_0x54f0('0x57')]=function(_0x3092ef){return function(_0x2e40b7,_0x1e387e){var _0x58c17c,_0x7094e6;var _0x2fc9d9=_[_0x54f0('0x58')](_0x3092ef);var _0x343553=_0x3092ef==='chat'?'Website':_0x54f0('0x59');return db[_0x2fc9d9+_0x54f0('0x5a')][_0x54f0('0x5b')]({'raw':!![],'where':{'id':_0x2e40b7[_0x54f0('0x19')]['id']}})['then'](function(_0xc59ef0){if(_[_0x54f0('0x10')](_0xc59ef0)){throw new Error(_0x2fc9d9+_0x54f0('0x5c'));}_0x58c17c=_0xc59ef0;return db[_0x2fc9d9+_0x54f0('0x5d')]['findOne']({'where':{'id':_0x2e40b7[_0x54f0('0x2b')][_0x54f0('0x5e')]},'include':[{'model':db[_0x2fc9d9+_0x54f0('0x5f')],'as':_0x54f0('0x5f')},{'model':db[_0x2fc9d9+_0x343553],'as':'Account'}]});})['then'](function(_0xa6abdd){if(_[_0x54f0('0x10')](_0xa6abdd)){throw new Error(_0x2fc9d9+_0x54f0('0x60'));}_0x7094e6=_0xa6abdd;return _0xa6abdd[_0x54f0('0x61')]({'read':0x0,'readAt':null,'UserId':null});})[_0x54f0('0x15')](function(){var _0x1e070f={'uniqueid':_0x3092ef+'.'+_0x7094e6['id']+'.'+_0x7094e6[_0x54f0('0x5f')]['id'],'FromUserId':_0x2e40b7[_0x54f0('0x30')]['id'],'type':_0x54f0('0x62')};_0x1e070f[_0x2fc9d9+_0x54f0('0x63')]=_0x7094e6['id'];_0x1e070f[_0x2fc9d9+'InteractionId']=_0x7094e6[_0x54f0('0x5f')]['id'];_0x1e070f['From'+_0x2fc9d9+_0x343553+'Id']=_0x7094e6['Account']['id'];_0x1e070f['To'+_0x2fc9d9+'QueueId']=_0x58c17c['id'];return db[_0x2fc9d9+'TransferReport'][_0x54f0('0x64')](_0x1e070f);})[_0x54f0('0x15')](function(){return respondWithRpcPromise(_0x54f0('0x65'),{'channel':_0x3092ef,'interaction':_0x7094e6[_0x54f0('0x5f')],'message':_0x7094e6,'account':_0x7094e6[_0x54f0('0x59')],'applications':[{'id':0x0,'priority':0x1,'app':_0x54f0('0x62'),'appdata':_0x58c17c[_0x54f0('0xe')]+','+(_0x7094e6[_0x54f0('0x59')][_0x54f0('0x66')]||0x12c),'interval':'*,*,*,*'}]},routingClient);})[_0x54f0('0x15')](respondWithResult(_0x1e387e,null))['catch'](handleError(_0x1e387e,null));};};exports[_0x54f0('0x67')]=function(_0x705f0,_0x6d35b2){var _0x3d58d9,_0x228d2e;if(_[_0x54f0('0x10')](_0x705f0[_0x54f0('0x2b')]['channel'])){throw new Error('Channel\x20field\x20is\x20mandatory');}var _0x402900=_0x705f0[_0x54f0('0x2b')][_0x54f0('0x68')];var _0x190b8c=_[_0x54f0('0x58')](_0x402900);var _0x3d619e=_0x402900===_0x54f0('0x69')?_0x54f0('0x6a'):_0x54f0('0x59');return db[_0x54f0('0x6b')][_0x54f0('0x5b')]({'raw':!![],'where':{'id':_0x705f0[_0x54f0('0x19')]['id'],'role':_0x54f0('0x38')}})[_0x54f0('0x15')](function(_0x474b7b){if(_[_0x54f0('0x10')](_0x474b7b)){throw new Error(_0x54f0('0x6c'));}_0x3d58d9=_0x474b7b;return db[_0x190b8c+'Message'][_0x54f0('0x5b')]({'where':{'id':_0x705f0[_0x54f0('0x2b')][_0x54f0('0x5e')]},'include':[{'model':db[_0x190b8c+_0x54f0('0x5f')],'as':_0x54f0('0x5f')},{'model':db[_0x190b8c+_0x3d619e],'as':_0x54f0('0x59')}]});})[_0x54f0('0x15')](function(_0x365176){if(_[_0x54f0('0x10')](_0x365176)){throw new Error(_0x190b8c+_0x54f0('0x60'));}_0x228d2e=_0x365176;return _0x365176[_0x54f0('0x61')]({'read':0x0,'readAt':null,'UserId':null});})[_0x54f0('0x15')](function(){var _0x5d124a={'uniqueid':_0x402900+'.'+_0x228d2e['id']+'.'+_0x228d2e['Interaction']['id'],'FromUserId':_0x705f0['user']['id'],'type':_0x54f0('0x62'),'ToUserId':_0x3d58d9['id']};_0x5d124a[_0x190b8c+_0x54f0('0x63')]=_0x228d2e['id'];_0x5d124a[_0x190b8c+_0x54f0('0x6d')]=_0x228d2e[_0x54f0('0x5f')]['id'];_0x5d124a[_0x54f0('0x6e')+_0x190b8c+_0x3d619e+'Id']=_0x228d2e['Account']['id'];return db[_0x190b8c+_0x54f0('0x6f')][_0x54f0('0x64')](_0x5d124a);})[_0x54f0('0x15')](function(){return respondWithRpcPromise(_0x54f0('0x65'),{'channel':_0x402900,'interaction':_0x228d2e[_0x54f0('0x5f')],'message':_0x228d2e,'account':_0x228d2e[_0x54f0('0x59')],'applications':[{'id':0x0,'priority':0x1,'app':_0x54f0('0x38'),'appdata':_0x3d58d9[_0x54f0('0xe')]+','+(_0x228d2e[_0x54f0('0x59')][_0x54f0('0x70')]||0x12c),'interval':'*,*,*,*'}]},routingClient);})[_0x54f0('0x15')](respondWithResult(_0x6d35b2,null))[_0x54f0('0xb')](handleError(_0x6d35b2,null));};
\ No newline at end of file