42f8335d8e3040b86d1eebe4d4a394bf2f3dc11e
[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 _0xb9df=['condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','consequence','getMustacheRender','replace','error','[%s][GOTOIF]\x20%s','message','join','condition','priorityTrue','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','findIndex','rules','info','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stop','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','validate','lodash','html-to-text','./utils','routing','string'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xb9df,0x123));var _0xfb9d=function(_0x5aca9d,_0xfccf0d){_0x5aca9d=_0x5aca9d-0x0;var _0x3f81eb=_0xb9df[_0x5aca9d];return _0x3f81eb;};'use strict';var schema=require(_0xfb9d('0x0'));var _=require(_0xfb9d('0x1'));var htmlToText=require(_0xfb9d('0x2'));var utils=require(_0xfb9d('0x3'));var logger=require('../../../../config/logger')(_0xfb9d('0x4'));var gotoif=schema({'condition':{'type':_0xfb9d('0x5'),'required':!![],'message':_0xfb9d('0x6')},'priorityTrue':{'type':'number','message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':_0xfb9d('0x7'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0xfb9d('0x8')]=function(_0x79481a,_0x38ef36){return function(_0x26b9a8){try{var _0x526df3={'condition':htmlToText['fromString'](utils[_0xfb9d('0x9')](_0x38ef36[0x0],this),{'wordwrap':![]})[_0xfb9d('0xa')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x38ef36[0x1],'priorityFalse':_0x38ef36[0x2]};var _0x85e52e=gotoif['validate'](_0x526df3,{'typecast':!![]});if(_0x85e52e['length']){logger[_0xfb9d('0xb')](_0xfb9d('0xc'),_0x79481a,_['map'](_0x85e52e,_0xfb9d('0xd'))[_0xfb9d('0xe')](',\x20'));_0x26b9a8['stop']();}else{try{var _0x421627=eval('('+_0x526df3[_0xfb9d('0xf')]+')');var _0x2ad7be=_0x421627?_0x526df3[_0xfb9d('0x10')]:_0x526df3['priorityFalse'];logger['info'](_0xfb9d('0x11'),_0x79481a,_0x526df3[_0xfb9d('0xf')],_0x421627,_0x2ad7be||'next');if(_0x2ad7be){var _0x48e97b=_[_0xfb9d('0x12')](_0x26b9a8[_0xfb9d('0x13')](),{'p':_0x2ad7be});if(_0x48e97b>=0x0){logger[_0xfb9d('0x14')](_0xfb9d('0x15'),_0x79481a,_0x2ad7be||_0xfb9d('0x16'),_0x48e97b);_0x26b9a8[_0xfb9d('0x16')](_0x48e97b);}else{logger[_0xfb9d('0x14')](_0xfb9d('0x17'),_0x79481a,_0x2ad7be||_0xfb9d('0x16'));_0x26b9a8[_0xfb9d('0x18')]();}}else{_0x26b9a8['next']();}}catch(_0x58ab1d){logger[_0xfb9d('0xb')](_0xfb9d('0x19'),_0x79481a,_0x58ab1d[_0xfb9d('0xd')]);_0x26b9a8[_0xfb9d('0x18')]();}}}catch(_0x189ab2){logger[_0xfb9d('0xb')](_0xfb9d('0xc'),_0x79481a,JSON[_0xfb9d('0x1a')](_0x189ab2));_0x26b9a8[_0xfb9d('0x18')]();}};};