cb6704ccaf224dfc23697c6912d62b9e315da4d0
[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 _0xf8d1=['[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stop','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','validate','lodash','html-to-text','./utils','../../../../config/logger','routing','string','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','message','join','condition','priorityTrue','priorityFalse','info'];(function(_0x206dc5,_0x5819bb){var _0x30f9d0=function(_0x25d010){while(--_0x25d010){_0x206dc5['push'](_0x206dc5['shift']());}};_0x30f9d0(++_0x5819bb);}(_0xf8d1,0x19b));var _0x1f8d=function(_0x2b6c06,_0x4ef67c){_0x2b6c06=_0x2b6c06-0x0;var _0x25a792=_0xf8d1[_0x2b6c06];return _0x25a792;};'use strict';var schema=require(_0x1f8d('0x0'));var _=require(_0x1f8d('0x1'));var htmlToText=require(_0x1f8d('0x2'));var utils=require(_0x1f8d('0x3'));var logger=require(_0x1f8d('0x4'))(_0x1f8d('0x5'));var gotoif=schema({'condition':{'type':_0x1f8d('0x6'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x1f8d('0x7'),'message':_0x1f8d('0x8')},'priorityFalse':{'type':_0x1f8d('0x7'),'message':_0x1f8d('0x9')}});exports[_0x1f8d('0xa')]=function(_0x287f6f,_0x5811dd){return function(_0x140441){try{var _0xd1a64d={'condition':htmlToText[_0x1f8d('0xb')](utils[_0x1f8d('0xc')](_0x5811dd[0x0],this),{'wordwrap':![]})[_0x1f8d('0xd')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x5811dd[0x1],'priorityFalse':_0x5811dd[0x2]};var _0x4aae29=gotoif['validate'](_0xd1a64d,{'typecast':!![]});if(_0x4aae29[_0x1f8d('0xe')]){logger[_0x1f8d('0xf')](_0x1f8d('0x10'),_0x287f6f,_['map'](_0x4aae29,_0x1f8d('0x11'))[_0x1f8d('0x12')](',\x20'));_0x140441['stop']();}else{try{var _0x3c4345=eval('('+_0xd1a64d[_0x1f8d('0x13')]+')');var _0x14926f=_0x3c4345?_0xd1a64d[_0x1f8d('0x14')]:_0xd1a64d[_0x1f8d('0x15')];logger[_0x1f8d('0x16')](_0x1f8d('0x17'),_0x287f6f,_0xd1a64d[_0x1f8d('0x13')],_0x3c4345,_0x14926f||_0x1f8d('0x18'));if(_0x14926f){var _0x260d8d=_[_0x1f8d('0x19')](_0x140441['rules'](),{'p':_0x14926f});if(_0x260d8d>=0x0){logger[_0x1f8d('0x16')](_0x1f8d('0x1a'),_0x287f6f,_0x14926f||'next',_0x260d8d);_0x140441[_0x1f8d('0x18')](_0x260d8d);}else{logger[_0x1f8d('0x16')](_0x1f8d('0x1b'),_0x287f6f,_0x14926f||_0x1f8d('0x18'));_0x140441[_0x1f8d('0x1c')]();}}else{_0x140441['next']();}}catch(_0x197f60){logger['error'](_0x1f8d('0x1d'),_0x287f6f,_0x197f60[_0x1f8d('0x11')]);_0x140441[_0x1f8d('0x1c')]();}}}catch(_0x543c11){logger[_0x1f8d('0xf')]('[%s][GOTOIF]\x20%s',_0x287f6f,JSON[_0x1f8d('0x1e')](_0x543c11));_0x140441[_0x1f8d('0x1c')]();}};};