Built motion from commit b4f7ded2.|2.0.69
[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 _0x0ec2=['stack','name','send','isNil','rows','find','voiceChannels','VoiceChannels','query','voiceChannelMixMonitor','VoiceChannelMixMonitor','merge','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','params','voiceQueues','VoiceQueues','showVoiceQueues','voiceQueuesPreview','VoiceQueuesPreview','VoiceQueuesChannels','voiceQueuesChannel','VoiceQueuesChannel','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','outbound','outboundChannels','OutboundChannels','agents','Agents','agentCapacity','body','user','interaction','MemberReport','findAll','INTERACTION','format','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','length','findOrCreate','internal','AgentCapacity','capacity','Telephones','trunks','Trunks','campaigns','Campaigns','chatQueues','ChatQueues','showChatQueues','mailQueues','MailQueues','mailAccounts','MailAccounts','openchannelQueues','OpenchannelQueues','SmsQueues','showSmsQueues','FaxQueues','showFaxQueues','faxAccounts','FaxAccounts','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','faxQueuesWaitingInteractions','FaxQueuesWaitingInteractions','capitalize','chat','Website','Account','\x20Queue\x20not\x20found','Message','findOne','messageId','Interaction','\x20Message\x20not\x20found','update','queue','MessageId','InteractionId','From','QueueId','create','Start','*,*,*,*','agentNotify','User','agent','TransferReport','agentTransferTimeout','bluebird','lodash','../../mysqldb','../../config/logger','api','jayson/promise','http','client','request','then','error','code','result','catch','status','json','sendStatus'];(function(_0x326ac6,_0x3469e3){var _0xd7d842=function(_0x123b45){while(--_0x123b45){_0x326ac6['push'](_0x326ac6['shift']());}};_0xd7d842(++_0x3469e3);}(_0x0ec2,0x145));var _0x20ec=function(_0xdeefbd,_0x9e1b3d){_0xdeefbd=_0xdeefbd-0x0;var _0x4ff63f=_0x0ec2[_0xdeefbd];return _0x4ff63f;};'use strict';var BPromise=require(_0x20ec('0x0'));var moment=require('moment');var _=require(_0x20ec('0x1'));var db=require(_0x20ec('0x2'))['db'];var logger=require(_0x20ec('0x3'))(_0x20ec('0x4'));var jayson=require(_0x20ec('0x5'));var amiClient=jayson['client'][_0x20ec('0x6')]({'port':0x232a});var mailClient=jayson['client'][_0x20ec('0x6')]({'port':0x232b});var routingClient=jayson[_0x20ec('0x7')][_0x20ec('0x6')]({'port':0x232c});function respondWithRpcPromise(_0x44386d,_0x3f8c57,_0x26ab54){return new BPromise(function(_0x23ec70,_0x5efabe){var _0x3c68eb=_0x26ab54?_0x26ab54:amiClient;return _0x3c68eb[_0x20ec('0x8')](_0x44386d,_0x3f8c57)[_0x20ec('0x9')](function(_0xb1ad1d){if(_0xb1ad1d[_0x20ec('0xa')]){if(_0xb1ad1d[_0x20ec('0xa')][_0x20ec('0xb')]===0x1f4){return _0x5efabe(_0xb1ad1d[_0x20ec('0xa')]['message']);}return _0x23ec70(_0xb1ad1d[_0x20ec('0xa')]['message']);}else{_0x23ec70(_0xb1ad1d[_0x20ec('0xc')]);}})[_0x20ec('0xd')](function(_0x4e82af){_0x5efabe(_0x4e82af);});});}function respondWithResult(_0x5e8e7c,_0x54e12e){_0x54e12e=_0x54e12e||0xc8;return function(_0x599811){if(_0x599811){return _0x5e8e7c[_0x20ec('0xe')](_0x54e12e)[_0x20ec('0xf')](_0x599811);}return _0x5e8e7c[_0x20ec('0x10')](0x194);};}function handleError(_0x322bb9,_0x4634ab){_0x4634ab=_0x4634ab||0x1f4;return function(_0x42ee6a){logger['error'](_0x42ee6a[_0x20ec('0x11')]);if(_0x42ee6a[_0x20ec('0x12')]){delete _0x42ee6a['name'];}_0x322bb9['status'](_0x4634ab)[_0x20ec('0x13')](_0x42ee6a);};}function findById(_0x56474c){return function(_0x4d009c){if(!_[_0x20ec('0x14')](_0x56474c)&&!_['isNil'](_0x4d009c)&&!_[_0x20ec('0x14')](_0x4d009c[_0x20ec('0x15')])){return _[_0x20ec('0x16')](_0x4d009c[_0x20ec('0x15')],function(_0x4b6072){return _0x4b6072['id']==_0x56474c;});}return null;};}exports[_0x20ec('0x17')]=function(_0x250dc9,_0x42c4ae){return respondWithRpcPromise(_0x20ec('0x18'),_0x250dc9[_0x20ec('0x19')])[_0x20ec('0x9')](respondWithResult(_0x42c4ae,null))[_0x20ec('0xd')](handleError(_0x42c4ae,null));};exports[_0x20ec('0x1a')]=function(_0x4da746,_0xcd9ada){return respondWithRpcPromise(_0x20ec('0x1b'),_[_0x20ec('0x1c')](_0x4da746['query'],_0x4da746['params']))['then'](respondWithResult(_0xcd9ada,null))[_0x20ec('0xd')](handleError(_0xcd9ada,null));};exports[_0x20ec('0x1d')]=function(_0x1ab04c,_0x366761){return respondWithRpcPromise(_0x20ec('0x1e'),_[_0x20ec('0x1c')](_0x1ab04c[_0x20ec('0x19')],_0x1ab04c[_0x20ec('0x1f')]))[_0x20ec('0x9')](respondWithResult(_0x366761,null))[_0x20ec('0xd')](handleError(_0x366761,null));};exports[_0x20ec('0x20')]=function(_0x26932f,_0x3419b1){return respondWithRpcPromise(_0x20ec('0x21'),_0x26932f[_0x20ec('0x19')])[_0x20ec('0x9')](respondWithResult(_0x3419b1,null))[_0x20ec('0xd')](handleError(_0x3419b1,null));};exports[_0x20ec('0x22')]=function(_0x3575e9,_0x5cd820){return respondWithRpcPromise(_0x20ec('0x21'),_0x3575e9['query'])['then'](findById(_0x3575e9[_0x20ec('0x1f')]['id']))['then'](respondWithResult(_0x5cd820,null))[_0x20ec('0xd')](handleError(_0x5cd820,null));};exports[_0x20ec('0x23')]=function(_0x519636,_0x58dc17){return respondWithRpcPromise(_0x20ec('0x24'),_[_0x20ec('0x1c')](_0x519636[_0x20ec('0x19')],_0x519636[_0x20ec('0x1f')]))[_0x20ec('0x9')](respondWithResult(_0x58dc17,null))['catch'](handleError(_0x58dc17,null));};exports['voiceQueuesChannels']=function(_0x2e01d3,_0x61253b){return respondWithRpcPromise(_0x20ec('0x25'),_0x2e01d3[_0x20ec('0x19')])[_0x20ec('0x9')](respondWithResult(_0x61253b,null))[_0x20ec('0xd')](handleError(_0x61253b,null));};exports[_0x20ec('0x26')]=function(_0x53c35e,_0x2d4f5c){return respondWithRpcPromise(_0x20ec('0x27'),_[_0x20ec('0x1c')](_0x53c35e['query'],_0x53c35e[_0x20ec('0x1f')]))[_0x20ec('0x9')](respondWithResult(_0x2d4f5c,null))[_0x20ec('0xd')](handleError(_0x2d4f5c,null));};exports['voiceQueuesChannelHangup']=function(_0x507b9f,_0x3f71f9){return respondWithRpcPromise('VoiceQueuesChannelHangup',_['merge'](_0x507b9f[_0x20ec('0x19')],_0x507b9f[_0x20ec('0x1f')]))[_0x20ec('0x9')](respondWithResult(_0x3f71f9,null))[_0x20ec('0xd')](handleError(_0x3f71f9,null));};exports[_0x20ec('0x28')]=function(_0x24bd2d,_0xa99b69){return respondWithRpcPromise(_0x20ec('0x29'),_[_0x20ec('0x1c')](_0x24bd2d['query'],_0x24bd2d['params']))[_0x20ec('0x9')](respondWithResult(_0xa99b69,null))[_0x20ec('0xd')](handleError(_0xa99b69,null));};exports[_0x20ec('0x2a')]=function(_0x2379db,_0x53ec3d){return respondWithRpcPromise('Outbound',_0x2379db[_0x20ec('0x19')])[_0x20ec('0x9')](respondWithResult(_0x53ec3d,null))[_0x20ec('0xd')](handleError(_0x53ec3d,null));};exports[_0x20ec('0x2b')]=function(_0xed825a,_0x34c672){return respondWithRpcPromise(_0x20ec('0x2c'),_0xed825a['query'])[_0x20ec('0x9')](respondWithResult(_0x34c672,null))[_0x20ec('0xd')](handleError(_0x34c672,null));};exports[_0x20ec('0x2d')]=function(_0x571135,_0x52d11a){var _0x1b2ce3;return respondWithRpcPromise(_0x20ec('0x2e'),_0x571135['query'])[_0x20ec('0x9')](function(_0xe671e3){_0x1b2ce3=_0xe671e3;return respondWithRpcPromise(_0x20ec('0x2e'),_0x571135[_0x20ec('0x19')],routingClient);})[_0x20ec('0x9')](function(_0x57c92c){return _['merge']({},_0x57c92c,_0x1b2ce3);})[_0x20ec('0x9')](respondWithResult(_0x52d11a,null))[_0x20ec('0xd')](handleError(_0x52d11a,null));};exports[_0x20ec('0x2f')]=function(_0x3a6674,_0x304fb5){if(_0x3a6674[_0x20ec('0x30')]&&_0x3a6674[_0x20ec('0x30')]['interaction']&&_0x3a6674[_0x20ec('0x31')]&&_0x3a6674[_0x20ec('0x31')][_0x20ec('0x12')]){for(var _0x404778 in _0x3a6674[_0x20ec('0x30')]['interaction']){if(_0x3a6674[_0x20ec('0x30')][_0x20ec('0x32')]['hasOwnProperty'](_0x404778)){db[_0x20ec('0x33')][_0x20ec('0x34')]({'where':{'channel':_0x404778,'membername':_0x3a6674['user'][_0x20ec('0x12')],'type':_0x20ec('0x35'),'exitAt':null,'uniqueid':_0x3a6674['body'][_0x20ec('0x32')][_0x404778]&&_0x3a6674['body'][_0x20ec('0x32')][_0x404778]['length']?{'$notIn':_0x3a6674[_0x20ec('0x30')]['interaction'][_0x404778]}:{'$ne':null}}})[_0x20ec('0x9')](function(_0x581f0e){var _0x1168f2=moment()[_0x20ec('0x36')](_0x20ec('0x37'));for(var _0x29e54b=0x0,_0x1fbae9=_0x581f0e['length'];_0x29e54b<_0x1fbae9;_0x29e54b+=0x1){_0x581f0e[_0x29e54b][_0x20ec('0x38')]({'exitAt':_0x1168f2});}});for(var _0xb4d835=0x0;_0xb4d835<_0x3a6674[_0x20ec('0x30')]['interaction'][_0x404778][_0x20ec('0x39')];_0xb4d835+=0x1){db[_0x20ec('0x33')][_0x20ec('0x3a')]({'where':{'channel':_0x404778,'membername':_0x3a6674[_0x20ec('0x31')]['name'],'type':'INTERACTION','uniqueid':_0x3a6674[_0x20ec('0x30')][_0x20ec('0x32')][_0x404778][_0xb4d835],'exitAt':null},'defaults':{'channel':_0x404778,'membername':_0x3a6674[_0x20ec('0x31')][_0x20ec('0x12')],'interface':'SIP/'+_0x3a6674[_0x20ec('0x31')]['name'],'type':_0x20ec('0x35'),'enterAt':moment()['format'](_0x20ec('0x37')),'role':'agent','internal':_0x3a6674[_0x20ec('0x31')][_0x20ec('0x3b')],'uniqueid':_0x3a6674[_0x20ec('0x30')][_0x20ec('0x32')][_0x404778][_0xb4d835]}});}}}}return respondWithRpcPromise(_0x20ec('0x3c'),{'id':_0x3a6674[_0x20ec('0x1f')]['id'],'capacity':_0x3a6674['body'][_0x20ec('0x3d')]},routingClient)[_0x20ec('0x9')](respondWithResult(_0x304fb5,null))[_0x20ec('0xd')](handleError(_0x304fb5,null));};exports['telephones']=function(_0x70ce38,_0x5ee894){return respondWithRpcPromise(_0x20ec('0x3e'),_0x70ce38[_0x20ec('0x19')])['then'](respondWithResult(_0x5ee894,null))[_0x20ec('0xd')](handleError(_0x5ee894,null));};exports[_0x20ec('0x3f')]=function(_0xd5ca25,_0x4ff3c6){return respondWithRpcPromise(_0x20ec('0x40'),_0xd5ca25[_0x20ec('0x19')])[_0x20ec('0x9')](respondWithResult(_0x4ff3c6,null))['catch'](handleError(_0x4ff3c6,null));};exports[_0x20ec('0x41')]=function(_0x2a61da,_0x2ed9a1){return respondWithRpcPromise(_0x20ec('0x42'),_0x2a61da['query'])['then'](respondWithResult(_0x2ed9a1,null))[_0x20ec('0xd')](handleError(_0x2ed9a1,null));};exports[_0x20ec('0x43')]=function(_0x67bebd,_0x47a04b){return respondWithRpcPromise(_0x20ec('0x44'),_0x67bebd[_0x20ec('0x19')],routingClient)[_0x20ec('0x9')](respondWithResult(_0x47a04b,null))[_0x20ec('0xd')](handleError(_0x47a04b,null));};exports[_0x20ec('0x45')]=function(_0x3ee32a,_0x534190){return respondWithRpcPromise(_0x20ec('0x44'),_0x3ee32a[_0x20ec('0x19')],routingClient)['then'](findById(_0x3ee32a[_0x20ec('0x1f')]['id']))[_0x20ec('0x9')](respondWithResult(_0x534190,null))[_0x20ec('0xd')](handleError(_0x534190,null));};exports[_0x20ec('0x46')]=function(_0x17449d,_0x491045){return respondWithRpcPromise(_0x20ec('0x47'),_0x17449d[_0x20ec('0x19')],routingClient)[_0x20ec('0x9')](respondWithResult(_0x491045,null))[_0x20ec('0xd')](handleError(_0x491045,null));};exports['showMailQueues']=function(_0x4b3426,_0xa6f500){return respondWithRpcPromise(_0x20ec('0x47'),_0x4b3426[_0x20ec('0x19')],routingClient)['then'](findById(_0x4b3426[_0x20ec('0x1f')]['id']))['then'](respondWithResult(_0xa6f500,null))['catch'](handleError(_0xa6f500,null));};exports[_0x20ec('0x48')]=function(_0x28a40b,_0x53c512){return respondWithRpcPromise(_0x20ec('0x49'),_0x28a40b['query'],mailClient)[_0x20ec('0x9')](respondWithResult(_0x53c512,null))['catch'](handleError(_0x53c512,null));};exports[_0x20ec('0x4a')]=function(_0x488f19,_0x5d6f00){return respondWithRpcPromise(_0x20ec('0x4b'),_0x488f19['query'],routingClient)['then'](respondWithResult(_0x5d6f00,null))[_0x20ec('0xd')](handleError(_0x5d6f00,null));};exports['showOpenchannelQueues']=function(_0x50aa4b,_0x262922){return respondWithRpcPromise('OpenchannelQueues',_0x50aa4b['query'],routingClient)['then'](findById(_0x50aa4b[_0x20ec('0x1f')]['id']))[_0x20ec('0x9')](respondWithResult(_0x262922,null))[_0x20ec('0xd')](handleError(_0x262922,null));};exports['smsQueues']=function(_0x3731a4,_0x4e6f15){return respondWithRpcPromise(_0x20ec('0x4c'),_0x3731a4['query'],routingClient)[_0x20ec('0x9')](respondWithResult(_0x4e6f15,null))[_0x20ec('0xd')](handleError(_0x4e6f15,null));};exports[_0x20ec('0x4d')]=function(_0x417b32,_0x53e92b){return respondWithRpcPromise(_0x20ec('0x4c'),_0x417b32[_0x20ec('0x19')],routingClient)[_0x20ec('0x9')](findById(_0x417b32['params']['id']))[_0x20ec('0x9')](respondWithResult(_0x53e92b,null))[_0x20ec('0xd')](handleError(_0x53e92b,null));};exports['faxQueues']=function(_0x1b7f5d,_0x34472f){return respondWithRpcPromise(_0x20ec('0x4e'),_0x1b7f5d[_0x20ec('0x19')],routingClient)[_0x20ec('0x9')](respondWithResult(_0x34472f,null))[_0x20ec('0xd')](handleError(_0x34472f,null));};exports[_0x20ec('0x4f')]=function(_0x2a7aea,_0x4cec12){return respondWithRpcPromise(_0x20ec('0x4e'),_0x2a7aea[_0x20ec('0x19')],routingClient)[_0x20ec('0x9')](findById(_0x2a7aea[_0x20ec('0x1f')]['id']))[_0x20ec('0x9')](respondWithResult(_0x4cec12,null))[_0x20ec('0xd')](handleError(_0x4cec12,null));};exports[_0x20ec('0x50')]=function(_0x15dd4f,_0x153f24){return respondWithRpcPromise(_0x20ec('0x51'),_0x15dd4f[_0x20ec('0x19')])[_0x20ec('0x9')](respondWithResult(_0x153f24,null))[_0x20ec('0xd')](handleError(_0x153f24,null));};exports['chatQueuesWaitingInteractions']=function(_0x40a944,_0x114366){return respondWithRpcPromise(_0x20ec('0x52'),_0x40a944[_0x20ec('0x19')],routingClient)[_0x20ec('0x9')](respondWithResult(_0x114366,null))[_0x20ec('0xd')](handleError(_0x114366,null));};exports[_0x20ec('0x53')]=function(_0x12860a,_0x138cdb){return respondWithRpcPromise('MailQueuesWaitingInteractions',_0x12860a[_0x20ec('0x19')],routingClient)[_0x20ec('0x9')](respondWithResult(_0x138cdb,null))[_0x20ec('0xd')](handleError(_0x138cdb,null));};exports[_0x20ec('0x54')]=function(_0x2fe75d,_0x400663){return respondWithRpcPromise(_0x20ec('0x55'),_0x2fe75d[_0x20ec('0x19')],routingClient)['then'](respondWithResult(_0x400663,null))['catch'](handleError(_0x400663,null));};exports[_0x20ec('0x56')]=function(_0x4b7840,_0x22e38f){return respondWithRpcPromise(_0x20ec('0x57'),_0x4b7840[_0x20ec('0x19')],routingClient)[_0x20ec('0x9')](respondWithResult(_0x22e38f,null))[_0x20ec('0xd')](handleError(_0x22e38f,null));};exports[_0x20ec('0x58')]=function(_0x4dc7e5,_0x2ae295){return respondWithRpcPromise(_0x20ec('0x59'),_0x4dc7e5[_0x20ec('0x19')],routingClient)[_0x20ec('0x9')](respondWithResult(_0x2ae295,null))[_0x20ec('0xd')](handleError(_0x2ae295,null));};exports['queueNotify']=function(_0x21a435){return function(_0x361abd,_0x3eee91){var _0x1e40e7,_0x3aef19;var _0x2b4f55=_[_0x20ec('0x5a')](_0x21a435);var _0x6a43c0=_0x21a435===_0x20ec('0x5b')?_0x20ec('0x5c'):_0x20ec('0x5d');return db[_0x2b4f55+'Queue']['findOne']({'raw':!![],'where':{'id':_0x361abd[_0x20ec('0x1f')]['id']}})['then'](function(_0x138ee1){if(_[_0x20ec('0x14')](_0x138ee1)){throw new Error(_0x2b4f55+_0x20ec('0x5e'));}_0x1e40e7=_0x138ee1;return db[_0x2b4f55+_0x20ec('0x5f')][_0x20ec('0x60')]({'where':{'id':_0x361abd['body'][_0x20ec('0x61')]},'include':[{'model':db[_0x2b4f55+'Interaction'],'as':_0x20ec('0x62')},{'model':db[_0x2b4f55+_0x6a43c0],'as':_0x20ec('0x5d')}]});})[_0x20ec('0x9')](function(_0x3a41cb){if(_['isNil'](_0x3a41cb)){throw new Error(_0x2b4f55+_0x20ec('0x63'));}_0x3aef19=_0x3a41cb;return _0x3a41cb[_0x20ec('0x64')]({'read':0x0,'readAt':null,'UserId':null});})[_0x20ec('0x9')](function(){var _0x4069ba={'uniqueid':_0x21a435+'.'+_0x3aef19['id']+'.'+_0x3aef19[_0x20ec('0x62')]['id'],'FromUserId':_0x361abd[_0x20ec('0x31')]['id'],'type':_0x20ec('0x65')};_0x4069ba[_0x2b4f55+_0x20ec('0x66')]=_0x3aef19['id'];_0x4069ba[_0x2b4f55+_0x20ec('0x67')]=_0x3aef19[_0x20ec('0x62')]['id'];_0x4069ba[_0x20ec('0x68')+_0x2b4f55+_0x6a43c0+'Id']=_0x3aef19[_0x20ec('0x5d')]['id'];_0x4069ba['To'+_0x2b4f55+_0x20ec('0x69')]=_0x1e40e7['id'];return db[_0x2b4f55+'TransferReport'][_0x20ec('0x6a')](_0x4069ba);})['then'](function(){return respondWithRpcPromise(_0x20ec('0x6b'),{'channel':_0x21a435,'interaction':_0x3aef19[_0x20ec('0x62')],'message':_0x3aef19,'account':_0x3aef19[_0x20ec('0x5d')],'applications':[{'id':0x0,'priority':0x1,'app':_0x20ec('0x65'),'appdata':_0x1e40e7['name']+','+(_0x3aef19[_0x20ec('0x5d')]['queueTransferTimeout']||0x12c),'interval':_0x20ec('0x6c')}]},routingClient);})[_0x20ec('0x9')](respondWithResult(_0x3eee91,null))['catch'](handleError(_0x3eee91,null));};};exports[_0x20ec('0x6d')]=function(_0x4977b4,_0x84809a){var _0x590506,_0x58fca6;if(_[_0x20ec('0x14')](_0x4977b4[_0x20ec('0x30')]['channel'])){throw new Error('Channel\x20field\x20is\x20mandatory');}var _0x6d6473=_0x4977b4[_0x20ec('0x30')]['channel'];var _0x21d0c0=_['capitalize'](_0x6d6473);var _0x261ac0=_0x6d6473===_0x20ec('0x5b')?'Website':_0x20ec('0x5d');return db[_0x20ec('0x6e')][_0x20ec('0x60')]({'raw':!![],'where':{'id':_0x4977b4['params']['id'],'role':_0x20ec('0x6f')}})[_0x20ec('0x9')](function(_0x9bad9){if(_[_0x20ec('0x14')](_0x9bad9)){throw new Error('Agent\x20not\x20found');}_0x590506=_0x9bad9;return db[_0x21d0c0+_0x20ec('0x5f')][_0x20ec('0x60')]({'where':{'id':_0x4977b4[_0x20ec('0x30')][_0x20ec('0x61')]},'include':[{'model':db[_0x21d0c0+_0x20ec('0x62')],'as':_0x20ec('0x62')},{'model':db[_0x21d0c0+_0x261ac0],'as':_0x20ec('0x5d')}]});})['then'](function(_0x2a8e0c){if(_[_0x20ec('0x14')](_0x2a8e0c)){throw new Error(_0x21d0c0+'\x20Message\x20not\x20found');}_0x58fca6=_0x2a8e0c;return _0x2a8e0c[_0x20ec('0x64')]({'read':0x0,'readAt':null,'UserId':null});})[_0x20ec('0x9')](function(){var _0x84d020={'uniqueid':_0x6d6473+'.'+_0x58fca6['id']+'.'+_0x58fca6[_0x20ec('0x62')]['id'],'FromUserId':_0x4977b4[_0x20ec('0x31')]['id'],'type':_0x20ec('0x65'),'ToUserId':_0x590506['id']};_0x84d020[_0x21d0c0+_0x20ec('0x66')]=_0x58fca6['id'];_0x84d020[_0x21d0c0+_0x20ec('0x67')]=_0x58fca6[_0x20ec('0x62')]['id'];_0x84d020[_0x20ec('0x68')+_0x21d0c0+_0x261ac0+'Id']=_0x58fca6[_0x20ec('0x5d')]['id'];return db[_0x21d0c0+_0x20ec('0x70')][_0x20ec('0x6a')](_0x84d020);})[_0x20ec('0x9')](function(){return respondWithRpcPromise('Start',{'channel':_0x6d6473,'interaction':_0x58fca6[_0x20ec('0x62')],'message':_0x58fca6,'account':_0x58fca6['Account'],'applications':[{'id':0x0,'priority':0x1,'app':'agent','appdata':_0x590506[_0x20ec('0x12')]+','+(_0x58fca6[_0x20ec('0x5d')][_0x20ec('0x71')]||0x12c),'interval':'*,*,*,*'}]},routingClient);})[_0x20ec('0x9')](respondWithResult(_0x84809a,null))[_0x20ec('0xd')](handleError(_0x84809a,null));};