Built motion from commit (unavailable).|2.5.30
[motion2.git] / server / api / rpc / rpc.controller.js
index 8583c6f..fba659e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdbb0=['OpenchannelQueues','smsQueues','SmsQueues','showSmsQueues','WhatsappQueues','showWhatsappQueues','faxQueues','FaxQueues','showFaxQueues','faxAccounts','FaxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','MailQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','openchannelQueuesIdWaitingInteractions','type','filter','map','queue_id','value','indexOf','SmsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','WhatsappQueuesWaitingInteractions','faxQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','chat','Website','Queue','\x20Queue\x20not\x20found','findOne','Interaction','Account','\x20Message\x20not\x20found','update','queue','MessageId','InteractionId','From','TransferReport','create','Start','*,*,*,*','agentNotify','channel','Channel\x20field\x20is\x20mandatory','capitalize','User','agent','Agent\x20not\x20found','Message','messageId','agentTransferTimeout','bluebird','moment','lodash','../../mysqldb','../../config/logger','jayson/promise','http','client','request','then','error','code','message','status','sendStatus','stack','name','send','isNil','rows','find','voiceChannels','VoiceChannels','VoiceChannelMixMonitor','query','catch','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','merge','params','voiceQueues','VoiceQueues','showVoiceQueues','VoiceQueuesPreview','voiceQueuesChannels','VoiceQueuesChannels','voiceQueuesChannel','VoiceQueuesChannel','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','outbound','Outbound','OutboundChannels','Agents','agentCapacity','body','interaction','user','hasOwnProperty','MemberReport','INTERACTION','length','format','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','findOrCreate','interface','SIP/%s','internal','AgentCapacity','capacity','trunks','Trunks','chatQueues','ChatQueues','showChatQueues','mailQueues','showMailQueues','mailAccounts','MailAccounts','openchannelQueues'];(function(_0x1af4d6,_0x29cdbb){var _0x1030e6=function(_0x23865d){while(--_0x23865d){_0x1af4d6['push'](_0x1af4d6['shift']());}};_0x1030e6(++_0x29cdbb);}(_0xdbb0,0x13a));var _0x0dbb=function(_0x3eb0d8,_0x4fd6d0){_0x3eb0d8=_0x3eb0d8-0x0;var _0x2f12ee=_0xdbb0[_0x3eb0d8];return _0x2f12ee;};'use strict';var BPromise=require(_0x0dbb('0x0'));var moment=require(_0x0dbb('0x1'));var _=require(_0x0dbb('0x2'));var util=require('util');var db=require(_0x0dbb('0x3'))['db'];var logger=require(_0x0dbb('0x4'))('api');var jayson=require(_0x0dbb('0x5'));var amiClient=jayson['client'][_0x0dbb('0x6')]({'port':0x232a});var mailClient=jayson['client']['http']({'port':0x232b});var routingClient=jayson[_0x0dbb('0x7')][_0x0dbb('0x6')]({'port':0x232c});function respondWithRpcPromise(_0x469d50,_0x1746a8,_0x535b7f){return new BPromise(function(_0x4ed5ab,_0x2dcfaf){var _0x1ef987=_0x535b7f?_0x535b7f:amiClient;return _0x1ef987[_0x0dbb('0x8')](_0x469d50,_0x1746a8)[_0x0dbb('0x9')](function(_0x122952){if(_0x122952[_0x0dbb('0xa')]){if(_0x122952[_0x0dbb('0xa')][_0x0dbb('0xb')]===0x1f4){return _0x2dcfaf(_0x122952[_0x0dbb('0xa')][_0x0dbb('0xc')]);}return _0x4ed5ab(_0x122952['error'][_0x0dbb('0xc')]);}else{_0x4ed5ab(_0x122952['result']);}})['catch'](function(_0x4f4aec){_0x2dcfaf(_0x4f4aec);});});}function respondWithResult(_0x14008f,_0x560056){_0x560056=_0x560056||0xc8;return function(_0x42f53c){if(_0x42f53c){return _0x14008f[_0x0dbb('0xd')](_0x560056)['json'](_0x42f53c);}return _0x14008f[_0x0dbb('0xe')](0x194);};}function handleError(_0x4f3f07,_0x5d064b){_0x5d064b=_0x5d064b||0x1f4;return function(_0x5d88bd){logger[_0x0dbb('0xa')](_0x5d88bd[_0x0dbb('0xf')]);if(_0x5d88bd[_0x0dbb('0x10')]){delete _0x5d88bd['name'];}_0x4f3f07[_0x0dbb('0xd')](_0x5d064b)[_0x0dbb('0x11')](_0x5d88bd);};}function findById(_0x2e1e3e){return function(_0x1a8adb){if(!_[_0x0dbb('0x12')](_0x2e1e3e)&&!_[_0x0dbb('0x12')](_0x1a8adb)&&!_[_0x0dbb('0x12')](_0x1a8adb[_0x0dbb('0x13')])){return _[_0x0dbb('0x14')](_0x1a8adb[_0x0dbb('0x13')],function(_0x5a5218){return _0x5a5218['id']==_0x2e1e3e;});}return null;};}exports[_0x0dbb('0x15')]=function(_0x76527c,_0x47a81b){return respondWithRpcPromise(_0x0dbb('0x16'),_0x76527c['query'])[_0x0dbb('0x9')](respondWithResult(_0x47a81b,null))['catch'](handleError(_0x47a81b,null));};exports['voiceChannelMixMonitor']=function(_0x3e6864,_0x545e8c){return respondWithRpcPromise(_0x0dbb('0x17'),_['merge'](_0x3e6864[_0x0dbb('0x18')],_0x3e6864['params']))[_0x0dbb('0x9')](respondWithResult(_0x545e8c,null))[_0x0dbb('0x19')](handleError(_0x545e8c,null));};exports[_0x0dbb('0x1a')]=function(_0x205dc7,_0x5f37ec){return respondWithRpcPromise(_0x0dbb('0x1b'),_[_0x0dbb('0x1c')](_0x205dc7[_0x0dbb('0x18')],_0x205dc7[_0x0dbb('0x1d')]))[_0x0dbb('0x9')](respondWithResult(_0x5f37ec,null))[_0x0dbb('0x19')](handleError(_0x5f37ec,null));};exports[_0x0dbb('0x1e')]=function(_0x193caa,_0x5434bd){return respondWithRpcPromise(_0x0dbb('0x1f'),_0x193caa[_0x0dbb('0x18')])[_0x0dbb('0x9')](respondWithResult(_0x5434bd,null))[_0x0dbb('0x19')](handleError(_0x5434bd,null));};exports[_0x0dbb('0x20')]=function(_0x4af82d,_0x4addce){return respondWithRpcPromise(_0x0dbb('0x1f'),_0x4af82d[_0x0dbb('0x18')])[_0x0dbb('0x9')](findById(_0x4af82d[_0x0dbb('0x1d')]['id']))[_0x0dbb('0x9')](respondWithResult(_0x4addce,null))[_0x0dbb('0x19')](handleError(_0x4addce,null));};exports['voiceQueuesPreview']=function(_0x32c9e4,_0x2a1dfb){return respondWithRpcPromise(_0x0dbb('0x21'),_[_0x0dbb('0x1c')](_0x32c9e4['query'],_0x32c9e4['params']))[_0x0dbb('0x9')](respondWithResult(_0x2a1dfb,null))[_0x0dbb('0x19')](handleError(_0x2a1dfb,null));};exports[_0x0dbb('0x22')]=function(_0x4a6d70,_0x1896be){return respondWithRpcPromise(_0x0dbb('0x23'),_0x4a6d70[_0x0dbb('0x18')])[_0x0dbb('0x9')](respondWithResult(_0x1896be,null))[_0x0dbb('0x19')](handleError(_0x1896be,null));};exports[_0x0dbb('0x24')]=function(_0x1999a5,_0xa156e){return respondWithRpcPromise(_0x0dbb('0x25'),_[_0x0dbb('0x1c')](_0x1999a5['query'],_0x1999a5[_0x0dbb('0x1d')]))[_0x0dbb('0x9')](respondWithResult(_0xa156e,null))[_0x0dbb('0x19')](handleError(_0xa156e,null));};exports[_0x0dbb('0x26')]=function(_0xf631d2,_0x11105a){return respondWithRpcPromise(_0x0dbb('0x27'),_[_0x0dbb('0x1c')](_0xf631d2[_0x0dbb('0x18')],_0xf631d2[_0x0dbb('0x1d')]))[_0x0dbb('0x9')](respondWithResult(_0x11105a,null))['catch'](handleError(_0x11105a,null));};exports[_0x0dbb('0x28')]=function(_0x34b384,_0x5bf570){return respondWithRpcPromise(_0x0dbb('0x29'),_[_0x0dbb('0x1c')](_0x34b384[_0x0dbb('0x18')],_0x34b384[_0x0dbb('0x1d')]))['then'](respondWithResult(_0x5bf570,null))['catch'](handleError(_0x5bf570,null));};exports[_0x0dbb('0x2a')]=function(_0x3c5efe,_0x26dafb){return respondWithRpcPromise(_0x0dbb('0x2b'),_0x3c5efe[_0x0dbb('0x18')])[_0x0dbb('0x9')](respondWithResult(_0x26dafb,null))[_0x0dbb('0x19')](handleError(_0x26dafb,null));};exports['outboundChannels']=function(_0x5a790d,_0x32e6ed){return respondWithRpcPromise(_0x0dbb('0x2c'),_0x5a790d[_0x0dbb('0x18')])[_0x0dbb('0x9')](respondWithResult(_0x32e6ed,null))[_0x0dbb('0x19')](handleError(_0x32e6ed,null));};exports['agents']=function(_0x4e88d3,_0x222136){var _0x22c047;return respondWithRpcPromise(_0x0dbb('0x2d'),_0x4e88d3[_0x0dbb('0x18')])[_0x0dbb('0x9')](function(_0x3406f0){_0x22c047=_0x3406f0;return respondWithRpcPromise(_0x0dbb('0x2d'),_0x4e88d3[_0x0dbb('0x18')],routingClient);})[_0x0dbb('0x9')](function(_0x479cd3){return _[_0x0dbb('0x1c')]({},_0x479cd3,_0x22c047);})[_0x0dbb('0x9')](respondWithResult(_0x222136,null))['catch'](handleError(_0x222136,null));};exports[_0x0dbb('0x2e')]=function(_0x5b3ba3,_0x327b9b){if(_0x5b3ba3['body']&&_0x5b3ba3[_0x0dbb('0x2f')][_0x0dbb('0x30')]&&_0x5b3ba3[_0x0dbb('0x31')]&&_0x5b3ba3[_0x0dbb('0x31')][_0x0dbb('0x10')]){for(var _0x4645fc in _0x5b3ba3['body'][_0x0dbb('0x30')]){if(_0x5b3ba3[_0x0dbb('0x2f')][_0x0dbb('0x30')][_0x0dbb('0x32')](_0x4645fc)){db[_0x0dbb('0x33')]['findAll']({'where':{'channel':_0x4645fc,'membername':_0x5b3ba3[_0x0dbb('0x31')]['name'],'type':_0x0dbb('0x34'),'exitAt':null,'uniqueid':_0x5b3ba3[_0x0dbb('0x2f')][_0x0dbb('0x30')][_0x4645fc]&&_0x5b3ba3[_0x0dbb('0x2f')]['interaction'][_0x4645fc][_0x0dbb('0x35')]?{'$notIn':_0x5b3ba3[_0x0dbb('0x2f')]['interaction'][_0x4645fc]}:{'$ne':null}}})[_0x0dbb('0x9')](function(_0x489b84){var _0x1551fc=moment()[_0x0dbb('0x36')](_0x0dbb('0x37'));for(var _0x4905fe=0x0,_0x471f3f=_0x489b84[_0x0dbb('0x35')];_0x4905fe<_0x471f3f;_0x4905fe+=0x1){_0x489b84[_0x4905fe][_0x0dbb('0x38')]({'exitAt':_0x1551fc});}});for(var _0x127e00=0x0;_0x127e00<_0x5b3ba3['body'][_0x0dbb('0x30')][_0x4645fc][_0x0dbb('0x35')];_0x127e00+=0x1){db[_0x0dbb('0x33')][_0x0dbb('0x39')]({'where':{'channel':_0x4645fc,'membername':_0x5b3ba3['user'][_0x0dbb('0x10')],'type':'INTERACTION','uniqueid':_0x5b3ba3['body']['interaction'][_0x4645fc][_0x127e00],'exitAt':null},'defaults':{'channel':_0x4645fc,'membername':_0x5b3ba3[_0x0dbb('0x31')][_0x0dbb('0x10')],'interface':_[_0x0dbb('0x12')](_0x5b3ba3[_0x0dbb('0x31')][_0x0dbb('0x3a')])?util[_0x0dbb('0x36')](_0x0dbb('0x3b'),_0x5b3ba3[_0x0dbb('0x31')][_0x0dbb('0x10')]):_0x5b3ba3[_0x0dbb('0x31')]['interface'],'type':'INTERACTION','enterAt':moment()[_0x0dbb('0x36')](_0x0dbb('0x37')),'role':'agent','internal':_0x5b3ba3[_0x0dbb('0x31')][_0x0dbb('0x3c')],'uniqueid':_0x5b3ba3[_0x0dbb('0x2f')][_0x0dbb('0x30')][_0x4645fc][_0x127e00]}});}}}}return respondWithRpcPromise(_0x0dbb('0x3d'),{'id':_0x5b3ba3[_0x0dbb('0x1d')]['id'],'capacity':_0x5b3ba3['body'][_0x0dbb('0x3e')]},routingClient)[_0x0dbb('0x9')](respondWithResult(_0x327b9b,null))[_0x0dbb('0x19')](handleError(_0x327b9b,null));};exports['telephones']=function(_0x58f3f3,_0x28bff9){return respondWithRpcPromise('Telephones',_0x58f3f3[_0x0dbb('0x18')])[_0x0dbb('0x9')](respondWithResult(_0x28bff9,null))[_0x0dbb('0x19')](handleError(_0x28bff9,null));};exports[_0x0dbb('0x3f')]=function(_0x537464,_0x44ecab){return respondWithRpcPromise(_0x0dbb('0x40'),_0x537464['query'])['then'](respondWithResult(_0x44ecab,null))[_0x0dbb('0x19')](handleError(_0x44ecab,null));};exports['campaigns']=function(_0x5e364c,_0x3a3557){return respondWithRpcPromise('Campaigns',_0x5e364c[_0x0dbb('0x18')])[_0x0dbb('0x9')](respondWithResult(_0x3a3557,null))[_0x0dbb('0x19')](handleError(_0x3a3557,null));};exports[_0x0dbb('0x41')]=function(_0x2aa4f6,_0x4a5f49){return respondWithRpcPromise(_0x0dbb('0x42'),_0x2aa4f6['query'],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x4a5f49,null))[_0x0dbb('0x19')](handleError(_0x4a5f49,null));};exports[_0x0dbb('0x43')]=function(_0xae7fa3,_0x48f3ee){return respondWithRpcPromise(_0x0dbb('0x42'),_0xae7fa3['query'],routingClient)[_0x0dbb('0x9')](findById(_0xae7fa3[_0x0dbb('0x1d')]['id']))[_0x0dbb('0x9')](respondWithResult(_0x48f3ee,null))['catch'](handleError(_0x48f3ee,null));};exports[_0x0dbb('0x44')]=function(_0x1b0765,_0x345502){return respondWithRpcPromise('MailQueues',_0x1b0765[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x345502,null))[_0x0dbb('0x19')](handleError(_0x345502,null));};exports[_0x0dbb('0x45')]=function(_0x1d73b0,_0x475af9){return respondWithRpcPromise('MailQueues',_0x1d73b0[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](findById(_0x1d73b0[_0x0dbb('0x1d')]['id']))[_0x0dbb('0x9')](respondWithResult(_0x475af9,null))['catch'](handleError(_0x475af9,null));};exports[_0x0dbb('0x46')]=function(_0x2f4c55,_0x1a0273){return respondWithRpcPromise(_0x0dbb('0x47'),_0x2f4c55[_0x0dbb('0x18')],mailClient)['then'](respondWithResult(_0x1a0273,null))[_0x0dbb('0x19')](handleError(_0x1a0273,null));};exports[_0x0dbb('0x48')]=function(_0x45d01d,_0x423340){return respondWithRpcPromise(_0x0dbb('0x49'),_0x45d01d[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x423340,null))[_0x0dbb('0x19')](handleError(_0x423340,null));};exports['showOpenchannelQueues']=function(_0x12eaf5,_0x8193fa){return respondWithRpcPromise(_0x0dbb('0x49'),_0x12eaf5[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](findById(_0x12eaf5[_0x0dbb('0x1d')]['id']))[_0x0dbb('0x9')](respondWithResult(_0x8193fa,null))[_0x0dbb('0x19')](handleError(_0x8193fa,null));};exports[_0x0dbb('0x4a')]=function(_0x2a72c7,_0x173c65){return respondWithRpcPromise(_0x0dbb('0x4b'),_0x2a72c7['query'],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x173c65,null))[_0x0dbb('0x19')](handleError(_0x173c65,null));};exports[_0x0dbb('0x4c')]=function(_0x5dfa15,_0xa73a43){return respondWithRpcPromise(_0x0dbb('0x4b'),_0x5dfa15['query'],routingClient)[_0x0dbb('0x9')](findById(_0x5dfa15[_0x0dbb('0x1d')]['id']))[_0x0dbb('0x9')](respondWithResult(_0xa73a43,null))['catch'](handleError(_0xa73a43,null));};exports['whatsappQueues']=function(_0x2124a8,_0x3e359f){return respondWithRpcPromise(_0x0dbb('0x4d'),_0x2124a8[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x3e359f,null))['catch'](handleError(_0x3e359f,null));};exports[_0x0dbb('0x4e')]=function(_0x503519,_0x31fd95){return respondWithRpcPromise(_0x0dbb('0x4d'),_0x503519[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](findById(_0x503519[_0x0dbb('0x1d')]['id']))[_0x0dbb('0x9')](respondWithResult(_0x31fd95,null))['catch'](handleError(_0x31fd95,null));};exports[_0x0dbb('0x4f')]=function(_0x47f159,_0x3fe03d){return respondWithRpcPromise(_0x0dbb('0x50'),_0x47f159[_0x0dbb('0x18')],routingClient)['then'](respondWithResult(_0x3fe03d,null))[_0x0dbb('0x19')](handleError(_0x3fe03d,null));};exports[_0x0dbb('0x51')]=function(_0x1ee385,_0x5ddf9e){return respondWithRpcPromise(_0x0dbb('0x50'),_0x1ee385[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](findById(_0x1ee385['params']['id']))[_0x0dbb('0x9')](respondWithResult(_0x5ddf9e,null))['catch'](handleError(_0x5ddf9e,null));};exports[_0x0dbb('0x52')]=function(_0x12a6b3,_0x458ab7){return respondWithRpcPromise(_0x0dbb('0x53'),_0x12a6b3[_0x0dbb('0x18')])['then'](respondWithResult(_0x458ab7,null))[_0x0dbb('0x19')](handleError(_0x458ab7,null));};exports[_0x0dbb('0x54')]=function(_0x5b1fb7,_0x43a05c){return respondWithRpcPromise(_0x0dbb('0x55'),_0x5b1fb7[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x43a05c,null))[_0x0dbb('0x19')](handleError(_0x43a05c,null));};exports[_0x0dbb('0x56')]=function(_0x3883ce,_0x5bd8a6){return respondWithRpcPromise(_0x0dbb('0x57'),_0x3883ce[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x5bd8a6,null))[_0x0dbb('0x19')](handleError(_0x5bd8a6,null));};exports['openchannelQueuesWaitingInteractions']=function(_0x5976a0,_0x4864a4){return respondWithRpcPromise(_0x0dbb('0x58'),_0x5976a0['query'],routingClient)['then'](respondWithResult(_0x4864a4,null))[_0x0dbb('0x19')](handleError(_0x4864a4,null));};exports[_0x0dbb('0x59')]=function(_0x37cfef,_0x3dbb78){return respondWithRpcPromise(_0x0dbb('0x58'),_0x37cfef[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](function(_0x4dd22e){if(_0x37cfef[_0x0dbb('0x18')][_0x0dbb('0x5a')]!==undefined){var _0x499fbb=_(_0x4dd22e[_0x0dbb('0x13')])[_0x0dbb('0x5b')]([_0x37cfef['query']['type'],_0x37cfef[_0x0dbb('0x1d')]['id']])[_0x0dbb('0x5c')](_0x0dbb('0x5d'))['uniq']()[_0x0dbb('0x5e')]();return _0x4dd22e[_0x0dbb('0x13')][_0x0dbb('0x5b')](function(_0x370f7e){return _0x499fbb[_0x0dbb('0x5f')](_0x370f7e[_0x0dbb('0x5d')])>-0x1;});}else{return _0x4dd22e[_0x0dbb('0x13')][_0x0dbb('0x5b')](function(_0x59064b){return _0x59064b['queue_id']===parseInt(_0x37cfef[_0x0dbb('0x1d')]['id']);});}})['then'](respondWithResult(_0x3dbb78,null))[_0x0dbb('0x19')](handleError(_0x3dbb78,null));};exports['smsQueuesWaitingInteractions']=function(_0x27fa32,_0x1b855c){return respondWithRpcPromise(_0x0dbb('0x60'),_0x27fa32['query'],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x1b855c,null))['catch'](handleError(_0x1b855c,null));};exports[_0x0dbb('0x61')]=function(_0x4d493c,_0x661c08){return respondWithRpcPromise(_0x0dbb('0x62'),_0x4d493c['query'],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x661c08,null))[_0x0dbb('0x19')](handleError(_0x661c08,null));};exports[_0x0dbb('0x63')]=function(_0x17d1a9,_0x21b696){return respondWithRpcPromise(_0x0dbb('0x64'),_0x17d1a9[_0x0dbb('0x18')],routingClient)[_0x0dbb('0x9')](respondWithResult(_0x21b696,null))['catch'](handleError(_0x21b696,null));};exports[_0x0dbb('0x65')]=function(_0x45df36){return function(_0x2f1ecc,_0x45eca7){var _0x5b9000,_0x2f5fe7;var _0x2b2bf4=_['capitalize'](_0x45df36);var _0x5b40da=_0x45df36===_0x0dbb('0x66')?_0x0dbb('0x67'):'Account';return db[_0x2b2bf4+_0x0dbb('0x68')]['findOne']({'raw':!![],'where':{'id':_0x2f1ecc[_0x0dbb('0x1d')]['id']}})['then'](function(_0x1d58c8){if(_[_0x0dbb('0x12')](_0x1d58c8)){throw new Error(_0x2b2bf4+_0x0dbb('0x69'));}_0x5b9000=_0x1d58c8;return db[_0x2b2bf4+'Message'][_0x0dbb('0x6a')]({'where':{'id':_0x2f1ecc[_0x0dbb('0x2f')]['messageId']},'include':[{'model':db[_0x2b2bf4+_0x0dbb('0x6b')],'as':'Interaction'},{'model':db[_0x2b2bf4+_0x5b40da],'as':_0x0dbb('0x6c')}]});})['then'](function(_0x4e5bee){if(_[_0x0dbb('0x12')](_0x4e5bee)){throw new Error(_0x2b2bf4+_0x0dbb('0x6d'));}_0x2f5fe7=_0x4e5bee;return _0x4e5bee[_0x0dbb('0x6e')]({'read':0x0,'readAt':null,'UserId':null});})[_0x0dbb('0x9')](function(){var _0x1eb446={'uniqueid':_0x45df36+'.'+_0x2f5fe7['id']+'.'+_0x2f5fe7['Interaction']['id'],'FromUserId':_0x2f1ecc['user']['id'],'type':_0x0dbb('0x6f')};_0x1eb446[_0x2b2bf4+_0x0dbb('0x70')]=_0x2f5fe7['id'];_0x1eb446[_0x2b2bf4+_0x0dbb('0x71')]=_0x2f5fe7[_0x0dbb('0x6b')]['id'];_0x1eb446[_0x0dbb('0x72')+_0x2b2bf4+_0x5b40da+'Id']=_0x2f5fe7[_0x0dbb('0x6c')]['id'];_0x1eb446['To'+_0x2b2bf4+'QueueId']=_0x5b9000['id'];return db[_0x2b2bf4+_0x0dbb('0x73')][_0x0dbb('0x74')](_0x1eb446);})['then'](function(){return respondWithRpcPromise(_0x0dbb('0x75'),{'channel':_0x45df36,'interaction':_0x2f5fe7[_0x0dbb('0x6b')],'message':_0x2f5fe7,'account':_0x2f5fe7[_0x0dbb('0x6c')],'applications':[{'id':0x0,'priority':0x1,'app':_0x0dbb('0x6f'),'appdata':_0x5b9000[_0x0dbb('0x10')]+','+(_0x2f5fe7[_0x0dbb('0x6c')]['queueTransferTimeout']||0x12c),'interval':_0x0dbb('0x76')}]},routingClient);})[_0x0dbb('0x9')](respondWithResult(_0x45eca7,null))[_0x0dbb('0x19')](handleError(_0x45eca7,null));};};exports[_0x0dbb('0x77')]=function(_0x2cc9de,_0x285c83){var _0xf84fe,_0x493ac0;if(_['isNil'](_0x2cc9de['body'][_0x0dbb('0x78')])){throw new Error(_0x0dbb('0x79'));}var _0x492039=_0x2cc9de[_0x0dbb('0x2f')]['channel'];var _0x44d0c1=_[_0x0dbb('0x7a')](_0x492039);var _0x1d4b75=_0x492039===_0x0dbb('0x66')?_0x0dbb('0x67'):_0x0dbb('0x6c');return db[_0x0dbb('0x7b')][_0x0dbb('0x6a')]({'raw':!![],'where':{'id':_0x2cc9de[_0x0dbb('0x1d')]['id'],'role':_0x0dbb('0x7c')}})['then'](function(_0x4246d9){if(_['isNil'](_0x4246d9)){throw new Error(_0x0dbb('0x7d'));}_0xf84fe=_0x4246d9;return db[_0x44d0c1+_0x0dbb('0x7e')][_0x0dbb('0x6a')]({'where':{'id':_0x2cc9de['body'][_0x0dbb('0x7f')]},'include':[{'model':db[_0x44d0c1+_0x0dbb('0x6b')],'as':_0x0dbb('0x6b')},{'model':db[_0x44d0c1+_0x1d4b75],'as':'Account'}]});})['then'](function(_0xc2073e){if(_['isNil'](_0xc2073e)){throw new Error(_0x44d0c1+_0x0dbb('0x6d'));}_0x493ac0=_0xc2073e;return _0xc2073e[_0x0dbb('0x6e')]({'read':0x0,'readAt':null,'UserId':null});})['then'](function(){var _0xf952a5={'uniqueid':_0x492039+'.'+_0x493ac0['id']+'.'+_0x493ac0['Interaction']['id'],'FromUserId':_0x2cc9de[_0x0dbb('0x31')]['id'],'type':_0x0dbb('0x6f'),'ToUserId':_0xf84fe['id']};_0xf952a5[_0x44d0c1+'MessageId']=_0x493ac0['id'];_0xf952a5[_0x44d0c1+_0x0dbb('0x71')]=_0x493ac0['Interaction']['id'];_0xf952a5[_0x0dbb('0x72')+_0x44d0c1+_0x1d4b75+'Id']=_0x493ac0[_0x0dbb('0x6c')]['id'];return db[_0x44d0c1+'TransferReport']['create'](_0xf952a5);})[_0x0dbb('0x9')](function(){return respondWithRpcPromise(_0x0dbb('0x75'),{'channel':_0x492039,'interaction':_0x493ac0[_0x0dbb('0x6b')],'message':_0x493ac0,'account':_0x493ac0[_0x0dbb('0x6c')],'applications':[{'id':0x0,'priority':0x1,'app':_0x0dbb('0x7c'),'appdata':_0xf84fe[_0x0dbb('0x10')]+','+(_0x493ac0[_0x0dbb('0x6c')][_0x0dbb('0x80')]||0x12c),'interval':_0x0dbb('0x76')}]},routingClient);})[_0x0dbb('0x9')](respondWithResult(_0x285c83,null))[_0x0dbb('0x19')](handleError(_0x285c83,null));};
\ No newline at end of file
+var _0x15a4=['catch','voiceChannelMixMonitor','VoiceChannelMixMonitor','merge','params','voiceChannelStopMixMonitor','VoiceChannelStopMixMonitor','voiceQueues','showVoiceQueues','VoiceQueues','updateVoiceQueue','UpdateVoiceQueue','body','voiceQueuesPreview','voiceQueuesChannels','VoiceQueuesChannels','voiceQueuesChannel','VoiceQueuesChannel','VoiceQueuesChannelHangup','voiceQueuesChannelRedirect','VoiceQueuesChannelRedirect','outbound','outboundChannels','agents','Agents','agentCapacity','interaction','user','MemberReport','findAll','INTERACTION','format','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','findOrCreate','interface','SIP/%s','internal','capacity','telephones','Telephones','Trunks','campaigns','chatQueues','ChatQueues','showChatQueues','mailQueues','MailQueues','MailAccounts','openchannelQueues','OpenchannelQueues','showOpenchannelQueues','smsQueues','showSmsQueues','SmsQueues','whatsappQueues','WhatsappQueues','faxQueues','showFaxQueues','FaxQueues','faxAccounts','FaxAccounts','chatQueuesWaitingInteractions','MailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','openchannelQueuesIdWaitingInteractions','filter','type','map','uniq','value','indexOf','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','WhatsappQueuesWaitingInteractions','faxQueuesWaitingInteractions','queueNotify','capitalize','Website','Account','findOne','\x20Queue\x20not\x20found','Message','messageId','Interaction','\x20Message\x20not\x20found','queue','MessageId','From','TransferReport','create','Start','*,*,*,*','agentNotify','channel','chat','agent','Agent\x20not\x20found','update','InteractionId','bluebird','moment','../../mysqldb','../../config/logger','api','jayson/promise','http','client','request','error','code','message','result','json','sendStatus','name','status','send','isNil','rows','find','voiceChannels','query','then'];(function(_0x59ee6f,_0x450239){var _0x4c0979=function(_0x565e92){while(--_0x565e92){_0x59ee6f['push'](_0x59ee6f['shift']());}};_0x4c0979(++_0x450239);}(_0x15a4,0x65));var _0x415a=function(_0x2be1ac,_0xfedc23){_0x2be1ac=_0x2be1ac-0x0;var _0x1049a8=_0x15a4[_0x2be1ac];return _0x1049a8;};'use strict';var BPromise=require(_0x415a('0x0'));var moment=require(_0x415a('0x1'));var _=require('lodash');var util=require('util');var db=require(_0x415a('0x2'))['db'];var logger=require(_0x415a('0x3'))(_0x415a('0x4'));var jayson=require(_0x415a('0x5'));var amiClient=jayson['client'][_0x415a('0x6')]({'port':0x232a});var mailClient=jayson[_0x415a('0x7')]['http']({'port':0x232b});var routingClient=jayson[_0x415a('0x7')][_0x415a('0x6')]({'port':0x232c});function respondWithRpcPromise(_0x31b926,_0x4ae538,_0x2fe0b8){return new BPromise(function(_0x468e6b,_0x171585){var _0x48d387=_0x2fe0b8?_0x2fe0b8:amiClient;return _0x48d387[_0x415a('0x8')](_0x31b926,_0x4ae538)['then'](function(_0xa977ef){if(_0xa977ef[_0x415a('0x9')]){if(_0xa977ef['error'][_0x415a('0xa')]===0x1f4){return _0x171585(_0xa977ef[_0x415a('0x9')][_0x415a('0xb')]);}return _0x468e6b(_0xa977ef[_0x415a('0x9')][_0x415a('0xb')]);}else{_0x468e6b(_0xa977ef[_0x415a('0xc')]);}})['catch'](function(_0xcc7ac0){_0x171585(_0xcc7ac0);});});}function respondWithResult(_0x46a383,_0x14a4ee){_0x14a4ee=_0x14a4ee||0xc8;return function(_0xe809d9){if(_0xe809d9){return _0x46a383['status'](_0x14a4ee)[_0x415a('0xd')](_0xe809d9);}return _0x46a383[_0x415a('0xe')](0x194);};}function handleError(_0x41c029,_0x514a0f){_0x514a0f=_0x514a0f||0x1f4;return function(_0x2371e3){logger[_0x415a('0x9')](_0x2371e3['stack']);if(_0x2371e3['name']){delete _0x2371e3[_0x415a('0xf')];}_0x41c029[_0x415a('0x10')](_0x514a0f)[_0x415a('0x11')](_0x2371e3);};}function findById(_0x5d21a3){return function(_0x408271){if(!_['isNil'](_0x5d21a3)&&!_[_0x415a('0x12')](_0x408271)&&!_[_0x415a('0x12')](_0x408271[_0x415a('0x13')])){return _[_0x415a('0x14')](_0x408271[_0x415a('0x13')],function(_0x2b99ed){return _0x2b99ed['id']==_0x5d21a3;});}return null;};}exports[_0x415a('0x15')]=function(_0x183ebd,_0x29f458){return respondWithRpcPromise('VoiceChannels',_0x183ebd[_0x415a('0x16')])[_0x415a('0x17')](respondWithResult(_0x29f458,null))[_0x415a('0x18')](handleError(_0x29f458,null));};exports[_0x415a('0x19')]=function(_0xa5ce34,_0x14b69a){return respondWithRpcPromise(_0x415a('0x1a'),_[_0x415a('0x1b')](_0xa5ce34[_0x415a('0x16')],_0xa5ce34[_0x415a('0x1c')]))[_0x415a('0x17')](respondWithResult(_0x14b69a,null))[_0x415a('0x18')](handleError(_0x14b69a,null));};exports[_0x415a('0x1d')]=function(_0x2bc2ee,_0x3a9001){return respondWithRpcPromise(_0x415a('0x1e'),_[_0x415a('0x1b')](_0x2bc2ee[_0x415a('0x16')],_0x2bc2ee[_0x415a('0x1c')]))[_0x415a('0x17')](respondWithResult(_0x3a9001,null))['catch'](handleError(_0x3a9001,null));};exports[_0x415a('0x1f')]=function(_0x5beca0,_0x27b82e){return respondWithRpcPromise('VoiceQueues',_0x5beca0[_0x415a('0x16')])['then'](respondWithResult(_0x27b82e,null))['catch'](handleError(_0x27b82e,null));};exports[_0x415a('0x20')]=function(_0x5954d0,_0x22c34f){return respondWithRpcPromise(_0x415a('0x21'),_0x5954d0[_0x415a('0x16')])['then'](findById(_0x5954d0[_0x415a('0x1c')]['id']))[_0x415a('0x17')](respondWithResult(_0x22c34f,null))[_0x415a('0x18')](handleError(_0x22c34f,null));};exports[_0x415a('0x22')]=function(_0x4c9d46,_0xa4e0bf){return respondWithRpcPromise(_0x415a('0x23'),_[_0x415a('0x1b')](_0x4c9d46[_0x415a('0x24')],_0x4c9d46[_0x415a('0x1c')]))[_0x415a('0x17')](respondWithResult(_0xa4e0bf,null))[_0x415a('0x18')](handleError(_0xa4e0bf,null));};exports[_0x415a('0x25')]=function(_0x291af4,_0xaa0060){return respondWithRpcPromise('VoiceQueuesPreview',_[_0x415a('0x1b')](_0x291af4[_0x415a('0x16')],_0x291af4['params']))['then'](respondWithResult(_0xaa0060,null))[_0x415a('0x18')](handleError(_0xaa0060,null));};exports[_0x415a('0x26')]=function(_0x4c33e3,_0x14ba4b){return respondWithRpcPromise(_0x415a('0x27'),_0x4c33e3[_0x415a('0x16')])['then'](respondWithResult(_0x14ba4b,null))[_0x415a('0x18')](handleError(_0x14ba4b,null));};exports[_0x415a('0x28')]=function(_0xd2e21e,_0x5f5689){return respondWithRpcPromise(_0x415a('0x29'),_[_0x415a('0x1b')](_0xd2e21e['query'],_0xd2e21e[_0x415a('0x1c')]))[_0x415a('0x17')](respondWithResult(_0x5f5689,null))['catch'](handleError(_0x5f5689,null));};exports['voiceQueuesChannelHangup']=function(_0x266fe6,_0x331816){return respondWithRpcPromise(_0x415a('0x2a'),_[_0x415a('0x1b')](_0x266fe6[_0x415a('0x16')],_0x266fe6[_0x415a('0x1c')]))[_0x415a('0x17')](respondWithResult(_0x331816,null))[_0x415a('0x18')](handleError(_0x331816,null));};exports[_0x415a('0x2b')]=function(_0x5f3d0e,_0x2a6933){return respondWithRpcPromise(_0x415a('0x2c'),_[_0x415a('0x1b')](_0x5f3d0e[_0x415a('0x16')],_0x5f3d0e['params']))[_0x415a('0x17')](respondWithResult(_0x2a6933,null))[_0x415a('0x18')](handleError(_0x2a6933,null));};exports[_0x415a('0x2d')]=function(_0x2ac1fb,_0x2f889e){return respondWithRpcPromise('Outbound',_0x2ac1fb[_0x415a('0x16')])[_0x415a('0x17')](respondWithResult(_0x2f889e,null))[_0x415a('0x18')](handleError(_0x2f889e,null));};exports[_0x415a('0x2e')]=function(_0x3c46ed,_0x13eda4){return respondWithRpcPromise('OutboundChannels',_0x3c46ed[_0x415a('0x16')])['then'](respondWithResult(_0x13eda4,null))['catch'](handleError(_0x13eda4,null));};exports[_0x415a('0x2f')]=function(_0x31291b,_0x41eca5){var _0x7a40e7;return respondWithRpcPromise(_0x415a('0x30'),_0x31291b[_0x415a('0x16')])['then'](function(_0x4ac4df){_0x7a40e7=_0x4ac4df;return respondWithRpcPromise(_0x415a('0x30'),_0x31291b['query'],routingClient);})[_0x415a('0x17')](function(_0x3a09c6){return _['merge']({},_0x3a09c6,_0x7a40e7);})['then'](respondWithResult(_0x41eca5,null))[_0x415a('0x18')](handleError(_0x41eca5,null));};exports[_0x415a('0x31')]=function(_0x165d4f,_0x555cea){if(_0x165d4f[_0x415a('0x24')]&&_0x165d4f[_0x415a('0x24')][_0x415a('0x32')]&&_0x165d4f[_0x415a('0x33')]&&_0x165d4f[_0x415a('0x33')][_0x415a('0xf')]){for(var _0x548a0b in _0x165d4f['body'][_0x415a('0x32')]){if(_0x165d4f[_0x415a('0x24')][_0x415a('0x32')]['hasOwnProperty'](_0x548a0b)){db[_0x415a('0x34')][_0x415a('0x35')]({'where':{'channel':_0x548a0b,'membername':_0x165d4f[_0x415a('0x33')][_0x415a('0xf')],'type':_0x415a('0x36'),'exitAt':null,'uniqueid':_0x165d4f[_0x415a('0x24')][_0x415a('0x32')][_0x548a0b]&&_0x165d4f[_0x415a('0x24')]['interaction'][_0x548a0b]['length']?{'$notIn':_0x165d4f[_0x415a('0x24')][_0x415a('0x32')][_0x548a0b]}:{'$ne':null}}})['then'](function(_0x300de0){var _0x5a0632=moment()[_0x415a('0x37')](_0x415a('0x38'));for(var _0x4250d5=0x0,_0x1188b8=_0x300de0['length'];_0x4250d5<_0x1188b8;_0x4250d5+=0x1){_0x300de0[_0x4250d5][_0x415a('0x39')]({'exitAt':_0x5a0632});}});for(var _0x815b45=0x0;_0x815b45<_0x165d4f[_0x415a('0x24')][_0x415a('0x32')][_0x548a0b]['length'];_0x815b45+=0x1){db[_0x415a('0x34')][_0x415a('0x3a')]({'where':{'channel':_0x548a0b,'membername':_0x165d4f['user'][_0x415a('0xf')],'type':_0x415a('0x36'),'uniqueid':_0x165d4f[_0x415a('0x24')][_0x415a('0x32')][_0x548a0b][_0x815b45],'exitAt':null},'defaults':{'channel':_0x548a0b,'membername':_0x165d4f['user'][_0x415a('0xf')],'interface':_['isNil'](_0x165d4f['user'][_0x415a('0x3b')])?util[_0x415a('0x37')](_0x415a('0x3c'),_0x165d4f['user']['name']):_0x165d4f[_0x415a('0x33')][_0x415a('0x3b')],'type':_0x415a('0x36'),'enterAt':moment()['format'](_0x415a('0x38')),'role':'agent','internal':_0x165d4f[_0x415a('0x33')][_0x415a('0x3d')],'uniqueid':_0x165d4f[_0x415a('0x24')][_0x415a('0x32')][_0x548a0b][_0x815b45]}});}}}}return respondWithRpcPromise('AgentCapacity',{'id':_0x165d4f[_0x415a('0x1c')]['id'],'capacity':_0x165d4f[_0x415a('0x24')][_0x415a('0x3e')]},routingClient)[_0x415a('0x17')](respondWithResult(_0x555cea,null))[_0x415a('0x18')](handleError(_0x555cea,null));};exports[_0x415a('0x3f')]=function(_0x7409ae,_0x2c7a44){return respondWithRpcPromise(_0x415a('0x40'),_0x7409ae[_0x415a('0x16')])[_0x415a('0x17')](respondWithResult(_0x2c7a44,null))[_0x415a('0x18')](handleError(_0x2c7a44,null));};exports['trunks']=function(_0xd4d8c5,_0x38e4da){return respondWithRpcPromise(_0x415a('0x41'),_0xd4d8c5[_0x415a('0x16')])[_0x415a('0x17')](respondWithResult(_0x38e4da,null))[_0x415a('0x18')](handleError(_0x38e4da,null));};exports[_0x415a('0x42')]=function(_0x2d88e7,_0x31de8d){return respondWithRpcPromise('Campaigns',_0x2d88e7[_0x415a('0x16')])[_0x415a('0x17')](respondWithResult(_0x31de8d,null))[_0x415a('0x18')](handleError(_0x31de8d,null));};exports[_0x415a('0x43')]=function(_0x21b9cd,_0x380189){return respondWithRpcPromise(_0x415a('0x44'),_0x21b9cd[_0x415a('0x16')],routingClient)[_0x415a('0x17')](respondWithResult(_0x380189,null))[_0x415a('0x18')](handleError(_0x380189,null));};exports[_0x415a('0x45')]=function(_0x5ebfb4,_0x27b4d3){return respondWithRpcPromise(_0x415a('0x44'),_0x5ebfb4['query'],routingClient)[_0x415a('0x17')](findById(_0x5ebfb4['params']['id']))[_0x415a('0x17')](respondWithResult(_0x27b4d3,null))['catch'](handleError(_0x27b4d3,null));};exports[_0x415a('0x46')]=function(_0xaf8e9c,_0x3030bf){return respondWithRpcPromise(_0x415a('0x47'),_0xaf8e9c[_0x415a('0x16')],routingClient)[_0x415a('0x17')](respondWithResult(_0x3030bf,null))[_0x415a('0x18')](handleError(_0x3030bf,null));};exports['showMailQueues']=function(_0x300f8e,_0xd89788){return respondWithRpcPromise('MailQueues',_0x300f8e[_0x415a('0x16')],routingClient)[_0x415a('0x17')](findById(_0x300f8e['params']['id']))['then'](respondWithResult(_0xd89788,null))[_0x415a('0x18')](handleError(_0xd89788,null));};exports['mailAccounts']=function(_0xeac833,_0x5d2dc7){return respondWithRpcPromise(_0x415a('0x48'),_0xeac833['query'],mailClient)[_0x415a('0x17')](respondWithResult(_0x5d2dc7,null))[_0x415a('0x18')](handleError(_0x5d2dc7,null));};exports[_0x415a('0x49')]=function(_0x54ff5b,_0x4fc564){return respondWithRpcPromise(_0x415a('0x4a'),_0x54ff5b['query'],routingClient)[_0x415a('0x17')](respondWithResult(_0x4fc564,null))['catch'](handleError(_0x4fc564,null));};exports[_0x415a('0x4b')]=function(_0x2d588c,_0x426576){return respondWithRpcPromise(_0x415a('0x4a'),_0x2d588c[_0x415a('0x16')],routingClient)[_0x415a('0x17')](findById(_0x2d588c[_0x415a('0x1c')]['id']))['then'](respondWithResult(_0x426576,null))[_0x415a('0x18')](handleError(_0x426576,null));};exports[_0x415a('0x4c')]=function(_0x95a635,_0x182d84){return respondWithRpcPromise('SmsQueues',_0x95a635['query'],routingClient)['then'](respondWithResult(_0x182d84,null))[_0x415a('0x18')](handleError(_0x182d84,null));};exports[_0x415a('0x4d')]=function(_0x2f8c43,_0xf35cd7){return respondWithRpcPromise(_0x415a('0x4e'),_0x2f8c43[_0x415a('0x16')],routingClient)[_0x415a('0x17')](findById(_0x2f8c43[_0x415a('0x1c')]['id']))['then'](respondWithResult(_0xf35cd7,null))[_0x415a('0x18')](handleError(_0xf35cd7,null));};exports[_0x415a('0x4f')]=function(_0x2898d6,_0x4e615e){return respondWithRpcPromise(_0x415a('0x50'),_0x2898d6['query'],routingClient)['then'](respondWithResult(_0x4e615e,null))['catch'](handleError(_0x4e615e,null));};exports['showWhatsappQueues']=function(_0x507798,_0x2698db){return respondWithRpcPromise(_0x415a('0x50'),_0x507798[_0x415a('0x16')],routingClient)[_0x415a('0x17')](findById(_0x507798[_0x415a('0x1c')]['id']))['then'](respondWithResult(_0x2698db,null))[_0x415a('0x18')](handleError(_0x2698db,null));};exports[_0x415a('0x51')]=function(_0x2deba4,_0x6ab299){return respondWithRpcPromise('FaxQueues',_0x2deba4[_0x415a('0x16')],routingClient)[_0x415a('0x17')](respondWithResult(_0x6ab299,null))[_0x415a('0x18')](handleError(_0x6ab299,null));};exports[_0x415a('0x52')]=function(_0x4842a0,_0xefe316){return respondWithRpcPromise(_0x415a('0x53'),_0x4842a0[_0x415a('0x16')],routingClient)['then'](findById(_0x4842a0[_0x415a('0x1c')]['id']))[_0x415a('0x17')](respondWithResult(_0xefe316,null))[_0x415a('0x18')](handleError(_0xefe316,null));};exports[_0x415a('0x54')]=function(_0x17a215,_0x22862d){return respondWithRpcPromise(_0x415a('0x55'),_0x17a215[_0x415a('0x16')])['then'](respondWithResult(_0x22862d,null))['catch'](handleError(_0x22862d,null));};exports[_0x415a('0x56')]=function(_0x3b221e,_0xa40a58){return respondWithRpcPromise('ChatQueuesWaitingInteractions',_0x3b221e[_0x415a('0x16')],routingClient)[_0x415a('0x17')](respondWithResult(_0xa40a58,null))[_0x415a('0x18')](handleError(_0xa40a58,null));};exports['mailQueuesWaitingInteractions']=function(_0x1a02f5,_0x12b5ea){return respondWithRpcPromise(_0x415a('0x57'),_0x1a02f5['query'],routingClient)['then'](respondWithResult(_0x12b5ea,null))[_0x415a('0x18')](handleError(_0x12b5ea,null));};exports[_0x415a('0x58')]=function(_0x121e85,_0x2c3d68){return respondWithRpcPromise(_0x415a('0x59'),_0x121e85[_0x415a('0x16')],routingClient)[_0x415a('0x17')](respondWithResult(_0x2c3d68,null))[_0x415a('0x18')](handleError(_0x2c3d68,null));};exports[_0x415a('0x5a')]=function(_0x818934,_0x114057){return respondWithRpcPromise(_0x415a('0x59'),_0x818934[_0x415a('0x16')],routingClient)[_0x415a('0x17')](function(_0x54d865){if(_0x818934[_0x415a('0x16')]['type']!==undefined){var _0x3e9034=_(_0x54d865[_0x415a('0x13')])[_0x415a('0x5b')]([_0x818934['query'][_0x415a('0x5c')],_0x818934[_0x415a('0x1c')]['id']])[_0x415a('0x5d')]('queue_id')[_0x415a('0x5e')]()[_0x415a('0x5f')]();return _0x54d865[_0x415a('0x13')]['filter'](function(_0x2fadd5){return _0x3e9034[_0x415a('0x60')](_0x2fadd5['queue_id'])>-0x1;});}else{return _0x54d865[_0x415a('0x13')][_0x415a('0x5b')](function(_0x1cb794){return _0x1cb794['queue_id']===parseInt(_0x818934[_0x415a('0x1c')]['id']);});}})[_0x415a('0x17')](respondWithResult(_0x114057,null))[_0x415a('0x18')](handleError(_0x114057,null));};exports[_0x415a('0x61')]=function(_0x30f704,_0x55f0a1){return respondWithRpcPromise(_0x415a('0x62'),_0x30f704[_0x415a('0x16')],routingClient)['then'](respondWithResult(_0x55f0a1,null))['catch'](handleError(_0x55f0a1,null));};exports['whatsappQueuesWaitingInteractions']=function(_0x4b89bb,_0x354d21){return respondWithRpcPromise(_0x415a('0x63'),_0x4b89bb['query'],routingClient)[_0x415a('0x17')](respondWithResult(_0x354d21,null))['catch'](handleError(_0x354d21,null));};exports[_0x415a('0x64')]=function(_0x1a6ee4,_0x4b798a){return respondWithRpcPromise('FaxQueuesWaitingInteractions',_0x1a6ee4['query'],routingClient)[_0x415a('0x17')](respondWithResult(_0x4b798a,null))[_0x415a('0x18')](handleError(_0x4b798a,null));};exports[_0x415a('0x65')]=function(_0x2741bc){return function(_0x5ef532,_0x5bb5d0){var _0x35443d,_0x534deb;var _0x125cd7=_[_0x415a('0x66')](_0x2741bc);var _0x5bcff8=_0x2741bc==='chat'?_0x415a('0x67'):_0x415a('0x68');return db[_0x125cd7+'Queue'][_0x415a('0x69')]({'raw':!![],'where':{'id':_0x5ef532[_0x415a('0x1c')]['id']}})[_0x415a('0x17')](function(_0x3e1b90){if(_[_0x415a('0x12')](_0x3e1b90)){throw new Error(_0x125cd7+_0x415a('0x6a'));}_0x35443d=_0x3e1b90;return db[_0x125cd7+_0x415a('0x6b')]['findOne']({'where':{'id':_0x5ef532[_0x415a('0x24')][_0x415a('0x6c')]},'include':[{'model':db[_0x125cd7+_0x415a('0x6d')],'as':_0x415a('0x6d')},{'model':db[_0x125cd7+_0x5bcff8],'as':_0x415a('0x68')}]});})[_0x415a('0x17')](function(_0x56f8df){if(_['isNil'](_0x56f8df)){throw new Error(_0x125cd7+_0x415a('0x6e'));}_0x534deb=_0x56f8df;return _0x56f8df['update']({'read':0x0,'readAt':null,'UserId':null});})[_0x415a('0x17')](function(){var _0xa9c6a4={'uniqueid':_0x2741bc+'.'+_0x534deb['id']+'.'+_0x534deb[_0x415a('0x6d')]['id'],'FromUserId':_0x5ef532[_0x415a('0x33')]['id'],'type':_0x415a('0x6f')};_0xa9c6a4[_0x125cd7+_0x415a('0x70')]=_0x534deb['id'];_0xa9c6a4[_0x125cd7+'InteractionId']=_0x534deb[_0x415a('0x6d')]['id'];_0xa9c6a4[_0x415a('0x71')+_0x125cd7+_0x5bcff8+'Id']=_0x534deb['Account']['id'];_0xa9c6a4['To'+_0x125cd7+'QueueId']=_0x35443d['id'];return db[_0x125cd7+_0x415a('0x72')][_0x415a('0x73')](_0xa9c6a4);})[_0x415a('0x17')](function(){return respondWithRpcPromise(_0x415a('0x74'),{'channel':_0x2741bc,'interaction':_0x534deb[_0x415a('0x6d')],'message':_0x534deb,'account':_0x534deb[_0x415a('0x68')],'applications':[{'id':0x0,'priority':0x1,'app':_0x415a('0x6f'),'appdata':_0x35443d[_0x415a('0xf')]+','+(_0x534deb['Account']['queueTransferTimeout']||0x12c),'interval':_0x415a('0x75')}]},routingClient);})[_0x415a('0x17')](respondWithResult(_0x5bb5d0,null))[_0x415a('0x18')](handleError(_0x5bb5d0,null));};};exports[_0x415a('0x76')]=function(_0xd36c37,_0x772123){var _0x461cbe,_0x1e34f6;if(_['isNil'](_0xd36c37['body'][_0x415a('0x77')])){throw new Error('Channel\x20field\x20is\x20mandatory');}var _0x171d96=_0xd36c37[_0x415a('0x24')][_0x415a('0x77')];var _0x5b9beb=_[_0x415a('0x66')](_0x171d96);var _0x57c52a=_0x171d96===_0x415a('0x78')?_0x415a('0x67'):_0x415a('0x68');return db['User']['findOne']({'raw':!![],'where':{'id':_0xd36c37[_0x415a('0x1c')]['id'],'role':_0x415a('0x79')}})[_0x415a('0x17')](function(_0x1db23b){if(_[_0x415a('0x12')](_0x1db23b)){throw new Error(_0x415a('0x7a'));}_0x461cbe=_0x1db23b;return db[_0x5b9beb+_0x415a('0x6b')][_0x415a('0x69')]({'where':{'id':_0xd36c37[_0x415a('0x24')][_0x415a('0x6c')]},'include':[{'model':db[_0x5b9beb+_0x415a('0x6d')],'as':'Interaction'},{'model':db[_0x5b9beb+_0x57c52a],'as':_0x415a('0x68')}]});})[_0x415a('0x17')](function(_0x43b9f5){if(_[_0x415a('0x12')](_0x43b9f5)){throw new Error(_0x5b9beb+_0x415a('0x6e'));}_0x1e34f6=_0x43b9f5;return _0x43b9f5[_0x415a('0x7b')]({'read':0x0,'readAt':null,'UserId':null});})[_0x415a('0x17')](function(){var _0x337dbf={'uniqueid':_0x171d96+'.'+_0x1e34f6['id']+'.'+_0x1e34f6['Interaction']['id'],'FromUserId':_0xd36c37[_0x415a('0x33')]['id'],'type':_0x415a('0x6f'),'ToUserId':_0x461cbe['id']};_0x337dbf[_0x5b9beb+_0x415a('0x70')]=_0x1e34f6['id'];_0x337dbf[_0x5b9beb+_0x415a('0x7c')]=_0x1e34f6[_0x415a('0x6d')]['id'];_0x337dbf['From'+_0x5b9beb+_0x57c52a+'Id']=_0x1e34f6[_0x415a('0x68')]['id'];return db[_0x5b9beb+_0x415a('0x72')]['create'](_0x337dbf);})['then'](function(){return respondWithRpcPromise(_0x415a('0x74'),{'channel':_0x171d96,'interaction':_0x1e34f6[_0x415a('0x6d')],'message':_0x1e34f6,'account':_0x1e34f6[_0x415a('0x68')],'applications':[{'id':0x0,'priority':0x1,'app':_0x415a('0x79'),'appdata':_0x461cbe['name']+','+(_0x1e34f6[_0x415a('0x68')]['agentTransferTimeout']||0x12c),'interval':_0x415a('0x75')}]},routingClient);})[_0x415a('0x17')](respondWithResult(_0x772123,null))[_0x415a('0x18')](handleError(_0x772123,null));};
\ No newline at end of file