f06d3d6b79957aafce1b25b10f600aad956b9a02
[motion2.git] / server / services / routing / server / interval.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 _0x52ef=['\x20|\x20','when','stack','util','bluebird','jayson/promise','lodash','../../../config/logger','client','http','then','error','message','catch','condition','rules','stop','length','push','Command','format','indexOf','true','[%s][INTERVAL]\x20%s','some','info','[%s][INTERVAL]\x20%s\x20%s','join'];(function(_0x342d31,_0x225162){var _0x159adc=function(_0x5ea44b){while(--_0x5ea44b){_0x342d31['push'](_0x342d31['shift']());}};_0x159adc(++_0x225162);}(_0x52ef,0xe3));var _0xf52e=function(_0x39fc84,_0x3a0de1){_0x39fc84=_0x39fc84-0x0;var _0x1f63c1=_0x52ef[_0x39fc84];return _0x1f63c1;};'use strict';var util=require(_0xf52e('0x0'));var BPromise=require(_0xf52e('0x1'));var jayson=require(_0xf52e('0x2'));var _=require(_0xf52e('0x3'));var logger=require(_0xf52e('0x4'))('routing');var client=jayson[_0xf52e('0x5')][_0xf52e('0x6')]({'port':0x232a});function request(_0x474f4d,_0x46511e){return new BPromise(function(_0x3138c1,_0x560f38){return client['request'](_0x474f4d,_0x46511e)[_0xf52e('0x7')](function(_0x118ad7){if(_0x118ad7[_0xf52e('0x8')]){return _0x560f38(_0x118ad7[_0xf52e('0x8')][_0xf52e('0x9')]);}else{return _0x3138c1(_0x118ad7['result']);}})[_0xf52e('0xa')](function(_0x3e923e){return _0x560f38(_0x3e923e);});});}exports[_0xf52e('0xb')]=function(_0x167e23,_0x4cf42c,_0x4a40e7){return function(_0x1de9bb){if(_0x4a40e7[_0xf52e('0xc')]&&!_0x4a40e7[_0xf52e('0xc')][_0x167e23]){logger['info']('[%s][INTERVAL]\x20ROUTING\x20STOPPED',_0x167e23);return _0x1de9bb[_0xf52e('0xd')]();}var _0x69693d=[];for(var _0x59092f=0x0;_0x59092f<_0x4cf42c[_0xf52e('0xe')];_0x59092f+=0x1){_0x69693d[_0xf52e('0xf')](request(_0xf52e('0x10'),{'command':util[_0xf52e('0x11')]('iftime\x20%s',_0x4cf42c[_0x59092f])})[_0xf52e('0x7')](function(_0x305f86){return _0x305f86&&_0x305f86[_0xf52e('0x9')]&&_0x305f86['message'][_0xf52e('0x12')](_0xf52e('0x13'))>=0x0?!![]:![];})['catch'](function(){logger[_0xf52e('0x8')](_0xf52e('0x14'),_0x167e23,_0x4cf42c[_0x59092f]);}));}BPromise['all'](_0x69693d)[_0xf52e('0x7')](function(_0x80fb16){var _0x22bb04=_[_0xf52e('0x15')](_0x80fb16);logger[_0xf52e('0x16')](_0xf52e('0x17'),_0x167e23,_0x4cf42c[_0xf52e('0x18')](_0xf52e('0x19')),_0x22bb04);_0x1de9bb[_0xf52e('0x1a')](_0x22bb04);})[_0xf52e('0xa')](function(_0x34f297){logger[_0xf52e('0x8')]('[%s][INTERVAL]\x20%s\x20%s',_0x167e23,_0x4cf42c[_0xf52e('0x18')](_0xf52e('0x19')),_0x34f297[_0xf52e('0x1b')]);_0x1de9bb[_0xf52e('0xd')]();});};};