27b31bbb4591e4caa56239bc41707c8ce96e0f22
[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 _0x6f01=['length','push','Command','format','indexOf','true','catch','all','some','\x20|\x20','when','log','[%s][INTERVAL]\x20%s\x20%s','join','stack','util','bluebird','lodash','request','then','error','message','result','rules','info','[%s][INTERVAL]\x20ROUTING\x20STOPPED','stop'];(function(_0x43a81d,_0x5448f0){var _0x5b23b4=function(_0x11d342){while(--_0x11d342){_0x43a81d['push'](_0x43a81d['shift']());}};_0x5b23b4(++_0x5448f0);}(_0x6f01,0x1bf));var _0x16f0=function(_0x397e5f,_0x454c8f){_0x397e5f=_0x397e5f-0x0;var _0x5302b8=_0x6f01[_0x397e5f];return _0x5302b8;};'use strict';var util=require(_0x16f0('0x0'));var BPromise=require(_0x16f0('0x1'));var jayson=require('jayson/promise');var _=require(_0x16f0('0x2'));var logger=require('../../../config/logger')('routing');var client=jayson['client']['http']({'port':0x232a});function request(_0x2175ca,_0x578081){return new BPromise(function(_0x296b35,_0x2b7fa3){return client[_0x16f0('0x3')](_0x2175ca,_0x578081)[_0x16f0('0x4')](function(_0x23ddec){if(_0x23ddec[_0x16f0('0x5')]){return _0x2b7fa3(_0x23ddec[_0x16f0('0x5')][_0x16f0('0x6')]);}else{return _0x296b35(_0x23ddec[_0x16f0('0x7')]);}})['catch'](function(_0x5911fa){return _0x2b7fa3(_0x5911fa);});});}exports['condition']=function(_0x30955a,_0x13d4bd,_0x4d5822){return function(_0x3d6353){if(_0x4d5822['rules']&&!_0x4d5822[_0x16f0('0x8')][_0x30955a]){logger[_0x16f0('0x9')](_0x16f0('0xa'),_0x30955a);return _0x3d6353[_0x16f0('0xb')]();}var _0x127f4f=[];for(var _0x248a72=0x0;_0x248a72<_0x13d4bd[_0x16f0('0xc')];_0x248a72+=0x1){_0x127f4f[_0x16f0('0xd')](request(_0x16f0('0xe'),{'command':util[_0x16f0('0xf')]('iftime\x20%s',_0x13d4bd[_0x248a72])})[_0x16f0('0x4')](function(_0x22330b){return _0x22330b&&_0x22330b['message']&&_0x22330b[_0x16f0('0x6')][_0x16f0('0x10')](_0x16f0('0x11'))>=0x0?!![]:![];})[_0x16f0('0x12')](function(_0x23791a){logger[_0x16f0('0x5')]('[%s][INTERVAL]\x20%s',_0x30955a,_0x13d4bd[_0x248a72]);}));}BPromise[_0x16f0('0x13')](_0x127f4f)[_0x16f0('0x4')](function(_0x319739){var _0x43ece9=_[_0x16f0('0x14')](_0x319739);logger[_0x16f0('0x9')]('[%s][INTERVAL]\x20%s\x20%s',_0x30955a,_0x13d4bd['join'](_0x16f0('0x15')),_0x43ece9);_0x3d6353[_0x16f0('0x16')](_0x43ece9);})[_0x16f0('0x12')](function(_0x3f8fab){console[_0x16f0('0x17')](_0x3f8fab);logger['error'](_0x16f0('0x18'),_0x30955a,_0x13d4bd[_0x16f0('0x19')](_0x16f0('0x15')),_0x3f8fab[_0x16f0('0x1a')]);_0x3d6353['stop']();});};};