c3a9b7a60ad60d96ade89f5e6fceb8d7d8d2094c
[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 _0xaabf=['html-to-text','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','error','[%s][GOTOIF]\x20%s','map','join','stop','condition','priorityFalse','[%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','[%s][GOTOIF]\x20eval\x20error:\x20%s','message','stringify','validate','lodash'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xaabf,0x153));var _0xfaab=function(_0x217d8a,_0x18dca0){_0x217d8a=_0x217d8a-0x0;var _0xbfc7db=_0xaabf[_0x217d8a];return _0xbfc7db;};'use strict';var schema=require(_0xfaab('0x0'));var _=require(_0xfaab('0x1'));var htmlToText=require(_0xfaab('0x2'));var utils=require('./utils');var logger=require(_0xfaab('0x3'))(_0xfaab('0x4'));var gotoif=schema({'condition':{'type':_0xfaab('0x5'),'required':!![],'message':_0xfaab('0x6')},'priorityTrue':{'type':_0xfaab('0x7'),'message':_0xfaab('0x8')},'priorityFalse':{'type':'number','message':_0xfaab('0x9')}});exports[_0xfaab('0xa')]=function(_0x20bc64,_0x6aa5da){return function(_0x207091){try{var _0x56d270={'condition':htmlToText[_0xfaab('0xb')](utils[_0xfaab('0xc')](_0x6aa5da[0x0],this),{'wordwrap':![]})[_0xfaab('0xd')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x6aa5da[0x1],'priorityFalse':_0x6aa5da[0x2]};var _0x17cb4e=gotoif[_0xfaab('0x0')](_0x56d270,{'typecast':!![]});if(_0x17cb4e['length']){logger[_0xfaab('0xe')](_0xfaab('0xf'),_0x20bc64,_[_0xfaab('0x10')](_0x17cb4e,'message')[_0xfaab('0x11')](',\x20'));_0x207091[_0xfaab('0x12')]();}else{try{var _0x4440dd=eval('('+_0x56d270[_0xfaab('0x13')]+')');var _0x544831=_0x4440dd?_0x56d270['priorityTrue']:_0x56d270[_0xfaab('0x14')];logger['info'](_0xfaab('0x15'),_0x20bc64,_0x56d270[_0xfaab('0x13')],_0x4440dd,_0x544831||'next');if(_0x544831){var _0x48b28b=_[_0xfaab('0x16')](_0x207091[_0xfaab('0x17')](),{'p':_0x544831});if(_0x48b28b>=0x0){logger[_0xfaab('0x18')](_0xfaab('0x19'),_0x20bc64,_0x544831||'next',_0x48b28b);_0x207091[_0xfaab('0x1a')](_0x48b28b);}else{logger[_0xfaab('0x18')](_0xfaab('0x1b'),_0x20bc64,_0x544831||'next');_0x207091['stop']();}}else{_0x207091[_0xfaab('0x1a')]();}}catch(_0x323b9c){logger[_0xfaab('0xe')](_0xfaab('0x1c'),_0x20bc64,_0x323b9c[_0xfaab('0x1d')]);_0x207091['stop']();}}}catch(_0x5b9e08){logger[_0xfaab('0xe')](_0xfaab('0xf'),_0x20bc64,JSON[_0xfaab('0x1e')](_0x5b9e08));_0x207091[_0xfaab('0x12')]();}};};