Built motion from commit (unavailable).|2.5.31
[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 _0xa105=['info','stop','length','push','Command','format','iftime\x20%s','indexOf','true','catch','[%s][INTERVAL]\x20%s','all','then','some','join','when','log','bluebird','jayson/promise','lodash','../../../config/logger','http','request','error','message','result','condition','rules'];(function(_0x1e3fd0,_0x1075b0){var _0x1fdc4c=function(_0x1ebc04){while(--_0x1ebc04){_0x1e3fd0['push'](_0x1e3fd0['shift']());}};_0x1fdc4c(++_0x1075b0);}(_0xa105,0xf1));var _0x5a10=function(_0x462e53,_0x245be5){_0x462e53=_0x462e53-0x0;var _0x3d8915=_0xa105[_0x462e53];return _0x3d8915;};'use strict';var util=require('util');var BPromise=require(_0x5a10('0x0'));var jayson=require(_0x5a10('0x1'));var _=require(_0x5a10('0x2'));var logger=require(_0x5a10('0x3'))('routing');var client=jayson['client'][_0x5a10('0x4')]({'port':0x232a});function request(_0x18a80f,_0x3799f2){return new BPromise(function(_0x385edc,_0x3f425e){return client[_0x5a10('0x5')](_0x18a80f,_0x3799f2)['then'](function(_0x54cb6e){if(_0x54cb6e[_0x5a10('0x6')]){return _0x3f425e(_0x54cb6e[_0x5a10('0x6')][_0x5a10('0x7')]);}else{return _0x385edc(_0x54cb6e[_0x5a10('0x8')]);}})['catch'](function(_0x28bde){return _0x3f425e(_0x28bde);});});}exports[_0x5a10('0x9')]=function(_0x16830f,_0x18c744,_0x4142cc){return function(_0x41fdd7){if(_0x4142cc[_0x5a10('0xa')]&&!_0x4142cc[_0x5a10('0xa')][_0x16830f]){logger[_0x5a10('0xb')]('[%s][INTERVAL]\x20ROUTING\x20STOPPED',_0x16830f);return _0x41fdd7[_0x5a10('0xc')]();}var _0x230440=[];for(var _0x45f835=0x0;_0x45f835<_0x18c744[_0x5a10('0xd')];_0x45f835+=0x1){_0x230440[_0x5a10('0xe')](request(_0x5a10('0xf'),{'command':util[_0x5a10('0x10')](_0x5a10('0x11'),_0x18c744[_0x45f835])})['then'](function(_0x1c958b){return _0x1c958b&&_0x1c958b[_0x5a10('0x7')]&&_0x1c958b[_0x5a10('0x7')][_0x5a10('0x12')](_0x5a10('0x13'))>=0x0?!![]:![];})[_0x5a10('0x14')](function(_0x4335f8){logger[_0x5a10('0x6')](_0x5a10('0x15'),_0x16830f,_0x18c744[_0x45f835]);}));}BPromise[_0x5a10('0x16')](_0x230440)[_0x5a10('0x17')](function(_0x2c784d){var _0x496721=_[_0x5a10('0x18')](_0x2c784d);logger['info']('[%s][INTERVAL]\x20%s\x20%s',_0x16830f,_0x18c744[_0x5a10('0x19')]('\x20|\x20'),_0x496721);_0x41fdd7[_0x5a10('0x1a')](_0x496721);})['catch'](function(_0x4d55ab){console[_0x5a10('0x1b')](_0x4d55ab);logger[_0x5a10('0x6')]('[%s][INTERVAL]\x20%s\x20%s',_0x16830f,_0x18c744['join']('\x20|\x20'),_0x4d55ab['stack']);_0x41fdd7[_0x5a10('0xc')]();});};};