Built motion from commit ce97982f.|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 _0x536c=['Command','format','iftime\x20%s','indexOf','true','all','some','join','\x20|\x20','when','[%s][INTERVAL]\x20%s\x20%s','stack','util','bluebird','lodash','../../../config/logger','routing','client','http','request','then','error','message','catch','rules','info','[%s][INTERVAL]\x20ROUTING\x20STOPPED','stop','length','push'];(function(_0x331937,_0x2c5627){var _0x58aba2=function(_0x54eb75){while(--_0x54eb75){_0x331937['push'](_0x331937['shift']());}};_0x58aba2(++_0x2c5627);}(_0x536c,0x84));var _0xc536=function(_0x485d7b,_0x3f3b52){_0x485d7b=_0x485d7b-0x0;var _0x899877=_0x536c[_0x485d7b];return _0x899877;};'use strict';var util=require(_0xc536('0x0'));var BPromise=require(_0xc536('0x1'));var jayson=require('jayson/promise');var _=require(_0xc536('0x2'));var logger=require(_0xc536('0x3'))(_0xc536('0x4'));var client=jayson[_0xc536('0x5')][_0xc536('0x6')]({'port':0x232a});function request(_0x1d1156,_0x3afc81){return new BPromise(function(_0x58abcd,_0x3cb512){return client[_0xc536('0x7')](_0x1d1156,_0x3afc81)[_0xc536('0x8')](function(_0x44dad7){if(_0x44dad7[_0xc536('0x9')]){return _0x3cb512(_0x44dad7[_0xc536('0x9')][_0xc536('0xa')]);}else{return _0x58abcd(_0x44dad7['result']);}})[_0xc536('0xb')](function(_0x2d67b8){return _0x3cb512(_0x2d67b8);});});}exports['condition']=function(_0x5efc92,_0x58d826,_0x444598){return function(_0x3b0a97){if(_0x444598[_0xc536('0xc')]&&!_0x444598[_0xc536('0xc')][_0x5efc92]){logger[_0xc536('0xd')](_0xc536('0xe'),_0x5efc92);return _0x3b0a97[_0xc536('0xf')]();}var _0x399b5d=[];for(var _0x4bcb47=0x0;_0x4bcb47<_0x58d826[_0xc536('0x10')];_0x4bcb47+=0x1){_0x399b5d[_0xc536('0x11')](request(_0xc536('0x12'),{'command':util[_0xc536('0x13')](_0xc536('0x14'),_0x58d826[_0x4bcb47])})[_0xc536('0x8')](function(_0x2e62ae){return _0x2e62ae&&_0x2e62ae[_0xc536('0xa')]&&_0x2e62ae[_0xc536('0xa')][_0xc536('0x15')](_0xc536('0x16'))>=0x0?!![]:![];})[_0xc536('0xb')](function(){logger[_0xc536('0x9')]('[%s][INTERVAL]\x20%s',_0x5efc92,_0x58d826[_0x4bcb47]);}));}BPromise[_0xc536('0x17')](_0x399b5d)['then'](function(_0x52270b){var _0x468fe7=_[_0xc536('0x18')](_0x52270b);logger[_0xc536('0xd')]('[%s][INTERVAL]\x20%s\x20%s',_0x5efc92,_0x58d826[_0xc536('0x19')](_0xc536('0x1a')),_0x468fe7);_0x3b0a97[_0xc536('0x1b')](_0x468fe7);})['catch'](function(_0x2bbc11){logger[_0xc536('0x9')](_0xc536('0x1c'),_0x5efc92,_0x58d826[_0xc536('0x19')](_0xc536('0x1a')),_0x2bbc11[_0xc536('0x1d')]);_0x3b0a97[_0xc536('0xf')]();});};};