Built motion from commit (unavailable).|2.5.1
[motion2.git] / server / api / rpc / rpc.controller.js
index 4da21e9..e2dbeb4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9434=['faxQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','capitalize','Website','Account','Queue','findOne','\x20Queue\x20not\x20found','messageId','Interaction','update','queue','From','QueueId','TransferReport','create','Start','queueTransferTimeout','agentNotify','channel','Channel\x20field\x20is\x20mandatory','chat','Agent\x20not\x20found','Message','\x20Message\x20not\x20found','MessageId','InteractionId','bluebird','moment','util','../../mysqldb','api','jayson/promise','http','client','request','then','error','code','message','result','status','json','sendStatus','stack','name','send','isNil','rows','find','voiceChannels','VoiceChannels','query','catch','voiceChannelMixMonitor','VoiceChannelMixMonitor','params','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','merge','voiceQueues','VoiceQueues','voiceQueuesPreview','VoiceQueuesPreview','VoiceQueuesChannels','voiceQueuesChannel','VoiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','outbound','OutboundChannels','agents','Agents','body','interaction','user','hasOwnProperty','MemberReport','findAll','INTERACTION','length','format','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','findOrCreate','interface','agent','internal','AgentCapacity','capacity','Telephones','Trunks','chatQueues','ChatQueues','showChatQueues','mailQueues','MailQueues','showMailQueues','mailAccounts','MailAccounts','openchannelQueues','OpenchannelQueues','showOpenchannelQueues','SmsQueues','showSmsQueues','WhatsappQueues','faxQueues','FaxQueues','showFaxQueues','faxAccounts','FaxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','openchannelQueuesIdWaitingInteractions','filter','queue_id','value','indexOf','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','WhatsappQueuesWaitingInteractions'];(function(_0x2665f4,_0x47efa4){var _0x2d0727=function(_0x4ee532){while(--_0x4ee532){_0x2665f4['push'](_0x2665f4['shift']());}};_0x2d0727(++_0x47efa4);}(_0x9434,0x193));var _0x4943=function(_0x79dfe0,_0x3d428a){_0x79dfe0=_0x79dfe0-0x0;var _0x5d36e0=_0x9434[_0x79dfe0];return _0x5d36e0;};'use strict';var BPromise=require(_0x4943('0x0'));var moment=require(_0x4943('0x1'));var _=require('lodash');var util=require(_0x4943('0x2'));var db=require(_0x4943('0x3'))['db'];var logger=require('../../config/logger')(_0x4943('0x4'));var jayson=require(_0x4943('0x5'));var amiClient=jayson['client'][_0x4943('0x6')]({'port':0x232a});var mailClient=jayson[_0x4943('0x7')]['http']({'port':0x232b});var routingClient=jayson[_0x4943('0x7')][_0x4943('0x6')]({'port':0x232c});function respondWithRpcPromise(_0x220c89,_0x5a4563,_0x1f0eca){return new BPromise(function(_0x5903b5,_0x1c6d91){var _0x4a7d86=_0x1f0eca?_0x1f0eca:amiClient;return _0x4a7d86[_0x4943('0x8')](_0x220c89,_0x5a4563)[_0x4943('0x9')](function(_0x35411f){if(_0x35411f[_0x4943('0xa')]){if(_0x35411f[_0x4943('0xa')][_0x4943('0xb')]===0x1f4){return _0x1c6d91(_0x35411f[_0x4943('0xa')][_0x4943('0xc')]);}return _0x5903b5(_0x35411f[_0x4943('0xa')][_0x4943('0xc')]);}else{_0x5903b5(_0x35411f[_0x4943('0xd')]);}})['catch'](function(_0x5c6d2a){_0x1c6d91(_0x5c6d2a);});});}function respondWithResult(_0x4ab16f,_0x32f4fe){_0x32f4fe=_0x32f4fe||0xc8;return function(_0x5d8b11){if(_0x5d8b11){return _0x4ab16f[_0x4943('0xe')](_0x32f4fe)[_0x4943('0xf')](_0x5d8b11);}return _0x4ab16f[_0x4943('0x10')](0x194);};}function handleError(_0x370c2b,_0x50dbed){_0x50dbed=_0x50dbed||0x1f4;return function(_0x46bc7a){logger[_0x4943('0xa')](_0x46bc7a[_0x4943('0x11')]);if(_0x46bc7a[_0x4943('0x12')]){delete _0x46bc7a['name'];}_0x370c2b[_0x4943('0xe')](_0x50dbed)[_0x4943('0x13')](_0x46bc7a);};}function findById(_0x5aa35e){return function(_0x30fd96){if(!_['isNil'](_0x5aa35e)&&!_[_0x4943('0x14')](_0x30fd96)&&!_['isNil'](_0x30fd96[_0x4943('0x15')])){return _[_0x4943('0x16')](_0x30fd96[_0x4943('0x15')],function(_0x2f29b5){return _0x2f29b5['id']==_0x5aa35e;});}return null;};}exports[_0x4943('0x17')]=function(_0x11969f,_0x162a4f){return respondWithRpcPromise(_0x4943('0x18'),_0x11969f[_0x4943('0x19')])[_0x4943('0x9')](respondWithResult(_0x162a4f,null))[_0x4943('0x1a')](handleError(_0x162a4f,null));};exports[_0x4943('0x1b')]=function(_0x59e965,_0xf20192){return respondWithRpcPromise(_0x4943('0x1c'),_['merge'](_0x59e965[_0x4943('0x19')],_0x59e965[_0x4943('0x1d')]))['then'](respondWithResult(_0xf20192,null))['catch'](handleError(_0xf20192,null));};exports[_0x4943('0x1e')]=function(_0x461d65,_0x594f55){return respondWithRpcPromise(_0x4943('0x1f'),_[_0x4943('0x20')](_0x461d65[_0x4943('0x19')],_0x461d65[_0x4943('0x1d')]))['then'](respondWithResult(_0x594f55,null))[_0x4943('0x1a')](handleError(_0x594f55,null));};exports[_0x4943('0x21')]=function(_0x29b1f9,_0x5b11cb){return respondWithRpcPromise(_0x4943('0x22'),_0x29b1f9['query'])[_0x4943('0x9')](respondWithResult(_0x5b11cb,null))[_0x4943('0x1a')](handleError(_0x5b11cb,null));};exports['showVoiceQueues']=function(_0xf1521b,_0x5415fa){return respondWithRpcPromise(_0x4943('0x22'),_0xf1521b['query'])[_0x4943('0x9')](findById(_0xf1521b[_0x4943('0x1d')]['id']))[_0x4943('0x9')](respondWithResult(_0x5415fa,null))[_0x4943('0x1a')](handleError(_0x5415fa,null));};exports[_0x4943('0x23')]=function(_0x596b19,_0x35ec73){return respondWithRpcPromise(_0x4943('0x24'),_[_0x4943('0x20')](_0x596b19['query'],_0x596b19[_0x4943('0x1d')]))[_0x4943('0x9')](respondWithResult(_0x35ec73,null))[_0x4943('0x1a')](handleError(_0x35ec73,null));};exports['voiceQueuesChannels']=function(_0x1a1377,_0x19ad61){return respondWithRpcPromise(_0x4943('0x25'),_0x1a1377[_0x4943('0x19')])[_0x4943('0x9')](respondWithResult(_0x19ad61,null))[_0x4943('0x1a')](handleError(_0x19ad61,null));};exports[_0x4943('0x26')]=function(_0x424f91,_0x3d4930){return respondWithRpcPromise(_0x4943('0x27'),_['merge'](_0x424f91[_0x4943('0x19')],_0x424f91['params']))[_0x4943('0x9')](respondWithResult(_0x3d4930,null))[_0x4943('0x1a')](handleError(_0x3d4930,null));};exports[_0x4943('0x28')]=function(_0x4a42b0,_0x2fa436){return respondWithRpcPromise(_0x4943('0x29'),_[_0x4943('0x20')](_0x4a42b0[_0x4943('0x19')],_0x4a42b0['params']))[_0x4943('0x9')](respondWithResult(_0x2fa436,null))[_0x4943('0x1a')](handleError(_0x2fa436,null));};exports['voiceQueuesChannelRedirect']=function(_0x5566d6,_0x41dbed){return respondWithRpcPromise('VoiceQueuesChannelRedirect',_[_0x4943('0x20')](_0x5566d6[_0x4943('0x19')],_0x5566d6[_0x4943('0x1d')]))[_0x4943('0x9')](respondWithResult(_0x41dbed,null))[_0x4943('0x1a')](handleError(_0x41dbed,null));};exports[_0x4943('0x2a')]=function(_0xac773e,_0x1badd8){return respondWithRpcPromise('Outbound',_0xac773e['query'])[_0x4943('0x9')](respondWithResult(_0x1badd8,null))[_0x4943('0x1a')](handleError(_0x1badd8,null));};exports['outboundChannels']=function(_0x2b4bb3,_0x3dd3f9){return respondWithRpcPromise(_0x4943('0x2b'),_0x2b4bb3[_0x4943('0x19')])[_0x4943('0x9')](respondWithResult(_0x3dd3f9,null))[_0x4943('0x1a')](handleError(_0x3dd3f9,null));};exports[_0x4943('0x2c')]=function(_0x5d1dca,_0xa8f97e){var _0xa3758e;return respondWithRpcPromise('Agents',_0x5d1dca[_0x4943('0x19')])['then'](function(_0x5643fb){_0xa3758e=_0x5643fb;return respondWithRpcPromise(_0x4943('0x2d'),_0x5d1dca['query'],routingClient);})['then'](function(_0x44b6aa){return _[_0x4943('0x20')]({},_0x44b6aa,_0xa3758e);})[_0x4943('0x9')](respondWithResult(_0xa8f97e,null))[_0x4943('0x1a')](handleError(_0xa8f97e,null));};exports['agentCapacity']=function(_0x548ec7,_0xda9617){if(_0x548ec7[_0x4943('0x2e')]&&_0x548ec7[_0x4943('0x2e')][_0x4943('0x2f')]&&_0x548ec7[_0x4943('0x30')]&&_0x548ec7[_0x4943('0x30')][_0x4943('0x12')]){for(var _0x113d93 in _0x548ec7['body'][_0x4943('0x2f')]){if(_0x548ec7[_0x4943('0x2e')][_0x4943('0x2f')][_0x4943('0x31')](_0x113d93)){db[_0x4943('0x32')][_0x4943('0x33')]({'where':{'channel':_0x113d93,'membername':_0x548ec7[_0x4943('0x30')][_0x4943('0x12')],'type':_0x4943('0x34'),'exitAt':null,'uniqueid':_0x548ec7[_0x4943('0x2e')][_0x4943('0x2f')][_0x113d93]&&_0x548ec7[_0x4943('0x2e')][_0x4943('0x2f')][_0x113d93][_0x4943('0x35')]?{'$notIn':_0x548ec7[_0x4943('0x2e')][_0x4943('0x2f')][_0x113d93]}:{'$ne':null}}})[_0x4943('0x9')](function(_0x33383b){var _0x53d31d=moment()[_0x4943('0x36')](_0x4943('0x37'));for(var _0x162dd9=0x0,_0x5c3ec2=_0x33383b[_0x4943('0x35')];_0x162dd9<_0x5c3ec2;_0x162dd9+=0x1){_0x33383b[_0x162dd9][_0x4943('0x38')]({'exitAt':_0x53d31d});}});for(var _0x5c5471=0x0;_0x5c5471<_0x548ec7[_0x4943('0x2e')][_0x4943('0x2f')][_0x113d93][_0x4943('0x35')];_0x5c5471+=0x1){db['MemberReport'][_0x4943('0x39')]({'where':{'channel':_0x113d93,'membername':_0x548ec7[_0x4943('0x30')][_0x4943('0x12')],'type':'INTERACTION','uniqueid':_0x548ec7['body']['interaction'][_0x113d93][_0x5c5471],'exitAt':null},'defaults':{'channel':_0x113d93,'membername':_0x548ec7[_0x4943('0x30')][_0x4943('0x12')],'interface':_[_0x4943('0x14')](_0x548ec7['user']['interface'])?util[_0x4943('0x36')]('SIP/%s',_0x548ec7[_0x4943('0x30')][_0x4943('0x12')]):_0x548ec7[_0x4943('0x30')][_0x4943('0x3a')],'type':'INTERACTION','enterAt':moment()[_0x4943('0x36')](_0x4943('0x37')),'role':_0x4943('0x3b'),'internal':_0x548ec7[_0x4943('0x30')][_0x4943('0x3c')],'uniqueid':_0x548ec7[_0x4943('0x2e')][_0x4943('0x2f')][_0x113d93][_0x5c5471]}});}}}}return respondWithRpcPromise(_0x4943('0x3d'),{'id':_0x548ec7[_0x4943('0x1d')]['id'],'capacity':_0x548ec7[_0x4943('0x2e')][_0x4943('0x3e')]},routingClient)[_0x4943('0x9')](respondWithResult(_0xda9617,null))[_0x4943('0x1a')](handleError(_0xda9617,null));};exports['telephones']=function(_0x62e9fa,_0x2de439){return respondWithRpcPromise(_0x4943('0x3f'),_0x62e9fa[_0x4943('0x19')])[_0x4943('0x9')](respondWithResult(_0x2de439,null))['catch'](handleError(_0x2de439,null));};exports['trunks']=function(_0x1c5060,_0x1558c7){return respondWithRpcPromise(_0x4943('0x40'),_0x1c5060[_0x4943('0x19')])['then'](respondWithResult(_0x1558c7,null))[_0x4943('0x1a')](handleError(_0x1558c7,null));};exports['campaigns']=function(_0x13291b,_0x3e9f5f){return respondWithRpcPromise('Campaigns',_0x13291b['query'])['then'](respondWithResult(_0x3e9f5f,null))[_0x4943('0x1a')](handleError(_0x3e9f5f,null));};exports[_0x4943('0x41')]=function(_0x2ff162,_0x443853){return respondWithRpcPromise(_0x4943('0x42'),_0x2ff162[_0x4943('0x19')],routingClient)[_0x4943('0x9')](respondWithResult(_0x443853,null))[_0x4943('0x1a')](handleError(_0x443853,null));};exports[_0x4943('0x43')]=function(_0x49daec,_0x1bc049){return respondWithRpcPromise(_0x4943('0x42'),_0x49daec[_0x4943('0x19')],routingClient)[_0x4943('0x9')](findById(_0x49daec[_0x4943('0x1d')]['id']))[_0x4943('0x9')](respondWithResult(_0x1bc049,null))['catch'](handleError(_0x1bc049,null));};exports[_0x4943('0x44')]=function(_0x113530,_0x1b2b0e){return respondWithRpcPromise(_0x4943('0x45'),_0x113530['query'],routingClient)[_0x4943('0x9')](respondWithResult(_0x1b2b0e,null))[_0x4943('0x1a')](handleError(_0x1b2b0e,null));};exports[_0x4943('0x46')]=function(_0x5f56c8,_0x5b406a){return respondWithRpcPromise(_0x4943('0x45'),_0x5f56c8['query'],routingClient)[_0x4943('0x9')](findById(_0x5f56c8[_0x4943('0x1d')]['id']))[_0x4943('0x9')](respondWithResult(_0x5b406a,null))[_0x4943('0x1a')](handleError(_0x5b406a,null));};exports[_0x4943('0x47')]=function(_0x98f4ca,_0x25ea83){return respondWithRpcPromise(_0x4943('0x48'),_0x98f4ca['query'],mailClient)[_0x4943('0x9')](respondWithResult(_0x25ea83,null))[_0x4943('0x1a')](handleError(_0x25ea83,null));};exports[_0x4943('0x49')]=function(_0x38e842,_0x1757c1){return respondWithRpcPromise(_0x4943('0x4a'),_0x38e842[_0x4943('0x19')],routingClient)[_0x4943('0x9')](respondWithResult(_0x1757c1,null))[_0x4943('0x1a')](handleError(_0x1757c1,null));};exports[_0x4943('0x4b')]=function(_0x43018a,_0x4ac3ff){return respondWithRpcPromise(_0x4943('0x4a'),_0x43018a[_0x4943('0x19')],routingClient)['then'](findById(_0x43018a['params']['id']))[_0x4943('0x9')](respondWithResult(_0x4ac3ff,null))[_0x4943('0x1a')](handleError(_0x4ac3ff,null));};exports['smsQueues']=function(_0x2a683b,_0x32b164){return respondWithRpcPromise(_0x4943('0x4c'),_0x2a683b[_0x4943('0x19')],routingClient)[_0x4943('0x9')](respondWithResult(_0x32b164,null))[_0x4943('0x1a')](handleError(_0x32b164,null));};exports[_0x4943('0x4d')]=function(_0xa37c50,_0x490baf){return respondWithRpcPromise(_0x4943('0x4c'),_0xa37c50[_0x4943('0x19')],routingClient)[_0x4943('0x9')](findById(_0xa37c50[_0x4943('0x1d')]['id']))[_0x4943('0x9')](respondWithResult(_0x490baf,null))['catch'](handleError(_0x490baf,null));};exports['whatsappQueues']=function(_0x523b02,_0x1e3a54){return respondWithRpcPromise('WhatsappQueues',_0x523b02['query'],routingClient)['then'](respondWithResult(_0x1e3a54,null))[_0x4943('0x1a')](handleError(_0x1e3a54,null));};exports['showWhatsappQueues']=function(_0x52f3cd,_0x423ac4){return respondWithRpcPromise(_0x4943('0x4e'),_0x52f3cd[_0x4943('0x19')],routingClient)[_0x4943('0x9')](findById(_0x52f3cd['params']['id']))[_0x4943('0x9')](respondWithResult(_0x423ac4,null))[_0x4943('0x1a')](handleError(_0x423ac4,null));};exports[_0x4943('0x4f')]=function(_0x5d0564,_0x20ba03){return respondWithRpcPromise(_0x4943('0x50'),_0x5d0564[_0x4943('0x19')],routingClient)[_0x4943('0x9')](respondWithResult(_0x20ba03,null))[_0x4943('0x1a')](handleError(_0x20ba03,null));};exports[_0x4943('0x51')]=function(_0x25bf16,_0x4f9c0c){return respondWithRpcPromise(_0x4943('0x50'),_0x25bf16[_0x4943('0x19')],routingClient)[_0x4943('0x9')](findById(_0x25bf16['params']['id']))[_0x4943('0x9')](respondWithResult(_0x4f9c0c,null))[_0x4943('0x1a')](handleError(_0x4f9c0c,null));};exports[_0x4943('0x52')]=function(_0x410662,_0x145984){return respondWithRpcPromise(_0x4943('0x53'),_0x410662[_0x4943('0x19')])[_0x4943('0x9')](respondWithResult(_0x145984,null))[_0x4943('0x1a')](handleError(_0x145984,null));};exports[_0x4943('0x54')]=function(_0x104665,_0xb45e6){return respondWithRpcPromise(_0x4943('0x55'),_0x104665[_0x4943('0x19')],routingClient)[_0x4943('0x9')](respondWithResult(_0xb45e6,null))['catch'](handleError(_0xb45e6,null));};exports[_0x4943('0x56')]=function(_0x355f86,_0xf21357){return respondWithRpcPromise('MailQueuesWaitingInteractions',_0x355f86[_0x4943('0x19')],routingClient)[_0x4943('0x9')](respondWithResult(_0xf21357,null))[_0x4943('0x1a')](handleError(_0xf21357,null));};exports[_0x4943('0x57')]=function(_0x3cd3f5,_0x137322){return respondWithRpcPromise(_0x4943('0x58'),_0x3cd3f5[_0x4943('0x19')],routingClient)[_0x4943('0x9')](respondWithResult(_0x137322,null))[_0x4943('0x1a')](handleError(_0x137322,null));};exports[_0x4943('0x59')]=function(_0x27fee7,_0x18cee1){return respondWithRpcPromise(_0x4943('0x58'),_0x27fee7[_0x4943('0x19')],routingClient)[_0x4943('0x9')](function(_0x337410){if(_0x27fee7['query']['type']!==undefined){var _0x5afcaf=_(_0x337410[_0x4943('0x15')])[_0x4943('0x5a')]([_0x27fee7[_0x4943('0x19')]['type'],_0x27fee7[_0x4943('0x1d')]['id']])['map'](_0x4943('0x5b'))['uniq']()[_0x4943('0x5c')]();return _0x337410[_0x4943('0x15')][_0x4943('0x5a')](function(_0x37384e){return _0x5afcaf[_0x4943('0x5d')](_0x37384e['queue_id'])>-0x1;});}else{return _0x337410[_0x4943('0x15')][_0x4943('0x5a')](function(_0x4a3c97){return _0x4a3c97[_0x4943('0x5b')]===parseInt(_0x27fee7[_0x4943('0x1d')]['id']);});}})['then'](respondWithResult(_0x18cee1,null))['catch'](handleError(_0x18cee1,null));};exports[_0x4943('0x5e')]=function(_0x5b7e1b,_0x468ef1){return respondWithRpcPromise(_0x4943('0x5f'),_0x5b7e1b[_0x4943('0x19')],routingClient)[_0x4943('0x9')](respondWithResult(_0x468ef1,null))[_0x4943('0x1a')](handleError(_0x468ef1,null));};exports['whatsappQueuesWaitingInteractions']=function(_0x5b4d81,_0x2e42c7){return respondWithRpcPromise(_0x4943('0x60'),_0x5b4d81['query'],routingClient)[_0x4943('0x9')](respondWithResult(_0x2e42c7,null))[_0x4943('0x1a')](handleError(_0x2e42c7,null));};exports[_0x4943('0x61')]=function(_0x1352c5,_0x44358a){return respondWithRpcPromise(_0x4943('0x62'),_0x1352c5[_0x4943('0x19')],routingClient)[_0x4943('0x9')](respondWithResult(_0x44358a,null))['catch'](handleError(_0x44358a,null));};exports[_0x4943('0x63')]=function(_0x47ccc1){return function(_0x443479,_0x116cba){var _0x29b272,_0x5a7823;var _0x469337=_[_0x4943('0x64')](_0x47ccc1);var _0x570ea5=_0x47ccc1==='chat'?_0x4943('0x65'):_0x4943('0x66');return db[_0x469337+_0x4943('0x67')][_0x4943('0x68')]({'raw':!![],'where':{'id':_0x443479[_0x4943('0x1d')]['id']}})['then'](function(_0x20a948){if(_[_0x4943('0x14')](_0x20a948)){throw new Error(_0x469337+_0x4943('0x69'));}_0x29b272=_0x20a948;return db[_0x469337+'Message'][_0x4943('0x68')]({'where':{'id':_0x443479['body'][_0x4943('0x6a')]},'include':[{'model':db[_0x469337+_0x4943('0x6b')],'as':_0x4943('0x6b')},{'model':db[_0x469337+_0x570ea5],'as':_0x4943('0x66')}]});})[_0x4943('0x9')](function(_0x1ddc06){if(_[_0x4943('0x14')](_0x1ddc06)){throw new Error(_0x469337+'\x20Message\x20not\x20found');}_0x5a7823=_0x1ddc06;return _0x1ddc06[_0x4943('0x6c')]({'read':0x0,'readAt':null,'UserId':null});})[_0x4943('0x9')](function(){var _0x1806f4={'uniqueid':_0x47ccc1+'.'+_0x5a7823['id']+'.'+_0x5a7823[_0x4943('0x6b')]['id'],'FromUserId':_0x443479[_0x4943('0x30')]['id'],'type':_0x4943('0x6d')};_0x1806f4[_0x469337+'MessageId']=_0x5a7823['id'];_0x1806f4[_0x469337+'InteractionId']=_0x5a7823[_0x4943('0x6b')]['id'];_0x1806f4[_0x4943('0x6e')+_0x469337+_0x570ea5+'Id']=_0x5a7823[_0x4943('0x66')]['id'];_0x1806f4['To'+_0x469337+_0x4943('0x6f')]=_0x29b272['id'];return db[_0x469337+_0x4943('0x70')][_0x4943('0x71')](_0x1806f4);})['then'](function(){return respondWithRpcPromise(_0x4943('0x72'),{'channel':_0x47ccc1,'interaction':_0x5a7823[_0x4943('0x6b')],'message':_0x5a7823,'account':_0x5a7823[_0x4943('0x66')],'applications':[{'id':0x0,'priority':0x1,'app':'queue','appdata':_0x29b272[_0x4943('0x12')]+','+(_0x5a7823['Account'][_0x4943('0x73')]||0x12c),'interval':'*,*,*,*'}]},routingClient);})[_0x4943('0x9')](respondWithResult(_0x116cba,null))[_0x4943('0x1a')](handleError(_0x116cba,null));};};exports[_0x4943('0x74')]=function(_0x2114dd,_0x2d18be){var _0x2185a9,_0x5b27ac;if(_[_0x4943('0x14')](_0x2114dd[_0x4943('0x2e')][_0x4943('0x75')])){throw new Error(_0x4943('0x76'));}var _0xec36e9=_0x2114dd[_0x4943('0x2e')][_0x4943('0x75')];var _0x2be399=_[_0x4943('0x64')](_0xec36e9);var _0x57719c=_0xec36e9===_0x4943('0x77')?'Website':'Account';return db['User'][_0x4943('0x68')]({'raw':!![],'where':{'id':_0x2114dd[_0x4943('0x1d')]['id'],'role':_0x4943('0x3b')}})[_0x4943('0x9')](function(_0x1fc63b){if(_[_0x4943('0x14')](_0x1fc63b)){throw new Error(_0x4943('0x78'));}_0x2185a9=_0x1fc63b;return db[_0x2be399+_0x4943('0x79')][_0x4943('0x68')]({'where':{'id':_0x2114dd['body']['messageId']},'include':[{'model':db[_0x2be399+_0x4943('0x6b')],'as':'Interaction'},{'model':db[_0x2be399+_0x57719c],'as':'Account'}]});})[_0x4943('0x9')](function(_0x469067){if(_[_0x4943('0x14')](_0x469067)){throw new Error(_0x2be399+_0x4943('0x7a'));}_0x5b27ac=_0x469067;return _0x469067[_0x4943('0x6c')]({'read':0x0,'readAt':null,'UserId':null});})[_0x4943('0x9')](function(){var _0x58d042={'uniqueid':_0xec36e9+'.'+_0x5b27ac['id']+'.'+_0x5b27ac[_0x4943('0x6b')]['id'],'FromUserId':_0x2114dd[_0x4943('0x30')]['id'],'type':'queue','ToUserId':_0x2185a9['id']};_0x58d042[_0x2be399+_0x4943('0x7b')]=_0x5b27ac['id'];_0x58d042[_0x2be399+_0x4943('0x7c')]=_0x5b27ac['Interaction']['id'];_0x58d042[_0x4943('0x6e')+_0x2be399+_0x57719c+'Id']=_0x5b27ac[_0x4943('0x66')]['id'];return db[_0x2be399+_0x4943('0x70')][_0x4943('0x71')](_0x58d042);})[_0x4943('0x9')](function(){return respondWithRpcPromise(_0x4943('0x72'),{'channel':_0xec36e9,'interaction':_0x5b27ac['Interaction'],'message':_0x5b27ac,'account':_0x5b27ac[_0x4943('0x66')],'applications':[{'id':0x0,'priority':0x1,'app':_0x4943('0x3b'),'appdata':_0x2185a9[_0x4943('0x12')]+','+(_0x5b27ac['Account']['agentTransferTimeout']||0x12c),'interval':'*,*,*,*'}]},routingClient);})['then'](respondWithResult(_0x2d18be,null))[_0x4943('0x1a')](handleError(_0x2d18be,null));};
\ No newline at end of file
+var _0x5654=['chatQueuesWaitingInteractions','mailQueuesWaitingInteractions','MailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','openchannelQueuesIdWaitingInteractions','type','map','queue_id','uniq','value','smsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','faxQueuesWaitingInteractions','Website','Account','findOne','\x20Queue\x20not\x20found','Message','messageId','Interaction','\x20Message\x20not\x20found','update','InteractionId','QueueId','TransferReport','create','queueTransferTimeout','*,*,*,*','agentNotify','channel','Channel\x20field\x20is\x20mandatory','capitalize','chat','Agent\x20not\x20found','queue','MessageId','Start','bluebird','moment','lodash','util','../../mysqldb','jayson/promise','http','client','then','error','code','message','result','catch','status','json','stack','send','isNil','rows','voiceChannels','VoiceChannels','query','voiceChannelMixMonitor','VoiceChannelMixMonitor','merge','params','voiceChannelStopMixMonitor','voiceQueues','VoiceQueues','showVoiceQueues','voiceQueuesPreview','VoiceQueuesPreview','VoiceQueuesChannels','VoiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','voiceQueuesChannelRedirect','Outbound','OutboundChannels','agents','Agents','agentCapacity','body','user','name','interaction','MemberReport','INTERACTION','length','format','YYYY-MM-DD\x20HH:mm:ss','interface','agent','internal','telephones','Telephones','trunks','Trunks','Campaigns','chatQueues','showChatQueues','mailQueues','showMailQueues','MailQueues','MailAccounts','openchannelQueues','OpenchannelQueues','smsQueues','SmsQueues','showSmsQueues','whatsappQueues','WhatsappQueues','showWhatsappQueues','FaxQueues','showFaxQueues','faxAccounts','FaxAccounts'];(function(_0x13ea00,_0x12f610){var _0x1f7347=function(_0x34ae63){while(--_0x34ae63){_0x13ea00['push'](_0x13ea00['shift']());}};_0x1f7347(++_0x12f610);}(_0x5654,0x10e));var _0x4565=function(_0x2f3614,_0x38bfab){_0x2f3614=_0x2f3614-0x0;var _0x28baab=_0x5654[_0x2f3614];return _0x28baab;};'use strict';var BPromise=require(_0x4565('0x0'));var moment=require(_0x4565('0x1'));var _=require(_0x4565('0x2'));var util=require(_0x4565('0x3'));var db=require(_0x4565('0x4'))['db'];var logger=require('../../config/logger')('api');var jayson=require(_0x4565('0x5'));var amiClient=jayson['client'][_0x4565('0x6')]({'port':0x232a});var mailClient=jayson[_0x4565('0x7')][_0x4565('0x6')]({'port':0x232b});var routingClient=jayson[_0x4565('0x7')][_0x4565('0x6')]({'port':0x232c});function respondWithRpcPromise(_0x4f9098,_0x2714cf,_0x20425a){return new BPromise(function(_0x3a4022,_0x5a80f0){var _0x2f6d55=_0x20425a?_0x20425a:amiClient;return _0x2f6d55['request'](_0x4f9098,_0x2714cf)[_0x4565('0x8')](function(_0x174884){if(_0x174884[_0x4565('0x9')]){if(_0x174884[_0x4565('0x9')][_0x4565('0xa')]===0x1f4){return _0x5a80f0(_0x174884['error'][_0x4565('0xb')]);}return _0x3a4022(_0x174884['error'][_0x4565('0xb')]);}else{_0x3a4022(_0x174884[_0x4565('0xc')]);}})[_0x4565('0xd')](function(_0x49c273){_0x5a80f0(_0x49c273);});});}function respondWithResult(_0x483d5a,_0x36ee0c){_0x36ee0c=_0x36ee0c||0xc8;return function(_0x57b6d5){if(_0x57b6d5){return _0x483d5a[_0x4565('0xe')](_0x36ee0c)[_0x4565('0xf')](_0x57b6d5);}return _0x483d5a['sendStatus'](0x194);};}function handleError(_0x53b0b1,_0x103dda){_0x103dda=_0x103dda||0x1f4;return function(_0x1008be){logger[_0x4565('0x9')](_0x1008be[_0x4565('0x10')]);if(_0x1008be['name']){delete _0x1008be['name'];}_0x53b0b1[_0x4565('0xe')](_0x103dda)[_0x4565('0x11')](_0x1008be);};}function findById(_0x1b3faa){return function(_0x8dafb8){if(!_[_0x4565('0x12')](_0x1b3faa)&&!_[_0x4565('0x12')](_0x8dafb8)&&!_[_0x4565('0x12')](_0x8dafb8[_0x4565('0x13')])){return _['find'](_0x8dafb8[_0x4565('0x13')],function(_0x5bb954){return _0x5bb954['id']==_0x1b3faa;});}return null;};}exports[_0x4565('0x14')]=function(_0x5f4d3d,_0x17b792){return respondWithRpcPromise(_0x4565('0x15'),_0x5f4d3d[_0x4565('0x16')])['then'](respondWithResult(_0x17b792,null))[_0x4565('0xd')](handleError(_0x17b792,null));};exports[_0x4565('0x17')]=function(_0x375fc1,_0x2996f6){return respondWithRpcPromise(_0x4565('0x18'),_[_0x4565('0x19')](_0x375fc1[_0x4565('0x16')],_0x375fc1[_0x4565('0x1a')]))[_0x4565('0x8')](respondWithResult(_0x2996f6,null))[_0x4565('0xd')](handleError(_0x2996f6,null));};exports[_0x4565('0x1b')]=function(_0x21d836,_0x48bdc3){return respondWithRpcPromise('VoiceChannelStopMixMonitor',_['merge'](_0x21d836[_0x4565('0x16')],_0x21d836['params']))[_0x4565('0x8')](respondWithResult(_0x48bdc3,null))[_0x4565('0xd')](handleError(_0x48bdc3,null));};exports[_0x4565('0x1c')]=function(_0x144912,_0x56d177){return respondWithRpcPromise(_0x4565('0x1d'),_0x144912['query'])[_0x4565('0x8')](respondWithResult(_0x56d177,null))['catch'](handleError(_0x56d177,null));};exports[_0x4565('0x1e')]=function(_0x46b49d,_0xac088f){return respondWithRpcPromise('VoiceQueues',_0x46b49d['query'])[_0x4565('0x8')](findById(_0x46b49d['params']['id']))[_0x4565('0x8')](respondWithResult(_0xac088f,null))[_0x4565('0xd')](handleError(_0xac088f,null));};exports[_0x4565('0x1f')]=function(_0x40db39,_0x49ac79){return respondWithRpcPromise(_0x4565('0x20'),_['merge'](_0x40db39['query'],_0x40db39[_0x4565('0x1a')]))[_0x4565('0x8')](respondWithResult(_0x49ac79,null))[_0x4565('0xd')](handleError(_0x49ac79,null));};exports['voiceQueuesChannels']=function(_0x3e59e5,_0x4a6f59){return respondWithRpcPromise(_0x4565('0x21'),_0x3e59e5[_0x4565('0x16')])[_0x4565('0x8')](respondWithResult(_0x4a6f59,null))[_0x4565('0xd')](handleError(_0x4a6f59,null));};exports['voiceQueuesChannel']=function(_0x97c139,_0x1be259){return respondWithRpcPromise(_0x4565('0x22'),_[_0x4565('0x19')](_0x97c139[_0x4565('0x16')],_0x97c139[_0x4565('0x1a')]))[_0x4565('0x8')](respondWithResult(_0x1be259,null))[_0x4565('0xd')](handleError(_0x1be259,null));};exports[_0x4565('0x23')]=function(_0x4e7021,_0x4e9ee9){return respondWithRpcPromise(_0x4565('0x24'),_[_0x4565('0x19')](_0x4e7021[_0x4565('0x16')],_0x4e7021[_0x4565('0x1a')]))[_0x4565('0x8')](respondWithResult(_0x4e9ee9,null))[_0x4565('0xd')](handleError(_0x4e9ee9,null));};exports[_0x4565('0x25')]=function(_0x58f483,_0x12cb1d){return respondWithRpcPromise('VoiceQueuesChannelRedirect',_['merge'](_0x58f483[_0x4565('0x16')],_0x58f483[_0x4565('0x1a')]))[_0x4565('0x8')](respondWithResult(_0x12cb1d,null))[_0x4565('0xd')](handleError(_0x12cb1d,null));};exports['outbound']=function(_0x22c26c,_0x39f683){return respondWithRpcPromise(_0x4565('0x26'),_0x22c26c[_0x4565('0x16')])[_0x4565('0x8')](respondWithResult(_0x39f683,null))['catch'](handleError(_0x39f683,null));};exports['outboundChannels']=function(_0x3dbb2d,_0x4769a9){return respondWithRpcPromise(_0x4565('0x27'),_0x3dbb2d['query'])[_0x4565('0x8')](respondWithResult(_0x4769a9,null))[_0x4565('0xd')](handleError(_0x4769a9,null));};exports[_0x4565('0x28')]=function(_0xc71d64,_0x28ca35){var _0x25b95d;return respondWithRpcPromise('Agents',_0xc71d64['query'])[_0x4565('0x8')](function(_0x1bc275){_0x25b95d=_0x1bc275;return respondWithRpcPromise(_0x4565('0x29'),_0xc71d64[_0x4565('0x16')],routingClient);})[_0x4565('0x8')](function(_0x21a754){return _[_0x4565('0x19')]({},_0x21a754,_0x25b95d);})['then'](respondWithResult(_0x28ca35,null))[_0x4565('0xd')](handleError(_0x28ca35,null));};exports[_0x4565('0x2a')]=function(_0x4bd2a8,_0x4436b7){if(_0x4bd2a8[_0x4565('0x2b')]&&_0x4bd2a8['body']['interaction']&&_0x4bd2a8[_0x4565('0x2c')]&&_0x4bd2a8[_0x4565('0x2c')][_0x4565('0x2d')]){for(var _0xd22e3 in _0x4bd2a8[_0x4565('0x2b')][_0x4565('0x2e')]){if(_0x4bd2a8['body'][_0x4565('0x2e')]['hasOwnProperty'](_0xd22e3)){db[_0x4565('0x2f')]['findAll']({'where':{'channel':_0xd22e3,'membername':_0x4bd2a8[_0x4565('0x2c')][_0x4565('0x2d')],'type':_0x4565('0x30'),'exitAt':null,'uniqueid':_0x4bd2a8['body'][_0x4565('0x2e')][_0xd22e3]&&_0x4bd2a8[_0x4565('0x2b')]['interaction'][_0xd22e3][_0x4565('0x31')]?{'$notIn':_0x4bd2a8[_0x4565('0x2b')]['interaction'][_0xd22e3]}:{'$ne':null}}})[_0x4565('0x8')](function(_0x3b74cf){var _0x44b206=moment()[_0x4565('0x32')](_0x4565('0x33'));for(var _0x1665c7=0x0,_0x34af18=_0x3b74cf[_0x4565('0x31')];_0x1665c7<_0x34af18;_0x1665c7+=0x1){_0x3b74cf[_0x1665c7]['updateAttributes']({'exitAt':_0x44b206});}});for(var _0x1c45d2=0x0;_0x1c45d2<_0x4bd2a8[_0x4565('0x2b')]['interaction'][_0xd22e3]['length'];_0x1c45d2+=0x1){db['MemberReport']['findOrCreate']({'where':{'channel':_0xd22e3,'membername':_0x4bd2a8[_0x4565('0x2c')][_0x4565('0x2d')],'type':_0x4565('0x30'),'uniqueid':_0x4bd2a8[_0x4565('0x2b')][_0x4565('0x2e')][_0xd22e3][_0x1c45d2],'exitAt':null},'defaults':{'channel':_0xd22e3,'membername':_0x4bd2a8[_0x4565('0x2c')][_0x4565('0x2d')],'interface':_[_0x4565('0x12')](_0x4bd2a8[_0x4565('0x2c')]['interface'])?util[_0x4565('0x32')]('SIP/%s',_0x4bd2a8['user'][_0x4565('0x2d')]):_0x4bd2a8['user'][_0x4565('0x34')],'type':_0x4565('0x30'),'enterAt':moment()[_0x4565('0x32')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x4565('0x35'),'internal':_0x4bd2a8['user'][_0x4565('0x36')],'uniqueid':_0x4bd2a8['body']['interaction'][_0xd22e3][_0x1c45d2]}});}}}}return respondWithRpcPromise('AgentCapacity',{'id':_0x4bd2a8[_0x4565('0x1a')]['id'],'capacity':_0x4bd2a8['body']['capacity']},routingClient)[_0x4565('0x8')](respondWithResult(_0x4436b7,null))[_0x4565('0xd')](handleError(_0x4436b7,null));};exports[_0x4565('0x37')]=function(_0x3d8ba4,_0x4d27fd){return respondWithRpcPromise(_0x4565('0x38'),_0x3d8ba4[_0x4565('0x16')])['then'](respondWithResult(_0x4d27fd,null))[_0x4565('0xd')](handleError(_0x4d27fd,null));};exports[_0x4565('0x39')]=function(_0x5511bf,_0x2136dc){return respondWithRpcPromise(_0x4565('0x3a'),_0x5511bf[_0x4565('0x16')])[_0x4565('0x8')](respondWithResult(_0x2136dc,null))[_0x4565('0xd')](handleError(_0x2136dc,null));};exports['campaigns']=function(_0x4c7ffd,_0x26e6f8){return respondWithRpcPromise(_0x4565('0x3b'),_0x4c7ffd[_0x4565('0x16')])['then'](respondWithResult(_0x26e6f8,null))['catch'](handleError(_0x26e6f8,null));};exports[_0x4565('0x3c')]=function(_0x1ee626,_0x14a622){return respondWithRpcPromise('ChatQueues',_0x1ee626[_0x4565('0x16')],routingClient)[_0x4565('0x8')](respondWithResult(_0x14a622,null))['catch'](handleError(_0x14a622,null));};exports[_0x4565('0x3d')]=function(_0x478bf5,_0x3f2fbe){return respondWithRpcPromise('ChatQueues',_0x478bf5[_0x4565('0x16')],routingClient)[_0x4565('0x8')](findById(_0x478bf5[_0x4565('0x1a')]['id']))['then'](respondWithResult(_0x3f2fbe,null))[_0x4565('0xd')](handleError(_0x3f2fbe,null));};exports[_0x4565('0x3e')]=function(_0x448d1f,_0x1f2daf){return respondWithRpcPromise('MailQueues',_0x448d1f[_0x4565('0x16')],routingClient)[_0x4565('0x8')](respondWithResult(_0x1f2daf,null))[_0x4565('0xd')](handleError(_0x1f2daf,null));};exports[_0x4565('0x3f')]=function(_0x1af2f6,_0x1f81ab){return respondWithRpcPromise(_0x4565('0x40'),_0x1af2f6[_0x4565('0x16')],routingClient)['then'](findById(_0x1af2f6[_0x4565('0x1a')]['id']))[_0x4565('0x8')](respondWithResult(_0x1f81ab,null))[_0x4565('0xd')](handleError(_0x1f81ab,null));};exports['mailAccounts']=function(_0x3d6861,_0x3b582e){return respondWithRpcPromise(_0x4565('0x41'),_0x3d6861['query'],mailClient)[_0x4565('0x8')](respondWithResult(_0x3b582e,null))['catch'](handleError(_0x3b582e,null));};exports[_0x4565('0x42')]=function(_0x2624bb,_0x2faa1a){return respondWithRpcPromise(_0x4565('0x43'),_0x2624bb[_0x4565('0x16')],routingClient)[_0x4565('0x8')](respondWithResult(_0x2faa1a,null))[_0x4565('0xd')](handleError(_0x2faa1a,null));};exports['showOpenchannelQueues']=function(_0x36c0fa,_0x44994b){return respondWithRpcPromise(_0x4565('0x43'),_0x36c0fa[_0x4565('0x16')],routingClient)['then'](findById(_0x36c0fa['params']['id']))['then'](respondWithResult(_0x44994b,null))[_0x4565('0xd')](handleError(_0x44994b,null));};exports[_0x4565('0x44')]=function(_0x53fc95,_0x5e84dc){return respondWithRpcPromise(_0x4565('0x45'),_0x53fc95[_0x4565('0x16')],routingClient)[_0x4565('0x8')](respondWithResult(_0x5e84dc,null))[_0x4565('0xd')](handleError(_0x5e84dc,null));};exports[_0x4565('0x46')]=function(_0x4d7870,_0x412557){return respondWithRpcPromise(_0x4565('0x45'),_0x4d7870[_0x4565('0x16')],routingClient)[_0x4565('0x8')](findById(_0x4d7870[_0x4565('0x1a')]['id']))[_0x4565('0x8')](respondWithResult(_0x412557,null))[_0x4565('0xd')](handleError(_0x412557,null));};exports[_0x4565('0x47')]=function(_0x38755c,_0x3fda99){return respondWithRpcPromise(_0x4565('0x48'),_0x38755c[_0x4565('0x16')],routingClient)[_0x4565('0x8')](respondWithResult(_0x3fda99,null))[_0x4565('0xd')](handleError(_0x3fda99,null));};exports[_0x4565('0x49')]=function(_0x572560,_0x55566c){return respondWithRpcPromise(_0x4565('0x48'),_0x572560[_0x4565('0x16')],routingClient)['then'](findById(_0x572560[_0x4565('0x1a')]['id']))[_0x4565('0x8')](respondWithResult(_0x55566c,null))['catch'](handleError(_0x55566c,null));};exports['faxQueues']=function(_0x13b74d,_0x222eaf){return respondWithRpcPromise(_0x4565('0x4a'),_0x13b74d['query'],routingClient)['then'](respondWithResult(_0x222eaf,null))[_0x4565('0xd')](handleError(_0x222eaf,null));};exports[_0x4565('0x4b')]=function(_0x34e664,_0x8cfbc5){return respondWithRpcPromise('FaxQueues',_0x34e664[_0x4565('0x16')],routingClient)[_0x4565('0x8')](findById(_0x34e664[_0x4565('0x1a')]['id']))[_0x4565('0x8')](respondWithResult(_0x8cfbc5,null))[_0x4565('0xd')](handleError(_0x8cfbc5,null));};exports[_0x4565('0x4c')]=function(_0x5c605a,_0x15712){return respondWithRpcPromise(_0x4565('0x4d'),_0x5c605a[_0x4565('0x16')])['then'](respondWithResult(_0x15712,null))['catch'](handleError(_0x15712,null));};exports[_0x4565('0x4e')]=function(_0x21f2bc,_0x549981){return respondWithRpcPromise('ChatQueuesWaitingInteractions',_0x21f2bc[_0x4565('0x16')],routingClient)[_0x4565('0x8')](respondWithResult(_0x549981,null))['catch'](handleError(_0x549981,null));};exports[_0x4565('0x4f')]=function(_0x3d3017,_0x58410e){return respondWithRpcPromise(_0x4565('0x50'),_0x3d3017[_0x4565('0x16')],routingClient)[_0x4565('0x8')](respondWithResult(_0x58410e,null))[_0x4565('0xd')](handleError(_0x58410e,null));};exports[_0x4565('0x51')]=function(_0xe3dfe3,_0x5e0e04){return respondWithRpcPromise(_0x4565('0x52'),_0xe3dfe3[_0x4565('0x16')],routingClient)[_0x4565('0x8')](respondWithResult(_0x5e0e04,null))[_0x4565('0xd')](handleError(_0x5e0e04,null));};exports[_0x4565('0x53')]=function(_0x20a404,_0x3ed470){return respondWithRpcPromise('OpenchannelQueuesWaitingInteractions',_0x20a404[_0x4565('0x16')],routingClient)['then'](function(_0x452c99){if(_0x20a404[_0x4565('0x16')][_0x4565('0x54')]!==undefined){var _0x33cfd5=_(_0x452c99[_0x4565('0x13')])['filter']([_0x20a404[_0x4565('0x16')][_0x4565('0x54')],_0x20a404[_0x4565('0x1a')]['id']])[_0x4565('0x55')](_0x4565('0x56'))[_0x4565('0x57')]()[_0x4565('0x58')]();return _0x452c99[_0x4565('0x13')]['filter'](function(_0x48053e){return _0x33cfd5['indexOf'](_0x48053e[_0x4565('0x56')])>-0x1;});}else{return _0x452c99[_0x4565('0x13')]['filter'](function(_0x184bf2){return _0x184bf2[_0x4565('0x56')]===parseInt(_0x20a404[_0x4565('0x1a')]['id']);});}})[_0x4565('0x8')](respondWithResult(_0x3ed470,null))['catch'](handleError(_0x3ed470,null));};exports[_0x4565('0x59')]=function(_0x17e3c0,_0x297269){return respondWithRpcPromise('SmsQueuesWaitingInteractions',_0x17e3c0[_0x4565('0x16')],routingClient)[_0x4565('0x8')](respondWithResult(_0x297269,null))[_0x4565('0xd')](handleError(_0x297269,null));};exports[_0x4565('0x5a')]=function(_0x3e9410,_0x3049aa){return respondWithRpcPromise('WhatsappQueuesWaitingInteractions',_0x3e9410['query'],routingClient)[_0x4565('0x8')](respondWithResult(_0x3049aa,null))[_0x4565('0xd')](handleError(_0x3049aa,null));};exports[_0x4565('0x5b')]=function(_0x61282d,_0x5e3ce4){return respondWithRpcPromise('FaxQueuesWaitingInteractions',_0x61282d[_0x4565('0x16')],routingClient)[_0x4565('0x8')](respondWithResult(_0x5e3ce4,null))[_0x4565('0xd')](handleError(_0x5e3ce4,null));};exports['queueNotify']=function(_0x809956){return function(_0x3d0aaf,_0x4bfaa9){var _0x1ea2a5,_0x4ded72;var _0x8f672d=_['capitalize'](_0x809956);var _0x489294=_0x809956==='chat'?_0x4565('0x5c'):_0x4565('0x5d');return db[_0x8f672d+'Queue'][_0x4565('0x5e')]({'raw':!![],'where':{'id':_0x3d0aaf[_0x4565('0x1a')]['id']}})[_0x4565('0x8')](function(_0x3cfbf6){if(_[_0x4565('0x12')](_0x3cfbf6)){throw new Error(_0x8f672d+_0x4565('0x5f'));}_0x1ea2a5=_0x3cfbf6;return db[_0x8f672d+_0x4565('0x60')][_0x4565('0x5e')]({'where':{'id':_0x3d0aaf[_0x4565('0x2b')][_0x4565('0x61')]},'include':[{'model':db[_0x8f672d+_0x4565('0x62')],'as':_0x4565('0x62')},{'model':db[_0x8f672d+_0x489294],'as':'Account'}]});})[_0x4565('0x8')](function(_0x234598){if(_[_0x4565('0x12')](_0x234598)){throw new Error(_0x8f672d+_0x4565('0x63'));}_0x4ded72=_0x234598;return _0x234598[_0x4565('0x64')]({'read':0x0,'readAt':null,'UserId':null});})[_0x4565('0x8')](function(){var _0x134d17={'uniqueid':_0x809956+'.'+_0x4ded72['id']+'.'+_0x4ded72['Interaction']['id'],'FromUserId':_0x3d0aaf[_0x4565('0x2c')]['id'],'type':'queue'};_0x134d17[_0x8f672d+'MessageId']=_0x4ded72['id'];_0x134d17[_0x8f672d+_0x4565('0x65')]=_0x4ded72[_0x4565('0x62')]['id'];_0x134d17['From'+_0x8f672d+_0x489294+'Id']=_0x4ded72[_0x4565('0x5d')]['id'];_0x134d17['To'+_0x8f672d+_0x4565('0x66')]=_0x1ea2a5['id'];return db[_0x8f672d+_0x4565('0x67')][_0x4565('0x68')](_0x134d17);})[_0x4565('0x8')](function(){return respondWithRpcPromise('Start',{'channel':_0x809956,'interaction':_0x4ded72[_0x4565('0x62')],'message':_0x4ded72,'account':_0x4ded72['Account'],'applications':[{'id':0x0,'priority':0x1,'app':'queue','appdata':_0x1ea2a5[_0x4565('0x2d')]+','+(_0x4ded72[_0x4565('0x5d')][_0x4565('0x69')]||0x12c),'interval':_0x4565('0x6a')}]},routingClient);})[_0x4565('0x8')](respondWithResult(_0x4bfaa9,null))[_0x4565('0xd')](handleError(_0x4bfaa9,null));};};exports[_0x4565('0x6b')]=function(_0x545bd0,_0x1fe39c){var _0x2ffc16,_0x58ab54;if(_[_0x4565('0x12')](_0x545bd0[_0x4565('0x2b')][_0x4565('0x6c')])){throw new Error(_0x4565('0x6d'));}var _0x3a5ac8=_0x545bd0['body'][_0x4565('0x6c')];var _0x4c2858=_[_0x4565('0x6e')](_0x3a5ac8);var _0x21b138=_0x3a5ac8===_0x4565('0x6f')?'Website':_0x4565('0x5d');return db['User'][_0x4565('0x5e')]({'raw':!![],'where':{'id':_0x545bd0[_0x4565('0x1a')]['id'],'role':_0x4565('0x35')}})[_0x4565('0x8')](function(_0x49bb83){if(_[_0x4565('0x12')](_0x49bb83)){throw new Error(_0x4565('0x70'));}_0x2ffc16=_0x49bb83;return db[_0x4c2858+_0x4565('0x60')][_0x4565('0x5e')]({'where':{'id':_0x545bd0[_0x4565('0x2b')][_0x4565('0x61')]},'include':[{'model':db[_0x4c2858+_0x4565('0x62')],'as':_0x4565('0x62')},{'model':db[_0x4c2858+_0x21b138],'as':'Account'}]});})[_0x4565('0x8')](function(_0x109998){if(_[_0x4565('0x12')](_0x109998)){throw new Error(_0x4c2858+_0x4565('0x63'));}_0x58ab54=_0x109998;return _0x109998['update']({'read':0x0,'readAt':null,'UserId':null});})[_0x4565('0x8')](function(){var _0x55c3d3={'uniqueid':_0x3a5ac8+'.'+_0x58ab54['id']+'.'+_0x58ab54[_0x4565('0x62')]['id'],'FromUserId':_0x545bd0[_0x4565('0x2c')]['id'],'type':_0x4565('0x71'),'ToUserId':_0x2ffc16['id']};_0x55c3d3[_0x4c2858+_0x4565('0x72')]=_0x58ab54['id'];_0x55c3d3[_0x4c2858+_0x4565('0x65')]=_0x58ab54[_0x4565('0x62')]['id'];_0x55c3d3['From'+_0x4c2858+_0x21b138+'Id']=_0x58ab54[_0x4565('0x5d')]['id'];return db[_0x4c2858+_0x4565('0x67')]['create'](_0x55c3d3);})[_0x4565('0x8')](function(){return respondWithRpcPromise(_0x4565('0x73'),{'channel':_0x3a5ac8,'interaction':_0x58ab54[_0x4565('0x62')],'message':_0x58ab54,'account':_0x58ab54['Account'],'applications':[{'id':0x0,'priority':0x1,'app':'agent','appdata':_0x2ffc16['name']+','+(_0x58ab54['Account']['agentTransferTimeout']||0x12c),'interval':_0x4565('0x6a')}]},routingClient);})[_0x4565('0x8')](respondWithResult(_0x1fe39c,null))[_0x4565('0xd')](handleError(_0x1fe39c,null));};
\ No newline at end of file