Built motion from commit (unavailable).|2.3.91
[motion2.git] / server / api / rpc / rpc.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xde91=['faxAccounts','FaxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','MailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','faxQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','capitalize','Website','Account','Queue','findOne','messageId','Interaction','\x20Message\x20not\x20found','update','queue','QueueId','TransferReport','Start','agentNotify','channel','chat','User','agent','Message','MessageId','InteractionId','*,*,*,*','lodash','util','../../mysqldb','../../config/logger','jayson/promise','client','http','error','message','result','status','json','sendStatus','stack','name','send','isNil','rows','find','voiceChannels','VoiceChannels','query','then','catch','voiceChannelMixMonitor','VoiceChannelMixMonitor','merge','params','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','voiceQueues','showVoiceQueues','voiceQueuesPreview','VoiceQueuesPreview','voiceQueuesChannels','voiceQueuesChannel','VoiceQueuesChannel','VoiceQueuesChannelHangup','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','outbound','Outbound','outboundChannels','Agents','agentCapacity','body','interaction','user','hasOwnProperty','findAll','INTERACTION','length','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','findOrCreate','format','SIP/%s','interface','internal','AgentCapacity','capacity','Telephones','trunks','Trunks','Campaigns','chatQueues','ChatQueues','showChatQueues','mailQueues','showMailQueues','MailAccounts','openchannelQueues','OpenchannelQueues','showOpenchannelQueues','smsQueues','SmsQueues','faxQueues','FaxQueues','showFaxQueues'];(function(_0x4826d0,_0x1c012b){var _0x237924=function(_0x1ae4d2){while(--_0x1ae4d2){_0x4826d0['push'](_0x4826d0['shift']());}};_0x237924(++_0x1c012b);}(_0xde91,0x95));var _0x1de9=function(_0x134192,_0x36adc5){_0x134192=_0x134192-0x0;var _0x3cd080=_0xde91[_0x134192];return _0x3cd080;};'use strict';var BPromise=require('bluebird');var moment=require('moment');var _=require(_0x1de9('0x0'));var util=require(_0x1de9('0x1'));var db=require(_0x1de9('0x2'))['db'];var logger=require(_0x1de9('0x3'))('api');var jayson=require(_0x1de9('0x4'));var amiClient=jayson[_0x1de9('0x5')][_0x1de9('0x6')]({'port':0x232a});var mailClient=jayson[_0x1de9('0x5')][_0x1de9('0x6')]({'port':0x232b});var routingClient=jayson[_0x1de9('0x5')][_0x1de9('0x6')]({'port':0x232c});function respondWithRpcPromise(_0x31384d,_0x2d0be2,_0xbe8c4f){return new BPromise(function(_0x229f31,_0x51c8af){var _0x4469dd=_0xbe8c4f?_0xbe8c4f:amiClient;return _0x4469dd['request'](_0x31384d,_0x2d0be2)['then'](function(_0x5c0e7e){if(_0x5c0e7e[_0x1de9('0x7')]){if(_0x5c0e7e[_0x1de9('0x7')]['code']===0x1f4){return _0x51c8af(_0x5c0e7e[_0x1de9('0x7')][_0x1de9('0x8')]);}return _0x229f31(_0x5c0e7e[_0x1de9('0x7')]['message']);}else{_0x229f31(_0x5c0e7e[_0x1de9('0x9')]);}})['catch'](function(_0x4a518e){_0x51c8af(_0x4a518e);});});}function respondWithResult(_0x3c297a,_0x16406d){_0x16406d=_0x16406d||0xc8;return function(_0x144b0a){if(_0x144b0a){return _0x3c297a[_0x1de9('0xa')](_0x16406d)[_0x1de9('0xb')](_0x144b0a);}return _0x3c297a[_0x1de9('0xc')](0x194);};}function handleError(_0x4a2f7a,_0x3a9036){_0x3a9036=_0x3a9036||0x1f4;return function(_0x1aa165){logger['error'](_0x1aa165[_0x1de9('0xd')]);if(_0x1aa165['name']){delete _0x1aa165[_0x1de9('0xe')];}_0x4a2f7a[_0x1de9('0xa')](_0x3a9036)[_0x1de9('0xf')](_0x1aa165);};}function findById(_0x249f97){return function(_0x59f603){if(!_[_0x1de9('0x10')](_0x249f97)&&!_[_0x1de9('0x10')](_0x59f603)&&!_[_0x1de9('0x10')](_0x59f603[_0x1de9('0x11')])){return _[_0x1de9('0x12')](_0x59f603['rows'],function(_0x30eb33){return _0x30eb33['id']==_0x249f97;});}return null;};}exports[_0x1de9('0x13')]=function(_0x5047a8,_0x30f4de){return respondWithRpcPromise(_0x1de9('0x14'),_0x5047a8[_0x1de9('0x15')])[_0x1de9('0x16')](respondWithResult(_0x30f4de,null))[_0x1de9('0x17')](handleError(_0x30f4de,null));};exports[_0x1de9('0x18')]=function(_0x4c3196,_0x140fbc){return respondWithRpcPromise(_0x1de9('0x19'),_[_0x1de9('0x1a')](_0x4c3196[_0x1de9('0x15')],_0x4c3196[_0x1de9('0x1b')]))[_0x1de9('0x16')](respondWithResult(_0x140fbc,null))[_0x1de9('0x17')](handleError(_0x140fbc,null));};exports[_0x1de9('0x1c')]=function(_0x20b354,_0x391e13){return respondWithRpcPromise(_0x1de9('0x1d'),_[_0x1de9('0x1a')](_0x20b354[_0x1de9('0x15')],_0x20b354['params']))['then'](respondWithResult(_0x391e13,null))[_0x1de9('0x17')](handleError(_0x391e13,null));};exports[_0x1de9('0x1e')]=function(_0x52d43a,_0x11e146){return respondWithRpcPromise('VoiceQueues',_0x52d43a[_0x1de9('0x15')])['then'](respondWithResult(_0x11e146,null))[_0x1de9('0x17')](handleError(_0x11e146,null));};exports[_0x1de9('0x1f')]=function(_0x3bb8b3,_0x415139){return respondWithRpcPromise('VoiceQueues',_0x3bb8b3[_0x1de9('0x15')])[_0x1de9('0x16')](findById(_0x3bb8b3[_0x1de9('0x1b')]['id']))[_0x1de9('0x16')](respondWithResult(_0x415139,null))[_0x1de9('0x17')](handleError(_0x415139,null));};exports[_0x1de9('0x20')]=function(_0x563a91,_0x56ce92){return respondWithRpcPromise(_0x1de9('0x21'),_[_0x1de9('0x1a')](_0x563a91[_0x1de9('0x15')],_0x563a91['params']))[_0x1de9('0x16')](respondWithResult(_0x56ce92,null))[_0x1de9('0x17')](handleError(_0x56ce92,null));};exports[_0x1de9('0x22')]=function(_0x491f8b,_0x1cf08d){return respondWithRpcPromise('VoiceQueuesChannels',_0x491f8b[_0x1de9('0x15')])[_0x1de9('0x16')](respondWithResult(_0x1cf08d,null))[_0x1de9('0x17')](handleError(_0x1cf08d,null));};exports[_0x1de9('0x23')]=function(_0x13ed26,_0x3e33af){return respondWithRpcPromise(_0x1de9('0x24'),_[_0x1de9('0x1a')](_0x13ed26[_0x1de9('0x15')],_0x13ed26[_0x1de9('0x1b')]))[_0x1de9('0x16')](respondWithResult(_0x3e33af,null))[_0x1de9('0x17')](handleError(_0x3e33af,null));};exports['voiceQueuesChannelHangup']=function(_0x4e3b8d,_0x27c95f){return respondWithRpcPromise(_0x1de9('0x25'),_[_0x1de9('0x1a')](_0x4e3b8d[_0x1de9('0x15')],_0x4e3b8d['params']))[_0x1de9('0x16')](respondWithResult(_0x27c95f,null))[_0x1de9('0x17')](handleError(_0x27c95f,null));};exports[_0x1de9('0x26')]=function(_0xffaa9b,_0x5f2994){return respondWithRpcPromise(_0x1de9('0x27'),_[_0x1de9('0x1a')](_0xffaa9b['query'],_0xffaa9b[_0x1de9('0x1b')]))[_0x1de9('0x16')](respondWithResult(_0x5f2994,null))[_0x1de9('0x17')](handleError(_0x5f2994,null));};exports[_0x1de9('0x28')]=function(_0x2cd36f,_0x5c8db8){return respondWithRpcPromise(_0x1de9('0x29'),_0x2cd36f[_0x1de9('0x15')])[_0x1de9('0x16')](respondWithResult(_0x5c8db8,null))['catch'](handleError(_0x5c8db8,null));};exports[_0x1de9('0x2a')]=function(_0x4023a9,_0x251f28){return respondWithRpcPromise('OutboundChannels',_0x4023a9[_0x1de9('0x15')])['then'](respondWithResult(_0x251f28,null))[_0x1de9('0x17')](handleError(_0x251f28,null));};exports['agents']=function(_0x34ea2c,_0x2117bb){var _0x1b9c57;return respondWithRpcPromise(_0x1de9('0x2b'),_0x34ea2c[_0x1de9('0x15')])[_0x1de9('0x16')](function(_0x891da){_0x1b9c57=_0x891da;return respondWithRpcPromise('Agents',_0x34ea2c[_0x1de9('0x15')],routingClient);})[_0x1de9('0x16')](function(_0x391374){return _[_0x1de9('0x1a')]({},_0x391374,_0x1b9c57);})['then'](respondWithResult(_0x2117bb,null))[_0x1de9('0x17')](handleError(_0x2117bb,null));};exports[_0x1de9('0x2c')]=function(_0x3679b7,_0x138026){if(_0x3679b7[_0x1de9('0x2d')]&&_0x3679b7[_0x1de9('0x2d')][_0x1de9('0x2e')]&&_0x3679b7[_0x1de9('0x2f')]&&_0x3679b7[_0x1de9('0x2f')][_0x1de9('0xe')]){for(var _0x4693f4 in _0x3679b7[_0x1de9('0x2d')]['interaction']){if(_0x3679b7[_0x1de9('0x2d')][_0x1de9('0x2e')][_0x1de9('0x30')](_0x4693f4)){db['MemberReport'][_0x1de9('0x31')]({'where':{'channel':_0x4693f4,'membername':_0x3679b7[_0x1de9('0x2f')][_0x1de9('0xe')],'type':_0x1de9('0x32'),'exitAt':null,'uniqueid':_0x3679b7['body'][_0x1de9('0x2e')][_0x4693f4]&&_0x3679b7[_0x1de9('0x2d')][_0x1de9('0x2e')][_0x4693f4][_0x1de9('0x33')]?{'$notIn':_0x3679b7[_0x1de9('0x2d')][_0x1de9('0x2e')][_0x4693f4]}:{'$ne':null}}})[_0x1de9('0x16')](function(_0x2a4912){var _0x2d5db3=moment()['format'](_0x1de9('0x34'));for(var _0x5a0b56=0x0,_0x5eee25=_0x2a4912[_0x1de9('0x33')];_0x5a0b56<_0x5eee25;_0x5a0b56+=0x1){_0x2a4912[_0x5a0b56][_0x1de9('0x35')]({'exitAt':_0x2d5db3});}});for(var _0x356fb7=0x0;_0x356fb7<_0x3679b7[_0x1de9('0x2d')][_0x1de9('0x2e')][_0x4693f4][_0x1de9('0x33')];_0x356fb7+=0x1){db['MemberReport'][_0x1de9('0x36')]({'where':{'channel':_0x4693f4,'membername':_0x3679b7[_0x1de9('0x2f')][_0x1de9('0xe')],'type':_0x1de9('0x32'),'uniqueid':_0x3679b7[_0x1de9('0x2d')][_0x1de9('0x2e')][_0x4693f4][_0x356fb7],'exitAt':null},'defaults':{'channel':_0x4693f4,'membername':_0x3679b7['user'][_0x1de9('0xe')],'interface':_[_0x1de9('0x10')](_0x3679b7[_0x1de9('0x2f')]['interface'])?util[_0x1de9('0x37')](_0x1de9('0x38'),_0x3679b7[_0x1de9('0x2f')][_0x1de9('0xe')]):_0x3679b7[_0x1de9('0x2f')][_0x1de9('0x39')],'type':'INTERACTION','enterAt':moment()['format'](_0x1de9('0x34')),'role':'agent','internal':_0x3679b7[_0x1de9('0x2f')][_0x1de9('0x3a')],'uniqueid':_0x3679b7['body']['interaction'][_0x4693f4][_0x356fb7]}});}}}}return respondWithRpcPromise(_0x1de9('0x3b'),{'id':_0x3679b7['params']['id'],'capacity':_0x3679b7['body'][_0x1de9('0x3c')]},routingClient)[_0x1de9('0x16')](respondWithResult(_0x138026,null))[_0x1de9('0x17')](handleError(_0x138026,null));};exports['telephones']=function(_0x1b82c3,_0x6d8046){return respondWithRpcPromise(_0x1de9('0x3d'),_0x1b82c3[_0x1de9('0x15')])[_0x1de9('0x16')](respondWithResult(_0x6d8046,null))[_0x1de9('0x17')](handleError(_0x6d8046,null));};exports[_0x1de9('0x3e')]=function(_0x48d860,_0x3ce24d){return respondWithRpcPromise(_0x1de9('0x3f'),_0x48d860[_0x1de9('0x15')])['then'](respondWithResult(_0x3ce24d,null))['catch'](handleError(_0x3ce24d,null));};exports['campaigns']=function(_0x118410,_0x57e7cd){return respondWithRpcPromise(_0x1de9('0x40'),_0x118410[_0x1de9('0x15')])[_0x1de9('0x16')](respondWithResult(_0x57e7cd,null))[_0x1de9('0x17')](handleError(_0x57e7cd,null));};exports[_0x1de9('0x41')]=function(_0x57d1e4,_0x3e0d3a){return respondWithRpcPromise(_0x1de9('0x42'),_0x57d1e4[_0x1de9('0x15')],routingClient)[_0x1de9('0x16')](respondWithResult(_0x3e0d3a,null))[_0x1de9('0x17')](handleError(_0x3e0d3a,null));};exports[_0x1de9('0x43')]=function(_0x1176b1,_0x2fd07b){return respondWithRpcPromise('ChatQueues',_0x1176b1[_0x1de9('0x15')],routingClient)[_0x1de9('0x16')](findById(_0x1176b1[_0x1de9('0x1b')]['id']))[_0x1de9('0x16')](respondWithResult(_0x2fd07b,null))[_0x1de9('0x17')](handleError(_0x2fd07b,null));};exports[_0x1de9('0x44')]=function(_0x4321b3,_0x22ca5d){return respondWithRpcPromise('MailQueues',_0x4321b3[_0x1de9('0x15')],routingClient)['then'](respondWithResult(_0x22ca5d,null))[_0x1de9('0x17')](handleError(_0x22ca5d,null));};exports[_0x1de9('0x45')]=function(_0x543733,_0x3cfe07){return respondWithRpcPromise('MailQueues',_0x543733[_0x1de9('0x15')],routingClient)['then'](findById(_0x543733[_0x1de9('0x1b')]['id']))[_0x1de9('0x16')](respondWithResult(_0x3cfe07,null))['catch'](handleError(_0x3cfe07,null));};exports['mailAccounts']=function(_0x34a897,_0x886a32){return respondWithRpcPromise(_0x1de9('0x46'),_0x34a897[_0x1de9('0x15')],mailClient)[_0x1de9('0x16')](respondWithResult(_0x886a32,null))['catch'](handleError(_0x886a32,null));};exports[_0x1de9('0x47')]=function(_0x3b5f95,_0xa48bbf){return respondWithRpcPromise(_0x1de9('0x48'),_0x3b5f95[_0x1de9('0x15')],routingClient)[_0x1de9('0x16')](respondWithResult(_0xa48bbf,null))[_0x1de9('0x17')](handleError(_0xa48bbf,null));};exports[_0x1de9('0x49')]=function(_0x39d069,_0x405c87){return respondWithRpcPromise('OpenchannelQueues',_0x39d069['query'],routingClient)[_0x1de9('0x16')](findById(_0x39d069[_0x1de9('0x1b')]['id']))[_0x1de9('0x16')](respondWithResult(_0x405c87,null))[_0x1de9('0x17')](handleError(_0x405c87,null));};exports[_0x1de9('0x4a')]=function(_0x20dc02,_0x8faf57){return respondWithRpcPromise(_0x1de9('0x4b'),_0x20dc02['query'],routingClient)['then'](respondWithResult(_0x8faf57,null))[_0x1de9('0x17')](handleError(_0x8faf57,null));};exports['showSmsQueues']=function(_0x164d3b,_0xf6faa){return respondWithRpcPromise(_0x1de9('0x4b'),_0x164d3b['query'],routingClient)[_0x1de9('0x16')](findById(_0x164d3b[_0x1de9('0x1b')]['id']))['then'](respondWithResult(_0xf6faa,null))[_0x1de9('0x17')](handleError(_0xf6faa,null));};exports[_0x1de9('0x4c')]=function(_0x396fd5,_0x4faa0e){return respondWithRpcPromise(_0x1de9('0x4d'),_0x396fd5[_0x1de9('0x15')],routingClient)[_0x1de9('0x16')](respondWithResult(_0x4faa0e,null))[_0x1de9('0x17')](handleError(_0x4faa0e,null));};exports[_0x1de9('0x4e')]=function(_0x4baa1e,_0x59e0ab){return respondWithRpcPromise('FaxQueues',_0x4baa1e[_0x1de9('0x15')],routingClient)['then'](findById(_0x4baa1e[_0x1de9('0x1b')]['id']))[_0x1de9('0x16')](respondWithResult(_0x59e0ab,null))[_0x1de9('0x17')](handleError(_0x59e0ab,null));};exports[_0x1de9('0x4f')]=function(_0x359c83,_0x25a8a9){return respondWithRpcPromise(_0x1de9('0x50'),_0x359c83[_0x1de9('0x15')])['then'](respondWithResult(_0x25a8a9,null))['catch'](handleError(_0x25a8a9,null));};exports[_0x1de9('0x51')]=function(_0x1978f4,_0x4c0ef1){return respondWithRpcPromise(_0x1de9('0x52'),_0x1978f4['query'],routingClient)[_0x1de9('0x16')](respondWithResult(_0x4c0ef1,null))[_0x1de9('0x17')](handleError(_0x4c0ef1,null));};exports[_0x1de9('0x53')]=function(_0x424ae5,_0x308bd1){return respondWithRpcPromise(_0x1de9('0x54'),_0x424ae5['query'],routingClient)[_0x1de9('0x16')](respondWithResult(_0x308bd1,null))[_0x1de9('0x17')](handleError(_0x308bd1,null));};exports[_0x1de9('0x55')]=function(_0x3a9aeb,_0x20a453){return respondWithRpcPromise(_0x1de9('0x56'),_0x3a9aeb['query'],routingClient)['then'](respondWithResult(_0x20a453,null))['catch'](handleError(_0x20a453,null));};exports[_0x1de9('0x57')]=function(_0x3dda31,_0x39beff){return respondWithRpcPromise(_0x1de9('0x58'),_0x3dda31['query'],routingClient)[_0x1de9('0x16')](respondWithResult(_0x39beff,null))[_0x1de9('0x17')](handleError(_0x39beff,null));};exports[_0x1de9('0x59')]=function(_0x2c80f0,_0x373e7){return respondWithRpcPromise(_0x1de9('0x5a'),_0x2c80f0[_0x1de9('0x15')],routingClient)[_0x1de9('0x16')](respondWithResult(_0x373e7,null))[_0x1de9('0x17')](handleError(_0x373e7,null));};exports[_0x1de9('0x5b')]=function(_0x54f299){return function(_0x4059c5,_0x883097){var _0x525439,_0x40e6fd;var _0x403c89=_[_0x1de9('0x5c')](_0x54f299);var _0x537e96=_0x54f299==='chat'?_0x1de9('0x5d'):_0x1de9('0x5e');return db[_0x403c89+_0x1de9('0x5f')][_0x1de9('0x60')]({'raw':!![],'where':{'id':_0x4059c5['params']['id']}})['then'](function(_0x486637){if(_[_0x1de9('0x10')](_0x486637)){throw new Error(_0x403c89+'\x20Queue\x20not\x20found');}_0x525439=_0x486637;return db[_0x403c89+'Message'][_0x1de9('0x60')]({'where':{'id':_0x4059c5[_0x1de9('0x2d')][_0x1de9('0x61')]},'include':[{'model':db[_0x403c89+_0x1de9('0x62')],'as':_0x1de9('0x62')},{'model':db[_0x403c89+_0x537e96],'as':_0x1de9('0x5e')}]});})['then'](function(_0x23dc76){if(_[_0x1de9('0x10')](_0x23dc76)){throw new Error(_0x403c89+_0x1de9('0x63'));}_0x40e6fd=_0x23dc76;return _0x23dc76[_0x1de9('0x64')]({'read':0x0,'readAt':null,'UserId':null});})[_0x1de9('0x16')](function(){var _0x1fb849={'uniqueid':_0x54f299+'.'+_0x40e6fd['id']+'.'+_0x40e6fd[_0x1de9('0x62')]['id'],'FromUserId':_0x4059c5['user']['id'],'type':_0x1de9('0x65')};_0x1fb849[_0x403c89+'MessageId']=_0x40e6fd['id'];_0x1fb849[_0x403c89+'InteractionId']=_0x40e6fd[_0x1de9('0x62')]['id'];_0x1fb849['From'+_0x403c89+_0x537e96+'Id']=_0x40e6fd[_0x1de9('0x5e')]['id'];_0x1fb849['To'+_0x403c89+_0x1de9('0x66')]=_0x525439['id'];return db[_0x403c89+_0x1de9('0x67')]['create'](_0x1fb849);})[_0x1de9('0x16')](function(){return respondWithRpcPromise(_0x1de9('0x68'),{'channel':_0x54f299,'interaction':_0x40e6fd['Interaction'],'message':_0x40e6fd,'account':_0x40e6fd[_0x1de9('0x5e')],'applications':[{'id':0x0,'priority':0x1,'app':_0x1de9('0x65'),'appdata':_0x525439[_0x1de9('0xe')]+','+(_0x40e6fd[_0x1de9('0x5e')]['queueTransferTimeout']||0x12c),'interval':'*,*,*,*'}]},routingClient);})[_0x1de9('0x16')](respondWithResult(_0x883097,null))[_0x1de9('0x17')](handleError(_0x883097,null));};};exports[_0x1de9('0x69')]=function(_0x4591be,_0x41200f){var _0x46da79,_0x2f3078;if(_[_0x1de9('0x10')](_0x4591be['body']['channel'])){throw new Error('Channel\x20field\x20is\x20mandatory');}var _0x44b450=_0x4591be['body'][_0x1de9('0x6a')];var _0xd578f7=_[_0x1de9('0x5c')](_0x44b450);var _0xae9705=_0x44b450===_0x1de9('0x6b')?_0x1de9('0x5d'):_0x1de9('0x5e');return db[_0x1de9('0x6c')]['findOne']({'raw':!![],'where':{'id':_0x4591be[_0x1de9('0x1b')]['id'],'role':_0x1de9('0x6d')}})[_0x1de9('0x16')](function(_0x28c322){if(_[_0x1de9('0x10')](_0x28c322)){throw new Error('Agent\x20not\x20found');}_0x46da79=_0x28c322;return db[_0xd578f7+_0x1de9('0x6e')][_0x1de9('0x60')]({'where':{'id':_0x4591be[_0x1de9('0x2d')]['messageId']},'include':[{'model':db[_0xd578f7+_0x1de9('0x62')],'as':'Interaction'},{'model':db[_0xd578f7+_0xae9705],'as':'Account'}]});})['then'](function(_0x3b9932){if(_[_0x1de9('0x10')](_0x3b9932)){throw new Error(_0xd578f7+_0x1de9('0x63'));}_0x2f3078=_0x3b9932;return _0x3b9932[_0x1de9('0x64')]({'read':0x0,'readAt':null,'UserId':null});})['then'](function(){var _0x1f3d7f={'uniqueid':_0x44b450+'.'+_0x2f3078['id']+'.'+_0x2f3078[_0x1de9('0x62')]['id'],'FromUserId':_0x4591be['user']['id'],'type':'queue','ToUserId':_0x46da79['id']};_0x1f3d7f[_0xd578f7+_0x1de9('0x6f')]=_0x2f3078['id'];_0x1f3d7f[_0xd578f7+_0x1de9('0x70')]=_0x2f3078[_0x1de9('0x62')]['id'];_0x1f3d7f['From'+_0xd578f7+_0xae9705+'Id']=_0x2f3078[_0x1de9('0x5e')]['id'];return db[_0xd578f7+_0x1de9('0x67')]['create'](_0x1f3d7f);})[_0x1de9('0x16')](function(){return respondWithRpcPromise(_0x1de9('0x68'),{'channel':_0x44b450,'interaction':_0x2f3078['Interaction'],'message':_0x2f3078,'account':_0x2f3078[_0x1de9('0x5e')],'applications':[{'id':0x0,'priority':0x1,'app':_0x1de9('0x6d'),'appdata':_0x46da79[_0x1de9('0xe')]+','+(_0x2f3078['Account']['agentTransferTimeout']||0x12c),'interval':_0x1de9('0x71')}]},routingClient);})[_0x1de9('0x16')](respondWithResult(_0x41200f,null))[_0x1de9('0x17')](handleError(_0x41200f,null));};