Built motion from commit (unavailable).|2.5.31
[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 _0x7d1f=['agentringnoanswer','agentconnect','[%s][index][agentconnect]','[%s][index][agentcomplete]','agentcomplete','queuecallerabandon','[%s][index][queuecallerabandon]','[%s][index][queuecallerjoin]','queuecallerjoin','[%s][index][queuecallerleave]','[%s][index][musiconholdstart]','musiconholdstart','musiconholdstop','[%s][index][musiconholdstop]','newstate','[%s][index][newstate]','[%s][index][hangup]','hangup','cdr','[%s][index][cdr]','blindtransfer','[%s][index][blindtransfer]','[%s][index][attendedtransfer]','attendedtransfer','origtransfereruniqueid','[%s][index][varset]','varset','newexten','[%s][index][newexten]','newchannel','[%s][index][newchannel]','dialbegin','[%s][index][dialbegin]','[%s]dialbegin','dialend','[%s][index][dialend]','asterisk-manager','../../config/environment','util','asterisk','port','username','keepConnected','xdr','disabled','info','XDR\x20DISABLED','./agents.controller','./calls.controller','./queues.controller','./recordings.controller','./members.controller','./dials.controller','connect','shutdown','fullybooted','error','close','managerevent','devicestatechange','debug','[%s][index][devicestatechange]','device','format','[%s][index][agentcalled]','uniqueid','[%s][index][agentringnoanswer]'];(function(_0x59e3c6,_0x516795){var _0x21d5f6=function(_0x3910f1){while(--_0x3910f1){_0x59e3c6['push'](_0x59e3c6['shift']());}};_0x21d5f6(++_0x516795);}(_0x7d1f,0xaa));var _0xf7d1=function(_0x34ada8,_0x5de101){_0x34ada8=_0x34ada8-0x0;var _0xfdd95e=_0x7d1f[_0x34ada8];return _0xfdd95e;};var AsteriskManager=require(_0xf7d1('0x0'));var config=require(_0xf7d1('0x1'));var utils=require('./utils');var util=require(_0xf7d1('0x2'));var ami=new AsteriskManager(config[_0xf7d1('0x3')][_0xf7d1('0x4')],config[_0xf7d1('0x3')]['ip'],config['asterisk'][_0xf7d1('0x5')],config[_0xf7d1('0x3')]['password'],!![]);ami[_0xf7d1('0x6')]();if(config[_0xf7d1('0x7')]&&config['xdr'][_0xf7d1('0x8')]){utils[_0xf7d1('0x9')](_0xf7d1('0xa'));}else{var agents=require(_0xf7d1('0xb'));var calls=require(_0xf7d1('0xc'));var queues=require(_0xf7d1('0xd'));var recordings=require(_0xf7d1('0xe'));var members=require(_0xf7d1('0xf'));var dials=require(_0xf7d1('0x10'));var transfers=require('./transfers.controller');var core=require('./core.controller');ami['on'](_0xf7d1('0x11'),core[_0xf7d1('0x11')]);ami['on'](_0xf7d1('0x12'),core[_0xf7d1('0x12')]);ami['on'](_0xf7d1('0x13'),core['fullybooted']);ami['on'](_0xf7d1('0x14'),core['error']);ami['on'](_0xf7d1('0x15'),core[_0xf7d1('0x15')]);ami['on'](_0xf7d1('0x16'),core['managerevent']);ami['on'](_0xf7d1('0x17'),function(_0x24e088){try{utils[_0xf7d1('0x18')](util['format'](_0xf7d1('0x19'),_0x24e088[_0xf7d1('0x1a')]),_0x24e088);members[_0xf7d1('0x17')](_0x24e088);}catch(_0x39093f){utils[_0xf7d1('0x14')](util[_0xf7d1('0x1b')]('[%s][index][devicestatechange]',_0x24e088[_0xf7d1('0x1a')]),_0x39093f);}});ami['on']('agentcalled',function(_0x4ece7f){try{utils[_0xf7d1('0x18')](util[_0xf7d1('0x1b')](_0xf7d1('0x1c'),_0x4ece7f[_0xf7d1('0x1d')]),_0x4ece7f);agents['agentcalled'](_0x4ece7f);}catch(_0x35b848){utils[_0xf7d1('0x14')](util[_0xf7d1('0x1b')]('[%s][index][agentcalled]',_0x4ece7f[_0xf7d1('0x1d')]),_0x35b848);}});ami['on']('agentringnoanswer',function(_0x3e3f77){try{utils['debug'](util['format'](_0xf7d1('0x1e'),_0x3e3f77['uniqueid']),_0x3e3f77);agents[_0xf7d1('0x1f')](_0x3e3f77);}catch(_0x344828){utils['error'](util[_0xf7d1('0x1b')](_0xf7d1('0x1e'),_0x3e3f77[_0xf7d1('0x1d')]),_0x344828);}});ami['on'](_0xf7d1('0x20'),function(_0x5abc3e){try{utils[_0xf7d1('0x18')](util[_0xf7d1('0x1b')](_0xf7d1('0x21'),_0x5abc3e[_0xf7d1('0x1d')]),_0x5abc3e);agents['agentconnect'](_0x5abc3e);queues[_0xf7d1('0x20')](_0x5abc3e);}catch(_0x2a59f9){utils['error'](util[_0xf7d1('0x1b')](_0xf7d1('0x21'),_0x5abc3e['uniqueid']),_0x2a59f9);}});ami['on']('agentcomplete',function(_0x29555e){try{utils[_0xf7d1('0x18')](util[_0xf7d1('0x1b')](_0xf7d1('0x22'),_0x29555e[_0xf7d1('0x1d')]),_0x29555e);agents[_0xf7d1('0x23')](_0x29555e);queues[_0xf7d1('0x23')](_0x29555e);members[_0xf7d1('0x23')](_0x29555e);}catch(_0x4bdd2d){utils[_0xf7d1('0x14')](util[_0xf7d1('0x1b')]('[%s][index][agentcomplete]',_0x29555e[_0xf7d1('0x1d')]),_0x4bdd2d);}});ami['on'](_0xf7d1('0x24'),function(_0xe1dd9b){try{utils[_0xf7d1('0x18')](util['format'](_0xf7d1('0x25'),_0xe1dd9b[_0xf7d1('0x1d')]),_0xe1dd9b);agents[_0xf7d1('0x24')](_0xe1dd9b);queues[_0xf7d1('0x24')](_0xe1dd9b);}catch(_0x17dcbd){utils[_0xf7d1('0x14')](util[_0xf7d1('0x1b')](_0xf7d1('0x25'),_0xe1dd9b[_0xf7d1('0x1d')]),_0x17dcbd);}});ami['on']('queuecallerjoin',function(_0x31ffad){try{utils[_0xf7d1('0x18')](util['format'](_0xf7d1('0x26'),_0x31ffad[_0xf7d1('0x1d')]),_0x31ffad);queues[_0xf7d1('0x27')](_0x31ffad);recordings[_0xf7d1('0x27')](_0x31ffad);}catch(_0x1073d4){utils[_0xf7d1('0x14')](util[_0xf7d1('0x1b')]('[%s][index][queuecallerjoin]',_0x31ffad[_0xf7d1('0x1d')]),_0x1073d4);}});ami['on']('queuecallerleave',function(_0x1ded89){try{utils['debug'](util[_0xf7d1('0x1b')](_0xf7d1('0x28'),_0x1ded89['uniqueid']),_0x1ded89);queues['queuecallerleave'](_0x1ded89);}catch(_0x2b226d){utils['error'](util[_0xf7d1('0x1b')](_0xf7d1('0x28'),_0x1ded89[_0xf7d1('0x1d')]),_0x2b226d);}});ami['on']('musiconholdstart',function(_0xe15fc9){try{utils['debug'](util[_0xf7d1('0x1b')](_0xf7d1('0x29'),_0xe15fc9[_0xf7d1('0x1d')]),_0xe15fc9);queues['musiconholdstart'](_0xe15fc9);calls[_0xf7d1('0x2a')](_0xe15fc9);}catch(_0x2b973b){utils['error'](util[_0xf7d1('0x1b')](_0xf7d1('0x29'),_0xe15fc9[_0xf7d1('0x1d')]),_0x2b973b);}});ami['on'](_0xf7d1('0x2b'),function(_0x696468){try{utils[_0xf7d1('0x18')](util[_0xf7d1('0x1b')](_0xf7d1('0x2c'),_0x696468[_0xf7d1('0x1d')]),_0x696468);queues[_0xf7d1('0x2b')](_0x696468);calls[_0xf7d1('0x2b')](_0x696468);}catch(_0x2e4885){utils['error'](util[_0xf7d1('0x1b')](_0xf7d1('0x2c'),_0x696468[_0xf7d1('0x1d')]),_0x2e4885);}});ami['on']('newstate',function(_0x460a2a){try{utils[_0xf7d1('0x18')](util[_0xf7d1('0x1b')]('[%s][index][newstate]',_0x460a2a[_0xf7d1('0x1d')]),_0x460a2a);calls['newstate'](_0x460a2a);recordings[_0xf7d1('0x2d')](_0x460a2a);}catch(_0x12f5bf){utils['error'](util[_0xf7d1('0x1b')](_0xf7d1('0x2e'),_0x460a2a[_0xf7d1('0x1d')]),_0x12f5bf);}});ami['on']('hangup',function(_0x3c2914){try{utils[_0xf7d1('0x18')](util[_0xf7d1('0x1b')](_0xf7d1('0x2f'),_0x3c2914['uniqueid']),_0x3c2914);calls[_0xf7d1('0x30')](_0x3c2914);recordings[_0xf7d1('0x30')](_0x3c2914);dials[_0xf7d1('0x30')](_0x3c2914);agents[_0xf7d1('0x30')](_0x3c2914);queues[_0xf7d1('0x30')](_0x3c2914);}catch(_0x17d4e3){utils['error'](util[_0xf7d1('0x1b')](_0xf7d1('0x2f'),_0x3c2914[_0xf7d1('0x1d')]),_0x17d4e3);}});ami['on'](_0xf7d1('0x31'),function(_0x11dc51){try{utils[_0xf7d1('0x18')](util[_0xf7d1('0x1b')](_0xf7d1('0x32'),_0x11dc51['uniqueid']),_0x11dc51);members[_0xf7d1('0x31')](_0x11dc51);}catch(_0xfeac50){utils[_0xf7d1('0x14')](util['format'](_0xf7d1('0x32'),_0x11dc51[_0xf7d1('0x1d')]),_0xfeac50);}});ami['on'](_0xf7d1('0x33'),function(_0x47d8c4){try{utils[_0xf7d1('0x18')](util['format'](_0xf7d1('0x34'),_0x47d8c4['uniqueid']),_0x47d8c4);queues[_0xf7d1('0x33')](_0x47d8c4);agents[_0xf7d1('0x33')](_0x47d8c4);transfers[_0xf7d1('0x33')](_0x47d8c4);}catch(_0x574e58){utils['error'](util[_0xf7d1('0x1b')](_0xf7d1('0x34'),_0x47d8c4[_0xf7d1('0x1d')]),_0x574e58);}});ami['on']('attendedtransfer',function(_0x15be19){try{utils['debug'](util[_0xf7d1('0x1b')](_0xf7d1('0x35'),_0x15be19['origtransfereruniqueid']),_0x15be19);queues[_0xf7d1('0x36')](_0x15be19);transfers[_0xf7d1('0x36')](_0x15be19);agents[_0xf7d1('0x36')](_0x15be19);calls[_0xf7d1('0x36')](_0x15be19);}catch(_0x5da998){utils[_0xf7d1('0x14')](util['format']('[%s][index][attendedtransfer]',_0x15be19[_0xf7d1('0x37')]),_0x5da998);}});ami['on']('varset',function(_0xcd36fb){try{utils[_0xf7d1('0x18')](util['format'](_0xf7d1('0x38'),_0xcd36fb['uniqueid']),_0xcd36fb);queues['varset'](_0xcd36fb);recordings[_0xf7d1('0x39')](_0xcd36fb);calls[_0xf7d1('0x39')](_0xcd36fb);dials[_0xf7d1('0x39')](_0xcd36fb);}catch(_0x2df4e0){utils[_0xf7d1('0x14')](util[_0xf7d1('0x1b')](_0xf7d1('0x38'),_0xcd36fb['uniqueid']),_0x2df4e0);}});ami['on'](_0xf7d1('0x3a'),function(_0x30214e){try{utils['debug'](util[_0xf7d1('0x1b')]('[%s][index][newexten]',_0x30214e[_0xf7d1('0x1d')]),_0x30214e);calls[_0xf7d1('0x3a')](_0x30214e);recordings['newexten'](_0x30214e);dials[_0xf7d1('0x3a')](_0x30214e);}catch(_0x1199eb){utils['error'](util[_0xf7d1('0x1b')](_0xf7d1('0x3b'),_0x30214e[_0xf7d1('0x1d')]),_0x1199eb);}});ami['on'](_0xf7d1('0x3c'),function(_0x31e6af){try{utils[_0xf7d1('0x18')](util[_0xf7d1('0x1b')](_0xf7d1('0x3d'),_0x31e6af[_0xf7d1('0x1d')]),_0x31e6af);calls[_0xf7d1('0x3c')](_0x31e6af);recordings['newchannel'](_0x31e6af);}catch(_0x2580c5){utils[_0xf7d1('0x14')](util[_0xf7d1('0x1b')](_0xf7d1('0x3d'),_0x31e6af['uniqueid']),_0x2580c5);}});ami['on'](_0xf7d1('0x3e'),function(_0x3100f1){try{utils[_0xf7d1('0x18')](util['format'](_0xf7d1('0x3f'),_0x3100f1[_0xf7d1('0x1d')]),_0x3100f1);dials[_0xf7d1('0x3e')](_0x3100f1);}catch(_0x56c151){utils[_0xf7d1('0x14')](util['format'](_0xf7d1('0x40'),_0x3100f1[_0xf7d1('0x1d')]),_0x56c151);}});ami['on']('dialend',function(_0x2823a5){try{utils[_0xf7d1('0x18')](util[_0xf7d1('0x1b')]('[%s][index][dialend]',_0x2823a5[_0xf7d1('0x1d')]),_0x2823a5);dials[_0xf7d1('0x41')](_0x2823a5);}catch(_0x28783e){utils[_0xf7d1('0x14')](util['format'](_0xf7d1('0x42'),_0x2823a5[_0xf7d1('0x1d')]),_0x28783e);}});}