8fc69ba4375a0451177dfd7f06bdf060f514b94a
[motion2.git] / server / services / routing / server / applications / system.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 _0xed04=['map','join','info','[%s][SYSTEM]\x20no\x20command\x20executed,\x20force\x20next','next','getMustacheRender','[%s][SYSTEM]\x20commnad:\x20%s','trim','replace','isNil','[%s][SYSTEM]\x20no\x20variable','body','[%s][SYSTEM]\x20set\x20variable\x20%s:\x20%s','error','[%s][SYSTEM]\x20%s','isObject','stringify','validate','string','command\x20is\x20a\x20string\x20and\x20it\x20is\x20required','length'];(function(_0x12fc3e,_0x2c9597){var _0x3d533f=function(_0x1367b0){while(--_0x1367b0){_0x12fc3e['push'](_0x12fc3e['shift']());}};_0x3d533f(++_0x2c9597);}(_0xed04,0xa4));var _0x4ed0=function(_0x221d7e,_0x5d22c6){_0x221d7e=_0x221d7e-0x0;var _0x31bd61=_0xed04[_0x221d7e];return _0x31bd61;};'use strict';var schema=require(_0x4ed0('0x0'));var sh=require('shelljs');var _=require('lodash');var utils=require('./utils');var logger=require('../../../../config/logger')('routing');var system=schema({'command':{'type':_0x4ed0('0x1'),'required':!![],'message':_0x4ed0('0x2')}});exports['consequence']=function(_0x45d90e,_0x31aaa3){return function(_0x5daa36){try{var _0x46b613={'command':_0x31aaa3[0x0]};var _0x47e1c8=system[_0x4ed0('0x0')](_0x46b613,{'typecast':!![]});if(_0x47e1c8[_0x4ed0('0x3')]){logger['error']('[%s][SYSTEM]\x20%s',_0x45d90e,_[_0x4ed0('0x4')](_0x47e1c8,'message')[_0x4ed0('0x5')](',\x20'));logger[_0x4ed0('0x6')](_0x4ed0('0x7'),_0x45d90e);_0x5daa36[_0x4ed0('0x8')]();}else{var _0x582324=this;var _0x5cf822=utils[_0x4ed0('0x9')](_0x31aaa3[0x0],this);logger[_0x4ed0('0x6')](_0x4ed0('0xa'),_0x45d90e,_0x5cf822);sh['exec'](_[_0x4ed0('0xb')](_0x5cf822),function(_0x1f9ffc,_0xf15e86){logger[_0x4ed0('0x6')]('[%s][SYSTEM]\x20result\x20code:\x20%s',_0x45d90e,_0x1f9ffc);if(_0x1f9ffc==0x0){var _0xdbaeb6=_0xf15e86[_0x4ed0('0xc')](/(\r\n|\n|\r)/gm,'');if(_[_0x4ed0('0xd')](_0x31aaa3[0x1])||_['isEmpty'](_0x31aaa3[0x1])){logger['info'](_0x4ed0('0xe'),_0x45d90e);_0x582324[_0x4ed0('0xf')][_0x31aaa3[0x1]]=_0xdbaeb6;}else{logger[_0x4ed0('0x6')](_0x4ed0('0x10'),_0x45d90e,_0x31aaa3[0x1],_0xdbaeb6);_0x582324['body'][_0x31aaa3[0x1]]=_0xdbaeb6;}}_0x5daa36[_0x4ed0('0x8')]();});}}catch(_0xacfaf0){logger[_0x4ed0('0x11')](_0x4ed0('0x12'),_0x45d90e,_[_0x4ed0('0x13')](_0xacfaf0)?JSON[_0x4ed0('0x14')](_0xacfaf0):_0xacfaf0);logger[_0x4ed0('0x6')](_0x4ed0('0x7'),_0x45d90e);_0x5daa36['next']();}};};