Built motion from commit 9c91e9f5.|2.6.29
[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 _0x9f81=['then','message','indexOf','true','[%s][INTERVAL]\x20%s\x20%s','\x20|\x20','join','stack','util','jayson/promise','lodash','../../../config/logger','routing','http','request','error','catch','condition','rules','info','[%s][INTERVAL]\x20ROUTING\x20STOPPED','push','Command','iftime\x20%s'];(function(_0x25c44a,_0x4dddda){var _0x3e7425=function(_0x17d80e){while(--_0x17d80e){_0x25c44a['push'](_0x25c44a['shift']());}};_0x3e7425(++_0x4dddda);}(_0x9f81,0x170));var _0x19f8=function(_0x57d51c,_0x5cc2e5){_0x57d51c=_0x57d51c-0x0;var _0x50fa4b=_0x9f81[_0x57d51c];return _0x50fa4b;};'use strict';var util=require(_0x19f8('0x0'));var BPromise=require('bluebird');var jayson=require(_0x19f8('0x1'));var _=require(_0x19f8('0x2'));var logger=require(_0x19f8('0x3'))(_0x19f8('0x4'));var client=jayson['client'][_0x19f8('0x5')]({'port':0x232a});function request(_0x3be678,_0x81a0f2){return new BPromise(function(_0x360b49,_0x407fd7){return client[_0x19f8('0x6')](_0x3be678,_0x81a0f2)['then'](function(_0x57c3c7){if(_0x57c3c7[_0x19f8('0x7')]){return _0x407fd7(_0x57c3c7[_0x19f8('0x7')]['message']);}else{return _0x360b49(_0x57c3c7['result']);}})[_0x19f8('0x8')](function(_0x1bb9ec){return _0x407fd7(_0x1bb9ec);});});}exports[_0x19f8('0x9')]=function(_0x2e4fc8,_0x560468,_0x490583){return function(_0x247948){if(_0x490583[_0x19f8('0xa')]&&!_0x490583[_0x19f8('0xa')][_0x2e4fc8]){logger[_0x19f8('0xb')](_0x19f8('0xc'),_0x2e4fc8);return _0x247948['stop']();}var _0x42dac8=[];for(var _0x518aec=0x0;_0x518aec<_0x560468['length'];_0x518aec+=0x1){_0x42dac8[_0x19f8('0xd')](request(_0x19f8('0xe'),{'command':util['format'](_0x19f8('0xf'),_0x560468[_0x518aec])})[_0x19f8('0x10')](function(_0x39f9be){return _0x39f9be&&_0x39f9be['message']&&_0x39f9be[_0x19f8('0x11')][_0x19f8('0x12')](_0x19f8('0x13'))>=0x0?!![]:![];})[_0x19f8('0x8')](function(){logger[_0x19f8('0x7')]('[%s][INTERVAL]\x20%s',_0x2e4fc8,_0x560468[_0x518aec]);}));}BPromise['all'](_0x42dac8)[_0x19f8('0x10')](function(_0x8861c1){var _0x53e972=_['some'](_0x8861c1);logger['info'](_0x19f8('0x14'),_0x2e4fc8,_0x560468['join'](_0x19f8('0x15')),_0x53e972);_0x247948['when'](_0x53e972);})[_0x19f8('0x8')](function(_0x5021b4){logger['error'](_0x19f8('0x14'),_0x2e4fc8,_0x560468[_0x19f8('0x16')]('\x20|\x20'),_0x5021b4[_0x19f8('0x17')]);_0x247948['stop']();});};};