Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / api / rpc / rpc.controller.js
index 9119638..8583c6f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xeff1=['FaxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','type','filter','indexOf','queue_id','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','faxQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','capitalize','Account','Queue','findOne','\x20Queue\x20not\x20found','Message','Interaction','update','queue','MessageId','InteractionId','From','QueueId','TransferReport','create','Start','queueTransferTimeout','*,*,*,*','Channel\x20field\x20is\x20mandatory','chat','Website','Agent\x20not\x20found','\x20Message\x20not\x20found','agentTransferTimeout','bluebird','lodash','util','../../mysqldb','api','http','client','request','then','error','code','message','result','catch','status','sendStatus','stack','name','send','isNil','rows','voiceChannels','VoiceChannels','query','voiceChannelMixMonitor','VoiceChannelMixMonitor','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','merge','params','voiceQueues','VoiceQueues','showVoiceQueues','UpdateVoiceQueue','body','voiceQueuesPreview','VoiceQueuesChannels','voiceQueuesChannel','VoiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','outbound','Outbound','OutboundChannels','agents','Agents','interaction','user','hasOwnProperty','findAll','length','format','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','findOrCreate','INTERACTION','interface','agent','internal','AgentCapacity','capacity','telephones','Telephones','trunks','Trunks','campaigns','Campaigns','chatQueues','ChatQueues','showMailQueues','MailQueues','mailAccounts','MailAccounts','openchannelQueues','showOpenchannelQueues','smsQueues','SmsQueues','showWhatsappQueues','faxQueues','FaxQueues','showFaxQueues','faxAccounts'];(function(_0x1fc4e2,_0x493c3b){var _0x2ba184=function(_0x58e64f){while(--_0x58e64f){_0x1fc4e2['push'](_0x1fc4e2['shift']());}};_0x2ba184(++_0x493c3b);}(_0xeff1,0x198));var _0x1eff=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xeff1[_0x3dd15e];return _0x231fd0;};'use strict';var BPromise=require(_0x1eff('0x0'));var moment=require('moment');var _=require(_0x1eff('0x1'));var util=require(_0x1eff('0x2'));var db=require(_0x1eff('0x3'))['db'];var logger=require('../../config/logger')(_0x1eff('0x4'));var jayson=require('jayson/promise');var amiClient=jayson['client'][_0x1eff('0x5')]({'port':0x232a});var mailClient=jayson['client'][_0x1eff('0x5')]({'port':0x232b});var routingClient=jayson[_0x1eff('0x6')][_0x1eff('0x5')]({'port':0x232c});function respondWithRpcPromise(_0x59421c,_0x1ae531,_0x12ca61){return new BPromise(function(_0x5b4d38,_0x41c656){var _0x1342ae=_0x12ca61?_0x12ca61:amiClient;return _0x1342ae[_0x1eff('0x7')](_0x59421c,_0x1ae531)[_0x1eff('0x8')](function(_0x5d1a2c){if(_0x5d1a2c[_0x1eff('0x9')]){if(_0x5d1a2c[_0x1eff('0x9')][_0x1eff('0xa')]===0x1f4){return _0x41c656(_0x5d1a2c[_0x1eff('0x9')][_0x1eff('0xb')]);}return _0x5b4d38(_0x5d1a2c[_0x1eff('0x9')][_0x1eff('0xb')]);}else{_0x5b4d38(_0x5d1a2c[_0x1eff('0xc')]);}})[_0x1eff('0xd')](function(_0x447f8a){_0x41c656(_0x447f8a);});});}function respondWithResult(_0x3c394c,_0x5cc042){_0x5cc042=_0x5cc042||0xc8;return function(_0x5a5c35){if(_0x5a5c35){return _0x3c394c[_0x1eff('0xe')](_0x5cc042)['json'](_0x5a5c35);}return _0x3c394c[_0x1eff('0xf')](0x194);};}function handleError(_0x4cf7ed,_0x41f75f){_0x41f75f=_0x41f75f||0x1f4;return function(_0x1f0de4){logger['error'](_0x1f0de4[_0x1eff('0x10')]);if(_0x1f0de4[_0x1eff('0x11')]){delete _0x1f0de4['name'];}_0x4cf7ed['status'](_0x41f75f)[_0x1eff('0x12')](_0x1f0de4);};}function findById(_0x3e1867){return function(_0x184a0b){if(!_[_0x1eff('0x13')](_0x3e1867)&&!_[_0x1eff('0x13')](_0x184a0b)&&!_[_0x1eff('0x13')](_0x184a0b[_0x1eff('0x14')])){return _['find'](_0x184a0b['rows'],function(_0x3abfb3){return _0x3abfb3['id']==_0x3e1867;});}return null;};}exports[_0x1eff('0x15')]=function(_0x5889a8,_0x38a9cc){return respondWithRpcPromise(_0x1eff('0x16'),_0x5889a8[_0x1eff('0x17')])[_0x1eff('0x8')](respondWithResult(_0x38a9cc,null))['catch'](handleError(_0x38a9cc,null));};exports[_0x1eff('0x18')]=function(_0x3b1e0a,_0x36e8d4){return respondWithRpcPromise(_0x1eff('0x19'),_['merge'](_0x3b1e0a['query'],_0x3b1e0a['params']))[_0x1eff('0x8')](respondWithResult(_0x36e8d4,null))[_0x1eff('0xd')](handleError(_0x36e8d4,null));};exports[_0x1eff('0x1a')]=function(_0x2cee09,_0xa0964d){return respondWithRpcPromise(_0x1eff('0x1b'),_[_0x1eff('0x1c')](_0x2cee09[_0x1eff('0x17')],_0x2cee09[_0x1eff('0x1d')]))[_0x1eff('0x8')](respondWithResult(_0xa0964d,null))[_0x1eff('0xd')](handleError(_0xa0964d,null));};exports[_0x1eff('0x1e')]=function(_0x2a721a,_0x38197e){return respondWithRpcPromise(_0x1eff('0x1f'),_0x2a721a['query'])[_0x1eff('0x8')](respondWithResult(_0x38197e,null))[_0x1eff('0xd')](handleError(_0x38197e,null));};exports[_0x1eff('0x20')]=function(_0x4ab014,_0x3b40cb){return respondWithRpcPromise(_0x1eff('0x1f'),_0x4ab014[_0x1eff('0x17')])[_0x1eff('0x8')](findById(_0x4ab014[_0x1eff('0x1d')]['id']))[_0x1eff('0x8')](respondWithResult(_0x3b40cb,null))[_0x1eff('0xd')](handleError(_0x3b40cb,null));};exports['updateVoiceQueue']=function(_0x225b93,_0x49601c){return respondWithRpcPromise(_0x1eff('0x21'),_[_0x1eff('0x1c')](_0x225b93[_0x1eff('0x22')],_0x225b93[_0x1eff('0x1d')]))[_0x1eff('0x8')](respondWithResult(_0x49601c,null))['catch'](handleError(_0x49601c,null));};exports[_0x1eff('0x23')]=function(_0x50211f,_0x12b150){return respondWithRpcPromise('VoiceQueuesPreview',_[_0x1eff('0x1c')](_0x50211f[_0x1eff('0x17')],_0x50211f[_0x1eff('0x1d')]))[_0x1eff('0x8')](respondWithResult(_0x12b150,null))[_0x1eff('0xd')](handleError(_0x12b150,null));};exports['voiceQueuesChannels']=function(_0x2b4ab8,_0x1ec7e9){return respondWithRpcPromise(_0x1eff('0x24'),_0x2b4ab8['query'])['then'](respondWithResult(_0x1ec7e9,null))['catch'](handleError(_0x1ec7e9,null));};exports[_0x1eff('0x25')]=function(_0x25f268,_0x50a831){return respondWithRpcPromise(_0x1eff('0x26'),_[_0x1eff('0x1c')](_0x25f268['query'],_0x25f268['params']))[_0x1eff('0x8')](respondWithResult(_0x50a831,null))[_0x1eff('0xd')](handleError(_0x50a831,null));};exports[_0x1eff('0x27')]=function(_0x38ce5a,_0x596cde){return respondWithRpcPromise(_0x1eff('0x28'),_[_0x1eff('0x1c')](_0x38ce5a[_0x1eff('0x17')],_0x38ce5a[_0x1eff('0x1d')]))[_0x1eff('0x8')](respondWithResult(_0x596cde,null))['catch'](handleError(_0x596cde,null));};exports[_0x1eff('0x29')]=function(_0x50fb39,_0x349933){return respondWithRpcPromise(_0x1eff('0x2a'),_['merge'](_0x50fb39['query'],_0x50fb39[_0x1eff('0x1d')]))[_0x1eff('0x8')](respondWithResult(_0x349933,null))[_0x1eff('0xd')](handleError(_0x349933,null));};exports[_0x1eff('0x2b')]=function(_0x4dcb79,_0x36ff74){return respondWithRpcPromise(_0x1eff('0x2c'),_0x4dcb79[_0x1eff('0x17')])[_0x1eff('0x8')](respondWithResult(_0x36ff74,null))['catch'](handleError(_0x36ff74,null));};exports['outboundChannels']=function(_0x2736bd,_0x5dc283){return respondWithRpcPromise(_0x1eff('0x2d'),_0x2736bd[_0x1eff('0x17')])['then'](respondWithResult(_0x5dc283,null))['catch'](handleError(_0x5dc283,null));};exports[_0x1eff('0x2e')]=function(_0x5a508a,_0x52f8e6){var _0x5aff5b;return respondWithRpcPromise('Agents',_0x5a508a[_0x1eff('0x17')])[_0x1eff('0x8')](function(_0x21f667){_0x5aff5b=_0x21f667;return respondWithRpcPromise(_0x1eff('0x2f'),_0x5a508a[_0x1eff('0x17')],routingClient);})['then'](function(_0x22325d){return _[_0x1eff('0x1c')]({},_0x22325d,_0x5aff5b);})['then'](respondWithResult(_0x52f8e6,null))[_0x1eff('0xd')](handleError(_0x52f8e6,null));};exports['agentCapacity']=function(_0x27c298,_0x125209){if(_0x27c298['body']&&_0x27c298[_0x1eff('0x22')][_0x1eff('0x30')]&&_0x27c298[_0x1eff('0x31')]&&_0x27c298['user'][_0x1eff('0x11')]){for(var _0x31e649 in _0x27c298[_0x1eff('0x22')]['interaction']){if(_0x27c298['body'][_0x1eff('0x30')][_0x1eff('0x32')](_0x31e649)){db['MemberReport'][_0x1eff('0x33')]({'where':{'channel':_0x31e649,'membername':_0x27c298['user'][_0x1eff('0x11')],'type':'INTERACTION','exitAt':null,'uniqueid':_0x27c298[_0x1eff('0x22')][_0x1eff('0x30')][_0x31e649]&&_0x27c298[_0x1eff('0x22')][_0x1eff('0x30')][_0x31e649][_0x1eff('0x34')]?{'$notIn':_0x27c298[_0x1eff('0x22')][_0x1eff('0x30')][_0x31e649]}:{'$ne':null}}})[_0x1eff('0x8')](function(_0xc77f37){var _0x460dab=moment()[_0x1eff('0x35')](_0x1eff('0x36'));for(var _0x45532e=0x0,_0x48e81a=_0xc77f37[_0x1eff('0x34')];_0x45532e<_0x48e81a;_0x45532e+=0x1){_0xc77f37[_0x45532e][_0x1eff('0x37')]({'exitAt':_0x460dab});}});for(var _0x18e6dc=0x0;_0x18e6dc<_0x27c298['body'][_0x1eff('0x30')][_0x31e649]['length'];_0x18e6dc+=0x1){db['MemberReport'][_0x1eff('0x38')]({'where':{'channel':_0x31e649,'membername':_0x27c298[_0x1eff('0x31')]['name'],'type':_0x1eff('0x39'),'uniqueid':_0x27c298['body'][_0x1eff('0x30')][_0x31e649][_0x18e6dc],'exitAt':null},'defaults':{'channel':_0x31e649,'membername':_0x27c298[_0x1eff('0x31')][_0x1eff('0x11')],'interface':_[_0x1eff('0x13')](_0x27c298['user'][_0x1eff('0x3a')])?util[_0x1eff('0x35')]('SIP/%s',_0x27c298[_0x1eff('0x31')][_0x1eff('0x11')]):_0x27c298[_0x1eff('0x31')][_0x1eff('0x3a')],'type':_0x1eff('0x39'),'enterAt':moment()[_0x1eff('0x35')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x1eff('0x3b'),'internal':_0x27c298[_0x1eff('0x31')][_0x1eff('0x3c')],'uniqueid':_0x27c298[_0x1eff('0x22')][_0x1eff('0x30')][_0x31e649][_0x18e6dc]}});}}}}return respondWithRpcPromise(_0x1eff('0x3d'),{'id':_0x27c298[_0x1eff('0x1d')]['id'],'capacity':_0x27c298[_0x1eff('0x22')][_0x1eff('0x3e')]},routingClient)['then'](respondWithResult(_0x125209,null))[_0x1eff('0xd')](handleError(_0x125209,null));};exports[_0x1eff('0x3f')]=function(_0xd8755b,_0x3fb272){return respondWithRpcPromise(_0x1eff('0x40'),_0xd8755b['query'])['then'](respondWithResult(_0x3fb272,null))['catch'](handleError(_0x3fb272,null));};exports[_0x1eff('0x41')]=function(_0x1f74bc,_0x51a824){return respondWithRpcPromise(_0x1eff('0x42'),_0x1f74bc[_0x1eff('0x17')])[_0x1eff('0x8')](respondWithResult(_0x51a824,null))[_0x1eff('0xd')](handleError(_0x51a824,null));};exports[_0x1eff('0x43')]=function(_0x22a045,_0x362ded){return respondWithRpcPromise(_0x1eff('0x44'),_0x22a045[_0x1eff('0x17')])[_0x1eff('0x8')](respondWithResult(_0x362ded,null))[_0x1eff('0xd')](handleError(_0x362ded,null));};exports[_0x1eff('0x45')]=function(_0x534ad8,_0x111458){return respondWithRpcPromise('ChatQueues',_0x534ad8[_0x1eff('0x17')],routingClient)[_0x1eff('0x8')](respondWithResult(_0x111458,null))['catch'](handleError(_0x111458,null));};exports['showChatQueues']=function(_0x922736,_0x4741af){return respondWithRpcPromise(_0x1eff('0x46'),_0x922736[_0x1eff('0x17')],routingClient)[_0x1eff('0x8')](findById(_0x922736['params']['id']))[_0x1eff('0x8')](respondWithResult(_0x4741af,null))[_0x1eff('0xd')](handleError(_0x4741af,null));};exports['mailQueues']=function(_0x18275a,_0x25b503){return respondWithRpcPromise('MailQueues',_0x18275a['query'],routingClient)[_0x1eff('0x8')](respondWithResult(_0x25b503,null))[_0x1eff('0xd')](handleError(_0x25b503,null));};exports[_0x1eff('0x47')]=function(_0x167821,_0x2dce07){return respondWithRpcPromise(_0x1eff('0x48'),_0x167821[_0x1eff('0x17')],routingClient)[_0x1eff('0x8')](findById(_0x167821['params']['id']))['then'](respondWithResult(_0x2dce07,null))[_0x1eff('0xd')](handleError(_0x2dce07,null));};exports[_0x1eff('0x49')]=function(_0x209da5,_0x26b987){return respondWithRpcPromise(_0x1eff('0x4a'),_0x209da5[_0x1eff('0x17')],mailClient)[_0x1eff('0x8')](respondWithResult(_0x26b987,null))['catch'](handleError(_0x26b987,null));};exports[_0x1eff('0x4b')]=function(_0x3f6f69,_0x3a148c){return respondWithRpcPromise('OpenchannelQueues',_0x3f6f69['query'],routingClient)['then'](respondWithResult(_0x3a148c,null))[_0x1eff('0xd')](handleError(_0x3a148c,null));};exports[_0x1eff('0x4c')]=function(_0x8d8254,_0x1a4e62){return respondWithRpcPromise('OpenchannelQueues',_0x8d8254[_0x1eff('0x17')],routingClient)[_0x1eff('0x8')](findById(_0x8d8254[_0x1eff('0x1d')]['id']))[_0x1eff('0x8')](respondWithResult(_0x1a4e62,null))[_0x1eff('0xd')](handleError(_0x1a4e62,null));};exports[_0x1eff('0x4d')]=function(_0x324255,_0x4d6a69){return respondWithRpcPromise(_0x1eff('0x4e'),_0x324255[_0x1eff('0x17')],routingClient)['then'](respondWithResult(_0x4d6a69,null))[_0x1eff('0xd')](handleError(_0x4d6a69,null));};exports['showSmsQueues']=function(_0x4b7309,_0x56736e){return respondWithRpcPromise(_0x1eff('0x4e'),_0x4b7309[_0x1eff('0x17')],routingClient)[_0x1eff('0x8')](findById(_0x4b7309['params']['id']))[_0x1eff('0x8')](respondWithResult(_0x56736e,null))[_0x1eff('0xd')](handleError(_0x56736e,null));};exports['whatsappQueues']=function(_0x42eebf,_0x8d21e4){return respondWithRpcPromise('WhatsappQueues',_0x42eebf['query'],routingClient)['then'](respondWithResult(_0x8d21e4,null))['catch'](handleError(_0x8d21e4,null));};exports[_0x1eff('0x4f')]=function(_0x349d6e,_0xbb1a){return respondWithRpcPromise('WhatsappQueues',_0x349d6e[_0x1eff('0x17')],routingClient)[_0x1eff('0x8')](findById(_0x349d6e['params']['id']))[_0x1eff('0x8')](respondWithResult(_0xbb1a,null))[_0x1eff('0xd')](handleError(_0xbb1a,null));};exports[_0x1eff('0x50')]=function(_0x2d6518,_0x57bc9f){return respondWithRpcPromise(_0x1eff('0x51'),_0x2d6518[_0x1eff('0x17')],routingClient)['then'](respondWithResult(_0x57bc9f,null))[_0x1eff('0xd')](handleError(_0x57bc9f,null));};exports[_0x1eff('0x52')]=function(_0x56164b,_0x561169){return respondWithRpcPromise(_0x1eff('0x51'),_0x56164b[_0x1eff('0x17')],routingClient)['then'](findById(_0x56164b[_0x1eff('0x1d')]['id']))[_0x1eff('0x8')](respondWithResult(_0x561169,null))['catch'](handleError(_0x561169,null));};exports[_0x1eff('0x53')]=function(_0x1cc57f,_0x3e747f){return respondWithRpcPromise(_0x1eff('0x54'),_0x1cc57f[_0x1eff('0x17')])[_0x1eff('0x8')](respondWithResult(_0x3e747f,null))[_0x1eff('0xd')](handleError(_0x3e747f,null));};exports[_0x1eff('0x55')]=function(_0xeba95,_0x4f416a){return respondWithRpcPromise(_0x1eff('0x56'),_0xeba95[_0x1eff('0x17')],routingClient)[_0x1eff('0x8')](respondWithResult(_0x4f416a,null))['catch'](handleError(_0x4f416a,null));};exports[_0x1eff('0x57')]=function(_0x211000,_0x21a78b){return respondWithRpcPromise('MailQueuesWaitingInteractions',_0x211000[_0x1eff('0x17')],routingClient)['then'](respondWithResult(_0x21a78b,null))['catch'](handleError(_0x21a78b,null));};exports[_0x1eff('0x58')]=function(_0x3c03bf,_0x4f69dd){return respondWithRpcPromise(_0x1eff('0x59'),_0x3c03bf['query'],routingClient)[_0x1eff('0x8')](respondWithResult(_0x4f69dd,null))[_0x1eff('0xd')](handleError(_0x4f69dd,null));};exports['openchannelQueuesIdWaitingInteractions']=function(_0x4a2d93,_0x2fea71){return respondWithRpcPromise('OpenchannelQueuesWaitingInteractions',_0x4a2d93[_0x1eff('0x17')],routingClient)['then'](function(_0x3075df){if(_0x4a2d93[_0x1eff('0x17')][_0x1eff('0x5a')]!==undefined){var _0x521c22=_(_0x3075df[_0x1eff('0x14')])[_0x1eff('0x5b')]([_0x4a2d93[_0x1eff('0x17')]['type'],_0x4a2d93[_0x1eff('0x1d')]['id']])['map']('queue_id')['uniq']()['value']();return _0x3075df[_0x1eff('0x14')]['filter'](function(_0x9a9593){return _0x521c22[_0x1eff('0x5c')](_0x9a9593[_0x1eff('0x5d')])>-0x1;});}else{return _0x3075df[_0x1eff('0x14')][_0x1eff('0x5b')](function(_0x5f411c){return _0x5f411c[_0x1eff('0x5d')]===parseInt(_0x4a2d93[_0x1eff('0x1d')]['id']);});}})[_0x1eff('0x8')](respondWithResult(_0x2fea71,null))[_0x1eff('0xd')](handleError(_0x2fea71,null));};exports[_0x1eff('0x5e')]=function(_0x4e694b,_0x409506){return respondWithRpcPromise(_0x1eff('0x5f'),_0x4e694b['query'],routingClient)[_0x1eff('0x8')](respondWithResult(_0x409506,null))['catch'](handleError(_0x409506,null));};exports['whatsappQueuesWaitingInteractions']=function(_0x2348a0,_0xbb91bc){return respondWithRpcPromise('WhatsappQueuesWaitingInteractions',_0x2348a0[_0x1eff('0x17')],routingClient)[_0x1eff('0x8')](respondWithResult(_0xbb91bc,null))[_0x1eff('0xd')](handleError(_0xbb91bc,null));};exports[_0x1eff('0x60')]=function(_0x307e19,_0x4ef25f){return respondWithRpcPromise(_0x1eff('0x61'),_0x307e19[_0x1eff('0x17')],routingClient)[_0x1eff('0x8')](respondWithResult(_0x4ef25f,null))[_0x1eff('0xd')](handleError(_0x4ef25f,null));};exports[_0x1eff('0x62')]=function(_0x53406a){return function(_0x3c2a5c,_0x1533c2){var _0xd05a51,_0xdc9af7;var _0x522f1d=_[_0x1eff('0x63')](_0x53406a);var _0x5b9068=_0x53406a==='chat'?'Website':_0x1eff('0x64');return db[_0x522f1d+_0x1eff('0x65')][_0x1eff('0x66')]({'raw':!![],'where':{'id':_0x3c2a5c[_0x1eff('0x1d')]['id']}})['then'](function(_0x206e5d){if(_['isNil'](_0x206e5d)){throw new Error(_0x522f1d+_0x1eff('0x67'));}_0xd05a51=_0x206e5d;return db[_0x522f1d+_0x1eff('0x68')]['findOne']({'where':{'id':_0x3c2a5c[_0x1eff('0x22')]['messageId']},'include':[{'model':db[_0x522f1d+_0x1eff('0x69')],'as':'Interaction'},{'model':db[_0x522f1d+_0x5b9068],'as':_0x1eff('0x64')}]});})[_0x1eff('0x8')](function(_0x4e0dbb){if(_[_0x1eff('0x13')](_0x4e0dbb)){throw new Error(_0x522f1d+'\x20Message\x20not\x20found');}_0xdc9af7=_0x4e0dbb;return _0x4e0dbb[_0x1eff('0x6a')]({'read':0x0,'readAt':null,'UserId':null});})[_0x1eff('0x8')](function(){var _0x351fcb={'uniqueid':_0x53406a+'.'+_0xdc9af7['id']+'.'+_0xdc9af7[_0x1eff('0x69')]['id'],'FromUserId':_0x3c2a5c['user']['id'],'type':_0x1eff('0x6b')};_0x351fcb[_0x522f1d+_0x1eff('0x6c')]=_0xdc9af7['id'];_0x351fcb[_0x522f1d+_0x1eff('0x6d')]=_0xdc9af7[_0x1eff('0x69')]['id'];_0x351fcb[_0x1eff('0x6e')+_0x522f1d+_0x5b9068+'Id']=_0xdc9af7[_0x1eff('0x64')]['id'];_0x351fcb['To'+_0x522f1d+_0x1eff('0x6f')]=_0xd05a51['id'];return db[_0x522f1d+_0x1eff('0x70')][_0x1eff('0x71')](_0x351fcb);})[_0x1eff('0x8')](function(){return respondWithRpcPromise(_0x1eff('0x72'),{'channel':_0x53406a,'interaction':_0xdc9af7[_0x1eff('0x69')],'message':_0xdc9af7,'account':_0xdc9af7['Account'],'applications':[{'id':0x0,'priority':0x1,'app':_0x1eff('0x6b'),'appdata':_0xd05a51[_0x1eff('0x11')]+','+(_0xdc9af7['Account'][_0x1eff('0x73')]||0x12c),'interval':_0x1eff('0x74')}]},routingClient);})['then'](respondWithResult(_0x1533c2,null))[_0x1eff('0xd')](handleError(_0x1533c2,null));};};exports['agentNotify']=function(_0x1a1662,_0x3e08e4){var _0x119f5e,_0x2eee85;if(_[_0x1eff('0x13')](_0x1a1662[_0x1eff('0x22')]['channel'])){throw new Error(_0x1eff('0x75'));}var _0x58d21f=_0x1a1662[_0x1eff('0x22')]['channel'];var _0x59c1f9=_[_0x1eff('0x63')](_0x58d21f);var _0xb8d78d=_0x58d21f===_0x1eff('0x76')?_0x1eff('0x77'):_0x1eff('0x64');return db['User'][_0x1eff('0x66')]({'raw':!![],'where':{'id':_0x1a1662[_0x1eff('0x1d')]['id'],'role':_0x1eff('0x3b')}})[_0x1eff('0x8')](function(_0x26ba60){if(_[_0x1eff('0x13')](_0x26ba60)){throw new Error(_0x1eff('0x78'));}_0x119f5e=_0x26ba60;return db[_0x59c1f9+_0x1eff('0x68')]['findOne']({'where':{'id':_0x1a1662['body']['messageId']},'include':[{'model':db[_0x59c1f9+_0x1eff('0x69')],'as':_0x1eff('0x69')},{'model':db[_0x59c1f9+_0xb8d78d],'as':_0x1eff('0x64')}]});})[_0x1eff('0x8')](function(_0x56c92f){if(_[_0x1eff('0x13')](_0x56c92f)){throw new Error(_0x59c1f9+_0x1eff('0x79'));}_0x2eee85=_0x56c92f;return _0x56c92f[_0x1eff('0x6a')]({'read':0x0,'readAt':null,'UserId':null});})[_0x1eff('0x8')](function(){var _0x364dfe={'uniqueid':_0x58d21f+'.'+_0x2eee85['id']+'.'+_0x2eee85['Interaction']['id'],'FromUserId':_0x1a1662['user']['id'],'type':_0x1eff('0x6b'),'ToUserId':_0x119f5e['id']};_0x364dfe[_0x59c1f9+_0x1eff('0x6c')]=_0x2eee85['id'];_0x364dfe[_0x59c1f9+_0x1eff('0x6d')]=_0x2eee85[_0x1eff('0x69')]['id'];_0x364dfe[_0x1eff('0x6e')+_0x59c1f9+_0xb8d78d+'Id']=_0x2eee85[_0x1eff('0x64')]['id'];return db[_0x59c1f9+_0x1eff('0x70')][_0x1eff('0x71')](_0x364dfe);})['then'](function(){return respondWithRpcPromise('Start',{'channel':_0x58d21f,'interaction':_0x2eee85[_0x1eff('0x69')],'message':_0x2eee85,'account':_0x2eee85[_0x1eff('0x64')],'applications':[{'id':0x0,'priority':0x1,'app':_0x1eff('0x3b'),'appdata':_0x119f5e[_0x1eff('0x11')]+','+(_0x2eee85['Account'][_0x1eff('0x7a')]||0x12c),'interval':_0x1eff('0x74')}]},routingClient);})[_0x1eff('0x8')](respondWithResult(_0x3e08e4,null))[_0x1eff('0xd')](handleError(_0x3e08e4,null));};
\ No newline at end of file
+var _0xdbb0=['OpenchannelQueues','smsQueues','SmsQueues','showSmsQueues','WhatsappQueues','showWhatsappQueues','faxQueues','FaxQueues','showFaxQueues','faxAccounts','FaxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','MailQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','openchannelQueuesIdWaitingInteractions','type','filter','map','queue_id','value','indexOf','SmsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','WhatsappQueuesWaitingInteractions','faxQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','chat','Website','Queue','\x20Queue\x20not\x20found','findOne','Interaction','Account','\x20Message\x20not\x20found','update','queue','MessageId','InteractionId','From','TransferReport','create','Start','*,*,*,*','agentNotify','channel','Channel\x20field\x20is\x20mandatory','capitalize','User','agent','Agent\x20not\x20found','Message','messageId','agentTransferTimeout','bluebird','moment','lodash','../../mysqldb','../../config/logger','jayson/promise','http','client','request','then','error','code','message','status','sendStatus','stack','name','send','isNil','rows','find','voiceChannels','VoiceChannels','VoiceChannelMixMonitor','query','catch','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','merge','params','voiceQueues','VoiceQueues','showVoiceQueues','VoiceQueuesPreview','voiceQueuesChannels','VoiceQueuesChannels','voiceQueuesChannel','VoiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','outbound','Outbound','OutboundChannels','Agents','agentCapacity','body','interaction','user','hasOwnProperty','MemberReport','INTERACTION','length','format','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','findOrCreate','interface','SIP/%s','internal','AgentCapacity','capacity','trunks','Trunks','chatQueues','ChatQueues','showChatQueues','mailQueues','showMailQueues','mailAccounts','MailAccounts','openchannelQueues'];(function(_0x1af4d6,_0x29cdbb){var _0x1030e6=function(_0x23865d){while(--_0x23865d){_0x1af4d6['push'](_0x1af4d6['shift']());}};_0x1030e6(++_0x29cdbb);}(_0xdbb0,0x13a));var _0x0dbb=function(_0x3eb0d8,_0x4fd6d0){_0x3eb0d8=_0x3eb0d8-0x0;var _0x2f12ee=_0xdbb0[_0x3eb0d8];return _0x2f12ee;};'use strict';var BPromise=require(_0x0dbb('0x0'));var moment=require(_0x0dbb('0x1'));var _=require(_0x0dbb('0x2'));var util=require('util');var db=require(_0x0dbb('0x3'))['db'];var logger=require(_0x0dbb('0x4'))('api');var jayson=require(_0x0dbb('0x5'));var amiClient=jayson['client'][_0x0dbb('0x6')]({'port':0x232a});var mailClient=jayson['client']['http']({'port':0x232b});var routingClient=jayson[_0x0dbb('0x7')][_0x0dbb('0x6')]({'port':0x232c});function respondWithRpcPromise(_0x469d50,_0x1746a8,_0x535b7f){return new BPromise(function(_0x4ed5ab,_0x2dcfaf){var _0x1ef987=_0x535b7f?_0x535b7f:amiClient;return _0x1ef987[_0x0dbb('0x8')](_0x469d50,_0x1746a8)[_0x0dbb('0x9')](function(_0x122952){if(_0x122952[_0x0dbb('0xa')]){if(_0x122952[_0x0dbb('0xa')][_0x0dbb('0xb')]===0x1f4){return _0x2dcfaf(_0x122952[_0x0dbb('0xa')][_0x0dbb('0xc')]);}return _0x4ed5ab(_0x122952['error'][_0x0dbb('0xc')]);}else{_0x4ed5ab(_0x122952['result']);}})['catch'](function(_0x4f4aec){_0x2dcfaf(_0x4f4aec);});});}function respondWithResult(_0x14008f,_0x560056){_0x560056=_0x560056||0xc8;return function(_0x42f53c){if(_0x42f53c){return _0x14008f[_0x0dbb('0xd')](_0x560056)['json'](_0x42f53c);}return _0x14008f[_0x0dbb('0xe')](0x194);};}function handleError(_0x4f3f07,_0x5d064b){_0x5d064b=_0x5d064b||0x1f4;return function(_0x5d88bd){logger[_0x0dbb('0xa')](_0x5d88bd[_0x0dbb('0xf')]);if(_0x5d88bd[_0x0dbb('0x10')]){delete _0x5d88bd['name'];}_0x4f3f07[_0x0dbb('0xd')](_0x5d064b)[_0x0dbb('0x11')](_0x5d88bd);};}function findById(_0x2e1e3e){return function(_0x1a8adb){if(!_[_0x0dbb('0x12')](_0x2e1e3e)&&!_[_0x0dbb('0x12')](_0x1a8adb)&&!_[_0x0dbb('0x12')](_0x1a8adb[_0x0dbb('0x13')])){return _[_0x0dbb('0x14')](_0x1a8adb[_0x0dbb('0x13')],function(_0x5a5218){return _0x5a5218['id']==_0x2e1e3e;});}return null;};}exports[_0x0dbb('0x15')]=function(_0x76527c,_0x47a81b){return respondWithRpcPromise(_0x0dbb('0x16'),_0x76527c['query'])[_0x0dbb('0x9')](respondWithResult(_0x47a81b,null))['catch'](handleError(_0x47a81b,null));};exports['voiceChannelMixMonitor']=function(_0x3e6864,_0x545e8c){return respondWithRpcPromise(_0x0dbb('0x17'),_['merge'](_0x3e6864[_0x0dbb('0x18')],_0x3e6864['params']))[_0x0dbb('0x9')](respondWithResult(_0x545e8c,null))[_0x0dbb('0x19')](handleError(_0x545e8c,null));};exports[_0x0dbb('0x1a')]=function(_0x205dc7,_0x5f37ec){return respondWithRpcPromise(_0x0dbb('0x1b'),_[_0x0dbb('0x1c')](_0x205dc7[_0x0dbb('0x18')],_0x205dc7[_0x0dbb('0x1d')]))[_0x0dbb('0x9')](respondWithResult(_0x5f37ec,null))[_0x0dbb('0x19')](handleError(_0x5f37ec,null));};exports[_0x0dbb('0x1e')]=function(_0x193caa,_0x5434bd){return respondWithRpcPromise(_0x0dbb('0x1f'),_0x193caa[_0x0dbb('0x18')])[_0x0dbb('0x9')](respondWithResult(_0x5434bd,null))[_0x0dbb('0x19')](handleError(_0x5434bd,null));};exports[_0x0dbb('0x20')]=function(_0x4af82d,_0x4addce){return respondWithRpcPromise(_0x0dbb('0x1f'),_0x4af82d[_0x0dbb('0x18')])[_0x0dbb('0x9')](findById(_0x4af82d[_0x0dbb('0x1d')]['id']))[_0x0dbb('0x9')](respondWithResult(_0x4addce,null))[_0x0dbb('0x19')](handleError(_0x4addce,null));};exports['voiceQueuesPreview']=function(_0x32c9e4,_0x2a1dfb){return respondWithRpcPromise(_0x0dbb('0x21'),_[_0x0dbb('0x1c')](_0x32c9e4['query'],_0x32c9e4['params']))[_0x0dbb('0x9')](respondWithResult(_0x2a1dfb,null))[_0x0dbb('0x19')](handleError(_0x2a1dfb,null));};exports[_0x0dbb('0x22')]=function(_0x4a6d70,_0x1896be){return respondWithRpcPromise(_0x0dbb('0x23'),_0x4a6d70[_0x0dbb('0x18')])[_0x0dbb('0x9')](respondWithResult(_0x1896be,null))[_0x0dbb('0x19')](handleError(_0x1896be,null));};exports[_0x0dbb('0x24')]=function(_0x1999a5,_0xa156e){return respondWithRpcPromise(_0x0dbb('0x25'),_[_0x0dbb('0x1c')](_0x1999a5['query'],_0x1999a5[_0x0dbb('0x1d')]))[_0x0dbb('0x9')](respondWithResult(_0xa156e,null))[_0x0dbb('0x19')](handleError(_0xa156e,null));};exports[_0x0dbb('0x26')]=function(_0xf631d2,_0x11105a){return respondWithRpcPromise(_0x0dbb('0x27'),_[_0x0dbb('0x1c')](_0xf631d2[_0x0dbb('0x18')],_0xf631d2[_0x0dbb('0x1d')]))[_0x0dbb('0x9')](respondWithResult(_0x11105a,null))['catch'](handleError(_0x11105a,null));};exports[_0x0dbb('0x28')]=function(_0x34b384,_0x5bf570){return respondWithRpcPromise(_0x0dbb('0x29'),_[_0x0dbb('0x1c')](_0x34b384[_0x0dbb('0x18')],_0x34b384[_0x0dbb('0x1d')]))['then'](respondWithResult(_0x5bf570,null))['catch'](handleError(_0x5bf570,null));};exports[_0x0dbb('0x2a')]=function(_0x3c5efe,_0x26dafb){return respondWithRpcPromise(_0x0dbb('0x2b'),_0x3c5efe[_0x0dbb('0x18')])[_0x0dbb('0x9')](respondWithResult(_0x26dafb,null))[_0x0dbb('0x19')](handleError(_0x26dafb,null));};exports['outboundChannels']=function(_0x5a790d,_0x32e6ed){return respondWithRpcPromise(_0x0dbb('0x2c'),_0x5a790d[_0x0dbb('0x18')])[_0x0dbb('0x9')](respondWithResult(_0x32e6ed,null))[_0x0dbb('0x19')](handleError(_0x32e6ed,null));};exports['agents']=function(_0x4e88d3,_0x222136){var _0x22c047;return respondWithRpcPromise(_0x0dbb('0x2d'),_0x4e88d3[_0x0dbb('0x18')])[_0x0dbb('0x9')](function(_0x3406f0){_0x22c047=_0x3406f0;return respondWithRpcPromise(_0x0dbb('0x2d'),_0x4e88d3[_0x0dbb('0x18')],routingClient);})[_0x0dbb('0x9')](function(_0x479cd3){return _[_0x0dbb('0x1c')]({},_0x479cd3,_0x22c047);})[_0x0dbb('0x9')](respondWithResult(_0x222136,null))['catch'](handleError(_0x222136,null));};exports[_0x0dbb('0x2e')]=function(_0x5b3ba3,_0x327b9b){if(_0x5b3ba3['body']&&_0x5b3ba3[_0x0dbb('0x2f')][_0x0dbb('0x30')]&&_0x5b3ba3[_0x0dbb('0x31')]&&_0x5b3ba3[_0x0dbb('0x31')][_0x0dbb('0x10')]){for(var _0x4645fc in _0x5b3ba3['body'][_0x0dbb('0x30')]){if(_0x5b3ba3[_0x0dbb('0x2f')][_0x0dbb('0x30')][_0x0dbb('0x32')](_0x4645fc)){db[_0x0dbb('0x33')]['findAll']({'where':{'channel':_0x4645fc,'membername':_0x5b3ba3[_0x0dbb('0x31')]['name'],'type':_0x0dbb('0x34'),'exitAt':null,'uniqueid':_0x5b3ba3[_0x0dbb('0x2f')][_0x0dbb('0x30')][_0x4645fc]&&_0x5b3ba3[_0x0dbb('0x2f')]['interaction'][_0x4645fc][_0x0dbb('0x35')]?{'$notIn':_0x5b3ba3[_0x0dbb('0x2f')]['interaction'][_0x4645fc]}:{'$ne':null}}})[_0x0dbb('0x9')](function(_0x489b84){var _0x1551fc=moment()[_0x0dbb('0x36')](_0x0dbb('0x37'));for(var _0x4905fe=0x0,_0x471f3f=_0x489b84[_0x0dbb('0x35')];_0x4905fe<_0x471f3f;_0x4905fe+=0x1){_0x489b84[_0x4905fe][_0x0dbb('0x38')]({'exitAt':_0x1551fc});}});for(var _0x127e00=0x0;_0x127e00<_0x5b3ba3['body'][_0x0dbb('0x30')][_0x4645fc][_0x0dbb('0x35')];_0x127e00+=0x1){db[_0x0dbb('0x33')][_0x0dbb('0x39')]({'where':{'channel':_0x4645fc,'membername':_0x5b3ba3['user'][_0x0dbb('0x10')],'type':'INTERACTION','uniqueid':_0x5b3ba3['body']['interaction'][_0x4645fc][_0x127e00],'exitAt':null},'defaults':{'channel':_0x4645fc,'membername':_0x5b3ba3[_0x0dbb('0x31')][_0x0dbb('0x10')],'interface':_[_0x0dbb('0x12')](_0x5b3ba3[_0x0dbb('0x31')][_0x0dbb('0x3a')])?util[_0x0dbb('0x36')](_0x0dbb('0x3b'),_0x5b3ba3[_0x0dbb('0x31')][_0x0dbb('0x10')]):_0x5b3ba3[_0x0dbb('0x31')]['interface'],'type':'INTERACTION','enterAt':moment()[_0x0dbb('0x36')](_0x0dbb('0x37')),'role':'agent','internal':_0x5b3ba3[_0x0dbb('0x31')][_0x0dbb('0x3c')],'uniqueid':_0x5b3ba3[_0x0dbb('0x2f')][_0x0dbb('0x30')][_0x4645fc][_0x127e00]}});}}}}return respondWithRpcPromise(_0x0dbb('0x3d'),{'id':_0x5b3ba3[_0x0dbb('0x1d')]['id'],'capacity':_0x5b3ba3['body'][_0x0dbb('0x3e')]},routingClient)[_0x0dbb('0x9')](respondWithResult(_0x327b9b,null))[_0x0dbb('0x19')](handleError(_0x327b9b,null));};exports['telephones']=function(_0x58f3f3,_0x28bff9){return respondWithRpcPromise('Telephones',_0x58f3f3[_0x0dbb('0x18')])[_0x0dbb('0x9')](respondWithResult(_0x28bff9,null))[_0x0dbb('0x19')](handleError(_0x28bff9,null));};exports[_0x0dbb('0x3f')]=function(_0x537464,_0x44ecab){return respondWithRpcPromise(_0x0dbb('0x40'),_0x537464['query'])['then'](respondWithResult(_0x44ecab,null))[_0x0dbb('0x19')](handleError(_0x44ecab,null));};exports['campaigns']=function(_0x5e364c,_0x3a3557){return respondWithRpcPromise('Campaigns',_0x5e364c[_0x0dbb('0x18')])[_0x0dbb('0x9')](respondWithResult(_0x3a3557,null))[_0x0dbb('0x19')](handleError(_0x3a3557,null));};exports[_0x0dbb('0x41')]=function(_0x2aa4f6,_0x4a5f49){return respondWithRpcPromise(_0x0dbb('0x42'),_0x2aa4f6['query'],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x4a5f49,null))[_0x0dbb('0x19')](handleError(_0x4a5f49,null));};exports[_0x0dbb('0x43')]=function(_0xae7fa3,_0x48f3ee){return respondWithRpcPromise(_0x0dbb('0x42'),_0xae7fa3['query'],routingClient)[_0x0dbb('0x9')](findById(_0xae7fa3[_0x0dbb('0x1d')]['id']))[_0x0dbb('0x9')](respondWithResult(_0x48f3ee,null))['catch'](handleError(_0x48f3ee,null));};exports[_0x0dbb('0x44')]=function(_0x1b0765,_0x345502){return respondWithRpcPromise('MailQueues',_0x1b0765[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x345502,null))[_0x0dbb('0x19')](handleError(_0x345502,null));};exports[_0x0dbb('0x45')]=function(_0x1d73b0,_0x475af9){return respondWithRpcPromise('MailQueues',_0x1d73b0[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](findById(_0x1d73b0[_0x0dbb('0x1d')]['id']))[_0x0dbb('0x9')](respondWithResult(_0x475af9,null))['catch'](handleError(_0x475af9,null));};exports[_0x0dbb('0x46')]=function(_0x2f4c55,_0x1a0273){return respondWithRpcPromise(_0x0dbb('0x47'),_0x2f4c55[_0x0dbb('0x18')],mailClient)['then'](respondWithResult(_0x1a0273,null))[_0x0dbb('0x19')](handleError(_0x1a0273,null));};exports[_0x0dbb('0x48')]=function(_0x45d01d,_0x423340){return respondWithRpcPromise(_0x0dbb('0x49'),_0x45d01d[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x423340,null))[_0x0dbb('0x19')](handleError(_0x423340,null));};exports['showOpenchannelQueues']=function(_0x12eaf5,_0x8193fa){return respondWithRpcPromise(_0x0dbb('0x49'),_0x12eaf5[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](findById(_0x12eaf5[_0x0dbb('0x1d')]['id']))[_0x0dbb('0x9')](respondWithResult(_0x8193fa,null))[_0x0dbb('0x19')](handleError(_0x8193fa,null));};exports[_0x0dbb('0x4a')]=function(_0x2a72c7,_0x173c65){return respondWithRpcPromise(_0x0dbb('0x4b'),_0x2a72c7['query'],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x173c65,null))[_0x0dbb('0x19')](handleError(_0x173c65,null));};exports[_0x0dbb('0x4c')]=function(_0x5dfa15,_0xa73a43){return respondWithRpcPromise(_0x0dbb('0x4b'),_0x5dfa15['query'],routingClient)[_0x0dbb('0x9')](findById(_0x5dfa15[_0x0dbb('0x1d')]['id']))[_0x0dbb('0x9')](respondWithResult(_0xa73a43,null))['catch'](handleError(_0xa73a43,null));};exports['whatsappQueues']=function(_0x2124a8,_0x3e359f){return respondWithRpcPromise(_0x0dbb('0x4d'),_0x2124a8[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x3e359f,null))['catch'](handleError(_0x3e359f,null));};exports[_0x0dbb('0x4e')]=function(_0x503519,_0x31fd95){return respondWithRpcPromise(_0x0dbb('0x4d'),_0x503519[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](findById(_0x503519[_0x0dbb('0x1d')]['id']))[_0x0dbb('0x9')](respondWithResult(_0x31fd95,null))['catch'](handleError(_0x31fd95,null));};exports[_0x0dbb('0x4f')]=function(_0x47f159,_0x3fe03d){return respondWithRpcPromise(_0x0dbb('0x50'),_0x47f159[_0x0dbb('0x18')],routingClient)['then'](respondWithResult(_0x3fe03d,null))[_0x0dbb('0x19')](handleError(_0x3fe03d,null));};exports[_0x0dbb('0x51')]=function(_0x1ee385,_0x5ddf9e){return respondWithRpcPromise(_0x0dbb('0x50'),_0x1ee385[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](findById(_0x1ee385['params']['id']))[_0x0dbb('0x9')](respondWithResult(_0x5ddf9e,null))['catch'](handleError(_0x5ddf9e,null));};exports[_0x0dbb('0x52')]=function(_0x12a6b3,_0x458ab7){return respondWithRpcPromise(_0x0dbb('0x53'),_0x12a6b3[_0x0dbb('0x18')])['then'](respondWithResult(_0x458ab7,null))[_0x0dbb('0x19')](handleError(_0x458ab7,null));};exports[_0x0dbb('0x54')]=function(_0x5b1fb7,_0x43a05c){return respondWithRpcPromise(_0x0dbb('0x55'),_0x5b1fb7[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x43a05c,null))[_0x0dbb('0x19')](handleError(_0x43a05c,null));};exports[_0x0dbb('0x56')]=function(_0x3883ce,_0x5bd8a6){return respondWithRpcPromise(_0x0dbb('0x57'),_0x3883ce[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x5bd8a6,null))[_0x0dbb('0x19')](handleError(_0x5bd8a6,null));};exports['openchannelQueuesWaitingInteractions']=function(_0x5976a0,_0x4864a4){return respondWithRpcPromise(_0x0dbb('0x58'),_0x5976a0['query'],routingClient)['then'](respondWithResult(_0x4864a4,null))[_0x0dbb('0x19')](handleError(_0x4864a4,null));};exports[_0x0dbb('0x59')]=function(_0x37cfef,_0x3dbb78){return respondWithRpcPromise(_0x0dbb('0x58'),_0x37cfef[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](function(_0x4dd22e){if(_0x37cfef[_0x0dbb('0x18')][_0x0dbb('0x5a')]!==undefined){var _0x499fbb=_(_0x4dd22e[_0x0dbb('0x13')])[_0x0dbb('0x5b')]([_0x37cfef['query']['type'],_0x37cfef[_0x0dbb('0x1d')]['id']])[_0x0dbb('0x5c')](_0x0dbb('0x5d'))['uniq']()[_0x0dbb('0x5e')]();return _0x4dd22e[_0x0dbb('0x13')][_0x0dbb('0x5b')](function(_0x370f7e){return _0x499fbb[_0x0dbb('0x5f')](_0x370f7e[_0x0dbb('0x5d')])>-0x1;});}else{return _0x4dd22e[_0x0dbb('0x13')][_0x0dbb('0x5b')](function(_0x59064b){return _0x59064b['queue_id']===parseInt(_0x37cfef[_0x0dbb('0x1d')]['id']);});}})['then'](respondWithResult(_0x3dbb78,null))[_0x0dbb('0x19')](handleError(_0x3dbb78,null));};exports['smsQueuesWaitingInteractions']=function(_0x27fa32,_0x1b855c){return respondWithRpcPromise(_0x0dbb('0x60'),_0x27fa32['query'],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x1b855c,null))['catch'](handleError(_0x1b855c,null));};exports[_0x0dbb('0x61')]=function(_0x4d493c,_0x661c08){return respondWithRpcPromise(_0x0dbb('0x62'),_0x4d493c['query'],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x661c08,null))[_0x0dbb('0x19')](handleError(_0x661c08,null));};exports[_0x0dbb('0x63')]=function(_0x17d1a9,_0x21b696){return respondWithRpcPromise(_0x0dbb('0x64'),_0x17d1a9[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x21b696,null))['catch'](handleError(_0x21b696,null));};exports[_0x0dbb('0x65')]=function(_0x45df36){return function(_0x2f1ecc,_0x45eca7){var _0x5b9000,_0x2f5fe7;var _0x2b2bf4=_['capitalize'](_0x45df36);var _0x5b40da=_0x45df36===_0x0dbb('0x66')?_0x0dbb('0x67'):'Account';return db[_0x2b2bf4+_0x0dbb('0x68')]['findOne']({'raw':!![],'where':{'id':_0x2f1ecc[_0x0dbb('0x1d')]['id']}})['then'](function(_0x1d58c8){if(_[_0x0dbb('0x12')](_0x1d58c8)){throw new Error(_0x2b2bf4+_0x0dbb('0x69'));}_0x5b9000=_0x1d58c8;return db[_0x2b2bf4+'Message'][_0x0dbb('0x6a')]({'where':{'id':_0x2f1ecc[_0x0dbb('0x2f')]['messageId']},'include':[{'model':db[_0x2b2bf4+_0x0dbb('0x6b')],'as':'Interaction'},{'model':db[_0x2b2bf4+_0x5b40da],'as':_0x0dbb('0x6c')}]});})['then'](function(_0x4e5bee){if(_[_0x0dbb('0x12')](_0x4e5bee)){throw new Error(_0x2b2bf4+_0x0dbb('0x6d'));}_0x2f5fe7=_0x4e5bee;return _0x4e5bee[_0x0dbb('0x6e')]({'read':0x0,'readAt':null,'UserId':null});})[_0x0dbb('0x9')](function(){var _0x1eb446={'uniqueid':_0x45df36+'.'+_0x2f5fe7['id']+'.'+_0x2f5fe7['Interaction']['id'],'FromUserId':_0x2f1ecc['user']['id'],'type':_0x0dbb('0x6f')};_0x1eb446[_0x2b2bf4+_0x0dbb('0x70')]=_0x2f5fe7['id'];_0x1eb446[_0x2b2bf4+_0x0dbb('0x71')]=_0x2f5fe7[_0x0dbb('0x6b')]['id'];_0x1eb446[_0x0dbb('0x72')+_0x2b2bf4+_0x5b40da+'Id']=_0x2f5fe7[_0x0dbb('0x6c')]['id'];_0x1eb446['To'+_0x2b2bf4+'QueueId']=_0x5b9000['id'];return db[_0x2b2bf4+_0x0dbb('0x73')][_0x0dbb('0x74')](_0x1eb446);})['then'](function(){return respondWithRpcPromise(_0x0dbb('0x75'),{'channel':_0x45df36,'interaction':_0x2f5fe7[_0x0dbb('0x6b')],'message':_0x2f5fe7,'account':_0x2f5fe7[_0x0dbb('0x6c')],'applications':[{'id':0x0,'priority':0x1,'app':_0x0dbb('0x6f'),'appdata':_0x5b9000[_0x0dbb('0x10')]+','+(_0x2f5fe7[_0x0dbb('0x6c')]['queueTransferTimeout']||0x12c),'interval':_0x0dbb('0x76')}]},routingClient);})[_0x0dbb('0x9')](respondWithResult(_0x45eca7,null))[_0x0dbb('0x19')](handleError(_0x45eca7,null));};};exports[_0x0dbb('0x77')]=function(_0x2cc9de,_0x285c83){var _0xf84fe,_0x493ac0;if(_['isNil'](_0x2cc9de['body'][_0x0dbb('0x78')])){throw new Error(_0x0dbb('0x79'));}var _0x492039=_0x2cc9de[_0x0dbb('0x2f')]['channel'];var _0x44d0c1=_[_0x0dbb('0x7a')](_0x492039);var _0x1d4b75=_0x492039===_0x0dbb('0x66')?_0x0dbb('0x67'):_0x0dbb('0x6c');return db[_0x0dbb('0x7b')][_0x0dbb('0x6a')]({'raw':!![],'where':{'id':_0x2cc9de[_0x0dbb('0x1d')]['id'],'role':_0x0dbb('0x7c')}})['then'](function(_0x4246d9){if(_['isNil'](_0x4246d9)){throw new Error(_0x0dbb('0x7d'));}_0xf84fe=_0x4246d9;return db[_0x44d0c1+_0x0dbb('0x7e')][_0x0dbb('0x6a')]({'where':{'id':_0x2cc9de['body'][_0x0dbb('0x7f')]},'include':[{'model':db[_0x44d0c1+_0x0dbb('0x6b')],'as':_0x0dbb('0x6b')},{'model':db[_0x44d0c1+_0x1d4b75],'as':'Account'}]});})['then'](function(_0xc2073e){if(_['isNil'](_0xc2073e)){throw new Error(_0x44d0c1+_0x0dbb('0x6d'));}_0x493ac0=_0xc2073e;return _0xc2073e[_0x0dbb('0x6e')]({'read':0x0,'readAt':null,'UserId':null});})['then'](function(){var _0xf952a5={'uniqueid':_0x492039+'.'+_0x493ac0['id']+'.'+_0x493ac0['Interaction']['id'],'FromUserId':_0x2cc9de[_0x0dbb('0x31')]['id'],'type':_0x0dbb('0x6f'),'ToUserId':_0xf84fe['id']};_0xf952a5[_0x44d0c1+'MessageId']=_0x493ac0['id'];_0xf952a5[_0x44d0c1+_0x0dbb('0x71')]=_0x493ac0['Interaction']['id'];_0xf952a5[_0x0dbb('0x72')+_0x44d0c1+_0x1d4b75+'Id']=_0x493ac0[_0x0dbb('0x6c')]['id'];return db[_0x44d0c1+'TransferReport']['create'](_0xf952a5);})[_0x0dbb('0x9')](function(){return respondWithRpcPromise(_0x0dbb('0x75'),{'channel':_0x492039,'interaction':_0x493ac0[_0x0dbb('0x6b')],'message':_0x493ac0,'account':_0x493ac0[_0x0dbb('0x6c')],'applications':[{'id':0x0,'priority':0x1,'app':_0x0dbb('0x7c'),'appdata':_0xf84fe[_0x0dbb('0x10')]+','+(_0x493ac0[_0x0dbb('0x6c')][_0x0dbb('0x80')]||0x12c),'interval':_0x0dbb('0x76')}]},routingClient);})[_0x0dbb('0x9')](respondWithResult(_0x285c83,null))[_0x0dbb('0x19')](handleError(_0x285c83,null));};
\ No newline at end of file