9cf41b755efa16e58a9c4733b56b6dc5b2be0935
[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 _0x6086=['./agents.controller','./calls.controller','./queues.controller','./recordings.controller','./members.controller','./core.controller','connect','shutdown','fullybooted','error','managerevent','agentcalled','agentringnoanswer','agentconnect','agentcomplete','queuecallerabandon','queuecallerjoin','queuecallerleave','musiconholdstart','musiconholdstop','newstate','hangup','cdr','blindtransfer','attendedtransfer','varset','newexten','newchannel','dialbegin','dialend','asterisk-manager','./utils','asterisk','port','password','keepConnected','xdr','disabled'];(function(_0xcfb5d9,_0x37f2e6){var _0x115c2e=function(_0x54d738){while(--_0x54d738){_0xcfb5d9['push'](_0xcfb5d9['shift']());}};_0x115c2e(++_0x37f2e6);}(_0x6086,0x6a));var _0x6608=function(_0x590181,_0x411899){_0x590181=_0x590181-0x0;var _0x53a339=_0x6086[_0x590181];return _0x53a339;};var AsteriskManager=require(_0x6608('0x0'));var config=require('../../config/environment');var utils=require(_0x6608('0x1'));var ami=new AsteriskManager(config[_0x6608('0x2')][_0x6608('0x3')],config[_0x6608('0x2')]['ip'],config[_0x6608('0x2')]['username'],config['asterisk'][_0x6608('0x4')],!![]);ami[_0x6608('0x5')]();if(config[_0x6608('0x6')]&&config[_0x6608('0x6')][_0x6608('0x7')]){utils['info']('XDR\x20DISABLED');}else{var agents=require(_0x6608('0x8'));var calls=require(_0x6608('0x9'));var queues=require(_0x6608('0xa'));var recordings=require(_0x6608('0xb'));var members=require(_0x6608('0xc'));var dials=require('./dials.controller');var transfers=require('./transfers.controller');var core=require(_0x6608('0xd'));ami['on'](_0x6608('0xe'),core['connect']);ami['on'](_0x6608('0xf'),core[_0x6608('0xf')]);ami['on'](_0x6608('0x10'),core[_0x6608('0x10')]);ami['on'](_0x6608('0x11'),core['error']);ami['on']('close',core['close']);ami['on'](_0x6608('0x12'),core['managerevent']);ami['on']('devicestatechange',function(_0x537b47){try{members['devicestatechange'](_0x537b47);}catch(_0xd4fd59){utils['error'](_0xd4fd59);}});ami['on'](_0x6608('0x13'),function(_0x506b4b){try{agents[_0x6608('0x13')](_0x506b4b);}catch(_0x2d76bc){utils['error'](_0x2d76bc);}});ami['on'](_0x6608('0x14'),function(_0xb4265){try{agents[_0x6608('0x14')](_0xb4265);}catch(_0x3266c4){utils[_0x6608('0x11')](_0x3266c4);}});ami['on'](_0x6608('0x15'),function(_0xe1cef3){try{agents[_0x6608('0x15')](_0xe1cef3);queues[_0x6608('0x15')](_0xe1cef3);}catch(_0x15c6a1){utils[_0x6608('0x11')](_0x15c6a1);}});ami['on'](_0x6608('0x16'),function(_0x3f36db){try{agents[_0x6608('0x16')](_0x3f36db);queues[_0x6608('0x16')](_0x3f36db);members[_0x6608('0x16')](_0x3f36db);}catch(_0xcc462a){utils['error'](_0xcc462a);}});ami['on']('queuecallerabandon',function(_0x40447b){try{agents[_0x6608('0x17')](_0x40447b);queues[_0x6608('0x17')](_0x40447b);}catch(_0x5beefe){utils[_0x6608('0x11')](_0x5beefe);}});ami['on'](_0x6608('0x18'),function(_0x5f481d){try{queues[_0x6608('0x18')](_0x5f481d);recordings[_0x6608('0x18')](_0x5f481d);}catch(_0x410d75){utils[_0x6608('0x11')](_0x410d75);}});ami['on']('queuecallerleave',function(_0x4070c8){try{queues[_0x6608('0x19')](_0x4070c8);}catch(_0x4a3d4f){utils[_0x6608('0x11')](_0x4a3d4f);}});ami['on']('musiconholdstart',function(_0x50d40c){try{queues['musiconholdstart'](_0x50d40c);calls[_0x6608('0x1a')](_0x50d40c);}catch(_0x3591d9){utils[_0x6608('0x11')](_0x3591d9);}});ami['on'](_0x6608('0x1b'),function(_0x13a58f){try{queues['musiconholdstop'](_0x13a58f);calls[_0x6608('0x1b')](_0x13a58f);}catch(_0x3e0a1d){utils[_0x6608('0x11')](_0x3e0a1d);}});ami['on'](_0x6608('0x1c'),function(_0x18f6de){try{calls[_0x6608('0x1c')](_0x18f6de);recordings[_0x6608('0x1c')](_0x18f6de);}catch(_0x175787){utils[_0x6608('0x11')](_0x175787);}});ami['on'](_0x6608('0x1d'),function(_0x468d76){try{calls['hangup'](_0x468d76);recordings[_0x6608('0x1d')](_0x468d76);dials[_0x6608('0x1d')](_0x468d76);agents[_0x6608('0x1d')](_0x468d76);queues['hangup'](_0x468d76);}catch(_0x1a147b){utils[_0x6608('0x11')](_0x1a147b);}});ami['on']('cdr',function(_0x4ef4f8){try{members[_0x6608('0x1e')](_0x4ef4f8);}catch(_0x4579c1){utils[_0x6608('0x11')](_0x4579c1);}});ami['on'](_0x6608('0x1f'),function(_0xac871a){try{queues[_0x6608('0x1f')](_0xac871a);agents['blindtransfer'](_0xac871a);transfers[_0x6608('0x1f')](_0xac871a);}catch(_0x1817ac){utils['error'](_0x1817ac);}});ami['on'](_0x6608('0x20'),function(_0xe37b82){try{queues[_0x6608('0x20')](_0xe37b82);transfers[_0x6608('0x20')](_0xe37b82);agents[_0x6608('0x20')](_0xe37b82);calls[_0x6608('0x20')](_0xe37b82);}catch(_0x5ce13a){utils[_0x6608('0x11')](_0x5ce13a);}});ami['on'](_0x6608('0x21'),function(_0x377067){try{queues['varset'](_0x377067);recordings[_0x6608('0x21')](_0x377067);calls[_0x6608('0x21')](_0x377067);dials[_0x6608('0x21')](_0x377067);}catch(_0x44c605){utils[_0x6608('0x11')](_0x44c605);}});ami['on']('newexten',function(_0x478ffc){try{calls['newexten'](_0x478ffc);recordings[_0x6608('0x22')](_0x478ffc);dials[_0x6608('0x22')](_0x478ffc);}catch(_0x296bc9){utils[_0x6608('0x11')](_0x296bc9);}});ami['on'](_0x6608('0x23'),function(_0x4768bc){try{calls[_0x6608('0x23')](_0x4768bc);recordings['newchannel'](_0x4768bc);}catch(_0x3858fa){utils[_0x6608('0x11')](_0x3858fa);}});ami['on'](_0x6608('0x24'),function(_0x11acd4){try{dials[_0x6608('0x24')](_0x11acd4);}catch(_0x29678d){utils['error'](_0x29678d);}});ami['on'](_0x6608('0x25'),function(_0x4f1517){try{dials[_0x6608('0x25')](_0x4f1517);}catch(_0x3b6b38){utils[_0x6608('0x11')](_0x3b6b38);}});}