Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / rpc / rpc.controller.js
index e02b0fc..4864521 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8e3b=['showChatQueues','mailQueues','MailQueues','showMailQueues','mailAccounts','MailAccounts','openchannelQueues','OpenchannelQueues','smsQueues','showSmsQueues','SmsQueues','WhatsappQueues','showWhatsappQueues','faxQueues','FaxQueues','showFaxQueues','faxAccounts','FaxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','WhatsappQueuesWaitingInteractions','faxQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','capitalize','chat','Website','Queue','\x20Queue\x20not\x20found','findOne','messageId','Interaction','Account','\x20Message\x20not\x20found','update','MessageId','InteractionId','From','create','queue','*,*,*,*','channel','Channel\x20field\x20is\x20mandatory','User','agent','Agent\x20not\x20found','TransferReport','Start','bluebird','moment','lodash','util','../../mysqldb','../../config/logger','api','jayson/promise','http','client','request','then','error','code','catch','status','json','sendStatus','send','isNil','find','rows','VoiceChannels','query','merge','params','voiceChannelStopMixMonitor','voiceQueues','VoiceQueues','showVoiceQueues','voiceQueuesChannels','VoiceQueuesChannels','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','outbound','Outbound','outboundChannels','OutboundChannels','agents','Agents','body','interaction','user','name','hasOwnProperty','MemberReport','findAll','INTERACTION','length','updateAttributes','format','SIP/%s','interface','AgentCapacity','capacity','telephones','Telephones','trunks','Trunks','campaigns','Campaigns','ChatQueues'];(function(_0x4c139d,_0xf5e7bf){var _0x5d7bb1=function(_0x2ddf30){while(--_0x2ddf30){_0x4c139d['push'](_0x4c139d['shift']());}};_0x5d7bb1(++_0xf5e7bf);}(_0x8e3b,0xaa));var _0xb8e3=function(_0x5a7282,_0xa6e195){_0x5a7282=_0x5a7282-0x0;var _0x4928ec=_0x8e3b[_0x5a7282];return _0x4928ec;};'use strict';var BPromise=require(_0xb8e3('0x0'));var moment=require(_0xb8e3('0x1'));var _=require(_0xb8e3('0x2'));var util=require(_0xb8e3('0x3'));var db=require(_0xb8e3('0x4'))['db'];var logger=require(_0xb8e3('0x5'))(_0xb8e3('0x6'));var jayson=require(_0xb8e3('0x7'));var amiClient=jayson['client'][_0xb8e3('0x8')]({'port':0x232a});var mailClient=jayson[_0xb8e3('0x9')][_0xb8e3('0x8')]({'port':0x232b});var routingClient=jayson[_0xb8e3('0x9')][_0xb8e3('0x8')]({'port':0x232c});function respondWithRpcPromise(_0x59badb,_0x127f31,_0x2e7af0){return new BPromise(function(_0x3bb305,_0x557b54){var _0x255811=_0x2e7af0?_0x2e7af0:amiClient;return _0x255811[_0xb8e3('0xa')](_0x59badb,_0x127f31)[_0xb8e3('0xb')](function(_0x5adb16){if(_0x5adb16[_0xb8e3('0xc')]){if(_0x5adb16[_0xb8e3('0xc')][_0xb8e3('0xd')]===0x1f4){return _0x557b54(_0x5adb16[_0xb8e3('0xc')]['message']);}return _0x3bb305(_0x5adb16[_0xb8e3('0xc')]['message']);}else{_0x3bb305(_0x5adb16['result']);}})[_0xb8e3('0xe')](function(_0x4c18b8){_0x557b54(_0x4c18b8);});});}function respondWithResult(_0x144a57,_0x479d31){_0x479d31=_0x479d31||0xc8;return function(_0x2ea5e7){if(_0x2ea5e7){return _0x144a57[_0xb8e3('0xf')](_0x479d31)[_0xb8e3('0x10')](_0x2ea5e7);}return _0x144a57[_0xb8e3('0x11')](0x194);};}function handleError(_0x5c4f8a,_0x289153){_0x289153=_0x289153||0x1f4;return function(_0x557837){logger['error'](_0x557837['stack']);if(_0x557837['name']){delete _0x557837['name'];}_0x5c4f8a[_0xb8e3('0xf')](_0x289153)[_0xb8e3('0x12')](_0x557837);};}function findById(_0x3f778b){return function(_0xb45379){if(!_[_0xb8e3('0x13')](_0x3f778b)&&!_['isNil'](_0xb45379)&&!_[_0xb8e3('0x13')](_0xb45379['rows'])){return _[_0xb8e3('0x14')](_0xb45379[_0xb8e3('0x15')],function(_0x2957aa){return _0x2957aa['id']==_0x3f778b;});}return null;};}exports['voiceChannels']=function(_0x3e6ab2,_0x26ae2f){return respondWithRpcPromise(_0xb8e3('0x16'),_0x3e6ab2[_0xb8e3('0x17')])[_0xb8e3('0xb')](respondWithResult(_0x26ae2f,null))[_0xb8e3('0xe')](handleError(_0x26ae2f,null));};exports['voiceChannelMixMonitor']=function(_0x8a9c20,_0x1607eb){return respondWithRpcPromise('VoiceChannelMixMonitor',_[_0xb8e3('0x18')](_0x8a9c20[_0xb8e3('0x17')],_0x8a9c20[_0xb8e3('0x19')]))['then'](respondWithResult(_0x1607eb,null))[_0xb8e3('0xe')](handleError(_0x1607eb,null));};exports[_0xb8e3('0x1a')]=function(_0x5afd8a,_0x54ea94){return respondWithRpcPromise('VoiceChannelStopMixMonitor',_[_0xb8e3('0x18')](_0x5afd8a[_0xb8e3('0x17')],_0x5afd8a[_0xb8e3('0x19')]))[_0xb8e3('0xb')](respondWithResult(_0x54ea94,null))[_0xb8e3('0xe')](handleError(_0x54ea94,null));};exports[_0xb8e3('0x1b')]=function(_0x3973e5,_0x12f5d1){return respondWithRpcPromise(_0xb8e3('0x1c'),_0x3973e5[_0xb8e3('0x17')])['then'](respondWithResult(_0x12f5d1,null))['catch'](handleError(_0x12f5d1,null));};exports[_0xb8e3('0x1d')]=function(_0x23dc82,_0x514d52){return respondWithRpcPromise(_0xb8e3('0x1c'),_0x23dc82[_0xb8e3('0x17')])[_0xb8e3('0xb')](findById(_0x23dc82[_0xb8e3('0x19')]['id']))[_0xb8e3('0xb')](respondWithResult(_0x514d52,null))[_0xb8e3('0xe')](handleError(_0x514d52,null));};exports['voiceQueuesPreview']=function(_0x127d9e,_0x155045){return respondWithRpcPromise('VoiceQueuesPreview',_[_0xb8e3('0x18')](_0x127d9e[_0xb8e3('0x17')],_0x127d9e[_0xb8e3('0x19')]))['then'](respondWithResult(_0x155045,null))['catch'](handleError(_0x155045,null));};exports[_0xb8e3('0x1e')]=function(_0x5aa3b3,_0x3cf970){return respondWithRpcPromise(_0xb8e3('0x1f'),_0x5aa3b3[_0xb8e3('0x17')])[_0xb8e3('0xb')](respondWithResult(_0x3cf970,null))[_0xb8e3('0xe')](handleError(_0x3cf970,null));};exports['voiceQueuesChannel']=function(_0x3c340f,_0x47393c){return respondWithRpcPromise('VoiceQueuesChannel',_[_0xb8e3('0x18')](_0x3c340f[_0xb8e3('0x17')],_0x3c340f[_0xb8e3('0x19')]))[_0xb8e3('0xb')](respondWithResult(_0x47393c,null))[_0xb8e3('0xe')](handleError(_0x47393c,null));};exports[_0xb8e3('0x20')]=function(_0x373354,_0x2132cd){return respondWithRpcPromise(_0xb8e3('0x21'),_[_0xb8e3('0x18')](_0x373354[_0xb8e3('0x17')],_0x373354[_0xb8e3('0x19')]))[_0xb8e3('0xb')](respondWithResult(_0x2132cd,null))[_0xb8e3('0xe')](handleError(_0x2132cd,null));};exports[_0xb8e3('0x22')]=function(_0x399570,_0x9e0152){return respondWithRpcPromise(_0xb8e3('0x23'),_[_0xb8e3('0x18')](_0x399570[_0xb8e3('0x17')],_0x399570[_0xb8e3('0x19')]))[_0xb8e3('0xb')](respondWithResult(_0x9e0152,null))[_0xb8e3('0xe')](handleError(_0x9e0152,null));};exports[_0xb8e3('0x24')]=function(_0x172900,_0x3df720){return respondWithRpcPromise(_0xb8e3('0x25'),_0x172900[_0xb8e3('0x17')])[_0xb8e3('0xb')](respondWithResult(_0x3df720,null))[_0xb8e3('0xe')](handleError(_0x3df720,null));};exports[_0xb8e3('0x26')]=function(_0xeb868d,_0x188fdf){return respondWithRpcPromise(_0xb8e3('0x27'),_0xeb868d[_0xb8e3('0x17')])[_0xb8e3('0xb')](respondWithResult(_0x188fdf,null))[_0xb8e3('0xe')](handleError(_0x188fdf,null));};exports[_0xb8e3('0x28')]=function(_0xdd01b,_0x5e657b){var _0x4e4b7f;return respondWithRpcPromise(_0xb8e3('0x29'),_0xdd01b[_0xb8e3('0x17')])[_0xb8e3('0xb')](function(_0x14a762){_0x4e4b7f=_0x14a762;return respondWithRpcPromise(_0xb8e3('0x29'),_0xdd01b[_0xb8e3('0x17')],routingClient);})[_0xb8e3('0xb')](function(_0x22937b){return _[_0xb8e3('0x18')]({},_0x22937b,_0x4e4b7f);})['then'](respondWithResult(_0x5e657b,null))[_0xb8e3('0xe')](handleError(_0x5e657b,null));};exports['agentCapacity']=function(_0x3cabf0,_0x458e97){if(_0x3cabf0[_0xb8e3('0x2a')]&&_0x3cabf0[_0xb8e3('0x2a')][_0xb8e3('0x2b')]&&_0x3cabf0[_0xb8e3('0x2c')]&&_0x3cabf0[_0xb8e3('0x2c')][_0xb8e3('0x2d')]){for(var _0x5a25ab in _0x3cabf0['body']['interaction']){if(_0x3cabf0['body'][_0xb8e3('0x2b')][_0xb8e3('0x2e')](_0x5a25ab)){db[_0xb8e3('0x2f')][_0xb8e3('0x30')]({'where':{'channel':_0x5a25ab,'membername':_0x3cabf0['user'][_0xb8e3('0x2d')],'type':_0xb8e3('0x31'),'exitAt':null,'uniqueid':_0x3cabf0['body'][_0xb8e3('0x2b')][_0x5a25ab]&&_0x3cabf0['body'][_0xb8e3('0x2b')][_0x5a25ab][_0xb8e3('0x32')]?{'$notIn':_0x3cabf0[_0xb8e3('0x2a')][_0xb8e3('0x2b')][_0x5a25ab]}:{'$ne':null}}})[_0xb8e3('0xb')](function(_0x12669c){var _0x5c6b31=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');for(var _0x4cbeb1=0x0,_0x3e2515=_0x12669c['length'];_0x4cbeb1<_0x3e2515;_0x4cbeb1+=0x1){_0x12669c[_0x4cbeb1][_0xb8e3('0x33')]({'exitAt':_0x5c6b31});}});for(var _0x1eb47c=0x0;_0x1eb47c<_0x3cabf0['body']['interaction'][_0x5a25ab][_0xb8e3('0x32')];_0x1eb47c+=0x1){db[_0xb8e3('0x2f')]['findOrCreate']({'where':{'channel':_0x5a25ab,'membername':_0x3cabf0[_0xb8e3('0x2c')][_0xb8e3('0x2d')],'type':_0xb8e3('0x31'),'uniqueid':_0x3cabf0['body'][_0xb8e3('0x2b')][_0x5a25ab][_0x1eb47c],'exitAt':null},'defaults':{'channel':_0x5a25ab,'membername':_0x3cabf0[_0xb8e3('0x2c')][_0xb8e3('0x2d')],'interface':_[_0xb8e3('0x13')](_0x3cabf0[_0xb8e3('0x2c')]['interface'])?util[_0xb8e3('0x34')](_0xb8e3('0x35'),_0x3cabf0[_0xb8e3('0x2c')][_0xb8e3('0x2d')]):_0x3cabf0[_0xb8e3('0x2c')][_0xb8e3('0x36')],'type':_0xb8e3('0x31'),'enterAt':moment()[_0xb8e3('0x34')]('YYYY-MM-DD\x20HH:mm:ss'),'role':'agent','internal':_0x3cabf0[_0xb8e3('0x2c')]['internal'],'uniqueid':_0x3cabf0[_0xb8e3('0x2a')][_0xb8e3('0x2b')][_0x5a25ab][_0x1eb47c]}});}}}}return respondWithRpcPromise(_0xb8e3('0x37'),{'id':_0x3cabf0[_0xb8e3('0x19')]['id'],'capacity':_0x3cabf0['body'][_0xb8e3('0x38')]},routingClient)['then'](respondWithResult(_0x458e97,null))['catch'](handleError(_0x458e97,null));};exports[_0xb8e3('0x39')]=function(_0x4aff87,_0x539ef9){return respondWithRpcPromise(_0xb8e3('0x3a'),_0x4aff87['query'])['then'](respondWithResult(_0x539ef9,null))[_0xb8e3('0xe')](handleError(_0x539ef9,null));};exports[_0xb8e3('0x3b')]=function(_0x532b70,_0x365235){return respondWithRpcPromise(_0xb8e3('0x3c'),_0x532b70[_0xb8e3('0x17')])[_0xb8e3('0xb')](respondWithResult(_0x365235,null))[_0xb8e3('0xe')](handleError(_0x365235,null));};exports[_0xb8e3('0x3d')]=function(_0xd3bd35,_0x3e57ee){return respondWithRpcPromise(_0xb8e3('0x3e'),_0xd3bd35[_0xb8e3('0x17')])['then'](respondWithResult(_0x3e57ee,null))[_0xb8e3('0xe')](handleError(_0x3e57ee,null));};exports['chatQueues']=function(_0x2518b1,_0x2638e3){return respondWithRpcPromise(_0xb8e3('0x3f'),_0x2518b1[_0xb8e3('0x17')],routingClient)[_0xb8e3('0xb')](respondWithResult(_0x2638e3,null))[_0xb8e3('0xe')](handleError(_0x2638e3,null));};exports[_0xb8e3('0x40')]=function(_0x6afc71,_0xd8bfb2){return respondWithRpcPromise(_0xb8e3('0x3f'),_0x6afc71[_0xb8e3('0x17')],routingClient)[_0xb8e3('0xb')](findById(_0x6afc71[_0xb8e3('0x19')]['id']))['then'](respondWithResult(_0xd8bfb2,null))[_0xb8e3('0xe')](handleError(_0xd8bfb2,null));};exports[_0xb8e3('0x41')]=function(_0xeb194e,_0x559311){return respondWithRpcPromise(_0xb8e3('0x42'),_0xeb194e[_0xb8e3('0x17')],routingClient)[_0xb8e3('0xb')](respondWithResult(_0x559311,null))['catch'](handleError(_0x559311,null));};exports[_0xb8e3('0x43')]=function(_0x2ffbce,_0x39fecb){return respondWithRpcPromise('MailQueues',_0x2ffbce[_0xb8e3('0x17')],routingClient)['then'](findById(_0x2ffbce['params']['id']))[_0xb8e3('0xb')](respondWithResult(_0x39fecb,null))[_0xb8e3('0xe')](handleError(_0x39fecb,null));};exports[_0xb8e3('0x44')]=function(_0x4ceb0e,_0x540dae){return respondWithRpcPromise(_0xb8e3('0x45'),_0x4ceb0e[_0xb8e3('0x17')],mailClient)['then'](respondWithResult(_0x540dae,null))['catch'](handleError(_0x540dae,null));};exports[_0xb8e3('0x46')]=function(_0x3fb511,_0x17dfad){return respondWithRpcPromise(_0xb8e3('0x47'),_0x3fb511['query'],routingClient)[_0xb8e3('0xb')](respondWithResult(_0x17dfad,null))[_0xb8e3('0xe')](handleError(_0x17dfad,null));};exports['showOpenchannelQueues']=function(_0x5b48eb,_0x54436f){return respondWithRpcPromise(_0xb8e3('0x47'),_0x5b48eb[_0xb8e3('0x17')],routingClient)[_0xb8e3('0xb')](findById(_0x5b48eb[_0xb8e3('0x19')]['id']))[_0xb8e3('0xb')](respondWithResult(_0x54436f,null))[_0xb8e3('0xe')](handleError(_0x54436f,null));};exports[_0xb8e3('0x48')]=function(_0x540d2b,_0x474588){return respondWithRpcPromise('SmsQueues',_0x540d2b[_0xb8e3('0x17')],routingClient)[_0xb8e3('0xb')](respondWithResult(_0x474588,null))[_0xb8e3('0xe')](handleError(_0x474588,null));};exports[_0xb8e3('0x49')]=function(_0xe126c1,_0x64cc76){return respondWithRpcPromise(_0xb8e3('0x4a'),_0xe126c1['query'],routingClient)[_0xb8e3('0xb')](findById(_0xe126c1[_0xb8e3('0x19')]['id']))[_0xb8e3('0xb')](respondWithResult(_0x64cc76,null))['catch'](handleError(_0x64cc76,null));};exports['whatsappQueues']=function(_0x20970d,_0xda893b){return respondWithRpcPromise(_0xb8e3('0x4b'),_0x20970d['query'],routingClient)[_0xb8e3('0xb')](respondWithResult(_0xda893b,null))['catch'](handleError(_0xda893b,null));};exports[_0xb8e3('0x4c')]=function(_0xb7a061,_0x4b6955){return respondWithRpcPromise(_0xb8e3('0x4b'),_0xb7a061['query'],routingClient)[_0xb8e3('0xb')](findById(_0xb7a061['params']['id']))[_0xb8e3('0xb')](respondWithResult(_0x4b6955,null))['catch'](handleError(_0x4b6955,null));};exports[_0xb8e3('0x4d')]=function(_0x18124a,_0x3bd692){return respondWithRpcPromise(_0xb8e3('0x4e'),_0x18124a['query'],routingClient)[_0xb8e3('0xb')](respondWithResult(_0x3bd692,null))[_0xb8e3('0xe')](handleError(_0x3bd692,null));};exports[_0xb8e3('0x4f')]=function(_0xa7aa9f,_0x1d821d){return respondWithRpcPromise(_0xb8e3('0x4e'),_0xa7aa9f[_0xb8e3('0x17')],routingClient)['then'](findById(_0xa7aa9f[_0xb8e3('0x19')]['id']))[_0xb8e3('0xb')](respondWithResult(_0x1d821d,null))['catch'](handleError(_0x1d821d,null));};exports[_0xb8e3('0x50')]=function(_0x23d9a8,_0xa383cd){return respondWithRpcPromise(_0xb8e3('0x51'),_0x23d9a8[_0xb8e3('0x17')])[_0xb8e3('0xb')](respondWithResult(_0xa383cd,null))[_0xb8e3('0xe')](handleError(_0xa383cd,null));};exports[_0xb8e3('0x52')]=function(_0x3263aa,_0x4099df){return respondWithRpcPromise(_0xb8e3('0x53'),_0x3263aa[_0xb8e3('0x17')],routingClient)[_0xb8e3('0xb')](respondWithResult(_0x4099df,null))[_0xb8e3('0xe')](handleError(_0x4099df,null));};exports['mailQueuesWaitingInteractions']=function(_0x24db68,_0x10c7ca){return respondWithRpcPromise('MailQueuesWaitingInteractions',_0x24db68[_0xb8e3('0x17')],routingClient)[_0xb8e3('0xb')](respondWithResult(_0x10c7ca,null))[_0xb8e3('0xe')](handleError(_0x10c7ca,null));};exports[_0xb8e3('0x54')]=function(_0x125c2f,_0x1cdb4a){return respondWithRpcPromise(_0xb8e3('0x55'),_0x125c2f[_0xb8e3('0x17')],routingClient)['then'](respondWithResult(_0x1cdb4a,null))[_0xb8e3('0xe')](handleError(_0x1cdb4a,null));};exports[_0xb8e3('0x56')]=function(_0x485e4f,_0x12fc82){return respondWithRpcPromise(_0xb8e3('0x57'),_0x485e4f['query'],routingClient)[_0xb8e3('0xb')](respondWithResult(_0x12fc82,null))['catch'](handleError(_0x12fc82,null));};exports[_0xb8e3('0x58')]=function(_0x340fd9,_0x5a3c90){return respondWithRpcPromise(_0xb8e3('0x59'),_0x340fd9['query'],routingClient)[_0xb8e3('0xb')](respondWithResult(_0x5a3c90,null))[_0xb8e3('0xe')](handleError(_0x5a3c90,null));};exports[_0xb8e3('0x5a')]=function(_0x4e05bb,_0x1d9346){return respondWithRpcPromise(_0xb8e3('0x5b'),_0x4e05bb[_0xb8e3('0x17')],routingClient)[_0xb8e3('0xb')](respondWithResult(_0x1d9346,null))[_0xb8e3('0xe')](handleError(_0x1d9346,null));};exports[_0xb8e3('0x5c')]=function(_0x5e9ce2){return function(_0x3fcb36,_0x2296c2){var _0x22dc3b,_0x1c389a;var _0x59f5fd=_[_0xb8e3('0x5d')](_0x5e9ce2);var _0x3eba57=_0x5e9ce2===_0xb8e3('0x5e')?_0xb8e3('0x5f'):'Account';return db[_0x59f5fd+_0xb8e3('0x60')]['findOne']({'raw':!![],'where':{'id':_0x3fcb36[_0xb8e3('0x19')]['id']}})[_0xb8e3('0xb')](function(_0x204076){if(_['isNil'](_0x204076)){throw new Error(_0x59f5fd+_0xb8e3('0x61'));}_0x22dc3b=_0x204076;return db[_0x59f5fd+'Message'][_0xb8e3('0x62')]({'where':{'id':_0x3fcb36[_0xb8e3('0x2a')][_0xb8e3('0x63')]},'include':[{'model':db[_0x59f5fd+_0xb8e3('0x64')],'as':'Interaction'},{'model':db[_0x59f5fd+_0x3eba57],'as':_0xb8e3('0x65')}]});})[_0xb8e3('0xb')](function(_0x143171){if(_['isNil'](_0x143171)){throw new Error(_0x59f5fd+_0xb8e3('0x66'));}_0x1c389a=_0x143171;return _0x143171[_0xb8e3('0x67')]({'read':0x0,'readAt':null,'UserId':null});})[_0xb8e3('0xb')](function(){var _0x6ef357={'uniqueid':_0x5e9ce2+'.'+_0x1c389a['id']+'.'+_0x1c389a['Interaction']['id'],'FromUserId':_0x3fcb36['user']['id'],'type':'queue'};_0x6ef357[_0x59f5fd+_0xb8e3('0x68')]=_0x1c389a['id'];_0x6ef357[_0x59f5fd+_0xb8e3('0x69')]=_0x1c389a['Interaction']['id'];_0x6ef357[_0xb8e3('0x6a')+_0x59f5fd+_0x3eba57+'Id']=_0x1c389a['Account']['id'];_0x6ef357['To'+_0x59f5fd+'QueueId']=_0x22dc3b['id'];return db[_0x59f5fd+'TransferReport'][_0xb8e3('0x6b')](_0x6ef357);})[_0xb8e3('0xb')](function(){return respondWithRpcPromise('Start',{'channel':_0x5e9ce2,'interaction':_0x1c389a[_0xb8e3('0x64')],'message':_0x1c389a,'account':_0x1c389a[_0xb8e3('0x65')],'applications':[{'id':0x0,'priority':0x1,'app':_0xb8e3('0x6c'),'appdata':_0x22dc3b[_0xb8e3('0x2d')]+','+(_0x1c389a['Account']['queueTransferTimeout']||0x12c),'interval':_0xb8e3('0x6d')}]},routingClient);})[_0xb8e3('0xb')](respondWithResult(_0x2296c2,null))[_0xb8e3('0xe')](handleError(_0x2296c2,null));};};exports['agentNotify']=function(_0x18e9e5,_0xbeb56f){var _0x4b8fa4,_0x1272d8;if(_[_0xb8e3('0x13')](_0x18e9e5[_0xb8e3('0x2a')][_0xb8e3('0x6e')])){throw new Error(_0xb8e3('0x6f'));}var _0x49c965=_0x18e9e5[_0xb8e3('0x2a')]['channel'];var _0x4a8d3c=_[_0xb8e3('0x5d')](_0x49c965);var _0x5ba527=_0x49c965===_0xb8e3('0x5e')?_0xb8e3('0x5f'):_0xb8e3('0x65');return db[_0xb8e3('0x70')][_0xb8e3('0x62')]({'raw':!![],'where':{'id':_0x18e9e5[_0xb8e3('0x19')]['id'],'role':_0xb8e3('0x71')}})[_0xb8e3('0xb')](function(_0x4530a2){if(_[_0xb8e3('0x13')](_0x4530a2)){throw new Error(_0xb8e3('0x72'));}_0x4b8fa4=_0x4530a2;return db[_0x4a8d3c+'Message'][_0xb8e3('0x62')]({'where':{'id':_0x18e9e5[_0xb8e3('0x2a')][_0xb8e3('0x63')]},'include':[{'model':db[_0x4a8d3c+_0xb8e3('0x64')],'as':_0xb8e3('0x64')},{'model':db[_0x4a8d3c+_0x5ba527],'as':'Account'}]});})[_0xb8e3('0xb')](function(_0x48299b){if(_[_0xb8e3('0x13')](_0x48299b)){throw new Error(_0x4a8d3c+_0xb8e3('0x66'));}_0x1272d8=_0x48299b;return _0x48299b[_0xb8e3('0x67')]({'read':0x0,'readAt':null,'UserId':null});})[_0xb8e3('0xb')](function(){var _0x402cd0={'uniqueid':_0x49c965+'.'+_0x1272d8['id']+'.'+_0x1272d8[_0xb8e3('0x64')]['id'],'FromUserId':_0x18e9e5[_0xb8e3('0x2c')]['id'],'type':_0xb8e3('0x6c'),'ToUserId':_0x4b8fa4['id']};_0x402cd0[_0x4a8d3c+_0xb8e3('0x68')]=_0x1272d8['id'];_0x402cd0[_0x4a8d3c+_0xb8e3('0x69')]=_0x1272d8[_0xb8e3('0x64')]['id'];_0x402cd0[_0xb8e3('0x6a')+_0x4a8d3c+_0x5ba527+'Id']=_0x1272d8['Account']['id'];return db[_0x4a8d3c+_0xb8e3('0x73')][_0xb8e3('0x6b')](_0x402cd0);})[_0xb8e3('0xb')](function(){return respondWithRpcPromise(_0xb8e3('0x74'),{'channel':_0x49c965,'interaction':_0x1272d8[_0xb8e3('0x64')],'message':_0x1272d8,'account':_0x1272d8['Account'],'applications':[{'id':0x0,'priority':0x1,'app':_0xb8e3('0x71'),'appdata':_0x4b8fa4['name']+','+(_0x1272d8[_0xb8e3('0x65')]['agentTransferTimeout']||0x12c),'interval':'*,*,*,*'}]},routingClient);})[_0xb8e3('0xb')](respondWithResult(_0xbeb56f,null))[_0xb8e3('0xe')](handleError(_0xbeb56f,null));};
\ No newline at end of file
+var _0x9256=['OpenchannelQueues','showOpenchannelQueues','smsQueues','showSmsQueues','SmsQueues','whatsappQueues','WhatsappQueues','faxQueues','showFaxQueues','FaxQueues','faxAccounts','FaxAccounts','chatQueuesWaitingInteractions','mailQueuesWaitingInteractions','MailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','WhatsappQueuesWaitingInteractions','faxQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','capitalize','chat','Website','Account','Queue','\x20Queue\x20not\x20found','Message','findOne','Interaction','\x20Message\x20not\x20found','update','queue','From','TransferReport','create','Start','queueTransferTimeout','*,*,*,*','agentNotify','channel','Channel\x20field\x20is\x20mandatory','messageId','MessageId','InteractionId','agentTransferTimeout','bluebird','../../mysqldb','jayson/promise','client','http','request','then','error','code','message','json','sendStatus','stack','name','status','send','isNil','rows','voiceChannels','VoiceChannels','catch','VoiceChannelMixMonitor','merge','query','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','params','showVoiceQueues','VoiceQueues','voiceQueuesChannels','voiceQueuesChannel','VoiceQueuesChannelHangup','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','outbound','Outbound','outboundChannels','OutboundChannels','body','interaction','user','hasOwnProperty','MemberReport','findAll','length','format','updateAttributes','findOrCreate','INTERACTION','interface','SIP/%s','YYYY-MM-DD\x20HH:mm:ss','agent','internal','AgentCapacity','capacity','telephones','Telephones','trunks','campaigns','Campaigns','chatQueues','ChatQueues','showChatQueues','mailQueues','MailQueues','showMailQueues','mailAccounts','MailAccounts','openchannelQueues'];(function(_0x1abd5e,_0x607b87){var _0x39194a=function(_0x4cfff4){while(--_0x4cfff4){_0x1abd5e['push'](_0x1abd5e['shift']());}};_0x39194a(++_0x607b87);}(_0x9256,0xa8));var _0x6925=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x9256[_0x321bb2];return _0x9c12ed;};'use strict';var BPromise=require(_0x6925('0x0'));var moment=require('moment');var _=require('lodash');var util=require('util');var db=require(_0x6925('0x1'))['db'];var logger=require('../../config/logger')('api');var jayson=require(_0x6925('0x2'));var amiClient=jayson[_0x6925('0x3')]['http']({'port':0x232a});var mailClient=jayson[_0x6925('0x3')]['http']({'port':0x232b});var routingClient=jayson[_0x6925('0x3')][_0x6925('0x4')]({'port':0x232c});function respondWithRpcPromise(_0x5b82da,_0x508677,_0x1be7f5){return new BPromise(function(_0x592f35,_0x473bd6){var _0x40c127=_0x1be7f5?_0x1be7f5:amiClient;return _0x40c127[_0x6925('0x5')](_0x5b82da,_0x508677)[_0x6925('0x6')](function(_0x261172){if(_0x261172[_0x6925('0x7')]){if(_0x261172[_0x6925('0x7')][_0x6925('0x8')]===0x1f4){return _0x473bd6(_0x261172['error'][_0x6925('0x9')]);}return _0x592f35(_0x261172[_0x6925('0x7')][_0x6925('0x9')]);}else{_0x592f35(_0x261172['result']);}})['catch'](function(_0xd6fc25){_0x473bd6(_0xd6fc25);});});}function respondWithResult(_0x4ff240,_0x34d638){_0x34d638=_0x34d638||0xc8;return function(_0xc2279){if(_0xc2279){return _0x4ff240['status'](_0x34d638)[_0x6925('0xa')](_0xc2279);}return _0x4ff240[_0x6925('0xb')](0x194);};}function handleError(_0x55783d,_0x51963a){_0x51963a=_0x51963a||0x1f4;return function(_0x20382e){logger[_0x6925('0x7')](_0x20382e[_0x6925('0xc')]);if(_0x20382e[_0x6925('0xd')]){delete _0x20382e['name'];}_0x55783d[_0x6925('0xe')](_0x51963a)[_0x6925('0xf')](_0x20382e);};}function findById(_0x24c33e){return function(_0x23a535){if(!_[_0x6925('0x10')](_0x24c33e)&&!_[_0x6925('0x10')](_0x23a535)&&!_['isNil'](_0x23a535[_0x6925('0x11')])){return _['find'](_0x23a535['rows'],function(_0x2f5a6f){return _0x2f5a6f['id']==_0x24c33e;});}return null;};}exports[_0x6925('0x12')]=function(_0x3dcab7,_0x1ba39b){return respondWithRpcPromise(_0x6925('0x13'),_0x3dcab7['query'])[_0x6925('0x6')](respondWithResult(_0x1ba39b,null))[_0x6925('0x14')](handleError(_0x1ba39b,null));};exports['voiceChannelMixMonitor']=function(_0x37ee53,_0x2c0480){return respondWithRpcPromise(_0x6925('0x15'),_[_0x6925('0x16')](_0x37ee53[_0x6925('0x17')],_0x37ee53['params']))[_0x6925('0x6')](respondWithResult(_0x2c0480,null))[_0x6925('0x14')](handleError(_0x2c0480,null));};exports[_0x6925('0x18')]=function(_0x2fc475,_0x432f52){return respondWithRpcPromise(_0x6925('0x19'),_[_0x6925('0x16')](_0x2fc475[_0x6925('0x17')],_0x2fc475[_0x6925('0x1a')]))[_0x6925('0x6')](respondWithResult(_0x432f52,null))[_0x6925('0x14')](handleError(_0x432f52,null));};exports['voiceQueues']=function(_0x190f36,_0x528a2b){return respondWithRpcPromise('VoiceQueues',_0x190f36[_0x6925('0x17')])['then'](respondWithResult(_0x528a2b,null))[_0x6925('0x14')](handleError(_0x528a2b,null));};exports[_0x6925('0x1b')]=function(_0x53fcf1,_0x5a8b08){return respondWithRpcPromise(_0x6925('0x1c'),_0x53fcf1[_0x6925('0x17')])['then'](findById(_0x53fcf1[_0x6925('0x1a')]['id']))[_0x6925('0x6')](respondWithResult(_0x5a8b08,null))[_0x6925('0x14')](handleError(_0x5a8b08,null));};exports['voiceQueuesPreview']=function(_0x41524b,_0x40cfc5){return respondWithRpcPromise('VoiceQueuesPreview',_[_0x6925('0x16')](_0x41524b[_0x6925('0x17')],_0x41524b[_0x6925('0x1a')]))['then'](respondWithResult(_0x40cfc5,null))[_0x6925('0x14')](handleError(_0x40cfc5,null));};exports[_0x6925('0x1d')]=function(_0x4e8414,_0xb17526){return respondWithRpcPromise('VoiceQueuesChannels',_0x4e8414[_0x6925('0x17')])[_0x6925('0x6')](respondWithResult(_0xb17526,null))[_0x6925('0x14')](handleError(_0xb17526,null));};exports[_0x6925('0x1e')]=function(_0x115f1e,_0xb21117){return respondWithRpcPromise('VoiceQueuesChannel',_[_0x6925('0x16')](_0x115f1e[_0x6925('0x17')],_0x115f1e['params']))[_0x6925('0x6')](respondWithResult(_0xb21117,null))[_0x6925('0x14')](handleError(_0xb21117,null));};exports['voiceQueuesChannelHangup']=function(_0x4b370a,_0x1356be){return respondWithRpcPromise(_0x6925('0x1f'),_[_0x6925('0x16')](_0x4b370a[_0x6925('0x17')],_0x4b370a[_0x6925('0x1a')]))[_0x6925('0x6')](respondWithResult(_0x1356be,null))['catch'](handleError(_0x1356be,null));};exports[_0x6925('0x20')]=function(_0x33340c,_0x145fe2){return respondWithRpcPromise(_0x6925('0x21'),_[_0x6925('0x16')](_0x33340c[_0x6925('0x17')],_0x33340c['params']))[_0x6925('0x6')](respondWithResult(_0x145fe2,null))[_0x6925('0x14')](handleError(_0x145fe2,null));};exports[_0x6925('0x22')]=function(_0xb7d486,_0x1fefc2){return respondWithRpcPromise(_0x6925('0x23'),_0xb7d486[_0x6925('0x17')])['then'](respondWithResult(_0x1fefc2,null))[_0x6925('0x14')](handleError(_0x1fefc2,null));};exports[_0x6925('0x24')]=function(_0x2b8e20,_0x8b8d0c){return respondWithRpcPromise(_0x6925('0x25'),_0x2b8e20[_0x6925('0x17')])[_0x6925('0x6')](respondWithResult(_0x8b8d0c,null))[_0x6925('0x14')](handleError(_0x8b8d0c,null));};exports['agents']=function(_0x15f585,_0xea72c6){var _0x618a99;return respondWithRpcPromise('Agents',_0x15f585[_0x6925('0x17')])[_0x6925('0x6')](function(_0x10c483){_0x618a99=_0x10c483;return respondWithRpcPromise('Agents',_0x15f585['query'],routingClient);})[_0x6925('0x6')](function(_0xc327cc){return _[_0x6925('0x16')]({},_0xc327cc,_0x618a99);})[_0x6925('0x6')](respondWithResult(_0xea72c6,null))[_0x6925('0x14')](handleError(_0xea72c6,null));};exports['agentCapacity']=function(_0x52d7de,_0x1e7096){if(_0x52d7de[_0x6925('0x26')]&&_0x52d7de[_0x6925('0x26')][_0x6925('0x27')]&&_0x52d7de[_0x6925('0x28')]&&_0x52d7de[_0x6925('0x28')][_0x6925('0xd')]){for(var _0x1d8d4a in _0x52d7de['body'][_0x6925('0x27')]){if(_0x52d7de[_0x6925('0x26')][_0x6925('0x27')][_0x6925('0x29')](_0x1d8d4a)){db[_0x6925('0x2a')][_0x6925('0x2b')]({'where':{'channel':_0x1d8d4a,'membername':_0x52d7de['user']['name'],'type':'INTERACTION','exitAt':null,'uniqueid':_0x52d7de[_0x6925('0x26')]['interaction'][_0x1d8d4a]&&_0x52d7de['body']['interaction'][_0x1d8d4a][_0x6925('0x2c')]?{'$notIn':_0x52d7de[_0x6925('0x26')][_0x6925('0x27')][_0x1d8d4a]}:{'$ne':null}}})[_0x6925('0x6')](function(_0x4f55dd){var _0x5be7f3=moment()[_0x6925('0x2d')]('YYYY-MM-DD\x20HH:mm:ss');for(var _0x1d7ada=0x0,_0x3ef597=_0x4f55dd[_0x6925('0x2c')];_0x1d7ada<_0x3ef597;_0x1d7ada+=0x1){_0x4f55dd[_0x1d7ada][_0x6925('0x2e')]({'exitAt':_0x5be7f3});}});for(var _0x313830=0x0;_0x313830<_0x52d7de[_0x6925('0x26')][_0x6925('0x27')][_0x1d8d4a]['length'];_0x313830+=0x1){db[_0x6925('0x2a')][_0x6925('0x2f')]({'where':{'channel':_0x1d8d4a,'membername':_0x52d7de['user']['name'],'type':_0x6925('0x30'),'uniqueid':_0x52d7de[_0x6925('0x26')][_0x6925('0x27')][_0x1d8d4a][_0x313830],'exitAt':null},'defaults':{'channel':_0x1d8d4a,'membername':_0x52d7de[_0x6925('0x28')]['name'],'interface':_[_0x6925('0x10')](_0x52d7de[_0x6925('0x28')][_0x6925('0x31')])?util[_0x6925('0x2d')](_0x6925('0x32'),_0x52d7de['user'][_0x6925('0xd')]):_0x52d7de[_0x6925('0x28')][_0x6925('0x31')],'type':_0x6925('0x30'),'enterAt':moment()[_0x6925('0x2d')](_0x6925('0x33')),'role':_0x6925('0x34'),'internal':_0x52d7de[_0x6925('0x28')][_0x6925('0x35')],'uniqueid':_0x52d7de[_0x6925('0x26')]['interaction'][_0x1d8d4a][_0x313830]}});}}}}return respondWithRpcPromise(_0x6925('0x36'),{'id':_0x52d7de['params']['id'],'capacity':_0x52d7de[_0x6925('0x26')][_0x6925('0x37')]},routingClient)['then'](respondWithResult(_0x1e7096,null))[_0x6925('0x14')](handleError(_0x1e7096,null));};exports[_0x6925('0x38')]=function(_0x2c1389,_0x56a58e){return respondWithRpcPromise(_0x6925('0x39'),_0x2c1389['query'])[_0x6925('0x6')](respondWithResult(_0x56a58e,null))['catch'](handleError(_0x56a58e,null));};exports[_0x6925('0x3a')]=function(_0x6be525,_0x2c027a){return respondWithRpcPromise('Trunks',_0x6be525[_0x6925('0x17')])[_0x6925('0x6')](respondWithResult(_0x2c027a,null))[_0x6925('0x14')](handleError(_0x2c027a,null));};exports[_0x6925('0x3b')]=function(_0x5616ee,_0x14690b){return respondWithRpcPromise(_0x6925('0x3c'),_0x5616ee[_0x6925('0x17')])[_0x6925('0x6')](respondWithResult(_0x14690b,null))[_0x6925('0x14')](handleError(_0x14690b,null));};exports[_0x6925('0x3d')]=function(_0x1b6c9a,_0x1a11ef){return respondWithRpcPromise(_0x6925('0x3e'),_0x1b6c9a['query'],routingClient)[_0x6925('0x6')](respondWithResult(_0x1a11ef,null))[_0x6925('0x14')](handleError(_0x1a11ef,null));};exports[_0x6925('0x3f')]=function(_0x597147,_0x1612ff){return respondWithRpcPromise(_0x6925('0x3e'),_0x597147[_0x6925('0x17')],routingClient)[_0x6925('0x6')](findById(_0x597147[_0x6925('0x1a')]['id']))[_0x6925('0x6')](respondWithResult(_0x1612ff,null))['catch'](handleError(_0x1612ff,null));};exports[_0x6925('0x40')]=function(_0x2310cc,_0x59f6ee){return respondWithRpcPromise(_0x6925('0x41'),_0x2310cc['query'],routingClient)[_0x6925('0x6')](respondWithResult(_0x59f6ee,null))[_0x6925('0x14')](handleError(_0x59f6ee,null));};exports[_0x6925('0x42')]=function(_0x40e43a,_0x32572e){return respondWithRpcPromise(_0x6925('0x41'),_0x40e43a['query'],routingClient)[_0x6925('0x6')](findById(_0x40e43a[_0x6925('0x1a')]['id']))[_0x6925('0x6')](respondWithResult(_0x32572e,null))['catch'](handleError(_0x32572e,null));};exports[_0x6925('0x43')]=function(_0x4a98af,_0x1b4869){return respondWithRpcPromise(_0x6925('0x44'),_0x4a98af[_0x6925('0x17')],mailClient)['then'](respondWithResult(_0x1b4869,null))['catch'](handleError(_0x1b4869,null));};exports[_0x6925('0x45')]=function(_0x2608d8,_0x49229e){return respondWithRpcPromise(_0x6925('0x46'),_0x2608d8[_0x6925('0x17')],routingClient)[_0x6925('0x6')](respondWithResult(_0x49229e,null))[_0x6925('0x14')](handleError(_0x49229e,null));};exports[_0x6925('0x47')]=function(_0x537f4e,_0x2e0806){return respondWithRpcPromise(_0x6925('0x46'),_0x537f4e['query'],routingClient)[_0x6925('0x6')](findById(_0x537f4e[_0x6925('0x1a')]['id']))[_0x6925('0x6')](respondWithResult(_0x2e0806,null))['catch'](handleError(_0x2e0806,null));};exports[_0x6925('0x48')]=function(_0x30a8fa,_0x3ea102){return respondWithRpcPromise('SmsQueues',_0x30a8fa['query'],routingClient)['then'](respondWithResult(_0x3ea102,null))[_0x6925('0x14')](handleError(_0x3ea102,null));};exports[_0x6925('0x49')]=function(_0x58f6c6,_0x17b86d){return respondWithRpcPromise(_0x6925('0x4a'),_0x58f6c6[_0x6925('0x17')],routingClient)[_0x6925('0x6')](findById(_0x58f6c6[_0x6925('0x1a')]['id']))[_0x6925('0x6')](respondWithResult(_0x17b86d,null))['catch'](handleError(_0x17b86d,null));};exports[_0x6925('0x4b')]=function(_0x224513,_0x393fcf){return respondWithRpcPromise(_0x6925('0x4c'),_0x224513[_0x6925('0x17')],routingClient)[_0x6925('0x6')](respondWithResult(_0x393fcf,null))[_0x6925('0x14')](handleError(_0x393fcf,null));};exports['showWhatsappQueues']=function(_0x3d300f,_0x435135){return respondWithRpcPromise(_0x6925('0x4c'),_0x3d300f[_0x6925('0x17')],routingClient)[_0x6925('0x6')](findById(_0x3d300f['params']['id']))[_0x6925('0x6')](respondWithResult(_0x435135,null))[_0x6925('0x14')](handleError(_0x435135,null));};exports[_0x6925('0x4d')]=function(_0x5c0cd1,_0x570da9){return respondWithRpcPromise('FaxQueues',_0x5c0cd1[_0x6925('0x17')],routingClient)[_0x6925('0x6')](respondWithResult(_0x570da9,null))[_0x6925('0x14')](handleError(_0x570da9,null));};exports[_0x6925('0x4e')]=function(_0x20c31f,_0x160f7e){return respondWithRpcPromise(_0x6925('0x4f'),_0x20c31f[_0x6925('0x17')],routingClient)['then'](findById(_0x20c31f[_0x6925('0x1a')]['id']))['then'](respondWithResult(_0x160f7e,null))[_0x6925('0x14')](handleError(_0x160f7e,null));};exports[_0x6925('0x50')]=function(_0x13c4a7,_0x5c5da8){return respondWithRpcPromise(_0x6925('0x51'),_0x13c4a7[_0x6925('0x17')])[_0x6925('0x6')](respondWithResult(_0x5c5da8,null))[_0x6925('0x14')](handleError(_0x5c5da8,null));};exports[_0x6925('0x52')]=function(_0x4de220,_0x1a7ce7){return respondWithRpcPromise('ChatQueuesWaitingInteractions',_0x4de220[_0x6925('0x17')],routingClient)[_0x6925('0x6')](respondWithResult(_0x1a7ce7,null))['catch'](handleError(_0x1a7ce7,null));};exports[_0x6925('0x53')]=function(_0x172fe1,_0x5489ce){return respondWithRpcPromise(_0x6925('0x54'),_0x172fe1[_0x6925('0x17')],routingClient)[_0x6925('0x6')](respondWithResult(_0x5489ce,null))[_0x6925('0x14')](handleError(_0x5489ce,null));};exports[_0x6925('0x55')]=function(_0x2456f3,_0x537c72){return respondWithRpcPromise(_0x6925('0x56'),_0x2456f3[_0x6925('0x17')],routingClient)[_0x6925('0x6')](respondWithResult(_0x537c72,null))['catch'](handleError(_0x537c72,null));};exports[_0x6925('0x57')]=function(_0x22e2c4,_0x2b451e){return respondWithRpcPromise(_0x6925('0x58'),_0x22e2c4[_0x6925('0x17')],routingClient)['then'](respondWithResult(_0x2b451e,null))[_0x6925('0x14')](handleError(_0x2b451e,null));};exports[_0x6925('0x59')]=function(_0x4d8b28,_0x317025){return respondWithRpcPromise(_0x6925('0x5a'),_0x4d8b28[_0x6925('0x17')],routingClient)[_0x6925('0x6')](respondWithResult(_0x317025,null))['catch'](handleError(_0x317025,null));};exports[_0x6925('0x5b')]=function(_0x5a4f74,_0x76f4c){return respondWithRpcPromise(_0x6925('0x5c'),_0x5a4f74[_0x6925('0x17')],routingClient)[_0x6925('0x6')](respondWithResult(_0x76f4c,null))['catch'](handleError(_0x76f4c,null));};exports[_0x6925('0x5d')]=function(_0x47eb37){return function(_0x1c0f76,_0x553a2a){var _0x19bdc6,_0x569dd6;var _0x2c1fd8=_[_0x6925('0x5e')](_0x47eb37);var _0x8e3660=_0x47eb37===_0x6925('0x5f')?_0x6925('0x60'):_0x6925('0x61');return db[_0x2c1fd8+_0x6925('0x62')]['findOne']({'raw':!![],'where':{'id':_0x1c0f76['params']['id']}})[_0x6925('0x6')](function(_0x5c51ca){if(_[_0x6925('0x10')](_0x5c51ca)){throw new Error(_0x2c1fd8+_0x6925('0x63'));}_0x19bdc6=_0x5c51ca;return db[_0x2c1fd8+_0x6925('0x64')][_0x6925('0x65')]({'where':{'id':_0x1c0f76[_0x6925('0x26')]['messageId']},'include':[{'model':db[_0x2c1fd8+_0x6925('0x66')],'as':_0x6925('0x66')},{'model':db[_0x2c1fd8+_0x8e3660],'as':_0x6925('0x61')}]});})[_0x6925('0x6')](function(_0x2b5279){if(_[_0x6925('0x10')](_0x2b5279)){throw new Error(_0x2c1fd8+_0x6925('0x67'));}_0x569dd6=_0x2b5279;return _0x2b5279[_0x6925('0x68')]({'read':0x0,'readAt':null,'UserId':null});})['then'](function(){var _0x55d38a={'uniqueid':_0x47eb37+'.'+_0x569dd6['id']+'.'+_0x569dd6[_0x6925('0x66')]['id'],'FromUserId':_0x1c0f76['user']['id'],'type':_0x6925('0x69')};_0x55d38a[_0x2c1fd8+'MessageId']=_0x569dd6['id'];_0x55d38a[_0x2c1fd8+'InteractionId']=_0x569dd6[_0x6925('0x66')]['id'];_0x55d38a[_0x6925('0x6a')+_0x2c1fd8+_0x8e3660+'Id']=_0x569dd6['Account']['id'];_0x55d38a['To'+_0x2c1fd8+'QueueId']=_0x19bdc6['id'];return db[_0x2c1fd8+_0x6925('0x6b')][_0x6925('0x6c')](_0x55d38a);})['then'](function(){return respondWithRpcPromise(_0x6925('0x6d'),{'channel':_0x47eb37,'interaction':_0x569dd6[_0x6925('0x66')],'message':_0x569dd6,'account':_0x569dd6['Account'],'applications':[{'id':0x0,'priority':0x1,'app':_0x6925('0x69'),'appdata':_0x19bdc6[_0x6925('0xd')]+','+(_0x569dd6[_0x6925('0x61')][_0x6925('0x6e')]||0x12c),'interval':_0x6925('0x6f')}]},routingClient);})[_0x6925('0x6')](respondWithResult(_0x553a2a,null))[_0x6925('0x14')](handleError(_0x553a2a,null));};};exports[_0x6925('0x70')]=function(_0x61697a,_0x3580e3){var _0x46a635,_0x5ee645;if(_[_0x6925('0x10')](_0x61697a[_0x6925('0x26')][_0x6925('0x71')])){throw new Error(_0x6925('0x72'));}var _0xb8fc80=_0x61697a['body'][_0x6925('0x71')];var _0x2a198a=_[_0x6925('0x5e')](_0xb8fc80);var _0x3192e2=_0xb8fc80===_0x6925('0x5f')?_0x6925('0x60'):_0x6925('0x61');return db['User'][_0x6925('0x65')]({'raw':!![],'where':{'id':_0x61697a['params']['id'],'role':_0x6925('0x34')}})[_0x6925('0x6')](function(_0x4a7a20){if(_[_0x6925('0x10')](_0x4a7a20)){throw new Error('Agent\x20not\x20found');}_0x46a635=_0x4a7a20;return db[_0x2a198a+_0x6925('0x64')][_0x6925('0x65')]({'where':{'id':_0x61697a[_0x6925('0x26')][_0x6925('0x73')]},'include':[{'model':db[_0x2a198a+_0x6925('0x66')],'as':_0x6925('0x66')},{'model':db[_0x2a198a+_0x3192e2],'as':_0x6925('0x61')}]});})['then'](function(_0x24020e){if(_['isNil'](_0x24020e)){throw new Error(_0x2a198a+_0x6925('0x67'));}_0x5ee645=_0x24020e;return _0x24020e[_0x6925('0x68')]({'read':0x0,'readAt':null,'UserId':null});})[_0x6925('0x6')](function(){var _0x84c567={'uniqueid':_0xb8fc80+'.'+_0x5ee645['id']+'.'+_0x5ee645[_0x6925('0x66')]['id'],'FromUserId':_0x61697a[_0x6925('0x28')]['id'],'type':_0x6925('0x69'),'ToUserId':_0x46a635['id']};_0x84c567[_0x2a198a+_0x6925('0x74')]=_0x5ee645['id'];_0x84c567[_0x2a198a+_0x6925('0x75')]=_0x5ee645[_0x6925('0x66')]['id'];_0x84c567[_0x6925('0x6a')+_0x2a198a+_0x3192e2+'Id']=_0x5ee645[_0x6925('0x61')]['id'];return db[_0x2a198a+_0x6925('0x6b')][_0x6925('0x6c')](_0x84c567);})[_0x6925('0x6')](function(){return respondWithRpcPromise(_0x6925('0x6d'),{'channel':_0xb8fc80,'interaction':_0x5ee645['Interaction'],'message':_0x5ee645,'account':_0x5ee645[_0x6925('0x61')],'applications':[{'id':0x0,'priority':0x1,'app':_0x6925('0x34'),'appdata':_0x46a635[_0x6925('0xd')]+','+(_0x5ee645['Account'][_0x6925('0x76')]||0x12c),'interval':_0x6925('0x6f')}]},routingClient);})[_0x6925('0x6')](respondWithResult(_0x3580e3,null))[_0x6925('0x14')](handleError(_0x3580e3,null));};
\ No newline at end of file