18 var _0xdcbe=['sendStatus','name','send','isNil','rows','find','voiceChannels','VoiceChannels','query','catch','voiceChannelMixMonitor','VoiceChannelMixMonitor','merge','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','VoiceQueues','params','VoiceQueuesPreview','voiceQueuesChannels','VoiceQueuesChannels','voiceQueuesChannel','VoiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','VoiceQueuesChannelRedirect','outbound','outboundChannels','OutboundChannels','agents','Agents','agentCapacity','body','interaction','user','hasOwnProperty','MemberReport','findAll','INTERACTION','format','YYYY-MM-DD\x20HH:mm:ss','length','updateAttributes','findOrCreate','interface','SIP/%s','agent','internal','AgentCapacity','capacity','telephones','Telephones','trunks','campaigns','Campaigns','chatQueues','ChatQueues','showChatQueues','mailQueues','showMailQueues','MailQueues','mailAccounts','MailAccounts','openchannelQueues','showOpenchannelQueues','OpenchannelQueues','smsQueues','SmsQueues','showSmsQueues','WhatsappQueues','showWhatsappQueues','faxQueues','FaxQueues','showFaxQueues','FaxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','WhatsappQueuesWaitingInteractions','faxQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','capitalize','Website','findOne','\x20Queue\x20not\x20found','messageId','Interaction','\x20Message\x20not\x20found','update','queue','InteractionId','From','Account','QueueId','create','queueTransferTimeout','*,*,*,*','agentNotify','channel','Channel\x20field\x20is\x20mandatory','chat','User','Agent\x20not\x20found','Message','TransferReport','agentTransferTimeout','moment','lodash','util','../../config/logger','http','client','request','then','error','code','message','status','json'];(function(_0x6c993a,_0x5ea3ab){var _0x27f547=function(_0x22df20){while(--_0x22df20){_0x6c993a['push'](_0x6c993a['shift']());}};_0x27f547(++_0x5ea3ab);}(_0xdcbe,0x164));var _0xedcb=function(_0x285387,_0x4a226d){_0x285387=_0x285387-0x0;var _0x3a18b6=_0xdcbe[_0x285387];return _0x3a18b6;};'use strict';var BPromise=require('bluebird');var moment=require(_0xedcb('0x0'));var _=require(_0xedcb('0x1'));var util=require(_0xedcb('0x2'));var db=require('../../mysqldb')['db'];var logger=require(_0xedcb('0x3'))('api');var jayson=require('jayson/promise');var amiClient=jayson['client'][_0xedcb('0x4')]({'port':0x232a});var mailClient=jayson[_0xedcb('0x5')][_0xedcb('0x4')]({'port':0x232b});var routingClient=jayson['client'][_0xedcb('0x4')]({'port':0x232c});function respondWithRpcPromise(_0x154aa6,_0x914aa5,_0x233eff){return new BPromise(function(_0x423136,_0x90cf51){var _0x40cc37=_0x233eff?_0x233eff:amiClient;return _0x40cc37[_0xedcb('0x6')](_0x154aa6,_0x914aa5)[_0xedcb('0x7')](function(_0x21fa5c){if(_0x21fa5c[_0xedcb('0x8')]){if(_0x21fa5c[_0xedcb('0x8')][_0xedcb('0x9')]===0x1f4){return _0x90cf51(_0x21fa5c[_0xedcb('0x8')][_0xedcb('0xa')]);}return _0x423136(_0x21fa5c[_0xedcb('0x8')][_0xedcb('0xa')]);}else{_0x423136(_0x21fa5c['result']);}})['catch'](function(_0x5ef797){_0x90cf51(_0x5ef797);});});}function respondWithResult(_0x5e8553,_0x1eb0b2){_0x1eb0b2=_0x1eb0b2||0xc8;return function(_0x3e72af){if(_0x3e72af){return _0x5e8553[_0xedcb('0xb')](_0x1eb0b2)[_0xedcb('0xc')](_0x3e72af);}return _0x5e8553[_0xedcb('0xd')](0x194);};}function handleError(_0x48f941,_0x252a24){_0x252a24=_0x252a24||0x1f4;return function(_0x5895c0){logger['error'](_0x5895c0['stack']);if(_0x5895c0['name']){delete _0x5895c0[_0xedcb('0xe')];}_0x48f941[_0xedcb('0xb')](_0x252a24)[_0xedcb('0xf')](_0x5895c0);};}function findById(_0x1ecde0){return function(_0x5c4f50){if(!_['isNil'](_0x1ecde0)&&!_[_0xedcb('0x10')](_0x5c4f50)&&!_['isNil'](_0x5c4f50[_0xedcb('0x11')])){return _[_0xedcb('0x12')](_0x5c4f50[_0xedcb('0x11')],function(_0x5419a9){return _0x5419a9['id']==_0x1ecde0;});}return null;};}exports[_0xedcb('0x13')]=function(_0x59f3bf,_0x6b9bb9){return respondWithRpcPromise(_0xedcb('0x14'),_0x59f3bf[_0xedcb('0x15')])[_0xedcb('0x7')](respondWithResult(_0x6b9bb9,null))[_0xedcb('0x16')](handleError(_0x6b9bb9,null));};exports[_0xedcb('0x17')]=function(_0x3c2513,_0x4581db){return respondWithRpcPromise(_0xedcb('0x18'),_[_0xedcb('0x19')](_0x3c2513[_0xedcb('0x15')],_0x3c2513['params']))['then'](respondWithResult(_0x4581db,null))[_0xedcb('0x16')](handleError(_0x4581db,null));};exports[_0xedcb('0x1a')]=function(_0x41616f,_0x10ef44){return respondWithRpcPromise(_0xedcb('0x1b'),_[_0xedcb('0x19')](_0x41616f['query'],_0x41616f['params']))[_0xedcb('0x7')](respondWithResult(_0x10ef44,null))[_0xedcb('0x16')](handleError(_0x10ef44,null));};exports['voiceQueues']=function(_0x352f75,_0x4bd339){return respondWithRpcPromise('VoiceQueues',_0x352f75['query'])['then'](respondWithResult(_0x4bd339,null))[_0xedcb('0x16')](handleError(_0x4bd339,null));};exports['showVoiceQueues']=function(_0xc80eff,_0x1671b5){return respondWithRpcPromise(_0xedcb('0x1c'),_0xc80eff[_0xedcb('0x15')])['then'](findById(_0xc80eff[_0xedcb('0x1d')]['id']))[_0xedcb('0x7')](respondWithResult(_0x1671b5,null))[_0xedcb('0x16')](handleError(_0x1671b5,null));};exports['voiceQueuesPreview']=function(_0x258133,_0x154f0a){return respondWithRpcPromise(_0xedcb('0x1e'),_[_0xedcb('0x19')](_0x258133['query'],_0x258133[_0xedcb('0x1d')]))['then'](respondWithResult(_0x154f0a,null))[_0xedcb('0x16')](handleError(_0x154f0a,null));};exports[_0xedcb('0x1f')]=function(_0x3cf3a8,_0x238560){return respondWithRpcPromise(_0xedcb('0x20'),_0x3cf3a8[_0xedcb('0x15')])[_0xedcb('0x7')](respondWithResult(_0x238560,null))[_0xedcb('0x16')](handleError(_0x238560,null));};exports[_0xedcb('0x21')]=function(_0x227d8c,_0x38ab87){return respondWithRpcPromise(_0xedcb('0x22'),_[_0xedcb('0x19')](_0x227d8c[_0xedcb('0x15')],_0x227d8c[_0xedcb('0x1d')]))[_0xedcb('0x7')](respondWithResult(_0x38ab87,null))['catch'](handleError(_0x38ab87,null));};exports[_0xedcb('0x23')]=function(_0x2dd67d,_0x59837a){return respondWithRpcPromise(_0xedcb('0x24'),_[_0xedcb('0x19')](_0x2dd67d[_0xedcb('0x15')],_0x2dd67d[_0xedcb('0x1d')]))[_0xedcb('0x7')](respondWithResult(_0x59837a,null))[_0xedcb('0x16')](handleError(_0x59837a,null));};exports['voiceQueuesChannelRedirect']=function(_0x4f1b98,_0x286e56){return respondWithRpcPromise(_0xedcb('0x25'),_[_0xedcb('0x19')](_0x4f1b98[_0xedcb('0x15')],_0x4f1b98[_0xedcb('0x1d')]))[_0xedcb('0x7')](respondWithResult(_0x286e56,null))['catch'](handleError(_0x286e56,null));};exports[_0xedcb('0x26')]=function(_0x32eb9e,_0x466bbe){return respondWithRpcPromise('Outbound',_0x32eb9e[_0xedcb('0x15')])['then'](respondWithResult(_0x466bbe,null))[_0xedcb('0x16')](handleError(_0x466bbe,null));};exports[_0xedcb('0x27')]=function(_0x215c8c,_0x418d81){return respondWithRpcPromise(_0xedcb('0x28'),_0x215c8c[_0xedcb('0x15')])[_0xedcb('0x7')](respondWithResult(_0x418d81,null))[_0xedcb('0x16')](handleError(_0x418d81,null));};exports[_0xedcb('0x29')]=function(_0x4b42a0,_0x6f88aa){var _0x1f3951;return respondWithRpcPromise(_0xedcb('0x2a'),_0x4b42a0[_0xedcb('0x15')])['then'](function(_0x528808){_0x1f3951=_0x528808;return respondWithRpcPromise(_0xedcb('0x2a'),_0x4b42a0[_0xedcb('0x15')],routingClient);})[_0xedcb('0x7')](function(_0x519b01){return _[_0xedcb('0x19')]({},_0x519b01,_0x1f3951);})[_0xedcb('0x7')](respondWithResult(_0x6f88aa,null))[_0xedcb('0x16')](handleError(_0x6f88aa,null));};exports[_0xedcb('0x2b')]=function(_0x202fe2,_0x2cc4ea){if(_0x202fe2[_0xedcb('0x2c')]&&_0x202fe2[_0xedcb('0x2c')][_0xedcb('0x2d')]&&_0x202fe2[_0xedcb('0x2e')]&&_0x202fe2[_0xedcb('0x2e')][_0xedcb('0xe')]){for(var _0x21f139 in _0x202fe2[_0xedcb('0x2c')][_0xedcb('0x2d')]){if(_0x202fe2[_0xedcb('0x2c')][_0xedcb('0x2d')][_0xedcb('0x2f')](_0x21f139)){db[_0xedcb('0x30')][_0xedcb('0x31')]({'where':{'channel':_0x21f139,'membername':_0x202fe2['user']['name'],'type':_0xedcb('0x32'),'exitAt':null,'uniqueid':_0x202fe2[_0xedcb('0x2c')][_0xedcb('0x2d')][_0x21f139]&&_0x202fe2[_0xedcb('0x2c')][_0xedcb('0x2d')][_0x21f139]['length']?{'$notIn':_0x202fe2['body'][_0xedcb('0x2d')][_0x21f139]}:{'$ne':null}}})[_0xedcb('0x7')](function(_0x2ee8c2){var _0x2c0f2b=moment()[_0xedcb('0x33')](_0xedcb('0x34'));for(var _0xd8dd25=0x0,_0x1216c7=_0x2ee8c2[_0xedcb('0x35')];_0xd8dd25<_0x1216c7;_0xd8dd25+=0x1){_0x2ee8c2[_0xd8dd25][_0xedcb('0x36')]({'exitAt':_0x2c0f2b});}});for(var _0x5c8785=0x0;_0x5c8785<_0x202fe2[_0xedcb('0x2c')][_0xedcb('0x2d')][_0x21f139][_0xedcb('0x35')];_0x5c8785+=0x1){db[_0xedcb('0x30')][_0xedcb('0x37')]({'where':{'channel':_0x21f139,'membername':_0x202fe2[_0xedcb('0x2e')]['name'],'type':_0xedcb('0x32'),'uniqueid':_0x202fe2[_0xedcb('0x2c')][_0xedcb('0x2d')][_0x21f139][_0x5c8785],'exitAt':null},'defaults':{'channel':_0x21f139,'membername':_0x202fe2[_0xedcb('0x2e')]['name'],'interface':_[_0xedcb('0x10')](_0x202fe2['user'][_0xedcb('0x38')])?util[_0xedcb('0x33')](_0xedcb('0x39'),_0x202fe2[_0xedcb('0x2e')][_0xedcb('0xe')]):_0x202fe2[_0xedcb('0x2e')][_0xedcb('0x38')],'type':_0xedcb('0x32'),'enterAt':moment()[_0xedcb('0x33')](_0xedcb('0x34')),'role':_0xedcb('0x3a'),'internal':_0x202fe2[_0xedcb('0x2e')][_0xedcb('0x3b')],'uniqueid':_0x202fe2[_0xedcb('0x2c')][_0xedcb('0x2d')][_0x21f139][_0x5c8785]}});}}}}return respondWithRpcPromise(_0xedcb('0x3c'),{'id':_0x202fe2[_0xedcb('0x1d')]['id'],'capacity':_0x202fe2['body'][_0xedcb('0x3d')]},routingClient)[_0xedcb('0x7')](respondWithResult(_0x2cc4ea,null))[_0xedcb('0x16')](handleError(_0x2cc4ea,null));};exports[_0xedcb('0x3e')]=function(_0x420c7b,_0x40a42a){return respondWithRpcPromise(_0xedcb('0x3f'),_0x420c7b[_0xedcb('0x15')])[_0xedcb('0x7')](respondWithResult(_0x40a42a,null))['catch'](handleError(_0x40a42a,null));};exports[_0xedcb('0x40')]=function(_0x5107da,_0x1d2908){return respondWithRpcPromise('Trunks',_0x5107da[_0xedcb('0x15')])[_0xedcb('0x7')](respondWithResult(_0x1d2908,null))['catch'](handleError(_0x1d2908,null));};exports[_0xedcb('0x41')]=function(_0x32a1c9,_0x33338b){return respondWithRpcPromise(_0xedcb('0x42'),_0x32a1c9[_0xedcb('0x15')])['then'](respondWithResult(_0x33338b,null))[_0xedcb('0x16')](handleError(_0x33338b,null));};exports[_0xedcb('0x43')]=function(_0x1d3516,_0x3b18e4){return respondWithRpcPromise(_0xedcb('0x44'),_0x1d3516[_0xedcb('0x15')],routingClient)[_0xedcb('0x7')](respondWithResult(_0x3b18e4,null))['catch'](handleError(_0x3b18e4,null));};exports[_0xedcb('0x45')]=function(_0x81f22,_0x2c8b0c){return respondWithRpcPromise(_0xedcb('0x44'),_0x81f22['query'],routingClient)[_0xedcb('0x7')](findById(_0x81f22[_0xedcb('0x1d')]['id']))[_0xedcb('0x7')](respondWithResult(_0x2c8b0c,null))[_0xedcb('0x16')](handleError(_0x2c8b0c,null));};exports[_0xedcb('0x46')]=function(_0x1dcb0a,_0x1da4ae){return respondWithRpcPromise('MailQueues',_0x1dcb0a[_0xedcb('0x15')],routingClient)[_0xedcb('0x7')](respondWithResult(_0x1da4ae,null))['catch'](handleError(_0x1da4ae,null));};exports[_0xedcb('0x47')]=function(_0x9d3d18,_0xf9b9ab){return respondWithRpcPromise(_0xedcb('0x48'),_0x9d3d18[_0xedcb('0x15')],routingClient)[_0xedcb('0x7')](findById(_0x9d3d18['params']['id']))[_0xedcb('0x7')](respondWithResult(_0xf9b9ab,null))[_0xedcb('0x16')](handleError(_0xf9b9ab,null));};exports[_0xedcb('0x49')]=function(_0x2b4850,_0x2b15b0){return respondWithRpcPromise(_0xedcb('0x4a'),_0x2b4850['query'],mailClient)[_0xedcb('0x7')](respondWithResult(_0x2b15b0,null))[_0xedcb('0x16')](handleError(_0x2b15b0,null));};exports[_0xedcb('0x4b')]=function(_0x11fe50,_0x54a527){return respondWithRpcPromise('OpenchannelQueues',_0x11fe50['query'],routingClient)['then'](respondWithResult(_0x54a527,null))[_0xedcb('0x16')](handleError(_0x54a527,null));};exports[_0xedcb('0x4c')]=function(_0xd5e8d0,_0x317b1d){return respondWithRpcPromise(_0xedcb('0x4d'),_0xd5e8d0['query'],routingClient)[_0xedcb('0x7')](findById(_0xd5e8d0['params']['id']))[_0xedcb('0x7')](respondWithResult(_0x317b1d,null))['catch'](handleError(_0x317b1d,null));};exports[_0xedcb('0x4e')]=function(_0x42ea66,_0x2c5798){return respondWithRpcPromise(_0xedcb('0x4f'),_0x42ea66[_0xedcb('0x15')],routingClient)[_0xedcb('0x7')](respondWithResult(_0x2c5798,null))[_0xedcb('0x16')](handleError(_0x2c5798,null));};exports[_0xedcb('0x50')]=function(_0x22da49,_0x2ca4f9){return respondWithRpcPromise('SmsQueues',_0x22da49['query'],routingClient)['then'](findById(_0x22da49[_0xedcb('0x1d')]['id']))[_0xedcb('0x7')](respondWithResult(_0x2ca4f9,null))[_0xedcb('0x16')](handleError(_0x2ca4f9,null));};exports['whatsappQueues']=function(_0xebfec8,_0x436ba6){return respondWithRpcPromise(_0xedcb('0x51'),_0xebfec8[_0xedcb('0x15')],routingClient)['then'](respondWithResult(_0x436ba6,null))[_0xedcb('0x16')](handleError(_0x436ba6,null));};exports[_0xedcb('0x52')]=function(_0x25744f,_0x3849fb){return respondWithRpcPromise(_0xedcb('0x51'),_0x25744f['query'],routingClient)[_0xedcb('0x7')](findById(_0x25744f[_0xedcb('0x1d')]['id']))[_0xedcb('0x7')](respondWithResult(_0x3849fb,null))['catch'](handleError(_0x3849fb,null));};exports[_0xedcb('0x53')]=function(_0x3e1827,_0x5eaff2){return respondWithRpcPromise(_0xedcb('0x54'),_0x3e1827[_0xedcb('0x15')],routingClient)[_0xedcb('0x7')](respondWithResult(_0x5eaff2,null))[_0xedcb('0x16')](handleError(_0x5eaff2,null));};exports[_0xedcb('0x55')]=function(_0x27cbf0,_0x5c012d){return respondWithRpcPromise(_0xedcb('0x54'),_0x27cbf0['query'],routingClient)[_0xedcb('0x7')](findById(_0x27cbf0[_0xedcb('0x1d')]['id']))['then'](respondWithResult(_0x5c012d,null))[_0xedcb('0x16')](handleError(_0x5c012d,null));};exports['faxAccounts']=function(_0x55c40f,_0x269fa0){return respondWithRpcPromise(_0xedcb('0x56'),_0x55c40f[_0xedcb('0x15')])[_0xedcb('0x7')](respondWithResult(_0x269fa0,null))[_0xedcb('0x16')](handleError(_0x269fa0,null));};exports[_0xedcb('0x57')]=function(_0x2dd481,_0xc03269){return respondWithRpcPromise(_0xedcb('0x58'),_0x2dd481[_0xedcb('0x15')],routingClient)['then'](respondWithResult(_0xc03269,null))[_0xedcb('0x16')](handleError(_0xc03269,null));};exports[_0xedcb('0x59')]=function(_0x5366d0,_0x5678d5){return respondWithRpcPromise('MailQueuesWaitingInteractions',_0x5366d0[_0xedcb('0x15')],routingClient)['then'](respondWithResult(_0x5678d5,null))[_0xedcb('0x16')](handleError(_0x5678d5,null));};exports['openchannelQueuesWaitingInteractions']=function(_0x4453ca,_0x112acb){return respondWithRpcPromise(_0xedcb('0x5a'),_0x4453ca[_0xedcb('0x15')],routingClient)[_0xedcb('0x7')](respondWithResult(_0x112acb,null))['catch'](handleError(_0x112acb,null));};exports[_0xedcb('0x5b')]=function(_0x4c102d,_0x2915ea){return respondWithRpcPromise(_0xedcb('0x5c'),_0x4c102d['query'],routingClient)[_0xedcb('0x7')](respondWithResult(_0x2915ea,null))['catch'](handleError(_0x2915ea,null));};exports[_0xedcb('0x5d')]=function(_0x2d13c7,_0x1b40e7){return respondWithRpcPromise(_0xedcb('0x5e'),_0x2d13c7['query'],routingClient)[_0xedcb('0x7')](respondWithResult(_0x1b40e7,null))[_0xedcb('0x16')](handleError(_0x1b40e7,null));};exports[_0xedcb('0x5f')]=function(_0x3a4215,_0x2d98ab){return respondWithRpcPromise(_0xedcb('0x60'),_0x3a4215[_0xedcb('0x15')],routingClient)[_0xedcb('0x7')](respondWithResult(_0x2d98ab,null))[_0xedcb('0x16')](handleError(_0x2d98ab,null));};exports[_0xedcb('0x61')]=function(_0x31d6a5){return function(_0x1da9f2,_0x1cc8a4){var _0x4262f3,_0x57454f;var _0x2e23a7=_[_0xedcb('0x62')](_0x31d6a5);var _0x1b7e91=_0x31d6a5==='chat'?_0xedcb('0x63'):'Account';return db[_0x2e23a7+'Queue'][_0xedcb('0x64')]({'raw':!![],'where':{'id':_0x1da9f2[_0xedcb('0x1d')]['id']}})[_0xedcb('0x7')](function(_0xd22d0a){if(_['isNil'](_0xd22d0a)){throw new Error(_0x2e23a7+_0xedcb('0x65'));}_0x4262f3=_0xd22d0a;return db[_0x2e23a7+'Message'][_0xedcb('0x64')]({'where':{'id':_0x1da9f2[_0xedcb('0x2c')][_0xedcb('0x66')]},'include':[{'model':db[_0x2e23a7+_0xedcb('0x67')],'as':_0xedcb('0x67')},{'model':db[_0x2e23a7+_0x1b7e91],'as':'Account'}]});})[_0xedcb('0x7')](function(_0x4db277){if(_['isNil'](_0x4db277)){throw new Error(_0x2e23a7+_0xedcb('0x68'));}_0x57454f=_0x4db277;return _0x4db277[_0xedcb('0x69')]({'read':0x0,'readAt':null,'UserId':null});})[_0xedcb('0x7')](function(){var _0xa8a184={'uniqueid':_0x31d6a5+'.'+_0x57454f['id']+'.'+_0x57454f[_0xedcb('0x67')]['id'],'FromUserId':_0x1da9f2['user']['id'],'type':_0xedcb('0x6a')};_0xa8a184[_0x2e23a7+'MessageId']=_0x57454f['id'];_0xa8a184[_0x2e23a7+_0xedcb('0x6b')]=_0x57454f[_0xedcb('0x67')]['id'];_0xa8a184[_0xedcb('0x6c')+_0x2e23a7+_0x1b7e91+'Id']=_0x57454f[_0xedcb('0x6d')]['id'];_0xa8a184['To'+_0x2e23a7+_0xedcb('0x6e')]=_0x4262f3['id'];return db[_0x2e23a7+'TransferReport'][_0xedcb('0x6f')](_0xa8a184);})[_0xedcb('0x7')](function(){return respondWithRpcPromise('Start',{'channel':_0x31d6a5,'interaction':_0x57454f[_0xedcb('0x67')],'message':_0x57454f,'account':_0x57454f[_0xedcb('0x6d')],'applications':[{'id':0x0,'priority':0x1,'app':_0xedcb('0x6a'),'appdata':_0x4262f3['name']+','+(_0x57454f[_0xedcb('0x6d')][_0xedcb('0x70')]||0x12c),'interval':_0xedcb('0x71')}]},routingClient);})['then'](respondWithResult(_0x1cc8a4,null))[_0xedcb('0x16')](handleError(_0x1cc8a4,null));};};exports[_0xedcb('0x72')]=function(_0x5607c2,_0x1b25df){var _0x567105,_0x4843d4;if(_[_0xedcb('0x10')](_0x5607c2[_0xedcb('0x2c')][_0xedcb('0x73')])){throw new Error(_0xedcb('0x74'));}var _0x57c616=_0x5607c2[_0xedcb('0x2c')][_0xedcb('0x73')];var _0x175366=_[_0xedcb('0x62')](_0x57c616);var _0x1f6ffd=_0x57c616===_0xedcb('0x75')?_0xedcb('0x63'):_0xedcb('0x6d');return db[_0xedcb('0x76')][_0xedcb('0x64')]({'raw':!![],'where':{'id':_0x5607c2[_0xedcb('0x1d')]['id'],'role':_0xedcb('0x3a')}})[_0xedcb('0x7')](function(_0xeaec58){if(_[_0xedcb('0x10')](_0xeaec58)){throw new Error(_0xedcb('0x77'));}_0x567105=_0xeaec58;return db[_0x175366+_0xedcb('0x78')]['findOne']({'where':{'id':_0x5607c2[_0xedcb('0x2c')]['messageId']},'include':[{'model':db[_0x175366+_0xedcb('0x67')],'as':'Interaction'},{'model':db[_0x175366+_0x1f6ffd],'as':'Account'}]});})[_0xedcb('0x7')](function(_0x57bdde){if(_['isNil'](_0x57bdde)){throw new Error(_0x175366+_0xedcb('0x68'));}_0x4843d4=_0x57bdde;return _0x57bdde[_0xedcb('0x69')]({'read':0x0,'readAt':null,'UserId':null});})['then'](function(){var _0x246115={'uniqueid':_0x57c616+'.'+_0x4843d4['id']+'.'+_0x4843d4[_0xedcb('0x67')]['id'],'FromUserId':_0x5607c2[_0xedcb('0x2e')]['id'],'type':_0xedcb('0x6a'),'ToUserId':_0x567105['id']};_0x246115[_0x175366+'MessageId']=_0x4843d4['id'];_0x246115[_0x175366+_0xedcb('0x6b')]=_0x4843d4[_0xedcb('0x67')]['id'];_0x246115['From'+_0x175366+_0x1f6ffd+'Id']=_0x4843d4['Account']['id'];return db[_0x175366+_0xedcb('0x79')][_0xedcb('0x6f')](_0x246115);})[_0xedcb('0x7')](function(){return respondWithRpcPromise('Start',{'channel':_0x57c616,'interaction':_0x4843d4['Interaction'],'message':_0x4843d4,'account':_0x4843d4[_0xedcb('0x6d')],'applications':[{'id':0x0,'priority':0x1,'app':_0xedcb('0x3a'),'appdata':_0x567105[_0xedcb('0xe')]+','+(_0x4843d4[_0xedcb('0x6d')][_0xedcb('0x7a')]||0x12c),'interval':_0xedcb('0x71')}]},routingClient);})['then'](respondWithResult(_0x1b25df,null))['catch'](handleError(_0x1b25df,null));};