0555702e9e2e60fdc53f9296557e494dfad3fdc0
[motion2.git] / server / services / routing / server / applications / gotoif.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 _0xe2b4=['string','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','replace','length','error','[%s][GOTOIF]\x20%s','message','join','condition','priorityFalse','info','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stop','[%s][GOTOIF]\x20eval\x20error:\x20%s','validate','lodash','./utils','../../../../config/logger','routing'];(function(_0x29d915,_0x54a040){var _0x160f86=function(_0x237dfa){while(--_0x237dfa){_0x29d915['push'](_0x29d915['shift']());}};_0x160f86(++_0x54a040);}(_0xe2b4,0x175));var _0x4e2b=function(_0x4d7809,_0x43a96d){_0x4d7809=_0x4d7809-0x0;var _0x459fcb=_0xe2b4[_0x4d7809];return _0x459fcb;};'use strict';var schema=require(_0x4e2b('0x0'));var _=require(_0x4e2b('0x1'));var htmlToText=require('html-to-text');var utils=require(_0x4e2b('0x2'));var logger=require(_0x4e2b('0x3'))(_0x4e2b('0x4'));var gotoif=schema({'condition':{'type':_0x4e2b('0x5'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x4e2b('0x6'),'message':_0x4e2b('0x7')},'priorityFalse':{'type':_0x4e2b('0x6'),'message':_0x4e2b('0x8')}});exports[_0x4e2b('0x9')]=function(_0x1cfd34,_0x1bba74){return function(_0x294487){try{var _0xa8f6f1={'condition':htmlToText[_0x4e2b('0xa')](utils['getMustacheRender'](_0x1bba74[0x0],this),{'wordwrap':![]})[_0x4e2b('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x1bba74[0x1],'priorityFalse':_0x1bba74[0x2]};var _0x3b2fb1=gotoif[_0x4e2b('0x0')](_0xa8f6f1,{'typecast':!![]});if(_0x3b2fb1[_0x4e2b('0xc')]){logger[_0x4e2b('0xd')](_0x4e2b('0xe'),_0x1cfd34,_['map'](_0x3b2fb1,_0x4e2b('0xf'))[_0x4e2b('0x10')](',\x20'));_0x294487['stop']();}else{try{var _0x366770=eval('('+_0xa8f6f1[_0x4e2b('0x11')]+')');var _0x3efef1=_0x366770?_0xa8f6f1['priorityTrue']:_0xa8f6f1[_0x4e2b('0x12')];logger[_0x4e2b('0x13')]('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0x1cfd34,_0xa8f6f1[_0x4e2b('0x11')],_0x366770,_0x3efef1||_0x4e2b('0x14'));if(_0x3efef1){var _0x4443e9=_[_0x4e2b('0x15')](_0x294487[_0x4e2b('0x16')](),{'p':_0x3efef1});if(_0x4443e9>=0x0){logger[_0x4e2b('0x13')](_0x4e2b('0x17'),_0x1cfd34,_0x3efef1||_0x4e2b('0x14'),_0x4443e9);_0x294487['next'](_0x4443e9);}else{logger[_0x4e2b('0x13')](_0x4e2b('0x18'),_0x1cfd34,_0x3efef1||_0x4e2b('0x14'));_0x294487[_0x4e2b('0x19')]();}}else{_0x294487['next']();}}catch(_0x4239ee){logger[_0x4e2b('0xd')](_0x4e2b('0x1a'),_0x1cfd34,_0x4239ee['message']);_0x294487[_0x4e2b('0x19')]();}}}catch(_0x243259){logger[_0x4e2b('0xd')](_0x4e2b('0xe'),_0x1cfd34,JSON['stringify'](_0x243259));_0x294487[_0x4e2b('0x19')]();}};};