Built motion from commit (unavailable).|2.5.8
[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 _0x1ccb=['../../config/environment','port','asterisk','password','keepConnected','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','Action','devicestatelist','actionSipPeerStatus','sippeerstatus','actionQueueSummary','queuesummary','coreshowchannels','Manager\x20\x22%s\x22\x20logged\x20on\x20to\x20%s:%s','close','connect','shutdown','info','fullybooted','resolve','then','actionCoreShowChannels','log','once','exports','asterisk-manager','bluebird','moment','util','lodash','../../config/logger','ami'];(function(_0x10f249,_0x5b8ad6){var _0x2b7423=function(_0x143f0c){while(--_0x143f0c){_0x10f249['push'](_0x10f249['shift']());}};_0x2b7423(++_0x5b8ad6);}(_0x1ccb,0x6e));var _0xb1cc=function(_0x246b7d,_0x5a22f4){_0x246b7d=_0x246b7d-0x0;var _0x22f86c=_0x1ccb[_0x246b7d];return _0x22f86c;};'use strict';var Manager=require(_0xb1cc('0x0'));var BPromise=require(_0xb1cc('0x1'));var moment=require(_0xb1cc('0x2'));var util=require(_0xb1cc('0x3'));var _=require(_0xb1cc('0x4'));var logger=require(_0xb1cc('0x5'))(_0xb1cc('0x6'));var config=require(_0xb1cc('0x7'));var ami=new Manager(config['asterisk'][_0xb1cc('0x8')],config[_0xb1cc('0x9')]['ip'],config['asterisk']['username'],config['asterisk'][_0xb1cc('0xa')],!![]);ami[_0xb1cc('0xb')]();ami['Action']=BPromise['promisify'](ami[_0xb1cc('0xc')]);function error(_0x229637){logger[_0xb1cc('0xd')](util[_0xb1cc('0xe')](_0xb1cc('0xf'),config['asterisk'][_0xb1cc('0x10')],config['asterisk']['ip'],config[_0xb1cc('0x9')][_0xb1cc('0x8')],util['inspect'](_0x229637,![],null)));}function close(){logger[_0xb1cc('0xd')](util[_0xb1cc('0xe')](_0xb1cc('0x11'),config[_0xb1cc('0x9')][_0xb1cc('0x10')],config['asterisk']['ip'],config[_0xb1cc('0x9')][_0xb1cc('0x8')]));}ami[_0xb1cc('0x12')]=function(){return function(){return ami['Action']({'action':_0xb1cc('0x13')});};};ami['actionDeviceStateList']=function(){return function(){return ami[_0xb1cc('0x14')]({'action':_0xb1cc('0x15')});};};ami[_0xb1cc('0x16')]=function(){return function(){return ami['Action']({'action':_0xb1cc('0x17')});};};ami[_0xb1cc('0x18')]=function(){return function(){return ami['Action']({'action':_0xb1cc('0x19')});};};ami['actionCoreShowChannels']=function(){return function(){return ami[_0xb1cc('0x14')]({'action':_0xb1cc('0x1a')});};};function connect(_0x3b3e55){logger['info'](util['format'](_0xb1cc('0x1b'),config['asterisk'][_0xb1cc('0x10')],config[_0xb1cc('0x9')]['ip'],config[_0xb1cc('0x9')][_0xb1cc('0x8')]));ami['once'](_0xb1cc('0xd'),error);ami['once'](_0xb1cc('0x1c'),close);}ami['on'](_0xb1cc('0x1d'),connect);ami['on'](_0xb1cc('0x1e'),function(_0x1dacf0){logger[_0xb1cc('0x1f')](util['format']('Shutdown\x20\x22%s\x22\x20to\x20%s:%s\x20with:\x0a%s',config['asterisk']['username'],config[_0xb1cc('0x9')]['ip'],config[_0xb1cc('0x9')][_0xb1cc('0x8')],util['inspect'](_0x1dacf0,![],null)));});ami['on'](_0xb1cc('0x20'),function(_0x26d311){logger[_0xb1cc('0x1f')](util[_0xb1cc('0xe')]('Fullybooted\x20\x22%s\x22\x20to\x20%s:%s',config[_0xb1cc('0x9')][_0xb1cc('0x10')],config['asterisk']['ip'],config[_0xb1cc('0x9')][_0xb1cc('0x8')]));return BPromise[_0xb1cc('0x21')]()['then'](ami[_0xb1cc('0x12')]())['then'](ami['actionDeviceStateList']())[_0xb1cc('0x22')](ami[_0xb1cc('0x16')]())[_0xb1cc('0x22')](ami[_0xb1cc('0x18')]())['then'](ami[_0xb1cc('0x23')]())['catch'](function(_0x15d4aa){console[_0xb1cc('0x24')](_0x15d4aa);});});ami[_0xb1cc('0x25')]('error',error);ami[_0xb1cc('0x25')](_0xb1cc('0x1c'),close);module[_0xb1cc('0x26')]=ami;