9b1cb9582d2fe47e1aa44ab65d60726809900026
[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 _0x05fb=['asterisk-manager','../../config/environment','./utils','util','asterisk','port','username','password','keepConnected','xdr','disabled','info','./agents.controller','./members.controller','./transfers.controller','connect','shutdown','fullybooted','error','close','managerevent','devicestatechange','[%s][index][devicestatechange]','device','agentcalled','debug','uniqueid','format','[%s][index][agentcalled]','[%s][index][agentringnoanswer]','agentringnoanswer','agentconnect','agentcomplete','[%s][index][agentcomplete]','queuecallerabandon','[%s][index][queuecallerabandon]','queuecallerjoin','[%s][index][queuecallerjoin]','[%s][index][queuecallerleave]','queuecallerleave','musiconholdstart','[%s][index][musiconholdstart]','musiconholdstop','[%s][index][musiconholdstop]','[%s][index][newstate]','newstate','hangup','cdr','blindtransfer','[%s][index][blindtransfer]','[%s][index][attendedtransfer]','origtransfereruniqueid','attendedtransfer','varset','[%s][index][varset]','newexten','[%s][index][newexten]','[%s][index][newchannel]','newchannel','dialbegin','[%s][index][dialbegin]','[%s]dialbegin','[%s][index][dialend]'];(function(_0x1d99c4,_0x5cda95){var _0x504ee5=function(_0x586aca){while(--_0x586aca){_0x1d99c4['push'](_0x1d99c4['shift']());}};_0x504ee5(++_0x5cda95);}(_0x05fb,0x1b9));var _0xb05f=function(_0x330293,_0x25f3e6){_0x330293=_0x330293-0x0;var _0xa1e41a=_0x05fb[_0x330293];return _0xa1e41a;};var AsteriskManager=require(_0xb05f('0x0'));var config=require(_0xb05f('0x1'));var utils=require(_0xb05f('0x2'));var util=require(_0xb05f('0x3'));var ami=new AsteriskManager(config[_0xb05f('0x4')][_0xb05f('0x5')],config[_0xb05f('0x4')]['ip'],config[_0xb05f('0x4')][_0xb05f('0x6')],config['asterisk'][_0xb05f('0x7')],!![]);ami[_0xb05f('0x8')]();if(config[_0xb05f('0x9')]&&config[_0xb05f('0x9')][_0xb05f('0xa')]){utils[_0xb05f('0xb')]('XDR\x20DISABLED');}else{var agents=require(_0xb05f('0xc'));var calls=require('./calls.controller');var queues=require('./queues.controller');var recordings=require('./recordings.controller');var members=require(_0xb05f('0xd'));var dials=require('./dials.controller');var transfers=require(_0xb05f('0xe'));var core=require('./core.controller');ami['on'](_0xb05f('0xf'),core[_0xb05f('0xf')]);ami['on']('shutdown',core[_0xb05f('0x10')]);ami['on'](_0xb05f('0x11'),core['fullybooted']);ami['on'](_0xb05f('0x12'),core[_0xb05f('0x12')]);ami['on'](_0xb05f('0x13'),core[_0xb05f('0x13')]);ami['on'](_0xb05f('0x14'),core[_0xb05f('0x14')]);ami['on'](_0xb05f('0x15'),function(_0x18358d){try{utils['debug'](util['format'](_0xb05f('0x16'),_0x18358d[_0xb05f('0x17')]),_0x18358d);members[_0xb05f('0x15')](_0x18358d);}catch(_0x549d62){utils['error'](util['format'](_0xb05f('0x16'),_0x18358d[_0xb05f('0x17')]),_0x549d62);}});ami['on'](_0xb05f('0x18'),function(_0x4eda92){try{utils[_0xb05f('0x19')](util['format']('[%s][index][agentcalled]',_0x4eda92[_0xb05f('0x1a')]),_0x4eda92);agents['agentcalled'](_0x4eda92);}catch(_0x1ec4a6){utils['error'](util[_0xb05f('0x1b')](_0xb05f('0x1c'),_0x4eda92[_0xb05f('0x1a')]),_0x1ec4a6);}});ami['on']('agentringnoanswer',function(_0x308e6f){try{utils[_0xb05f('0x19')](util[_0xb05f('0x1b')](_0xb05f('0x1d'),_0x308e6f[_0xb05f('0x1a')]),_0x308e6f);agents[_0xb05f('0x1e')](_0x308e6f);}catch(_0x53d270){utils[_0xb05f('0x12')](util[_0xb05f('0x1b')](_0xb05f('0x1d'),_0x308e6f[_0xb05f('0x1a')]),_0x53d270);}});ami['on'](_0xb05f('0x1f'),function(_0x5180d3){try{utils[_0xb05f('0x19')](util['format']('[%s][index][agentconnect]',_0x5180d3[_0xb05f('0x1a')]),_0x5180d3);agents[_0xb05f('0x1f')](_0x5180d3);queues[_0xb05f('0x1f')](_0x5180d3);}catch(_0x4212e8){utils[_0xb05f('0x12')](util['format']('[%s][index][agentconnect]',_0x5180d3[_0xb05f('0x1a')]),_0x4212e8);}});ami['on'](_0xb05f('0x20'),function(_0x4d5b83){try{utils[_0xb05f('0x19')](util[_0xb05f('0x1b')](_0xb05f('0x21'),_0x4d5b83[_0xb05f('0x1a')]),_0x4d5b83);agents[_0xb05f('0x20')](_0x4d5b83);queues[_0xb05f('0x20')](_0x4d5b83);members[_0xb05f('0x20')](_0x4d5b83);}catch(_0x10fd4c){utils['error'](util['format']('[%s][index][agentcomplete]',_0x4d5b83[_0xb05f('0x1a')]),_0x10fd4c);}});ami['on'](_0xb05f('0x22'),function(_0x30986e){try{utils[_0xb05f('0x19')](util['format']('[%s][index][queuecallerabandon]',_0x30986e[_0xb05f('0x1a')]),_0x30986e);agents['queuecallerabandon'](_0x30986e);queues[_0xb05f('0x22')](_0x30986e);}catch(_0x442a8c){utils['error'](util[_0xb05f('0x1b')](_0xb05f('0x23'),_0x30986e['uniqueid']),_0x442a8c);}});ami['on'](_0xb05f('0x24'),function(_0x13e671){try{utils[_0xb05f('0x19')](util[_0xb05f('0x1b')](_0xb05f('0x25'),_0x13e671['uniqueid']),_0x13e671);queues['queuecallerjoin'](_0x13e671);recordings['queuecallerjoin'](_0x13e671);}catch(_0xed726e){utils['error'](util[_0xb05f('0x1b')](_0xb05f('0x25'),_0x13e671[_0xb05f('0x1a')]),_0xed726e);}});ami['on']('queuecallerleave',function(_0x45561f){try{utils[_0xb05f('0x19')](util[_0xb05f('0x1b')](_0xb05f('0x26'),_0x45561f['uniqueid']),_0x45561f);queues[_0xb05f('0x27')](_0x45561f);}catch(_0x12c586){utils['error'](util[_0xb05f('0x1b')](_0xb05f('0x26'),_0x45561f[_0xb05f('0x1a')]),_0x12c586);}});ami['on'](_0xb05f('0x28'),function(_0x1247c3){try{utils[_0xb05f('0x19')](util['format'](_0xb05f('0x29'),_0x1247c3[_0xb05f('0x1a')]),_0x1247c3);queues['musiconholdstart'](_0x1247c3);calls[_0xb05f('0x28')](_0x1247c3);}catch(_0x104a6e){utils[_0xb05f('0x12')](util[_0xb05f('0x1b')](_0xb05f('0x29'),_0x1247c3[_0xb05f('0x1a')]),_0x104a6e);}});ami['on'](_0xb05f('0x2a'),function(_0x45bbb0){try{utils['debug'](util['format'](_0xb05f('0x2b'),_0x45bbb0['uniqueid']),_0x45bbb0);queues['musiconholdstop'](_0x45bbb0);calls[_0xb05f('0x2a')](_0x45bbb0);}catch(_0x1f9f09){utils[_0xb05f('0x12')](util[_0xb05f('0x1b')]('[%s][index][musiconholdstop]',_0x45bbb0[_0xb05f('0x1a')]),_0x1f9f09);}});ami['on']('newstate',function(_0x429d46){try{utils['debug'](util[_0xb05f('0x1b')](_0xb05f('0x2c'),_0x429d46[_0xb05f('0x1a')]),_0x429d46);calls[_0xb05f('0x2d')](_0x429d46);recordings['newstate'](_0x429d46);}catch(_0x2cccf6){utils['error'](util[_0xb05f('0x1b')](_0xb05f('0x2c'),_0x429d46['uniqueid']),_0x2cccf6);}});ami['on'](_0xb05f('0x2e'),function(_0x5231e7){try{utils[_0xb05f('0x19')](util['format']('[%s][index][hangup]',_0x5231e7[_0xb05f('0x1a')]),_0x5231e7);calls[_0xb05f('0x2e')](_0x5231e7);recordings[_0xb05f('0x2e')](_0x5231e7);dials[_0xb05f('0x2e')](_0x5231e7);agents['hangup'](_0x5231e7);queues[_0xb05f('0x2e')](_0x5231e7);}catch(_0x3f11e4){utils[_0xb05f('0x12')](util[_0xb05f('0x1b')]('[%s][index][hangup]',_0x5231e7[_0xb05f('0x1a')]),_0x3f11e4);}});ami['on'](_0xb05f('0x2f'),function(_0xe2f8d3){try{utils['debug'](util[_0xb05f('0x1b')]('[%s][index][cdr]',_0xe2f8d3[_0xb05f('0x1a')]),_0xe2f8d3);members[_0xb05f('0x2f')](_0xe2f8d3);}catch(_0x2c3ded){utils['error'](util['format']('[%s][index][cdr]',_0xe2f8d3['uniqueid']),_0x2c3ded);}});ami['on'](_0xb05f('0x30'),function(_0x168e47){try{utils[_0xb05f('0x19')](util[_0xb05f('0x1b')](_0xb05f('0x31'),_0x168e47[_0xb05f('0x1a')]),_0x168e47);queues[_0xb05f('0x30')](_0x168e47);agents[_0xb05f('0x30')](_0x168e47);transfers[_0xb05f('0x30')](_0x168e47);}catch(_0x52ebb9){utils['error'](util[_0xb05f('0x1b')]('[%s][index][blindtransfer]',_0x168e47['uniqueid']),_0x52ebb9);}});ami['on']('attendedtransfer',function(_0x28c4cd){try{utils[_0xb05f('0x19')](util[_0xb05f('0x1b')](_0xb05f('0x32'),_0x28c4cd[_0xb05f('0x33')]),_0x28c4cd);queues[_0xb05f('0x34')](_0x28c4cd);transfers['attendedtransfer'](_0x28c4cd);agents[_0xb05f('0x34')](_0x28c4cd);calls[_0xb05f('0x34')](_0x28c4cd);}catch(_0x565ad9){utils[_0xb05f('0x12')](util[_0xb05f('0x1b')]('[%s][index][attendedtransfer]',_0x28c4cd[_0xb05f('0x33')]),_0x565ad9);}});ami['on'](_0xb05f('0x35'),function(_0x5810fe){try{utils[_0xb05f('0x19')](util[_0xb05f('0x1b')](_0xb05f('0x36'),_0x5810fe[_0xb05f('0x1a')]),_0x5810fe);queues[_0xb05f('0x35')](_0x5810fe);recordings[_0xb05f('0x35')](_0x5810fe);calls[_0xb05f('0x35')](_0x5810fe);dials[_0xb05f('0x35')](_0x5810fe);}catch(_0x5dc2bd){utils[_0xb05f('0x12')](util[_0xb05f('0x1b')](_0xb05f('0x36'),_0x5810fe[_0xb05f('0x1a')]),_0x5dc2bd);}});ami['on'](_0xb05f('0x37'),function(_0x3ee130){try{utils[_0xb05f('0x19')](util[_0xb05f('0x1b')]('[%s][index][newexten]',_0x3ee130['uniqueid']),_0x3ee130);calls[_0xb05f('0x37')](_0x3ee130);recordings[_0xb05f('0x37')](_0x3ee130);dials[_0xb05f('0x37')](_0x3ee130);}catch(_0x356661){utils[_0xb05f('0x12')](util[_0xb05f('0x1b')](_0xb05f('0x38'),_0x3ee130[_0xb05f('0x1a')]),_0x356661);}});ami['on']('newchannel',function(_0x531c4d){try{utils['debug'](util[_0xb05f('0x1b')](_0xb05f('0x39'),_0x531c4d['uniqueid']),_0x531c4d);calls[_0xb05f('0x3a')](_0x531c4d);recordings['newchannel'](_0x531c4d);}catch(_0x47c032){utils['error'](util[_0xb05f('0x1b')](_0xb05f('0x39'),_0x531c4d['uniqueid']),_0x47c032);}});ami['on'](_0xb05f('0x3b'),function(_0x3623ee){try{utils[_0xb05f('0x19')](util[_0xb05f('0x1b')](_0xb05f('0x3c'),_0x3623ee[_0xb05f('0x1a')]),_0x3623ee);dials[_0xb05f('0x3b')](_0x3623ee);}catch(_0x211178){utils[_0xb05f('0x12')](util[_0xb05f('0x1b')](_0xb05f('0x3d'),_0x3623ee['uniqueid']),_0x211178);}});ami['on']('dialend',function(_0xb09654){try{utils[_0xb05f('0x19')](util['format'](_0xb05f('0x3e'),_0xb09654[_0xb05f('0x1a')]),_0xb09654);dials['dialend'](_0xb09654);}catch(_0x1506ba){utils['error'](util[_0xb05f('0x1b')](_0xb05f('0x3e'),_0xb09654[_0xb05f('0x1a')]),_0x1506ba);}});}