Built motion from commit 753c950e.|2.5.42
[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 _0xe0d8=['uniqueid','[%s][index][agentcalled]','[%s][index][agentringnoanswer]','agentringnoanswer','agentconnect','agentcomplete','[%s][index][agentcomplete]','[%s][index][queuecallerabandon]','queuecallerabandon','queuecallerjoin','[%s][index][queuecallerjoin]','queuecallerleave','[%s][index][queuecallerleave]','musiconholdstart','[%s][index][musiconholdstart]','musiconholdstop','[%s][index][musiconholdstop]','newstate','hangup','[%s][index][hangup]','cdr','[%s][index][cdr]','[%s][index][blindtransfer]','blindtransfer','[%s][index][attendedtransfer]','attendedtransfer','origtransfereruniqueid','varset','[%s][index][varset]','newexten','[%s][index][newexten]','newchannel','[%s][index][newchannel]','dialbegin','[%s][index][dialbegin]','[%s]dialbegin','dialend','[%s][index][dialend]','asterisk-manager','../../config/environment','./utils','util','port','asterisk','username','password','keepConnected','xdr','XDR\x20DISABLED','./agents.controller','./calls.controller','./queues.controller','./recordings.controller','./members.controller','./dials.controller','./transfers.controller','./core.controller','connect','shutdown','fullybooted','error','close','managerevent','debug','format','[%s][index][devicestatechange]','devicestatechange','device','agentcalled'];(function(_0x48628e,_0x393ec1){var _0x185426=function(_0x43369e){while(--_0x43369e){_0x48628e['push'](_0x48628e['shift']());}};_0x185426(++_0x393ec1);}(_0xe0d8,0x13a));var _0x8e0d=function(_0x2f37e0,_0x393ef9){_0x2f37e0=_0x2f37e0-0x0;var _0x43ccce=_0xe0d8[_0x2f37e0];return _0x43ccce;};var AsteriskManager=require(_0x8e0d('0x0'));var config=require(_0x8e0d('0x1'));var utils=require(_0x8e0d('0x2'));var util=require(_0x8e0d('0x3'));var ami=new AsteriskManager(config['asterisk'][_0x8e0d('0x4')],config[_0x8e0d('0x5')]['ip'],config[_0x8e0d('0x5')][_0x8e0d('0x6')],config['asterisk'][_0x8e0d('0x7')],!![]);ami[_0x8e0d('0x8')]();if(config[_0x8e0d('0x9')]&&config[_0x8e0d('0x9')]['disabled']){utils['info'](_0x8e0d('0xa'));}else{var agents=require(_0x8e0d('0xb'));var calls=require(_0x8e0d('0xc'));var queues=require(_0x8e0d('0xd'));var recordings=require(_0x8e0d('0xe'));var members=require(_0x8e0d('0xf'));var dials=require(_0x8e0d('0x10'));var transfers=require(_0x8e0d('0x11'));var core=require(_0x8e0d('0x12'));ami['on'](_0x8e0d('0x13'),core[_0x8e0d('0x13')]);ami['on'](_0x8e0d('0x14'),core['shutdown']);ami['on']('fullybooted',core[_0x8e0d('0x15')]);ami['on']('error',core[_0x8e0d('0x16')]);ami['on'](_0x8e0d('0x17'),core['close']);ami['on'](_0x8e0d('0x18'),core[_0x8e0d('0x18')]);ami['on']('devicestatechange',function(_0x1ab83c){try{utils[_0x8e0d('0x19')](util[_0x8e0d('0x1a')](_0x8e0d('0x1b'),_0x1ab83c['device']),_0x1ab83c);members[_0x8e0d('0x1c')](_0x1ab83c);}catch(_0x2e11eb){utils[_0x8e0d('0x16')](util[_0x8e0d('0x1a')](_0x8e0d('0x1b'),_0x1ab83c[_0x8e0d('0x1d')]),_0x2e11eb);}});ami['on'](_0x8e0d('0x1e'),function(_0x395acd){try{utils['debug'](util[_0x8e0d('0x1a')]('[%s][index][agentcalled]',_0x395acd[_0x8e0d('0x1f')]),_0x395acd);agents['agentcalled'](_0x395acd);}catch(_0x1799f3){utils['error'](util[_0x8e0d('0x1a')](_0x8e0d('0x20'),_0x395acd[_0x8e0d('0x1f')]),_0x1799f3);}});ami['on']('agentringnoanswer',function(_0x8dba84){try{utils[_0x8e0d('0x19')](util[_0x8e0d('0x1a')](_0x8e0d('0x21'),_0x8dba84[_0x8e0d('0x1f')]),_0x8dba84);agents[_0x8e0d('0x22')](_0x8dba84);}catch(_0x312102){utils[_0x8e0d('0x16')](util[_0x8e0d('0x1a')](_0x8e0d('0x21'),_0x8dba84[_0x8e0d('0x1f')]),_0x312102);}});ami['on']('agentconnect',function(_0x3d65fd){try{utils[_0x8e0d('0x19')](util[_0x8e0d('0x1a')]('[%s][index][agentconnect]',_0x3d65fd['uniqueid']),_0x3d65fd);agents[_0x8e0d('0x23')](_0x3d65fd);queues['agentconnect'](_0x3d65fd);}catch(_0x15089d){utils[_0x8e0d('0x16')](util[_0x8e0d('0x1a')]('[%s][index][agentconnect]',_0x3d65fd['uniqueid']),_0x15089d);}});ami['on'](_0x8e0d('0x24'),function(_0x339aed){try{utils['debug'](util[_0x8e0d('0x1a')](_0x8e0d('0x25'),_0x339aed['uniqueid']),_0x339aed);agents[_0x8e0d('0x24')](_0x339aed);queues['agentcomplete'](_0x339aed);members[_0x8e0d('0x24')](_0x339aed);}catch(_0x265af6){utils[_0x8e0d('0x16')](util['format'](_0x8e0d('0x25'),_0x339aed[_0x8e0d('0x1f')]),_0x265af6);}});ami['on']('queuecallerabandon',function(_0x1c4336){try{utils['debug'](util['format'](_0x8e0d('0x26'),_0x1c4336['uniqueid']),_0x1c4336);agents['queuecallerabandon'](_0x1c4336);queues[_0x8e0d('0x27')](_0x1c4336);}catch(_0x1806f8){utils[_0x8e0d('0x16')](util[_0x8e0d('0x1a')](_0x8e0d('0x26'),_0x1c4336[_0x8e0d('0x1f')]),_0x1806f8);}});ami['on'](_0x8e0d('0x28'),function(_0x3e574c){try{utils[_0x8e0d('0x19')](util[_0x8e0d('0x1a')](_0x8e0d('0x29'),_0x3e574c['uniqueid']),_0x3e574c);queues[_0x8e0d('0x28')](_0x3e574c);recordings[_0x8e0d('0x28')](_0x3e574c);}catch(_0x4c60f1){utils[_0x8e0d('0x16')](util['format'](_0x8e0d('0x29'),_0x3e574c['uniqueid']),_0x4c60f1);}});ami['on']('queuecallerleave',function(_0x1ae9ee){try{utils[_0x8e0d('0x19')](util['format']('[%s][index][queuecallerleave]',_0x1ae9ee[_0x8e0d('0x1f')]),_0x1ae9ee);queues[_0x8e0d('0x2a')](_0x1ae9ee);}catch(_0xc746fd){utils[_0x8e0d('0x16')](util['format'](_0x8e0d('0x2b'),_0x1ae9ee[_0x8e0d('0x1f')]),_0xc746fd);}});ami['on'](_0x8e0d('0x2c'),function(_0x35d0ef){try{utils[_0x8e0d('0x19')](util[_0x8e0d('0x1a')]('[%s][index][musiconholdstart]',_0x35d0ef[_0x8e0d('0x1f')]),_0x35d0ef);queues[_0x8e0d('0x2c')](_0x35d0ef);calls[_0x8e0d('0x2c')](_0x35d0ef);}catch(_0x23191d){utils[_0x8e0d('0x16')](util[_0x8e0d('0x1a')](_0x8e0d('0x2d'),_0x35d0ef['uniqueid']),_0x23191d);}});ami['on'](_0x8e0d('0x2e'),function(_0x280ca3){try{utils[_0x8e0d('0x19')](util[_0x8e0d('0x1a')](_0x8e0d('0x2f'),_0x280ca3[_0x8e0d('0x1f')]),_0x280ca3);queues['musiconholdstop'](_0x280ca3);calls[_0x8e0d('0x2e')](_0x280ca3);}catch(_0xaca5f3){utils[_0x8e0d('0x16')](util['format'](_0x8e0d('0x2f'),_0x280ca3[_0x8e0d('0x1f')]),_0xaca5f3);}});ami['on'](_0x8e0d('0x30'),function(_0x4d8cca){try{utils[_0x8e0d('0x19')](util[_0x8e0d('0x1a')]('[%s][index][newstate]',_0x4d8cca[_0x8e0d('0x1f')]),_0x4d8cca);calls[_0x8e0d('0x30')](_0x4d8cca);recordings[_0x8e0d('0x30')](_0x4d8cca);}catch(_0x5988ea){utils['error'](util[_0x8e0d('0x1a')]('[%s][index][newstate]',_0x4d8cca[_0x8e0d('0x1f')]),_0x5988ea);}});ami['on'](_0x8e0d('0x31'),function(_0x38e01d){try{utils[_0x8e0d('0x19')](util['format'](_0x8e0d('0x32'),_0x38e01d[_0x8e0d('0x1f')]),_0x38e01d);calls[_0x8e0d('0x31')](_0x38e01d);recordings[_0x8e0d('0x31')](_0x38e01d);dials[_0x8e0d('0x31')](_0x38e01d);agents['hangup'](_0x38e01d);queues[_0x8e0d('0x31')](_0x38e01d);}catch(_0x4512f9){utils[_0x8e0d('0x16')](util[_0x8e0d('0x1a')](_0x8e0d('0x32'),_0x38e01d[_0x8e0d('0x1f')]),_0x4512f9);}});ami['on'](_0x8e0d('0x33'),function(_0x2f6f13){try{utils[_0x8e0d('0x19')](util[_0x8e0d('0x1a')]('[%s][index][cdr]',_0x2f6f13[_0x8e0d('0x1f')]),_0x2f6f13);members[_0x8e0d('0x33')](_0x2f6f13);}catch(_0x3f1ae5){utils[_0x8e0d('0x16')](util[_0x8e0d('0x1a')](_0x8e0d('0x34'),_0x2f6f13[_0x8e0d('0x1f')]),_0x3f1ae5);}});ami['on']('blindtransfer',function(_0x5e40c0){try{utils[_0x8e0d('0x19')](util['format'](_0x8e0d('0x35'),_0x5e40c0[_0x8e0d('0x1f')]),_0x5e40c0);queues[_0x8e0d('0x36')](_0x5e40c0);agents[_0x8e0d('0x36')](_0x5e40c0);transfers[_0x8e0d('0x36')](_0x5e40c0);recordings[_0x8e0d('0x36')](_0x5e40c0);}catch(_0xb66998){utils['error'](util[_0x8e0d('0x1a')](_0x8e0d('0x35'),_0x5e40c0['uniqueid']),_0xb66998);}});ami['on']('attendedtransfer',function(_0x50d4d4){try{utils[_0x8e0d('0x19')](util[_0x8e0d('0x1a')](_0x8e0d('0x37'),_0x50d4d4['origtransfereruniqueid']),_0x50d4d4);queues['attendedtransfer'](_0x50d4d4);transfers[_0x8e0d('0x38')](_0x50d4d4);agents['attendedtransfer'](_0x50d4d4);calls['attendedtransfer'](_0x50d4d4);}catch(_0x3d60a8){utils['error'](util[_0x8e0d('0x1a')](_0x8e0d('0x37'),_0x50d4d4[_0x8e0d('0x39')]),_0x3d60a8);}});ami['on'](_0x8e0d('0x3a'),function(_0x813b3e){try{utils['debug'](util['format'](_0x8e0d('0x3b'),_0x813b3e['uniqueid']),_0x813b3e);queues['varset'](_0x813b3e);recordings[_0x8e0d('0x3a')](_0x813b3e);calls[_0x8e0d('0x3a')](_0x813b3e);dials[_0x8e0d('0x3a')](_0x813b3e);}catch(_0x54bfb0){utils[_0x8e0d('0x16')](util['format']('[%s][index][varset]',_0x813b3e['uniqueid']),_0x54bfb0);}});ami['on'](_0x8e0d('0x3c'),function(_0x326236){try{utils[_0x8e0d('0x19')](util[_0x8e0d('0x1a')](_0x8e0d('0x3d'),_0x326236[_0x8e0d('0x1f')]),_0x326236);calls['newexten'](_0x326236);recordings[_0x8e0d('0x3c')](_0x326236);dials[_0x8e0d('0x3c')](_0x326236);}catch(_0x413522){utils[_0x8e0d('0x16')](util[_0x8e0d('0x1a')](_0x8e0d('0x3d'),_0x326236['uniqueid']),_0x413522);}});ami['on']('newchannel',function(_0xe69706){try{utils[_0x8e0d('0x19')](util['format']('[%s][index][newchannel]',_0xe69706[_0x8e0d('0x1f')]),_0xe69706);calls['newchannel'](_0xe69706);recordings[_0x8e0d('0x3e')](_0xe69706);}catch(_0xd0ef4b){utils[_0x8e0d('0x16')](util[_0x8e0d('0x1a')](_0x8e0d('0x3f'),_0xe69706[_0x8e0d('0x1f')]),_0xd0ef4b);}});ami['on'](_0x8e0d('0x40'),function(_0x3f6088){try{utils[_0x8e0d('0x19')](util[_0x8e0d('0x1a')](_0x8e0d('0x41'),_0x3f6088[_0x8e0d('0x1f')]),_0x3f6088);dials[_0x8e0d('0x40')](_0x3f6088);}catch(_0x4a0bbc){utils[_0x8e0d('0x16')](util[_0x8e0d('0x1a')](_0x8e0d('0x42'),_0x3f6088[_0x8e0d('0x1f')]),_0x4a0bbc);}});ami['on'](_0x8e0d('0x43'),function(_0x84a1c8){try{utils[_0x8e0d('0x19')](util[_0x8e0d('0x1a')]('[%s][index][dialend]',_0x84a1c8[_0x8e0d('0x1f')]),_0x84a1c8);dials[_0x8e0d('0x43')](_0x84a1c8);}catch(_0x1bf5f9){utils[_0x8e0d('0x16')](util[_0x8e0d('0x1a')](_0x8e0d('0x44'),_0x84a1c8[_0x8e0d('0x1f')]),_0x1bf5f9);}});}