Built motion from commit db94841.|2.5.3
[motion2.git] / server / api / rpc / rpc.controller.js
index 9a8ba3d..5e3035f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6aec=['MailQueues','showMailQueues','MailAccounts','openchannelQueues','OpenchannelQueues','showOpenchannelQueues','smsQueues','SmsQueues','whatsappQueues','WhatsappQueues','showWhatsappQueues','faxQueues','FaxQueues','FaxAccounts','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','WhatsappQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','chat','Website','Account','Queue','findOne','Message','messageId','Interaction','\x20Message\x20not\x20found','update','queue','MessageId','InteractionId','QueueId','TransferReport','*,*,*,*','agentNotify','channel','Channel\x20field\x20is\x20mandatory','User','From','create','agentTransferTimeout','bluebird','lodash','util','../../mysqldb','../../config/logger','client','http','request','then','error','code','message','result','catch','status','json','stack','name','isNil','rows','find','voiceChannels','query','VoiceChannelMixMonitor','merge','params','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','showVoiceQueues','VoiceQueuesPreview','voiceQueuesChannels','voiceQueuesChannel','VoiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','OutboundChannels','agents','Agents','agentCapacity','body','interaction','user','hasOwnProperty','MemberReport','findAll','INTERACTION','YYYY-MM-DD\x20HH:mm:ss','length','findOrCreate','interface','format','SIP/%s','agent','internal','AgentCapacity','capacity','telephones','Telephones','trunks','Trunks','campaigns','Campaigns','chatQueues','ChatQueues'];(function(_0x407aa0,_0x5ea282){var _0x117c8d=function(_0x5e9dc6){while(--_0x5e9dc6){_0x407aa0['push'](_0x407aa0['shift']());}};_0x117c8d(++_0x5ea282);}(_0x6aec,0x10e));var _0xc6ae=function(_0x29e6b2,_0x1d4a57){_0x29e6b2=_0x29e6b2-0x0;var _0x2160e3=_0x6aec[_0x29e6b2];return _0x2160e3;};'use strict';var BPromise=require(_0xc6ae('0x0'));var moment=require('moment');var _=require(_0xc6ae('0x1'));var util=require(_0xc6ae('0x2'));var db=require(_0xc6ae('0x3'))['db'];var logger=require(_0xc6ae('0x4'))('api');var jayson=require('jayson/promise');var amiClient=jayson[_0xc6ae('0x5')]['http']({'port':0x232a});var mailClient=jayson['client'][_0xc6ae('0x6')]({'port':0x232b});var routingClient=jayson[_0xc6ae('0x5')][_0xc6ae('0x6')]({'port':0x232c});function respondWithRpcPromise(_0x56daf4,_0x4ceaad,_0x448296){return new BPromise(function(_0x369fbe,_0x475168){var _0x2ea2ef=_0x448296?_0x448296:amiClient;return _0x2ea2ef[_0xc6ae('0x7')](_0x56daf4,_0x4ceaad)[_0xc6ae('0x8')](function(_0xbb43f7){if(_0xbb43f7[_0xc6ae('0x9')]){if(_0xbb43f7[_0xc6ae('0x9')][_0xc6ae('0xa')]===0x1f4){return _0x475168(_0xbb43f7['error']['message']);}return _0x369fbe(_0xbb43f7[_0xc6ae('0x9')][_0xc6ae('0xb')]);}else{_0x369fbe(_0xbb43f7[_0xc6ae('0xc')]);}})[_0xc6ae('0xd')](function(_0x57a932){_0x475168(_0x57a932);});});}function respondWithResult(_0xb8006d,_0x2fa5aa){_0x2fa5aa=_0x2fa5aa||0xc8;return function(_0x26c0c3){if(_0x26c0c3){return _0xb8006d[_0xc6ae('0xe')](_0x2fa5aa)[_0xc6ae('0xf')](_0x26c0c3);}return _0xb8006d['sendStatus'](0x194);};}function handleError(_0x3a280a,_0x35954d){_0x35954d=_0x35954d||0x1f4;return function(_0x1000e3){logger[_0xc6ae('0x9')](_0x1000e3[_0xc6ae('0x10')]);if(_0x1000e3['name']){delete _0x1000e3[_0xc6ae('0x11')];}_0x3a280a[_0xc6ae('0xe')](_0x35954d)['send'](_0x1000e3);};}function findById(_0x16c0df){return function(_0x3f90da){if(!_[_0xc6ae('0x12')](_0x16c0df)&&!_[_0xc6ae('0x12')](_0x3f90da)&&!_[_0xc6ae('0x12')](_0x3f90da[_0xc6ae('0x13')])){return _[_0xc6ae('0x14')](_0x3f90da[_0xc6ae('0x13')],function(_0x3892af){return _0x3892af['id']==_0x16c0df;});}return null;};}exports[_0xc6ae('0x15')]=function(_0x37d281,_0x1f39af){return respondWithRpcPromise('VoiceChannels',_0x37d281[_0xc6ae('0x16')])[_0xc6ae('0x8')](respondWithResult(_0x1f39af,null))[_0xc6ae('0xd')](handleError(_0x1f39af,null));};exports['voiceChannelMixMonitor']=function(_0x5d7417,_0x3e39bf){return respondWithRpcPromise(_0xc6ae('0x17'),_[_0xc6ae('0x18')](_0x5d7417[_0xc6ae('0x16')],_0x5d7417[_0xc6ae('0x19')]))['then'](respondWithResult(_0x3e39bf,null))[_0xc6ae('0xd')](handleError(_0x3e39bf,null));};exports[_0xc6ae('0x1a')]=function(_0x285d17,_0xffb878){return respondWithRpcPromise(_0xc6ae('0x1b'),_[_0xc6ae('0x18')](_0x285d17[_0xc6ae('0x16')],_0x285d17[_0xc6ae('0x19')]))[_0xc6ae('0x8')](respondWithResult(_0xffb878,null))[_0xc6ae('0xd')](handleError(_0xffb878,null));};exports['voiceQueues']=function(_0x288b00,_0x107957){return respondWithRpcPromise('VoiceQueues',_0x288b00[_0xc6ae('0x16')])[_0xc6ae('0x8')](respondWithResult(_0x107957,null))[_0xc6ae('0xd')](handleError(_0x107957,null));};exports[_0xc6ae('0x1c')]=function(_0x435add,_0xf3836f){return respondWithRpcPromise('VoiceQueues',_0x435add['query'])[_0xc6ae('0x8')](findById(_0x435add[_0xc6ae('0x19')]['id']))[_0xc6ae('0x8')](respondWithResult(_0xf3836f,null))[_0xc6ae('0xd')](handleError(_0xf3836f,null));};exports['voiceQueuesPreview']=function(_0x3a0cbc,_0x323581){return respondWithRpcPromise(_0xc6ae('0x1d'),_['merge'](_0x3a0cbc[_0xc6ae('0x16')],_0x3a0cbc[_0xc6ae('0x19')]))[_0xc6ae('0x8')](respondWithResult(_0x323581,null))[_0xc6ae('0xd')](handleError(_0x323581,null));};exports[_0xc6ae('0x1e')]=function(_0xbbc5a0,_0x9e2d1f){return respondWithRpcPromise('VoiceQueuesChannels',_0xbbc5a0[_0xc6ae('0x16')])[_0xc6ae('0x8')](respondWithResult(_0x9e2d1f,null))[_0xc6ae('0xd')](handleError(_0x9e2d1f,null));};exports[_0xc6ae('0x1f')]=function(_0x9d349d,_0x357ea9){return respondWithRpcPromise(_0xc6ae('0x20'),_['merge'](_0x9d349d[_0xc6ae('0x16')],_0x9d349d[_0xc6ae('0x19')]))['then'](respondWithResult(_0x357ea9,null))[_0xc6ae('0xd')](handleError(_0x357ea9,null));};exports[_0xc6ae('0x21')]=function(_0x335356,_0x5f1945){return respondWithRpcPromise(_0xc6ae('0x22'),_['merge'](_0x335356[_0xc6ae('0x16')],_0x335356['params']))['then'](respondWithResult(_0x5f1945,null))['catch'](handleError(_0x5f1945,null));};exports[_0xc6ae('0x23')]=function(_0x47e1ab,_0x4fb0ed){return respondWithRpcPromise(_0xc6ae('0x24'),_[_0xc6ae('0x18')](_0x47e1ab[_0xc6ae('0x16')],_0x47e1ab[_0xc6ae('0x19')]))[_0xc6ae('0x8')](respondWithResult(_0x4fb0ed,null))[_0xc6ae('0xd')](handleError(_0x4fb0ed,null));};exports['outbound']=function(_0x2eeb9e,_0x5f2a55){return respondWithRpcPromise('Outbound',_0x2eeb9e[_0xc6ae('0x16')])['then'](respondWithResult(_0x5f2a55,null))[_0xc6ae('0xd')](handleError(_0x5f2a55,null));};exports['outboundChannels']=function(_0x48dfff,_0x1eb65e){return respondWithRpcPromise(_0xc6ae('0x25'),_0x48dfff[_0xc6ae('0x16')])['then'](respondWithResult(_0x1eb65e,null))[_0xc6ae('0xd')](handleError(_0x1eb65e,null));};exports[_0xc6ae('0x26')]=function(_0x44d7b8,_0x4cdc5f){var _0x446a19;return respondWithRpcPromise(_0xc6ae('0x27'),_0x44d7b8[_0xc6ae('0x16')])[_0xc6ae('0x8')](function(_0x5cb494){_0x446a19=_0x5cb494;return respondWithRpcPromise(_0xc6ae('0x27'),_0x44d7b8[_0xc6ae('0x16')],routingClient);})[_0xc6ae('0x8')](function(_0x5d3e7f){return _[_0xc6ae('0x18')]({},_0x5d3e7f,_0x446a19);})[_0xc6ae('0x8')](respondWithResult(_0x4cdc5f,null))[_0xc6ae('0xd')](handleError(_0x4cdc5f,null));};exports[_0xc6ae('0x28')]=function(_0x3e8254,_0x1d92b6){if(_0x3e8254[_0xc6ae('0x29')]&&_0x3e8254[_0xc6ae('0x29')][_0xc6ae('0x2a')]&&_0x3e8254['user']&&_0x3e8254[_0xc6ae('0x2b')][_0xc6ae('0x11')]){for(var _0x5b6391 in _0x3e8254[_0xc6ae('0x29')][_0xc6ae('0x2a')]){if(_0x3e8254['body'][_0xc6ae('0x2a')][_0xc6ae('0x2c')](_0x5b6391)){db[_0xc6ae('0x2d')][_0xc6ae('0x2e')]({'where':{'channel':_0x5b6391,'membername':_0x3e8254[_0xc6ae('0x2b')][_0xc6ae('0x11')],'type':_0xc6ae('0x2f'),'exitAt':null,'uniqueid':_0x3e8254[_0xc6ae('0x29')][_0xc6ae('0x2a')][_0x5b6391]&&_0x3e8254[_0xc6ae('0x29')][_0xc6ae('0x2a')][_0x5b6391]['length']?{'$notIn':_0x3e8254[_0xc6ae('0x29')][_0xc6ae('0x2a')][_0x5b6391]}:{'$ne':null}}})[_0xc6ae('0x8')](function(_0x5a8c69){var _0x2a95b4=moment()['format'](_0xc6ae('0x30'));for(var _0x160259=0x0,_0x23673d=_0x5a8c69[_0xc6ae('0x31')];_0x160259<_0x23673d;_0x160259+=0x1){_0x5a8c69[_0x160259]['updateAttributes']({'exitAt':_0x2a95b4});}});for(var _0x5add3e=0x0;_0x5add3e<_0x3e8254['body']['interaction'][_0x5b6391][_0xc6ae('0x31')];_0x5add3e+=0x1){db[_0xc6ae('0x2d')][_0xc6ae('0x32')]({'where':{'channel':_0x5b6391,'membername':_0x3e8254[_0xc6ae('0x2b')][_0xc6ae('0x11')],'type':'INTERACTION','uniqueid':_0x3e8254[_0xc6ae('0x29')]['interaction'][_0x5b6391][_0x5add3e],'exitAt':null},'defaults':{'channel':_0x5b6391,'membername':_0x3e8254['user'][_0xc6ae('0x11')],'interface':_['isNil'](_0x3e8254[_0xc6ae('0x2b')][_0xc6ae('0x33')])?util[_0xc6ae('0x34')](_0xc6ae('0x35'),_0x3e8254['user'][_0xc6ae('0x11')]):_0x3e8254['user'][_0xc6ae('0x33')],'type':'INTERACTION','enterAt':moment()[_0xc6ae('0x34')](_0xc6ae('0x30')),'role':_0xc6ae('0x36'),'internal':_0x3e8254[_0xc6ae('0x2b')][_0xc6ae('0x37')],'uniqueid':_0x3e8254[_0xc6ae('0x29')][_0xc6ae('0x2a')][_0x5b6391][_0x5add3e]}});}}}}return respondWithRpcPromise(_0xc6ae('0x38'),{'id':_0x3e8254['params']['id'],'capacity':_0x3e8254[_0xc6ae('0x29')][_0xc6ae('0x39')]},routingClient)[_0xc6ae('0x8')](respondWithResult(_0x1d92b6,null))[_0xc6ae('0xd')](handleError(_0x1d92b6,null));};exports[_0xc6ae('0x3a')]=function(_0x489b9c,_0x5c8ebf){return respondWithRpcPromise(_0xc6ae('0x3b'),_0x489b9c[_0xc6ae('0x16')])[_0xc6ae('0x8')](respondWithResult(_0x5c8ebf,null))[_0xc6ae('0xd')](handleError(_0x5c8ebf,null));};exports[_0xc6ae('0x3c')]=function(_0x11d713,_0x31ad80){return respondWithRpcPromise(_0xc6ae('0x3d'),_0x11d713[_0xc6ae('0x16')])[_0xc6ae('0x8')](respondWithResult(_0x31ad80,null))[_0xc6ae('0xd')](handleError(_0x31ad80,null));};exports[_0xc6ae('0x3e')]=function(_0x3f9227,_0x4d8fc8){return respondWithRpcPromise(_0xc6ae('0x3f'),_0x3f9227['query'])[_0xc6ae('0x8')](respondWithResult(_0x4d8fc8,null))[_0xc6ae('0xd')](handleError(_0x4d8fc8,null));};exports[_0xc6ae('0x40')]=function(_0x2ddd94,_0x1297f2){return respondWithRpcPromise(_0xc6ae('0x41'),_0x2ddd94['query'],routingClient)[_0xc6ae('0x8')](respondWithResult(_0x1297f2,null))[_0xc6ae('0xd')](handleError(_0x1297f2,null));};exports['showChatQueues']=function(_0x1b73ab,_0x223b19){return respondWithRpcPromise('ChatQueues',_0x1b73ab['query'],routingClient)[_0xc6ae('0x8')](findById(_0x1b73ab[_0xc6ae('0x19')]['id']))['then'](respondWithResult(_0x223b19,null))[_0xc6ae('0xd')](handleError(_0x223b19,null));};exports['mailQueues']=function(_0x473df6,_0x530e2a){return respondWithRpcPromise(_0xc6ae('0x42'),_0x473df6['query'],routingClient)[_0xc6ae('0x8')](respondWithResult(_0x530e2a,null))[_0xc6ae('0xd')](handleError(_0x530e2a,null));};exports[_0xc6ae('0x43')]=function(_0x43a514,_0x3743f4){return respondWithRpcPromise('MailQueues',_0x43a514['query'],routingClient)[_0xc6ae('0x8')](findById(_0x43a514[_0xc6ae('0x19')]['id']))[_0xc6ae('0x8')](respondWithResult(_0x3743f4,null))['catch'](handleError(_0x3743f4,null));};exports['mailAccounts']=function(_0x1df1d3,_0x3af49e){return respondWithRpcPromise(_0xc6ae('0x44'),_0x1df1d3[_0xc6ae('0x16')],mailClient)['then'](respondWithResult(_0x3af49e,null))[_0xc6ae('0xd')](handleError(_0x3af49e,null));};exports[_0xc6ae('0x45')]=function(_0x1c9d84,_0x41311f){return respondWithRpcPromise(_0xc6ae('0x46'),_0x1c9d84[_0xc6ae('0x16')],routingClient)[_0xc6ae('0x8')](respondWithResult(_0x41311f,null))['catch'](handleError(_0x41311f,null));};exports[_0xc6ae('0x47')]=function(_0x45bbb3,_0x56eaaa){return respondWithRpcPromise('OpenchannelQueues',_0x45bbb3[_0xc6ae('0x16')],routingClient)[_0xc6ae('0x8')](findById(_0x45bbb3[_0xc6ae('0x19')]['id']))[_0xc6ae('0x8')](respondWithResult(_0x56eaaa,null))['catch'](handleError(_0x56eaaa,null));};exports[_0xc6ae('0x48')]=function(_0x14ddfd,_0x473a59){return respondWithRpcPromise('SmsQueues',_0x14ddfd['query'],routingClient)[_0xc6ae('0x8')](respondWithResult(_0x473a59,null))[_0xc6ae('0xd')](handleError(_0x473a59,null));};exports['showSmsQueues']=function(_0x1b4c98,_0x9c86f0){return respondWithRpcPromise(_0xc6ae('0x49'),_0x1b4c98['query'],routingClient)['then'](findById(_0x1b4c98[_0xc6ae('0x19')]['id']))[_0xc6ae('0x8')](respondWithResult(_0x9c86f0,null))[_0xc6ae('0xd')](handleError(_0x9c86f0,null));};exports[_0xc6ae('0x4a')]=function(_0x44b4a3,_0x428eed){return respondWithRpcPromise(_0xc6ae('0x4b'),_0x44b4a3[_0xc6ae('0x16')],routingClient)['then'](respondWithResult(_0x428eed,null))[_0xc6ae('0xd')](handleError(_0x428eed,null));};exports[_0xc6ae('0x4c')]=function(_0x49b44a,_0x5b6842){return respondWithRpcPromise('WhatsappQueues',_0x49b44a[_0xc6ae('0x16')],routingClient)[_0xc6ae('0x8')](findById(_0x49b44a[_0xc6ae('0x19')]['id']))[_0xc6ae('0x8')](respondWithResult(_0x5b6842,null))['catch'](handleError(_0x5b6842,null));};exports[_0xc6ae('0x4d')]=function(_0x3bf5f2,_0x4d7346){return respondWithRpcPromise(_0xc6ae('0x4e'),_0x3bf5f2[_0xc6ae('0x16')],routingClient)[_0xc6ae('0x8')](respondWithResult(_0x4d7346,null))['catch'](handleError(_0x4d7346,null));};exports['showFaxQueues']=function(_0x45c247,_0x20e382){return respondWithRpcPromise(_0xc6ae('0x4e'),_0x45c247[_0xc6ae('0x16')],routingClient)[_0xc6ae('0x8')](findById(_0x45c247[_0xc6ae('0x19')]['id']))[_0xc6ae('0x8')](respondWithResult(_0x20e382,null))[_0xc6ae('0xd')](handleError(_0x20e382,null));};exports['faxAccounts']=function(_0x47b840,_0x1d693e){return respondWithRpcPromise(_0xc6ae('0x4f'),_0x47b840[_0xc6ae('0x16')])[_0xc6ae('0x8')](respondWithResult(_0x1d693e,null))['catch'](handleError(_0x1d693e,null));};exports['chatQueuesWaitingInteractions']=function(_0x391aa5,_0x25415d){return respondWithRpcPromise(_0xc6ae('0x50'),_0x391aa5[_0xc6ae('0x16')],routingClient)['then'](respondWithResult(_0x25415d,null))[_0xc6ae('0xd')](handleError(_0x25415d,null));};exports[_0xc6ae('0x51')]=function(_0x301789,_0x474055){return respondWithRpcPromise('MailQueuesWaitingInteractions',_0x301789[_0xc6ae('0x16')],routingClient)[_0xc6ae('0x8')](respondWithResult(_0x474055,null))[_0xc6ae('0xd')](handleError(_0x474055,null));};exports[_0xc6ae('0x52')]=function(_0x4a4739,_0x5f58ef){return respondWithRpcPromise(_0xc6ae('0x53'),_0x4a4739[_0xc6ae('0x16')],routingClient)[_0xc6ae('0x8')](respondWithResult(_0x5f58ef,null))['catch'](handleError(_0x5f58ef,null));};exports[_0xc6ae('0x54')]=function(_0x5ab076,_0x1fbcef){return respondWithRpcPromise('SmsQueuesWaitingInteractions',_0x5ab076[_0xc6ae('0x16')],routingClient)[_0xc6ae('0x8')](respondWithResult(_0x1fbcef,null))[_0xc6ae('0xd')](handleError(_0x1fbcef,null));};exports[_0xc6ae('0x55')]=function(_0x2670cb,_0x3b2a7a){return respondWithRpcPromise(_0xc6ae('0x56'),_0x2670cb[_0xc6ae('0x16')],routingClient)[_0xc6ae('0x8')](respondWithResult(_0x3b2a7a,null))[_0xc6ae('0xd')](handleError(_0x3b2a7a,null));};exports['faxQueuesWaitingInteractions']=function(_0x4056d6,_0x21845f){return respondWithRpcPromise(_0xc6ae('0x57'),_0x4056d6['query'],routingClient)['then'](respondWithResult(_0x21845f,null))[_0xc6ae('0xd')](handleError(_0x21845f,null));};exports[_0xc6ae('0x58')]=function(_0x47b194){return function(_0x4b2636,_0x4f5f22){var _0x5f50da,_0x4819f8;var _0x5ed0c3=_['capitalize'](_0x47b194);var _0x2c5bed=_0x47b194===_0xc6ae('0x59')?_0xc6ae('0x5a'):_0xc6ae('0x5b');return db[_0x5ed0c3+_0xc6ae('0x5c')][_0xc6ae('0x5d')]({'raw':!![],'where':{'id':_0x4b2636[_0xc6ae('0x19')]['id']}})[_0xc6ae('0x8')](function(_0x1bb85a){if(_['isNil'](_0x1bb85a)){throw new Error(_0x5ed0c3+'\x20Queue\x20not\x20found');}_0x5f50da=_0x1bb85a;return db[_0x5ed0c3+_0xc6ae('0x5e')]['findOne']({'where':{'id':_0x4b2636[_0xc6ae('0x29')][_0xc6ae('0x5f')]},'include':[{'model':db[_0x5ed0c3+_0xc6ae('0x60')],'as':'Interaction'},{'model':db[_0x5ed0c3+_0x2c5bed],'as':_0xc6ae('0x5b')}]});})[_0xc6ae('0x8')](function(_0x3becba){if(_['isNil'](_0x3becba)){throw new Error(_0x5ed0c3+_0xc6ae('0x61'));}_0x4819f8=_0x3becba;return _0x3becba[_0xc6ae('0x62')]({'read':0x0,'readAt':null,'UserId':null});})[_0xc6ae('0x8')](function(){var _0x497c24={'uniqueid':_0x47b194+'.'+_0x4819f8['id']+'.'+_0x4819f8['Interaction']['id'],'FromUserId':_0x4b2636['user']['id'],'type':_0xc6ae('0x63')};_0x497c24[_0x5ed0c3+_0xc6ae('0x64')]=_0x4819f8['id'];_0x497c24[_0x5ed0c3+_0xc6ae('0x65')]=_0x4819f8[_0xc6ae('0x60')]['id'];_0x497c24['From'+_0x5ed0c3+_0x2c5bed+'Id']=_0x4819f8[_0xc6ae('0x5b')]['id'];_0x497c24['To'+_0x5ed0c3+_0xc6ae('0x66')]=_0x5f50da['id'];return db[_0x5ed0c3+_0xc6ae('0x67')]['create'](_0x497c24);})['then'](function(){return respondWithRpcPromise('Start',{'channel':_0x47b194,'interaction':_0x4819f8['Interaction'],'message':_0x4819f8,'account':_0x4819f8['Account'],'applications':[{'id':0x0,'priority':0x1,'app':_0xc6ae('0x63'),'appdata':_0x5f50da[_0xc6ae('0x11')]+','+(_0x4819f8['Account']['queueTransferTimeout']||0x12c),'interval':_0xc6ae('0x68')}]},routingClient);})['then'](respondWithResult(_0x4f5f22,null))[_0xc6ae('0xd')](handleError(_0x4f5f22,null));};};exports[_0xc6ae('0x69')]=function(_0x19bd04,_0xab491f){var _0x3d4a63,_0x23e648;if(_['isNil'](_0x19bd04[_0xc6ae('0x29')][_0xc6ae('0x6a')])){throw new Error(_0xc6ae('0x6b'));}var _0x1c11a9=_0x19bd04['body'][_0xc6ae('0x6a')];var _0x56513e=_['capitalize'](_0x1c11a9);var _0x3f4193=_0x1c11a9===_0xc6ae('0x59')?_0xc6ae('0x5a'):_0xc6ae('0x5b');return db[_0xc6ae('0x6c')][_0xc6ae('0x5d')]({'raw':!![],'where':{'id':_0x19bd04['params']['id'],'role':_0xc6ae('0x36')}})[_0xc6ae('0x8')](function(_0x16d582){if(_[_0xc6ae('0x12')](_0x16d582)){throw new Error('Agent\x20not\x20found');}_0x3d4a63=_0x16d582;return db[_0x56513e+_0xc6ae('0x5e')][_0xc6ae('0x5d')]({'where':{'id':_0x19bd04[_0xc6ae('0x29')]['messageId']},'include':[{'model':db[_0x56513e+_0xc6ae('0x60')],'as':_0xc6ae('0x60')},{'model':db[_0x56513e+_0x3f4193],'as':_0xc6ae('0x5b')}]});})['then'](function(_0x100589){if(_[_0xc6ae('0x12')](_0x100589)){throw new Error(_0x56513e+_0xc6ae('0x61'));}_0x23e648=_0x100589;return _0x100589[_0xc6ae('0x62')]({'read':0x0,'readAt':null,'UserId':null});})['then'](function(){var _0x4b00ba={'uniqueid':_0x1c11a9+'.'+_0x23e648['id']+'.'+_0x23e648['Interaction']['id'],'FromUserId':_0x19bd04[_0xc6ae('0x2b')]['id'],'type':_0xc6ae('0x63'),'ToUserId':_0x3d4a63['id']};_0x4b00ba[_0x56513e+_0xc6ae('0x64')]=_0x23e648['id'];_0x4b00ba[_0x56513e+_0xc6ae('0x65')]=_0x23e648[_0xc6ae('0x60')]['id'];_0x4b00ba[_0xc6ae('0x6d')+_0x56513e+_0x3f4193+'Id']=_0x23e648[_0xc6ae('0x5b')]['id'];return db[_0x56513e+'TransferReport'][_0xc6ae('0x6e')](_0x4b00ba);})[_0xc6ae('0x8')](function(){return respondWithRpcPromise('Start',{'channel':_0x1c11a9,'interaction':_0x23e648[_0xc6ae('0x60')],'message':_0x23e648,'account':_0x23e648[_0xc6ae('0x5b')],'applications':[{'id':0x0,'priority':0x1,'app':_0xc6ae('0x36'),'appdata':_0x3d4a63[_0xc6ae('0x11')]+','+(_0x23e648[_0xc6ae('0x5b')][_0xc6ae('0x6f')]||0x12c),'interval':_0xc6ae('0x68')}]},routingClient);})['then'](respondWithResult(_0xab491f,null))[_0xc6ae('0xd')](handleError(_0xab491f,null));};
\ No newline at end of file
+var _0x43d8=['InteractionId','From','TransferReport','create','Start','*,*,*,*','agentNotify','channel','Channel\x20field\x20is\x20mandatory','User','Message','update','MessageId','agentTransferTimeout','bluebird','moment','lodash','../../mysqldb','../../config/logger','api','http','client','request','error','code','result','status','sendStatus','name','send','isNil','rows','find','voiceChannels','query','catch','voiceChannelMixMonitor','VoiceChannelMixMonitor','params','then','voiceChannelStopMixMonitor','merge','voiceQueues','VoiceQueues','showVoiceQueues','voiceQueuesPreview','voiceQueuesChannels','VoiceQueuesChannels','voiceQueuesChannel','VoiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','VoiceQueuesChannelRedirect','outbound','Outbound','outboundChannels','OutboundChannels','Agents','body','interaction','user','hasOwnProperty','MemberReport','findAll','length','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','INTERACTION','format','SIP/%s','interface','agent','internal','capacity','telephones','Telephones','trunks','Trunks','campaigns','chatQueues','ChatQueues','showChatQueues','mailQueues','showMailQueues','MailAccounts','OpenchannelQueues','smsQueues','SmsQueues','showSmsQueues','showWhatsappQueues','WhatsappQueues','faxQueues','FaxQueues','faxAccounts','FaxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','MailQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','faxQueuesWaitingInteractions','queueNotify','capitalize','chat','Website','Account','findOne','messageId','Interaction','\x20Message\x20not\x20found','queue'];(function(_0x1891df,_0x13f014){var _0x4547d6=function(_0x2b222e){while(--_0x2b222e){_0x1891df['push'](_0x1891df['shift']());}};_0x4547d6(++_0x13f014);}(_0x43d8,0x1d2));var _0x843d=function(_0x4fc80b,_0xfe1b3d){_0x4fc80b=_0x4fc80b-0x0;var _0x119dba=_0x43d8[_0x4fc80b];return _0x119dba;};'use strict';var BPromise=require(_0x843d('0x0'));var moment=require(_0x843d('0x1'));var _=require(_0x843d('0x2'));var util=require('util');var db=require(_0x843d('0x3'))['db'];var logger=require(_0x843d('0x4'))(_0x843d('0x5'));var jayson=require('jayson/promise');var amiClient=jayson['client'][_0x843d('0x6')]({'port':0x232a});var mailClient=jayson['client']['http']({'port':0x232b});var routingClient=jayson[_0x843d('0x7')][_0x843d('0x6')]({'port':0x232c});function respondWithRpcPromise(_0x5ee272,_0x4dfdc4,_0x460176){return new BPromise(function(_0x1857dc,_0x1d151a){var _0x80ace5=_0x460176?_0x460176:amiClient;return _0x80ace5[_0x843d('0x8')](_0x5ee272,_0x4dfdc4)['then'](function(_0x6e3468){if(_0x6e3468[_0x843d('0x9')]){if(_0x6e3468[_0x843d('0x9')][_0x843d('0xa')]===0x1f4){return _0x1d151a(_0x6e3468['error']['message']);}return _0x1857dc(_0x6e3468[_0x843d('0x9')]['message']);}else{_0x1857dc(_0x6e3468[_0x843d('0xb')]);}})['catch'](function(_0x4bf9aa){_0x1d151a(_0x4bf9aa);});});}function respondWithResult(_0x3ccd0e,_0x5f539c){_0x5f539c=_0x5f539c||0xc8;return function(_0x4beadc){if(_0x4beadc){return _0x3ccd0e[_0x843d('0xc')](_0x5f539c)['json'](_0x4beadc);}return _0x3ccd0e[_0x843d('0xd')](0x194);};}function handleError(_0x5d8908,_0xa81b96){_0xa81b96=_0xa81b96||0x1f4;return function(_0xabe91c){logger[_0x843d('0x9')](_0xabe91c['stack']);if(_0xabe91c['name']){delete _0xabe91c[_0x843d('0xe')];}_0x5d8908[_0x843d('0xc')](_0xa81b96)[_0x843d('0xf')](_0xabe91c);};}function findById(_0x12aa72){return function(_0x142742){if(!_[_0x843d('0x10')](_0x12aa72)&&!_[_0x843d('0x10')](_0x142742)&&!_[_0x843d('0x10')](_0x142742[_0x843d('0x11')])){return _[_0x843d('0x12')](_0x142742[_0x843d('0x11')],function(_0x2c71a3){return _0x2c71a3['id']==_0x12aa72;});}return null;};}exports[_0x843d('0x13')]=function(_0x2cd5cd,_0x5792c5){return respondWithRpcPromise('VoiceChannels',_0x2cd5cd[_0x843d('0x14')])['then'](respondWithResult(_0x5792c5,null))[_0x843d('0x15')](handleError(_0x5792c5,null));};exports[_0x843d('0x16')]=function(_0x46777a,_0x23a5bf){return respondWithRpcPromise(_0x843d('0x17'),_['merge'](_0x46777a[_0x843d('0x14')],_0x46777a[_0x843d('0x18')]))[_0x843d('0x19')](respondWithResult(_0x23a5bf,null))[_0x843d('0x15')](handleError(_0x23a5bf,null));};exports[_0x843d('0x1a')]=function(_0x1c1dfd,_0x253e62){return respondWithRpcPromise('VoiceChannelStopMixMonitor',_[_0x843d('0x1b')](_0x1c1dfd['query'],_0x1c1dfd[_0x843d('0x18')]))['then'](respondWithResult(_0x253e62,null))['catch'](handleError(_0x253e62,null));};exports[_0x843d('0x1c')]=function(_0x2e300d,_0x14884e){return respondWithRpcPromise(_0x843d('0x1d'),_0x2e300d[_0x843d('0x14')])[_0x843d('0x19')](respondWithResult(_0x14884e,null))[_0x843d('0x15')](handleError(_0x14884e,null));};exports[_0x843d('0x1e')]=function(_0x249edb,_0x4fa9fc){return respondWithRpcPromise(_0x843d('0x1d'),_0x249edb[_0x843d('0x14')])[_0x843d('0x19')](findById(_0x249edb['params']['id']))[_0x843d('0x19')](respondWithResult(_0x4fa9fc,null))['catch'](handleError(_0x4fa9fc,null));};exports[_0x843d('0x1f')]=function(_0x1af99f,_0x3b0f24){return respondWithRpcPromise('VoiceQueuesPreview',_[_0x843d('0x1b')](_0x1af99f[_0x843d('0x14')],_0x1af99f['params']))[_0x843d('0x19')](respondWithResult(_0x3b0f24,null))[_0x843d('0x15')](handleError(_0x3b0f24,null));};exports[_0x843d('0x20')]=function(_0x3a0123,_0x2fac31){return respondWithRpcPromise(_0x843d('0x21'),_0x3a0123[_0x843d('0x14')])[_0x843d('0x19')](respondWithResult(_0x2fac31,null))['catch'](handleError(_0x2fac31,null));};exports[_0x843d('0x22')]=function(_0x18fa6f,_0x298a1f){return respondWithRpcPromise(_0x843d('0x23'),_[_0x843d('0x1b')](_0x18fa6f[_0x843d('0x14')],_0x18fa6f['params']))[_0x843d('0x19')](respondWithResult(_0x298a1f,null))[_0x843d('0x15')](handleError(_0x298a1f,null));};exports[_0x843d('0x24')]=function(_0x4e4ae1,_0x56530a){return respondWithRpcPromise(_0x843d('0x25'),_['merge'](_0x4e4ae1[_0x843d('0x14')],_0x4e4ae1[_0x843d('0x18')]))[_0x843d('0x19')](respondWithResult(_0x56530a,null))[_0x843d('0x15')](handleError(_0x56530a,null));};exports['voiceQueuesChannelRedirect']=function(_0x6e4e80,_0x40beb7){return respondWithRpcPromise(_0x843d('0x26'),_[_0x843d('0x1b')](_0x6e4e80[_0x843d('0x14')],_0x6e4e80['params']))[_0x843d('0x19')](respondWithResult(_0x40beb7,null))['catch'](handleError(_0x40beb7,null));};exports[_0x843d('0x27')]=function(_0x4d7afc,_0x18a4d5){return respondWithRpcPromise(_0x843d('0x28'),_0x4d7afc[_0x843d('0x14')])[_0x843d('0x19')](respondWithResult(_0x18a4d5,null))[_0x843d('0x15')](handleError(_0x18a4d5,null));};exports[_0x843d('0x29')]=function(_0xdeb08e,_0x18a86c){return respondWithRpcPromise(_0x843d('0x2a'),_0xdeb08e[_0x843d('0x14')])[_0x843d('0x19')](respondWithResult(_0x18a86c,null))['catch'](handleError(_0x18a86c,null));};exports['agents']=function(_0x55aa85,_0x242122){var _0x1dbaf8;return respondWithRpcPromise(_0x843d('0x2b'),_0x55aa85[_0x843d('0x14')])[_0x843d('0x19')](function(_0x4842cc){_0x1dbaf8=_0x4842cc;return respondWithRpcPromise(_0x843d('0x2b'),_0x55aa85[_0x843d('0x14')],routingClient);})[_0x843d('0x19')](function(_0x25fac5){return _[_0x843d('0x1b')]({},_0x25fac5,_0x1dbaf8);})[_0x843d('0x19')](respondWithResult(_0x242122,null))[_0x843d('0x15')](handleError(_0x242122,null));};exports['agentCapacity']=function(_0x24e679,_0x39f8c6){if(_0x24e679[_0x843d('0x2c')]&&_0x24e679[_0x843d('0x2c')][_0x843d('0x2d')]&&_0x24e679[_0x843d('0x2e')]&&_0x24e679['user'][_0x843d('0xe')]){for(var _0x3bdd9a in _0x24e679[_0x843d('0x2c')][_0x843d('0x2d')]){if(_0x24e679['body'][_0x843d('0x2d')][_0x843d('0x2f')](_0x3bdd9a)){db[_0x843d('0x30')][_0x843d('0x31')]({'where':{'channel':_0x3bdd9a,'membername':_0x24e679[_0x843d('0x2e')]['name'],'type':'INTERACTION','exitAt':null,'uniqueid':_0x24e679[_0x843d('0x2c')]['interaction'][_0x3bdd9a]&&_0x24e679['body'][_0x843d('0x2d')][_0x3bdd9a][_0x843d('0x32')]?{'$notIn':_0x24e679[_0x843d('0x2c')][_0x843d('0x2d')][_0x3bdd9a]}:{'$ne':null}}})[_0x843d('0x19')](function(_0x31136c){var _0x586f4f=moment()['format'](_0x843d('0x33'));for(var _0x14a51b=0x0,_0x189a25=_0x31136c[_0x843d('0x32')];_0x14a51b<_0x189a25;_0x14a51b+=0x1){_0x31136c[_0x14a51b][_0x843d('0x34')]({'exitAt':_0x586f4f});}});for(var _0x5f1145=0x0;_0x5f1145<_0x24e679[_0x843d('0x2c')]['interaction'][_0x3bdd9a]['length'];_0x5f1145+=0x1){db[_0x843d('0x30')]['findOrCreate']({'where':{'channel':_0x3bdd9a,'membername':_0x24e679[_0x843d('0x2e')][_0x843d('0xe')],'type':_0x843d('0x35'),'uniqueid':_0x24e679['body']['interaction'][_0x3bdd9a][_0x5f1145],'exitAt':null},'defaults':{'channel':_0x3bdd9a,'membername':_0x24e679['user'][_0x843d('0xe')],'interface':_['isNil'](_0x24e679[_0x843d('0x2e')]['interface'])?util[_0x843d('0x36')](_0x843d('0x37'),_0x24e679[_0x843d('0x2e')]['name']):_0x24e679['user'][_0x843d('0x38')],'type':'INTERACTION','enterAt':moment()[_0x843d('0x36')](_0x843d('0x33')),'role':_0x843d('0x39'),'internal':_0x24e679[_0x843d('0x2e')][_0x843d('0x3a')],'uniqueid':_0x24e679[_0x843d('0x2c')][_0x843d('0x2d')][_0x3bdd9a][_0x5f1145]}});}}}}return respondWithRpcPromise('AgentCapacity',{'id':_0x24e679['params']['id'],'capacity':_0x24e679['body'][_0x843d('0x3b')]},routingClient)[_0x843d('0x19')](respondWithResult(_0x39f8c6,null))[_0x843d('0x15')](handleError(_0x39f8c6,null));};exports[_0x843d('0x3c')]=function(_0x5244ff,_0x5dcd2d){return respondWithRpcPromise(_0x843d('0x3d'),_0x5244ff[_0x843d('0x14')])[_0x843d('0x19')](respondWithResult(_0x5dcd2d,null))[_0x843d('0x15')](handleError(_0x5dcd2d,null));};exports[_0x843d('0x3e')]=function(_0x493fa1,_0x2c67aa){return respondWithRpcPromise(_0x843d('0x3f'),_0x493fa1[_0x843d('0x14')])[_0x843d('0x19')](respondWithResult(_0x2c67aa,null))['catch'](handleError(_0x2c67aa,null));};exports[_0x843d('0x40')]=function(_0x41fe26,_0xb11fa){return respondWithRpcPromise('Campaigns',_0x41fe26['query'])[_0x843d('0x19')](respondWithResult(_0xb11fa,null))[_0x843d('0x15')](handleError(_0xb11fa,null));};exports[_0x843d('0x41')]=function(_0x18dbea,_0x5d35cc){return respondWithRpcPromise(_0x843d('0x42'),_0x18dbea[_0x843d('0x14')],routingClient)[_0x843d('0x19')](respondWithResult(_0x5d35cc,null))[_0x843d('0x15')](handleError(_0x5d35cc,null));};exports[_0x843d('0x43')]=function(_0x243e19,_0x2fcdd1){return respondWithRpcPromise(_0x843d('0x42'),_0x243e19[_0x843d('0x14')],routingClient)[_0x843d('0x19')](findById(_0x243e19[_0x843d('0x18')]['id']))[_0x843d('0x19')](respondWithResult(_0x2fcdd1,null))[_0x843d('0x15')](handleError(_0x2fcdd1,null));};exports[_0x843d('0x44')]=function(_0x54c35a,_0x290f21){return respondWithRpcPromise('MailQueues',_0x54c35a[_0x843d('0x14')],routingClient)[_0x843d('0x19')](respondWithResult(_0x290f21,null))[_0x843d('0x15')](handleError(_0x290f21,null));};exports[_0x843d('0x45')]=function(_0x26c7ae,_0x54b1fd){return respondWithRpcPromise('MailQueues',_0x26c7ae[_0x843d('0x14')],routingClient)[_0x843d('0x19')](findById(_0x26c7ae['params']['id']))[_0x843d('0x19')](respondWithResult(_0x54b1fd,null))[_0x843d('0x15')](handleError(_0x54b1fd,null));};exports['mailAccounts']=function(_0x83d330,_0x3b7cb7){return respondWithRpcPromise(_0x843d('0x46'),_0x83d330[_0x843d('0x14')],mailClient)['then'](respondWithResult(_0x3b7cb7,null))[_0x843d('0x15')](handleError(_0x3b7cb7,null));};exports['openchannelQueues']=function(_0x3d8ade,_0x2dd09b){return respondWithRpcPromise(_0x843d('0x47'),_0x3d8ade['query'],routingClient)[_0x843d('0x19')](respondWithResult(_0x2dd09b,null))[_0x843d('0x15')](handleError(_0x2dd09b,null));};exports['showOpenchannelQueues']=function(_0x27ccdf,_0x1d6f73){return respondWithRpcPromise(_0x843d('0x47'),_0x27ccdf[_0x843d('0x14')],routingClient)[_0x843d('0x19')](findById(_0x27ccdf[_0x843d('0x18')]['id']))[_0x843d('0x19')](respondWithResult(_0x1d6f73,null))['catch'](handleError(_0x1d6f73,null));};exports[_0x843d('0x48')]=function(_0xec551c,_0xd50335){return respondWithRpcPromise(_0x843d('0x49'),_0xec551c[_0x843d('0x14')],routingClient)[_0x843d('0x19')](respondWithResult(_0xd50335,null))[_0x843d('0x15')](handleError(_0xd50335,null));};exports[_0x843d('0x4a')]=function(_0x34736e,_0x162e55){return respondWithRpcPromise(_0x843d('0x49'),_0x34736e[_0x843d('0x14')],routingClient)[_0x843d('0x19')](findById(_0x34736e['params']['id']))[_0x843d('0x19')](respondWithResult(_0x162e55,null))['catch'](handleError(_0x162e55,null));};exports['whatsappQueues']=function(_0x357150,_0x2ec8b4){return respondWithRpcPromise('WhatsappQueues',_0x357150[_0x843d('0x14')],routingClient)[_0x843d('0x19')](respondWithResult(_0x2ec8b4,null))['catch'](handleError(_0x2ec8b4,null));};exports[_0x843d('0x4b')]=function(_0x178db5,_0x85b4b5){return respondWithRpcPromise(_0x843d('0x4c'),_0x178db5[_0x843d('0x14')],routingClient)[_0x843d('0x19')](findById(_0x178db5[_0x843d('0x18')]['id']))[_0x843d('0x19')](respondWithResult(_0x85b4b5,null))[_0x843d('0x15')](handleError(_0x85b4b5,null));};exports[_0x843d('0x4d')]=function(_0x13be56,_0x437bf2){return respondWithRpcPromise(_0x843d('0x4e'),_0x13be56[_0x843d('0x14')],routingClient)[_0x843d('0x19')](respondWithResult(_0x437bf2,null))[_0x843d('0x15')](handleError(_0x437bf2,null));};exports['showFaxQueues']=function(_0x2143dc,_0x1b5aee){return respondWithRpcPromise(_0x843d('0x4e'),_0x2143dc[_0x843d('0x14')],routingClient)[_0x843d('0x19')](findById(_0x2143dc[_0x843d('0x18')]['id']))[_0x843d('0x19')](respondWithResult(_0x1b5aee,null))['catch'](handleError(_0x1b5aee,null));};exports[_0x843d('0x4f')]=function(_0x57d5cf,_0x10e9d8){return respondWithRpcPromise(_0x843d('0x50'),_0x57d5cf[_0x843d('0x14')])[_0x843d('0x19')](respondWithResult(_0x10e9d8,null))[_0x843d('0x15')](handleError(_0x10e9d8,null));};exports[_0x843d('0x51')]=function(_0x4fbdd9,_0x178068){return respondWithRpcPromise(_0x843d('0x52'),_0x4fbdd9[_0x843d('0x14')],routingClient)[_0x843d('0x19')](respondWithResult(_0x178068,null))[_0x843d('0x15')](handleError(_0x178068,null));};exports[_0x843d('0x53')]=function(_0x3faf3f,_0x4918dc){return respondWithRpcPromise(_0x843d('0x54'),_0x3faf3f[_0x843d('0x14')],routingClient)[_0x843d('0x19')](respondWithResult(_0x4918dc,null))[_0x843d('0x15')](handleError(_0x4918dc,null));};exports['openchannelQueuesWaitingInteractions']=function(_0x4064d6,_0x142e83){return respondWithRpcPromise(_0x843d('0x55'),_0x4064d6[_0x843d('0x14')],routingClient)['then'](respondWithResult(_0x142e83,null))[_0x843d('0x15')](handleError(_0x142e83,null));};exports[_0x843d('0x56')]=function(_0x53f50a,_0x2a9333){return respondWithRpcPromise('SmsQueuesWaitingInteractions',_0x53f50a[_0x843d('0x14')],routingClient)[_0x843d('0x19')](respondWithResult(_0x2a9333,null))[_0x843d('0x15')](handleError(_0x2a9333,null));};exports[_0x843d('0x57')]=function(_0x19c039,_0x4da25c){return respondWithRpcPromise('WhatsappQueuesWaitingInteractions',_0x19c039[_0x843d('0x14')],routingClient)[_0x843d('0x19')](respondWithResult(_0x4da25c,null))[_0x843d('0x15')](handleError(_0x4da25c,null));};exports[_0x843d('0x58')]=function(_0x43048f,_0x2639c4){return respondWithRpcPromise('FaxQueuesWaitingInteractions',_0x43048f[_0x843d('0x14')],routingClient)[_0x843d('0x19')](respondWithResult(_0x2639c4,null))[_0x843d('0x15')](handleError(_0x2639c4,null));};exports[_0x843d('0x59')]=function(_0x5e0455){return function(_0x39a0d6,_0x2455f8){var _0x5285a4,_0x36c34c;var _0x2d2d97=_[_0x843d('0x5a')](_0x5e0455);var _0x4deb3c=_0x5e0455===_0x843d('0x5b')?_0x843d('0x5c'):_0x843d('0x5d');return db[_0x2d2d97+'Queue'][_0x843d('0x5e')]({'raw':!![],'where':{'id':_0x39a0d6[_0x843d('0x18')]['id']}})[_0x843d('0x19')](function(_0x45e80d){if(_['isNil'](_0x45e80d)){throw new Error(_0x2d2d97+'\x20Queue\x20not\x20found');}_0x5285a4=_0x45e80d;return db[_0x2d2d97+'Message'][_0x843d('0x5e')]({'where':{'id':_0x39a0d6[_0x843d('0x2c')][_0x843d('0x5f')]},'include':[{'model':db[_0x2d2d97+_0x843d('0x60')],'as':_0x843d('0x60')},{'model':db[_0x2d2d97+_0x4deb3c],'as':_0x843d('0x5d')}]});})[_0x843d('0x19')](function(_0x384361){if(_[_0x843d('0x10')](_0x384361)){throw new Error(_0x2d2d97+_0x843d('0x61'));}_0x36c34c=_0x384361;return _0x384361['update']({'read':0x0,'readAt':null,'UserId':null});})[_0x843d('0x19')](function(){var _0x483ae5={'uniqueid':_0x5e0455+'.'+_0x36c34c['id']+'.'+_0x36c34c[_0x843d('0x60')]['id'],'FromUserId':_0x39a0d6[_0x843d('0x2e')]['id'],'type':_0x843d('0x62')};_0x483ae5[_0x2d2d97+'MessageId']=_0x36c34c['id'];_0x483ae5[_0x2d2d97+_0x843d('0x63')]=_0x36c34c['Interaction']['id'];_0x483ae5[_0x843d('0x64')+_0x2d2d97+_0x4deb3c+'Id']=_0x36c34c[_0x843d('0x5d')]['id'];_0x483ae5['To'+_0x2d2d97+'QueueId']=_0x5285a4['id'];return db[_0x2d2d97+_0x843d('0x65')][_0x843d('0x66')](_0x483ae5);})[_0x843d('0x19')](function(){return respondWithRpcPromise(_0x843d('0x67'),{'channel':_0x5e0455,'interaction':_0x36c34c[_0x843d('0x60')],'message':_0x36c34c,'account':_0x36c34c[_0x843d('0x5d')],'applications':[{'id':0x0,'priority':0x1,'app':_0x843d('0x62'),'appdata':_0x5285a4[_0x843d('0xe')]+','+(_0x36c34c['Account']['queueTransferTimeout']||0x12c),'interval':_0x843d('0x68')}]},routingClient);})['then'](respondWithResult(_0x2455f8,null))[_0x843d('0x15')](handleError(_0x2455f8,null));};};exports[_0x843d('0x69')]=function(_0x3bef14,_0x4af7df){var _0x18d6b5,_0x248e50;if(_[_0x843d('0x10')](_0x3bef14[_0x843d('0x2c')][_0x843d('0x6a')])){throw new Error(_0x843d('0x6b'));}var _0x439da9=_0x3bef14[_0x843d('0x2c')]['channel'];var _0x1a62aa=_[_0x843d('0x5a')](_0x439da9);var _0x4e7ce4=_0x439da9===_0x843d('0x5b')?_0x843d('0x5c'):_0x843d('0x5d');return db[_0x843d('0x6c')][_0x843d('0x5e')]({'raw':!![],'where':{'id':_0x3bef14[_0x843d('0x18')]['id'],'role':_0x843d('0x39')}})[_0x843d('0x19')](function(_0x41853b){if(_[_0x843d('0x10')](_0x41853b)){throw new Error('Agent\x20not\x20found');}_0x18d6b5=_0x41853b;return db[_0x1a62aa+_0x843d('0x6d')]['findOne']({'where':{'id':_0x3bef14[_0x843d('0x2c')][_0x843d('0x5f')]},'include':[{'model':db[_0x1a62aa+_0x843d('0x60')],'as':_0x843d('0x60')},{'model':db[_0x1a62aa+_0x4e7ce4],'as':'Account'}]});})[_0x843d('0x19')](function(_0xb21298){if(_['isNil'](_0xb21298)){throw new Error(_0x1a62aa+'\x20Message\x20not\x20found');}_0x248e50=_0xb21298;return _0xb21298[_0x843d('0x6e')]({'read':0x0,'readAt':null,'UserId':null});})[_0x843d('0x19')](function(){var _0x17371f={'uniqueid':_0x439da9+'.'+_0x248e50['id']+'.'+_0x248e50[_0x843d('0x60')]['id'],'FromUserId':_0x3bef14['user']['id'],'type':_0x843d('0x62'),'ToUserId':_0x18d6b5['id']};_0x17371f[_0x1a62aa+_0x843d('0x6f')]=_0x248e50['id'];_0x17371f[_0x1a62aa+_0x843d('0x63')]=_0x248e50[_0x843d('0x60')]['id'];_0x17371f['From'+_0x1a62aa+_0x4e7ce4+'Id']=_0x248e50[_0x843d('0x5d')]['id'];return db[_0x1a62aa+_0x843d('0x65')][_0x843d('0x66')](_0x17371f);})[_0x843d('0x19')](function(){return respondWithRpcPromise(_0x843d('0x67'),{'channel':_0x439da9,'interaction':_0x248e50[_0x843d('0x60')],'message':_0x248e50,'account':_0x248e50[_0x843d('0x5d')],'applications':[{'id':0x0,'priority':0x1,'app':_0x843d('0x39'),'appdata':_0x18d6b5['name']+','+(_0x248e50['Account'][_0x843d('0x70')]||0x12c),'interval':'*,*,*,*'}]},routingClient);})[_0x843d('0x19')](respondWithResult(_0x4af7df,null))[_0x843d('0x15')](handleError(_0x4af7df,null));};
\ No newline at end of file