a0a963943b6eebc0ef36879c65afa786b1c0a67e
[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 _0x4f2f=['routing','request','then','error','message','condition','rules','info','stop','length','format','indexOf','true','[%s][INTERVAL]\x20%s','all','join','\x20|\x20','when','catch','log','[%s][INTERVAL]\x20%s\x20%s','util','bluebird','jayson/promise','lodash','../../../config/logger'];(function(_0x8345ab,_0x29ad5c){var _0x333aa9=function(_0x390288){while(--_0x390288){_0x8345ab['push'](_0x8345ab['shift']());}};_0x333aa9(++_0x29ad5c);}(_0x4f2f,0x119));var _0xf4f2=function(_0x278e3c,_0x1c9cfd){_0x278e3c=_0x278e3c-0x0;var _0x3e2d9b=_0x4f2f[_0x278e3c];return _0x3e2d9b;};'use strict';var util=require(_0xf4f2('0x0'));var BPromise=require(_0xf4f2('0x1'));var jayson=require(_0xf4f2('0x2'));var _=require(_0xf4f2('0x3'));var logger=require(_0xf4f2('0x4'))(_0xf4f2('0x5'));var client=jayson['client']['http']({'port':0x232a});function request(_0x3ef7b0,_0x43b555){return new BPromise(function(_0x4bdd1c,_0x4f2b94){return client[_0xf4f2('0x6')](_0x3ef7b0,_0x43b555)[_0xf4f2('0x7')](function(_0xbf251d){if(_0xbf251d['error']){return _0x4f2b94(_0xbf251d[_0xf4f2('0x8')][_0xf4f2('0x9')]);}else{return _0x4bdd1c(_0xbf251d['result']);}})['catch'](function(_0x77c36e){return _0x4f2b94(_0x77c36e);});});}exports[_0xf4f2('0xa')]=function(_0x51e514,_0x3b6ff1,_0x51b6d0){return function(_0x4d3490){if(_0x51b6d0[_0xf4f2('0xb')]&&!_0x51b6d0[_0xf4f2('0xb')][_0x51e514]){logger[_0xf4f2('0xc')]('[%s][INTERVAL]\x20ROUTING\x20STOPPED',_0x51e514);return _0x4d3490[_0xf4f2('0xd')]();}var _0x3d2d73=[];for(var _0xb7b71d=0x0;_0xb7b71d<_0x3b6ff1[_0xf4f2('0xe')];_0xb7b71d+=0x1){_0x3d2d73['push'](request('Command',{'command':util[_0xf4f2('0xf')]('iftime\x20%s',_0x3b6ff1[_0xb7b71d])})['then'](function(_0x59d322){return _0x59d322&&_0x59d322[_0xf4f2('0x9')]&&_0x59d322[_0xf4f2('0x9')][_0xf4f2('0x10')](_0xf4f2('0x11'))>=0x0?!![]:![];})['catch'](function(_0x2ae4b0){logger[_0xf4f2('0x8')](_0xf4f2('0x12'),_0x51e514,_0x3b6ff1[_0xb7b71d]);}));}BPromise[_0xf4f2('0x13')](_0x3d2d73)[_0xf4f2('0x7')](function(_0x504a0f){var _0x1ad5da=_['some'](_0x504a0f);logger['info']('[%s][INTERVAL]\x20%s\x20%s',_0x51e514,_0x3b6ff1[_0xf4f2('0x14')](_0xf4f2('0x15')),_0x1ad5da);_0x4d3490[_0xf4f2('0x16')](_0x1ad5da);})[_0xf4f2('0x17')](function(_0x43d9b0){console[_0xf4f2('0x18')](_0x43d9b0);logger[_0xf4f2('0x8')](_0xf4f2('0x19'),_0x51e514,_0x3b6ff1[_0xf4f2('0x14')](_0xf4f2('0x15')),_0x43d9b0['stack']);_0x4d3490[_0xf4f2('0xd')]();});};};