Built motion from commit (unavailable).|2.4.11
[motion2.git] / server / services / ami / report / voiceQueueReport.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x6faf=['queueReports','[FullyBooted]\x20clear\x20realtime','clearQueueReport','emitVoiceQueueChannelRemove','inspect','emit','emitVoiceQueueChannelSave','format','voice:queue:%s','voice_queue_channel:save','voice_queue_channel:remove','emitVoiceQueueSummary','type','inbound','strategy','answered','available','sumDuration','sumHoldTime','total','unmanaged','abandoned','waiting','Trunk','name','active','callerid','Interval','stringify','voice_queue:save','isNotNull','loopQueueShow','[queues]','then','flagQueueSummary','[queuesummary]','queue','countBy','callers','toNumber','loggedin','[syncQueueSummary][VoiceQueueReport]','syncNewExten','uniqueid','queuecallerjoinAt','position','count','merge','pick','push','[syncQueueCallerJoin][VoiceQueueReport]','queuecallercomplete','holdtime','originalposition','queuecallerabandonAt','YYYY-MM-DD\x20HH:mm:ss','queuecallerexitreason','lastAssignedTo','[syncQueueCallerAbandon][VoiceQueueReport]','last','queuecallerleaveAt','connectedlinename','COMPLETEDBYAGENT','[syncAgentConnect][VoiceQueueReport]','assigned','membername','queuecallerexit','queuecallerexitAt','reason','transfer','COMPLETED','startsWith','channel','toLowerCase','local/','linkedid','FORWARDTRANSFER','transfertype','FORWARD','destexten','transferuniqueid','COMPLETEDBY','toUpperCase','[syncAgentComplete][VoiceQueueReport]','syncVarSet','keys','variable','CONTINUE','value','queueposition','EXITWITHKEY','[syncVarSet][VoiceQueueReport]','addVariable','rtpaudioqos','rtpaudioqosbridged','rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrtt','rtpaudioqosrttbridged','bridgepvtcallid','membercalls','memberdynamic','memberinterface','memberlastcall','memberpenalty','memberrealtime','includes','length','seconds','milliseconds','diff','sumBillable','queuecallercompleteAt','lastevent','syncAttendedTransfer','transfereeuniqueid','transferexten','secondtransfererexten','secondtransfereruniqueid','ATTENDED','transfertargetuniqueid','origtransfererexten','origtransfereruniqueid','[syncAttendedTransfer][VoiceQueueReport]','extension','BlindTransfer','context','transfererchannel','[syncBlindTransfer][VoiceQueueReport]','mohstarttime','[syncMusicOnHoldStart][VoiceQueueReport]','exports','moment','bluebird','util','md5','ioredis','../../../config/logger','../ami','../model/queueReport','redis','defaults','localhost','socket.io-emitter','prototype','enqueue','tail','finally','sequence','agents','channels','voiceQueues','campaigns','variables','queuesummary','syncQueueSummary','bind','queuesummarycomplete','syncQueueSummaryComplete','queuecallerjoin','syncQueueCallerJoin','queuecallerabandon','syncQueueCallerAbandon','queuecallerleave','syncQueueCallerLeave','agentcomplete','syncAgentComplete','syncAgentConnect','varset','hangup','syncHangup','syncFullyBooted','musiconholdstart','syncMusicOnHoldStart','syncMusicOnHoldStop','attendedtransfer','loopQueueSummary','isUndefined','isEmpty','hasOwnProperty','originated','talking','unlockRR','clearZombieChannels','switch','isNil','status','catch','message','No\x20such\x20channel','error'];(function(_0x18f3d1,_0x390629){var _0x3872dd=function(_0x583954){while(--_0x583954){_0x18f3d1['push'](_0x18f3d1['shift']());}};_0x3872dd(++_0x390629);}(_0x6faf,0x147));var _0xf6fa=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x6faf[_0x14add3];return _0x4a174f;};'use strict';var _=require('lodash');var moment=require(_0xf6fa('0x0'));var BPromise=require(_0xf6fa('0x1'));var util=require(_0xf6fa('0x2'));var md5=require(_0xf6fa('0x3'));var Redis=require(_0xf6fa('0x4'));var config=require('../../../config/environment');var logger=require(_0xf6fa('0x5'))('ami');var ami=require(_0xf6fa('0x6'));var QueueReport=require(_0xf6fa('0x7'));config[_0xf6fa('0x8')]=_[_0xf6fa('0x9')](config['redis'],{'host':_0xf6fa('0xa'),'port':0x18eb});var io=require(_0xf6fa('0xb'))(new Redis(config[_0xf6fa('0x8')]));var Sequence=function(){};Sequence[_0xf6fa('0xc')][_0xf6fa('0xd')]=function(_0x51c7fe){this[_0xf6fa('0xe')]=this['tail']?this['tail'][_0xf6fa('0xf')](_0x51c7fe):_0x51c7fe();};function VoiceQueueReport(_0x97ec53){this[_0xf6fa('0x10')]=new Sequence();this['queueReports']={};this[_0xf6fa('0x11')]=_0x97ec53['agents'];this[_0xf6fa('0x12')]=_0x97ec53['queueChannels'];this['voiceQueues']=_0x97ec53[_0xf6fa('0x13')];this['flagQueueSummary']=!![];this[_0xf6fa('0x14')]=_0x97ec53['campaigns'];this[_0xf6fa('0x15')]={};ami['on'](_0xf6fa('0x16'),this[_0xf6fa('0x17')][_0xf6fa('0x18')](this));ami['on'](_0xf6fa('0x19'),this[_0xf6fa('0x1a')][_0xf6fa('0x18')](this));ami['on'](_0xf6fa('0x1b'),this[_0xf6fa('0x1c')]['bind'](this));ami['on'](_0xf6fa('0x1d'),this[_0xf6fa('0x1e')]['bind'](this));ami['on'](_0xf6fa('0x1f'),this[_0xf6fa('0x20')][_0xf6fa('0x18')](this));ami['on'](_0xf6fa('0x21'),this[_0xf6fa('0x22')][_0xf6fa('0x18')](this));ami['on']('agentconnect',this[_0xf6fa('0x23')][_0xf6fa('0x18')](this));ami['on'](_0xf6fa('0x24'),this['syncVarSet'][_0xf6fa('0x18')](this));ami['on'](_0xf6fa('0x25'),this[_0xf6fa('0x26')][_0xf6fa('0x18')](this));ami['on']('fullybooted',this[_0xf6fa('0x27')][_0xf6fa('0x18')](this));ami['on'](_0xf6fa('0x28'),this[_0xf6fa('0x29')][_0xf6fa('0x18')](this));ami['on']('musiconholdstop',this[_0xf6fa('0x2a')][_0xf6fa('0x18')](this));ami['on'](_0xf6fa('0x2b'),this['syncAttendedTransfer'][_0xf6fa('0x18')](this));ami['on']('blindtransfer',this['syncBlindTransfer'][_0xf6fa('0x18')](this));this[_0xf6fa('0x2c')]();this['loopQueueShow']();}function isNotNull(_0x54110e){return _0x54110e!==null&&!_[_0xf6fa('0x2d')](_0x54110e);}function clearChannels(_0x4c53e9){if(!_[_0xf6fa('0x2e')](_0x4c53e9)){for(var _0x4c479a in _0x4c53e9){if(_0x4c53e9[_0xf6fa('0x2f')](_0x4c479a)){delete _0x4c53e9[_0x4c479a];}}}}function clearCampaigns(_0x66147b){if(!_[_0xf6fa('0x2e')](_0x66147b)){for(var _0x24faf4 in _0x66147b){if(_0x66147b[_0xf6fa('0x2f')](_0x24faf4)){_0x66147b[_0x24faf4][_0xf6fa('0x30')]=0x0;}}}}function clearVoiceQueues(_0x54f932){if(!_['isEmpty'](_0x54f932)){for(var _0x745304 in _0x54f932){if(_0x54f932[_0xf6fa('0x2f')](_0x745304)){_0x54f932[_0x745304][_0xf6fa('0x30')]=0x0;_0x54f932[_0x745304][_0xf6fa('0x31')]=0x0;_0x54f932[_0x745304]['pTalking']=0x0;_0x54f932[_0x745304]['waiting']=0x0;_0x54f932[_0x745304]['queueStatusComplete']=!![];}}}}function clearAgentBooked(_0x2d2164){if(!_[_0xf6fa('0x2e')](_0x2d2164)){for(var _0x567cc0 in _0x2d2164){if(_0x2d2164[_0xf6fa('0x2f')](_0x567cc0)){_0x2d2164[_0x567cc0][_0xf6fa('0x32')]=!![];}}}}VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x33')]=function(){var _0x1e87f5=this;for(var _0xabce33 in this[_0xf6fa('0x12')]){if(this[_0xf6fa('0x12')]['hasOwnProperty'](_0xabce33)&&!this[_0xf6fa('0x12')][_0xabce33][_0xf6fa('0x34')]){this[_0xf6fa('0x10')]['enqueue'](function(){if(!_[_0xf6fa('0x35')](_0x1e87f5[_0xf6fa('0x12')][_0xabce33])){return ami['Action']({'action':_0xf6fa('0x36'),'channel':_0x1e87f5[_0xf6fa('0x12')][_0xabce33]['channel']})[_0xf6fa('0x37')](function(_0x1f5a52){if(_0x1f5a52[_0xf6fa('0x38')]===_0xf6fa('0x39')){setTimeout(function(){if(_0x1e87f5['channels'][_0xabce33]){delete _0x1e87f5[_0xf6fa('0x12')][_0xabce33];logger[_0xf6fa('0x3a')]('[voiceQueueReport][checkChannel]',_0xabce33);}if(_0x1e87f5[_0xf6fa('0x3b')][_0xabce33]){delete _0x1e87f5[_0xf6fa('0x3b')][_0xabce33];logger[_0xf6fa('0x3a')]('[voiceQueueReport][checkQueueReport]',_0xabce33);}if(_0x1e87f5[_0xf6fa('0x15')][_0xabce33]){delete _0x1e87f5[_0xf6fa('0x15')][_0xabce33];logger[_0xf6fa('0x3a')]('[voiceQueueReport][checkVariables]',_0xabce33);}},0x1f40);}});}});}}};VoiceQueueReport[_0xf6fa('0xc')]['syncFullyBooted']=function(){logger['error'](_0xf6fa('0x3c'));clearChannels(this[_0xf6fa('0x12')]);this[_0xf6fa('0x3d')](this[_0xf6fa('0x3b')]);clearAgentBooked(this[_0xf6fa('0x11')]);clearVoiceQueues(this[_0xf6fa('0x13')]);clearCampaigns(this[_0xf6fa('0x14')]);};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x3d')]=function(_0xfcfcf0){var _0x5bdd28=this;if(!_[_0xf6fa('0x2e')](_0xfcfcf0)){for(var _0x48826 in _0xfcfcf0){if(_0xfcfcf0[_0xf6fa('0x2f')](_0x48826)){_0x5bdd28[_0xf6fa('0x3e')](_0xfcfcf0[_0x48826]);delete _0xfcfcf0[_0x48826];}}}};function loggerCatch(_0x800087){return function(_0x5d8d51){logger[_0xf6fa('0x3a')](_0x800087,util[_0xf6fa('0x3f')](_0x5d8d51,{'showHidden':![],'depth':null}));};}VoiceQueueReport['prototype'][_0xf6fa('0x40')]=function(_0x252f7d,_0x4192ad,_0x66b943){io['to'](_0x252f7d)[_0xf6fa('0x40')](_0x4192ad,_0x66b943);};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x41')]=function(_0x40a29e){this[_0xf6fa('0x40')](util[_0xf6fa('0x42')](_0xf6fa('0x43'),_0x40a29e['name']),_0xf6fa('0x44'),_0x40a29e);};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x3e')]=function(_0x59bff5){this[_0xf6fa('0x40')](util[_0xf6fa('0x42')](_0xf6fa('0x43'),_0x59bff5['name']),_0xf6fa('0x45'),_0x59bff5);};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x46')]=function(_0x154fba){if(_0x154fba[_0xf6fa('0x47')]===_0xf6fa('0x48')){var _0xf0e780={'id':_0x154fba['id'],'name':_0x154fba['name'],'strategy':_0x154fba[_0xf6fa('0x49')],'answered':_0x154fba[_0xf6fa('0x4a')],'available':_0x154fba[_0xf6fa('0x4b')],'loggedIn':_0x154fba['loggedIn'],'pTalking':_0x154fba['pTalking'],'sumBillable':_0x154fba['sumBillable'],'sumDuration':_0x154fba[_0xf6fa('0x4c')],'sumHoldTime':_0x154fba[_0xf6fa('0x4d')]||0x0,'talking':_0x154fba[_0xf6fa('0x31')],'total':_0x154fba[_0xf6fa('0x4e')],'type':_0x154fba[_0xf6fa('0x47')],'unmanaged':_0x154fba[_0xf6fa('0x4f')],'abandoned':_0x154fba[_0xf6fa('0x50')],'waiting':_0x154fba[_0xf6fa('0x51')]};if(_0x154fba[_0xf6fa('0x52')]){_0xf0e780[_0xf6fa('0x52')]={'id':_0x154fba[_0xf6fa('0x52')]['id'],'name':_0x154fba[_0xf6fa('0x52')][_0xf6fa('0x53')],'active':_0x154fba['Trunk'][_0xf6fa('0x54')],'callerid':_0x154fba[_0xf6fa('0x52')][_0xf6fa('0x55')]};}if(_0x154fba[_0xf6fa('0x56')]){_0xf0e780['Interval']={'id':_0x154fba[_0xf6fa('0x56')]['id'],'name':_0x154fba[_0xf6fa('0x56')]['name']};}var _0x96f9f8=md5(JSON[_0xf6fa('0x57')](_0xf0e780));if(_0x154fba[_0xf6fa('0x3')]!==_0x96f9f8){_0x154fba[_0xf6fa('0x3')]=_0x96f9f8;this['emit'](util[_0xf6fa('0x42')](_0xf6fa('0x43'),_0xf0e780[_0xf6fa('0x53')]),_0xf6fa('0x58'),_0xf0e780);}}};VoiceQueueReport['prototype'][_0xf6fa('0x59')]=function(_0xbd3389){return _0xbd3389!==null&&!_[_0xf6fa('0x2d')](_0xbd3389);};VoiceQueueReport['prototype'][_0xf6fa('0x5a')]=function(){var _0x4ab551=this;setInterval(function(){_0x4ab551[_0xf6fa('0x33')]();ami['Action']({'action':'queues'})[_0xf6fa('0x37')](loggerCatch(_0xf6fa('0x5b')));},0x2710);};VoiceQueueReport['prototype'][_0xf6fa('0x2c')]=function(){var _0x1a16a0=this;setInterval(function(){if(_0x1a16a0['flagQueueSummary']){return ami['Action']({'action':'queuesummary'})[_0xf6fa('0x5c')](function(_0x17474f){_0x1a16a0[_0xf6fa('0x5d')]=![];})[_0xf6fa('0x37')](loggerCatch(_0xf6fa('0x5e')));}},0x3e8);};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x17')]=function(_0x1377e3){try{if(this['isNotNull'](_0x1377e3)&&this['isNotNull'](_0x1377e3[_0xf6fa('0x5f')])){if(this[_0xf6fa('0x13')][_0x1377e3[_0xf6fa('0x5f')]]){var _0x5628a4=_[_0xf6fa('0x60')](this[_0xf6fa('0x12')],_0xf6fa('0x5f'))[_0x1377e3[_0xf6fa('0x5f')]]||0x0;var _0x6ead26=_0x5628a4-_0x1377e3[_0xf6fa('0x61')];if(this[_0xf6fa('0x13')][_0x1377e3[_0xf6fa('0x5f')]][_0xf6fa('0x51')]!==_[_0xf6fa('0x62')](_0x1377e3[_0xf6fa('0x61')])||this[_0xf6fa('0x13')][_0x1377e3['queue']]['loggedIn']!==_[_0xf6fa('0x62')](_0x1377e3['loggedin'])||this['voiceQueues'][_0x1377e3[_0xf6fa('0x5f')]][_0xf6fa('0x4b')]!==_[_0xf6fa('0x62')](_0x1377e3[_0xf6fa('0x4b')])||this['voiceQueues'][_0x1377e3[_0xf6fa('0x5f')]][_0xf6fa('0x31')]!==_0x6ead26){this['voiceQueues'][_0x1377e3[_0xf6fa('0x5f')]][_0xf6fa('0x51')]=_[_0xf6fa('0x62')](_0x1377e3['callers']);this[_0xf6fa('0x13')][_0x1377e3[_0xf6fa('0x5f')]]['loggedIn']=_[_0xf6fa('0x62')](_0x1377e3[_0xf6fa('0x63')]);this[_0xf6fa('0x13')][_0x1377e3[_0xf6fa('0x5f')]]['available']=_[_0xf6fa('0x62')](_0x1377e3[_0xf6fa('0x4b')]);this[_0xf6fa('0x13')][_0x1377e3[_0xf6fa('0x5f')]][_0xf6fa('0x31')]=_0x6ead26>0x0?_0x6ead26:0x0;this[_0xf6fa('0x13')][_0x1377e3[_0xf6fa('0x5f')]][_0xf6fa('0x31')]=this['voiceQueues'][_0x1377e3[_0xf6fa('0x5f')]][_0xf6fa('0x31')]>_[_0xf6fa('0x62')](_0x1377e3['loggedin'])?_[_0xf6fa('0x62')](_0x1377e3[_0xf6fa('0x63')]):this[_0xf6fa('0x13')][_0x1377e3[_0xf6fa('0x5f')]][_0xf6fa('0x31')];this[_0xf6fa('0x46')](this['voiceQueues'][_0x1377e3[_0xf6fa('0x5f')]]);}ami[_0xf6fa('0x40')]('custom:queuesummary',this['voiceQueues'][_0x1377e3[_0xf6fa('0x5f')]]);}}}catch(_0x17d4cf){logger[_0xf6fa('0x3a')](_0xf6fa('0x64'),util[_0xf6fa('0x3f')](_0x17d4cf,{'showHidden':![],'depth':null}));}};VoiceQueueReport['prototype']['syncQueueSummaryComplete']=function(_0x5a81aa){this[_0xf6fa('0x5d')]=!![];};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x65')]=function(_0x4c7aae){};VoiceQueueReport[_0xf6fa('0xc')]['syncQueueCallerJoin']=function(_0x4e7beb){try{if(this[_0xf6fa('0x59')](_0x4e7beb)){if(_['isUndefined'](this[_0xf6fa('0x3b')][_0x4e7beb['uniqueid']])){this[_0xf6fa('0x3b')][_0x4e7beb['uniqueid']]=[];this['channels'][_0x4e7beb[_0xf6fa('0x66')]]={};}var _0x2e0a27=new QueueReport();_0x2e0a27[_0xf6fa('0x53')]=_0x4e7beb['queue'];_0x2e0a27[_0xf6fa('0x47')]=this[_0xf6fa('0x13')][_0x2e0a27[_0xf6fa('0x53')]]&&this[_0xf6fa('0x13')][_0x2e0a27[_0xf6fa('0x53')]][_0xf6fa('0x47')]?this[_0xf6fa('0x13')][_0x2e0a27[_0xf6fa('0x53')]]['type']||_0xf6fa('0x48'):_0xf6fa('0x48');_0x2e0a27[_0xf6fa('0x5f')]=_0x4e7beb[_0xf6fa('0x5f')];_0x2e0a27[_0xf6fa('0x67')]=moment()[_0xf6fa('0x42')]('YYYY-MM-DD\x20HH:mm:ss');_0x2e0a27[_0xf6fa('0x68')]=_0x4e7beb[_0xf6fa('0x68')];_0x2e0a27[_0xf6fa('0x69')]=_0x4e7beb[_0xf6fa('0x69')];_[_0xf6fa('0x6a')](_0x2e0a27,_[_0xf6fa('0x6b')](_0x4e7beb,_['keys'](_0x2e0a27)));this[_0xf6fa('0x3b')][_0x4e7beb[_0xf6fa('0x66')]][_0xf6fa('0x6c')](_0x2e0a27);this[_0xf6fa('0x12')][_0x4e7beb['uniqueid']]=_0x2e0a27;this[_0xf6fa('0x41')](_0x2e0a27);}}catch(_0x56816c){logger[_0xf6fa('0x3a')](_0xf6fa('0x6d'),util[_0xf6fa('0x3f')](_0x56816c,{'showHidden':![],'depth':null}));}};VoiceQueueReport['prototype']['syncQueueCallerAbandon']=function(_0x453f4f){try{if(this[_0xf6fa('0x59')](_0x453f4f)){if(this[_0xf6fa('0x3b')][_0x453f4f[_0xf6fa('0x66')]]){var _0x134582=_['last'](this[_0xf6fa('0x3b')][_0x453f4f[_0xf6fa('0x66')]]);_0x134582[_0xf6fa('0x6e')]=![];_0x134582['queuecallercompleteAt']=null;_0x134582[_0xf6fa('0x6f')]=_0x453f4f[_0xf6fa('0x6f')];_0x134582[_0xf6fa('0x70')]=_0x453f4f[_0xf6fa('0x70')];_0x134582[_0xf6fa('0x1d')]=!![];_0x134582[_0xf6fa('0x71')]=moment()[_0xf6fa('0x42')](_0xf6fa('0x72'));_0x134582[_0xf6fa('0x73')]='ABANDONED';_0x134582[_0xf6fa('0x74')]=null;this[_0xf6fa('0x12')][_0x453f4f[_0xf6fa('0x66')]]=_0x134582;this[_0xf6fa('0x3e')](_0x134582);}}}catch(_0x42ef87){logger['error'](_0xf6fa('0x75'),util[_0xf6fa('0x3f')](_0x42ef87,{'showHidden':![],'depth':null}));}};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x20')]=function(_0x2b3bf2){try{if(this['isNotNull'](_0x2b3bf2)){if(this['queueReports'][_0x2b3bf2[_0xf6fa('0x66')]]){var _0x23ccfe=_[_0xf6fa('0x76')](this[_0xf6fa('0x3b')][_0x2b3bf2[_0xf6fa('0x66')]]);_0x23ccfe[_0xf6fa('0x77')]=moment()[_0xf6fa('0x42')](_0xf6fa('0x72'));_0x23ccfe['connectedlinenum']=_0x2b3bf2['connectedlinenum'];_0x23ccfe[_0xf6fa('0x78')]=_0x2b3bf2['connectedlinename'];this[_0xf6fa('0x12')][_0x2b3bf2[_0xf6fa('0x66')]]=_0x23ccfe;this[_0xf6fa('0x41')](_0x23ccfe);}}}catch(_0x307dfe){logger[_0xf6fa('0x3a')]('[syncQueueCallerLeave][VoiceQueueReport]',util[_0xf6fa('0x3f')](_0x307dfe,{'showHidden':![],'depth':null}));}};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x23')]=function(_0x5962d9){try{if(this[_0xf6fa('0x59')](_0x5962d9)){if(this[_0xf6fa('0x3b')][_0x5962d9[_0xf6fa('0x66')]]){var _0x1391ea=_[_0xf6fa('0x76')](this[_0xf6fa('0x3b')][_0x5962d9['uniqueid']]);_0x1391ea[_0xf6fa('0x6e')]=!![];_0x1391ea[_0xf6fa('0x73')]=_0xf6fa('0x79');}}}catch(_0x3b85ae){logger[_0xf6fa('0x3a')](_0xf6fa('0x7a'),util[_0xf6fa('0x3f')](_0x3b85ae,{'showHidden':![],'depth':null}));}};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x22')]=function(_0x46a1aa){try{if(this[_0xf6fa('0x59')](_0x46a1aa)){if(this[_0xf6fa('0x3b')][_0x46a1aa[_0xf6fa('0x66')]]){var _0x15da24=_[_0xf6fa('0x76')](this[_0xf6fa('0x3b')][_0x46a1aa['uniqueid']]);_0x15da24[_0xf6fa('0x1d')]=![];_0x15da24[_0xf6fa('0x71')]=null;_0x15da24[_0xf6fa('0x7b')]=!![];_0x15da24['lastAssignedTo']=_0x46a1aa[_0xf6fa('0x7c')];_0x15da24[_0xf6fa('0x6f')]=_0x46a1aa[_0xf6fa('0x6f')];_0x15da24[_0xf6fa('0x6e')]=!![];_0x15da24[_0xf6fa('0x7d')]=![];_0x15da24[_0xf6fa('0x7e')]=null;if(!_0x15da24['transfer']){if(_0x46a1aa[_0xf6fa('0x7f')]==_0xf6fa('0x80')){_0x15da24[_0xf6fa('0x73')]=_0xf6fa('0x81');}else{if(_[_0xf6fa('0x82')](_0x46a1aa[_0xf6fa('0x83')][_0xf6fa('0x84')](),_0xf6fa('0x85'))){if(this[_0xf6fa('0x3b')][_0x46a1aa[_0xf6fa('0x86')]]){var _0x12b7f4=_['last'](this[_0xf6fa('0x3b')][_0x46a1aa[_0xf6fa('0x86')]]);_0x12b7f4[_0xf6fa('0x6e')]=![];_0x12b7f4[_0xf6fa('0x7d')]=!![];_0x12b7f4[_0xf6fa('0x7e')]=moment(_0x15da24[_0xf6fa('0x67')])['add'](_0x46a1aa[_0xf6fa('0x6f')],'seconds')[_0xf6fa('0x42')](_0xf6fa('0x72'));_0x12b7f4[_0xf6fa('0x73')]=_0xf6fa('0x87');_0x12b7f4[_0xf6fa('0x80')]=!![];_0x12b7f4[_0xf6fa('0x88')]=_0xf6fa('0x89');_0x12b7f4['transferexten']=_0x46a1aa[_0xf6fa('0x8a')];_0x12b7f4[_0xf6fa('0x8b')]=_0x46a1aa[_0xf6fa('0x66')];var _0x30bf2a=this[_0xf6fa('0x3b')][_0x46a1aa[_0xf6fa('0x86')]];this[_0xf6fa('0x3b')][_0x46a1aa[_0xf6fa('0x86')]]=this[_0xf6fa('0x3b')][_0x46a1aa[_0xf6fa('0x66')]];this[_0xf6fa('0x3b')][_0x46a1aa[_0xf6fa('0x66')]]=_0x30bf2a;}}else{_0x15da24[_0xf6fa('0x73')]=_0xf6fa('0x8c')+_0x46a1aa['reason'][_0xf6fa('0x8d')]();}}}this[_0xf6fa('0x12')][_0x46a1aa['uniqueid']]=_0x15da24;this[_0xf6fa('0x3e')](_0x15da24);}}}catch(_0x3a1c78){logger[_0xf6fa('0x3a')](_0xf6fa('0x8e'),util['inspect'](_0x3a1c78,{'showHidden':![],'depth':null}));}};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x8f')]=function(_0x116ce4){try{if(this['isNotNull'](_0x116ce4)){this['addVariable'](_0x116ce4['uniqueid'],_[_0xf6fa('0x90')](_0x116ce4[_0xf6fa('0x91')])[0x0],_0x116ce4['value']);if(this[_0xf6fa('0x3b')][_0x116ce4[_0xf6fa('0x66')]]){var _0x233e4f=_['last'](this[_0xf6fa('0x3b')][_0x116ce4[_0xf6fa('0x66')]]);if(_0x233e4f){if(this['isNotNull'](_0x116ce4[_0xf6fa('0x91')])&&this[_0xf6fa('0x59')](_0x116ce4['variable']['queuestatus'])){switch(_0x116ce4['value']){case _0xf6fa('0x92'):_0x233e4f[_0xf6fa('0x7d')]=![];_0x233e4f[_0xf6fa('0x7e')]=null;break;default:_0x233e4f['queuecallerexit']=!![];_0x233e4f[_0xf6fa('0x7e')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0x233e4f[_0xf6fa('0x77')]=moment()[_0xf6fa('0x42')]('YYYY-MM-DD\x20HH:mm:ss');}_0x233e4f[_0xf6fa('0x1d')]=![];_0x233e4f[_0xf6fa('0x71')]=null;_0x233e4f['queuecallerexitreason']=_0x116ce4[_0xf6fa('0x93')];this[_0xf6fa('0x12')][_0x116ce4['uniqueid']]=_0x233e4f;this[_0xf6fa('0x3e')](_0x233e4f);}else if(this['isNotNull'](_0x116ce4['variable'])&&this[_0xf6fa('0x59')](_0x116ce4['variable'][_0xf6fa('0x94')])){if(!_0x233e4f['queuecallerabandon']){_0x233e4f['queuecallerexit']=!![];_0x233e4f[_0xf6fa('0x7e')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0x233e4f[_0xf6fa('0x73')]=_0xf6fa('0x95');_0x233e4f['queuecallerleaveAt']=moment()[_0xf6fa('0x42')](_0xf6fa('0x72'));this[_0xf6fa('0x12')][_0x116ce4['uniqueid']]=_0x233e4f;}}_0x233e4f[_0xf6fa('0x15')]=this[_0xf6fa('0x15')][_0x116ce4['uniqueid']];}}}}catch(_0x308859){logger['error'](_0xf6fa('0x96'),util[_0xf6fa('0x3f')](_0x308859,{'showHidden':![],'depth':null}));}};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x97')]=function(_0x2ced28,_0x52bf93,_0x5e1e2b){var _0x3c6802=[_0xf6fa('0x98'),_0xf6fa('0x99'),_0xf6fa('0x9a'),_0xf6fa('0x9b'),_0xf6fa('0x9c'),_0xf6fa('0x9d'),_0xf6fa('0x9e'),_0xf6fa('0x9f'),'sipcallid','sipuri','bridgepeer',_0xf6fa('0xa0'),_0xf6fa('0xa1'),_0xf6fa('0xa2'),_0xf6fa('0xa3'),_0xf6fa('0xa4'),_0xf6fa('0x7c'),_0xf6fa('0xa5'),_0xf6fa('0xa6')];if(!_[_0xf6fa('0x35')](_0x52bf93)&&!_[_0xf6fa('0xa7')](_0x3c6802,_0x52bf93)){if(_[_0xf6fa('0x2d')](this[_0xf6fa('0x15')][_0x2ced28])){this['variables'][_0x2ced28]={};}this[_0xf6fa('0x15')][_0x2ced28][_0x52bf93]=_0x5e1e2b;}};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0x26')]=function(_0x5a2eca){try{if(this[_0xf6fa('0x59')](_0x5a2eca)){if(this['queueReports'][_0x5a2eca[_0xf6fa('0x66')]]){for(var _0x3d0eec=0x0,_0x869c87={};_0x3d0eec<this[_0xf6fa('0x3b')][_0x5a2eca['uniqueid']][_0xf6fa('0xa8')];_0x3d0eec+=0x1){_0x869c87=this[_0xf6fa('0x3b')][_0x5a2eca[_0xf6fa('0x66')]][_0x3d0eec];if(this['voiceQueues'][_0x869c87[_0xf6fa('0x5f')]]){if(_0x869c87[_0xf6fa('0x7d')]){this[_0xf6fa('0x13')][_0x869c87[_0xf6fa('0x5f')]]['unmanaged']+=0x1;}if(_0x869c87[_0xf6fa('0x1d')]){this['voiceQueues'][_0x869c87['queue']]['abandoned']+=0x1;}this[_0xf6fa('0x13')][_0x869c87[_0xf6fa('0x5f')]][_0xf6fa('0x4d')]+=moment(_0x869c87['queuecallerleaveAt'])['diff'](_0x869c87['queuecallerjoinAt'],_0xf6fa('0xa9'))||0x0;if(_0x3d0eec===this[_0xf6fa('0x3b')][_0x5a2eca[_0xf6fa('0x66')]][_0xf6fa('0xa8')]-0x1){this[_0xf6fa('0x13')][_0x869c87[_0xf6fa('0x5f')]][_0xf6fa('0x4c')]+=moment()[_0xf6fa('0xaa')](0x0)[_0xf6fa('0xab')](_0x869c87[_0xf6fa('0x67')],'seconds');this['voiceQueues'][_0x869c87[_0xf6fa('0x5f')]][_0xf6fa('0x4e')]+=0x1;if(_0x869c87[_0xf6fa('0x6e')]){this[_0xf6fa('0x13')][_0x869c87[_0xf6fa('0x5f')]][_0xf6fa('0x4a')]+=0x1;this[_0xf6fa('0x13')][_0x869c87[_0xf6fa('0x5f')]][_0xf6fa('0xac')]+=moment()[_0xf6fa('0xaa')](0x0)['diff'](_0x869c87[_0xf6fa('0x77')],_0xf6fa('0xa9'));_0x869c87[_0xf6fa('0xad')]=moment()[_0xf6fa('0x42')](_0xf6fa('0x72'));_0x869c87[_0xf6fa('0x7d')]=![];_0x869c87[_0xf6fa('0x7e')]=null;}if(_0x869c87[_0xf6fa('0x7d')]){_0x869c87[_0xf6fa('0xae')]=_0xf6fa('0x4f');ami['emit']('custom:queuecallerunmanaged',_0x869c87);}if(_0x869c87[_0xf6fa('0x1d')]){_0x869c87['lastevent']=_0xf6fa('0x50');ami[_0xf6fa('0x40')]('custom:queuecallerabandon',_0x869c87);}}else{this[_0xf6fa('0x13')][_0x869c87[_0xf6fa('0x5f')]][_0xf6fa('0x4c')]+=this[_0xf6fa('0x13')][_0x869c87[_0xf6fa('0x5f')]][_0xf6fa('0x4d')];}this[_0xf6fa('0x12')][_0x5a2eca['uniqueid']]=_0x869c87;this[_0xf6fa('0x3e')](_0x869c87);this[_0xf6fa('0x46')](this[_0xf6fa('0x13')][_0x869c87[_0xf6fa('0x5f')]]);}}ami['emit']('custom:voiceQueueReport',this[_0xf6fa('0x3b')][_0x5a2eca['uniqueid']]);delete this[_0xf6fa('0x3b')][_0x5a2eca['uniqueid']];delete this['channels'][_0x5a2eca[_0xf6fa('0x66')]];}if(this['variables'][_0x5a2eca[_0xf6fa('0x66')]]){delete this[_0xf6fa('0x15')][_0x5a2eca[_0xf6fa('0x66')]];}}}catch(_0x1012b1){logger[_0xf6fa('0x3a')]('[syncHangup][VoiceQueueReport]',util[_0xf6fa('0x3f')](_0x1012b1,{'showHidden':![],'depth':null}));}};VoiceQueueReport[_0xf6fa('0xc')][_0xf6fa('0xaf')]=function(_0x3c60aa){try{if(this[_0xf6fa('0x59')](_0x3c60aa)){var _0x516500;if(this[_0xf6fa('0x3b')][_0x3c60aa[_0xf6fa('0xb0')]]){_0x516500=_[_0xf6fa('0x76')](this['queueReports'][_0x3c60aa[_0xf6fa('0xb0')]]);_0x516500[_0xf6fa('0xb1')]=_0x3c60aa[_0xf6fa('0xb2')];_0x516500[_0xf6fa('0x8b')]=_0x3c60aa[_0xf6fa('0xb3')];_0x516500[_0xf6fa('0x73')]='ATTENDEDTRANSFER';_0x516500['transfer']=!![];_0x516500[_0xf6fa('0x88')]=_0xf6fa('0xb4');if(this[_0xf6fa('0x3b')][_0x3c60aa['secondtransfereruniqueid']]){var _0x4917fb=this['queueReports'][_0x3c60aa[_0xf6fa('0xb3')]];this['queueReports'][_0x3c60aa[_0xf6fa('0xb3')]]=this[_0xf6fa('0x3b')][_0x3c60aa[_0xf6fa('0xb0')]];this[_0xf6fa('0x3b')][_0x3c60aa['transfereeuniqueid']]=_0x4917fb;var _0x2136b9=_['last'](this[_0xf6fa('0x3b')][_0x3c60aa[_0xf6fa('0xb0')]]);_0x2136b9[_0xf6fa('0x34')]=!![];}}else if(this[_0xf6fa('0x3b')][_0x3c60aa[_0xf6fa('0xb5')]]){_0x516500=_[_0xf6fa('0x76')](this['queueReports'][_0x3c60aa[_0xf6fa('0xb5')]]);_0x516500[_0xf6fa('0xb1')]=_0x3c60aa[_0xf6fa('0xb6')];_0x516500[_0xf6fa('0x8b')]=_0x3c60aa['origtransfereruniqueid'];_0x516500['queuecallerexitreason']='ATTENDEDTRANSFER';_0x516500[_0xf6fa('0x80')]=!![];_0x516500['transfertype']='ATTENDED';if(this[_0xf6fa('0x3b')][_0x3c60aa[_0xf6fa('0xb7')]]){var _0x4917fb=this[_0xf6fa('0x3b')][_0x3c60aa[_0xf6fa('0xb7')]];this['queueReports'][_0x3c60aa[_0xf6fa('0xb7')]]=this[_0xf6fa('0x3b')][_0x3c60aa['transfertargetuniqueid']];this[_0xf6fa('0x3b')][_0x3c60aa['transfertargetuniqueid']]=_0x4917fb;var _0x2136b9=_['last'](this['queueReports'][_0x3c60aa[_0xf6fa('0xb5')]]);_0x2136b9[_0xf6fa('0x34')]=!![];}}}}catch(_0x3cfd){logger['error'](_0xf6fa('0xb8'),util['inspect'](_0x3cfd,{'showHidden':![],'depth':null}));}};VoiceQueueReport['prototype']['syncBlindTransfer']=function(_0x4c0a39){try{if(this[_0xf6fa('0x59')](_0x4c0a39)){if(this[_0xf6fa('0x3b')][_0x4c0a39[_0xf6fa('0xb0')]]){var _0x3c96cb=_[_0xf6fa('0x76')](this[_0xf6fa('0x3b')][_0x4c0a39[_0xf6fa('0xb0')]]);_0x3c96cb[_0xf6fa('0x73')]='BLINDTRANSFER';_0x3c96cb['transfer']=!![];_0x3c96cb[_0xf6fa('0x88')]='BLIND';_0x3c96cb[_0xf6fa('0xb1')]=_0x4c0a39[_0xf6fa('0xb9')];_0x3c96cb[_0xf6fa('0x8b')]=_0x4c0a39[_0xf6fa('0xb0')];this['syncHangup']({'event':_0xf6fa('0xba'),'uniqueid':_0x4c0a39[_0xf6fa('0xb0')],'context':_0x4c0a39[_0xf6fa('0xbb')],'channel':_0x4c0a39[_0xf6fa('0xbc')]});}}}catch(_0x19fc59){logger[_0xf6fa('0x3a')](_0xf6fa('0xbd'),util[_0xf6fa('0x3f')](_0x19fc59,{'showHidden':![],'depth':null}));}};VoiceQueueReport['prototype'][_0xf6fa('0x29')]=function(_0x52f8f5){try{if(this['isNotNull'](_0x52f8f5)){if(this[_0xf6fa('0x3b')][_0x52f8f5[_0xf6fa('0x66')]]){var _0x1612f4=_[_0xf6fa('0x76')](this[_0xf6fa('0x3b')][_0x52f8f5[_0xf6fa('0x66')]]);if(!_['isNil'](_0x1612f4[_0xf6fa('0x77')])){_0x1612f4[_0xf6fa('0xbe')]=moment()[_0xf6fa('0x42')](_0xf6fa('0x72'));}}}}catch(_0x689d87){logger[_0xf6fa('0x3a')](_0xf6fa('0xbf'),util[_0xf6fa('0x3f')](_0x689d87,{'showHidden':![],'depth':null}));}};VoiceQueueReport[_0xf6fa('0xc')]['syncMusicOnHoldStop']=function(_0x556f81){try{if(this['isNotNull'](_0x556f81)){if(this[_0xf6fa('0x3b')][_0x556f81[_0xf6fa('0x66')]]){var _0x575c37=_[_0xf6fa('0x76')](this[_0xf6fa('0x3b')][_0x556f81['uniqueid']]);if(!_[_0xf6fa('0x35')](_0x575c37[_0xf6fa('0xbe')])){_0x575c37['mohtime']+=moment()[_0xf6fa('0xaa')](0x0)[_0xf6fa('0xab')](_0x575c37[_0xf6fa('0xbe')],_0xf6fa('0xa9'));delete _0x575c37[_0xf6fa('0xbe')];}}}}catch(_0x280617){logger['error']('[syncMusicOnHoldStop][VoiceQueueReport]',util[_0xf6fa('0x3f')](_0x280617,{'showHidden':![],'depth':null}));}};module[_0xf6fa('0xc0')]=VoiceQueueReport;