f02cfcdeeb5a01acd68f1811ca87940ba6854cfa
[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 _0x0f12=['util','jayson/promise','lodash','../../../config/logger','routing','client','http','then','error','result','catch','rules','info','stop','length','Command','format','iftime\x20%s','message','true','all','some','[%s][INTERVAL]\x20%s\x20%s','join','when','\x20|\x20'];(function(_0x12ecc9,_0x333677){var _0x1498d=function(_0x430f94){while(--_0x430f94){_0x12ecc9['push'](_0x12ecc9['shift']());}};_0x1498d(++_0x333677);}(_0x0f12,0x186));var _0x20f1=function(_0x1bc13b,_0x3d719d){_0x1bc13b=_0x1bc13b-0x0;var _0x60199c=_0x0f12[_0x1bc13b];return _0x60199c;};'use strict';var util=require(_0x20f1('0x0'));var BPromise=require('bluebird');var jayson=require(_0x20f1('0x1'));var _=require(_0x20f1('0x2'));var logger=require(_0x20f1('0x3'))(_0x20f1('0x4'));var client=jayson[_0x20f1('0x5')][_0x20f1('0x6')]({'port':0x232a});function request(_0x1c9919,_0x52e549){return new BPromise(function(_0x39d76e,_0x52fb17){return client['request'](_0x1c9919,_0x52e549)[_0x20f1('0x7')](function(_0x44d34b){if(_0x44d34b[_0x20f1('0x8')]){return _0x52fb17(_0x44d34b[_0x20f1('0x8')]['message']);}else{return _0x39d76e(_0x44d34b[_0x20f1('0x9')]);}})[_0x20f1('0xa')](function(_0x5e6094){return _0x52fb17(_0x5e6094);});});}exports['condition']=function(_0xf0bd25,_0x1bd1f9,_0x30052d){return function(_0x2e2423){if(_0x30052d[_0x20f1('0xb')]&&!_0x30052d[_0x20f1('0xb')][_0xf0bd25]){logger[_0x20f1('0xc')]('[%s][INTERVAL]\x20ROUTING\x20STOPPED',_0xf0bd25);return _0x2e2423[_0x20f1('0xd')]();}var _0xcb240=[];for(var _0x48a586=0x0;_0x48a586<_0x1bd1f9[_0x20f1('0xe')];_0x48a586+=0x1){_0xcb240['push'](request(_0x20f1('0xf'),{'command':util[_0x20f1('0x10')](_0x20f1('0x11'),_0x1bd1f9[_0x48a586])})[_0x20f1('0x7')](function(_0x1dafdb){return _0x1dafdb&&_0x1dafdb[_0x20f1('0x12')]&&_0x1dafdb[_0x20f1('0x12')]['indexOf'](_0x20f1('0x13'))>=0x0?!![]:![];})[_0x20f1('0xa')](function(){logger[_0x20f1('0x8')]('[%s][INTERVAL]\x20%s',_0xf0bd25,_0x1bd1f9[_0x48a586]);}));}BPromise[_0x20f1('0x14')](_0xcb240)[_0x20f1('0x7')](function(_0x5da2e0){var _0x14da12=_[_0x20f1('0x15')](_0x5da2e0);logger[_0x20f1('0xc')](_0x20f1('0x16'),_0xf0bd25,_0x1bd1f9[_0x20f1('0x17')]('\x20|\x20'),_0x14da12);_0x2e2423[_0x20f1('0x18')](_0x14da12);})['catch'](function(_0x77f17d){logger[_0x20f1('0x8')]('[%s][INTERVAL]\x20%s\x20%s',_0xf0bd25,_0x1bd1f9['join'](_0x20f1('0x19')),_0x77f17d['stack']);_0x2e2423['stop']();});};};