Built motion from commit da617fac.|2.6.6
[motion2.git] / server / services / ami / preview / util / util.js
index 5c10f91..55ed8b2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x096c=['variablesAction','RECALL','originate','channelAgent','from-sip','timeout','uniqueid','totalGlobal','countbusyretry','countcongestionretry','countnoanswerretry','countagentrejectretry','countnosuchnumberretry','cloneAction','Global','scheduledAt','active','scheduledat','add','minutes','ListId','VoiceQueueId','decrementTalkink','pTalking','[decrementTalkink]\x20object\x20talking\x20is\x20negative','[decrementTalkink]\x20is\x20null\x20or\x20undefined','IsNotLoggedIn','name','queue','interface','motionChannel','mandatoryDisposition','buildObj','agentReadyId','not_inuse','status','reachable','push','getDiff','diff','seconds','createBody','CampaignId','filterKey','idContact','type','campaigntype','dialAnswer','callback','callbackat','sipcallid','xmd-voicequeueid','xmd-queue','xmd-phone','xmd-listid','xmd-dialurl','xmd-dialtimeout','xmd-dialoptions','xmd-dialid','xmd-dialchannel','xmd-cdrtype','xmd-agiafter','xmd-agi','rtpaudioqos','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrttbridged','rtpaudioqosrtt','bridgepeer','bridgepvtcallid','getCallerIdRandom','pow','replace','random','match','keys','variables','toLowerCase','buildNoAnswerEventPayload','util','lodash','moment','../../../../config/logger','env','127.0.0.1','milliseconds','error','logger','info','inspect','logger2','message','getCallerId','isUndefined','string','isEmpty','format','\x22%s\x22\x20<%s>','isActive','isNil','addVariables','Queue','calleridname','calleridnum','ContactId','dialOriginateTimeout','\x22rtTxX%s%s\x22','monitor_format','dialPreviewUrl','dialQueueProject','\x22agi://%s/square,%s\x22','NONE','dialQueueProject2','originatecalleridnum','originatecalleridname','xcally-motion-preview','Call-Type:\x20PREVIEW','_XCALLY_MIXMONITOR_FORMAT','Contact','%s%s','XMD-','toUpper','toLowerVariables','hasOwnProperty','toLower','updateOriginated','originated','[updateOriginated]\x20is\x20null\x20or\x20undefined','logBlacklist','YYYY-MM-DD\x20HH:mm:ss','state','statedesc','starttime','endtime','responsetime','ringtime','logLookAgent','membername','UserId','logCustomer','talktime','answertime','isFailure','Failure'];(function(_0x5b644e,_0x2e5e07){var _0x49c6bf=function(_0x3032d9){while(--_0x3032d9){_0x5b644e['push'](_0x5b644e['shift']());}};_0x49c6bf(++_0x2e5e07);}(_0x096c,0x172));var _0xc096=function(_0x193156,_0x1df464){_0x193156=_0x193156-0x0;var _0x31540f=_0x096c[_0x193156];return _0x31540f;};'use strict';var util=require(_0xc096('0x0'));var _=require(_0xc096('0x1'));var moment=require(_0xc096('0x2'));var logger=require(_0xc096('0x3'))('preview');var ipAgi=process[_0xc096('0x4')]['XCALLY_IP_AGI']||_0xc096('0x5');function getSeconds(_0x255ca8,_0x5984b7){var _0x1afe79=moment(_0x255ca8)[_0xc096('0x6')](0x0);var _0x4e7bbe=moment(_0x5984b7)[_0xc096('0x6')](0x0);return _0x1afe79['diff'](_0x4e7bbe,'seconds');}exports['loggerCatch']=function(_0x246fe2){return function(_0x356069){logger[_0xc096('0x7')](_0x246fe2,util['inspect'](_0x356069,{'showHidden':![],'depth':null}));};};exports[_0xc096('0x8')]=function(_0xe3710f,_0x1de638){logger[_0xc096('0x9')](_0xe3710f,util[_0xc096('0xa')](_0x1de638,{'showHidden':![],'depth':null}));};exports['loggerError']=function(_0x1b7e11,_0x33c45f){logger[_0xc096('0x7')](_0x1b7e11,util[_0xc096('0xa')](_0x33c45f,{'showHidden':![],'depth':null}));};exports[_0xc096('0xb')]=function(_0x6d969e){return function(_0x2e03af){logger[_0xc096('0x9')](_0x6d969e,util[_0xc096('0xa')](_0x2e03af,{'showHidden':![],'depth':null}));};};exports[_0xc096('0xc')]=function(_0x16421a,_0x4639e2,_0x4de6bd){return{'message':_0x16421a,'unlock':_0x4639e2,'active':_0x4de6bd};};exports[_0xc096('0xd')]=function(_0x4a4bb2,_0x39f11d,_0x142f7f){if(!_[_0xc096('0xe')](_0x142f7f)&&_0xc096('0xf')===typeof _0x142f7f&&!_[_0xc096('0x10')](_0x142f7f)){if(!_['isUndefined'](_0x39f11d)&&'string'===typeof _0x39f11d&&!_[_0xc096('0x10')](_0x39f11d)){return util[_0xc096('0x11')](_0xc096('0x12'),_0x39f11d,_0x142f7f);}return util[_0xc096('0x11')](_0xc096('0x12'),_0x142f7f,_0x142f7f);}if(!_[_0xc096('0xe')](_0x4a4bb2)&&_0xc096('0xf')===typeof _0x4a4bb2&&!_[_0xc096('0x10')](_0x4a4bb2)){return _0x4a4bb2;}return'\x22\x22\x20<>';};exports[_0xc096('0x13')]=function(_0x32e1a5){if(_[_0xc096('0x14')](_0x32e1a5)){return![];}return _0x32e1a5;};exports[_0xc096('0x15')]=function(_0x59a761,_0xa591a7,_0x5b8b16,_0x28d7af,_0x1b8363,_0x3e85fa){var _0x171b04={'XMD-QUEUE':_0xa591a7[_0xc096('0x16')]?_0xa591a7[_0xc096('0x16')]['name']:'','XMD-CALLERID':_0x28d7af,'XMD-CALLERID-PREVIEW':_0x3e85fa?util['format'](_0xc096('0x12'),_0x3e85fa[_0xc096('0x17')],_0x3e85fa[_0xc096('0x18')]):_0x28d7af,'XMD-DIALID':_0x1b8363,'XMD-CONTACTID':_0xa591a7[_0xc096('0x19')],'XMD-CDRTYPE':'dialer','CALLERID(all)':_0x28d7af,'XMD-VOICEQUEUEID':_0xa591a7['VoiceQueueId'],'XMD-DIALCHANNEL':_0x5b8b16,'XMD-DIALTIMEOUT':_0x59a761[_0xc096('0x1a')]||0x1e,'XMD-DIALOPTIONS':util[_0xc096('0x11')](_0xc096('0x1b'),_0x59a761['dialQueueProject2']?'g':'',_[_0xc096('0x10')](_0x59a761[_0xc096('0x1c')])?'':'U(xcally-mixmonitor-context)'),'XMD-DIALURL':_0x59a761[_0xc096('0x1d')]||'','XMD-AGI':_0x59a761[_0xc096('0x1e')]?util[_0xc096('0x11')](_0xc096('0x1f'),ipAgi,_0x59a761[_0xc096('0x1e')]):_0xc096('0x20'),'XMD-AGIAFTER':_0x59a761[_0xc096('0x21')]?util[_0xc096('0x11')]('\x22agi://%s/square,%s\x22',ipAgi,_0x59a761['dialQueueProject2']):_0xc096('0x20'),'XMD-ORIGINATECALLERIDNUM':_0x3e85fa?_0x3e85fa[_0xc096('0x22')]:'','XMD-ORIGINATECALLERIDNAME':_0x3e85fa?_0x3e85fa[_0xc096('0x23')]:'','XMD-DESTINATION':_0xc096('0x24'),'SIPADDHEADER':_0xc096('0x25')};if(!_[_0xc096('0x10')](_0x59a761[_0xc096('0x1c')])){_0x171b04[util[_0xc096('0x11')]('%s',_0xc096('0x26'))]=_0x59a761['monitor_format'];_0x171b04[util['format']('%s','_XCALLY_MIXMONITOR_UNIQUEID')]=_0x1b8363;}if(_0xa591a7&&_0xa591a7[_0xc096('0x27')]){for(var _0x2f5409 in _0xa591a7['Contact']){if(_0xa591a7[_0xc096('0x27')]['hasOwnProperty'](_0x2f5409)){if(!_[_0xc096('0x14')](_0xa591a7['Contact'][_0x2f5409])&&_0x2f5409!=='id'&&_0x2f5409!=='tags'&&_0x2f5409!=='createdAt'&&_0x2f5409!=='updatedAt'){_0x171b04[util['format'](_0xc096('0x28'),_0xc096('0x29'),_[_0xc096('0x2a')](_0x2f5409))]=_0xa591a7[_0xc096('0x27')][_0x2f5409];}}}}return _0x171b04;};exports[_0xc096('0x2b')]=function(_0x1dc70b){var _0x390eac={};for(var _0x47ebdc in _0x1dc70b){if(_0x1dc70b[_0xc096('0x2c')](_0x47ebdc)){_0x390eac[util[_0xc096('0x11')]('%s',_[_0xc096('0x2d')](_0x47ebdc))]=_0x1dc70b[_0x47ebdc];}}return{'variables':_0x390eac};};exports[_0xc096('0x2e')]=function(_0x2760ec,_0x52a655){if(!_[_0xc096('0x14')](_0x2760ec)){if(_0x2760ec[_0xc096('0x2c')](_0xc096('0x2f'))){if(_0x2760ec['originated']>0x0){_0x2760ec[_0xc096('0x2f')]-=0x1;}else{logger[_0xc096('0x7')]('[updateOriginated]\x20object\x20originated\x20is\x20negative',_0x52a655);}}}else{logger['error'](_0xc096('0x30'),_0x52a655);}};exports[_0xc096('0x31')]=function(_0x314b89){var _0x27c0e8=moment()[_0xc096('0x11')](_0xc096('0x32'));_0x314b89[_0xc096('0x33')]=0xd;_0x314b89[_0xc096('0x34')]='Blacklist';_0x314b89[_0xc096('0x35')]=_0x27c0e8;_0x314b89['responsetime']=_0x27c0e8;_0x314b89[_0xc096('0x36')]=_0x27c0e8;};exports['logAgent']=function(_0x51f97c,_0x2e9f69,_0x150499){var _0x545800=moment()[_0xc096('0x11')](_0xc096('0x32'));_0x51f97c[_0xc096('0x33')]=_0x2e9f69;_0x51f97c['statedesc']=_0x150499;_0x51f97c[_0xc096('0x37')]=_0x545800;_0x51f97c[_0xc096('0x38')]=getSeconds(_0x51f97c[_0xc096('0x37')],_0x51f97c[_0xc096('0x35')]);};exports[_0xc096('0x39')]=function(_0x539435,_0x3d97d7,_0x517f48){_0x539435[_0xc096('0x3a')]=_0x3d97d7;_0x539435[_0xc096('0x3b')]=_0x517f48;};exports[_0xc096('0x3c')]=function(_0x15ea8f,_0x50e711,_0x1d1628){var _0x2fb5ae=moment()[_0xc096('0x11')](_0xc096('0x32'));_0x15ea8f[_0xc096('0x33')]=_0x50e711;_0x15ea8f[_0xc096('0x34')]=_0x1d1628;_0x15ea8f[_0xc096('0x37')]=_0x15ea8f['responsetime']?_0x15ea8f[_0xc096('0x37')]:_0x2fb5ae;_0x15ea8f[_0xc096('0x36')]=_0x15ea8f[_0xc096('0x36')]?_0x15ea8f['endtime']:_0x2fb5ae;_0x15ea8f['ringtime']=getSeconds(_0x15ea8f[_0xc096('0x37')]||0x0,_0x15ea8f[_0xc096('0x35')]||0x0);_0x15ea8f[_0xc096('0x3d')]=_0x15ea8f[_0xc096('0x3e')]?getSeconds(_0x15ea8f[_0xc096('0x36')],_0x15ea8f[_0xc096('0x3e')]):0x0;};exports[_0xc096('0x3f')]=function(_0xa2bc88){return _0xa2bc88===_0xc096('0x40');};exports[_0xc096('0x41')]=function(_0x5452c9,_0x29ceae,_0x29e90d,_0x2d78f2,_0x3ea5fc){var _0x32a18d=_0x2d78f2?_0xc096('0x42'):_0x5452c9[_0xc096('0x17')];_0x32a18d=_0x3ea5fc?'BOOKED':_0x32a18d;return{'actionid':_0x5452c9['uniqueid'],'action':_0xc096('0x43'),'channel':_0x5452c9[_0xc096('0x44')],'callerid':util['format'](_0xc096('0x12'),_0x32a18d,_0x5452c9['calleridnum']),'Exten':'xcally-motion-preview','Context':_0xc096('0x45'),'Priority':'1','variable':_0x29e90d,'timeout':(_0x29ceae[_0xc096('0x46')]||0x1e)*0x3e8,'async':!![],'channelid':_0x5452c9[_0xc096('0x47')]};};exports[_0xc096('0x48')]=function(_0x45c402){return _0x45c402[_0xc096('0x49')]+_0x45c402[_0xc096('0x4a')]+_0x45c402[_0xc096('0x4b')]+_0x45c402[_0xc096('0x4c')]+_0x45c402[_0xc096('0x4d')];};exports[_0xc096('0x4e')]=function(_0x10ebe2){var _0x40954e=_['clone'](_0x10ebe2);_0x40954e[_0xc096('0x33')]=0xf;_0x40954e[_0xc096('0x34')]=_0xc096('0x4f');return _0x40954e;};exports[_0xc096('0x50')]=function(_0x9527b3,_0x573717,_0x390011){var _0x3d261c={};_0x3d261c[_0x573717]=_0x9527b3[_0x573717];_0x3d261c[_0xc096('0x51')]=![];_0x3d261c[_0xc096('0x52')]=moment()[_0xc096('0x53')](_0x390011,_0xc096('0x54'))[_0xc096('0x11')](_0xc096('0x32'));_0x3d261c[_0xc096('0x19')]=_0x9527b3[_0xc096('0x19')];_0x3d261c[_0xc096('0x55')]=_0x9527b3[_0xc096('0x55')];_0x3d261c[_0xc096('0x56')]=_0x9527b3[_0xc096('0x56')]||undefined;return _0x3d261c;};exports[_0xc096('0x57')]=function(_0x50bcfc,_0x33c36e){if(!_[_0xc096('0x14')](_0x50bcfc)){if(_0x50bcfc[_0xc096('0x58')]>0x0){_0x50bcfc[_0xc096('0x58')]-=0x1;}else{logger[_0xc096('0x7')](_0x33c36e,_0xc096('0x59'));}}else{logger[_0xc096('0x7')](_0x33c36e,_0xc096('0x5a'));}};exports[_0xc096('0x5b')]=function(_0x16501b){if(_0x16501b<=0x0){return!![];}return![];};function buildObj(_0x36ee4a,_0x18d864,_0x4bcd98){_0x36ee4a['lastevent']=_0x18d864;_0x36ee4a[_0xc096('0x5c')]=_0x36ee4a[_0xc096('0x5d')];_0x36ee4a[_0xc096('0x5e')]=_0x36ee4a['channelAgent'];_0x36ee4a[_0xc096('0x5f')]='voice';if(_0x4bcd98){_0x36ee4a['mandatoryDisposition']=_0x4bcd98[_0xc096('0x60')];}return _0x36ee4a;}exports[_0xc096('0x61')]=buildObj;exports['buildAcw']=function(_0x3b7675){var _0x15ebde={};_0x15ebde[_0xc096('0x5d')]=_0x3b7675[_0xc096('0x5d')];_0x15ebde[_0xc096('0x5e')]=_0x3b7675[_0xc096('0x44')];_0x15ebde['uniqueid']=_0x3b7675[_0xc096('0x47')];return _0x15ebde;};exports[_0xc096('0x62')]=function(_0x1529ad){var _0x47349e=[];for(var _0x548e7f in _0x1529ad){if(_0x1529ad['hasOwnProperty'](_0x548e7f)){if(!_['isNil'](_0x1529ad[_0x548e7f])&&_0x1529ad[_0x548e7f][_0xc096('0x33')]===_0xc096('0x63')&&_0x1529ad[_0x548e7f][_0xc096('0x64')]===_0xc096('0x65')){_0x47349e[_0xc096('0x66')](_0x1529ad[_0x548e7f]['id']);}}}return _0x47349e;};exports[_0xc096('0x67')]=function(_0x375bd0){var _0x4c3b1c=moment()[_0xc096('0x6')](0x0);var _0x50ab59=moment(_0x375bd0)['milliseconds'](0x0);return _0x4c3b1c[_0xc096('0x68')](_0x50ab59,_0xc096('0x69'));};exports[_0xc096('0x6a')]=function(_0x35e7f8){return{'active':![],'recallme':![],'UserId':null,'ContactId':_0x35e7f8[_0xc096('0x19')],'ListId':_0x35e7f8[_0xc096('0x55')],'VoiceQueueId':_0x35e7f8[_0xc096('0x56')]||undefined,'CampaignId':_0x35e7f8[_0xc096('0x6b')]||undefined};};exports[_0xc096('0x6c')]=function(_0x3438d5){if(_0x3438d5===_0xc096('0x47')||_0x3438d5===_0xc096('0x6d')||_0x3438d5===_0xc096('0x5d')||_0x3438d5===_0xc096('0x6e')||_0x3438d5===_0xc096('0x6f')||_0x3438d5===_0xc096('0x70')||_0x3438d5==='membername'||_0x3438d5===_0xc096('0x44')||_0x3438d5===_0xc096('0x17')||_0x3438d5==='active'||_0x3438d5===_0xc096('0x18')||_0x3438d5===_0xc096('0x52')||_0x3438d5==='countbusyretry'||_0x3438d5===_0xc096('0x4a')||_0x3438d5===_0xc096('0x4b')||_0x3438d5==='countglobal'||_0x3438d5===_0xc096('0x71')||_0x3438d5==='callbackuniqueid'||_0x3438d5===_0xc096('0x72')||_0x3438d5==='recallme'||_0x3438d5===_0xc096('0x19')||_0x3438d5===_0xc096('0x55')||_0x3438d5==='UserId'||_0x3438d5===_0xc096('0x56')||_0x3438d5===_0xc096('0x73')||_0x3438d5===_0xc096('0x74')||_0x3438d5===_0xc096('0x75')||_0x3438d5===_0xc096('0x76')||_0x3438d5===_0xc096('0x77')||_0x3438d5===_0xc096('0x78')||_0x3438d5===_0xc096('0x79')||_0x3438d5===_0xc096('0x7a')||_0x3438d5===_0xc096('0x7b')||_0x3438d5===_0xc096('0x7c')||_0x3438d5==='xmd-contactid'||_0x3438d5===_0xc096('0x7d')||_0x3438d5==='xmd-callerid'||_0x3438d5===_0xc096('0x7e')||_0x3438d5===_0xc096('0x7f')||_0x3438d5===_0xc096('0x80')||_0x3438d5==='rtpaudioqosbridged'||_0x3438d5==='rtpaudioqosjitter'||_0x3438d5===_0xc096('0x81')||_0x3438d5===_0xc096('0x82')||_0x3438d5===_0xc096('0x83')||_0x3438d5==='rtpaudioqosrtt'||_0x3438d5===_0xc096('0x84')||_0x3438d5===_0xc096('0x80')||_0x3438d5==='rtpaudioqosbridged'||_0x3438d5==='rtpaudioqosjitter'||_0x3438d5===_0xc096('0x81')||_0x3438d5===_0xc096('0x82')||_0x3438d5===_0xc096('0x83')||_0x3438d5===_0xc096('0x85')||_0x3438d5===_0xc096('0x84')||_0x3438d5===_0xc096('0x86')||_0x3438d5===_0xc096('0x87')||_0x3438d5==='state'||_0x3438d5===_0xc096('0x34')){return![];}return!![];};exports[_0xc096('0x88')]=function(_0x5d2041,_0x530e50){var _0x3c1f82,_0x243f2f,_0x51d2f7;if(_0x530e50<=0x0){_0x530e50=0x1;}_0x3c1f82=new RegExp('\x5cw{0,'+_0x530e50+'}$');_0x243f2f=Math[_0xc096('0x89')](0xa,_0x530e50-0x1);_0x51d2f7=Math['pow'](0xa,_0x530e50)-0x1;return util[_0xc096('0x11')]('%s',_[_0xc096('0x8a')](_0x5d2041,_0x3c1f82,_[_0xc096('0x8b')](_0x243f2f,_0x51d2f7)));};exports['extractCalleridName']=function(_0x30f67e){var _0xb9df35=_0x30f67e[_0xc096('0x8c')](/"(.*?)"/);return _0xb9df35?_0xb9df35[0x1]:_0x30f67e;};exports['extractCalleridNumber']=function(_0x42ef22){var _0x549f3a=_0x42ef22['match'](/<(.*?)>/);return _0x549f3a?_0x549f3a[0x1]:_0x42ef22;};function buildNoAnswerEventPayload(_0x1f493a,_0x242c86){var _0x19d576=buildObj(_0x1f493a,'noanswer');if(!_[_0xc096('0x10')](_0x242c86['variables'])){Object[_0xc096('0x8d')](_0x242c86[_0xc096('0x8e')])['forEach'](function(_0x572906){_0x19d576[_0x572906[_0xc096('0x8f')]()]=_0x242c86[_0xc096('0x8e')][_0x572906];});}return _0x19d576;}exports[_0xc096('0x90')]=buildNoAnswerEventPayload;
\ No newline at end of file
+var _0xa9eb=['diff','loggerCatch','inspect','logger','info','loggerError','error','logger2','getCallerId','string','isEmpty','format','\x22%s\x22\x20<%s>','\x22\x22\x20<>','isActive','isNil','addVariables','Queue','calleridname','ContactId','dialer','VoiceQueueId','dialOriginateTimeout','dialQueueProject2','U(xcally-mixmonitor-context)','dialQueueProject','\x22agi://%s/square,%s\x22','NONE','originatecalleridnum','originatecalleridname','xcally-motion-preview','Call-Type:\x20PREVIEW','_XCALLY_MIXMONITOR_FORMAT','monitor_format','_XCALLY_MIXMONITOR_UNIQUEID','Contact','hasOwnProperty','tags','updatedAt','%s%s','toUpper','toLowerVariables','updateOriginated','originated','[updateOriginated]\x20object\x20originated\x20is\x20negative','[updateOriginated]\x20is\x20null\x20or\x20undefined','logBlacklist','YYYY-MM-DD\x20HH:mm:ss','statedesc','starttime','responsetime','endtime','state','ringtime','logLookAgent','membername','UserId','logCustomer','answertime','isFailure','Failure','variablesAction','BOOKED','originate','channelAgent','from-sip','timeout','uniqueid','totalGlobal','countbusyretry','countnoanswerretry','countagentrejectretry','countnosuchnumberretry','cloneAction','clone','scheduledAt','active','add','minutes','ListId','decrementTalkink','pTalking','[decrementTalkink]\x20object\x20talking\x20is\x20negative','[decrementTalkink]\x20is\x20null\x20or\x20undefined','lastevent','queue','interface','motionChannel','mandatoryDisposition','buildObj','buildAcw','agentReadyId','not_inuse','status','reachable','push','getDiff','seconds','createBody','CampaignId','filterKey','idContact','type','dialAnswer','calleridnum','countglobal','callbackuniqueid','callbackat','recallme','sipcallid','xmd-voicequeueid','xmd-queue','xmd-phone','xmd-dialtimeout','xmd-dialid','xmd-contactid','xmd-cdrtype','xmd-callerid','xmd-agiafter','xmd-agi','rtpaudioqos','rtpaudioqosbridged','rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrttbridged','rtpaudioqosrtt','bridgepeer','bridgepvtcallid','getCallerIdRandom','\x5cw{0,','pow','replace','extractCalleridName','match','extractCalleridNumber','variables','keys','forEach','buildNoAnswerEventPayload','util','preview','env','XCALLY_IP_AGI','127.0.0.1','milliseconds'];(function(_0x58d808,_0x5e605d){var _0x3c9f9d=function(_0x32882d){while(--_0x32882d){_0x58d808['push'](_0x58d808['shift']());}};_0x3c9f9d(++_0x5e605d);}(_0xa9eb,0x1b3));var _0xba9e=function(_0x1992f1,_0x5c61f0){_0x1992f1=_0x1992f1-0x0;var _0x413dfe=_0xa9eb[_0x1992f1];return _0x413dfe;};'use strict';var util=require(_0xba9e('0x0'));var _=require('lodash');var moment=require('moment');var logger=require('../../../../config/logger')(_0xba9e('0x1'));var ipAgi=process[_0xba9e('0x2')][_0xba9e('0x3')]||_0xba9e('0x4');function getSeconds(_0x30d478,_0x3bb808){var _0x464273=moment(_0x30d478)[_0xba9e('0x5')](0x0);var _0x206477=moment(_0x3bb808)[_0xba9e('0x5')](0x0);return _0x464273[_0xba9e('0x6')](_0x206477,'seconds');}exports[_0xba9e('0x7')]=function(_0x1f050d){return function(_0x507fdf){logger['error'](_0x1f050d,util[_0xba9e('0x8')](_0x507fdf,{'showHidden':![],'depth':null}));};};exports[_0xba9e('0x9')]=function(_0x4f52df,_0x4f49c2){logger[_0xba9e('0xa')](_0x4f52df,util[_0xba9e('0x8')](_0x4f49c2,{'showHidden':![],'depth':null}));};exports[_0xba9e('0xb')]=function(_0x3f8500,_0x43a71d){logger[_0xba9e('0xc')](_0x3f8500,util[_0xba9e('0x8')](_0x43a71d,{'showHidden':![],'depth':null}));};exports[_0xba9e('0xd')]=function(_0x1913b6){return function(_0x4922c0){logger['info'](_0x1913b6,util[_0xba9e('0x8')](_0x4922c0,{'showHidden':![],'depth':null}));};};exports['message']=function(_0x2d3e9c,_0x50d6a7,_0x428c57){return{'message':_0x2d3e9c,'unlock':_0x50d6a7,'active':_0x428c57};};exports[_0xba9e('0xe')]=function(_0x71f83,_0x4d2f8d,_0x45a23e){if(!_['isUndefined'](_0x45a23e)&&_0xba9e('0xf')===typeof _0x45a23e&&!_[_0xba9e('0x10')](_0x45a23e)){if(!_['isUndefined'](_0x4d2f8d)&&'string'===typeof _0x4d2f8d&&!_[_0xba9e('0x10')](_0x4d2f8d)){return util[_0xba9e('0x11')](_0xba9e('0x12'),_0x4d2f8d,_0x45a23e);}return util[_0xba9e('0x11')](_0xba9e('0x12'),_0x45a23e,_0x45a23e);}if(!_['isUndefined'](_0x71f83)&&_0xba9e('0xf')===typeof _0x71f83&&!_[_0xba9e('0x10')](_0x71f83)){return _0x71f83;}return _0xba9e('0x13');};exports[_0xba9e('0x14')]=function(_0x44823b){if(_[_0xba9e('0x15')](_0x44823b)){return![];}return _0x44823b;};exports[_0xba9e('0x16')]=function(_0x3f41c1,_0x45e149,_0x32d768,_0x37ad81,_0x227b2c,_0x522898){var _0x4d480e={'XMD-QUEUE':_0x45e149[_0xba9e('0x17')]?_0x45e149[_0xba9e('0x17')]['name']:'','XMD-CALLERID':_0x37ad81,'XMD-CALLERID-PREVIEW':_0x522898?util[_0xba9e('0x11')](_0xba9e('0x12'),_0x522898[_0xba9e('0x18')],_0x522898['calleridnum']):_0x37ad81,'XMD-DIALID':_0x227b2c,'XMD-CONTACTID':_0x45e149[_0xba9e('0x19')],'XMD-CDRTYPE':_0xba9e('0x1a'),'CALLERID(all)':_0x37ad81,'XMD-VOICEQUEUEID':_0x45e149[_0xba9e('0x1b')],'XMD-DIALCHANNEL':_0x32d768,'XMD-DIALTIMEOUT':_0x3f41c1[_0xba9e('0x1c')]||0x1e,'XMD-DIALOPTIONS':util['format']('\x22rtTxX%s%s\x22',_0x3f41c1[_0xba9e('0x1d')]?'g':'',_[_0xba9e('0x10')](_0x3f41c1['monitor_format'])?'':_0xba9e('0x1e')),'XMD-DIALURL':_0x3f41c1['dialPreviewUrl']||'','XMD-AGI':_0x3f41c1[_0xba9e('0x1f')]?util[_0xba9e('0x11')](_0xba9e('0x20'),ipAgi,_0x3f41c1['dialQueueProject']):_0xba9e('0x21'),'XMD-AGIAFTER':_0x3f41c1[_0xba9e('0x1d')]?util[_0xba9e('0x11')]('\x22agi://%s/square,%s\x22',ipAgi,_0x3f41c1[_0xba9e('0x1d')]):_0xba9e('0x21'),'XMD-ORIGINATECALLERIDNUM':_0x522898?_0x522898[_0xba9e('0x22')]:'','XMD-ORIGINATECALLERIDNAME':_0x522898?_0x522898[_0xba9e('0x23')]:'','XMD-DESTINATION':_0xba9e('0x24'),'SIPADDHEADER':_0xba9e('0x25')};if(!_[_0xba9e('0x10')](_0x3f41c1['monitor_format'])){_0x4d480e[util[_0xba9e('0x11')]('%s',_0xba9e('0x26'))]=_0x3f41c1[_0xba9e('0x27')];_0x4d480e[util[_0xba9e('0x11')]('%s',_0xba9e('0x28'))]=_0x227b2c;}if(_0x45e149&&_0x45e149[_0xba9e('0x29')]){for(var _0x2769cd in _0x45e149[_0xba9e('0x29')]){if(_0x45e149[_0xba9e('0x29')][_0xba9e('0x2a')](_0x2769cd)){if(!_[_0xba9e('0x15')](_0x45e149[_0xba9e('0x29')][_0x2769cd])&&_0x2769cd!=='id'&&_0x2769cd!==_0xba9e('0x2b')&&_0x2769cd!=='createdAt'&&_0x2769cd!==_0xba9e('0x2c')){_0x4d480e[util[_0xba9e('0x11')](_0xba9e('0x2d'),'XMD-',_[_0xba9e('0x2e')](_0x2769cd))]=_0x45e149['Contact'][_0x2769cd];}}}}return _0x4d480e;};exports[_0xba9e('0x2f')]=function(_0x4b5ac3){var _0x2a8548={};for(var _0x4669f8 in _0x4b5ac3){if(_0x4b5ac3[_0xba9e('0x2a')](_0x4669f8)){_0x2a8548[util[_0xba9e('0x11')]('%s',_['toLower'](_0x4669f8))]=_0x4b5ac3[_0x4669f8];}}return{'variables':_0x2a8548};};exports[_0xba9e('0x30')]=function(_0x591c38,_0x42197f){if(!_[_0xba9e('0x15')](_0x591c38)){if(_0x591c38[_0xba9e('0x2a')](_0xba9e('0x31'))){if(_0x591c38[_0xba9e('0x31')]>0x0){_0x591c38[_0xba9e('0x31')]-=0x1;}else{logger[_0xba9e('0xc')](_0xba9e('0x32'),_0x42197f);}}}else{logger['error'](_0xba9e('0x33'),_0x42197f);}};exports[_0xba9e('0x34')]=function(_0x22975d){var _0x3ff686=moment()[_0xba9e('0x11')](_0xba9e('0x35'));_0x22975d['state']=0xd;_0x22975d[_0xba9e('0x36')]='Blacklist';_0x22975d[_0xba9e('0x37')]=_0x3ff686;_0x22975d[_0xba9e('0x38')]=_0x3ff686;_0x22975d[_0xba9e('0x39')]=_0x3ff686;};exports['logAgent']=function(_0x23ad8b,_0x5c7aa6,_0x2b84ee){var _0x3672f7=moment()['format'](_0xba9e('0x35'));_0x23ad8b[_0xba9e('0x3a')]=_0x5c7aa6;_0x23ad8b[_0xba9e('0x36')]=_0x2b84ee;_0x23ad8b[_0xba9e('0x38')]=_0x3672f7;_0x23ad8b[_0xba9e('0x3b')]=getSeconds(_0x23ad8b[_0xba9e('0x38')],_0x23ad8b[_0xba9e('0x37')]);};exports[_0xba9e('0x3c')]=function(_0x4b8142,_0x2aaeab,_0x4845fb){_0x4b8142[_0xba9e('0x3d')]=_0x2aaeab;_0x4b8142[_0xba9e('0x3e')]=_0x4845fb;};exports[_0xba9e('0x3f')]=function(_0xba2d70,_0x573719,_0x258e68){var _0x157e46=moment()['format'](_0xba9e('0x35'));_0xba2d70[_0xba9e('0x3a')]=_0x573719;_0xba2d70['statedesc']=_0x258e68;_0xba2d70[_0xba9e('0x38')]=_0xba2d70[_0xba9e('0x38')]?_0xba2d70[_0xba9e('0x38')]:_0x157e46;_0xba2d70[_0xba9e('0x39')]=_0xba2d70[_0xba9e('0x39')]?_0xba2d70[_0xba9e('0x39')]:_0x157e46;_0xba2d70[_0xba9e('0x3b')]=getSeconds(_0xba2d70[_0xba9e('0x38')]||0x0,_0xba2d70[_0xba9e('0x37')]||0x0);_0xba2d70['talktime']=_0xba2d70[_0xba9e('0x40')]?getSeconds(_0xba2d70[_0xba9e('0x39')],_0xba2d70['answertime']):0x0;};exports[_0xba9e('0x41')]=function(_0x4cf75f){return _0x4cf75f===_0xba9e('0x42');};exports[_0xba9e('0x43')]=function(_0x35e4d8,_0x45bc4e,_0x2829df,_0x2d3b32,_0x5d4aa0){var _0x567440=_0x2d3b32?'RECALL':_0x35e4d8['calleridname'];_0x567440=_0x5d4aa0?_0xba9e('0x44'):_0x567440;return{'actionid':_0x35e4d8['uniqueid'],'action':_0xba9e('0x45'),'channel':_0x35e4d8[_0xba9e('0x46')],'callerid':util[_0xba9e('0x11')](_0xba9e('0x12'),_0x567440,_0x35e4d8['calleridnum']),'Exten':_0xba9e('0x24'),'Context':_0xba9e('0x47'),'Priority':'1','variable':_0x2829df,'timeout':(_0x45bc4e[_0xba9e('0x48')]||0x1e)*0x3e8,'async':!![],'channelid':_0x35e4d8[_0xba9e('0x49')]};};exports[_0xba9e('0x4a')]=function(_0xc2dd53){return _0xc2dd53[_0xba9e('0x4b')]+_0xc2dd53['countcongestionretry']+_0xc2dd53[_0xba9e('0x4c')]+_0xc2dd53[_0xba9e('0x4d')]+_0xc2dd53[_0xba9e('0x4e')];};exports[_0xba9e('0x4f')]=function(_0xe29d12){var _0x4d8717=_[_0xba9e('0x50')](_0xe29d12);_0x4d8717[_0xba9e('0x3a')]=0xf;_0x4d8717[_0xba9e('0x36')]='Global';return _0x4d8717;};exports[_0xba9e('0x51')]=function(_0xe90feb,_0x5e6270,_0x484bee){var _0x1ba39e={};_0x1ba39e[_0x5e6270]=_0xe90feb[_0x5e6270];_0x1ba39e[_0xba9e('0x52')]=![];_0x1ba39e['scheduledat']=moment()[_0xba9e('0x53')](_0x484bee,_0xba9e('0x54'))[_0xba9e('0x11')]('YYYY-MM-DD\x20HH:mm:ss');_0x1ba39e[_0xba9e('0x19')]=_0xe90feb['ContactId'];_0x1ba39e[_0xba9e('0x55')]=_0xe90feb['ListId'];_0x1ba39e[_0xba9e('0x1b')]=_0xe90feb['VoiceQueueId']||undefined;return _0x1ba39e;};exports[_0xba9e('0x56')]=function(_0x364586,_0x209c85){if(!_[_0xba9e('0x15')](_0x364586)){if(_0x364586[_0xba9e('0x57')]>0x0){_0x364586[_0xba9e('0x57')]-=0x1;}else{logger[_0xba9e('0xc')](_0x209c85,_0xba9e('0x58'));}}else{logger['error'](_0x209c85,_0xba9e('0x59'));}};exports['IsNotLoggedIn']=function(_0x52b004){if(_0x52b004<=0x0){return!![];}return![];};function buildObj(_0x280c32,_0x5229c3,_0x17685a){_0x280c32[_0xba9e('0x5a')]=_0x5229c3;_0x280c32['name']=_0x280c32[_0xba9e('0x5b')];_0x280c32[_0xba9e('0x5c')]=_0x280c32['channelAgent'];_0x280c32[_0xba9e('0x5d')]='voice';if(_0x17685a){_0x280c32[_0xba9e('0x5e')]=_0x17685a['mandatoryDisposition'];}return _0x280c32;}exports[_0xba9e('0x5f')]=buildObj;exports[_0xba9e('0x60')]=function(_0x1ff830){var _0x39cb62={};_0x39cb62[_0xba9e('0x5b')]=_0x1ff830[_0xba9e('0x5b')];_0x39cb62[_0xba9e('0x5c')]=_0x1ff830[_0xba9e('0x46')];_0x39cb62[_0xba9e('0x49')]=_0x1ff830[_0xba9e('0x49')];return _0x39cb62;};exports[_0xba9e('0x61')]=function(_0x28d54c){var _0x468f42=[];for(var _0x3a42c8 in _0x28d54c){if(_0x28d54c[_0xba9e('0x2a')](_0x3a42c8)){if(!_[_0xba9e('0x15')](_0x28d54c[_0x3a42c8])&&_0x28d54c[_0x3a42c8][_0xba9e('0x3a')]===_0xba9e('0x62')&&_0x28d54c[_0x3a42c8][_0xba9e('0x63')]===_0xba9e('0x64')){_0x468f42[_0xba9e('0x65')](_0x28d54c[_0x3a42c8]['id']);}}}return _0x468f42;};exports[_0xba9e('0x66')]=function(_0x568320){var _0x3baf96=moment()[_0xba9e('0x5')](0x0);var _0x423250=moment(_0x568320)[_0xba9e('0x5')](0x0);return _0x3baf96[_0xba9e('0x6')](_0x423250,_0xba9e('0x67'));};exports[_0xba9e('0x68')]=function(_0x1cfd45){return{'active':![],'recallme':![],'UserId':null,'ContactId':_0x1cfd45[_0xba9e('0x19')],'ListId':_0x1cfd45[_0xba9e('0x55')],'VoiceQueueId':_0x1cfd45[_0xba9e('0x1b')]||undefined,'CampaignId':_0x1cfd45[_0xba9e('0x69')]||undefined};};exports[_0xba9e('0x6a')]=function(_0x4e0b38){if(_0x4e0b38==='uniqueid'||_0x4e0b38===_0xba9e('0x6b')||_0x4e0b38===_0xba9e('0x5b')||_0x4e0b38===_0xba9e('0x6c')||_0x4e0b38==='campaigntype'||_0x4e0b38===_0xba9e('0x6d')||_0x4e0b38===_0xba9e('0x3d')||_0x4e0b38===_0xba9e('0x46')||_0x4e0b38===_0xba9e('0x18')||_0x4e0b38===_0xba9e('0x52')||_0x4e0b38===_0xba9e('0x6e')||_0x4e0b38==='scheduledat'||_0x4e0b38==='countbusyretry'||_0x4e0b38==='countcongestionretry'||_0x4e0b38===_0xba9e('0x4c')||_0x4e0b38===_0xba9e('0x6f')||_0x4e0b38==='callback'||_0x4e0b38===_0xba9e('0x70')||_0x4e0b38===_0xba9e('0x71')||_0x4e0b38===_0xba9e('0x72')||_0x4e0b38===_0xba9e('0x19')||_0x4e0b38===_0xba9e('0x55')||_0x4e0b38==='UserId'||_0x4e0b38===_0xba9e('0x1b')||_0x4e0b38===_0xba9e('0x73')||_0x4e0b38===_0xba9e('0x74')||_0x4e0b38===_0xba9e('0x75')||_0x4e0b38===_0xba9e('0x76')||_0x4e0b38==='xmd-listid'||_0x4e0b38==='xmd-dialurl'||_0x4e0b38===_0xba9e('0x77')||_0x4e0b38==='xmd-dialoptions'||_0x4e0b38===_0xba9e('0x78')||_0x4e0b38==='xmd-dialchannel'||_0x4e0b38===_0xba9e('0x79')||_0x4e0b38===_0xba9e('0x7a')||_0x4e0b38===_0xba9e('0x7b')||_0x4e0b38===_0xba9e('0x7c')||_0x4e0b38===_0xba9e('0x7d')||_0x4e0b38===_0xba9e('0x7e')||_0x4e0b38===_0xba9e('0x7f')||_0x4e0b38===_0xba9e('0x80')||_0x4e0b38===_0xba9e('0x81')||_0x4e0b38===_0xba9e('0x82')||_0x4e0b38===_0xba9e('0x83')||_0x4e0b38==='rtpaudioqosrtt'||_0x4e0b38===_0xba9e('0x84')||_0x4e0b38===_0xba9e('0x7e')||_0x4e0b38===_0xba9e('0x7f')||_0x4e0b38===_0xba9e('0x80')||_0x4e0b38===_0xba9e('0x81')||_0x4e0b38==='rtpaudioqosloss'||_0x4e0b38==='rtpaudioqoslossbridged'||_0x4e0b38===_0xba9e('0x85')||_0x4e0b38===_0xba9e('0x84')||_0x4e0b38===_0xba9e('0x86')||_0x4e0b38===_0xba9e('0x87')||_0x4e0b38===_0xba9e('0x3a')||_0x4e0b38===_0xba9e('0x36')){return![];}return!![];};exports[_0xba9e('0x88')]=function(_0xfee90b,_0x144db3){var _0x1470c0,_0x518690,_0x4ccf98;if(_0x144db3<=0x0){_0x144db3=0x1;}_0x1470c0=new RegExp(_0xba9e('0x89')+_0x144db3+'}$');_0x518690=Math[_0xba9e('0x8a')](0xa,_0x144db3-0x1);_0x4ccf98=Math[_0xba9e('0x8a')](0xa,_0x144db3)-0x1;return util[_0xba9e('0x11')]('%s',_[_0xba9e('0x8b')](_0xfee90b,_0x1470c0,_['random'](_0x518690,_0x4ccf98)));};exports[_0xba9e('0x8c')]=function(_0x1000ba){var _0x216074=_0x1000ba[_0xba9e('0x8d')](/"(.*?)"/);return _0x216074?_0x216074[0x1]:_0x1000ba;};exports[_0xba9e('0x8e')]=function(_0x33f182){var _0x3544b6=_0x33f182[_0xba9e('0x8d')](/<(.*?)>/);return _0x3544b6?_0x3544b6[0x1]:_0x33f182;};function buildNoAnswerEventPayload(_0x387670,_0x10a04f){var _0x331430=buildObj(_0x387670,'noanswer');if(!_[_0xba9e('0x10')](_0x10a04f[_0xba9e('0x8f')])){Object[_0xba9e('0x90')](_0x10a04f[_0xba9e('0x8f')])[_0xba9e('0x91')](function(_0x154228){_0x331430[_0x154228['toLowerCase']()]=_0x10a04f[_0xba9e('0x8f')][_0x154228];});}return _0x331430;}exports[_0xba9e('0x92')]=buildNoAnswerEventPayload;
\ No newline at end of file