Built motion from commit 9d1906d1.|2.5.40
[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 _0x888b=['length','[%s][GOTOIF]\x20%s','map','message','stop','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','error','[%s][GOTOIF]\x20eval\x20error:\x20%s','validate','html-to-text','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','consequence','getMustacheRender','replace'];(function(_0x577e46,_0x542dee){var _0x5af20e=function(_0x4500a6){while(--_0x4500a6){_0x577e46['push'](_0x577e46['shift']());}};_0x5af20e(++_0x542dee);}(_0x888b,0x155));var _0xb888=function(_0x21a9d9,_0x4d5ac8){_0x21a9d9=_0x21a9d9-0x0;var _0x46adce=_0x888b[_0x21a9d9];return _0x46adce;};'use strict';var schema=require(_0xb888('0x0'));var _=require('lodash');var htmlToText=require(_0xb888('0x1'));var utils=require(_0xb888('0x2'));var logger=require(_0xb888('0x3'))(_0xb888('0x4'));var gotoif=schema({'condition':{'type':_0xb888('0x5'),'required':!![],'message':_0xb888('0x6')},'priorityTrue':{'type':'number','message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':'number','message':'priority\x20false\x20is\x20a\x20number'}});exports[_0xb888('0x7')]=function(_0x32b032,_0xd13d61){return function(_0x2cabbc){try{var _0x493db5={'condition':htmlToText['fromString'](utils[_0xb888('0x8')](_0xd13d61[0x0],this),{'wordwrap':![]})[_0xb888('0x9')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0xd13d61[0x1],'priorityFalse':_0xd13d61[0x2]};var _0x24570b=gotoif[_0xb888('0x0')](_0x493db5,{'typecast':!![]});if(_0x24570b[_0xb888('0xa')]){logger['error'](_0xb888('0xb'),_0x32b032,_[_0xb888('0xc')](_0x24570b,_0xb888('0xd'))['join'](',\x20'));_0x2cabbc[_0xb888('0xe')]();}else{try{var _0x1a24e7=eval('('+_0x493db5[_0xb888('0xf')]+')');var _0x345d15=_0x1a24e7?_0x493db5[_0xb888('0x10')]:_0x493db5[_0xb888('0x11')];logger[_0xb888('0x12')](_0xb888('0x13'),_0x32b032,_0x493db5[_0xb888('0xf')],_0x1a24e7,_0x345d15||'next');if(_0x345d15){var _0xf4f82c=_[_0xb888('0x14')](_0x2cabbc[_0xb888('0x15')](),{'p':_0x345d15});if(_0xf4f82c>=0x0){logger[_0xb888('0x12')](_0xb888('0x16'),_0x32b032,_0x345d15||_0xb888('0x17'),_0xf4f82c);_0x2cabbc['next'](_0xf4f82c);}else{logger[_0xb888('0x12')](_0xb888('0x18'),_0x32b032,_0x345d15||_0xb888('0x17'));_0x2cabbc[_0xb888('0xe')]();}}else{_0x2cabbc['next']();}}catch(_0x30cf76){logger[_0xb888('0x19')](_0xb888('0x1a'),_0x32b032,_0x30cf76[_0xb888('0xd')]);_0x2cabbc[_0xb888('0xe')]();}}}catch(_0x55fc58){logger[_0xb888('0x19')](_0xb888('0xb'),_0x32b032,JSON['stringify'](_0x55fc58));_0x2cabbc['stop']();}};};