Built motion from commit 85328c08.|2.5.50
[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 _0xb084=['error','[%s][GOTOIF]\x20%s','message','join','stop','condition','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','validate','lodash','./utils','../../../../config/logger','routing','string','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','length'];(function(_0x21a9d9,_0x4d5ac8){var _0x46adce=function(_0xfdd336){while(--_0xfdd336){_0x21a9d9['push'](_0x21a9d9['shift']());}};_0x46adce(++_0x4d5ac8);}(_0xb084,0x196));var _0x4b08=function(_0x5b687c,_0x61bdcc){_0x5b687c=_0x5b687c-0x0;var _0x23e9ed=_0xb084[_0x5b687c];return _0x23e9ed;};'use strict';var schema=require(_0x4b08('0x0'));var _=require(_0x4b08('0x1'));var htmlToText=require('html-to-text');var utils=require(_0x4b08('0x2'));var logger=require(_0x4b08('0x3'))(_0x4b08('0x4'));var gotoif=schema({'condition':{'type':_0x4b08('0x5'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x4b08('0x6'),'message':_0x4b08('0x7')},'priorityFalse':{'type':_0x4b08('0x6'),'message':_0x4b08('0x8')}});exports[_0x4b08('0x9')]=function(_0x3f33a3,_0x199f84){return function(_0x196e8c){try{var _0x32d06a={'condition':htmlToText[_0x4b08('0xa')](utils[_0x4b08('0xb')](_0x199f84[0x0],this),{'wordwrap':![]})[_0x4b08('0xc')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x199f84[0x1],'priorityFalse':_0x199f84[0x2]};var _0x1d4242=gotoif['validate'](_0x32d06a,{'typecast':!![]});if(_0x1d4242[_0x4b08('0xd')]){logger[_0x4b08('0xe')](_0x4b08('0xf'),_0x3f33a3,_['map'](_0x1d4242,_0x4b08('0x10'))[_0x4b08('0x11')](',\x20'));_0x196e8c[_0x4b08('0x12')]();}else{try{var _0x59e76b=eval('('+_0x32d06a[_0x4b08('0x13')]+')');var _0x6e756d=_0x59e76b?_0x32d06a['priorityTrue']:_0x32d06a[_0x4b08('0x14')];logger[_0x4b08('0x15')](_0x4b08('0x16'),_0x3f33a3,_0x32d06a[_0x4b08('0x13')],_0x59e76b,_0x6e756d||_0x4b08('0x17'));if(_0x6e756d){var _0x83c6c3=_[_0x4b08('0x18')](_0x196e8c[_0x4b08('0x19')](),{'p':_0x6e756d});if(_0x83c6c3>=0x0){logger[_0x4b08('0x15')](_0x4b08('0x1a'),_0x3f33a3,_0x6e756d||_0x4b08('0x17'),_0x83c6c3);_0x196e8c['next'](_0x83c6c3);}else{logger[_0x4b08('0x15')](_0x4b08('0x1b'),_0x3f33a3,_0x6e756d||_0x4b08('0x17'));_0x196e8c[_0x4b08('0x12')]();}}else{_0x196e8c[_0x4b08('0x17')]();}}catch(_0x284c68){logger[_0x4b08('0xe')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x3f33a3,_0x284c68[_0x4b08('0x10')]);_0x196e8c[_0x4b08('0x12')]();}}}catch(_0x3778fa){logger[_0x4b08('0xe')](_0x4b08('0xf'),_0x3f33a3,JSON['stringify'](_0x3778fa));_0x196e8c[_0x4b08('0x12')]();}};};