82ded97640d5ecf5edb684697eceb4e38c016f87
[motion-next.git] / server / services / ami / preview / util / util.js
1 const a1090_0x260c=['\x22agi://%s/square,%s\x22','rtpaudioqoslossbridged','queue','YYYY-MM-DD\x20HH:mm:ss','Queue','filterKey','callbackuniqueid','dialer','tags','lastevent','match','membername','util','VoiceQueueId','statedesc','talktime','\x22%s\x22\x20<%s>','milliseconds','monitor_format','xcally-motion-preview','agiIp','addVariables','xmd-agi','countbusyretry','RECALL','scheduledat','xmd-queue','xmd-contactid','sipcallid','rtpaudioqosjitterbridged','loggerCatch','bridgepvtcallid','clone','buildObj','from-sip','string','XMD-','originatecalleridname','\x22rtTxX%s%s\x22','status','uniqueid','dialAnswer','starttime','Global','toLowerVariables','calleridnum','inspect','diff','xmd-dialoptions','xmd-phone','IsNotLoggedIn','rtpaudioqosrttbridged','logger','minutes','message','seconds','NONE','xmd-callerid','[decrementTalkink]\x20object\x20talking\x20is\x20negative','loggerError','callbackat','isNil','ringtime','isActive','getDiff','ContactId','Contact','state','[updateOriginated]\x20object\x20originated\x20is\x20negative','rtpaudioqosjitter','xmd-listid','[updateOriginated]\x20is\x20null\x20or\x20undefined','undefined','[decrementTalkink]\x20is\x20null\x20or\x20undefined','originatecalleridnum','isFailure','dialOriginateTimeout','random','rtpaudioqosbridged','countnoanswerretry','dialQueueProject2','extractCalleridName','info','add','BOOKED','createdAt','moment','lodash','timeout','extractCalleridNumber','calleridname','active','rtpaudioqos','getCallerId','buildAcw','xmd-cdrtype','logger2','updateOriginated','originate','%s%s','format','responsetime','recallme','not_inuse','createBody','channelAgent','xmd-dialchannel','rtpaudioqosloss','name','isUndefined','dialPreviewUrl','answertime','reachable','logCustomer','agentReadyId','logAgent','originated','campaigntype','interface','_XCALLY_MIXMONITOR_UNIQUEID','error','countcongestionretry','xmd-dialurl','endtime','\x5cw{0,','cloneAction','countagentrejectretry','countnosuchnumberretry','dialQueueProject','CampaignId','isEmpty','scheduledAt','pTalking','pow','Failure','rtpaudioqosrtt','UserId','ListId','type','decrementTalkink','variablesAction','toUpper'];(function(_0x597831,_0x260c8e){const _0x5de39a=function(_0x5c3854){while(--_0x5c3854){_0x597831['push'](_0x597831['shift']());}};_0x5de39a(++_0x260c8e);}(a1090_0x260c,0x1c1));const a1090_0x5de3=function(_0x597831,_0x260c8e){_0x597831=_0x597831-0x0;let _0x5de39a=a1090_0x260c[_0x597831];return _0x5de39a;};const _0x384fc5=a1090_0x5de3;'use strict';const util=require(_0x384fc5('0x83')),_=require(_0x384fc5('0x40')),moment=require(_0x384fc5('0x3f')),logger=require('../../../../config/logger')('preview'),{getConfigService}=require('../../../../config/config.service');function getSeconds(_0x5c3854,_0x3dc278){const _0x5d144a=_0x384fc5,_0x275da7=moment(_0x5c3854)[_0x5d144a('0x88')](0x0),_0x3beb71=moment(_0x3dc278)[_0x5d144a('0x88')](0x0);return _0x275da7[_0x5d144a('0x18')](_0x3beb71,_0x5d144a('0x20'));}exports[_0x384fc5('0x7')]=function(_0x4331a6){return function(_0x42da43){const _0x48e057=a1090_0x5de3;logger[_0x48e057('0x61')](_0x4331a6,util[_0x48e057('0x17')](_0x42da43,{'showHidden':![],'depth':null}));};},exports[_0x384fc5('0x1d')]=function(_0xa56370,_0x4dfe03){const _0xea7d93=_0x384fc5;logger['info'](_0xa56370,util[_0xea7d93('0x17')](_0x4dfe03,{'showHidden':![],'depth':null}));},exports[_0x384fc5('0x24')]=function(_0x559868,_0x15d737){const _0x4e174f=_0x384fc5;logger[_0x4e174f('0x61')](_0x559868,util['inspect'](_0x15d737,{'showHidden':![],'depth':null}));},exports[_0x384fc5('0x49')]=function(_0x288bbf){return function(_0x1c6c1b){const _0xdb0ef5=a1090_0x5de3;logger[_0xdb0ef5('0x3b')](_0x288bbf,util['inspect'](_0x1c6c1b,{'showHidden':![],'depth':null}));};},exports[_0x384fc5('0x1f')]=function(_0x4d574c,_0x176df7,_0x3ff139){return{'message':_0x4d574c,'unlock':_0x176df7,'active':_0x3ff139};},exports[_0x384fc5('0x46')]=function(_0x2e29f8,_0x489e71,_0x9d73de){const _0x209330=_0x384fc5;if(!_['isUndefined'](_0x9d73de)&&_0x209330('0xc')===typeof _0x9d73de&&!_[_0x209330('0x6b')](_0x9d73de)){if(!_[_0x209330('0x56')](_0x489e71)&&'string'===typeof _0x489e71&&!_[_0x209330('0x6b')](_0x489e71))return util[_0x209330('0x4d')](_0x209330('0x87'),_0x489e71,_0x9d73de);return util[_0x209330('0x4d')](_0x209330('0x87'),_0x9d73de,_0x9d73de);}if(!_[_0x209330('0x56')](_0x2e29f8)&&_0x209330('0xc')===typeof _0x2e29f8&&!_['isEmpty'](_0x2e29f8))return _0x2e29f8;return'\x22\x22\x20<>';},exports[_0x384fc5('0x28')]=function(_0xf967d2){const _0x3a3c79=_0x384fc5;if(_[_0x3a3c79('0x26')](_0xf967d2))return![];return _0xf967d2;},exports[_0x384fc5('0x8c')]=function(_0x30780e,_0x303a11,_0x36009d,_0x274a15,_0x3da07c,_0x47129e){const _0x1c9a14=_0x384fc5,_0x11ee56=getConfigService(),_0x625614={'XMD-QUEUE':_0x303a11['Queue']?_0x303a11[_0x1c9a14('0x7b')]['name']:'','XMD-CALLERID':_0x274a15,'XMD-CALLERID-PREVIEW':_0x47129e?util[_0x1c9a14('0x4d')]('\x22%s\x22\x20<%s>',_0x47129e[_0x1c9a14('0x43')],_0x47129e[_0x1c9a14('0x16')]):_0x274a15,'XMD-DIALID':_0x3da07c,'XMD-CONTACTID':_0x303a11[_0x1c9a14('0x2a')],'XMD-CDRTYPE':_0x1c9a14('0x7e'),'CALLERID(all)':_0x274a15,'XMD-VOICEQUEUEID':_0x303a11[_0x1c9a14('0x84')],'XMD-DIALCHANNEL':_0x36009d,'XMD-DIALTIMEOUT':_0x30780e[_0x1c9a14('0x35')]||0x1e,'XMD-DIALOPTIONS':util['format'](_0x1c9a14('0xf'),_0x30780e['dialQueueProject2']?'g':'',_[_0x1c9a14('0x6b')](_0x30780e['monitor_format'])?'':'U(xcally-mixmonitor-context)'),'XMD-DIALURL':_0x30780e[_0x1c9a14('0x57')]||'','XMD-AGI':_0x30780e[_0x1c9a14('0x69')]?util[_0x1c9a14('0x4d')]('\x22agi://%s/square,%s\x22',_0x11ee56[_0x1c9a14('0x8b')],_0x30780e[_0x1c9a14('0x69')]):_0x1c9a14('0x21'),'XMD-AGIAFTER':_0x30780e[_0x1c9a14('0x39')]?util[_0x1c9a14('0x4d')](_0x1c9a14('0x77'),_0x11ee56[_0x1c9a14('0x8b')],_0x30780e[_0x1c9a14('0x39')]):'NONE','XMD-ORIGINATECALLERIDNUM':_0x47129e?_0x47129e[_0x1c9a14('0x33')]:'','XMD-ORIGINATECALLERIDNAME':_0x47129e?_0x47129e[_0x1c9a14('0xe')]:'','XMD-DESTINATION':_0x1c9a14('0x8a')};!_['isEmpty'](_0x30780e[_0x1c9a14('0x89')])&&(_0x625614[util['format']('%s','_XCALLY_MIXMONITOR_FORMAT')]=_0x30780e[_0x1c9a14('0x89')],_0x625614[util['format']('%s',_0x1c9a14('0x60'))]=_0x3da07c);if(_0x303a11&&_0x303a11[_0x1c9a14('0x2b')])for(const _0x81862c in _0x303a11[_0x1c9a14('0x2b')]){typeof _0x303a11['Contact'][_0x81862c]!==_0x1c9a14('0x31')&&(!_[_0x1c9a14('0x26')](_0x303a11[_0x1c9a14('0x2b')][_0x81862c])&&_0x81862c!=='id'&&_0x81862c!==_0x1c9a14('0x7f')&&_0x81862c!==_0x1c9a14('0x3e')&&_0x81862c!=='updatedAt'&&(_0x625614[util[_0x1c9a14('0x4d')](_0x1c9a14('0x4c'),_0x1c9a14('0xd'),_[_0x1c9a14('0x76')](_0x81862c))]=_0x303a11[_0x1c9a14('0x2b')][_0x81862c]));}return _0x625614;},exports[_0x384fc5('0x15')]=function(_0xb54e2c){const _0x35f51e=_0x384fc5,_0x39121a={};for(const _0x36adbf in _0xb54e2c){typeof _0xb54e2c[_0x36adbf]!==_0x35f51e('0x31')&&(_0x39121a[util[_0x35f51e('0x4d')]('%s',_['toLower'](_0x36adbf))]=_0xb54e2c[_0x36adbf]);}return{'variables':_0x39121a};},exports[_0x384fc5('0x4a')]=function(_0x4de6c7,_0x24328d){const _0x466b19=_0x384fc5;!_[_0x466b19('0x26')](_0x4de6c7)?typeof _0x4de6c7['originated']!==_0x466b19('0x31')&&(_0x4de6c7[_0x466b19('0x5d')]>0x0?_0x4de6c7[_0x466b19('0x5d')]-=0x1:logger[_0x466b19('0x61')](_0x466b19('0x2d'),_0x24328d)):logger[_0x466b19('0x61')](_0x466b19('0x30'),_0x24328d);},exports['logBlacklist']=function(_0x4dbd85){const _0x421a2e=_0x384fc5,_0x2a8093=moment()[_0x421a2e('0x4d')]('YYYY-MM-DD\x20HH:mm:ss');_0x4dbd85[_0x421a2e('0x2c')]=0xd,_0x4dbd85[_0x421a2e('0x85')]='Blacklist',_0x4dbd85['starttime']=_0x2a8093,_0x4dbd85[_0x421a2e('0x4e')]=_0x2a8093,_0x4dbd85[_0x421a2e('0x64')]=_0x2a8093;},exports[_0x384fc5('0x5c')]=function(_0x401bc1,_0x1d921f,_0x481fbc){const _0x3ed1fd=_0x384fc5,_0x3bf1c6=moment()[_0x3ed1fd('0x4d')]('YYYY-MM-DD\x20HH:mm:ss');_0x401bc1[_0x3ed1fd('0x2c')]=_0x1d921f,_0x401bc1[_0x3ed1fd('0x85')]=_0x481fbc,_0x401bc1[_0x3ed1fd('0x4e')]=_0x3bf1c6,_0x401bc1[_0x3ed1fd('0x27')]=getSeconds(_0x401bc1[_0x3ed1fd('0x4e')],_0x401bc1[_0x3ed1fd('0x13')]);},exports['logLookAgent']=function(_0x24810a,_0x29f1ab,_0x1985c3){const _0x58e0d5=_0x384fc5;_0x24810a[_0x58e0d5('0x82')]=_0x29f1ab,_0x24810a['UserId']=_0x1985c3;},exports[_0x384fc5('0x5a')]=function(_0x5e54dd,_0x25ec77,_0x37692a){const _0x281932=_0x384fc5,_0x2fe50c=moment()['format'](_0x281932('0x7a'));_0x5e54dd['state']=_0x25ec77,_0x5e54dd[_0x281932('0x85')]=_0x37692a,_0x5e54dd['responsetime']=_0x5e54dd[_0x281932('0x4e')]?_0x5e54dd[_0x281932('0x4e')]:_0x2fe50c,_0x5e54dd[_0x281932('0x64')]=_0x5e54dd[_0x281932('0x64')]?_0x5e54dd[_0x281932('0x64')]:_0x2fe50c,_0x5e54dd['ringtime']=getSeconds(_0x5e54dd[_0x281932('0x4e')]||0x0,_0x5e54dd[_0x281932('0x13')]||0x0),_0x5e54dd[_0x281932('0x86')]=_0x5e54dd[_0x281932('0x58')]?getSeconds(_0x5e54dd[_0x281932('0x64')],_0x5e54dd[_0x281932('0x58')]):0x0;},exports[_0x384fc5('0x34')]=function(_0x3439fc){const _0x2137f0=_0x384fc5;return _0x3439fc===_0x2137f0('0x6f');},exports[_0x384fc5('0x75')]=function(_0x409cac,_0x25c7ce,_0x43b0f4,_0x47cf6f,_0x1c3591){const _0x39b749=_0x384fc5;let _0x2a8914=_0x47cf6f?_0x39b749('0x1'):_0x409cac['calleridname'];return _0x2a8914=_0x1c3591?_0x39b749('0x3d'):_0x2a8914,{'actionid':_0x409cac[_0x39b749('0x11')],'action':_0x39b749('0x4b'),'channel':_0x409cac[_0x39b749('0x52')],'callerid':util[_0x39b749('0x4d')](_0x39b749('0x87'),_0x2a8914,_0x409cac['calleridnum']),'Exten':_0x39b749('0x8a'),'Context':_0x39b749('0xb'),'Priority':'1','variable':_0x43b0f4,'timeout':(_0x25c7ce[_0x39b749('0x41')]||0x1e)*0x3e8,'async':!![],'channelid':_0x409cac[_0x39b749('0x11')]};},exports['totalGlobal']=function(_0x24e178){const _0xddf7ac=_0x384fc5;return _0x24e178[_0xddf7ac('0x0')]+_0x24e178['countcongestionretry']+_0x24e178['countnoanswerretry']+_0x24e178[_0xddf7ac('0x67')]+_0x24e178[_0xddf7ac('0x68')];},exports[_0x384fc5('0x66')]=function(_0xd5dff9){const _0x26eb37=_0x384fc5,_0x162fc4=_[_0x26eb37('0x9')](_0xd5dff9);return _0x162fc4[_0x26eb37('0x2c')]=0xf,_0x162fc4[_0x26eb37('0x85')]=_0x26eb37('0x14'),_0x162fc4;},exports[_0x384fc5('0x6c')]=function(_0x14a23c,_0x1e67ce,_0x48b4ef){const _0x1bc848=_0x384fc5,_0x4da6ff={};return _0x4da6ff[_0x1e67ce]=_0x14a23c[_0x1e67ce],_0x4da6ff[_0x1bc848('0x44')]=![],_0x4da6ff['scheduledat']=moment()[_0x1bc848('0x3c')](_0x48b4ef,_0x1bc848('0x1e'))[_0x1bc848('0x4d')](_0x1bc848('0x7a')),_0x4da6ff[_0x1bc848('0x2a')]=_0x14a23c['ContactId'],_0x4da6ff['ListId']=_0x14a23c['ListId'],_0x4da6ff[_0x1bc848('0x84')]=_0x14a23c['VoiceQueueId']||undefined,_0x4da6ff;},exports[_0x384fc5('0x74')]=function(_0x4b8883,_0x2b19d4){const _0x2aa134=_0x384fc5;!_[_0x2aa134('0x26')](_0x4b8883)?_0x4b8883[_0x2aa134('0x6d')]>0x0?_0x4b8883['pTalking']-=0x1:logger[_0x2aa134('0x61')](_0x2b19d4,_0x2aa134('0x23')):logger['error'](_0x2b19d4,_0x2aa134('0x32'));},exports[_0x384fc5('0x1b')]=function(_0x20529b){if(_0x20529b<=0x0)return!![];return![];},exports[_0x384fc5('0xa')]=function(_0x59db30,_0x5775c3){const _0x310622=_0x384fc5;return _0x59db30[_0x310622('0x80')]=_0x5775c3,_0x59db30[_0x310622('0x55')]=_0x59db30[_0x310622('0x79')],_0x59db30['interface']=_0x59db30[_0x310622('0x52')],_0x59db30;},exports[_0x384fc5('0x47')]=function(_0x585217){const _0x22fb53=_0x384fc5,_0x17c677={};return _0x17c677[_0x22fb53('0x79')]=_0x585217['queue'],_0x17c677[_0x22fb53('0x5f')]=_0x585217[_0x22fb53('0x52')],_0x17c677['uniqueid']=_0x585217[_0x22fb53('0x11')],_0x17c677;},exports[_0x384fc5('0x5b')]=function(_0x508f04){const _0x2bf7bf=_0x384fc5,_0xe49cf1=[];for(const _0x189962 in _0x508f04){typeof _0x508f04[_0x189962]!=='undefined'&&(!_[_0x2bf7bf('0x26')](_0x508f04[_0x189962])&&_0x508f04[_0x189962]['state']===_0x2bf7bf('0x50')&&_0x508f04[_0x189962][_0x2bf7bf('0x10')]===_0x2bf7bf('0x59')&&_0xe49cf1['push'](_0x508f04[_0x189962]['id']));}return _0xe49cf1;},exports[_0x384fc5('0x29')]=function(_0xda6fc2){const _0x44c6dc=_0x384fc5,_0x5643e6=moment()[_0x44c6dc('0x88')](0x0),_0x5be2a4=moment(_0xda6fc2)[_0x44c6dc('0x88')](0x0);return _0x5643e6[_0x44c6dc('0x18')](_0x5be2a4,_0x44c6dc('0x20'));},exports[_0x384fc5('0x51')]=function(_0x53760a){const _0x129bcd=_0x384fc5;return{'active':![],'recallme':![],'UserId':null,'ContactId':_0x53760a[_0x129bcd('0x2a')],'ListId':_0x53760a[_0x129bcd('0x72')],'VoiceQueueId':_0x53760a[_0x129bcd('0x84')]||undefined,'CampaignId':_0x53760a[_0x129bcd('0x6a')]||undefined};},exports[_0x384fc5('0x7c')]=function(_0x4f4cc1){const _0x51faca=_0x384fc5;if(_0x4f4cc1===_0x51faca('0x11')||_0x4f4cc1==='idContact'||_0x4f4cc1==='queue'||_0x4f4cc1===_0x51faca('0x73')||_0x4f4cc1===_0x51faca('0x5e')||_0x4f4cc1===_0x51faca('0x12')||_0x4f4cc1===_0x51faca('0x82')||_0x4f4cc1===_0x51faca('0x52')||_0x4f4cc1===_0x51faca('0x43')||_0x4f4cc1===_0x51faca('0x44')||_0x4f4cc1===_0x51faca('0x16')||_0x4f4cc1===_0x51faca('0x2')||_0x4f4cc1===_0x51faca('0x0')||_0x4f4cc1===_0x51faca('0x62')||_0x4f4cc1===_0x51faca('0x38')||_0x4f4cc1==='countglobal'||_0x4f4cc1==='callback'||_0x4f4cc1===_0x51faca('0x7d')||_0x4f4cc1===_0x51faca('0x25')||_0x4f4cc1===_0x51faca('0x4f')||_0x4f4cc1==='ContactId'||_0x4f4cc1===_0x51faca('0x72')||_0x4f4cc1===_0x51faca('0x71')||_0x4f4cc1===_0x51faca('0x84')||_0x4f4cc1===_0x51faca('0x5')||_0x4f4cc1==='xmd-voicequeueid'||_0x4f4cc1===_0x51faca('0x3')||_0x4f4cc1===_0x51faca('0x1a')||_0x4f4cc1===_0x51faca('0x2f')||_0x4f4cc1===_0x51faca('0x63')||_0x4f4cc1==='xmd-dialtimeout'||_0x4f4cc1===_0x51faca('0x19')||_0x4f4cc1==='xmd-dialid'||_0x4f4cc1===_0x51faca('0x53')||_0x4f4cc1===_0x51faca('0x4')||_0x4f4cc1===_0x51faca('0x48')||_0x4f4cc1===_0x51faca('0x22')||_0x4f4cc1==='xmd-agiafter'||_0x4f4cc1===_0x51faca('0x8d')||_0x4f4cc1===_0x51faca('0x45')||_0x4f4cc1===_0x51faca('0x37')||_0x4f4cc1===_0x51faca('0x2e')||_0x4f4cc1===_0x51faca('0x6')||_0x4f4cc1===_0x51faca('0x54')||_0x4f4cc1===_0x51faca('0x78')||_0x4f4cc1===_0x51faca('0x70')||_0x4f4cc1===_0x51faca('0x1c')||_0x4f4cc1===_0x51faca('0x45')||_0x4f4cc1==='rtpaudioqosbridged'||_0x4f4cc1===_0x51faca('0x2e')||_0x4f4cc1===_0x51faca('0x6')||_0x4f4cc1==='rtpaudioqosloss'||_0x4f4cc1===_0x51faca('0x78')||_0x4f4cc1===_0x51faca('0x70')||_0x4f4cc1===_0x51faca('0x1c')||_0x4f4cc1==='bridgepeer'||_0x4f4cc1===_0x51faca('0x8')||_0x4f4cc1===_0x51faca('0x2c')||_0x4f4cc1===_0x51faca('0x85'))return![];return!![];},exports['getCallerIdRandom']=function(_0xe41acb,_0x342391){const _0x4a0a5e=_0x384fc5;_0x342391<=0x0&&(_0x342391=0x1);const _0x29635e=new RegExp(_0x4a0a5e('0x65')+_0x342391+'}$'),_0x4ad212=Math[_0x4a0a5e('0x6e')](0xa,_0x342391-0x1),_0x1795e5=Math['pow'](0xa,_0x342391)-0x1;return util['format']('%s',_['replace'](_0xe41acb,_0x29635e,_[_0x4a0a5e('0x36')](_0x4ad212,_0x1795e5)));},exports[_0x384fc5('0x3a')]=function(_0x9b8200){const _0x2dd773=_0x384fc5,_0x491cc8=_0x9b8200[_0x2dd773('0x81')](/"(.*?)"/);return _0x491cc8?_0x491cc8[0x1]:_0x9b8200;},exports[_0x384fc5('0x42')]=function(_0xcaf45b){const _0x19f1bd=_0x384fc5,_0xc0c9a3=_0xcaf45b[_0x19f1bd('0x81')](/<(.*?)>/);return _0xc0c9a3?_0xc0c9a3[0x1]:_0xcaf45b;};