40592fa3dd2201cb237a4f4015961b3671d06504
[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 _0x4fef=['[%s][SYSTEM]\x20%s','map','message','join','info','getMustacheRender','exec','trim','[%s][SYSTEM]\x20result\x20code:\x20%s','isNil','isEmpty','body','[%s][SYSTEM]\x20set\x20variable\x20%s:\x20%s','next','[%s][SYSTEM]\x20no\x20command\x20executed,\x20force\x20next','shelljs','lodash','./utils','../../../../config/logger','routing','string','consequence','validate','length','error'];(function(_0x25521d,_0xa70c12){var _0xc9ec=function(_0x3a01fe){while(--_0x3a01fe){_0x25521d['push'](_0x25521d['shift']());}};_0xc9ec(++_0xa70c12);}(_0x4fef,0x109));var _0xf4fe=function(_0x370453,_0x403f2c){_0x370453=_0x370453-0x0;var _0x218a20=_0x4fef[_0x370453];return _0x218a20;};'use strict';var schema=require('validate');var sh=require(_0xf4fe('0x0'));var _=require(_0xf4fe('0x1'));var utils=require(_0xf4fe('0x2'));var logger=require(_0xf4fe('0x3'))(_0xf4fe('0x4'));var system=schema({'command':{'type':_0xf4fe('0x5'),'required':!![],'message':'command\x20is\x20a\x20string\x20and\x20it\x20is\x20required'}});exports[_0xf4fe('0x6')]=function(_0x1f08c3,_0x43f52a){return function(_0x302560){try{var _0x641f95={'command':_0x43f52a[0x0]};var _0x36e8f2=system[_0xf4fe('0x7')](_0x641f95,{'typecast':!![]});if(_0x36e8f2[_0xf4fe('0x8')]){logger[_0xf4fe('0x9')](_0xf4fe('0xa'),_0x1f08c3,_[_0xf4fe('0xb')](_0x36e8f2,_0xf4fe('0xc'))[_0xf4fe('0xd')](',\x20'));logger[_0xf4fe('0xe')]('[%s][SYSTEM]\x20no\x20command\x20executed,\x20force\x20next',_0x1f08c3);_0x302560['next']();}else{var _0xa249e4=this;var _0x3e922a=utils[_0xf4fe('0xf')](_0x43f52a[0x0],this);logger[_0xf4fe('0xe')]('[%s][SYSTEM]\x20commnad:\x20%s',_0x1f08c3,_0x3e922a);sh[_0xf4fe('0x10')](_[_0xf4fe('0x11')](_0x3e922a),function(_0x312264,_0x593a9a){logger[_0xf4fe('0xe')](_0xf4fe('0x12'),_0x1f08c3,_0x312264);if(_0x312264==0x0){var _0x427c1d=_0x593a9a['replace'](/(\r\n|\n|\r)/gm,'');if(_[_0xf4fe('0x13')](_0x43f52a[0x1])||_[_0xf4fe('0x14')](_0x43f52a[0x1])){logger['info']('[%s][SYSTEM]\x20no\x20variable',_0x1f08c3);_0xa249e4[_0xf4fe('0x15')][_0x43f52a[0x1]]=_0x427c1d;}else{logger[_0xf4fe('0xe')](_0xf4fe('0x16'),_0x1f08c3,_0x43f52a[0x1],_0x427c1d);_0xa249e4[_0xf4fe('0x15')][_0x43f52a[0x1]]=_0x427c1d;}}_0x302560[_0xf4fe('0x17')]();});}}catch(_0x20f29e){logger['error']('[%s][SYSTEM]\x20%s',_0x1f08c3,_['isObject'](_0x20f29e)?JSON['stringify'](_0x20f29e):_0x20f29e);logger[_0xf4fe('0xe')](_0xf4fe('0x18'),_0x1f08c3);_0x302560['next']();}};};