4e82a9ebfed9f949ee0edf815b52a3069ec31e89
[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 _0x32c9=['client','http','request','then','error','message','catch','rules','[%s][INTERVAL]\x20ROUTING\x20STOPPED','length','push','format','iftime\x20%s','indexOf','true','[%s][INTERVAL]\x20%s','all','some','info','[%s][INTERVAL]\x20%s\x20%s','join','\x20|\x20','log','stop','util','bluebird','jayson/promise','lodash','../../../config/logger','routing'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0x32c9,0xcc));var _0x932c=function(_0x240353,_0x3ee0e5){_0x240353=_0x240353-0x0;var _0x535096=_0x32c9[_0x240353];return _0x535096;};'use strict';var util=require(_0x932c('0x0'));var BPromise=require(_0x932c('0x1'));var jayson=require(_0x932c('0x2'));var _=require(_0x932c('0x3'));var logger=require(_0x932c('0x4'))(_0x932c('0x5'));var client=jayson[_0x932c('0x6')][_0x932c('0x7')]({'port':0x232a});function request(_0x4e5796,_0x1e5b33){return new BPromise(function(_0x154f40,_0x5819e5){return client[_0x932c('0x8')](_0x4e5796,_0x1e5b33)[_0x932c('0x9')](function(_0x3dfdf0){if(_0x3dfdf0[_0x932c('0xa')]){return _0x5819e5(_0x3dfdf0[_0x932c('0xa')][_0x932c('0xb')]);}else{return _0x154f40(_0x3dfdf0['result']);}})[_0x932c('0xc')](function(_0x1da1b4){return _0x5819e5(_0x1da1b4);});});}exports['condition']=function(_0x403ea2,_0x127c16,_0x2094af){return function(_0x5ef5d1){if(_0x2094af[_0x932c('0xd')]&&!_0x2094af[_0x932c('0xd')][_0x403ea2]){logger['info'](_0x932c('0xe'),_0x403ea2);return _0x5ef5d1['stop']();}var _0x369250=[];for(var _0x578f09=0x0;_0x578f09<_0x127c16[_0x932c('0xf')];_0x578f09+=0x1){_0x369250[_0x932c('0x10')](request('Command',{'command':util[_0x932c('0x11')](_0x932c('0x12'),_0x127c16[_0x578f09])})[_0x932c('0x9')](function(_0x4b3087){return _0x4b3087&&_0x4b3087[_0x932c('0xb')]&&_0x4b3087[_0x932c('0xb')][_0x932c('0x13')](_0x932c('0x14'))>=0x0?!![]:![];})[_0x932c('0xc')](function(_0x5764ba){logger[_0x932c('0xa')](_0x932c('0x15'),_0x403ea2,_0x127c16[_0x578f09]);}));}BPromise[_0x932c('0x16')](_0x369250)[_0x932c('0x9')](function(_0x3b4215){var _0x22d4ac=_[_0x932c('0x17')](_0x3b4215);logger[_0x932c('0x18')](_0x932c('0x19'),_0x403ea2,_0x127c16[_0x932c('0x1a')](_0x932c('0x1b')),_0x22d4ac);_0x5ef5d1['when'](_0x22d4ac);})[_0x932c('0xc')](function(_0xc77c53){console[_0x932c('0x1c')](_0xc77c53);logger['error'](_0x932c('0x19'),_0x403ea2,_0x127c16[_0x932c('0x1a')](_0x932c('0x1b')),_0xc77c53['stack']);_0x5ef5d1[_0x932c('0x1d')]();});};};