Built motion from commit 4e7c323b.|2.5.34
[motion2.git] / server / api / rpc / rpc.controller.js
index 60157db..f89a938 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb138=['telephones','Telephones','campaigns','Campaigns','chatQueues','ChatQueues','showChatQueues','mailQueues','MailQueues','showMailQueues','mailAccounts','MailAccounts','openchannelQueues','OpenchannelQueues','showOpenchannelQueues','smsQueues','SmsQueues','showSmsQueues','whatsappQueues','WhatsappQueues','showWhatsappQueues','faxQueues','FaxQueues','showFaxQueues','faxAccounts','FaxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','MailQueuesWaitingInteractions','openchannelQueuesIdWaitingInteractions','OpenchannelQueuesWaitingInteractions','type','filter','map','queue_id','uniq','value','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','WhatsappQueuesWaitingInteractions','faxQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','chat','Website','Account','Queue','findOne','\x20Queue\x20not\x20found','messageId','Interaction','update','queue','MessageId','InteractionId','From','QueueId','create','Start','queueTransferTimeout','*,*,*,*','Channel\x20field\x20is\x20mandatory','channel','capitalize','User','agent','Agent\x20not\x20found','Message','\x20Message\x20not\x20found','agentTransferTimeout','bluebird','moment','lodash','util','../../mysqldb','../../config/logger','api','client','http','request','error','code','message','result','catch','json','sendStatus','stack','name','status','isNil','rows','find','VoiceChannels','query','then','VoiceChannelMixMonitor','params','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','merge','voiceQueues','VoiceQueues','updateVoiceQueue','UpdateVoiceQueue','body','voiceQueuesPreview','VoiceQueuesPreview','voiceQueuesChannels','VoiceQueuesChannels','VoiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','outbound','OutboundChannels','Agents','interaction','user','hasOwnProperty','MemberReport','findAll','length','format','YYYY-MM-DD\x20HH:mm:ss','findOrCreate','INTERACTION','SIP/%s','interface','internal','AgentCapacity','capacity'];(function(_0x76b82e,_0x4f923e){var _0x10ea22=function(_0x1828f3){while(--_0x1828f3){_0x76b82e['push'](_0x76b82e['shift']());}};_0x10ea22(++_0x4f923e);}(_0xb138,0x1dd));var _0x8b13=function(_0x2350c0,_0x422b5f){_0x2350c0=_0x2350c0-0x0;var _0xfc82e5=_0xb138[_0x2350c0];return _0xfc82e5;};'use strict';var BPromise=require(_0x8b13('0x0'));var moment=require(_0x8b13('0x1'));var _=require(_0x8b13('0x2'));var util=require(_0x8b13('0x3'));var db=require(_0x8b13('0x4'))['db'];var logger=require(_0x8b13('0x5'))(_0x8b13('0x6'));var jayson=require('jayson/promise');var amiClient=jayson[_0x8b13('0x7')][_0x8b13('0x8')]({'port':0x232a});var mailClient=jayson[_0x8b13('0x7')]['http']({'port':0x232b});var routingClient=jayson[_0x8b13('0x7')][_0x8b13('0x8')]({'port':0x232c});function respondWithRpcPromise(_0x5d51b1,_0x3fdf4d,_0x33d1a7){return new BPromise(function(_0x22e157,_0x498832){var _0x8570b0=_0x33d1a7?_0x33d1a7:amiClient;return _0x8570b0[_0x8b13('0x9')](_0x5d51b1,_0x3fdf4d)['then'](function(_0x53ae50){if(_0x53ae50[_0x8b13('0xa')]){if(_0x53ae50[_0x8b13('0xa')][_0x8b13('0xb')]===0x1f4){return _0x498832(_0x53ae50[_0x8b13('0xa')][_0x8b13('0xc')]);}return _0x22e157(_0x53ae50['error'][_0x8b13('0xc')]);}else{_0x22e157(_0x53ae50[_0x8b13('0xd')]);}})[_0x8b13('0xe')](function(_0x3f79d5){_0x498832(_0x3f79d5);});});}function respondWithResult(_0xb227e0,_0x1893b1){_0x1893b1=_0x1893b1||0xc8;return function(_0x58f97e){if(_0x58f97e){return _0xb227e0['status'](_0x1893b1)[_0x8b13('0xf')](_0x58f97e);}return _0xb227e0[_0x8b13('0x10')](0x194);};}function handleError(_0x5f12b5,_0x51a935){_0x51a935=_0x51a935||0x1f4;return function(_0x479773){logger[_0x8b13('0xa')](_0x479773[_0x8b13('0x11')]);if(_0x479773[_0x8b13('0x12')]){delete _0x479773[_0x8b13('0x12')];}_0x5f12b5[_0x8b13('0x13')](_0x51a935)['send'](_0x479773);};}function findById(_0x1c6c99){return function(_0xea7881){if(!_[_0x8b13('0x14')](_0x1c6c99)&&!_[_0x8b13('0x14')](_0xea7881)&&!_[_0x8b13('0x14')](_0xea7881[_0x8b13('0x15')])){return _[_0x8b13('0x16')](_0xea7881[_0x8b13('0x15')],function(_0x4989d3){return _0x4989d3['id']==_0x1c6c99;});}return null;};}exports['voiceChannels']=function(_0xae4966,_0x335709){return respondWithRpcPromise(_0x8b13('0x17'),_0xae4966[_0x8b13('0x18')])[_0x8b13('0x19')](respondWithResult(_0x335709,null))[_0x8b13('0xe')](handleError(_0x335709,null));};exports['voiceChannelMixMonitor']=function(_0x1e8a48,_0x3c4d4f){return respondWithRpcPromise(_0x8b13('0x1a'),_['merge'](_0x1e8a48['query'],_0x1e8a48[_0x8b13('0x1b')]))[_0x8b13('0x19')](respondWithResult(_0x3c4d4f,null))['catch'](handleError(_0x3c4d4f,null));};exports[_0x8b13('0x1c')]=function(_0x2c3afb,_0x37ca5f){return respondWithRpcPromise(_0x8b13('0x1d'),_[_0x8b13('0x1e')](_0x2c3afb['query'],_0x2c3afb[_0x8b13('0x1b')]))[_0x8b13('0x19')](respondWithResult(_0x37ca5f,null))['catch'](handleError(_0x37ca5f,null));};exports[_0x8b13('0x1f')]=function(_0x4fdd1c,_0x420772){return respondWithRpcPromise(_0x8b13('0x20'),_0x4fdd1c['query'])[_0x8b13('0x19')](respondWithResult(_0x420772,null))[_0x8b13('0xe')](handleError(_0x420772,null));};exports['showVoiceQueues']=function(_0x134c5e,_0x14a739){return respondWithRpcPromise(_0x8b13('0x20'),_0x134c5e[_0x8b13('0x18')])[_0x8b13('0x19')](findById(_0x134c5e['params']['id']))[_0x8b13('0x19')](respondWithResult(_0x14a739,null))[_0x8b13('0xe')](handleError(_0x14a739,null));};exports[_0x8b13('0x21')]=function(_0x1511bf,_0x114b01){return respondWithRpcPromise(_0x8b13('0x22'),_['merge'](_0x1511bf[_0x8b13('0x23')],_0x1511bf[_0x8b13('0x1b')]))[_0x8b13('0x19')](respondWithResult(_0x114b01,null))[_0x8b13('0xe')](handleError(_0x114b01,null));};exports[_0x8b13('0x24')]=function(_0x29946e,_0x3304bd){return respondWithRpcPromise(_0x8b13('0x25'),_[_0x8b13('0x1e')](_0x29946e['query'],_0x29946e[_0x8b13('0x1b')]))[_0x8b13('0x19')](respondWithResult(_0x3304bd,null))[_0x8b13('0xe')](handleError(_0x3304bd,null));};exports[_0x8b13('0x26')]=function(_0x51a334,_0x4f7d91){return respondWithRpcPromise(_0x8b13('0x27'),_0x51a334['query'])['then'](respondWithResult(_0x4f7d91,null))[_0x8b13('0xe')](handleError(_0x4f7d91,null));};exports['voiceQueuesChannel']=function(_0x2ec1ab,_0x408626){return respondWithRpcPromise(_0x8b13('0x28'),_[_0x8b13('0x1e')](_0x2ec1ab[_0x8b13('0x18')],_0x2ec1ab[_0x8b13('0x1b')]))[_0x8b13('0x19')](respondWithResult(_0x408626,null))[_0x8b13('0xe')](handleError(_0x408626,null));};exports[_0x8b13('0x29')]=function(_0x1b313d,_0x4d45bc){return respondWithRpcPromise(_0x8b13('0x2a'),_[_0x8b13('0x1e')](_0x1b313d[_0x8b13('0x18')],_0x1b313d[_0x8b13('0x1b')]))[_0x8b13('0x19')](respondWithResult(_0x4d45bc,null))[_0x8b13('0xe')](handleError(_0x4d45bc,null));};exports[_0x8b13('0x2b')]=function(_0x241687,_0x5c67b1){return respondWithRpcPromise(_0x8b13('0x2c'),_['merge'](_0x241687[_0x8b13('0x18')],_0x241687[_0x8b13('0x1b')]))[_0x8b13('0x19')](respondWithResult(_0x5c67b1,null))[_0x8b13('0xe')](handleError(_0x5c67b1,null));};exports[_0x8b13('0x2d')]=function(_0x327eb1,_0x4ec1a5){return respondWithRpcPromise('Outbound',_0x327eb1[_0x8b13('0x18')])['then'](respondWithResult(_0x4ec1a5,null))[_0x8b13('0xe')](handleError(_0x4ec1a5,null));};exports['outboundChannels']=function(_0x590a23,_0x3a8e06){return respondWithRpcPromise(_0x8b13('0x2e'),_0x590a23[_0x8b13('0x18')])[_0x8b13('0x19')](respondWithResult(_0x3a8e06,null))['catch'](handleError(_0x3a8e06,null));};exports['agents']=function(_0x230a8c,_0x595d8d){var _0x6ba2f3;return respondWithRpcPromise(_0x8b13('0x2f'),_0x230a8c['query'])[_0x8b13('0x19')](function(_0x41d710){_0x6ba2f3=_0x41d710;return respondWithRpcPromise(_0x8b13('0x2f'),_0x230a8c[_0x8b13('0x18')],routingClient);})[_0x8b13('0x19')](function(_0x38ec75){return _[_0x8b13('0x1e')]({},_0x38ec75,_0x6ba2f3);})['then'](respondWithResult(_0x595d8d,null))['catch'](handleError(_0x595d8d,null));};exports['agentCapacity']=function(_0x3eb3c5,_0x16ec3){if(_0x3eb3c5[_0x8b13('0x23')]&&_0x3eb3c5[_0x8b13('0x23')][_0x8b13('0x30')]&&_0x3eb3c5[_0x8b13('0x31')]&&_0x3eb3c5['user'][_0x8b13('0x12')]){for(var _0x50e535 in _0x3eb3c5[_0x8b13('0x23')]['interaction']){if(_0x3eb3c5[_0x8b13('0x23')][_0x8b13('0x30')][_0x8b13('0x32')](_0x50e535)){db[_0x8b13('0x33')][_0x8b13('0x34')]({'where':{'channel':_0x50e535,'membername':_0x3eb3c5[_0x8b13('0x31')][_0x8b13('0x12')],'type':'INTERACTION','exitAt':null,'uniqueid':_0x3eb3c5['body']['interaction'][_0x50e535]&&_0x3eb3c5[_0x8b13('0x23')][_0x8b13('0x30')][_0x50e535][_0x8b13('0x35')]?{'$notIn':_0x3eb3c5[_0x8b13('0x23')]['interaction'][_0x50e535]}:{'$ne':null}}})['then'](function(_0x3f420d){var _0x54d19d=moment()[_0x8b13('0x36')](_0x8b13('0x37'));for(var _0x20c363=0x0,_0x28ae75=_0x3f420d[_0x8b13('0x35')];_0x20c363<_0x28ae75;_0x20c363+=0x1){_0x3f420d[_0x20c363]['updateAttributes']({'exitAt':_0x54d19d});}});for(var _0x2df766=0x0;_0x2df766<_0x3eb3c5[_0x8b13('0x23')][_0x8b13('0x30')][_0x50e535][_0x8b13('0x35')];_0x2df766+=0x1){db[_0x8b13('0x33')][_0x8b13('0x38')]({'where':{'channel':_0x50e535,'membername':_0x3eb3c5[_0x8b13('0x31')][_0x8b13('0x12')],'type':_0x8b13('0x39'),'uniqueid':_0x3eb3c5['body'][_0x8b13('0x30')][_0x50e535][_0x2df766],'exitAt':null},'defaults':{'channel':_0x50e535,'membername':_0x3eb3c5['user'][_0x8b13('0x12')],'interface':_[_0x8b13('0x14')](_0x3eb3c5[_0x8b13('0x31')]['interface'])?util[_0x8b13('0x36')](_0x8b13('0x3a'),_0x3eb3c5[_0x8b13('0x31')][_0x8b13('0x12')]):_0x3eb3c5[_0x8b13('0x31')][_0x8b13('0x3b')],'type':_0x8b13('0x39'),'enterAt':moment()['format'](_0x8b13('0x37')),'role':'agent','internal':_0x3eb3c5[_0x8b13('0x31')][_0x8b13('0x3c')],'uniqueid':_0x3eb3c5[_0x8b13('0x23')][_0x8b13('0x30')][_0x50e535][_0x2df766]}});}}}}return respondWithRpcPromise(_0x8b13('0x3d'),{'id':_0x3eb3c5[_0x8b13('0x1b')]['id'],'capacity':_0x3eb3c5[_0x8b13('0x23')][_0x8b13('0x3e')]},routingClient)[_0x8b13('0x19')](respondWithResult(_0x16ec3,null))[_0x8b13('0xe')](handleError(_0x16ec3,null));};exports[_0x8b13('0x3f')]=function(_0xddac8e,_0xd55f3b){return respondWithRpcPromise(_0x8b13('0x40'),_0xddac8e[_0x8b13('0x18')])[_0x8b13('0x19')](respondWithResult(_0xd55f3b,null))[_0x8b13('0xe')](handleError(_0xd55f3b,null));};exports['trunks']=function(_0x1699c6,_0x20e89c){return respondWithRpcPromise('Trunks',_0x1699c6[_0x8b13('0x18')])[_0x8b13('0x19')](respondWithResult(_0x20e89c,null))[_0x8b13('0xe')](handleError(_0x20e89c,null));};exports[_0x8b13('0x41')]=function(_0x25cb45,_0x12549b){return respondWithRpcPromise(_0x8b13('0x42'),_0x25cb45[_0x8b13('0x18')])[_0x8b13('0x19')](respondWithResult(_0x12549b,null))[_0x8b13('0xe')](handleError(_0x12549b,null));};exports[_0x8b13('0x43')]=function(_0x450b47,_0x137e8c){return respondWithRpcPromise(_0x8b13('0x44'),_0x450b47[_0x8b13('0x18')],routingClient)['then'](respondWithResult(_0x137e8c,null))[_0x8b13('0xe')](handleError(_0x137e8c,null));};exports[_0x8b13('0x45')]=function(_0x47a3fa,_0x11e8af){return respondWithRpcPromise(_0x8b13('0x44'),_0x47a3fa[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](findById(_0x47a3fa[_0x8b13('0x1b')]['id']))['then'](respondWithResult(_0x11e8af,null))[_0x8b13('0xe')](handleError(_0x11e8af,null));};exports[_0x8b13('0x46')]=function(_0x46850a,_0x52e2a6){return respondWithRpcPromise(_0x8b13('0x47'),_0x46850a[_0x8b13('0x18')],routingClient)['then'](respondWithResult(_0x52e2a6,null))[_0x8b13('0xe')](handleError(_0x52e2a6,null));};exports[_0x8b13('0x48')]=function(_0x475c8d,_0xd29067){return respondWithRpcPromise('MailQueues',_0x475c8d[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](findById(_0x475c8d['params']['id']))[_0x8b13('0x19')](respondWithResult(_0xd29067,null))[_0x8b13('0xe')](handleError(_0xd29067,null));};exports[_0x8b13('0x49')]=function(_0x23a63c,_0x5d05cb){return respondWithRpcPromise(_0x8b13('0x4a'),_0x23a63c[_0x8b13('0x18')],mailClient)[_0x8b13('0x19')](respondWithResult(_0x5d05cb,null))[_0x8b13('0xe')](handleError(_0x5d05cb,null));};exports[_0x8b13('0x4b')]=function(_0x2fff4e,_0x571e89){return respondWithRpcPromise(_0x8b13('0x4c'),_0x2fff4e[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](respondWithResult(_0x571e89,null))['catch'](handleError(_0x571e89,null));};exports[_0x8b13('0x4d')]=function(_0x576c91,_0x122ea2){return respondWithRpcPromise(_0x8b13('0x4c'),_0x576c91['query'],routingClient)['then'](findById(_0x576c91['params']['id']))['then'](respondWithResult(_0x122ea2,null))['catch'](handleError(_0x122ea2,null));};exports[_0x8b13('0x4e')]=function(_0x1bc936,_0x574f98){return respondWithRpcPromise(_0x8b13('0x4f'),_0x1bc936['query'],routingClient)[_0x8b13('0x19')](respondWithResult(_0x574f98,null))[_0x8b13('0xe')](handleError(_0x574f98,null));};exports[_0x8b13('0x50')]=function(_0x22c4d4,_0x43f12a){return respondWithRpcPromise(_0x8b13('0x4f'),_0x22c4d4[_0x8b13('0x18')],routingClient)['then'](findById(_0x22c4d4[_0x8b13('0x1b')]['id']))['then'](respondWithResult(_0x43f12a,null))[_0x8b13('0xe')](handleError(_0x43f12a,null));};exports[_0x8b13('0x51')]=function(_0x207a54,_0x11a4ba){return respondWithRpcPromise(_0x8b13('0x52'),_0x207a54[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](respondWithResult(_0x11a4ba,null))['catch'](handleError(_0x11a4ba,null));};exports[_0x8b13('0x53')]=function(_0x5d1174,_0x2b109c){return respondWithRpcPromise(_0x8b13('0x52'),_0x5d1174[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](findById(_0x5d1174[_0x8b13('0x1b')]['id']))['then'](respondWithResult(_0x2b109c,null))['catch'](handleError(_0x2b109c,null));};exports[_0x8b13('0x54')]=function(_0x37a243,_0x5ccf4e){return respondWithRpcPromise(_0x8b13('0x55'),_0x37a243[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](respondWithResult(_0x5ccf4e,null))['catch'](handleError(_0x5ccf4e,null));};exports[_0x8b13('0x56')]=function(_0x215a8a,_0x15ce51){return respondWithRpcPromise(_0x8b13('0x55'),_0x215a8a['query'],routingClient)[_0x8b13('0x19')](findById(_0x215a8a[_0x8b13('0x1b')]['id']))['then'](respondWithResult(_0x15ce51,null))[_0x8b13('0xe')](handleError(_0x15ce51,null));};exports[_0x8b13('0x57')]=function(_0x69e237,_0x3734e7){return respondWithRpcPromise(_0x8b13('0x58'),_0x69e237[_0x8b13('0x18')])[_0x8b13('0x19')](respondWithResult(_0x3734e7,null))[_0x8b13('0xe')](handleError(_0x3734e7,null));};exports[_0x8b13('0x59')]=function(_0x2cace0,_0x2f2bc5){return respondWithRpcPromise(_0x8b13('0x5a'),_0x2cace0[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](respondWithResult(_0x2f2bc5,null))['catch'](handleError(_0x2f2bc5,null));};exports[_0x8b13('0x5b')]=function(_0x578469,_0x14dee4){return respondWithRpcPromise(_0x8b13('0x5c'),_0x578469[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](respondWithResult(_0x14dee4,null))['catch'](handleError(_0x14dee4,null));};exports['openchannelQueuesWaitingInteractions']=function(_0x27ad64,_0x2236b5){return respondWithRpcPromise('OpenchannelQueuesWaitingInteractions',_0x27ad64[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](respondWithResult(_0x2236b5,null))[_0x8b13('0xe')](handleError(_0x2236b5,null));};exports[_0x8b13('0x5d')]=function(_0x7499cb,_0x12aa48){return respondWithRpcPromise(_0x8b13('0x5e'),_0x7499cb[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](function(_0x24211c){if(_0x7499cb['query'][_0x8b13('0x5f')]!==undefined){var _0x2e7477=_(_0x24211c['rows'])[_0x8b13('0x60')]([_0x7499cb[_0x8b13('0x18')]['type'],_0x7499cb[_0x8b13('0x1b')]['id']])[_0x8b13('0x61')](_0x8b13('0x62'))[_0x8b13('0x63')]()[_0x8b13('0x64')]();return _0x24211c[_0x8b13('0x15')][_0x8b13('0x60')](function(_0x1fde8b){return _0x2e7477['indexOf'](_0x1fde8b[_0x8b13('0x62')])>-0x1;});}else{return _0x24211c[_0x8b13('0x15')][_0x8b13('0x60')](function(_0x5e2b4c){return _0x5e2b4c[_0x8b13('0x62')]===parseInt(_0x7499cb['params']['id']);});}})[_0x8b13('0x19')](respondWithResult(_0x12aa48,null))[_0x8b13('0xe')](handleError(_0x12aa48,null));};exports[_0x8b13('0x65')]=function(_0x40fefa,_0xc74525){return respondWithRpcPromise(_0x8b13('0x66'),_0x40fefa[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](respondWithResult(_0xc74525,null))[_0x8b13('0xe')](handleError(_0xc74525,null));};exports[_0x8b13('0x67')]=function(_0x595f45,_0x3dc732){return respondWithRpcPromise(_0x8b13('0x68'),_0x595f45[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](respondWithResult(_0x3dc732,null))[_0x8b13('0xe')](handleError(_0x3dc732,null));};exports[_0x8b13('0x69')]=function(_0x2c69f5,_0x9173d){return respondWithRpcPromise(_0x8b13('0x6a'),_0x2c69f5[_0x8b13('0x18')],routingClient)[_0x8b13('0x19')](respondWithResult(_0x9173d,null))[_0x8b13('0xe')](handleError(_0x9173d,null));};exports[_0x8b13('0x6b')]=function(_0x4bb71a){return function(_0x491bf8,_0x3870a9){var _0x512f30,_0x22e10a;var _0x38a1de=_['capitalize'](_0x4bb71a);var _0x5319a1=_0x4bb71a===_0x8b13('0x6c')?_0x8b13('0x6d'):_0x8b13('0x6e');return db[_0x38a1de+_0x8b13('0x6f')][_0x8b13('0x70')]({'raw':!![],'where':{'id':_0x491bf8['params']['id']}})[_0x8b13('0x19')](function(_0x5152d0){if(_[_0x8b13('0x14')](_0x5152d0)){throw new Error(_0x38a1de+_0x8b13('0x71'));}_0x512f30=_0x5152d0;return db[_0x38a1de+'Message'][_0x8b13('0x70')]({'where':{'id':_0x491bf8[_0x8b13('0x23')][_0x8b13('0x72')]},'include':[{'model':db[_0x38a1de+_0x8b13('0x73')],'as':_0x8b13('0x73')},{'model':db[_0x38a1de+_0x5319a1],'as':'Account'}]});})[_0x8b13('0x19')](function(_0x202c12){if(_[_0x8b13('0x14')](_0x202c12)){throw new Error(_0x38a1de+'\x20Message\x20not\x20found');}_0x22e10a=_0x202c12;return _0x202c12[_0x8b13('0x74')]({'read':0x0,'readAt':null,'UserId':null});})['then'](function(){var _0x3bfb06={'uniqueid':_0x4bb71a+'.'+_0x22e10a['id']+'.'+_0x22e10a[_0x8b13('0x73')]['id'],'FromUserId':_0x491bf8[_0x8b13('0x31')]['id'],'type':_0x8b13('0x75')};_0x3bfb06[_0x38a1de+_0x8b13('0x76')]=_0x22e10a['id'];_0x3bfb06[_0x38a1de+_0x8b13('0x77')]=_0x22e10a[_0x8b13('0x73')]['id'];_0x3bfb06[_0x8b13('0x78')+_0x38a1de+_0x5319a1+'Id']=_0x22e10a[_0x8b13('0x6e')]['id'];_0x3bfb06['To'+_0x38a1de+_0x8b13('0x79')]=_0x512f30['id'];return db[_0x38a1de+'TransferReport'][_0x8b13('0x7a')](_0x3bfb06);})[_0x8b13('0x19')](function(){return respondWithRpcPromise(_0x8b13('0x7b'),{'channel':_0x4bb71a,'interaction':_0x22e10a[_0x8b13('0x73')],'message':_0x22e10a,'account':_0x22e10a[_0x8b13('0x6e')],'applications':[{'id':0x0,'priority':0x1,'app':'queue','appdata':_0x512f30[_0x8b13('0x12')]+','+(_0x22e10a[_0x8b13('0x6e')][_0x8b13('0x7c')]||0x12c),'interval':_0x8b13('0x7d')}]},routingClient);})[_0x8b13('0x19')](respondWithResult(_0x3870a9,null))[_0x8b13('0xe')](handleError(_0x3870a9,null));};};exports['agentNotify']=function(_0x24005e,_0xd2b08b){var _0x556a92,_0x1b3a1b;if(_['isNil'](_0x24005e[_0x8b13('0x23')]['channel'])){throw new Error(_0x8b13('0x7e'));}var _0x291a30=_0x24005e[_0x8b13('0x23')][_0x8b13('0x7f')];var _0x13a7ea=_[_0x8b13('0x80')](_0x291a30);var _0x165813=_0x291a30===_0x8b13('0x6c')?'Website':_0x8b13('0x6e');return db[_0x8b13('0x81')]['findOne']({'raw':!![],'where':{'id':_0x24005e[_0x8b13('0x1b')]['id'],'role':_0x8b13('0x82')}})['then'](function(_0xa97f27){if(_[_0x8b13('0x14')](_0xa97f27)){throw new Error(_0x8b13('0x83'));}_0x556a92=_0xa97f27;return db[_0x13a7ea+_0x8b13('0x84')][_0x8b13('0x70')]({'where':{'id':_0x24005e['body']['messageId']},'include':[{'model':db[_0x13a7ea+_0x8b13('0x73')],'as':_0x8b13('0x73')},{'model':db[_0x13a7ea+_0x165813],'as':_0x8b13('0x6e')}]});})[_0x8b13('0x19')](function(_0xcafeff){if(_[_0x8b13('0x14')](_0xcafeff)){throw new Error(_0x13a7ea+_0x8b13('0x85'));}_0x1b3a1b=_0xcafeff;return _0xcafeff[_0x8b13('0x74')]({'read':0x0,'readAt':null,'UserId':null});})[_0x8b13('0x19')](function(){var _0xfac180={'uniqueid':_0x291a30+'.'+_0x1b3a1b['id']+'.'+_0x1b3a1b[_0x8b13('0x73')]['id'],'FromUserId':_0x24005e[_0x8b13('0x31')]['id'],'type':_0x8b13('0x75'),'ToUserId':_0x556a92['id']};_0xfac180[_0x13a7ea+_0x8b13('0x76')]=_0x1b3a1b['id'];_0xfac180[_0x13a7ea+_0x8b13('0x77')]=_0x1b3a1b[_0x8b13('0x73')]['id'];_0xfac180['From'+_0x13a7ea+_0x165813+'Id']=_0x1b3a1b[_0x8b13('0x6e')]['id'];return db[_0x13a7ea+'TransferReport'][_0x8b13('0x7a')](_0xfac180);})[_0x8b13('0x19')](function(){return respondWithRpcPromise(_0x8b13('0x7b'),{'channel':_0x291a30,'interaction':_0x1b3a1b[_0x8b13('0x73')],'message':_0x1b3a1b,'account':_0x1b3a1b[_0x8b13('0x6e')],'applications':[{'id':0x0,'priority':0x1,'app':_0x8b13('0x82'),'appdata':_0x556a92[_0x8b13('0x12')]+','+(_0x1b3a1b['Account'][_0x8b13('0x86')]||0x12c),'interval':'*,*,*,*'}]},routingClient);})[_0x8b13('0x19')](respondWithResult(_0xd2b08b,null))[_0x8b13('0xe')](handleError(_0xd2b08b,null));};
\ No newline at end of file
+var _0x55ca=['ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','MailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','type','filter','map','uniq','value','indexOf','queue_id','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','capitalize','chat','Account','Queue','findOne','\x20Queue\x20not\x20found','messageId','Interaction','update','MessageId','InteractionId','From','QueueId','create','Start','queue','*,*,*,*','agentNotify','channel','Website','User','Agent\x20not\x20found','Message','\x20Message\x20not\x20found','agentTransferTimeout','bluebird','moment','../../config/logger','api','client','http','request','error','code','message','result','catch','stack','name','status','send','isNil','rows','find','voiceChannels','VoiceChannels','query','voiceChannelMixMonitor','merge','then','voiceChannelStopMixMonitor','VoiceQueues','showVoiceQueues','params','updateVoiceQueue','UpdateVoiceQueue','body','voiceQueuesPreview','VoiceQueuesPreview','voiceQueuesChannels','VoiceQueuesChannels','voiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','VoiceQueuesChannelRedirect','outbound','outboundChannels','agents','Agents','agentCapacity','user','interaction','hasOwnProperty','findAll','INTERACTION','length','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','MemberReport','findOrCreate','interface','SIP/%s','agent','internal','AgentCapacity','capacity','telephones','Telephones','Trunks','campaigns','Campaigns','ChatQueues','showChatQueues','MailQueues','showMailQueues','mailAccounts','MailAccounts','openchannelQueues','OpenchannelQueues','smsQueues','SmsQueues','WhatsappQueues','showWhatsappQueues','faxQueues','FaxQueues','showFaxQueues','faxAccounts','FaxAccounts','chatQueuesWaitingInteractions'];(function(_0x394d80,_0x1e6060){var _0x371934=function(_0xc60e1d){while(--_0xc60e1d){_0x394d80['push'](_0x394d80['shift']());}};_0x371934(++_0x1e6060);}(_0x55ca,0x126));var _0xa55c=function(_0x453378,_0x2f360c){_0x453378=_0x453378-0x0;var _0xab3d9e=_0x55ca[_0x453378];return _0xab3d9e;};'use strict';var BPromise=require(_0xa55c('0x0'));var moment=require(_0xa55c('0x1'));var _=require('lodash');var util=require('util');var db=require('../../mysqldb')['db'];var logger=require(_0xa55c('0x2'))(_0xa55c('0x3'));var jayson=require('jayson/promise');var amiClient=jayson[_0xa55c('0x4')][_0xa55c('0x5')]({'port':0x232a});var mailClient=jayson[_0xa55c('0x4')][_0xa55c('0x5')]({'port':0x232b});var routingClient=jayson[_0xa55c('0x4')][_0xa55c('0x5')]({'port':0x232c});function respondWithRpcPromise(_0x36b623,_0x4d0624,_0x2121fd){return new BPromise(function(_0x2537f0,_0x57e069){var _0x291996=_0x2121fd?_0x2121fd:amiClient;return _0x291996[_0xa55c('0x6')](_0x36b623,_0x4d0624)['then'](function(_0x5849ad){if(_0x5849ad[_0xa55c('0x7')]){if(_0x5849ad[_0xa55c('0x7')][_0xa55c('0x8')]===0x1f4){return _0x57e069(_0x5849ad[_0xa55c('0x7')][_0xa55c('0x9')]);}return _0x2537f0(_0x5849ad[_0xa55c('0x7')][_0xa55c('0x9')]);}else{_0x2537f0(_0x5849ad[_0xa55c('0xa')]);}})[_0xa55c('0xb')](function(_0x15eec8){_0x57e069(_0x15eec8);});});}function respondWithResult(_0x5d47ff,_0x59d84a){_0x59d84a=_0x59d84a||0xc8;return function(_0x2a35be){if(_0x2a35be){return _0x5d47ff['status'](_0x59d84a)['json'](_0x2a35be);}return _0x5d47ff['sendStatus'](0x194);};}function handleError(_0x18ee85,_0x3930e4){_0x3930e4=_0x3930e4||0x1f4;return function(_0x462cd6){logger[_0xa55c('0x7')](_0x462cd6[_0xa55c('0xc')]);if(_0x462cd6[_0xa55c('0xd')]){delete _0x462cd6['name'];}_0x18ee85[_0xa55c('0xe')](_0x3930e4)[_0xa55c('0xf')](_0x462cd6);};}function findById(_0x25934f){return function(_0x31e10d){if(!_[_0xa55c('0x10')](_0x25934f)&&!_[_0xa55c('0x10')](_0x31e10d)&&!_[_0xa55c('0x10')](_0x31e10d[_0xa55c('0x11')])){return _[_0xa55c('0x12')](_0x31e10d['rows'],function(_0x3d4c9e){return _0x3d4c9e['id']==_0x25934f;});}return null;};}exports[_0xa55c('0x13')]=function(_0x461284,_0x358b61){return respondWithRpcPromise(_0xa55c('0x14'),_0x461284[_0xa55c('0x15')])['then'](respondWithResult(_0x358b61,null))['catch'](handleError(_0x358b61,null));};exports[_0xa55c('0x16')]=function(_0x3776ac,_0xade4c4){return respondWithRpcPromise('VoiceChannelMixMonitor',_[_0xa55c('0x17')](_0x3776ac[_0xa55c('0x15')],_0x3776ac['params']))[_0xa55c('0x18')](respondWithResult(_0xade4c4,null))[_0xa55c('0xb')](handleError(_0xade4c4,null));};exports[_0xa55c('0x19')]=function(_0x1965f1,_0x234372){return respondWithRpcPromise('VoiceChannelStopMixMonitor',_[_0xa55c('0x17')](_0x1965f1['query'],_0x1965f1['params']))['then'](respondWithResult(_0x234372,null))[_0xa55c('0xb')](handleError(_0x234372,null));};exports['voiceQueues']=function(_0x3ecbe7,_0x190757){return respondWithRpcPromise(_0xa55c('0x1a'),_0x3ecbe7[_0xa55c('0x15')])[_0xa55c('0x18')](respondWithResult(_0x190757,null))[_0xa55c('0xb')](handleError(_0x190757,null));};exports[_0xa55c('0x1b')]=function(_0x11e7f7,_0x192df2){return respondWithRpcPromise(_0xa55c('0x1a'),_0x11e7f7[_0xa55c('0x15')])['then'](findById(_0x11e7f7[_0xa55c('0x1c')]['id']))[_0xa55c('0x18')](respondWithResult(_0x192df2,null))[_0xa55c('0xb')](handleError(_0x192df2,null));};exports[_0xa55c('0x1d')]=function(_0x5d940d,_0x1377b0){return respondWithRpcPromise(_0xa55c('0x1e'),_[_0xa55c('0x17')](_0x5d940d[_0xa55c('0x1f')],_0x5d940d[_0xa55c('0x1c')]))[_0xa55c('0x18')](respondWithResult(_0x1377b0,null))['catch'](handleError(_0x1377b0,null));};exports[_0xa55c('0x20')]=function(_0x490b7d,_0x35c9c2){return respondWithRpcPromise(_0xa55c('0x21'),_[_0xa55c('0x17')](_0x490b7d[_0xa55c('0x15')],_0x490b7d['params']))[_0xa55c('0x18')](respondWithResult(_0x35c9c2,null))[_0xa55c('0xb')](handleError(_0x35c9c2,null));};exports[_0xa55c('0x22')]=function(_0x20da31,_0x10f4b7){return respondWithRpcPromise(_0xa55c('0x23'),_0x20da31[_0xa55c('0x15')])[_0xa55c('0x18')](respondWithResult(_0x10f4b7,null))[_0xa55c('0xb')](handleError(_0x10f4b7,null));};exports[_0xa55c('0x24')]=function(_0x197099,_0x4eb7c4){return respondWithRpcPromise('VoiceQueuesChannel',_[_0xa55c('0x17')](_0x197099[_0xa55c('0x15')],_0x197099['params']))[_0xa55c('0x18')](respondWithResult(_0x4eb7c4,null))[_0xa55c('0xb')](handleError(_0x4eb7c4,null));};exports[_0xa55c('0x25')]=function(_0x1839ac,_0x30d4f8){return respondWithRpcPromise(_0xa55c('0x26'),_[_0xa55c('0x17')](_0x1839ac[_0xa55c('0x15')],_0x1839ac[_0xa55c('0x1c')]))['then'](respondWithResult(_0x30d4f8,null))['catch'](handleError(_0x30d4f8,null));};exports['voiceQueuesChannelRedirect']=function(_0x3fd75f,_0x18e00e){return respondWithRpcPromise(_0xa55c('0x27'),_['merge'](_0x3fd75f[_0xa55c('0x15')],_0x3fd75f['params']))[_0xa55c('0x18')](respondWithResult(_0x18e00e,null))['catch'](handleError(_0x18e00e,null));};exports[_0xa55c('0x28')]=function(_0x39267c,_0x3c0ec1){return respondWithRpcPromise('Outbound',_0x39267c[_0xa55c('0x15')])[_0xa55c('0x18')](respondWithResult(_0x3c0ec1,null))['catch'](handleError(_0x3c0ec1,null));};exports[_0xa55c('0x29')]=function(_0x194e78,_0x4d9083){return respondWithRpcPromise('OutboundChannels',_0x194e78[_0xa55c('0x15')])['then'](respondWithResult(_0x4d9083,null))[_0xa55c('0xb')](handleError(_0x4d9083,null));};exports[_0xa55c('0x2a')]=function(_0x5427bf,_0x542d76){var _0x5e50b6;return respondWithRpcPromise('Agents',_0x5427bf[_0xa55c('0x15')])[_0xa55c('0x18')](function(_0x429336){_0x5e50b6=_0x429336;return respondWithRpcPromise(_0xa55c('0x2b'),_0x5427bf[_0xa55c('0x15')],routingClient);})['then'](function(_0x3d52d8){return _[_0xa55c('0x17')]({},_0x3d52d8,_0x5e50b6);})[_0xa55c('0x18')](respondWithResult(_0x542d76,null))[_0xa55c('0xb')](handleError(_0x542d76,null));};exports[_0xa55c('0x2c')]=function(_0x23cef5,_0x554620){if(_0x23cef5[_0xa55c('0x1f')]&&_0x23cef5['body']['interaction']&&_0x23cef5[_0xa55c('0x2d')]&&_0x23cef5[_0xa55c('0x2d')]['name']){for(var _0x2bd98b in _0x23cef5['body']['interaction']){if(_0x23cef5[_0xa55c('0x1f')][_0xa55c('0x2e')][_0xa55c('0x2f')](_0x2bd98b)){db['MemberReport'][_0xa55c('0x30')]({'where':{'channel':_0x2bd98b,'membername':_0x23cef5[_0xa55c('0x2d')]['name'],'type':_0xa55c('0x31'),'exitAt':null,'uniqueid':_0x23cef5['body'][_0xa55c('0x2e')][_0x2bd98b]&&_0x23cef5[_0xa55c('0x1f')]['interaction'][_0x2bd98b][_0xa55c('0x32')]?{'$notIn':_0x23cef5[_0xa55c('0x1f')]['interaction'][_0x2bd98b]}:{'$ne':null}}})[_0xa55c('0x18')](function(_0x187e09){var _0x204767=moment()['format'](_0xa55c('0x33'));for(var _0x582901=0x0,_0x2f9717=_0x187e09[_0xa55c('0x32')];_0x582901<_0x2f9717;_0x582901+=0x1){_0x187e09[_0x582901][_0xa55c('0x34')]({'exitAt':_0x204767});}});for(var _0x51d663=0x0;_0x51d663<_0x23cef5[_0xa55c('0x1f')][_0xa55c('0x2e')][_0x2bd98b]['length'];_0x51d663+=0x1){db[_0xa55c('0x35')][_0xa55c('0x36')]({'where':{'channel':_0x2bd98b,'membername':_0x23cef5['user'][_0xa55c('0xd')],'type':_0xa55c('0x31'),'uniqueid':_0x23cef5['body'][_0xa55c('0x2e')][_0x2bd98b][_0x51d663],'exitAt':null},'defaults':{'channel':_0x2bd98b,'membername':_0x23cef5[_0xa55c('0x2d')][_0xa55c('0xd')],'interface':_[_0xa55c('0x10')](_0x23cef5['user'][_0xa55c('0x37')])?util['format'](_0xa55c('0x38'),_0x23cef5[_0xa55c('0x2d')][_0xa55c('0xd')]):_0x23cef5['user'][_0xa55c('0x37')],'type':_0xa55c('0x31'),'enterAt':moment()['format'](_0xa55c('0x33')),'role':_0xa55c('0x39'),'internal':_0x23cef5[_0xa55c('0x2d')][_0xa55c('0x3a')],'uniqueid':_0x23cef5[_0xa55c('0x1f')][_0xa55c('0x2e')][_0x2bd98b][_0x51d663]}});}}}}return respondWithRpcPromise(_0xa55c('0x3b'),{'id':_0x23cef5[_0xa55c('0x1c')]['id'],'capacity':_0x23cef5[_0xa55c('0x1f')][_0xa55c('0x3c')]},routingClient)['then'](respondWithResult(_0x554620,null))[_0xa55c('0xb')](handleError(_0x554620,null));};exports[_0xa55c('0x3d')]=function(_0x216de8,_0x4f73b6){return respondWithRpcPromise(_0xa55c('0x3e'),_0x216de8[_0xa55c('0x15')])['then'](respondWithResult(_0x4f73b6,null))[_0xa55c('0xb')](handleError(_0x4f73b6,null));};exports['trunks']=function(_0x2b6a0e,_0x228df4){return respondWithRpcPromise(_0xa55c('0x3f'),_0x2b6a0e[_0xa55c('0x15')])[_0xa55c('0x18')](respondWithResult(_0x228df4,null))['catch'](handleError(_0x228df4,null));};exports[_0xa55c('0x40')]=function(_0x4607ca,_0x4b85cc){return respondWithRpcPromise(_0xa55c('0x41'),_0x4607ca[_0xa55c('0x15')])[_0xa55c('0x18')](respondWithResult(_0x4b85cc,null))[_0xa55c('0xb')](handleError(_0x4b85cc,null));};exports['chatQueues']=function(_0x4def35,_0x267965){return respondWithRpcPromise(_0xa55c('0x42'),_0x4def35[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](respondWithResult(_0x267965,null))['catch'](handleError(_0x267965,null));};exports[_0xa55c('0x43')]=function(_0x5ce463,_0x2742e4){return respondWithRpcPromise(_0xa55c('0x42'),_0x5ce463[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](findById(_0x5ce463[_0xa55c('0x1c')]['id']))['then'](respondWithResult(_0x2742e4,null))[_0xa55c('0xb')](handleError(_0x2742e4,null));};exports['mailQueues']=function(_0x23f67f,_0x157afe){return respondWithRpcPromise(_0xa55c('0x44'),_0x23f67f[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](respondWithResult(_0x157afe,null))[_0xa55c('0xb')](handleError(_0x157afe,null));};exports[_0xa55c('0x45')]=function(_0x53e2be,_0x450567){return respondWithRpcPromise(_0xa55c('0x44'),_0x53e2be[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](findById(_0x53e2be[_0xa55c('0x1c')]['id']))['then'](respondWithResult(_0x450567,null))[_0xa55c('0xb')](handleError(_0x450567,null));};exports[_0xa55c('0x46')]=function(_0x28bac4,_0x20e53c){return respondWithRpcPromise(_0xa55c('0x47'),_0x28bac4['query'],mailClient)[_0xa55c('0x18')](respondWithResult(_0x20e53c,null))[_0xa55c('0xb')](handleError(_0x20e53c,null));};exports[_0xa55c('0x48')]=function(_0x16d9b2,_0x3ba56d){return respondWithRpcPromise('OpenchannelQueues',_0x16d9b2[_0xa55c('0x15')],routingClient)['then'](respondWithResult(_0x3ba56d,null))[_0xa55c('0xb')](handleError(_0x3ba56d,null));};exports['showOpenchannelQueues']=function(_0x3495a7,_0x5a8897){return respondWithRpcPromise(_0xa55c('0x49'),_0x3495a7[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](findById(_0x3495a7[_0xa55c('0x1c')]['id']))[_0xa55c('0x18')](respondWithResult(_0x5a8897,null))[_0xa55c('0xb')](handleError(_0x5a8897,null));};exports[_0xa55c('0x4a')]=function(_0x2f2226,_0x14b515){return respondWithRpcPromise(_0xa55c('0x4b'),_0x2f2226['query'],routingClient)[_0xa55c('0x18')](respondWithResult(_0x14b515,null))[_0xa55c('0xb')](handleError(_0x14b515,null));};exports['showSmsQueues']=function(_0x18b928,_0x2b8b88){return respondWithRpcPromise(_0xa55c('0x4b'),_0x18b928[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](findById(_0x18b928[_0xa55c('0x1c')]['id']))[_0xa55c('0x18')](respondWithResult(_0x2b8b88,null))[_0xa55c('0xb')](handleError(_0x2b8b88,null));};exports['whatsappQueues']=function(_0x1dfaf7,_0x475131){return respondWithRpcPromise(_0xa55c('0x4c'),_0x1dfaf7[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](respondWithResult(_0x475131,null))[_0xa55c('0xb')](handleError(_0x475131,null));};exports[_0xa55c('0x4d')]=function(_0x4249c1,_0x25d5a1){return respondWithRpcPromise('WhatsappQueues',_0x4249c1[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](findById(_0x4249c1[_0xa55c('0x1c')]['id']))[_0xa55c('0x18')](respondWithResult(_0x25d5a1,null))[_0xa55c('0xb')](handleError(_0x25d5a1,null));};exports[_0xa55c('0x4e')]=function(_0x3ea755,_0x3606b2){return respondWithRpcPromise(_0xa55c('0x4f'),_0x3ea755[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](respondWithResult(_0x3606b2,null))['catch'](handleError(_0x3606b2,null));};exports[_0xa55c('0x50')]=function(_0x531eee,_0x1228a4){return respondWithRpcPromise(_0xa55c('0x4f'),_0x531eee[_0xa55c('0x15')],routingClient)['then'](findById(_0x531eee['params']['id']))[_0xa55c('0x18')](respondWithResult(_0x1228a4,null))[_0xa55c('0xb')](handleError(_0x1228a4,null));};exports[_0xa55c('0x51')]=function(_0x42529f,_0x4c7ee1){return respondWithRpcPromise(_0xa55c('0x52'),_0x42529f[_0xa55c('0x15')])[_0xa55c('0x18')](respondWithResult(_0x4c7ee1,null))[_0xa55c('0xb')](handleError(_0x4c7ee1,null));};exports[_0xa55c('0x53')]=function(_0x500968,_0x4b090c){return respondWithRpcPromise(_0xa55c('0x54'),_0x500968[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](respondWithResult(_0x4b090c,null))[_0xa55c('0xb')](handleError(_0x4b090c,null));};exports[_0xa55c('0x55')]=function(_0x4b2032,_0x14febc){return respondWithRpcPromise(_0xa55c('0x56'),_0x4b2032['query'],routingClient)[_0xa55c('0x18')](respondWithResult(_0x14febc,null))[_0xa55c('0xb')](handleError(_0x14febc,null));};exports[_0xa55c('0x57')]=function(_0x4dcb93,_0x1521d5){return respondWithRpcPromise(_0xa55c('0x58'),_0x4dcb93[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](respondWithResult(_0x1521d5,null))[_0xa55c('0xb')](handleError(_0x1521d5,null));};exports['openchannelQueuesIdWaitingInteractions']=function(_0x25bd5b,_0x2e2cf6){return respondWithRpcPromise('OpenchannelQueuesWaitingInteractions',_0x25bd5b['query'],routingClient)[_0xa55c('0x18')](function(_0x4e1cbd){if(_0x25bd5b[_0xa55c('0x15')][_0xa55c('0x59')]!==undefined){var _0x2f13db=_(_0x4e1cbd[_0xa55c('0x11')])[_0xa55c('0x5a')]([_0x25bd5b[_0xa55c('0x15')][_0xa55c('0x59')],_0x25bd5b[_0xa55c('0x1c')]['id']])[_0xa55c('0x5b')]('queue_id')[_0xa55c('0x5c')]()[_0xa55c('0x5d')]();return _0x4e1cbd[_0xa55c('0x11')][_0xa55c('0x5a')](function(_0x4f0a26){return _0x2f13db[_0xa55c('0x5e')](_0x4f0a26[_0xa55c('0x5f')])>-0x1;});}else{return _0x4e1cbd[_0xa55c('0x11')][_0xa55c('0x5a')](function(_0x5d766e){return _0x5d766e['queue_id']===parseInt(_0x25bd5b[_0xa55c('0x1c')]['id']);});}})[_0xa55c('0x18')](respondWithResult(_0x2e2cf6,null))[_0xa55c('0xb')](handleError(_0x2e2cf6,null));};exports[_0xa55c('0x60')]=function(_0x5e87cb,_0x55ee0d){return respondWithRpcPromise(_0xa55c('0x61'),_0x5e87cb[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](respondWithResult(_0x55ee0d,null))[_0xa55c('0xb')](handleError(_0x55ee0d,null));};exports[_0xa55c('0x62')]=function(_0x346060,_0x239269){return respondWithRpcPromise('WhatsappQueuesWaitingInteractions',_0x346060[_0xa55c('0x15')],routingClient)['then'](respondWithResult(_0x239269,null))[_0xa55c('0xb')](handleError(_0x239269,null));};exports['faxQueuesWaitingInteractions']=function(_0x36ded7,_0x313cdc){return respondWithRpcPromise(_0xa55c('0x63'),_0x36ded7[_0xa55c('0x15')],routingClient)[_0xa55c('0x18')](respondWithResult(_0x313cdc,null))[_0xa55c('0xb')](handleError(_0x313cdc,null));};exports[_0xa55c('0x64')]=function(_0x2c71ca){return function(_0x576a1b,_0x59414d){var _0x14cb74,_0x2948b1;var _0xc2ad5c=_[_0xa55c('0x65')](_0x2c71ca);var _0x1622cb=_0x2c71ca===_0xa55c('0x66')?'Website':_0xa55c('0x67');return db[_0xc2ad5c+_0xa55c('0x68')][_0xa55c('0x69')]({'raw':!![],'where':{'id':_0x576a1b[_0xa55c('0x1c')]['id']}})[_0xa55c('0x18')](function(_0x3b1cd7){if(_[_0xa55c('0x10')](_0x3b1cd7)){throw new Error(_0xc2ad5c+_0xa55c('0x6a'));}_0x14cb74=_0x3b1cd7;return db[_0xc2ad5c+'Message'][_0xa55c('0x69')]({'where':{'id':_0x576a1b[_0xa55c('0x1f')][_0xa55c('0x6b')]},'include':[{'model':db[_0xc2ad5c+_0xa55c('0x6c')],'as':_0xa55c('0x6c')},{'model':db[_0xc2ad5c+_0x1622cb],'as':'Account'}]});})[_0xa55c('0x18')](function(_0x2ab1f2){if(_['isNil'](_0x2ab1f2)){throw new Error(_0xc2ad5c+'\x20Message\x20not\x20found');}_0x2948b1=_0x2ab1f2;return _0x2ab1f2[_0xa55c('0x6d')]({'read':0x0,'readAt':null,'UserId':null});})[_0xa55c('0x18')](function(){var _0x5c2229={'uniqueid':_0x2c71ca+'.'+_0x2948b1['id']+'.'+_0x2948b1['Interaction']['id'],'FromUserId':_0x576a1b['user']['id'],'type':'queue'};_0x5c2229[_0xc2ad5c+_0xa55c('0x6e')]=_0x2948b1['id'];_0x5c2229[_0xc2ad5c+_0xa55c('0x6f')]=_0x2948b1[_0xa55c('0x6c')]['id'];_0x5c2229[_0xa55c('0x70')+_0xc2ad5c+_0x1622cb+'Id']=_0x2948b1[_0xa55c('0x67')]['id'];_0x5c2229['To'+_0xc2ad5c+_0xa55c('0x71')]=_0x14cb74['id'];return db[_0xc2ad5c+'TransferReport'][_0xa55c('0x72')](_0x5c2229);})[_0xa55c('0x18')](function(){return respondWithRpcPromise(_0xa55c('0x73'),{'channel':_0x2c71ca,'interaction':_0x2948b1[_0xa55c('0x6c')],'message':_0x2948b1,'account':_0x2948b1['Account'],'applications':[{'id':0x0,'priority':0x1,'app':_0xa55c('0x74'),'appdata':_0x14cb74[_0xa55c('0xd')]+','+(_0x2948b1[_0xa55c('0x67')]['queueTransferTimeout']||0x12c),'interval':_0xa55c('0x75')}]},routingClient);})['then'](respondWithResult(_0x59414d,null))['catch'](handleError(_0x59414d,null));};};exports[_0xa55c('0x76')]=function(_0x413b45,_0x1e298d){var _0x249b0c,_0x2544c1;if(_[_0xa55c('0x10')](_0x413b45[_0xa55c('0x1f')]['channel'])){throw new Error('Channel\x20field\x20is\x20mandatory');}var _0x71bd0d=_0x413b45[_0xa55c('0x1f')][_0xa55c('0x77')];var _0x1f4bc8=_[_0xa55c('0x65')](_0x71bd0d);var _0x2a0805=_0x71bd0d===_0xa55c('0x66')?_0xa55c('0x78'):_0xa55c('0x67');return db[_0xa55c('0x79')]['findOne']({'raw':!![],'where':{'id':_0x413b45[_0xa55c('0x1c')]['id'],'role':_0xa55c('0x39')}})['then'](function(_0xb9708){if(_['isNil'](_0xb9708)){throw new Error(_0xa55c('0x7a'));}_0x249b0c=_0xb9708;return db[_0x1f4bc8+_0xa55c('0x7b')][_0xa55c('0x69')]({'where':{'id':_0x413b45[_0xa55c('0x1f')][_0xa55c('0x6b')]},'include':[{'model':db[_0x1f4bc8+'Interaction'],'as':_0xa55c('0x6c')},{'model':db[_0x1f4bc8+_0x2a0805],'as':_0xa55c('0x67')}]});})[_0xa55c('0x18')](function(_0x376c1f){if(_[_0xa55c('0x10')](_0x376c1f)){throw new Error(_0x1f4bc8+_0xa55c('0x7c'));}_0x2544c1=_0x376c1f;return _0x376c1f[_0xa55c('0x6d')]({'read':0x0,'readAt':null,'UserId':null});})['then'](function(){var _0x49a307={'uniqueid':_0x71bd0d+'.'+_0x2544c1['id']+'.'+_0x2544c1['Interaction']['id'],'FromUserId':_0x413b45[_0xa55c('0x2d')]['id'],'type':'queue','ToUserId':_0x249b0c['id']};_0x49a307[_0x1f4bc8+_0xa55c('0x6e')]=_0x2544c1['id'];_0x49a307[_0x1f4bc8+_0xa55c('0x6f')]=_0x2544c1[_0xa55c('0x6c')]['id'];_0x49a307[_0xa55c('0x70')+_0x1f4bc8+_0x2a0805+'Id']=_0x2544c1[_0xa55c('0x67')]['id'];return db[_0x1f4bc8+'TransferReport'][_0xa55c('0x72')](_0x49a307);})['then'](function(){return respondWithRpcPromise(_0xa55c('0x73'),{'channel':_0x71bd0d,'interaction':_0x2544c1[_0xa55c('0x6c')],'message':_0x2544c1,'account':_0x2544c1[_0xa55c('0x67')],'applications':[{'id':0x0,'priority':0x1,'app':_0xa55c('0x39'),'appdata':_0x249b0c['name']+','+(_0x2544c1[_0xa55c('0x67')][_0xa55c('0x7d')]||0x12c),'interval':_0xa55c('0x75')}]},routingClient);})[_0xa55c('0x18')](respondWithResult(_0x1e298d,null))[_0xa55c('0xb')](handleError(_0x1e298d,null));};
\ No newline at end of file