48d5ab1d658f8d020a27593075a0b03d2a5034a0
[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 _0x02f9=['device','agentcalled','uniqueid','[%s][index][agentcalled]','[%s][index][agentringnoanswer]','[%s][index][agentconnect]','agentconnect','agentcomplete','[%s][index][agentcomplete]','queuecallerabandon','[%s][index][queuecallerabandon]','queuecallerjoin','[%s][index][queuecallerjoin]','queuecallerleave','musiconholdstart','musiconholdstop','[%s][index][musiconholdstop]','newstate','[%s][index][newstate]','[%s][index][hangup]','hangup','cdr','[%s][index][cdr]','[%s][index][blindtransfer]','blindtransfer','attendedtransfer','[%s][index][attendedtransfer]','origtransfereruniqueid','varset','[%s][index][varset]','newexten','[%s][index][newexten]','newchannel','[%s][index][newchannel]','dialend','[%s][index][dialend]','asterisk-manager','../../config/environment','util','asterisk','port','username','keepConnected','xdr','disabled','XDR\x20DISABLED','./calls.controller','./queues.controller','./members.controller','./dials.controller','./transfers.controller','./core.controller','connect','shutdown','fullybooted','error','close','managerevent','devicestatechange','debug','format','[%s][index][devicestatechange]'];(function(_0x5e7c90,_0x3d72b3){var _0x4e4b8d=function(_0x3a5b62){while(--_0x3a5b62){_0x5e7c90['push'](_0x5e7c90['shift']());}};_0x4e4b8d(++_0x3d72b3);}(_0x02f9,0x11c));var _0x902f=function(_0x209648,_0x19de09){_0x209648=_0x209648-0x0;var _0x20f9c8=_0x02f9[_0x209648];return _0x20f9c8;};var AsteriskManager=require(_0x902f('0x0'));var config=require(_0x902f('0x1'));var utils=require('./utils');var util=require(_0x902f('0x2'));var ami=new AsteriskManager(config[_0x902f('0x3')][_0x902f('0x4')],config['asterisk']['ip'],config[_0x902f('0x3')][_0x902f('0x5')],config[_0x902f('0x3')]['password'],!![]);ami[_0x902f('0x6')]();if(config['xdr']&&config[_0x902f('0x7')][_0x902f('0x8')]){utils['info'](_0x902f('0x9'));}else{var agents=require('./agents.controller');var calls=require(_0x902f('0xa'));var queues=require(_0x902f('0xb'));var recordings=require('./recordings.controller');var members=require(_0x902f('0xc'));var dials=require(_0x902f('0xd'));var transfers=require(_0x902f('0xe'));var core=require(_0x902f('0xf'));ami['on'](_0x902f('0x10'),core[_0x902f('0x10')]);ami['on'](_0x902f('0x11'),core[_0x902f('0x11')]);ami['on']('fullybooted',core[_0x902f('0x12')]);ami['on'](_0x902f('0x13'),core[_0x902f('0x13')]);ami['on'](_0x902f('0x14'),core['close']);ami['on'](_0x902f('0x15'),core[_0x902f('0x15')]);ami['on'](_0x902f('0x16'),function(_0x12bc29){try{utils[_0x902f('0x17')](util[_0x902f('0x18')](_0x902f('0x19'),_0x12bc29['device']),_0x12bc29);members['devicestatechange'](_0x12bc29);}catch(_0x4bfb6e){utils['error'](util[_0x902f('0x18')]('[%s][index][devicestatechange]',_0x12bc29[_0x902f('0x1a')]),_0x4bfb6e);}});ami['on'](_0x902f('0x1b'),function(_0x57d25c){try{utils[_0x902f('0x17')](util[_0x902f('0x18')]('[%s][index][agentcalled]',_0x57d25c[_0x902f('0x1c')]),_0x57d25c);agents[_0x902f('0x1b')](_0x57d25c);}catch(_0x4ee31f){utils[_0x902f('0x13')](util[_0x902f('0x18')](_0x902f('0x1d'),_0x57d25c['uniqueid']),_0x4ee31f);}});ami['on']('agentringnoanswer',function(_0x1f5d9f){try{utils[_0x902f('0x17')](util[_0x902f('0x18')](_0x902f('0x1e'),_0x1f5d9f[_0x902f('0x1c')]),_0x1f5d9f);agents['agentringnoanswer'](_0x1f5d9f);}catch(_0x207beb){utils[_0x902f('0x13')](util['format']('[%s][index][agentringnoanswer]',_0x1f5d9f[_0x902f('0x1c')]),_0x207beb);}});ami['on']('agentconnect',function(_0x452665){try{utils['debug'](util[_0x902f('0x18')](_0x902f('0x1f'),_0x452665[_0x902f('0x1c')]),_0x452665);agents[_0x902f('0x20')](_0x452665);queues[_0x902f('0x20')](_0x452665);}catch(_0x97a8ab){utils[_0x902f('0x13')](util[_0x902f('0x18')](_0x902f('0x1f'),_0x452665['uniqueid']),_0x97a8ab);}});ami['on'](_0x902f('0x21'),function(_0x16e508){try{utils[_0x902f('0x17')](util[_0x902f('0x18')](_0x902f('0x22'),_0x16e508[_0x902f('0x1c')]),_0x16e508);agents[_0x902f('0x21')](_0x16e508);queues[_0x902f('0x21')](_0x16e508);members[_0x902f('0x21')](_0x16e508);}catch(_0x31084c){utils[_0x902f('0x13')](util[_0x902f('0x18')](_0x902f('0x22'),_0x16e508['uniqueid']),_0x31084c);}});ami['on'](_0x902f('0x23'),function(_0x351e93){try{utils['debug'](util[_0x902f('0x18')](_0x902f('0x24'),_0x351e93[_0x902f('0x1c')]),_0x351e93);agents[_0x902f('0x23')](_0x351e93);queues[_0x902f('0x23')](_0x351e93);}catch(_0x5ec28b){utils[_0x902f('0x13')](util['format'](_0x902f('0x24'),_0x351e93[_0x902f('0x1c')]),_0x5ec28b);}});ami['on'](_0x902f('0x25'),function(_0x46a4b8){try{utils[_0x902f('0x17')](util[_0x902f('0x18')](_0x902f('0x26'),_0x46a4b8[_0x902f('0x1c')]),_0x46a4b8);queues[_0x902f('0x25')](_0x46a4b8);recordings[_0x902f('0x25')](_0x46a4b8);}catch(_0x2962cc){utils[_0x902f('0x13')](util[_0x902f('0x18')](_0x902f('0x26'),_0x46a4b8[_0x902f('0x1c')]),_0x2962cc);}});ami['on'](_0x902f('0x27'),function(_0x23c9ec){try{utils[_0x902f('0x17')](util['format']('[%s][index][queuecallerleave]',_0x23c9ec[_0x902f('0x1c')]),_0x23c9ec);queues[_0x902f('0x27')](_0x23c9ec);}catch(_0x159e52){utils[_0x902f('0x13')](util['format']('[%s][index][queuecallerleave]',_0x23c9ec[_0x902f('0x1c')]),_0x159e52);}});ami['on'](_0x902f('0x28'),function(_0x4ff9cb){try{utils[_0x902f('0x17')](util['format']('[%s][index][musiconholdstart]',_0x4ff9cb['uniqueid']),_0x4ff9cb);queues[_0x902f('0x28')](_0x4ff9cb);calls[_0x902f('0x28')](_0x4ff9cb);}catch(_0x586da8){utils[_0x902f('0x13')](util[_0x902f('0x18')]('[%s][index][musiconholdstart]',_0x4ff9cb['uniqueid']),_0x586da8);}});ami['on'](_0x902f('0x29'),function(_0x3573e6){try{utils['debug'](util[_0x902f('0x18')](_0x902f('0x2a'),_0x3573e6[_0x902f('0x1c')]),_0x3573e6);queues[_0x902f('0x29')](_0x3573e6);calls[_0x902f('0x29')](_0x3573e6);}catch(_0x344153){utils[_0x902f('0x13')](util[_0x902f('0x18')](_0x902f('0x2a'),_0x3573e6[_0x902f('0x1c')]),_0x344153);}});ami['on'](_0x902f('0x2b'),function(_0x3af43e){try{utils[_0x902f('0x17')](util[_0x902f('0x18')]('[%s][index][newstate]',_0x3af43e['uniqueid']),_0x3af43e);calls[_0x902f('0x2b')](_0x3af43e);recordings[_0x902f('0x2b')](_0x3af43e);}catch(_0x46e47e){utils[_0x902f('0x13')](util[_0x902f('0x18')](_0x902f('0x2c'),_0x3af43e[_0x902f('0x1c')]),_0x46e47e);}});ami['on']('hangup',function(_0x57c73e){try{utils[_0x902f('0x17')](util[_0x902f('0x18')](_0x902f('0x2d'),_0x57c73e[_0x902f('0x1c')]),_0x57c73e);calls[_0x902f('0x2e')](_0x57c73e);recordings[_0x902f('0x2e')](_0x57c73e);dials[_0x902f('0x2e')](_0x57c73e);agents[_0x902f('0x2e')](_0x57c73e);queues[_0x902f('0x2e')](_0x57c73e);}catch(_0x4f640e){utils[_0x902f('0x13')](util[_0x902f('0x18')](_0x902f('0x2d'),_0x57c73e[_0x902f('0x1c')]),_0x4f640e);}});ami['on'](_0x902f('0x2f'),function(_0x428c82){try{utils['debug'](util[_0x902f('0x18')](_0x902f('0x30'),_0x428c82[_0x902f('0x1c')]),_0x428c82);members['cdr'](_0x428c82);}catch(_0x2c66b2){utils['error'](util['format'](_0x902f('0x30'),_0x428c82[_0x902f('0x1c')]),_0x2c66b2);}});ami['on']('blindtransfer',function(_0x1f8674){try{utils[_0x902f('0x17')](util[_0x902f('0x18')](_0x902f('0x31'),_0x1f8674[_0x902f('0x1c')]),_0x1f8674);queues['blindtransfer'](_0x1f8674);agents[_0x902f('0x32')](_0x1f8674);transfers[_0x902f('0x32')](_0x1f8674);}catch(_0x1a993d){utils[_0x902f('0x13')](util[_0x902f('0x18')](_0x902f('0x31'),_0x1f8674[_0x902f('0x1c')]),_0x1a993d);}});ami['on'](_0x902f('0x33'),function(_0x5b5262){try{utils['debug'](util[_0x902f('0x18')](_0x902f('0x34'),_0x5b5262[_0x902f('0x35')]),_0x5b5262);queues[_0x902f('0x33')](_0x5b5262);transfers['attendedtransfer'](_0x5b5262);agents[_0x902f('0x33')](_0x5b5262);calls[_0x902f('0x33')](_0x5b5262);}catch(_0x5bd1e9){utils[_0x902f('0x13')](util[_0x902f('0x18')](_0x902f('0x34'),_0x5b5262[_0x902f('0x35')]),_0x5bd1e9);}});ami['on'](_0x902f('0x36'),function(_0x50f930){try{utils['debug'](util['format'](_0x902f('0x37'),_0x50f930[_0x902f('0x1c')]),_0x50f930);queues[_0x902f('0x36')](_0x50f930);recordings[_0x902f('0x36')](_0x50f930);calls[_0x902f('0x36')](_0x50f930);dials[_0x902f('0x36')](_0x50f930);}catch(_0x5402a2){utils[_0x902f('0x13')](util[_0x902f('0x18')](_0x902f('0x37'),_0x50f930[_0x902f('0x1c')]),_0x5402a2);}});ami['on'](_0x902f('0x38'),function(_0x197eb4){try{utils['debug'](util[_0x902f('0x18')](_0x902f('0x39'),_0x197eb4[_0x902f('0x1c')]),_0x197eb4);calls[_0x902f('0x38')](_0x197eb4);recordings['newexten'](_0x197eb4);dials['newexten'](_0x197eb4);}catch(_0x4c81e0){utils['error'](util[_0x902f('0x18')]('[%s][index][newexten]',_0x197eb4[_0x902f('0x1c')]),_0x4c81e0);}});ami['on'](_0x902f('0x3a'),function(_0x3b5b6a){try{utils[_0x902f('0x17')](util['format'](_0x902f('0x3b'),_0x3b5b6a[_0x902f('0x1c')]),_0x3b5b6a);calls['newchannel'](_0x3b5b6a);recordings['newchannel'](_0x3b5b6a);}catch(_0x1d7475){utils[_0x902f('0x13')](util[_0x902f('0x18')](_0x902f('0x3b'),_0x3b5b6a[_0x902f('0x1c')]),_0x1d7475);}});ami['on']('dialbegin',function(_0x342157){try{utils[_0x902f('0x17')](util[_0x902f('0x18')]('[%s][index][dialbegin]',_0x342157['uniqueid']),_0x342157);dials['dialbegin'](_0x342157);}catch(_0x20e815){utils[_0x902f('0x13')](util[_0x902f('0x18')]('[%s]dialbegin',_0x342157[_0x902f('0x1c')]),_0x20e815);}});ami['on'](_0x902f('0x3c'),function(_0x2eafae){try{utils[_0x902f('0x17')](util[_0x902f('0x18')]('[%s][index][dialend]',_0x2eafae['uniqueid']),_0x2eafae);dials[_0x902f('0x3c')](_0x2eafae);}catch(_0x49f4c8){utils[_0x902f('0x13')](util[_0x902f('0x18')](_0x902f('0x3d'),_0x2eafae[_0x902f('0x1c')]),_0x49f4c8);}});}