Built motion from commit (unavailable).|2.3.4
[motion2.git] / server / services / ami / report / index.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 _0x5c30=['./voiceQueueReport','./voiceCallReport','./voiceAgentReport','realtime','telephones','prototype','sync','agents','name','find','accountcode','interface','format','SIP/%s','length','findAgent','connectedlinenum','assigned','lastAssignedTo','queuecallercomplete','queuecallercompleteAt','queuecallerexitAt','YYYY-MM-DD\x20HH:mm:ss','voiceQueueReport','voiceCallReport','destination','exten','type','dialer','lastapplication','queue','context','from-voip-provider','callerid','calleridpreview','calleridnum','originatecalleridnum','destinationchannel','channel','disposition','ANSWERED','\x22%s\x22\x20<%s>','calleridname','create','monitorFilename','monitors','filename','createdAt','xcally-motion-preview','connectedlinename','membername','xcally-motion-dialer','voiceAgentReport','voiceDialReport','startsWith','Local','substring','indexOf','mobile','phone','lastIndexOf','blindTransfer','attendedTransfer','exports','bluebird','lodash','moment','util','../../../config/logger','ami','../ami','../rpc/voiceAgentReport','../rpc/voiceCallReport','../rpc/memberReport','../rpc/voiceQueueReport','../rpc/voiceRecording','../rpc/voiceTransferReport'];(function(_0x58c5d1,_0x53ca13){var _0x300ebd=function(_0x391dd3){while(--_0x391dd3){_0x58c5d1['push'](_0x58c5d1['shift']());}};_0x300ebd(++_0x53ca13);}(_0x5c30,0x174));var _0x05c3=function(_0x18ff55,_0xdfc235){_0x18ff55=_0x18ff55-0x0;var _0x164630=_0x5c30[_0x18ff55];return _0x164630;};'use strict';var BPromise=require(_0x05c3('0x0'));var _=require(_0x05c3('0x1'));var moment=require(_0x05c3('0x2'));var util=require(_0x05c3('0x3'));var logger=require(_0x05c3('0x4'))(_0x05c3('0x5'));var ami=require(_0x05c3('0x6'));var RpcVoiceAgentReport=require(_0x05c3('0x7'));var RpcVoiceCallReport=require(_0x05c3('0x8'));var RpcVoiceDialReport=require('../rpc/voiceDialReport');var RpcMemberReport=require(_0x05c3('0x9'));var RpcVoiceQueueReport=require(_0x05c3('0xa'));var RpcVoiceRecording=require(_0x05c3('0xb'));var RpcVoiceTransferReport=require(_0x05c3('0xc'));var VoiceQueueReport=require(_0x05c3('0xd'));var VoiceCallReport=require(_0x05c3('0xe'));var VoiceAgentReport=require(_0x05c3('0xf'));var VoiceDialReport=require('./voiceDialReport');var UserReport=require('./userReport');function Report(_0x2e5143){this[_0x05c3('0x10')]=_0x2e5143;this['agents']=_0x2e5143['agents'];this[_0x05c3('0x11')]=_0x2e5143[_0x05c3('0x11')];}Report[_0x05c3('0x12')][_0x05c3('0x13')]=function(_0x253b3e){var _0x53ca4f=new VoiceQueueReport(this[_0x05c3('0x10')]);var _0x7ba03d=new VoiceAgentReport(this['realtime']);var _0x3a10d1=new VoiceDialReport(this[_0x05c3('0x10')]);var _0x577cf8=new VoiceCallReport(this[_0x05c3('0x10')]);var _0x522aea=new UserReport(this[_0x05c3('0x10')]);};Report[_0x05c3('0x12')]['findAgent']=function(_0x2f7882){var _0x209e68=undefined;_0x209e68=_['find'](this[_0x05c3('0x14')],function(_0x485e14){return _0x485e14['accountcode']==_0x2f7882||_0x485e14[_0x05c3('0x15')]==_0x2f7882;});if(_['isNil'](_0x209e68)){var _0x60c329=_[_0x05c3('0x16')](this['telephones'],function(_0x44b527){return _0x44b527[_0x05c3('0x17')]==_0x2f7882||_0x44b527[_0x05c3('0x15')]==_0x2f7882;});if(_0x60c329){_0x209e68=_[_0x05c3('0x16')](this['agents'],function(_0x3820c5){return _0x3820c5[_0x05c3('0x18')]==util[_0x05c3('0x19')](_0x05c3('0x1a'),_0x60c329[_0x05c3('0x15')]);});}}return _0x209e68;};Report[_0x05c3('0x12')]['voiceQueueReport']=function(_0xcd27c0){for(var _0x72053b=0x0;_0x72053b<_0xcd27c0[_0x05c3('0x1b')];_0x72053b+=0x1){var _0x31fffc=this[_0x05c3('0x1c')](_0xcd27c0[_0x72053b][_0x05c3('0x1d')]);if(_0x31fffc){_0xcd27c0[_0x72053b][_0x05c3('0x17')]=_0x31fffc[_0x05c3('0x17')];_0xcd27c0[_0x72053b][_0x05c3('0x1e')]=!![];_0xcd27c0[_0x72053b][_0x05c3('0x1f')]=_0x31fffc[_0x05c3('0x15')];_0xcd27c0[_0x72053b][_0x05c3('0x18')]=_['isNil'](_0x31fffc[_0x05c3('0x18')])?util[_0x05c3('0x19')]('SIP/%s',_0x31fffc[_0x05c3('0x15')]):_0x31fffc[_0x05c3('0x18')];if(_0xcd27c0[_0x72053b][_0x05c3('0x20')]){_0xcd27c0[_0x72053b][_0x05c3('0x21')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');}if(_0xcd27c0[_0x72053b]['queuecallerexit']){_0xcd27c0[_0x72053b][_0x05c3('0x22')]=moment()[_0x05c3('0x19')](_0x05c3('0x23'));}RpcMemberReport[_0x05c3('0x24')](_0xcd27c0[_0x72053b]);}RpcVoiceQueueReport['create'](_0xcd27c0[_0x72053b]);}};function extractCalleridNumber(_0x4530a0){var _0x2efe72=_0x4530a0['match'](/<(.*?)>/);return _0x2efe72?_0x2efe72[0x1]:_0x4530a0;}Report[_0x05c3('0x12')][_0x05c3('0x25')]=function(_0xa8a612){_0xa8a612[_0x05c3('0x26')]=_0xa8a612['destination']||_0xa8a612[_0x05c3('0x27')];if(_0xa8a612[_0x05c3('0x28')]==_0x05c3('0x29')){_0xa8a612[_0x05c3('0x2a')]=_0x05c3('0x2b');_0xa8a612['lastdata']=_0xa8a612[_0x05c3('0x2b')];if(_0xa8a612[_0x05c3('0x2c')]==_0x05c3('0x2d')){_0xa8a612[_0x05c3('0x17')]='';_0xa8a612[_0x05c3('0x26')]=extractCalleridNumber(_0xa8a612[_0x05c3('0x2e')]);}else if(_0xa8a612[_0x05c3('0x2c')]=='from-sip'){if(_0xa8a612[_0x05c3('0x26')]=='xcally-motion-preview'){_0xa8a612[_0x05c3('0x26')]=extractCalleridNumber(_0xa8a612[_0x05c3('0x2f')]);_0xa8a612[_0x05c3('0x30')]=_0xa8a612[_0x05c3('0x31')];_0xa8a612[_0x05c3('0x32')]=[_0xa8a612[_0x05c3('0x33')],_0xa8a612['channel']=_0xa8a612['destinationchannel']][0x0];_0xa8a612[_0x05c3('0x2e')]=_0xa8a612[_0x05c3('0x2f')];}else{_0xa8a612[_0x05c3('0x26')]=_0xa8a612[_0x05c3('0x30')];_0xa8a612[_0x05c3('0x30')]=_0xa8a612['originatecalleridnum'];if(_0xa8a612[_0x05c3('0x34')]==_0x05c3('0x35')){_0xa8a612['accountcode']=_0xa8a612[_0x05c3('0x1d')];}else{_0xa8a612[_0x05c3('0x17')]='';}}}}else{_0xa8a612['callerid']=util[_0x05c3('0x19')](_0x05c3('0x36'),_0xa8a612[_0x05c3('0x37')],_0xa8a612[_0x05c3('0x30')]);}RpcVoiceCallReport[_0x05c3('0x38')](_0xa8a612);if(_0xa8a612['monitor']){for(var _0xabf462=0x0;_0xabf462<_0xa8a612['monitors'][_0x05c3('0x1b')];_0xabf462+=0x1){_0xa8a612[_0x05c3('0x39')]=_0xa8a612[_0x05c3('0x3a')][_0xabf462][_0x05c3('0x3b')];_0xa8a612['createdAt']=_0xa8a612[_0x05c3('0x3a')][_0xabf462][_0x05c3('0x3c')];if(_0xa8a612[_0x05c3('0x27')]==_0x05c3('0x3d')){_0xa8a612['calleridnum']=_0xa8a612[_0x05c3('0x1d')];_0xa8a612[_0x05c3('0x37')]=_0xa8a612[_0x05c3('0x3e')];_0xa8a612[_0x05c3('0x1d')]=_0xa8a612[_0x05c3('0x17')];_0xa8a612['connectedlinename']=_0xa8a612[_0x05c3('0x3f')];_0xa8a612['exten']=_0xa8a612[_0x05c3('0x31')];}else if(_0xa8a612[_0x05c3('0x27')]==_0x05c3('0x40')){_0xa8a612[_0x05c3('0x30')]=_0xa8a612[_0x05c3('0x26')];_0xa8a612[_0x05c3('0x27')]=_0xa8a612[_0x05c3('0x31')];}RpcVoiceRecording[_0x05c3('0x38')](_0xa8a612);}}};Report['prototype'][_0x05c3('0x41')]=function(_0x47affd){RpcVoiceAgentReport[_0x05c3('0x38')](_0x47affd);};Report[_0x05c3('0x12')][_0x05c3('0x42')]=function(_0x4cb819){RpcVoiceDialReport['create'](_0x4cb819);var _0x20d5bd=undefined;var _0x3e48ff=_0x4cb819['channel'];if(_[_0x05c3('0x43')](_0x3e48ff,_0x05c3('0x44'))){var _0x658e6=_0x3e48ff[_0x05c3('0x45')](_0x3e48ff[_0x05c3('0x46')]('/')+0x1,_0x3e48ff['indexOf']('@'));_0x20d5bd=_['find'](this[_0x05c3('0x14')],function(_0x1d2d53){return _0x1d2d53[_0x05c3('0x47')]==_0x658e6||_0x1d2d53[_0x05c3('0x48')]==_0x658e6||_0x1d2d53[_0x05c3('0x17')]==_0x658e6;});}else{var _0x658e6=_0x3e48ff['substring'](_0x3e48ff[_0x05c3('0x46')]('/')+0x1,_0x3e48ff[_0x05c3('0x49')]('-'));_0x20d5bd=this[_0x05c3('0x1c')](_0x658e6);}if(_0x20d5bd){_0x4cb819[_0x05c3('0x18')]=_['isNil'](_0x20d5bd[_0x05c3('0x18')])?util['format'](_0x05c3('0x1a'),_0x20d5bd[_0x05c3('0x15')]):_0x20d5bd[_0x05c3('0x18')];_0x4cb819[_0x05c3('0x3f')]=_0x20d5bd[_0x05c3('0x15')];_0x4cb819[_0x05c3('0x17')]=_0x20d5bd[_0x05c3('0x17')];RpcMemberReport[_0x05c3('0x42')](_0x4cb819);}};Report[_0x05c3('0x12')]['blindTransfer']=function(_0x1cc9fd){RpcVoiceTransferReport[_0x05c3('0x4a')](_0x1cc9fd);};Report[_0x05c3('0x12')][_0x05c3('0x4b')]=function(_0x1f9be7){RpcVoiceTransferReport[_0x05c3('0x4b')](_0x1f9be7);};module[_0x05c3('0x4c')]=Report;