Built motion from commit ecf5ab8ec560fd4c6972692268e350fcef2f38e7. Version 3.0.0...
[motion-next.git] / server / services / ami / preview / util / util.js
1 const a1089_0x4023=['replace','string','add','buildObj','responsetime','seconds','xmd-agiafter','countcongestionretry','inspect','\x22%s\x22\x20<%s>','logBlacklist','interface','extractCalleridName','idContact','channelAgent','logLookAgent','countbusyretry','dialQueueProject2','isUndefined','dialAnswer','IsNotLoggedIn','type','info','match','toUpper','diff','format','xmd-callerid','sipcallid','YYYY-MM-DD\x20HH:mm:ss','scheduledat','name','dialPreviewUrl','\x22\x22\x20<>','undefined','talktime','Contact','xmd-dialid','originatecalleridnum','scheduledAt','[updateOriginated]\x20is\x20null\x20or\x20undefined','agentReadyId','logger2','rtpaudioqosjitter','not_inuse','calleridname','rtpaudioqosloss','loggerError','xmd-dialchannel','calleridnum','ListId','rtpaudioqos','xmd-phone','lodash','originated','ContactId','state','originatecalleridname','countnosuchnumberretry','Failure','pow','decrementTalkink','Queue','loggerCatch','updatedAt','rtpaudioqosbridged','queue','callbackuniqueid','minutes','pTalking','toLower','countglobal','_XCALLY_MIXMONITOR_UNIQUEID','NONE','getCallerId','createBody','rtpaudioqoslossbridged','rtpaudioqosrtt','membername','milliseconds','dialOriginateTimeout','[decrementTalkink]\x20is\x20null\x20or\x20undefined','variablesAction','error','dialQueueProject','monitor_format','[decrementTalkink]\x20object\x20talking\x20is\x20negative','xmd-queue','xmd-dialtimeout','logAgent','isNil','dialer','originate','../../../../config/logger','logger','xmd-dialurl','isFailure','createdAt','statedesc','extractCalleridNumber','RECALL','clone','xmd-dialoptions','VoiceQueueId','reachable','rtpaudioqosrttbridged','U(xcally-mixmonitor-context)','isActive','countnoanswerretry','callbackat','Global','xmd-listid','addVariables','util','lastevent','answertime','\x22agi://%s/square,%s\x22','xmd-agi','CampaignId','uniqueid','%s%s','starttime','push','Blacklist','xmd-contactid','isEmpty','endtime','_XCALLY_MIXMONITOR_FORMAT','message','timeout','status','active','xmd-cdrtype'];(function(_0x5afc32,_0x40230f){const _0x177346=function(_0x329e1a){while(--_0x329e1a){_0x5afc32['push'](_0x5afc32['shift']());}};_0x177346(++_0x40230f);}(a1089_0x4023,0x114));const a1089_0x1773=function(_0x5afc32,_0x40230f){_0x5afc32=_0x5afc32-0x0;let _0x177346=a1089_0x4023[_0x5afc32];return _0x177346;};const _0x384e63=a1089_0x1773;'use strict';const util=require(_0x384e63('0x67')),_=require(_0x384e63('0x2b')),moment=require('moment'),logger=require(_0x384e63('0x53'))('preview'),{getConfigService}=require('../../../../config/config.service');function getSeconds(_0x329e1a,_0x59e0e8){const _0x526548=_0x384e63,_0x21231f=moment(_0x329e1a)[_0x526548('0x45')](0x0),_0x5f08a5=moment(_0x59e0e8)[_0x526548('0x45')](0x0);return _0x21231f[_0x526548('0xf')](_0x5f08a5,'seconds');}exports[_0x384e63('0x35')]=function(_0x1f85bd){return function(_0x41ef5b){const _0x3b0902=a1089_0x1773;logger[_0x3b0902('0x49')](_0x1f85bd,util[_0x3b0902('0x83')](_0x41ef5b,{'showHidden':![],'depth':null}));};},exports[_0x384e63('0x54')]=function(_0x44e530,_0x5334eb){const _0x24b1a3=_0x384e63;logger[_0x24b1a3('0xc')](_0x44e530,util[_0x24b1a3('0x83')](_0x5334eb,{'showHidden':![],'depth':null}));},exports[_0x384e63('0x25')]=function(_0x5d57d0,_0x49bf0b){const _0x1de256=_0x384e63;logger[_0x1de256('0x49')](_0x5d57d0,util[_0x1de256('0x83')](_0x49bf0b,{'showHidden':![],'depth':null}));},exports[_0x384e63('0x20')]=function(_0x3f068a){return function(_0x443cd8){const _0x2a51b1=a1089_0x1773;logger['info'](_0x3f068a,util[_0x2a51b1('0x83')](_0x443cd8,{'showHidden':![],'depth':null}));};},exports[_0x384e63('0x76')]=function(_0x11b263,_0x4c7927,_0x15ddcf){return{'message':_0x11b263,'unlock':_0x4c7927,'active':_0x15ddcf};},exports[_0x384e63('0x40')]=function(_0x30224c,_0x5b055e,_0x4ae7de){const _0x5198b1=_0x384e63;if(!_[_0x5198b1('0x8')](_0x4ae7de)&&'string'===typeof _0x4ae7de&&!_[_0x5198b1('0x73')](_0x4ae7de)){if(!_['isUndefined'](_0x5b055e)&&_0x5198b1('0x7c')===typeof _0x5b055e&&!_[_0x5198b1('0x73')](_0x5b055e))return util[_0x5198b1('0x10')](_0x5198b1('0x84'),_0x5b055e,_0x4ae7de);return util['format'](_0x5198b1('0x84'),_0x4ae7de,_0x4ae7de);}if(!_[_0x5198b1('0x8')](_0x30224c)&&'string'===typeof _0x30224c&&!_[_0x5198b1('0x73')](_0x30224c))return _0x30224c;return _0x5198b1('0x17');},exports[_0x384e63('0x61')]=function(_0x214a14){const _0x481ac6=_0x384e63;if(_[_0x481ac6('0x50')](_0x214a14))return![];return _0x214a14;},exports[_0x384e63('0x66')]=function(_0x198573,_0x56db47,_0xd49825,_0x15e296,_0x186ded,_0xa99e62){const _0x2b704f=_0x384e63,_0x210811=getConfigService(),_0x13008a={'XMD-QUEUE':_0x56db47[_0x2b704f('0x34')]?_0x56db47[_0x2b704f('0x34')]['name']:'','XMD-CALLERID':_0x15e296,'XMD-CALLERID-PREVIEW':_0xa99e62?util[_0x2b704f('0x10')]('\x22%s\x22\x20<%s>',_0xa99e62[_0x2b704f('0x23')],_0xa99e62[_0x2b704f('0x27')]):_0x15e296,'XMD-DIALID':_0x186ded,'XMD-CONTACTID':_0x56db47[_0x2b704f('0x2d')],'XMD-CDRTYPE':_0x2b704f('0x51'),'CALLERID(all)':_0x15e296,'XMD-VOICEQUEUEID':_0x56db47[_0x2b704f('0x5d')],'XMD-DIALCHANNEL':_0xd49825,'XMD-DIALTIMEOUT':_0x198573[_0x2b704f('0x46')]||0x1e,'XMD-DIALOPTIONS':util['format']('\x22rtTxX%s%s\x22',_0x198573[_0x2b704f('0x7')]?'g':'',_[_0x2b704f('0x73')](_0x198573[_0x2b704f('0x4b')])?'':_0x2b704f('0x60')),'XMD-DIALURL':_0x198573[_0x2b704f('0x16')]||'','XMD-AGI':_0x198573['dialQueueProject']?util[_0x2b704f('0x10')](_0x2b704f('0x6a'),_0x210811['agiIp'],_0x198573[_0x2b704f('0x4a')]):_0x2b704f('0x3f'),'XMD-AGIAFTER':_0x198573['dialQueueProject2']?util[_0x2b704f('0x10')](_0x2b704f('0x6a'),_0x210811['agiIp'],_0x198573[_0x2b704f('0x7')]):'NONE','XMD-ORIGINATECALLERIDNUM':_0xa99e62?_0xa99e62[_0x2b704f('0x1c')]:'','XMD-ORIGINATECALLERIDNAME':_0xa99e62?_0xa99e62[_0x2b704f('0x2f')]:'','XMD-DESTINATION':'xcally-motion-preview'};!_[_0x2b704f('0x73')](_0x198573[_0x2b704f('0x4b')])&&(_0x13008a[util['format']('%s',_0x2b704f('0x75'))]=_0x198573[_0x2b704f('0x4b')],_0x13008a[util[_0x2b704f('0x10')]('%s',_0x2b704f('0x3e'))]=_0x186ded);if(_0x56db47&&_0x56db47[_0x2b704f('0x1a')])for(const _0x372de7 in _0x56db47[_0x2b704f('0x1a')]){typeof _0x56db47[_0x2b704f('0x1a')][_0x372de7]!==_0x2b704f('0x18')&&(!_[_0x2b704f('0x50')](_0x56db47[_0x2b704f('0x1a')][_0x372de7])&&_0x372de7!=='id'&&_0x372de7!=='tags'&&_0x372de7!==_0x2b704f('0x57')&&_0x372de7!==_0x2b704f('0x36')&&(_0x13008a[util[_0x2b704f('0x10')](_0x2b704f('0x6e'),'XMD-',_[_0x2b704f('0xe')](_0x372de7))]=_0x56db47['Contact'][_0x372de7]));}return _0x13008a;},exports['toLowerVariables']=function(_0x4df52b){const _0x27386f=_0x384e63,_0x251bd5={};for(const _0xdb1271 in _0x4df52b){typeof _0x4df52b[_0xdb1271]!==_0x27386f('0x18')&&(_0x251bd5[util[_0x27386f('0x10')]('%s',_[_0x27386f('0x3c')](_0xdb1271))]=_0x4df52b[_0xdb1271]);}return{'variables':_0x251bd5};},exports['updateOriginated']=function(_0x360c19,_0x54f110){const _0x9b1365=_0x384e63;!_['isNil'](_0x360c19)?typeof _0x360c19[_0x9b1365('0x2c')]!==_0x9b1365('0x18')&&(_0x360c19[_0x9b1365('0x2c')]>0x0?_0x360c19[_0x9b1365('0x2c')]-=0x1:logger[_0x9b1365('0x49')]('[updateOriginated]\x20object\x20originated\x20is\x20negative',_0x54f110)):logger['error'](_0x9b1365('0x1e'),_0x54f110);},exports[_0x384e63('0x0')]=function(_0x4cf974){const _0x92c342=_0x384e63,_0x51655c=moment()[_0x92c342('0x10')](_0x92c342('0x13'));_0x4cf974[_0x92c342('0x2e')]=0xd,_0x4cf974[_0x92c342('0x58')]=_0x92c342('0x71'),_0x4cf974[_0x92c342('0x6f')]=_0x51655c,_0x4cf974['responsetime']=_0x51655c,_0x4cf974[_0x92c342('0x74')]=_0x51655c;},exports[_0x384e63('0x4f')]=function(_0x49ef08,_0x422e19,_0x4469ba){const _0x4b87d5=_0x384e63,_0x2ee462=moment()[_0x4b87d5('0x10')](_0x4b87d5('0x13'));_0x49ef08[_0x4b87d5('0x2e')]=_0x422e19,_0x49ef08[_0x4b87d5('0x58')]=_0x4469ba,_0x49ef08[_0x4b87d5('0x7f')]=_0x2ee462,_0x49ef08['ringtime']=getSeconds(_0x49ef08[_0x4b87d5('0x7f')],_0x49ef08[_0x4b87d5('0x6f')]);},exports[_0x384e63('0x5')]=function(_0x10b522,_0x2b0c9f,_0x298d4d){const _0x1526b1=_0x384e63;_0x10b522[_0x1526b1('0x44')]=_0x2b0c9f,_0x10b522['UserId']=_0x298d4d;},exports['logCustomer']=function(_0x31992e,_0x9be352,_0x3db220){const _0xcb9872=_0x384e63,_0x288494=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0x31992e[_0xcb9872('0x2e')]=_0x9be352,_0x31992e['statedesc']=_0x3db220,_0x31992e[_0xcb9872('0x7f')]=_0x31992e['responsetime']?_0x31992e[_0xcb9872('0x7f')]:_0x288494,_0x31992e[_0xcb9872('0x74')]=_0x31992e['endtime']?_0x31992e[_0xcb9872('0x74')]:_0x288494,_0x31992e['ringtime']=getSeconds(_0x31992e['responsetime']||0x0,_0x31992e[_0xcb9872('0x6f')]||0x0),_0x31992e[_0xcb9872('0x19')]=_0x31992e[_0xcb9872('0x69')]?getSeconds(_0x31992e[_0xcb9872('0x74')],_0x31992e[_0xcb9872('0x69')]):0x0;},exports[_0x384e63('0x56')]=function(_0x552222){const _0x5645a0=_0x384e63;return _0x552222===_0x5645a0('0x31');},exports[_0x384e63('0x48')]=function(_0x5558f1,_0x384d7d,_0x3445ba,_0x51b05f,_0xace8e1){const _0x2c3399=_0x384e63;let _0x4b2385=_0x51b05f?_0x2c3399('0x5a'):_0x5558f1[_0x2c3399('0x23')];return _0x4b2385=_0xace8e1?'BOOKED':_0x4b2385,{'actionid':_0x5558f1[_0x2c3399('0x6d')],'action':_0x2c3399('0x52'),'channel':_0x5558f1[_0x2c3399('0x4')],'callerid':util[_0x2c3399('0x10')](_0x2c3399('0x84'),_0x4b2385,_0x5558f1[_0x2c3399('0x27')]),'Exten':'xcally-motion-preview','Context':'from-sip','Priority':'1','variable':_0x3445ba,'timeout':(_0x384d7d[_0x2c3399('0x77')]||0x1e)*0x3e8,'async':!![],'channelid':_0x5558f1['uniqueid']};},exports['totalGlobal']=function(_0x2948ab){const _0x4d70d9=_0x384e63;return _0x2948ab[_0x4d70d9('0x6')]+_0x2948ab[_0x4d70d9('0x82')]+_0x2948ab['countnoanswerretry']+_0x2948ab['countagentrejectretry']+_0x2948ab[_0x4d70d9('0x30')];},exports['cloneAction']=function(_0xc5fdd9){const _0x4be922=_0x384e63,_0x319264=_[_0x4be922('0x5b')](_0xc5fdd9);return _0x319264[_0x4be922('0x2e')]=0xf,_0x319264[_0x4be922('0x58')]=_0x4be922('0x64'),_0x319264;},exports[_0x384e63('0x1d')]=function(_0x4d81d2,_0x2948da,_0x16a2e4){const _0x1605bf=_0x384e63,_0x11ea95={};return _0x11ea95[_0x2948da]=_0x4d81d2[_0x2948da],_0x11ea95[_0x1605bf('0x79')]=![],_0x11ea95[_0x1605bf('0x14')]=moment()[_0x1605bf('0x7d')](_0x16a2e4,_0x1605bf('0x3a'))['format'](_0x1605bf('0x13')),_0x11ea95[_0x1605bf('0x2d')]=_0x4d81d2[_0x1605bf('0x2d')],_0x11ea95[_0x1605bf('0x28')]=_0x4d81d2[_0x1605bf('0x28')],_0x11ea95[_0x1605bf('0x5d')]=_0x4d81d2[_0x1605bf('0x5d')]||undefined,_0x11ea95;},exports[_0x384e63('0x33')]=function(_0x532e97,_0x2fde61){const _0x536551=_0x384e63;!_[_0x536551('0x50')](_0x532e97)?_0x532e97[_0x536551('0x3b')]>0x0?_0x532e97[_0x536551('0x3b')]-=0x1:logger['error'](_0x2fde61,_0x536551('0x4c')):logger['error'](_0x2fde61,_0x536551('0x47'));},exports[_0x384e63('0xa')]=function(_0x314dcf){if(_0x314dcf<=0x0)return!![];return![];},exports[_0x384e63('0x7e')]=function(_0x22a671,_0x32bb5c){const _0x2264ff=_0x384e63;return _0x22a671[_0x2264ff('0x68')]=_0x32bb5c,_0x22a671[_0x2264ff('0x15')]=_0x22a671[_0x2264ff('0x38')],_0x22a671[_0x2264ff('0x1')]=_0x22a671[_0x2264ff('0x4')],_0x22a671;},exports['buildAcw']=function(_0x3b96cf){const _0x10d047=_0x384e63,_0x53eaba={};return _0x53eaba['queue']=_0x3b96cf[_0x10d047('0x38')],_0x53eaba[_0x10d047('0x1')]=_0x3b96cf[_0x10d047('0x4')],_0x53eaba['uniqueid']=_0x3b96cf[_0x10d047('0x6d')],_0x53eaba;},exports[_0x384e63('0x1f')]=function(_0x4f688b){const _0x67040d=_0x384e63,_0x37cdea=[];for(const _0x317141 in _0x4f688b){typeof _0x4f688b[_0x317141]!==_0x67040d('0x18')&&(!_['isNil'](_0x4f688b[_0x317141])&&_0x4f688b[_0x317141][_0x67040d('0x2e')]===_0x67040d('0x22')&&_0x4f688b[_0x317141][_0x67040d('0x78')]===_0x67040d('0x5e')&&_0x37cdea[_0x67040d('0x70')](_0x4f688b[_0x317141]['id']));}return _0x37cdea;},exports['getDiff']=function(_0x1d8b4a){const _0x18c6ba=_0x384e63,_0x6549a2=moment()[_0x18c6ba('0x45')](0x0),_0x2f40fc=moment(_0x1d8b4a)[_0x18c6ba('0x45')](0x0);return _0x6549a2[_0x18c6ba('0xf')](_0x2f40fc,_0x18c6ba('0x80'));},exports[_0x384e63('0x41')]=function(_0x513a4a){const _0xe31acc=_0x384e63;return{'active':![],'recallme':![],'UserId':null,'ContactId':_0x513a4a[_0xe31acc('0x2d')],'ListId':_0x513a4a[_0xe31acc('0x28')],'VoiceQueueId':_0x513a4a[_0xe31acc('0x5d')]||undefined,'CampaignId':_0x513a4a[_0xe31acc('0x6c')]||undefined};},exports['filterKey']=function(_0x5cbdc1){const _0x5354d6=_0x384e63;if(_0x5cbdc1===_0x5354d6('0x6d')||_0x5cbdc1===_0x5354d6('0x3')||_0x5cbdc1===_0x5354d6('0x38')||_0x5cbdc1===_0x5354d6('0xb')||_0x5cbdc1==='campaigntype'||_0x5cbdc1===_0x5354d6('0x9')||_0x5cbdc1===_0x5354d6('0x44')||_0x5cbdc1==='channelAgent'||_0x5cbdc1==='calleridname'||_0x5cbdc1===_0x5354d6('0x79')||_0x5cbdc1===_0x5354d6('0x27')||_0x5cbdc1===_0x5354d6('0x14')||_0x5cbdc1===_0x5354d6('0x6')||_0x5cbdc1===_0x5354d6('0x82')||_0x5cbdc1===_0x5354d6('0x62')||_0x5cbdc1===_0x5354d6('0x3d')||_0x5cbdc1==='callback'||_0x5cbdc1===_0x5354d6('0x39')||_0x5cbdc1===_0x5354d6('0x63')||_0x5cbdc1==='recallme'||_0x5cbdc1===_0x5354d6('0x2d')||_0x5cbdc1==='ListId'||_0x5cbdc1==='UserId'||_0x5cbdc1===_0x5354d6('0x5d')||_0x5cbdc1===_0x5354d6('0x12')||_0x5cbdc1==='xmd-voicequeueid'||_0x5cbdc1===_0x5354d6('0x4d')||_0x5cbdc1===_0x5354d6('0x2a')||_0x5cbdc1===_0x5354d6('0x65')||_0x5cbdc1===_0x5354d6('0x55')||_0x5cbdc1===_0x5354d6('0x4e')||_0x5cbdc1===_0x5354d6('0x5c')||_0x5cbdc1===_0x5354d6('0x1b')||_0x5cbdc1===_0x5354d6('0x26')||_0x5cbdc1===_0x5354d6('0x72')||_0x5cbdc1===_0x5354d6('0x7a')||_0x5cbdc1===_0x5354d6('0x11')||_0x5cbdc1===_0x5354d6('0x81')||_0x5cbdc1===_0x5354d6('0x6b')||_0x5cbdc1==='rtpaudioqos'||_0x5cbdc1===_0x5354d6('0x37')||_0x5cbdc1===_0x5354d6('0x21')||_0x5cbdc1==='rtpaudioqosjitterbridged'||_0x5cbdc1===_0x5354d6('0x24')||_0x5cbdc1===_0x5354d6('0x42')||_0x5cbdc1==='rtpaudioqosrtt'||_0x5cbdc1===_0x5354d6('0x5f')||_0x5cbdc1===_0x5354d6('0x29')||_0x5cbdc1==='rtpaudioqosbridged'||_0x5cbdc1===_0x5354d6('0x21')||_0x5cbdc1==='rtpaudioqosjitterbridged'||_0x5cbdc1===_0x5354d6('0x24')||_0x5cbdc1===_0x5354d6('0x42')||_0x5cbdc1===_0x5354d6('0x43')||_0x5cbdc1===_0x5354d6('0x5f')||_0x5cbdc1==='bridgepeer'||_0x5cbdc1==='bridgepvtcallid'||_0x5cbdc1===_0x5354d6('0x2e')||_0x5cbdc1===_0x5354d6('0x58'))return![];return!![];},exports['getCallerIdRandom']=function(_0x57e0cd,_0x308215){const _0x9e1658=_0x384e63;_0x308215<=0x0&&(_0x308215=0x1);const _0x3428da=new RegExp('\x5cw{0,'+_0x308215+'}$'),_0x1d28c1=Math[_0x9e1658('0x32')](0xa,_0x308215-0x1),_0x4bacc9=Math[_0x9e1658('0x32')](0xa,_0x308215)-0x1;return util['format']('%s',_[_0x9e1658('0x7b')](_0x57e0cd,_0x3428da,_['random'](_0x1d28c1,_0x4bacc9)));},exports[_0x384e63('0x2')]=function(_0x58b92b){const _0x489ffc=_0x384e63,_0x1aa616=_0x58b92b[_0x489ffc('0xd')](/"(.*?)"/);return _0x1aa616?_0x1aa616[0x1]:_0x58b92b;},exports[_0x384e63('0x59')]=function(_0x3ceb84){const _0x44d620=_0x384e63,_0x1c5733=_0x3ceb84[_0x44d620('0xd')](/<(.*?)>/);return _0x1c5733?_0x1c5733[0x1]:_0x3ceb84;};