Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / api / rpc / rpc.controller.js
index 3ab5947..637a400 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x738b=['Trunks','campaigns','Campaigns','chatQueues','showChatQueues','ChatQueues','MailQueues','showMailQueues','mailAccounts','MailAccounts','openchannelQueues','OpenchannelQueues','showOpenchannelQueues','smsQueues','SmsQueues','whatsappQueues','WhatsappQueues','showWhatsappQueues','faxQueues','FaxQueues','showFaxQueues','FaxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','MailQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','type','filter','map','queue_id','uniq','value','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','faxQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','capitalize','Account','Queue','findOne','Message','messageId','Interaction','\x20Message\x20not\x20found','update','queue','MessageId','From','QueueId','TransferReport','create','queueTransferTimeout','*,*,*,*','channel','chat','Website','User','Agent\x20not\x20found','Start','bluebird','moment','lodash','../../mysqldb','../../config/logger','api','jayson/promise','client','http','request','then','error','code','message','result','catch','status','json','sendStatus','stack','name','send','isNil','find','rows','voiceChannels','query','VoiceChannelMixMonitor','merge','params','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','voiceQueues','VoiceQueues','showVoiceQueues','updateVoiceQueue','body','voiceQueuesPreview','voiceQueuesChannels','VoiceQueuesChannels','voiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','outboundChannels','OutboundChannels','Agents','agentCapacity','user','hasOwnProperty','MemberReport','findAll','INTERACTION','interaction','length','format','YYYY-MM-DD\x20HH:mm:ss','SIP/%s','interface','agent','internal','AgentCapacity','capacity','telephones','Telephones','trunks'];(function(_0x5a111d,_0x56422a){var _0x404bfd=function(_0x282063){while(--_0x282063){_0x5a111d['push'](_0x5a111d['shift']());}};_0x404bfd(++_0x56422a);}(_0x738b,0x1c1));var _0xb738=function(_0xb987b7,_0x44b4e4){_0xb987b7=_0xb987b7-0x0;var _0x2efdbb=_0x738b[_0xb987b7];return _0x2efdbb;};'use strict';var BPromise=require(_0xb738('0x0'));var moment=require(_0xb738('0x1'));var _=require(_0xb738('0x2'));var util=require('util');var db=require(_0xb738('0x3'))['db'];var logger=require(_0xb738('0x4'))(_0xb738('0x5'));var jayson=require(_0xb738('0x6'));var amiClient=jayson[_0xb738('0x7')][_0xb738('0x8')]({'port':0x232a});var mailClient=jayson[_0xb738('0x7')][_0xb738('0x8')]({'port':0x232b});var routingClient=jayson[_0xb738('0x7')]['http']({'port':0x232c});function respondWithRpcPromise(_0x461c4e,_0x340325,_0x119c91){return new BPromise(function(_0x9ec59c,_0x1ec7f0){var _0x2345df=_0x119c91?_0x119c91:amiClient;return _0x2345df[_0xb738('0x9')](_0x461c4e,_0x340325)[_0xb738('0xa')](function(_0x4993aa){if(_0x4993aa[_0xb738('0xb')]){if(_0x4993aa['error'][_0xb738('0xc')]===0x1f4){return _0x1ec7f0(_0x4993aa[_0xb738('0xb')][_0xb738('0xd')]);}return _0x9ec59c(_0x4993aa[_0xb738('0xb')][_0xb738('0xd')]);}else{_0x9ec59c(_0x4993aa[_0xb738('0xe')]);}})[_0xb738('0xf')](function(_0x406138){_0x1ec7f0(_0x406138);});});}function respondWithResult(_0x3b1a7e,_0x5e33da){_0x5e33da=_0x5e33da||0xc8;return function(_0x1e92c0){if(_0x1e92c0){return _0x3b1a7e[_0xb738('0x10')](_0x5e33da)[_0xb738('0x11')](_0x1e92c0);}return _0x3b1a7e[_0xb738('0x12')](0x194);};}function handleError(_0x2cf435,_0x6cc3f){_0x6cc3f=_0x6cc3f||0x1f4;return function(_0x21b6ff){logger[_0xb738('0xb')](_0x21b6ff[_0xb738('0x13')]);if(_0x21b6ff['name']){delete _0x21b6ff[_0xb738('0x14')];}_0x2cf435[_0xb738('0x10')](_0x6cc3f)[_0xb738('0x15')](_0x21b6ff);};}function findById(_0x1aac31){return function(_0xfc18f7){if(!_[_0xb738('0x16')](_0x1aac31)&&!_[_0xb738('0x16')](_0xfc18f7)&&!_[_0xb738('0x16')](_0xfc18f7['rows'])){return _[_0xb738('0x17')](_0xfc18f7[_0xb738('0x18')],function(_0x3e6afe){return _0x3e6afe['id']==_0x1aac31;});}return null;};}exports[_0xb738('0x19')]=function(_0x462501,_0x12d650){return respondWithRpcPromise('VoiceChannels',_0x462501[_0xb738('0x1a')])['then'](respondWithResult(_0x12d650,null))[_0xb738('0xf')](handleError(_0x12d650,null));};exports['voiceChannelMixMonitor']=function(_0x314717,_0x20d8bc){return respondWithRpcPromise(_0xb738('0x1b'),_[_0xb738('0x1c')](_0x314717[_0xb738('0x1a')],_0x314717[_0xb738('0x1d')]))[_0xb738('0xa')](respondWithResult(_0x20d8bc,null))[_0xb738('0xf')](handleError(_0x20d8bc,null));};exports[_0xb738('0x1e')]=function(_0x31e1c1,_0x5e9653){return respondWithRpcPromise(_0xb738('0x1f'),_[_0xb738('0x1c')](_0x31e1c1[_0xb738('0x1a')],_0x31e1c1[_0xb738('0x1d')]))[_0xb738('0xa')](respondWithResult(_0x5e9653,null))[_0xb738('0xf')](handleError(_0x5e9653,null));};exports[_0xb738('0x20')]=function(_0x43d972,_0x523d30){return respondWithRpcPromise(_0xb738('0x21'),_0x43d972[_0xb738('0x1a')])[_0xb738('0xa')](respondWithResult(_0x523d30,null))[_0xb738('0xf')](handleError(_0x523d30,null));};exports[_0xb738('0x22')]=function(_0x1cdd3a,_0x1299cb){return respondWithRpcPromise(_0xb738('0x21'),_0x1cdd3a['query'])[_0xb738('0xa')](findById(_0x1cdd3a[_0xb738('0x1d')]['id']))['then'](respondWithResult(_0x1299cb,null))[_0xb738('0xf')](handleError(_0x1299cb,null));};exports[_0xb738('0x23')]=function(_0x21c232,_0x4deb2b){return respondWithRpcPromise('UpdateVoiceQueue',_[_0xb738('0x1c')](_0x21c232[_0xb738('0x24')],_0x21c232[_0xb738('0x1d')]))[_0xb738('0xa')](respondWithResult(_0x4deb2b,null))[_0xb738('0xf')](handleError(_0x4deb2b,null));};exports[_0xb738('0x25')]=function(_0x27edad,_0x5c1728){return respondWithRpcPromise('VoiceQueuesPreview',_['merge'](_0x27edad[_0xb738('0x1a')],_0x27edad['params']))[_0xb738('0xa')](respondWithResult(_0x5c1728,null))[_0xb738('0xf')](handleError(_0x5c1728,null));};exports[_0xb738('0x26')]=function(_0x2404cf,_0x124ff5){return respondWithRpcPromise(_0xb738('0x27'),_0x2404cf[_0xb738('0x1a')])[_0xb738('0xa')](respondWithResult(_0x124ff5,null))[_0xb738('0xf')](handleError(_0x124ff5,null));};exports[_0xb738('0x28')]=function(_0x41ffb4,_0x769b9){return respondWithRpcPromise('VoiceQueuesChannel',_[_0xb738('0x1c')](_0x41ffb4['query'],_0x41ffb4['params']))[_0xb738('0xa')](respondWithResult(_0x769b9,null))['catch'](handleError(_0x769b9,null));};exports[_0xb738('0x29')]=function(_0x3c57b7,_0x3c6991){return respondWithRpcPromise(_0xb738('0x2a'),_[_0xb738('0x1c')](_0x3c57b7[_0xb738('0x1a')],_0x3c57b7['params']))[_0xb738('0xa')](respondWithResult(_0x3c6991,null))[_0xb738('0xf')](handleError(_0x3c6991,null));};exports[_0xb738('0x2b')]=function(_0x30400d,_0x1a35ac){return respondWithRpcPromise(_0xb738('0x2c'),_[_0xb738('0x1c')](_0x30400d['query'],_0x30400d[_0xb738('0x1d')]))['then'](respondWithResult(_0x1a35ac,null))[_0xb738('0xf')](handleError(_0x1a35ac,null));};exports['outbound']=function(_0x516194,_0x274aff){return respondWithRpcPromise('Outbound',_0x516194[_0xb738('0x1a')])['then'](respondWithResult(_0x274aff,null))[_0xb738('0xf')](handleError(_0x274aff,null));};exports[_0xb738('0x2d')]=function(_0xd0668e,_0x2f7787){return respondWithRpcPromise(_0xb738('0x2e'),_0xd0668e[_0xb738('0x1a')])[_0xb738('0xa')](respondWithResult(_0x2f7787,null))[_0xb738('0xf')](handleError(_0x2f7787,null));};exports['agents']=function(_0x26c4f6,_0x11e547){var _0x17df5e;return respondWithRpcPromise(_0xb738('0x2f'),_0x26c4f6[_0xb738('0x1a')])[_0xb738('0xa')](function(_0x4f932f){_0x17df5e=_0x4f932f;return respondWithRpcPromise('Agents',_0x26c4f6[_0xb738('0x1a')],routingClient);})['then'](function(_0x2036c5){return _[_0xb738('0x1c')]({},_0x2036c5,_0x17df5e);})[_0xb738('0xa')](respondWithResult(_0x11e547,null))[_0xb738('0xf')](handleError(_0x11e547,null));};exports[_0xb738('0x30')]=function(_0x5cfcaf,_0x403a27){if(_0x5cfcaf[_0xb738('0x24')]&&_0x5cfcaf[_0xb738('0x24')]['interaction']&&_0x5cfcaf[_0xb738('0x31')]&&_0x5cfcaf['user']['name']){for(var _0xded48c in _0x5cfcaf[_0xb738('0x24')]['interaction']){if(_0x5cfcaf[_0xb738('0x24')]['interaction'][_0xb738('0x32')](_0xded48c)){db[_0xb738('0x33')][_0xb738('0x34')]({'where':{'channel':_0xded48c,'membername':_0x5cfcaf[_0xb738('0x31')][_0xb738('0x14')],'type':_0xb738('0x35'),'exitAt':null,'uniqueid':_0x5cfcaf[_0xb738('0x24')][_0xb738('0x36')][_0xded48c]&&_0x5cfcaf[_0xb738('0x24')][_0xb738('0x36')][_0xded48c][_0xb738('0x37')]?{'$notIn':_0x5cfcaf[_0xb738('0x24')][_0xb738('0x36')][_0xded48c]}:{'$ne':null}}})[_0xb738('0xa')](function(_0x34f473){var _0x2f27a3=moment()[_0xb738('0x38')](_0xb738('0x39'));for(var _0x5e1df3=0x0,_0x10ed96=_0x34f473[_0xb738('0x37')];_0x5e1df3<_0x10ed96;_0x5e1df3+=0x1){_0x34f473[_0x5e1df3]['updateAttributes']({'exitAt':_0x2f27a3});}});for(var _0x4d54a8=0x0;_0x4d54a8<_0x5cfcaf[_0xb738('0x24')][_0xb738('0x36')][_0xded48c][_0xb738('0x37')];_0x4d54a8+=0x1){db[_0xb738('0x33')]['findOrCreate']({'where':{'channel':_0xded48c,'membername':_0x5cfcaf[_0xb738('0x31')][_0xb738('0x14')],'type':_0xb738('0x35'),'uniqueid':_0x5cfcaf[_0xb738('0x24')][_0xb738('0x36')][_0xded48c][_0x4d54a8],'exitAt':null},'defaults':{'channel':_0xded48c,'membername':_0x5cfcaf['user'][_0xb738('0x14')],'interface':_[_0xb738('0x16')](_0x5cfcaf[_0xb738('0x31')]['interface'])?util[_0xb738('0x38')](_0xb738('0x3a'),_0x5cfcaf[_0xb738('0x31')]['name']):_0x5cfcaf[_0xb738('0x31')][_0xb738('0x3b')],'type':_0xb738('0x35'),'enterAt':moment()[_0xb738('0x38')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0xb738('0x3c'),'internal':_0x5cfcaf['user'][_0xb738('0x3d')],'uniqueid':_0x5cfcaf['body']['interaction'][_0xded48c][_0x4d54a8]}});}}}}return respondWithRpcPromise(_0xb738('0x3e'),{'id':_0x5cfcaf[_0xb738('0x1d')]['id'],'capacity':_0x5cfcaf[_0xb738('0x24')][_0xb738('0x3f')]},routingClient)['then'](respondWithResult(_0x403a27,null))['catch'](handleError(_0x403a27,null));};exports[_0xb738('0x40')]=function(_0x36d605,_0x3e9ee5){return respondWithRpcPromise(_0xb738('0x41'),_0x36d605[_0xb738('0x1a')])['then'](respondWithResult(_0x3e9ee5,null))['catch'](handleError(_0x3e9ee5,null));};exports[_0xb738('0x42')]=function(_0x4c3dba,_0x2e96e2){return respondWithRpcPromise(_0xb738('0x43'),_0x4c3dba[_0xb738('0x1a')])[_0xb738('0xa')](respondWithResult(_0x2e96e2,null))[_0xb738('0xf')](handleError(_0x2e96e2,null));};exports[_0xb738('0x44')]=function(_0x3d11e7,_0x456236){return respondWithRpcPromise(_0xb738('0x45'),_0x3d11e7[_0xb738('0x1a')])[_0xb738('0xa')](respondWithResult(_0x456236,null))['catch'](handleError(_0x456236,null));};exports[_0xb738('0x46')]=function(_0x1a1ffa,_0x40dd9b){return respondWithRpcPromise('ChatQueues',_0x1a1ffa['query'],routingClient)[_0xb738('0xa')](respondWithResult(_0x40dd9b,null))[_0xb738('0xf')](handleError(_0x40dd9b,null));};exports[_0xb738('0x47')]=function(_0x570ee0,_0x5cc3ba){return respondWithRpcPromise(_0xb738('0x48'),_0x570ee0[_0xb738('0x1a')],routingClient)[_0xb738('0xa')](findById(_0x570ee0[_0xb738('0x1d')]['id']))['then'](respondWithResult(_0x5cc3ba,null))['catch'](handleError(_0x5cc3ba,null));};exports['mailQueues']=function(_0x5660cd,_0x379caa){return respondWithRpcPromise(_0xb738('0x49'),_0x5660cd[_0xb738('0x1a')],routingClient)[_0xb738('0xa')](respondWithResult(_0x379caa,null))['catch'](handleError(_0x379caa,null));};exports[_0xb738('0x4a')]=function(_0x222e8e,_0x43850e){return respondWithRpcPromise(_0xb738('0x49'),_0x222e8e['query'],routingClient)[_0xb738('0xa')](findById(_0x222e8e[_0xb738('0x1d')]['id']))[_0xb738('0xa')](respondWithResult(_0x43850e,null))[_0xb738('0xf')](handleError(_0x43850e,null));};exports[_0xb738('0x4b')]=function(_0x51d6a2,_0x2574d3){return respondWithRpcPromise(_0xb738('0x4c'),_0x51d6a2[_0xb738('0x1a')],mailClient)['then'](respondWithResult(_0x2574d3,null))['catch'](handleError(_0x2574d3,null));};exports[_0xb738('0x4d')]=function(_0x4630c9,_0x2c1c37){return respondWithRpcPromise(_0xb738('0x4e'),_0x4630c9[_0xb738('0x1a')],routingClient)[_0xb738('0xa')](respondWithResult(_0x2c1c37,null))[_0xb738('0xf')](handleError(_0x2c1c37,null));};exports[_0xb738('0x4f')]=function(_0x562b4d,_0x5f1704){return respondWithRpcPromise(_0xb738('0x4e'),_0x562b4d[_0xb738('0x1a')],routingClient)['then'](findById(_0x562b4d[_0xb738('0x1d')]['id']))['then'](respondWithResult(_0x5f1704,null))['catch'](handleError(_0x5f1704,null));};exports[_0xb738('0x50')]=function(_0x59b53d,_0x345528){return respondWithRpcPromise(_0xb738('0x51'),_0x59b53d['query'],routingClient)[_0xb738('0xa')](respondWithResult(_0x345528,null))[_0xb738('0xf')](handleError(_0x345528,null));};exports['showSmsQueues']=function(_0x1587f6,_0x120107){return respondWithRpcPromise(_0xb738('0x51'),_0x1587f6['query'],routingClient)['then'](findById(_0x1587f6[_0xb738('0x1d')]['id']))['then'](respondWithResult(_0x120107,null))[_0xb738('0xf')](handleError(_0x120107,null));};exports[_0xb738('0x52')]=function(_0xfca66d,_0x5686ac){return respondWithRpcPromise(_0xb738('0x53'),_0xfca66d[_0xb738('0x1a')],routingClient)[_0xb738('0xa')](respondWithResult(_0x5686ac,null))[_0xb738('0xf')](handleError(_0x5686ac,null));};exports[_0xb738('0x54')]=function(_0x4fbcb8,_0x120f20){return respondWithRpcPromise(_0xb738('0x53'),_0x4fbcb8['query'],routingClient)[_0xb738('0xa')](findById(_0x4fbcb8[_0xb738('0x1d')]['id']))[_0xb738('0xa')](respondWithResult(_0x120f20,null))[_0xb738('0xf')](handleError(_0x120f20,null));};exports[_0xb738('0x55')]=function(_0x1af486,_0x2b9e00){return respondWithRpcPromise(_0xb738('0x56'),_0x1af486[_0xb738('0x1a')],routingClient)[_0xb738('0xa')](respondWithResult(_0x2b9e00,null))[_0xb738('0xf')](handleError(_0x2b9e00,null));};exports[_0xb738('0x57')]=function(_0x36a855,_0xcd1ae9){return respondWithRpcPromise(_0xb738('0x56'),_0x36a855[_0xb738('0x1a')],routingClient)[_0xb738('0xa')](findById(_0x36a855[_0xb738('0x1d')]['id']))[_0xb738('0xa')](respondWithResult(_0xcd1ae9,null))[_0xb738('0xf')](handleError(_0xcd1ae9,null));};exports['faxAccounts']=function(_0x574ad0,_0x507c2e){return respondWithRpcPromise(_0xb738('0x58'),_0x574ad0[_0xb738('0x1a')])[_0xb738('0xa')](respondWithResult(_0x507c2e,null))[_0xb738('0xf')](handleError(_0x507c2e,null));};exports[_0xb738('0x59')]=function(_0x391bc7,_0x4cbb30){return respondWithRpcPromise(_0xb738('0x5a'),_0x391bc7[_0xb738('0x1a')],routingClient)[_0xb738('0xa')](respondWithResult(_0x4cbb30,null))[_0xb738('0xf')](handleError(_0x4cbb30,null));};exports[_0xb738('0x5b')]=function(_0x9d50be,_0x16527f){return respondWithRpcPromise(_0xb738('0x5c'),_0x9d50be['query'],routingClient)['then'](respondWithResult(_0x16527f,null))['catch'](handleError(_0x16527f,null));};exports['openchannelQueuesWaitingInteractions']=function(_0x1dfcdb,_0x1c0991){return respondWithRpcPromise(_0xb738('0x5d'),_0x1dfcdb[_0xb738('0x1a')],routingClient)[_0xb738('0xa')](respondWithResult(_0x1c0991,null))[_0xb738('0xf')](handleError(_0x1c0991,null));};exports['openchannelQueuesIdWaitingInteractions']=function(_0x5bb0bf,_0x4a5d3c){return respondWithRpcPromise(_0xb738('0x5d'),_0x5bb0bf[_0xb738('0x1a')],routingClient)[_0xb738('0xa')](function(_0xcbb033){if(_0x5bb0bf[_0xb738('0x1a')][_0xb738('0x5e')]!==undefined){var _0x447787=_(_0xcbb033[_0xb738('0x18')])[_0xb738('0x5f')]([_0x5bb0bf[_0xb738('0x1a')][_0xb738('0x5e')],_0x5bb0bf[_0xb738('0x1d')]['id']])[_0xb738('0x60')](_0xb738('0x61'))[_0xb738('0x62')]()[_0xb738('0x63')]();return _0xcbb033[_0xb738('0x18')][_0xb738('0x5f')](function(_0xe4f638){return _0x447787['indexOf'](_0xe4f638[_0xb738('0x61')])>-0x1;});}else{return _0xcbb033[_0xb738('0x18')][_0xb738('0x5f')](function(_0x1650a2){return _0x1650a2[_0xb738('0x61')]===parseInt(_0x5bb0bf[_0xb738('0x1d')]['id']);});}})[_0xb738('0xa')](respondWithResult(_0x4a5d3c,null))[_0xb738('0xf')](handleError(_0x4a5d3c,null));};exports[_0xb738('0x64')]=function(_0x4a20ca,_0x584b4a){return respondWithRpcPromise(_0xb738('0x65'),_0x4a20ca[_0xb738('0x1a')],routingClient)['then'](respondWithResult(_0x584b4a,null))[_0xb738('0xf')](handleError(_0x584b4a,null));};exports[_0xb738('0x66')]=function(_0x17ccc7,_0x32a489){return respondWithRpcPromise('WhatsappQueuesWaitingInteractions',_0x17ccc7[_0xb738('0x1a')],routingClient)[_0xb738('0xa')](respondWithResult(_0x32a489,null))['catch'](handleError(_0x32a489,null));};exports[_0xb738('0x67')]=function(_0x14f669,_0x4d72dd){return respondWithRpcPromise(_0xb738('0x68'),_0x14f669['query'],routingClient)[_0xb738('0xa')](respondWithResult(_0x4d72dd,null))['catch'](handleError(_0x4d72dd,null));};exports[_0xb738('0x69')]=function(_0x52887b){return function(_0x389f11,_0x52ef6b){var _0x3270de,_0x128196;var _0x2d6517=_[_0xb738('0x6a')](_0x52887b);var _0xf787e1=_0x52887b==='chat'?'Website':_0xb738('0x6b');return db[_0x2d6517+_0xb738('0x6c')][_0xb738('0x6d')]({'raw':!![],'where':{'id':_0x389f11['params']['id']}})[_0xb738('0xa')](function(_0x420efc){if(_[_0xb738('0x16')](_0x420efc)){throw new Error(_0x2d6517+'\x20Queue\x20not\x20found');}_0x3270de=_0x420efc;return db[_0x2d6517+_0xb738('0x6e')][_0xb738('0x6d')]({'where':{'id':_0x389f11[_0xb738('0x24')][_0xb738('0x6f')]},'include':[{'model':db[_0x2d6517+_0xb738('0x70')],'as':'Interaction'},{'model':db[_0x2d6517+_0xf787e1],'as':_0xb738('0x6b')}]});})[_0xb738('0xa')](function(_0x110cf4){if(_[_0xb738('0x16')](_0x110cf4)){throw new Error(_0x2d6517+_0xb738('0x71'));}_0x128196=_0x110cf4;return _0x110cf4[_0xb738('0x72')]({'read':0x0,'readAt':null,'UserId':null});})['then'](function(){var _0xb1f765={'uniqueid':_0x52887b+'.'+_0x128196['id']+'.'+_0x128196[_0xb738('0x70')]['id'],'FromUserId':_0x389f11[_0xb738('0x31')]['id'],'type':_0xb738('0x73')};_0xb1f765[_0x2d6517+_0xb738('0x74')]=_0x128196['id'];_0xb1f765[_0x2d6517+'InteractionId']=_0x128196[_0xb738('0x70')]['id'];_0xb1f765[_0xb738('0x75')+_0x2d6517+_0xf787e1+'Id']=_0x128196[_0xb738('0x6b')]['id'];_0xb1f765['To'+_0x2d6517+_0xb738('0x76')]=_0x3270de['id'];return db[_0x2d6517+_0xb738('0x77')][_0xb738('0x78')](_0xb1f765);})[_0xb738('0xa')](function(){return respondWithRpcPromise('Start',{'channel':_0x52887b,'interaction':_0x128196[_0xb738('0x70')],'message':_0x128196,'account':_0x128196['Account'],'applications':[{'id':0x0,'priority':0x1,'app':_0xb738('0x73'),'appdata':_0x3270de[_0xb738('0x14')]+','+(_0x128196[_0xb738('0x6b')][_0xb738('0x79')]||0x12c),'interval':_0xb738('0x7a')}]},routingClient);})[_0xb738('0xa')](respondWithResult(_0x52ef6b,null))[_0xb738('0xf')](handleError(_0x52ef6b,null));};};exports['agentNotify']=function(_0x4559df,_0x58c3d6){var _0x46e2ba,_0x3a63ff;if(_[_0xb738('0x16')](_0x4559df[_0xb738('0x24')][_0xb738('0x7b')])){throw new Error('Channel\x20field\x20is\x20mandatory');}var _0xabe174=_0x4559df['body'][_0xb738('0x7b')];var _0x221ea1=_['capitalize'](_0xabe174);var _0x3c5211=_0xabe174===_0xb738('0x7c')?_0xb738('0x7d'):_0xb738('0x6b');return db[_0xb738('0x7e')]['findOne']({'raw':!![],'where':{'id':_0x4559df[_0xb738('0x1d')]['id'],'role':_0xb738('0x3c')}})[_0xb738('0xa')](function(_0x11a029){if(_[_0xb738('0x16')](_0x11a029)){throw new Error(_0xb738('0x7f'));}_0x46e2ba=_0x11a029;return db[_0x221ea1+'Message'][_0xb738('0x6d')]({'where':{'id':_0x4559df[_0xb738('0x24')][_0xb738('0x6f')]},'include':[{'model':db[_0x221ea1+_0xb738('0x70')],'as':_0xb738('0x70')},{'model':db[_0x221ea1+_0x3c5211],'as':_0xb738('0x6b')}]});})[_0xb738('0xa')](function(_0x3db16b){if(_[_0xb738('0x16')](_0x3db16b)){throw new Error(_0x221ea1+_0xb738('0x71'));}_0x3a63ff=_0x3db16b;return _0x3db16b[_0xb738('0x72')]({'read':0x0,'readAt':null,'UserId':null});})[_0xb738('0xa')](function(){var _0x57e45f={'uniqueid':_0xabe174+'.'+_0x3a63ff['id']+'.'+_0x3a63ff[_0xb738('0x70')]['id'],'FromUserId':_0x4559df[_0xb738('0x31')]['id'],'type':_0xb738('0x73'),'ToUserId':_0x46e2ba['id']};_0x57e45f[_0x221ea1+_0xb738('0x74')]=_0x3a63ff['id'];_0x57e45f[_0x221ea1+'InteractionId']=_0x3a63ff[_0xb738('0x70')]['id'];_0x57e45f[_0xb738('0x75')+_0x221ea1+_0x3c5211+'Id']=_0x3a63ff[_0xb738('0x6b')]['id'];return db[_0x221ea1+'TransferReport'][_0xb738('0x78')](_0x57e45f);})[_0xb738('0xa')](function(){return respondWithRpcPromise(_0xb738('0x80'),{'channel':_0xabe174,'interaction':_0x3a63ff['Interaction'],'message':_0x3a63ff,'account':_0x3a63ff[_0xb738('0x6b')],'applications':[{'id':0x0,'priority':0x1,'app':_0xb738('0x3c'),'appdata':_0x46e2ba['name']+','+(_0x3a63ff[_0xb738('0x6b')]['agentTransferTimeout']||0x12c),'interval':_0xb738('0x7a')}]},routingClient);})['then'](respondWithResult(_0x58c3d6,null))['catch'](handleError(_0x58c3d6,null));};
\ No newline at end of file
+var _0x49bc=['*,*,*,*','agentNotify','Channel\x20field\x20is\x20mandatory','channel','Website','User','Agent\x20not\x20found','messageId','InteractionId','TransferReport','Start','agentTransferTimeout','bluebird','lodash','util','../../mysqldb','api','jayson/promise','http','client','then','code','error','message','result','catch','status','sendStatus','stack','name','send','isNil','rows','voiceChannels','VoiceChannels','query','voiceChannelMixMonitor','merge','params','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','voiceQueues','VoiceQueues','updateVoiceQueue','UpdateVoiceQueue','body','voiceQueuesPreview','VoiceQueuesPreview','voiceQueuesChannels','voiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','Outbound','OutboundChannels','agents','Agents','agentCapacity','interaction','user','hasOwnProperty','MemberReport','findAll','INTERACTION','length','format','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','interface','SIP/%s','agent','AgentCapacity','capacity','telephones','Telephones','trunks','Trunks','campaigns','chatQueues','ChatQueues','showChatQueues','MailQueues','showMailQueues','mailAccounts','openchannelQueues','OpenchannelQueues','showOpenchannelQueues','smsQueues','SmsQueues','showSmsQueues','WhatsappQueues','showWhatsappQueues','faxQueues','FaxQueues','faxAccounts','FaxAccounts','mailQueuesWaitingInteractions','MailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','openchannelQueuesIdWaitingInteractions','type','filter','map','uniq','value','indexOf','queue_id','SmsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','capitalize','chat','Account','\x20Queue\x20not\x20found','Message','findOne','Interaction','\x20Message\x20not\x20found','update','queue','MessageId','From','QueueId','create','queueTransferTimeout'];(function(_0x4a9fb1,_0x273043){var _0x348672=function(_0x142b69){while(--_0x142b69){_0x4a9fb1['push'](_0x4a9fb1['shift']());}};_0x348672(++_0x273043);}(_0x49bc,0x10c));var _0xc49b=function(_0x343501,_0x38f78b){_0x343501=_0x343501-0x0;var _0x4839a4=_0x49bc[_0x343501];return _0x4839a4;};'use strict';var BPromise=require(_0xc49b('0x0'));var moment=require('moment');var _=require(_0xc49b('0x1'));var util=require(_0xc49b('0x2'));var db=require(_0xc49b('0x3'))['db'];var logger=require('../../config/logger')(_0xc49b('0x4'));var jayson=require(_0xc49b('0x5'));var amiClient=jayson['client'][_0xc49b('0x6')]({'port':0x232a});var mailClient=jayson['client'][_0xc49b('0x6')]({'port':0x232b});var routingClient=jayson[_0xc49b('0x7')][_0xc49b('0x6')]({'port':0x232c});function respondWithRpcPromise(_0x27603e,_0x3c79b1,_0x12e8d7){return new BPromise(function(_0x29d478,_0x378d09){var _0x4b0eb8=_0x12e8d7?_0x12e8d7:amiClient;return _0x4b0eb8['request'](_0x27603e,_0x3c79b1)[_0xc49b('0x8')](function(_0x2c8e0d){if(_0x2c8e0d['error']){if(_0x2c8e0d['error'][_0xc49b('0x9')]===0x1f4){return _0x378d09(_0x2c8e0d[_0xc49b('0xa')]['message']);}return _0x29d478(_0x2c8e0d[_0xc49b('0xa')][_0xc49b('0xb')]);}else{_0x29d478(_0x2c8e0d[_0xc49b('0xc')]);}})[_0xc49b('0xd')](function(_0x52e44f){_0x378d09(_0x52e44f);});});}function respondWithResult(_0x834969,_0x54fdd7){_0x54fdd7=_0x54fdd7||0xc8;return function(_0x343023){if(_0x343023){return _0x834969[_0xc49b('0xe')](_0x54fdd7)['json'](_0x343023);}return _0x834969[_0xc49b('0xf')](0x194);};}function handleError(_0x4aecb2,_0xe5cea7){_0xe5cea7=_0xe5cea7||0x1f4;return function(_0xfcac40){logger[_0xc49b('0xa')](_0xfcac40[_0xc49b('0x10')]);if(_0xfcac40['name']){delete _0xfcac40[_0xc49b('0x11')];}_0x4aecb2[_0xc49b('0xe')](_0xe5cea7)[_0xc49b('0x12')](_0xfcac40);};}function findById(_0x5e58c5){return function(_0x50f576){if(!_[_0xc49b('0x13')](_0x5e58c5)&&!_[_0xc49b('0x13')](_0x50f576)&&!_[_0xc49b('0x13')](_0x50f576[_0xc49b('0x14')])){return _['find'](_0x50f576[_0xc49b('0x14')],function(_0x2bcdad){return _0x2bcdad['id']==_0x5e58c5;});}return null;};}exports[_0xc49b('0x15')]=function(_0x241eef,_0x5dd45b){return respondWithRpcPromise(_0xc49b('0x16'),_0x241eef[_0xc49b('0x17')])['then'](respondWithResult(_0x5dd45b,null))[_0xc49b('0xd')](handleError(_0x5dd45b,null));};exports[_0xc49b('0x18')]=function(_0x3e5da3,_0x3365aa){return respondWithRpcPromise('VoiceChannelMixMonitor',_[_0xc49b('0x19')](_0x3e5da3[_0xc49b('0x17')],_0x3e5da3[_0xc49b('0x1a')]))['then'](respondWithResult(_0x3365aa,null))[_0xc49b('0xd')](handleError(_0x3365aa,null));};exports[_0xc49b('0x1b')]=function(_0x229632,_0x494415){return respondWithRpcPromise(_0xc49b('0x1c'),_[_0xc49b('0x19')](_0x229632['query'],_0x229632[_0xc49b('0x1a')]))[_0xc49b('0x8')](respondWithResult(_0x494415,null))[_0xc49b('0xd')](handleError(_0x494415,null));};exports[_0xc49b('0x1d')]=function(_0x2bc3c3,_0x578793){return respondWithRpcPromise(_0xc49b('0x1e'),_0x2bc3c3[_0xc49b('0x17')])[_0xc49b('0x8')](respondWithResult(_0x578793,null))[_0xc49b('0xd')](handleError(_0x578793,null));};exports['showVoiceQueues']=function(_0x119634,_0x1bfdf3){return respondWithRpcPromise(_0xc49b('0x1e'),_0x119634[_0xc49b('0x17')])['then'](findById(_0x119634['params']['id']))[_0xc49b('0x8')](respondWithResult(_0x1bfdf3,null))['catch'](handleError(_0x1bfdf3,null));};exports[_0xc49b('0x1f')]=function(_0x4b7d4d,_0x2895bf){return respondWithRpcPromise(_0xc49b('0x20'),_[_0xc49b('0x19')](_0x4b7d4d[_0xc49b('0x21')],_0x4b7d4d[_0xc49b('0x1a')]))[_0xc49b('0x8')](respondWithResult(_0x2895bf,null))[_0xc49b('0xd')](handleError(_0x2895bf,null));};exports[_0xc49b('0x22')]=function(_0x2dbd7d,_0x531711){return respondWithRpcPromise(_0xc49b('0x23'),_[_0xc49b('0x19')](_0x2dbd7d[_0xc49b('0x17')],_0x2dbd7d[_0xc49b('0x1a')]))[_0xc49b('0x8')](respondWithResult(_0x531711,null))[_0xc49b('0xd')](handleError(_0x531711,null));};exports[_0xc49b('0x24')]=function(_0x481b5c,_0x913b0e){return respondWithRpcPromise('VoiceQueuesChannels',_0x481b5c['query'])[_0xc49b('0x8')](respondWithResult(_0x913b0e,null))[_0xc49b('0xd')](handleError(_0x913b0e,null));};exports[_0xc49b('0x25')]=function(_0x31d651,_0x1cb8c4){return respondWithRpcPromise('VoiceQueuesChannel',_[_0xc49b('0x19')](_0x31d651[_0xc49b('0x17')],_0x31d651[_0xc49b('0x1a')]))[_0xc49b('0x8')](respondWithResult(_0x1cb8c4,null))['catch'](handleError(_0x1cb8c4,null));};exports[_0xc49b('0x26')]=function(_0x54e0a0,_0x4c4343){return respondWithRpcPromise(_0xc49b('0x27'),_[_0xc49b('0x19')](_0x54e0a0['query'],_0x54e0a0[_0xc49b('0x1a')]))[_0xc49b('0x8')](respondWithResult(_0x4c4343,null))[_0xc49b('0xd')](handleError(_0x4c4343,null));};exports[_0xc49b('0x28')]=function(_0x40caca,_0x2108f7){return respondWithRpcPromise(_0xc49b('0x29'),_[_0xc49b('0x19')](_0x40caca[_0xc49b('0x17')],_0x40caca[_0xc49b('0x1a')]))[_0xc49b('0x8')](respondWithResult(_0x2108f7,null))[_0xc49b('0xd')](handleError(_0x2108f7,null));};exports['outbound']=function(_0x3e3f56,_0x258081){return respondWithRpcPromise(_0xc49b('0x2a'),_0x3e3f56[_0xc49b('0x17')])[_0xc49b('0x8')](respondWithResult(_0x258081,null))[_0xc49b('0xd')](handleError(_0x258081,null));};exports['outboundChannels']=function(_0x17c7b2,_0x2da7fa){return respondWithRpcPromise(_0xc49b('0x2b'),_0x17c7b2[_0xc49b('0x17')])[_0xc49b('0x8')](respondWithResult(_0x2da7fa,null))[_0xc49b('0xd')](handleError(_0x2da7fa,null));};exports[_0xc49b('0x2c')]=function(_0x7f8ec9,_0x2ad716){var _0x1f50df;return respondWithRpcPromise(_0xc49b('0x2d'),_0x7f8ec9[_0xc49b('0x17')])[_0xc49b('0x8')](function(_0x24edc6){_0x1f50df=_0x24edc6;return respondWithRpcPromise(_0xc49b('0x2d'),_0x7f8ec9['query'],routingClient);})['then'](function(_0x121204){return _[_0xc49b('0x19')]({},_0x121204,_0x1f50df);})['then'](respondWithResult(_0x2ad716,null))[_0xc49b('0xd')](handleError(_0x2ad716,null));};exports[_0xc49b('0x2e')]=function(_0x53bda6,_0x953a7b){if(_0x53bda6[_0xc49b('0x21')]&&_0x53bda6['body'][_0xc49b('0x2f')]&&_0x53bda6['user']&&_0x53bda6[_0xc49b('0x30')][_0xc49b('0x11')]){for(var _0x30f63a in _0x53bda6[_0xc49b('0x21')]['interaction']){if(_0x53bda6['body'][_0xc49b('0x2f')][_0xc49b('0x31')](_0x30f63a)){db[_0xc49b('0x32')][_0xc49b('0x33')]({'where':{'channel':_0x30f63a,'membername':_0x53bda6[_0xc49b('0x30')][_0xc49b('0x11')],'type':_0xc49b('0x34'),'exitAt':null,'uniqueid':_0x53bda6[_0xc49b('0x21')][_0xc49b('0x2f')][_0x30f63a]&&_0x53bda6[_0xc49b('0x21')][_0xc49b('0x2f')][_0x30f63a][_0xc49b('0x35')]?{'$notIn':_0x53bda6[_0xc49b('0x21')][_0xc49b('0x2f')][_0x30f63a]}:{'$ne':null}}})[_0xc49b('0x8')](function(_0x399c0c){var _0x384ddf=moment()[_0xc49b('0x36')](_0xc49b('0x37'));for(var _0x5232d0=0x0,_0x179937=_0x399c0c[_0xc49b('0x35')];_0x5232d0<_0x179937;_0x5232d0+=0x1){_0x399c0c[_0x5232d0][_0xc49b('0x38')]({'exitAt':_0x384ddf});}});for(var _0x12cc34=0x0;_0x12cc34<_0x53bda6[_0xc49b('0x21')][_0xc49b('0x2f')][_0x30f63a][_0xc49b('0x35')];_0x12cc34+=0x1){db[_0xc49b('0x32')]['findOrCreate']({'where':{'channel':_0x30f63a,'membername':_0x53bda6['user'][_0xc49b('0x11')],'type':'INTERACTION','uniqueid':_0x53bda6[_0xc49b('0x21')]['interaction'][_0x30f63a][_0x12cc34],'exitAt':null},'defaults':{'channel':_0x30f63a,'membername':_0x53bda6[_0xc49b('0x30')][_0xc49b('0x11')],'interface':_[_0xc49b('0x13')](_0x53bda6['user'][_0xc49b('0x39')])?util['format'](_0xc49b('0x3a'),_0x53bda6[_0xc49b('0x30')]['name']):_0x53bda6[_0xc49b('0x30')]['interface'],'type':_0xc49b('0x34'),'enterAt':moment()[_0xc49b('0x36')](_0xc49b('0x37')),'role':_0xc49b('0x3b'),'internal':_0x53bda6['user']['internal'],'uniqueid':_0x53bda6[_0xc49b('0x21')][_0xc49b('0x2f')][_0x30f63a][_0x12cc34]}});}}}}return respondWithRpcPromise(_0xc49b('0x3c'),{'id':_0x53bda6[_0xc49b('0x1a')]['id'],'capacity':_0x53bda6[_0xc49b('0x21')][_0xc49b('0x3d')]},routingClient)[_0xc49b('0x8')](respondWithResult(_0x953a7b,null))[_0xc49b('0xd')](handleError(_0x953a7b,null));};exports[_0xc49b('0x3e')]=function(_0x48c712,_0x385a79){return respondWithRpcPromise(_0xc49b('0x3f'),_0x48c712[_0xc49b('0x17')])[_0xc49b('0x8')](respondWithResult(_0x385a79,null))['catch'](handleError(_0x385a79,null));};exports[_0xc49b('0x40')]=function(_0x546422,_0x24420f){return respondWithRpcPromise(_0xc49b('0x41'),_0x546422[_0xc49b('0x17')])['then'](respondWithResult(_0x24420f,null))[_0xc49b('0xd')](handleError(_0x24420f,null));};exports[_0xc49b('0x42')]=function(_0x2d32c4,_0x175da3){return respondWithRpcPromise('Campaigns',_0x2d32c4[_0xc49b('0x17')])['then'](respondWithResult(_0x175da3,null))['catch'](handleError(_0x175da3,null));};exports[_0xc49b('0x43')]=function(_0x18b3be,_0x552f51){return respondWithRpcPromise(_0xc49b('0x44'),_0x18b3be[_0xc49b('0x17')],routingClient)[_0xc49b('0x8')](respondWithResult(_0x552f51,null))['catch'](handleError(_0x552f51,null));};exports[_0xc49b('0x45')]=function(_0x50cac8,_0x3b3328){return respondWithRpcPromise(_0xc49b('0x44'),_0x50cac8[_0xc49b('0x17')],routingClient)[_0xc49b('0x8')](findById(_0x50cac8['params']['id']))[_0xc49b('0x8')](respondWithResult(_0x3b3328,null))[_0xc49b('0xd')](handleError(_0x3b3328,null));};exports['mailQueues']=function(_0x569292,_0x3e4fd9){return respondWithRpcPromise(_0xc49b('0x46'),_0x569292[_0xc49b('0x17')],routingClient)[_0xc49b('0x8')](respondWithResult(_0x3e4fd9,null))[_0xc49b('0xd')](handleError(_0x3e4fd9,null));};exports[_0xc49b('0x47')]=function(_0x5180be,_0x35d73){return respondWithRpcPromise(_0xc49b('0x46'),_0x5180be[_0xc49b('0x17')],routingClient)[_0xc49b('0x8')](findById(_0x5180be[_0xc49b('0x1a')]['id']))[_0xc49b('0x8')](respondWithResult(_0x35d73,null))[_0xc49b('0xd')](handleError(_0x35d73,null));};exports[_0xc49b('0x48')]=function(_0x379208,_0xa79dc9){return respondWithRpcPromise('MailAccounts',_0x379208[_0xc49b('0x17')],mailClient)[_0xc49b('0x8')](respondWithResult(_0xa79dc9,null))[_0xc49b('0xd')](handleError(_0xa79dc9,null));};exports[_0xc49b('0x49')]=function(_0x521927,_0x546790){return respondWithRpcPromise(_0xc49b('0x4a'),_0x521927['query'],routingClient)['then'](respondWithResult(_0x546790,null))[_0xc49b('0xd')](handleError(_0x546790,null));};exports[_0xc49b('0x4b')]=function(_0xd28889,_0x1561db){return respondWithRpcPromise(_0xc49b('0x4a'),_0xd28889['query'],routingClient)[_0xc49b('0x8')](findById(_0xd28889[_0xc49b('0x1a')]['id']))[_0xc49b('0x8')](respondWithResult(_0x1561db,null))[_0xc49b('0xd')](handleError(_0x1561db,null));};exports[_0xc49b('0x4c')]=function(_0x436946,_0x4f6c35){return respondWithRpcPromise(_0xc49b('0x4d'),_0x436946[_0xc49b('0x17')],routingClient)['then'](respondWithResult(_0x4f6c35,null))[_0xc49b('0xd')](handleError(_0x4f6c35,null));};exports[_0xc49b('0x4e')]=function(_0x2a669f,_0x3da3e2){return respondWithRpcPromise(_0xc49b('0x4d'),_0x2a669f['query'],routingClient)[_0xc49b('0x8')](findById(_0x2a669f[_0xc49b('0x1a')]['id']))[_0xc49b('0x8')](respondWithResult(_0x3da3e2,null))[_0xc49b('0xd')](handleError(_0x3da3e2,null));};exports['whatsappQueues']=function(_0x4e0a67,_0x353f64){return respondWithRpcPromise(_0xc49b('0x4f'),_0x4e0a67[_0xc49b('0x17')],routingClient)[_0xc49b('0x8')](respondWithResult(_0x353f64,null))['catch'](handleError(_0x353f64,null));};exports[_0xc49b('0x50')]=function(_0x4b39ae,_0x2aefb2){return respondWithRpcPromise('WhatsappQueues',_0x4b39ae[_0xc49b('0x17')],routingClient)['then'](findById(_0x4b39ae[_0xc49b('0x1a')]['id']))[_0xc49b('0x8')](respondWithResult(_0x2aefb2,null))[_0xc49b('0xd')](handleError(_0x2aefb2,null));};exports[_0xc49b('0x51')]=function(_0x36c8a0,_0x242660){return respondWithRpcPromise(_0xc49b('0x52'),_0x36c8a0[_0xc49b('0x17')],routingClient)[_0xc49b('0x8')](respondWithResult(_0x242660,null))['catch'](handleError(_0x242660,null));};exports['showFaxQueues']=function(_0x381c49,_0x77bc8){return respondWithRpcPromise(_0xc49b('0x52'),_0x381c49['query'],routingClient)[_0xc49b('0x8')](findById(_0x381c49['params']['id']))[_0xc49b('0x8')](respondWithResult(_0x77bc8,null))[_0xc49b('0xd')](handleError(_0x77bc8,null));};exports[_0xc49b('0x53')]=function(_0x244217,_0x345264){return respondWithRpcPromise(_0xc49b('0x54'),_0x244217['query'])[_0xc49b('0x8')](respondWithResult(_0x345264,null))[_0xc49b('0xd')](handleError(_0x345264,null));};exports['chatQueuesWaitingInteractions']=function(_0x21ba58,_0x3b1e3b){return respondWithRpcPromise('ChatQueuesWaitingInteractions',_0x21ba58[_0xc49b('0x17')],routingClient)[_0xc49b('0x8')](respondWithResult(_0x3b1e3b,null))[_0xc49b('0xd')](handleError(_0x3b1e3b,null));};exports[_0xc49b('0x55')]=function(_0x15dfa4,_0x11599b){return respondWithRpcPromise(_0xc49b('0x56'),_0x15dfa4['query'],routingClient)['then'](respondWithResult(_0x11599b,null))[_0xc49b('0xd')](handleError(_0x11599b,null));};exports[_0xc49b('0x57')]=function(_0x2c440d,_0x15129d){return respondWithRpcPromise(_0xc49b('0x58'),_0x2c440d[_0xc49b('0x17')],routingClient)[_0xc49b('0x8')](respondWithResult(_0x15129d,null))[_0xc49b('0xd')](handleError(_0x15129d,null));};exports[_0xc49b('0x59')]=function(_0x293e95,_0x3fccb9){return respondWithRpcPromise(_0xc49b('0x58'),_0x293e95[_0xc49b('0x17')],routingClient)[_0xc49b('0x8')](function(_0x94fa58){if(_0x293e95[_0xc49b('0x17')][_0xc49b('0x5a')]!==undefined){var _0x37a058=_(_0x94fa58[_0xc49b('0x14')])[_0xc49b('0x5b')]([_0x293e95[_0xc49b('0x17')][_0xc49b('0x5a')],_0x293e95['params']['id']])[_0xc49b('0x5c')]('queue_id')[_0xc49b('0x5d')]()[_0xc49b('0x5e')]();return _0x94fa58['rows']['filter'](function(_0x1361c1){return _0x37a058[_0xc49b('0x5f')](_0x1361c1[_0xc49b('0x60')])>-0x1;});}else{return _0x94fa58['rows'][_0xc49b('0x5b')](function(_0x3b583f){return _0x3b583f[_0xc49b('0x60')]===parseInt(_0x293e95[_0xc49b('0x1a')]['id']);});}})[_0xc49b('0x8')](respondWithResult(_0x3fccb9,null))['catch'](handleError(_0x3fccb9,null));};exports['smsQueuesWaitingInteractions']=function(_0x19c8fb,_0x454f64){return respondWithRpcPromise(_0xc49b('0x61'),_0x19c8fb[_0xc49b('0x17')],routingClient)['then'](respondWithResult(_0x454f64,null))[_0xc49b('0xd')](handleError(_0x454f64,null));};exports[_0xc49b('0x62')]=function(_0x786ed6,_0x307b12){return respondWithRpcPromise('WhatsappQueuesWaitingInteractions',_0x786ed6['query'],routingClient)['then'](respondWithResult(_0x307b12,null))[_0xc49b('0xd')](handleError(_0x307b12,null));};exports['faxQueuesWaitingInteractions']=function(_0x53c6a8,_0x6bd6ce){return respondWithRpcPromise(_0xc49b('0x63'),_0x53c6a8[_0xc49b('0x17')],routingClient)[_0xc49b('0x8')](respondWithResult(_0x6bd6ce,null))[_0xc49b('0xd')](handleError(_0x6bd6ce,null));};exports[_0xc49b('0x64')]=function(_0x535f2a){return function(_0x320636,_0x1c64b1){var _0x14b4b6,_0x115cb1;var _0x51eee4=_[_0xc49b('0x65')](_0x535f2a);var _0x21c73e=_0x535f2a===_0xc49b('0x66')?'Website':_0xc49b('0x67');return db[_0x51eee4+'Queue']['findOne']({'raw':!![],'where':{'id':_0x320636[_0xc49b('0x1a')]['id']}})[_0xc49b('0x8')](function(_0x22307f){if(_[_0xc49b('0x13')](_0x22307f)){throw new Error(_0x51eee4+_0xc49b('0x68'));}_0x14b4b6=_0x22307f;return db[_0x51eee4+_0xc49b('0x69')][_0xc49b('0x6a')]({'where':{'id':_0x320636[_0xc49b('0x21')]['messageId']},'include':[{'model':db[_0x51eee4+_0xc49b('0x6b')],'as':_0xc49b('0x6b')},{'model':db[_0x51eee4+_0x21c73e],'as':_0xc49b('0x67')}]});})[_0xc49b('0x8')](function(_0x458acb){if(_[_0xc49b('0x13')](_0x458acb)){throw new Error(_0x51eee4+_0xc49b('0x6c'));}_0x115cb1=_0x458acb;return _0x458acb[_0xc49b('0x6d')]({'read':0x0,'readAt':null,'UserId':null});})['then'](function(){var _0x16c37b={'uniqueid':_0x535f2a+'.'+_0x115cb1['id']+'.'+_0x115cb1[_0xc49b('0x6b')]['id'],'FromUserId':_0x320636[_0xc49b('0x30')]['id'],'type':_0xc49b('0x6e')};_0x16c37b[_0x51eee4+_0xc49b('0x6f')]=_0x115cb1['id'];_0x16c37b[_0x51eee4+'InteractionId']=_0x115cb1[_0xc49b('0x6b')]['id'];_0x16c37b[_0xc49b('0x70')+_0x51eee4+_0x21c73e+'Id']=_0x115cb1['Account']['id'];_0x16c37b['To'+_0x51eee4+_0xc49b('0x71')]=_0x14b4b6['id'];return db[_0x51eee4+'TransferReport'][_0xc49b('0x72')](_0x16c37b);})[_0xc49b('0x8')](function(){return respondWithRpcPromise('Start',{'channel':_0x535f2a,'interaction':_0x115cb1['Interaction'],'message':_0x115cb1,'account':_0x115cb1[_0xc49b('0x67')],'applications':[{'id':0x0,'priority':0x1,'app':_0xc49b('0x6e'),'appdata':_0x14b4b6[_0xc49b('0x11')]+','+(_0x115cb1[_0xc49b('0x67')][_0xc49b('0x73')]||0x12c),'interval':_0xc49b('0x74')}]},routingClient);})[_0xc49b('0x8')](respondWithResult(_0x1c64b1,null))['catch'](handleError(_0x1c64b1,null));};};exports[_0xc49b('0x75')]=function(_0x11211a,_0x5d5ccf){var _0x409ff6,_0x114f80;if(_['isNil'](_0x11211a[_0xc49b('0x21')]['channel'])){throw new Error(_0xc49b('0x76'));}var _0x26858f=_0x11211a['body'][_0xc49b('0x77')];var _0x3b268a=_[_0xc49b('0x65')](_0x26858f);var _0x2ab1f4=_0x26858f===_0xc49b('0x66')?_0xc49b('0x78'):'Account';return db[_0xc49b('0x79')][_0xc49b('0x6a')]({'raw':!![],'where':{'id':_0x11211a[_0xc49b('0x1a')]['id'],'role':'agent'}})[_0xc49b('0x8')](function(_0x5e3438){if(_[_0xc49b('0x13')](_0x5e3438)){throw new Error(_0xc49b('0x7a'));}_0x409ff6=_0x5e3438;return db[_0x3b268a+'Message'][_0xc49b('0x6a')]({'where':{'id':_0x11211a['body'][_0xc49b('0x7b')]},'include':[{'model':db[_0x3b268a+_0xc49b('0x6b')],'as':_0xc49b('0x6b')},{'model':db[_0x3b268a+_0x2ab1f4],'as':_0xc49b('0x67')}]});})[_0xc49b('0x8')](function(_0x282a4a){if(_[_0xc49b('0x13')](_0x282a4a)){throw new Error(_0x3b268a+'\x20Message\x20not\x20found');}_0x114f80=_0x282a4a;return _0x282a4a[_0xc49b('0x6d')]({'read':0x0,'readAt':null,'UserId':null});})['then'](function(){var _0x12cb38={'uniqueid':_0x26858f+'.'+_0x114f80['id']+'.'+_0x114f80['Interaction']['id'],'FromUserId':_0x11211a['user']['id'],'type':_0xc49b('0x6e'),'ToUserId':_0x409ff6['id']};_0x12cb38[_0x3b268a+_0xc49b('0x6f')]=_0x114f80['id'];_0x12cb38[_0x3b268a+_0xc49b('0x7c')]=_0x114f80[_0xc49b('0x6b')]['id'];_0x12cb38[_0xc49b('0x70')+_0x3b268a+_0x2ab1f4+'Id']=_0x114f80['Account']['id'];return db[_0x3b268a+_0xc49b('0x7d')][_0xc49b('0x72')](_0x12cb38);})[_0xc49b('0x8')](function(){return respondWithRpcPromise(_0xc49b('0x7e'),{'channel':_0x26858f,'interaction':_0x114f80['Interaction'],'message':_0x114f80,'account':_0x114f80['Account'],'applications':[{'id':0x0,'priority':0x1,'app':'agent','appdata':_0x409ff6[_0xc49b('0x11')]+','+(_0x114f80[_0xc49b('0x67')][_0xc49b('0x7f')]||0x12c),'interval':'*,*,*,*'}]},routingClient);})[_0xc49b('0x8')](respondWithResult(_0x5d5ccf,null))[_0xc49b('0xd')](handleError(_0x5d5ccf,null));};
\ No newline at end of file