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 _0x0ed1=['origtransfereruniqueid','varset','[%s][index][varset]','newexten','[%s][index][newexten]','[%s][index][newchannel]','newchannel','dialbegin','[%s][index][dialbegin]','[%s]dialbegin','dialend','[%s][index][dialend]','asterisk-manager','util','asterisk','port','username','keepConnected','xdr','disabled','info','./calls.controller','./queues.controller','./recordings.controller','./members.controller','./dials.controller','./transfers.controller','./core.controller','connect','shutdown','error','close','managerevent','devicestatechange','debug','format','device','[%s][index][devicestatechange]','agentcalled','[%s][index][agentcalled]','uniqueid','agentringnoanswer','[%s][index][agentringnoanswer]','agentconnect','agentcomplete','[%s][index][agentcomplete]','queuecallerabandon','[%s][index][queuecallerabandon]','queuecallerjoin','[%s][index][queuecallerjoin]','queuecallerleave','[%s][index][queuecallerleave]','musiconholdstart','[%s][index][musiconholdstart]','[%s][index][musiconholdstop]','newstate','[%s][index][newstate]','hangup','[%s][index][hangup]','[%s][index][cdr]','cdr','blindtransfer','[%s][index][blindtransfer]','attendedtransfer','[%s][index][attendedtransfer]'];(function(_0xfb5fda,_0x44fd68){var _0xbbb700=function(_0x266f8c){while(--_0x266f8c){_0xfb5fda['push'](_0xfb5fda['shift']());}};_0xbbb700(++_0x44fd68);}(_0x0ed1,0x151));var _0x10ed=function(_0x23b147,_0x447c4a){_0x23b147=_0x23b147-0x0;var _0x469fa8=_0x0ed1[_0x23b147];return _0x469fa8;};var AsteriskManager=require(_0x10ed('0x0'));var config=require('../../config/environment');var utils=require('./utils');var util=require(_0x10ed('0x1'));var ami=new AsteriskManager(config[_0x10ed('0x2')][_0x10ed('0x3')],config[_0x10ed('0x2')]['ip'],config['asterisk'][_0x10ed('0x4')],config[_0x10ed('0x2')]['password'],!![]);ami[_0x10ed('0x5')]();if(config['xdr']&&config[_0x10ed('0x6')][_0x10ed('0x7')]){utils[_0x10ed('0x8')]('XDR\x20DISABLED');}else{var agents=require('./agents.controller');var calls=require(_0x10ed('0x9'));var queues=require(_0x10ed('0xa'));var recordings=require(_0x10ed('0xb'));var members=require(_0x10ed('0xc'));var dials=require(_0x10ed('0xd'));var transfers=require(_0x10ed('0xe'));var core=require(_0x10ed('0xf'));ami['on'](_0x10ed('0x10'),core['connect']);ami['on'](_0x10ed('0x11'),core['shutdown']);ami['on']('fullybooted',core['fullybooted']);ami['on'](_0x10ed('0x12'),core[_0x10ed('0x12')]);ami['on'](_0x10ed('0x13'),core[_0x10ed('0x13')]);ami['on'](_0x10ed('0x14'),core[_0x10ed('0x14')]);ami['on'](_0x10ed('0x15'),function(_0x2e2c8a){try{utils[_0x10ed('0x16')](util[_0x10ed('0x17')]('[%s][index][devicestatechange]',_0x2e2c8a[_0x10ed('0x18')]),_0x2e2c8a);members[_0x10ed('0x15')](_0x2e2c8a);}catch(_0x390132){utils[_0x10ed('0x12')](util[_0x10ed('0x17')](_0x10ed('0x19'),_0x2e2c8a[_0x10ed('0x18')]),_0x390132);}});ami['on'](_0x10ed('0x1a'),function(_0x1a359a){try{utils[_0x10ed('0x16')](util[_0x10ed('0x17')](_0x10ed('0x1b'),_0x1a359a[_0x10ed('0x1c')]),_0x1a359a);agents['agentcalled'](_0x1a359a);}catch(_0x1f331b){utils['error'](util['format'](_0x10ed('0x1b'),_0x1a359a[_0x10ed('0x1c')]),_0x1f331b);}});ami['on'](_0x10ed('0x1d'),function(_0x1b99e7){try{utils[_0x10ed('0x16')](util[_0x10ed('0x17')]('[%s][index][agentringnoanswer]',_0x1b99e7[_0x10ed('0x1c')]),_0x1b99e7);agents['agentringnoanswer'](_0x1b99e7);}catch(_0x21e42a){utils[_0x10ed('0x12')](util[_0x10ed('0x17')](_0x10ed('0x1e'),_0x1b99e7['uniqueid']),_0x21e42a);}});ami['on'](_0x10ed('0x1f'),function(_0x21eacb){try{utils[_0x10ed('0x16')](util[_0x10ed('0x17')]('[%s][index][agentconnect]',_0x21eacb[_0x10ed('0x1c')]),_0x21eacb);agents[_0x10ed('0x1f')](_0x21eacb);queues[_0x10ed('0x1f')](_0x21eacb);}catch(_0xd83b9c){utils[_0x10ed('0x12')](util[_0x10ed('0x17')]('[%s][index][agentconnect]',_0x21eacb['uniqueid']),_0xd83b9c);}});ami['on'](_0x10ed('0x20'),function(_0x1059b7){try{utils['debug'](util[_0x10ed('0x17')](_0x10ed('0x21'),_0x1059b7[_0x10ed('0x1c')]),_0x1059b7);agents[_0x10ed('0x20')](_0x1059b7);queues[_0x10ed('0x20')](_0x1059b7);members['agentcomplete'](_0x1059b7);}catch(_0x6fd191){utils[_0x10ed('0x12')](util[_0x10ed('0x17')]('[%s][index][agentcomplete]',_0x1059b7['uniqueid']),_0x6fd191);}});ami['on'](_0x10ed('0x22'),function(_0x4d13c7){try{utils['debug'](util[_0x10ed('0x17')](_0x10ed('0x23'),_0x4d13c7[_0x10ed('0x1c')]),_0x4d13c7);agents[_0x10ed('0x22')](_0x4d13c7);queues['queuecallerabandon'](_0x4d13c7);}catch(_0x519314){utils[_0x10ed('0x12')](util[_0x10ed('0x17')](_0x10ed('0x23'),_0x4d13c7[_0x10ed('0x1c')]),_0x519314);}});ami['on'](_0x10ed('0x24'),function(_0x261031){try{utils[_0x10ed('0x16')](util[_0x10ed('0x17')](_0x10ed('0x25'),_0x261031[_0x10ed('0x1c')]),_0x261031);queues['queuecallerjoin'](_0x261031);recordings[_0x10ed('0x24')](_0x261031);}catch(_0x2cb25e){utils[_0x10ed('0x12')](util[_0x10ed('0x17')](_0x10ed('0x25'),_0x261031[_0x10ed('0x1c')]),_0x2cb25e);}});ami['on'](_0x10ed('0x26'),function(_0x23fd18){try{utils[_0x10ed('0x16')](util[_0x10ed('0x17')](_0x10ed('0x27'),_0x23fd18[_0x10ed('0x1c')]),_0x23fd18);queues[_0x10ed('0x26')](_0x23fd18);}catch(_0x21e206){utils['error'](util[_0x10ed('0x17')](_0x10ed('0x27'),_0x23fd18[_0x10ed('0x1c')]),_0x21e206);}});ami['on'](_0x10ed('0x28'),function(_0x22f8b8){try{utils[_0x10ed('0x16')](util[_0x10ed('0x17')](_0x10ed('0x29'),_0x22f8b8[_0x10ed('0x1c')]),_0x22f8b8);queues['musiconholdstart'](_0x22f8b8);calls[_0x10ed('0x28')](_0x22f8b8);}catch(_0x3496f0){utils[_0x10ed('0x12')](util['format'](_0x10ed('0x29'),_0x22f8b8[_0x10ed('0x1c')]),_0x3496f0);}});ami['on']('musiconholdstop',function(_0x3fe7e6){try{utils[_0x10ed('0x16')](util[_0x10ed('0x17')]('[%s][index][musiconholdstop]',_0x3fe7e6[_0x10ed('0x1c')]),_0x3fe7e6);queues['musiconholdstop'](_0x3fe7e6);calls['musiconholdstop'](_0x3fe7e6);}catch(_0x4f4861){utils['error'](util[_0x10ed('0x17')](_0x10ed('0x2a'),_0x3fe7e6[_0x10ed('0x1c')]),_0x4f4861);}});ami['on'](_0x10ed('0x2b'),function(_0x5c53ae){try{utils['debug'](util[_0x10ed('0x17')](_0x10ed('0x2c'),_0x5c53ae[_0x10ed('0x1c')]),_0x5c53ae);calls['newstate'](_0x5c53ae);recordings[_0x10ed('0x2b')](_0x5c53ae);}catch(_0x5d94a0){utils[_0x10ed('0x12')](util['format'](_0x10ed('0x2c'),_0x5c53ae[_0x10ed('0x1c')]),_0x5d94a0);}});ami['on']('hangup',function(_0x4cbbdf){try{utils[_0x10ed('0x16')](util['format']('[%s][index][hangup]',_0x4cbbdf[_0x10ed('0x1c')]),_0x4cbbdf);calls[_0x10ed('0x2d')](_0x4cbbdf);recordings[_0x10ed('0x2d')](_0x4cbbdf);dials[_0x10ed('0x2d')](_0x4cbbdf);agents[_0x10ed('0x2d')](_0x4cbbdf);queues['hangup'](_0x4cbbdf);}catch(_0x6b844e){utils[_0x10ed('0x12')](util['format'](_0x10ed('0x2e'),_0x4cbbdf['uniqueid']),_0x6b844e);}});ami['on']('cdr',function(_0x58ea40){try{utils[_0x10ed('0x16')](util['format'](_0x10ed('0x2f'),_0x58ea40[_0x10ed('0x1c')]),_0x58ea40);members[_0x10ed('0x30')](_0x58ea40);}catch(_0x5ea738){utils[_0x10ed('0x12')](util['format'](_0x10ed('0x2f'),_0x58ea40[_0x10ed('0x1c')]),_0x5ea738);}});ami['on'](_0x10ed('0x31'),function(_0x16182f){try{utils[_0x10ed('0x16')](util['format']('[%s][index][blindtransfer]',_0x16182f[_0x10ed('0x1c')]),_0x16182f);queues['blindtransfer'](_0x16182f);agents['blindtransfer'](_0x16182f);transfers[_0x10ed('0x31')](_0x16182f);}catch(_0x4def7f){utils['error'](util[_0x10ed('0x17')](_0x10ed('0x32'),_0x16182f[_0x10ed('0x1c')]),_0x4def7f);}});ami['on'](_0x10ed('0x33'),function(_0x3c8999){try{utils[_0x10ed('0x16')](util[_0x10ed('0x17')](_0x10ed('0x34'),_0x3c8999[_0x10ed('0x35')]),_0x3c8999);queues[_0x10ed('0x33')](_0x3c8999);transfers[_0x10ed('0x33')](_0x3c8999);agents[_0x10ed('0x33')](_0x3c8999);calls['attendedtransfer'](_0x3c8999);}catch(_0xfceef4){utils['error'](util[_0x10ed('0x17')](_0x10ed('0x34'),_0x3c8999[_0x10ed('0x35')]),_0xfceef4);}});ami['on'](_0x10ed('0x36'),function(_0x4d3578){try{utils['debug'](util[_0x10ed('0x17')](_0x10ed('0x37'),_0x4d3578[_0x10ed('0x1c')]),_0x4d3578);queues[_0x10ed('0x36')](_0x4d3578);recordings[_0x10ed('0x36')](_0x4d3578);calls[_0x10ed('0x36')](_0x4d3578);dials[_0x10ed('0x36')](_0x4d3578);}catch(_0x486afd){utils[_0x10ed('0x12')](util['format'](_0x10ed('0x37'),_0x4d3578[_0x10ed('0x1c')]),_0x486afd);}});ami['on'](_0x10ed('0x38'),function(_0xa6f2ef){try{utils[_0x10ed('0x16')](util[_0x10ed('0x17')]('[%s][index][newexten]',_0xa6f2ef['uniqueid']),_0xa6f2ef);calls[_0x10ed('0x38')](_0xa6f2ef);recordings[_0x10ed('0x38')](_0xa6f2ef);dials[_0x10ed('0x38')](_0xa6f2ef);}catch(_0x4ecc57){utils[_0x10ed('0x12')](util[_0x10ed('0x17')](_0x10ed('0x39'),_0xa6f2ef[_0x10ed('0x1c')]),_0x4ecc57);}});ami['on']('newchannel',function(_0x4cda63){try{utils['debug'](util[_0x10ed('0x17')](_0x10ed('0x3a'),_0x4cda63['uniqueid']),_0x4cda63);calls['newchannel'](_0x4cda63);recordings[_0x10ed('0x3b')](_0x4cda63);}catch(_0x13e160){utils['error'](util[_0x10ed('0x17')](_0x10ed('0x3a'),_0x4cda63[_0x10ed('0x1c')]),_0x13e160);}});ami['on'](_0x10ed('0x3c'),function(_0x2c7341){try{utils[_0x10ed('0x16')](util[_0x10ed('0x17')](_0x10ed('0x3d'),_0x2c7341[_0x10ed('0x1c')]),_0x2c7341);dials[_0x10ed('0x3c')](_0x2c7341);}catch(_0x2122b8){utils[_0x10ed('0x12')](util['format'](_0x10ed('0x3e'),_0x2c7341[_0x10ed('0x1c')]),_0x2122b8);}});ami['on']('dialend',function(_0x50ee62){try{utils[_0x10ed('0x16')](util[_0x10ed('0x17')]('[%s][index][dialend]',_0x50ee62[_0x10ed('0x1c')]),_0x50ee62);dials[_0x10ed('0x3f')](_0x50ee62);}catch(_0x5ab1ba){utils[_0x10ed('0x12')](util[_0x10ed('0x17')](_0x10ed('0x40'),_0x50ee62[_0x10ed('0x1c')]),_0x5ab1ba);}});}