fd8b4caa00a5b0f156d74bb9103a3764ee9c0886
[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 _0x4f6a=['queuecallerjoin','queuecallerleave','musiconholdstart','musiconholdstop','newstate','hangup','blindtransfer','attendedtransfer','varset','newexten','newchannel','dialbegin','dialend','asterisk-manager','../../config/environment','asterisk','port','username','password','keepConnected','xdr','info','XDR\x20DISABLED','./agents.controller','./recordings.controller','./members.controller','./dials.controller','./transfers.controller','./core.controller','connect','shutdown','fullybooted','close','managerevent','devicestatechange','error','agentcalled','agentringnoanswer','agentconnect','agentcomplete','queuecallerabandon'];(function(_0x21c5bf,_0x305328){var _0x1f66cf=function(_0x26081a){while(--_0x26081a){_0x21c5bf['push'](_0x21c5bf['shift']());}};_0x1f66cf(++_0x305328);}(_0x4f6a,0xda));var _0xa4f6=function(_0x3cca3e,_0x950fc5){_0x3cca3e=_0x3cca3e-0x0;var _0x382338=_0x4f6a[_0x3cca3e];return _0x382338;};var AsteriskManager=require(_0xa4f6('0x0'));var config=require(_0xa4f6('0x1'));var utils=require('./utils');var ami=new AsteriskManager(config[_0xa4f6('0x2')][_0xa4f6('0x3')],config['asterisk']['ip'],config[_0xa4f6('0x2')][_0xa4f6('0x4')],config['asterisk'][_0xa4f6('0x5')],!![]);ami[_0xa4f6('0x6')]();if(config[_0xa4f6('0x7')]&&config['xdr']['disabled']){utils[_0xa4f6('0x8')](_0xa4f6('0x9'));}else{var agents=require(_0xa4f6('0xa'));var calls=require('./calls.controller');var queues=require('./queues.controller');var recordings=require(_0xa4f6('0xb'));var members=require(_0xa4f6('0xc'));var dials=require(_0xa4f6('0xd'));var transfers=require(_0xa4f6('0xe'));var core=require(_0xa4f6('0xf'));ami['on'](_0xa4f6('0x10'),core[_0xa4f6('0x10')]);ami['on'](_0xa4f6('0x11'),core[_0xa4f6('0x11')]);ami['on'](_0xa4f6('0x12'),core[_0xa4f6('0x12')]);ami['on']('error',core['error']);ami['on'](_0xa4f6('0x13'),core['close']);ami['on']('managerevent',core[_0xa4f6('0x14')]);ami['on'](_0xa4f6('0x15'),function(_0x4c9a85){try{members[_0xa4f6('0x15')](_0x4c9a85);}catch(_0x21dc31){utils[_0xa4f6('0x16')](_0x21dc31);}});ami['on']('agentcalled',function(_0x5c282a){try{agents[_0xa4f6('0x17')](_0x5c282a);}catch(_0x4cfa50){utils['error'](_0x4cfa50);}});ami['on'](_0xa4f6('0x18'),function(_0x11911a){try{agents[_0xa4f6('0x18')](_0x11911a);}catch(_0x324ec1){utils['error'](_0x324ec1);}});ami['on'](_0xa4f6('0x19'),function(_0x3fb8ac){try{agents[_0xa4f6('0x19')](_0x3fb8ac);queues['agentconnect'](_0x3fb8ac);}catch(_0x2143f3){utils[_0xa4f6('0x16')](_0x2143f3);}});ami['on'](_0xa4f6('0x1a'),function(_0x261b10){try{agents[_0xa4f6('0x1a')](_0x261b10);queues[_0xa4f6('0x1a')](_0x261b10);members[_0xa4f6('0x1a')](_0x261b10);}catch(_0x58b366){utils['error'](_0x58b366);}});ami['on']('queuecallerabandon',function(_0x460ffd){try{agents[_0xa4f6('0x1b')](_0x460ffd);queues['queuecallerabandon'](_0x460ffd);}catch(_0x27b77f){utils['error'](_0x27b77f);}});ami['on'](_0xa4f6('0x1c'),function(_0x32e304){try{queues[_0xa4f6('0x1c')](_0x32e304);recordings[_0xa4f6('0x1c')](_0x32e304);}catch(_0x4faf40){utils[_0xa4f6('0x16')](_0x4faf40);}});ami['on'](_0xa4f6('0x1d'),function(_0x4a3095){try{queues[_0xa4f6('0x1d')](_0x4a3095);}catch(_0x5929d6){utils['error'](_0x5929d6);}});ami['on']('musiconholdstart',function(_0x3488ff){try{queues['musiconholdstart'](_0x3488ff);calls[_0xa4f6('0x1e')](_0x3488ff);}catch(_0x8289f1){utils[_0xa4f6('0x16')](_0x8289f1);}});ami['on'](_0xa4f6('0x1f'),function(_0x44901e){try{queues['musiconholdstop'](_0x44901e);calls[_0xa4f6('0x1f')](_0x44901e);}catch(_0xc47931){utils[_0xa4f6('0x16')](_0xc47931);}});ami['on'](_0xa4f6('0x20'),function(_0x4cd505){try{calls['newstate'](_0x4cd505);recordings[_0xa4f6('0x20')](_0x4cd505);}catch(_0x127001){utils[_0xa4f6('0x16')](_0x127001);}});ami['on']('hangup',function(_0x1571b0){try{calls[_0xa4f6('0x21')](_0x1571b0);recordings['hangup'](_0x1571b0);dials[_0xa4f6('0x21')](_0x1571b0);agents['hangup'](_0x1571b0);queues[_0xa4f6('0x21')](_0x1571b0);}catch(_0x3f60ea){utils[_0xa4f6('0x16')](_0x3f60ea);}});ami['on']('cdr',function(_0x3de992){try{members['cdr'](_0x3de992);}catch(_0x26abc4){utils[_0xa4f6('0x16')](_0x26abc4);}});ami['on'](_0xa4f6('0x22'),function(_0x3798e8){try{queues[_0xa4f6('0x22')](_0x3798e8);agents[_0xa4f6('0x22')](_0x3798e8);transfers[_0xa4f6('0x22')](_0x3798e8);}catch(_0x486a46){utils[_0xa4f6('0x16')](_0x486a46);}});ami['on']('attendedtransfer',function(_0x11cbc8){try{queues['attendedtransfer'](_0x11cbc8);transfers[_0xa4f6('0x23')](_0x11cbc8);agents[_0xa4f6('0x23')](_0x11cbc8);calls[_0xa4f6('0x23')](_0x11cbc8);}catch(_0x2956c3){utils[_0xa4f6('0x16')](_0x2956c3);}});ami['on'](_0xa4f6('0x24'),function(_0x100201){try{queues[_0xa4f6('0x24')](_0x100201);recordings[_0xa4f6('0x24')](_0x100201);calls[_0xa4f6('0x24')](_0x100201);dials[_0xa4f6('0x24')](_0x100201);}catch(_0x5163b8){utils['error'](_0x5163b8);}});ami['on'](_0xa4f6('0x25'),function(_0xcf2c18){try{calls[_0xa4f6('0x25')](_0xcf2c18);recordings[_0xa4f6('0x25')](_0xcf2c18);dials[_0xa4f6('0x25')](_0xcf2c18);}catch(_0x552fd2){utils['error'](_0x552fd2);}});ami['on'](_0xa4f6('0x26'),function(_0x2374e1){try{calls[_0xa4f6('0x26')](_0x2374e1);recordings[_0xa4f6('0x26')](_0x2374e1);}catch(_0x1b60ff){utils[_0xa4f6('0x16')](_0x1b60ff);}});ami['on'](_0xa4f6('0x27'),function(_0x1b745f){try{dials['dialbegin'](_0x1b745f);}catch(_0x5ca534){utils[_0xa4f6('0x16')](_0x5ca534);}});ami['on'](_0xa4f6('0x28'),function(_0xa663d8){try{dials['dialend'](_0xa663d8);}catch(_0x5c38b8){utils[_0xa4f6('0x16')](_0x5c38b8);}});}