Built motion from commit (unavailable).|2.3.1
[motion2.git] / server / services / ami / report / index.js
index aa48f30..e47014d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1bff=['realtime','findAgent','find','accountcode','name','isNil','format','SIP/%s','prototype','voiceQueueReport','length','connectedlinenum','assigned','lastAssignedTo','interface','queuecallercomplete','queuecallercompleteAt','YYYY-MM-DD\x20HH:mm:ss','queuecallerexit','queuecallerexitAt','create','match','destination','type','dialer','lastapplication','queue','lastdata','context','from-voip-provider','callerid','from-sip','xcally-motion-preview','calleridpreview','originatecalleridnum','destinationchannel','channel','calleridnum','disposition','ANSWERED','\x22%s\x22\x20<%s>','calleridname','monitor','monitors','monitorFilename','createdAt','exten','connectedlinename','membername','xcally-motion-dialer','voiceAgentReport','voiceDialReport','Local','substring','indexOf','mobile','phone','lastIndexOf','blindTransfer','attendedTransfer','exports','lodash','util','../../../config/logger','ami','../ami','../rpc/voiceAgentReport','../rpc/voiceDialReport','../rpc/memberReport','../rpc/voiceQueueReport','../rpc/voiceRecording','../rpc/voiceTransferReport','./voiceQueueReport','./voiceCallReport','./voiceDialReport','agents','telephones'];(function(_0x521e8d,_0x23a290){var _0x518bbd=function(_0x4241eb){while(--_0x4241eb){_0x521e8d['push'](_0x521e8d['shift']());}};_0x518bbd(++_0x23a290);}(_0x1bff,0x8a));var _0xf1bf=function(_0x112fe3,_0x16b642){_0x112fe3=_0x112fe3-0x0;var _0x1ec903=_0x1bff[_0x112fe3];return _0x1ec903;};'use strict';var BPromise=require('bluebird');var _=require(_0xf1bf('0x0'));var moment=require('moment');var util=require(_0xf1bf('0x1'));var logger=require(_0xf1bf('0x2'))(_0xf1bf('0x3'));var ami=require(_0xf1bf('0x4'));var RpcVoiceAgentReport=require(_0xf1bf('0x5'));var RpcVoiceCallReport=require('../rpc/voiceCallReport');var RpcVoiceDialReport=require(_0xf1bf('0x6'));var RpcMemberReport=require(_0xf1bf('0x7'));var RpcVoiceQueueReport=require(_0xf1bf('0x8'));var RpcVoiceRecording=require(_0xf1bf('0x9'));var RpcVoiceTransferReport=require(_0xf1bf('0xa'));var VoiceQueueReport=require(_0xf1bf('0xb'));var VoiceCallReport=require(_0xf1bf('0xc'));var VoiceAgentReport=require('./voiceAgentReport');var VoiceDialReport=require(_0xf1bf('0xd'));var UserReport=require('./userReport');function Report(_0x17f566){this['realtime']=_0x17f566;this[_0xf1bf('0xe')]=_0x17f566['agents'];this[_0xf1bf('0xf')]=_0x17f566[_0xf1bf('0xf')];}Report['prototype']['sync']=function(_0x2f2a4d){var _0x4746c5=new VoiceQueueReport(this[_0xf1bf('0x10')]);var _0x29ec24=new VoiceAgentReport(this[_0xf1bf('0x10')]);var _0x34e05a=new VoiceDialReport(this[_0xf1bf('0x10')]);var _0x351ac8=new VoiceCallReport(this[_0xf1bf('0x10')]);var _0x5bdde9=new UserReport(this[_0xf1bf('0x10')]);};Report['prototype'][_0xf1bf('0x11')]=function(_0x225fb3){var _0x239bcf=undefined;_0x239bcf=_[_0xf1bf('0x12')](this['agents'],function(_0x52e162){return _0x52e162[_0xf1bf('0x13')]==_0x225fb3||_0x52e162[_0xf1bf('0x14')]==_0x225fb3;});if(_[_0xf1bf('0x15')](_0x239bcf)){var _0x284dc3=_[_0xf1bf('0x12')](this['telephones'],function(_0x413c8d){return _0x413c8d['accountcode']==_0x225fb3||_0x413c8d[_0xf1bf('0x14')]==_0x225fb3;});if(_0x284dc3){_0x239bcf=_[_0xf1bf('0x12')](this['agents'],function(_0x2c3487){return _0x2c3487['interface']==util[_0xf1bf('0x16')](_0xf1bf('0x17'),_0x284dc3[_0xf1bf('0x14')]);});}}return _0x239bcf;};Report[_0xf1bf('0x18')][_0xf1bf('0x19')]=function(_0x39fe3c){for(var _0x560159=0x0;_0x560159<_0x39fe3c[_0xf1bf('0x1a')];_0x560159+=0x1){var _0x1febc0=this['findAgent'](_0x39fe3c[_0x560159][_0xf1bf('0x1b')]);if(_0x1febc0){_0x39fe3c[_0x560159][_0xf1bf('0x13')]=_0x1febc0['accountcode'];_0x39fe3c[_0x560159][_0xf1bf('0x1c')]=!![];_0x39fe3c[_0x560159][_0xf1bf('0x1d')]=_0x1febc0[_0xf1bf('0x14')];_0x39fe3c[_0x560159][_0xf1bf('0x1e')]=_['isNil'](_0x1febc0[_0xf1bf('0x1e')])?util[_0xf1bf('0x16')](_0xf1bf('0x17'),_0x1febc0[_0xf1bf('0x14')]):_0x1febc0['interface'];if(_0x39fe3c[_0x560159][_0xf1bf('0x1f')]){_0x39fe3c[_0x560159][_0xf1bf('0x20')]=moment()['format'](_0xf1bf('0x21'));}if(_0x39fe3c[_0x560159][_0xf1bf('0x22')]){_0x39fe3c[_0x560159][_0xf1bf('0x23')]=moment()[_0xf1bf('0x16')](_0xf1bf('0x21'));}RpcMemberReport[_0xf1bf('0x19')](_0x39fe3c[_0x560159]);}RpcVoiceQueueReport[_0xf1bf('0x24')](_0x39fe3c[_0x560159]);}};function extractCalleridNumber(_0x3c73c4){var _0x58694c=_0x3c73c4[_0xf1bf('0x25')](/<(.*?)>/);return _0x58694c?_0x58694c[0x1]:_0x3c73c4;}Report['prototype']['voiceCallReport']=function(_0x11d1ba){_0x11d1ba[_0xf1bf('0x26')]=_0x11d1ba['destination']||_0x11d1ba['exten'];if(_0x11d1ba[_0xf1bf('0x27')]==_0xf1bf('0x28')){_0x11d1ba[_0xf1bf('0x29')]=_0xf1bf('0x2a');_0x11d1ba[_0xf1bf('0x2b')]=_0x11d1ba[_0xf1bf('0x2a')];if(_0x11d1ba[_0xf1bf('0x2c')]==_0xf1bf('0x2d')){_0x11d1ba[_0xf1bf('0x13')]='';_0x11d1ba[_0xf1bf('0x26')]=extractCalleridNumber(_0x11d1ba[_0xf1bf('0x2e')]);}else if(_0x11d1ba['context']==_0xf1bf('0x2f')){if(_0x11d1ba[_0xf1bf('0x26')]==_0xf1bf('0x30')){_0x11d1ba['destination']=extractCalleridNumber(_0x11d1ba[_0xf1bf('0x31')]);_0x11d1ba['calleridnum']=_0x11d1ba[_0xf1bf('0x32')];_0x11d1ba[_0xf1bf('0x33')]=[_0x11d1ba['channel'],_0x11d1ba[_0xf1bf('0x34')]=_0x11d1ba['destinationchannel']][0x0];_0x11d1ba[_0xf1bf('0x2e')]=_0x11d1ba[_0xf1bf('0x31')];}else{_0x11d1ba[_0xf1bf('0x26')]=_0x11d1ba[_0xf1bf('0x35')];_0x11d1ba[_0xf1bf('0x35')]=_0x11d1ba[_0xf1bf('0x32')];if(_0x11d1ba[_0xf1bf('0x36')]==_0xf1bf('0x37')){_0x11d1ba[_0xf1bf('0x13')]=_0x11d1ba[_0xf1bf('0x1b')];}else{_0x11d1ba[_0xf1bf('0x13')]='';}}}}else{_0x11d1ba['callerid']=util[_0xf1bf('0x16')](_0xf1bf('0x38'),_0x11d1ba[_0xf1bf('0x39')],_0x11d1ba[_0xf1bf('0x35')]);}RpcVoiceCallReport['create'](_0x11d1ba);if(_0x11d1ba[_0xf1bf('0x3a')]){for(var _0x54e284=0x0;_0x54e284<_0x11d1ba[_0xf1bf('0x3b')][_0xf1bf('0x1a')];_0x54e284+=0x1){_0x11d1ba[_0xf1bf('0x3c')]=_0x11d1ba['monitors'][_0x54e284]['filename'];_0x11d1ba[_0xf1bf('0x3d')]=_0x11d1ba[_0xf1bf('0x3b')][_0x54e284]['createdAt'];if(_0x11d1ba[_0xf1bf('0x3e')]=='xcally-motion-preview'){_0x11d1ba[_0xf1bf('0x35')]=_0x11d1ba[_0xf1bf('0x1b')];_0x11d1ba[_0xf1bf('0x39')]=_0x11d1ba[_0xf1bf('0x3f')];_0x11d1ba['connectedlinenum']=_0x11d1ba[_0xf1bf('0x13')];_0x11d1ba[_0xf1bf('0x3f')]=_0x11d1ba[_0xf1bf('0x40')];_0x11d1ba[_0xf1bf('0x3e')]=_0x11d1ba[_0xf1bf('0x32')];}else if(_0x11d1ba[_0xf1bf('0x3e')]==_0xf1bf('0x41')){_0x11d1ba[_0xf1bf('0x35')]=_0x11d1ba[_0xf1bf('0x26')];_0x11d1ba['exten']=_0x11d1ba[_0xf1bf('0x32')];}RpcVoiceRecording['create'](_0x11d1ba);}}};Report[_0xf1bf('0x18')][_0xf1bf('0x42')]=function(_0x3fe6f3){RpcVoiceAgentReport[_0xf1bf('0x24')](_0x3fe6f3);};Report['prototype'][_0xf1bf('0x43')]=function(_0x40c548){RpcVoiceDialReport[_0xf1bf('0x24')](_0x40c548);var _0x421881=undefined;var _0x3e6391=_0x40c548[_0xf1bf('0x34')];if(_['startsWith'](_0x3e6391,_0xf1bf('0x44'))){var _0x5e5ad5=_0x3e6391[_0xf1bf('0x45')](_0x3e6391['indexOf']('/')+0x1,_0x3e6391[_0xf1bf('0x46')]('@'));_0x421881=_['find'](this[_0xf1bf('0xe')],function(_0x1b232e){return _0x1b232e[_0xf1bf('0x47')]==_0x5e5ad5||_0x1b232e[_0xf1bf('0x48')]==_0x5e5ad5||_0x1b232e['accountcode']==_0x5e5ad5;});}else{var _0x5e5ad5=_0x3e6391['substring'](_0x3e6391['indexOf']('/')+0x1,_0x3e6391[_0xf1bf('0x49')]('-'));_0x421881=this[_0xf1bf('0x11')](_0x5e5ad5);}if(_0x421881){_0x40c548[_0xf1bf('0x1e')]=_[_0xf1bf('0x15')](_0x421881[_0xf1bf('0x1e')])?util[_0xf1bf('0x16')](_0xf1bf('0x17'),_0x421881[_0xf1bf('0x14')]):_0x421881[_0xf1bf('0x1e')];_0x40c548['membername']=_0x421881['name'];_0x40c548[_0xf1bf('0x13')]=_0x421881[_0xf1bf('0x13')];RpcMemberReport[_0xf1bf('0x43')](_0x40c548);}};Report[_0xf1bf('0x18')]['blindTransfer']=function(_0x4a1b65){RpcVoiceTransferReport[_0xf1bf('0x4a')](_0x4a1b65);};Report[_0xf1bf('0x18')][_0xf1bf('0x4b')]=function(_0xb69f37){RpcVoiceTransferReport[_0xf1bf('0x4b')](_0xb69f37);};module[_0xf1bf('0x4c')]=Report;
\ No newline at end of file
+var _0x5a9f=['bluebird','moment','util','../ami','../rpc/voiceCallReport','../rpc/voiceDialReport','../rpc/memberReport','../rpc/voiceRecording','../rpc/voiceTransferReport','./voiceQueueReport','./voiceCallReport','./userReport','realtime','agents','telephones','prototype','findAgent','find','accountcode','name','isNil','interface','format','SIP/%s','voiceQueueReport','assigned','queuecallercomplete','queuecallercompleteAt','YYYY-MM-DD\x20HH:mm:ss','queuecallerexit','queuecallerexitAt','create','destination','type','dialer','queue','lastdata','context','from-voip-provider','callerid','from-sip','xcally-motion-preview','calleridpreview','calleridnum','originatecalleridnum','destinationchannel','disposition','connectedlinenum','\x22%s\x22\x20<%s>','calleridname','monitor','monitors','createdAt','exten','connectedlinename','membername','xcally-motion-dialer','voiceAgentReport','channel','Local','substring','indexOf','lastIndexOf','voiceDialReport','blindTransfer','attendedTransfer','exports'];(function(_0x4e02f2,_0x16f365){var _0x950618=function(_0x545c4a){while(--_0x545c4a){_0x4e02f2['push'](_0x4e02f2['shift']());}};_0x950618(++_0x16f365);}(_0x5a9f,0x14f));var _0xf5a9=function(_0x6499cf,_0x29ee68){_0x6499cf=_0x6499cf-0x0;var _0x4fab82=_0x5a9f[_0x6499cf];return _0x4fab82;};'use strict';var BPromise=require(_0xf5a9('0x0'));var _=require('lodash');var moment=require(_0xf5a9('0x1'));var util=require(_0xf5a9('0x2'));var logger=require('../../../config/logger')('ami');var ami=require(_0xf5a9('0x3'));var RpcVoiceAgentReport=require('../rpc/voiceAgentReport');var RpcVoiceCallReport=require(_0xf5a9('0x4'));var RpcVoiceDialReport=require(_0xf5a9('0x5'));var RpcMemberReport=require(_0xf5a9('0x6'));var RpcVoiceQueueReport=require('../rpc/voiceQueueReport');var RpcVoiceRecording=require(_0xf5a9('0x7'));var RpcVoiceTransferReport=require(_0xf5a9('0x8'));var VoiceQueueReport=require(_0xf5a9('0x9'));var VoiceCallReport=require(_0xf5a9('0xa'));var VoiceAgentReport=require('./voiceAgentReport');var VoiceDialReport=require('./voiceDialReport');var UserReport=require(_0xf5a9('0xb'));function Report(_0x39a730){this[_0xf5a9('0xc')]=_0x39a730;this[_0xf5a9('0xd')]=_0x39a730[_0xf5a9('0xd')];this[_0xf5a9('0xe')]=_0x39a730[_0xf5a9('0xe')];}Report['prototype']['sync']=function(_0x460783){var _0x2e6497=new VoiceQueueReport(this['realtime']);var _0x391c41=new VoiceAgentReport(this[_0xf5a9('0xc')]);var _0xb80292=new VoiceDialReport(this[_0xf5a9('0xc')]);var _0x3f2e0e=new VoiceCallReport(this[_0xf5a9('0xc')]);var _0x16b5e0=new UserReport(this[_0xf5a9('0xc')]);};Report[_0xf5a9('0xf')][_0xf5a9('0x10')]=function(_0x2eb3ac){var _0x36155d=undefined;_0x36155d=_[_0xf5a9('0x11')](this['agents'],function(_0xe47697){return _0xe47697[_0xf5a9('0x12')]==_0x2eb3ac||_0xe47697[_0xf5a9('0x13')]==_0x2eb3ac;});if(_[_0xf5a9('0x14')](_0x36155d)){var _0x953661=_['find'](this['telephones'],function(_0x5a8364){return _0x5a8364[_0xf5a9('0x12')]==_0x2eb3ac||_0x5a8364['name']==_0x2eb3ac;});if(_0x953661){_0x36155d=_[_0xf5a9('0x11')](this['agents'],function(_0x161649){return _0x161649[_0xf5a9('0x15')]==util[_0xf5a9('0x16')](_0xf5a9('0x17'),_0x953661[_0xf5a9('0x13')]);});}}return _0x36155d;};Report[_0xf5a9('0xf')][_0xf5a9('0x18')]=function(_0x1d36dc){for(var _0x173cf0=0x0;_0x173cf0<_0x1d36dc['length'];_0x173cf0+=0x1){var _0x19a3ea=this[_0xf5a9('0x10')](_0x1d36dc[_0x173cf0]['connectedlinenum']);if(_0x19a3ea){_0x1d36dc[_0x173cf0]['accountcode']=_0x19a3ea[_0xf5a9('0x12')];_0x1d36dc[_0x173cf0][_0xf5a9('0x19')]=!![];_0x1d36dc[_0x173cf0]['lastAssignedTo']=_0x19a3ea[_0xf5a9('0x13')];_0x1d36dc[_0x173cf0][_0xf5a9('0x15')]=_['isNil'](_0x19a3ea[_0xf5a9('0x15')])?util[_0xf5a9('0x16')](_0xf5a9('0x17'),_0x19a3ea[_0xf5a9('0x13')]):_0x19a3ea[_0xf5a9('0x15')];if(_0x1d36dc[_0x173cf0][_0xf5a9('0x1a')]){_0x1d36dc[_0x173cf0][_0xf5a9('0x1b')]=moment()[_0xf5a9('0x16')](_0xf5a9('0x1c'));}if(_0x1d36dc[_0x173cf0][_0xf5a9('0x1d')]){_0x1d36dc[_0x173cf0][_0xf5a9('0x1e')]=moment()['format'](_0xf5a9('0x1c'));}RpcMemberReport[_0xf5a9('0x18')](_0x1d36dc[_0x173cf0]);}RpcVoiceQueueReport[_0xf5a9('0x1f')](_0x1d36dc[_0x173cf0]);}};function extractCalleridNumber(_0x5ddbca){var _0x1cf83c=_0x5ddbca['match'](/<(.*?)>/);return _0x1cf83c?_0x1cf83c[0x1]:_0x5ddbca;}Report[_0xf5a9('0xf')]['voiceCallReport']=function(_0x28088b){_0x28088b[_0xf5a9('0x20')]=_0x28088b['destination']||_0x28088b['exten'];if(_0x28088b[_0xf5a9('0x21')]==_0xf5a9('0x22')){_0x28088b['lastapplication']=_0xf5a9('0x23');_0x28088b[_0xf5a9('0x24')]=_0x28088b['queue'];if(_0x28088b[_0xf5a9('0x25')]==_0xf5a9('0x26')){_0x28088b[_0xf5a9('0x12')]='';_0x28088b[_0xf5a9('0x20')]=extractCalleridNumber(_0x28088b[_0xf5a9('0x27')]);}else if(_0x28088b[_0xf5a9('0x25')]==_0xf5a9('0x28')){if(_0x28088b[_0xf5a9('0x20')]==_0xf5a9('0x29')){_0x28088b[_0xf5a9('0x20')]=extractCalleridNumber(_0x28088b[_0xf5a9('0x2a')]);_0x28088b[_0xf5a9('0x2b')]=_0x28088b[_0xf5a9('0x2c')];_0x28088b[_0xf5a9('0x2d')]=[_0x28088b['channel'],_0x28088b['channel']=_0x28088b[_0xf5a9('0x2d')]][0x0];_0x28088b[_0xf5a9('0x27')]=_0x28088b[_0xf5a9('0x2a')];}else{_0x28088b[_0xf5a9('0x20')]=_0x28088b[_0xf5a9('0x2b')];_0x28088b['calleridnum']=_0x28088b['originatecalleridnum'];if(_0x28088b[_0xf5a9('0x2e')]=='ANSWERED'){_0x28088b[_0xf5a9('0x12')]=_0x28088b[_0xf5a9('0x2f')];}else{_0x28088b[_0xf5a9('0x12')]='';}}}}else{_0x28088b[_0xf5a9('0x27')]=util[_0xf5a9('0x16')](_0xf5a9('0x30'),_0x28088b[_0xf5a9('0x31')],_0x28088b[_0xf5a9('0x2b')]);}RpcVoiceCallReport['create'](_0x28088b);if(_0x28088b[_0xf5a9('0x32')]){for(var _0x383af3=0x0;_0x383af3<_0x28088b[_0xf5a9('0x33')]['length'];_0x383af3+=0x1){_0x28088b['monitorFilename']=_0x28088b[_0xf5a9('0x33')][_0x383af3]['filename'];_0x28088b[_0xf5a9('0x34')]=_0x28088b[_0xf5a9('0x33')][_0x383af3]['createdAt'];if(_0x28088b[_0xf5a9('0x35')]==_0xf5a9('0x29')){_0x28088b[_0xf5a9('0x2b')]=_0x28088b[_0xf5a9('0x2f')];_0x28088b[_0xf5a9('0x31')]=_0x28088b[_0xf5a9('0x36')];_0x28088b[_0xf5a9('0x2f')]=_0x28088b[_0xf5a9('0x12')];_0x28088b[_0xf5a9('0x36')]=_0x28088b[_0xf5a9('0x37')];_0x28088b[_0xf5a9('0x35')]=_0x28088b[_0xf5a9('0x2c')];}else if(_0x28088b[_0xf5a9('0x35')]==_0xf5a9('0x38')){_0x28088b[_0xf5a9('0x2b')]=_0x28088b[_0xf5a9('0x20')];_0x28088b[_0xf5a9('0x35')]=_0x28088b['originatecalleridnum'];}RpcVoiceRecording[_0xf5a9('0x1f')](_0x28088b);}}};Report[_0xf5a9('0xf')][_0xf5a9('0x39')]=function(_0x1335fd){RpcVoiceAgentReport[_0xf5a9('0x1f')](_0x1335fd);};Report[_0xf5a9('0xf')]['voiceDialReport']=function(_0x2e68c4){RpcVoiceDialReport[_0xf5a9('0x1f')](_0x2e68c4);var _0x1c19c7=undefined;var _0x372fca=_0x2e68c4[_0xf5a9('0x3a')];if(_['startsWith'](_0x372fca,_0xf5a9('0x3b'))){var _0x84e207=_0x372fca[_0xf5a9('0x3c')](_0x372fca[_0xf5a9('0x3d')]('/')+0x1,_0x372fca['indexOf']('@'));_0x1c19c7=_[_0xf5a9('0x11')](this[_0xf5a9('0xd')],function(_0x31bda0){return _0x31bda0['mobile']==_0x84e207||_0x31bda0['phone']==_0x84e207||_0x31bda0[_0xf5a9('0x12')]==_0x84e207;});}else{var _0x84e207=_0x372fca['substring'](_0x372fca[_0xf5a9('0x3d')]('/')+0x1,_0x372fca[_0xf5a9('0x3e')]('-'));_0x1c19c7=this[_0xf5a9('0x10')](_0x84e207);}if(_0x1c19c7){_0x2e68c4['interface']=_[_0xf5a9('0x14')](_0x1c19c7[_0xf5a9('0x15')])?util[_0xf5a9('0x16')](_0xf5a9('0x17'),_0x1c19c7['name']):_0x1c19c7[_0xf5a9('0x15')];_0x2e68c4[_0xf5a9('0x37')]=_0x1c19c7[_0xf5a9('0x13')];_0x2e68c4[_0xf5a9('0x12')]=_0x1c19c7['accountcode'];RpcMemberReport[_0xf5a9('0x3f')](_0x2e68c4);}};Report[_0xf5a9('0xf')]['blindTransfer']=function(_0x1a2e17){RpcVoiceTransferReport[_0xf5a9('0x40')](_0x1a2e17);};Report['prototype'][_0xf5a9('0x41')]=function(_0x22adf6){RpcVoiceTransferReport[_0xf5a9('0x41')](_0x22adf6);};module[_0xf5a9('0x42')]=Report;
\ No newline at end of file