Built motion from commit 6f14c8ba.|2.6.29
[motion2.git] / server / services / ami / ami.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 _0xae1a=['info','once','connect','shutdown','Shutdown\x20\x22%s\x22\x20to\x20%s:%s\x20with:\x0a%s','inspect','fullybooted','Fullybooted\x20\x22%s\x22\x20to\x20%s:%s','resolve','then','catch','[ami.js][fullybooted]','close','asterisk-manager','util','../../config/logger','ami','../../config/environment','asterisk','port','password','keepConnected','Action','action','error','format','Manager\x20\x22%s\x22\x20error\x20to\x20%s:%s\x20with:\x0a%s','username','Manager\x20\x22%s\x22\x20closed\x20to\x20%s:%s','actionSipShowRegistry','sipshowregistry','actionDeviceStateList','actionSipPeerStatus','sippeerstatus','actionQueueSummary','queuesummary','actionCoreShowChannels'];(function(_0x278e3c,_0x1c9cfd){var _0x3e2d9b=function(_0x34d928){while(--_0x34d928){_0x278e3c['push'](_0x278e3c['shift']());}};_0x3e2d9b(++_0x1c9cfd);}(_0xae1a,0xeb));var _0xaae1=function(_0x3ff085,_0x27c92e){_0x3ff085=_0x3ff085-0x0;var _0x2b68c3=_0xae1a[_0x3ff085];return _0x2b68c3;};'use strict';var Manager=require(_0xaae1('0x0'));var BPromise=require('bluebird');var util=require(_0xaae1('0x1'));var logger=require(_0xaae1('0x2'))(_0xaae1('0x3'));var config=require(_0xaae1('0x4'));var ami=new Manager(config[_0xaae1('0x5')][_0xaae1('0x6')],config['asterisk']['ip'],config[_0xaae1('0x5')]['username'],config[_0xaae1('0x5')][_0xaae1('0x7')],!![]);ami[_0xaae1('0x8')]();ami[_0xaae1('0x9')]=BPromise['promisify'](ami[_0xaae1('0xa')]);function error(_0x571bf9){logger[_0xaae1('0xb')](util[_0xaae1('0xc')](_0xaae1('0xd'),config[_0xaae1('0x5')][_0xaae1('0xe')],config[_0xaae1('0x5')]['ip'],config['asterisk'][_0xaae1('0x6')],util['inspect'](_0x571bf9,![],null)));}function close(){logger[_0xaae1('0xb')](util['format'](_0xaae1('0xf'),config[_0xaae1('0x5')]['username'],config[_0xaae1('0x5')]['ip'],config['asterisk'][_0xaae1('0x6')]));}ami[_0xaae1('0x10')]=function(){return function(){return ami[_0xaae1('0x9')]({'action':_0xaae1('0x11')});};};ami[_0xaae1('0x12')]=function(){return function(){return ami[_0xaae1('0x9')]({'action':'devicestatelist'});};};ami[_0xaae1('0x13')]=function(){return function(){return ami[_0xaae1('0x9')]({'action':_0xaae1('0x14')});};};ami[_0xaae1('0x15')]=function(){return function(){return ami[_0xaae1('0x9')]({'action':_0xaae1('0x16')});};};ami[_0xaae1('0x17')]=function(){return function(){return ami[_0xaae1('0x9')]({'action':'coreshowchannels'});};};function connect(){logger[_0xaae1('0x18')](util[_0xaae1('0xc')]('Manager\x20\x22%s\x22\x20logged\x20on\x20to\x20%s:%s',config[_0xaae1('0x5')]['username'],config[_0xaae1('0x5')]['ip'],config['asterisk'][_0xaae1('0x6')]));ami[_0xaae1('0x19')](_0xaae1('0xb'),error);ami[_0xaae1('0x19')]('close',close);}ami['on'](_0xaae1('0x1a'),connect);ami['on'](_0xaae1('0x1b'),function(_0x5698e1){logger['info'](util[_0xaae1('0xc')](_0xaae1('0x1c'),config[_0xaae1('0x5')]['username'],config['asterisk']['ip'],config[_0xaae1('0x5')][_0xaae1('0x6')],util[_0xaae1('0x1d')](_0x5698e1,![],null)));});ami['on'](_0xaae1('0x1e'),function(){logger[_0xaae1('0x18')](util[_0xaae1('0xc')](_0xaae1('0x1f'),config[_0xaae1('0x5')]['username'],config[_0xaae1('0x5')]['ip'],config['asterisk'][_0xaae1('0x6')]));return Promise[_0xaae1('0x20')]()[_0xaae1('0x21')](ami[_0xaae1('0x10')]())[_0xaae1('0x21')](ami[_0xaae1('0x12')]())[_0xaae1('0x21')](ami['actionSipPeerStatus']())[_0xaae1('0x21')](ami[_0xaae1('0x15')]())[_0xaae1('0x21')](ami[_0xaae1('0x17')]())[_0xaae1('0x22')](function(_0x3cda7a){logger[_0xaae1('0xb')](_0xaae1('0x23'),util[_0xaae1('0x1d')](_0x3cda7a,{'showHidden':![],'depth':null}));});});ami['once'](_0xaae1('0xb'),error);ami[_0xaae1('0x19')](_0xaae1('0x24'),close);module['exports']=ami;