Built motion from commit (unavailable).|2.2.0
[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 _0x4ec9=['../rpc/voiceQueueReport','../rpc/voiceRecording','../rpc/voiceTransferReport','./voiceQueueReport','./voiceCallReport','./voiceAgentReport','./voiceDialReport','./userReport','realtime','agents','telephones','prototype','sync','findAgent','accountcode','name','find','format','SIP/%s','assigned','isNil','interface','queuecallercomplete','queuecallercompleteAt','YYYY-MM-DD\x20HH:mm:ss','queuecallerexit','queuecallerexitAt','voiceQueueReport','create','match','voiceCallReport','destination','exten','dialer','lastapplication','queue','lastdata','context','from-voip-provider','callerid','from-sip','xcally-motion-preview','calleridpreview','originatecalleridnum','channel','calleridnum','disposition','ANSWERED','calleridname','monitor','monitors','length','filename','createdAt','connectedlinenum','connectedlinename','membername','voiceAgentReport','voiceDialReport','startsWith','Local','mobile','phone','substring','indexOf','blindTransfer','bluebird','lodash','moment','util','../ami','../rpc/voiceAgentReport','../rpc/voiceDialReport'];(function(_0x1cafc8,_0x3511d0){var _0x131cdf=function(_0x587d78){while(--_0x587d78){_0x1cafc8['push'](_0x1cafc8['shift']());}};_0x131cdf(++_0x3511d0);}(_0x4ec9,0x166));var _0x94ec=function(_0x16ca8e,_0x60f267){_0x16ca8e=_0x16ca8e-0x0;var _0x4c560e=_0x4ec9[_0x16ca8e];return _0x4c560e;};'use strict';var BPromise=require(_0x94ec('0x0'));var _=require(_0x94ec('0x1'));var moment=require(_0x94ec('0x2'));var util=require(_0x94ec('0x3'));var logger=require('../../../config/logger')('ami');var ami=require(_0x94ec('0x4'));var RpcVoiceAgentReport=require(_0x94ec('0x5'));var RpcVoiceCallReport=require('../rpc/voiceCallReport');var RpcVoiceDialReport=require(_0x94ec('0x6'));var RpcMemberReport=require('../rpc/memberReport');var RpcVoiceQueueReport=require(_0x94ec('0x7'));var RpcVoiceRecording=require(_0x94ec('0x8'));var RpcVoiceTransferReport=require(_0x94ec('0x9'));var VoiceQueueReport=require(_0x94ec('0xa'));var VoiceCallReport=require(_0x94ec('0xb'));var VoiceAgentReport=require(_0x94ec('0xc'));var VoiceDialReport=require(_0x94ec('0xd'));var UserReport=require(_0x94ec('0xe'));function Report(_0x71dc00){this[_0x94ec('0xf')]=_0x71dc00;this['agents']=_0x71dc00[_0x94ec('0x10')];this[_0x94ec('0x11')]=_0x71dc00[_0x94ec('0x11')];}Report[_0x94ec('0x12')][_0x94ec('0x13')]=function(_0x4907e7){var _0x14df49=new VoiceQueueReport(this[_0x94ec('0xf')]);var _0x255e8d=new VoiceAgentReport(this[_0x94ec('0xf')]);var _0xda480c=new VoiceDialReport(this[_0x94ec('0xf')]);var _0x444b63=new VoiceCallReport(this['realtime']);var _0x3ff1d9=new UserReport(this[_0x94ec('0xf')]);};Report[_0x94ec('0x12')][_0x94ec('0x14')]=function(_0x58b2c9){var _0x5494fb=undefined;_0x5494fb=_['find'](this[_0x94ec('0x10')],function(_0x20c824){return _0x20c824[_0x94ec('0x15')]==_0x58b2c9||_0x20c824[_0x94ec('0x16')]==_0x58b2c9;});if(_['isNil'](_0x5494fb)){var _0x108921=_[_0x94ec('0x17')](this[_0x94ec('0x11')],function(_0x13171f){return _0x13171f['accountcode']==_0x58b2c9||_0x13171f[_0x94ec('0x16')]==_0x58b2c9;});if(_0x108921){_0x5494fb=_['find'](this['agents'],function(_0x2643b1){return _0x2643b1['interface']==util[_0x94ec('0x18')](_0x94ec('0x19'),_0x108921['name']);});}}return _0x5494fb;};Report[_0x94ec('0x12')]['voiceQueueReport']=function(_0x27d398){for(var _0x3f6f5f=0x0;_0x3f6f5f<_0x27d398['length'];_0x3f6f5f+=0x1){var _0x5ea05d=this[_0x94ec('0x14')](_0x27d398[_0x3f6f5f]['connectedlinenum']);if(_0x5ea05d){_0x27d398[_0x3f6f5f][_0x94ec('0x15')]=_0x5ea05d['accountcode'];_0x27d398[_0x3f6f5f][_0x94ec('0x1a')]=!![];_0x27d398[_0x3f6f5f]['lastAssignedTo']=_0x5ea05d[_0x94ec('0x16')];_0x27d398[_0x3f6f5f]['interface']=_[_0x94ec('0x1b')](_0x5ea05d[_0x94ec('0x1c')])?util[_0x94ec('0x18')]('SIP/%s',_0x5ea05d[_0x94ec('0x16')]):_0x5ea05d[_0x94ec('0x1c')];if(_0x27d398[_0x3f6f5f][_0x94ec('0x1d')]){_0x27d398[_0x3f6f5f][_0x94ec('0x1e')]=moment()['format'](_0x94ec('0x1f'));}if(_0x27d398[_0x3f6f5f][_0x94ec('0x20')]){_0x27d398[_0x3f6f5f][_0x94ec('0x21')]=moment()[_0x94ec('0x18')](_0x94ec('0x1f'));}RpcMemberReport[_0x94ec('0x22')](_0x27d398[_0x3f6f5f]);}RpcVoiceQueueReport[_0x94ec('0x23')](_0x27d398[_0x3f6f5f]);}};function extractCalleridNumber(_0x45df1a){var _0xc9c1b5=_0x45df1a[_0x94ec('0x24')](/<(.*?)>/);return _0xc9c1b5?_0xc9c1b5[0x1]:_0x45df1a;}Report[_0x94ec('0x12')][_0x94ec('0x25')]=function(_0x286e12){_0x286e12[_0x94ec('0x26')]=_0x286e12[_0x94ec('0x26')]||_0x286e12[_0x94ec('0x27')];if(_0x286e12['type']==_0x94ec('0x28')){_0x286e12[_0x94ec('0x29')]=_0x94ec('0x2a');_0x286e12[_0x94ec('0x2b')]=_0x286e12[_0x94ec('0x2a')];if(_0x286e12[_0x94ec('0x2c')]==_0x94ec('0x2d')){_0x286e12[_0x94ec('0x15')]='';_0x286e12['destination']=extractCalleridNumber(_0x286e12[_0x94ec('0x2e')]);}else if(_0x286e12['context']==_0x94ec('0x2f')){if(_0x286e12[_0x94ec('0x26')]==_0x94ec('0x30')){_0x286e12[_0x94ec('0x26')]=extractCalleridNumber(_0x286e12[_0x94ec('0x31')]);_0x286e12['calleridnum']=_0x286e12[_0x94ec('0x32')];_0x286e12['destinationchannel']=[_0x286e12[_0x94ec('0x33')],_0x286e12['channel']=_0x286e12['destinationchannel']][0x0];_0x286e12['callerid']=_0x286e12[_0x94ec('0x31')];}else{_0x286e12[_0x94ec('0x26')]=_0x286e12[_0x94ec('0x34')];_0x286e12[_0x94ec('0x34')]=_0x286e12[_0x94ec('0x32')];if(_0x286e12[_0x94ec('0x35')]==_0x94ec('0x36')){_0x286e12[_0x94ec('0x15')]=_0x286e12['connectedlinenum'];}else{_0x286e12['accountcode']='';}}}}else{_0x286e12['callerid']=util[_0x94ec('0x18')]('\x22%s\x22\x20<%s>',_0x286e12[_0x94ec('0x37')],_0x286e12[_0x94ec('0x34')]);}RpcVoiceCallReport[_0x94ec('0x23')](_0x286e12);if(_0x286e12[_0x94ec('0x38')]){for(var _0x1bf512=0x0;_0x1bf512<_0x286e12[_0x94ec('0x39')][_0x94ec('0x3a')];_0x1bf512+=0x1){_0x286e12['monitorFilename']=_0x286e12[_0x94ec('0x39')][_0x1bf512][_0x94ec('0x3b')];_0x286e12[_0x94ec('0x3c')]=_0x286e12[_0x94ec('0x39')][_0x1bf512]['createdAt'];if(_0x286e12[_0x94ec('0x27')]==_0x94ec('0x30')){_0x286e12[_0x94ec('0x34')]=_0x286e12[_0x94ec('0x3d')];_0x286e12[_0x94ec('0x37')]=_0x286e12[_0x94ec('0x3e')];_0x286e12[_0x94ec('0x3d')]=_0x286e12[_0x94ec('0x15')];_0x286e12['connectedlinename']=_0x286e12[_0x94ec('0x3f')];_0x286e12[_0x94ec('0x27')]=_0x286e12[_0x94ec('0x32')];}else if(_0x286e12[_0x94ec('0x27')]=='xcally-motion-dialer'){_0x286e12['calleridnum']=_0x286e12[_0x94ec('0x26')];_0x286e12['exten']=_0x286e12[_0x94ec('0x32')];}RpcVoiceRecording[_0x94ec('0x23')](_0x286e12);}}};Report['prototype'][_0x94ec('0x40')]=function(_0x2638f4){RpcVoiceAgentReport[_0x94ec('0x23')](_0x2638f4);};Report[_0x94ec('0x12')][_0x94ec('0x41')]=function(_0x3b7f1f){RpcVoiceDialReport[_0x94ec('0x23')](_0x3b7f1f);var _0x4381e8=undefined;var _0x4d49a1=_0x3b7f1f[_0x94ec('0x33')];if(_[_0x94ec('0x42')](_0x4d49a1,_0x94ec('0x43'))){var _0x5d8a89=_0x4d49a1['substring'](_0x4d49a1['indexOf']('/')+0x1,_0x4d49a1['indexOf']('@'));_0x4381e8=_[_0x94ec('0x17')](this[_0x94ec('0x10')],function(_0x553c28){return _0x553c28[_0x94ec('0x44')]==_0x5d8a89||_0x553c28[_0x94ec('0x45')]==_0x5d8a89||_0x553c28[_0x94ec('0x15')]==_0x5d8a89;});}else{var _0x5d8a89=_0x4d49a1[_0x94ec('0x46')](_0x4d49a1[_0x94ec('0x47')]('/')+0x1,_0x4d49a1['lastIndexOf']('-'));_0x4381e8=this['findAgent'](_0x5d8a89);}if(_0x4381e8){_0x3b7f1f[_0x94ec('0x1c')]=_['isNil'](_0x4381e8[_0x94ec('0x1c')])?util[_0x94ec('0x18')](_0x94ec('0x19'),_0x4381e8[_0x94ec('0x16')]):_0x4381e8[_0x94ec('0x1c')];_0x3b7f1f[_0x94ec('0x3f')]=_0x4381e8[_0x94ec('0x16')];_0x3b7f1f[_0x94ec('0x15')]=_0x4381e8[_0x94ec('0x15')];RpcMemberReport[_0x94ec('0x41')](_0x3b7f1f);}};Report['prototype']['blindTransfer']=function(_0x335547){RpcVoiceTransferReport[_0x94ec('0x48')](_0x335547);};Report[_0x94ec('0x12')]['attendedTransfer']=function(_0x377335){RpcVoiceTransferReport['attendedTransfer'](_0x377335);};module['exports']=Report;