Built motion from commit (unavailable).|2.1.0
[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 _0xfdf7=['error','map','message','join','condition','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stop','[%s][GOTOIF]\x20eval\x20error:\x20%s','[%s][GOTOIF]\x20%s','stringify','validate','lodash','html-to-text','./utils','../../../../config/logger','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','replace','length'];(function(_0x4a55b1,_0xa87186){var _0x24905b=function(_0x1c5a9b){while(--_0x1c5a9b){_0x4a55b1['push'](_0x4a55b1['shift']());}};_0x24905b(++_0xa87186);}(_0xfdf7,0xa0));var _0x7fdf=function(_0x1eff1a,_0x5d05a9){_0x1eff1a=_0x1eff1a-0x0;var _0x478b4b=_0xfdf7[_0x1eff1a];return _0x478b4b;};'use strict';var schema=require(_0x7fdf('0x0'));var _=require(_0x7fdf('0x1'));var htmlToText=require(_0x7fdf('0x2'));var utils=require(_0x7fdf('0x3'));var logger=require(_0x7fdf('0x4'))('routing');var gotoif=schema({'condition':{'type':_0x7fdf('0x5'),'required':!![],'message':_0x7fdf('0x6')},'priorityTrue':{'type':_0x7fdf('0x7'),'message':_0x7fdf('0x8')},'priorityFalse':{'type':'number','message':_0x7fdf('0x9')}});exports[_0x7fdf('0xa')]=function(_0x1d28fc,_0x2ebff3){return function(_0x3fba7a){try{var _0x16e4fe={'condition':htmlToText[_0x7fdf('0xb')](utils['getMustacheRender'](_0x2ebff3[0x0],this),{'wordwrap':![]})[_0x7fdf('0xc')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x2ebff3[0x1],'priorityFalse':_0x2ebff3[0x2]};var _0x51dc90=gotoif[_0x7fdf('0x0')](_0x16e4fe,{'typecast':!![]});if(_0x51dc90[_0x7fdf('0xd')]){logger[_0x7fdf('0xe')]('[%s][GOTOIF]\x20%s',_0x1d28fc,_[_0x7fdf('0xf')](_0x51dc90,_0x7fdf('0x10'))[_0x7fdf('0x11')](',\x20'));_0x3fba7a['stop']();}else{try{var _0x3df547=eval('('+_0x16e4fe[_0x7fdf('0x12')]+')');var _0x347d13=_0x3df547?_0x16e4fe['priorityTrue']:_0x16e4fe['priorityFalse'];logger[_0x7fdf('0x13')](_0x7fdf('0x14'),_0x1d28fc,_0x16e4fe[_0x7fdf('0x12')],_0x3df547,_0x347d13||_0x7fdf('0x15'));if(_0x347d13){var _0x1fb4b7=_[_0x7fdf('0x16')](_0x3fba7a[_0x7fdf('0x17')](),{'p':_0x347d13});if(_0x1fb4b7>=0x0){logger[_0x7fdf('0x13')]('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x1d28fc,_0x347d13||_0x7fdf('0x15'),_0x1fb4b7);_0x3fba7a[_0x7fdf('0x15')](_0x1fb4b7);}else{logger[_0x7fdf('0x13')](_0x7fdf('0x18'),_0x1d28fc,_0x347d13||_0x7fdf('0x15'));_0x3fba7a[_0x7fdf('0x19')]();}}else{_0x3fba7a[_0x7fdf('0x15')]();}}catch(_0x12f718){logger[_0x7fdf('0xe')](_0x7fdf('0x1a'),_0x1d28fc,_0x12f718['message']);_0x3fba7a['stop']();}}}catch(_0x5ee824){logger[_0x7fdf('0xe')](_0x7fdf('0x1b'),_0x1d28fc,JSON[_0x7fdf('0x1c')](_0x5ee824));_0x3fba7a[_0x7fdf('0x19')]();}};};