Built motion from commit 9e1399f3.|2.5.37
[motion2.git] / server / services / xdr / 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 _0xabff=['newexten','[%s][index][newexten]','newchannel','[%s][index][newchannel]','dialbegin','[%s][index][dialbegin]','[%s]dialbegin','[%s][index][dialend]','dialend','../../config/environment','./utils','util','port','asterisk','password','keepConnected','xdr','./agents.controller','./calls.controller','./queues.controller','./recordings.controller','./members.controller','./transfers.controller','connect','shutdown','fullybooted','error','close','managerevent','devicestatechange','debug','[%s][index][devicestatechange]','device','format','agentcalled','uniqueid','[%s][index][agentcalled]','[%s][index][agentringnoanswer]','agentringnoanswer','agentconnect','[%s][index][agentconnect]','agentcomplete','[%s][index][agentcomplete]','[%s][index][queuecallerabandon]','queuecallerabandon','queuecallerjoin','queuecallerleave','[%s][index][queuecallerleave]','[%s][index][musiconholdstart]','musiconholdstart','musiconholdstop','[%s][index][musiconholdstop]','newstate','[%s][index][newstate]','[%s][index][hangup]','hangup','cdr','blindtransfer','[%s][index][blindtransfer]','attendedtransfer','[%s][index][attendedtransfer]','origtransfereruniqueid','varset','[%s][index][varset]'];(function(_0xb487c6,_0x3bbbc1){var _0x17773d=function(_0x5a4b13){while(--_0x5a4b13){_0xb487c6['push'](_0xb487c6['shift']());}};_0x17773d(++_0x3bbbc1);}(_0xabff,0x109));var _0xfabf=function(_0x39187b,_0x2a6214){_0x39187b=_0x39187b-0x0;var _0x2cf25f=_0xabff[_0x39187b];return _0x2cf25f;};var AsteriskManager=require('asterisk-manager');var config=require(_0xfabf('0x0'));var utils=require(_0xfabf('0x1'));var util=require(_0xfabf('0x2'));var ami=new AsteriskManager(config['asterisk'][_0xfabf('0x3')],config[_0xfabf('0x4')]['ip'],config[_0xfabf('0x4')]['username'],config[_0xfabf('0x4')][_0xfabf('0x5')],!![]);ami[_0xfabf('0x6')]();if(config[_0xfabf('0x7')]&&config[_0xfabf('0x7')]['disabled']){utils['info']('XDR\x20DISABLED');}else{var agents=require(_0xfabf('0x8'));var calls=require(_0xfabf('0x9'));var queues=require(_0xfabf('0xa'));var recordings=require(_0xfabf('0xb'));var members=require(_0xfabf('0xc'));var dials=require('./dials.controller');var transfers=require(_0xfabf('0xd'));var core=require('./core.controller');ami['on'](_0xfabf('0xe'),core[_0xfabf('0xe')]);ami['on'](_0xfabf('0xf'),core['shutdown']);ami['on']('fullybooted',core[_0xfabf('0x10')]);ami['on'](_0xfabf('0x11'),core[_0xfabf('0x11')]);ami['on'](_0xfabf('0x12'),core['close']);ami['on'](_0xfabf('0x13'),core[_0xfabf('0x13')]);ami['on'](_0xfabf('0x14'),function(_0xce36ae){try{utils[_0xfabf('0x15')](util['format'](_0xfabf('0x16'),_0xce36ae[_0xfabf('0x17')]),_0xce36ae);members[_0xfabf('0x14')](_0xce36ae);}catch(_0x22ef2b){utils[_0xfabf('0x11')](util[_0xfabf('0x18')](_0xfabf('0x16'),_0xce36ae[_0xfabf('0x17')]),_0x22ef2b);}});ami['on'](_0xfabf('0x19'),function(_0xc4ae0f){try{utils[_0xfabf('0x15')](util[_0xfabf('0x18')]('[%s][index][agentcalled]',_0xc4ae0f[_0xfabf('0x1a')]),_0xc4ae0f);agents['agentcalled'](_0xc4ae0f);}catch(_0x5906f9){utils[_0xfabf('0x11')](util['format'](_0xfabf('0x1b'),_0xc4ae0f[_0xfabf('0x1a')]),_0x5906f9);}});ami['on']('agentringnoanswer',function(_0x439efa){try{utils[_0xfabf('0x15')](util[_0xfabf('0x18')](_0xfabf('0x1c'),_0x439efa[_0xfabf('0x1a')]),_0x439efa);agents[_0xfabf('0x1d')](_0x439efa);}catch(_0x370dc2){utils[_0xfabf('0x11')](util[_0xfabf('0x18')](_0xfabf('0x1c'),_0x439efa[_0xfabf('0x1a')]),_0x370dc2);}});ami['on'](_0xfabf('0x1e'),function(_0x5abaa0){try{utils['debug'](util[_0xfabf('0x18')](_0xfabf('0x1f'),_0x5abaa0[_0xfabf('0x1a')]),_0x5abaa0);agents['agentconnect'](_0x5abaa0);queues[_0xfabf('0x1e')](_0x5abaa0);}catch(_0x19fe72){utils[_0xfabf('0x11')](util[_0xfabf('0x18')](_0xfabf('0x1f'),_0x5abaa0[_0xfabf('0x1a')]),_0x19fe72);}});ami['on'](_0xfabf('0x20'),function(_0x518ed1){try{utils[_0xfabf('0x15')](util[_0xfabf('0x18')]('[%s][index][agentcomplete]',_0x518ed1[_0xfabf('0x1a')]),_0x518ed1);agents[_0xfabf('0x20')](_0x518ed1);queues[_0xfabf('0x20')](_0x518ed1);members[_0xfabf('0x20')](_0x518ed1);}catch(_0x2047a2){utils[_0xfabf('0x11')](util[_0xfabf('0x18')](_0xfabf('0x21'),_0x518ed1[_0xfabf('0x1a')]),_0x2047a2);}});ami['on']('queuecallerabandon',function(_0x6545d6){try{utils[_0xfabf('0x15')](util[_0xfabf('0x18')](_0xfabf('0x22'),_0x6545d6[_0xfabf('0x1a')]),_0x6545d6);agents[_0xfabf('0x23')](_0x6545d6);queues[_0xfabf('0x23')](_0x6545d6);}catch(_0x30d2b1){utils[_0xfabf('0x11')](util['format'](_0xfabf('0x22'),_0x6545d6[_0xfabf('0x1a')]),_0x30d2b1);}});ami['on']('queuecallerjoin',function(_0x4f0f10){try{utils[_0xfabf('0x15')](util[_0xfabf('0x18')]('[%s][index][queuecallerjoin]',_0x4f0f10[_0xfabf('0x1a')]),_0x4f0f10);queues[_0xfabf('0x24')](_0x4f0f10);recordings['queuecallerjoin'](_0x4f0f10);}catch(_0x1e4cf1){utils[_0xfabf('0x11')](util[_0xfabf('0x18')]('[%s][index][queuecallerjoin]',_0x4f0f10['uniqueid']),_0x1e4cf1);}});ami['on'](_0xfabf('0x25'),function(_0x521665){try{utils[_0xfabf('0x15')](util[_0xfabf('0x18')]('[%s][index][queuecallerleave]',_0x521665[_0xfabf('0x1a')]),_0x521665);queues[_0xfabf('0x25')](_0x521665);}catch(_0x30cef7){utils[_0xfabf('0x11')](util['format'](_0xfabf('0x26'),_0x521665[_0xfabf('0x1a')]),_0x30cef7);}});ami['on']('musiconholdstart',function(_0x3f42f2){try{utils[_0xfabf('0x15')](util[_0xfabf('0x18')](_0xfabf('0x27'),_0x3f42f2[_0xfabf('0x1a')]),_0x3f42f2);queues['musiconholdstart'](_0x3f42f2);calls[_0xfabf('0x28')](_0x3f42f2);}catch(_0x43ee6a){utils[_0xfabf('0x11')](util[_0xfabf('0x18')](_0xfabf('0x27'),_0x3f42f2['uniqueid']),_0x43ee6a);}});ami['on'](_0xfabf('0x29'),function(_0x2dcf40){try{utils[_0xfabf('0x15')](util[_0xfabf('0x18')](_0xfabf('0x2a'),_0x2dcf40[_0xfabf('0x1a')]),_0x2dcf40);queues[_0xfabf('0x29')](_0x2dcf40);calls['musiconholdstop'](_0x2dcf40);}catch(_0x34ccea){utils[_0xfabf('0x11')](util[_0xfabf('0x18')](_0xfabf('0x2a'),_0x2dcf40[_0xfabf('0x1a')]),_0x34ccea);}});ami['on'](_0xfabf('0x2b'),function(_0x56af62){try{utils['debug'](util[_0xfabf('0x18')](_0xfabf('0x2c'),_0x56af62['uniqueid']),_0x56af62);calls[_0xfabf('0x2b')](_0x56af62);recordings[_0xfabf('0x2b')](_0x56af62);}catch(_0x40cdc5){utils[_0xfabf('0x11')](util['format']('[%s][index][newstate]',_0x56af62[_0xfabf('0x1a')]),_0x40cdc5);}});ami['on']('hangup',function(_0x3cb330){try{utils[_0xfabf('0x15')](util[_0xfabf('0x18')](_0xfabf('0x2d'),_0x3cb330['uniqueid']),_0x3cb330);calls['hangup'](_0x3cb330);recordings[_0xfabf('0x2e')](_0x3cb330);dials[_0xfabf('0x2e')](_0x3cb330);agents[_0xfabf('0x2e')](_0x3cb330);queues['hangup'](_0x3cb330);}catch(_0x1f261a){utils[_0xfabf('0x11')](util['format'](_0xfabf('0x2d'),_0x3cb330['uniqueid']),_0x1f261a);}});ami['on'](_0xfabf('0x2f'),function(_0x3a470c){try{utils[_0xfabf('0x15')](util['format']('[%s][index][cdr]',_0x3a470c['uniqueid']),_0x3a470c);members[_0xfabf('0x2f')](_0x3a470c);}catch(_0x31ea3e){utils['error'](util[_0xfabf('0x18')]('[%s][index][cdr]',_0x3a470c[_0xfabf('0x1a')]),_0x31ea3e);}});ami['on'](_0xfabf('0x30'),function(_0x9ce428){try{utils[_0xfabf('0x15')](util[_0xfabf('0x18')](_0xfabf('0x31'),_0x9ce428[_0xfabf('0x1a')]),_0x9ce428);queues['blindtransfer'](_0x9ce428);agents[_0xfabf('0x30')](_0x9ce428);transfers[_0xfabf('0x30')](_0x9ce428);recordings[_0xfabf('0x30')](_0x9ce428);}catch(_0x58400a){utils[_0xfabf('0x11')](util['format'](_0xfabf('0x31'),_0x9ce428[_0xfabf('0x1a')]),_0x58400a);}});ami['on'](_0xfabf('0x32'),function(_0x3a2cb3){try{utils[_0xfabf('0x15')](util[_0xfabf('0x18')](_0xfabf('0x33'),_0x3a2cb3[_0xfabf('0x34')]),_0x3a2cb3);queues['attendedtransfer'](_0x3a2cb3);transfers[_0xfabf('0x32')](_0x3a2cb3);agents[_0xfabf('0x32')](_0x3a2cb3);calls[_0xfabf('0x32')](_0x3a2cb3);}catch(_0x267ff6){utils[_0xfabf('0x11')](util['format'](_0xfabf('0x33'),_0x3a2cb3[_0xfabf('0x34')]),_0x267ff6);}});ami['on'](_0xfabf('0x35'),function(_0x5e892b){try{utils[_0xfabf('0x15')](util['format'](_0xfabf('0x36'),_0x5e892b[_0xfabf('0x1a')]),_0x5e892b);queues['varset'](_0x5e892b);recordings['varset'](_0x5e892b);calls[_0xfabf('0x35')](_0x5e892b);dials[_0xfabf('0x35')](_0x5e892b);}catch(_0x2bdc12){utils[_0xfabf('0x11')](util[_0xfabf('0x18')](_0xfabf('0x36'),_0x5e892b[_0xfabf('0x1a')]),_0x2bdc12);}});ami['on'](_0xfabf('0x37'),function(_0xa478b1){try{utils[_0xfabf('0x15')](util['format'](_0xfabf('0x38'),_0xa478b1[_0xfabf('0x1a')]),_0xa478b1);calls[_0xfabf('0x37')](_0xa478b1);recordings['newexten'](_0xa478b1);dials[_0xfabf('0x37')](_0xa478b1);}catch(_0x30923f){utils['error'](util[_0xfabf('0x18')](_0xfabf('0x38'),_0xa478b1[_0xfabf('0x1a')]),_0x30923f);}});ami['on'](_0xfabf('0x39'),function(_0x19c439){try{utils['debug'](util[_0xfabf('0x18')]('[%s][index][newchannel]',_0x19c439[_0xfabf('0x1a')]),_0x19c439);calls['newchannel'](_0x19c439);recordings[_0xfabf('0x39')](_0x19c439);}catch(_0x1b5e26){utils[_0xfabf('0x11')](util[_0xfabf('0x18')](_0xfabf('0x3a'),_0x19c439['uniqueid']),_0x1b5e26);}});ami['on'](_0xfabf('0x3b'),function(_0x203a00){try{utils[_0xfabf('0x15')](util['format'](_0xfabf('0x3c'),_0x203a00['uniqueid']),_0x203a00);dials['dialbegin'](_0x203a00);}catch(_0x4a44bc){utils[_0xfabf('0x11')](util[_0xfabf('0x18')](_0xfabf('0x3d'),_0x203a00[_0xfabf('0x1a')]),_0x4a44bc);}});ami['on']('dialend',function(_0x5da545){try{utils[_0xfabf('0x15')](util['format'](_0xfabf('0x3e'),_0x5da545['uniqueid']),_0x5da545);dials[_0xfabf('0x3f')](_0x5da545);}catch(_0x5a263f){utils[_0xfabf('0x11')](util[_0xfabf('0x18')](_0xfabf('0x3e'),_0x5da545['uniqueid']),_0x5a263f);}});}