8c72730ed16fc16945c023ef286ebc309ddf8b80
[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 _0x1664=['priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','map','message','join','priorityFalse','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','condition','next','findIndex','rules','info','[%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','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number'];(function(_0x491a7f,_0x28bb80){var _0x3d8f44=function(_0xdaa716){while(--_0xdaa716){_0x491a7f['push'](_0x491a7f['shift']());}};_0x3d8f44(++_0x28bb80);}(_0x1664,0x1a4));var _0x4166=function(_0x4fbfd9,_0x3ab91a){_0x4fbfd9=_0x4fbfd9-0x0;var _0x31dc94=_0x1664[_0x4fbfd9];return _0x31dc94;};'use strict';var schema=require(_0x4166('0x0'));var _=require(_0x4166('0x1'));var htmlToText=require(_0x4166('0x2'));var utils=require(_0x4166('0x3'));var logger=require(_0x4166('0x4'))(_0x4166('0x5'));var gotoif=schema({'condition':{'type':_0x4166('0x6'),'required':!![],'message':_0x4166('0x7')},'priorityTrue':{'type':_0x4166('0x8'),'message':_0x4166('0x9')},'priorityFalse':{'type':'number','message':_0x4166('0xa')}});exports[_0x4166('0xb')]=function(_0x1280b9,_0x5a6a3c){return function(_0x4c1bbf){try{var _0x30dd19={'condition':htmlToText[_0x4166('0xc')](utils[_0x4166('0xd')](_0x5a6a3c[0x0],this),{'wordwrap':![]})[_0x4166('0xe')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x5a6a3c[0x1],'priorityFalse':_0x5a6a3c[0x2]};var _0x5d3b78=gotoif[_0x4166('0x0')](_0x30dd19,{'typecast':!![]});if(_0x5d3b78[_0x4166('0xf')]){logger[_0x4166('0x10')](_0x4166('0x11'),_0x1280b9,_[_0x4166('0x12')](_0x5d3b78,_0x4166('0x13'))[_0x4166('0x14')](',\x20'));_0x4c1bbf['stop']();}else{try{var _0x45b682=eval('('+_0x30dd19['condition']+')');var _0x542674=_0x45b682?_0x30dd19['priorityTrue']:_0x30dd19[_0x4166('0x15')];logger['info'](_0x4166('0x16'),_0x1280b9,_0x30dd19[_0x4166('0x17')],_0x45b682,_0x542674||_0x4166('0x18'));if(_0x542674){var _0x379e41=_[_0x4166('0x19')](_0x4c1bbf[_0x4166('0x1a')](),{'p':_0x542674});if(_0x379e41>=0x0){logger[_0x4166('0x1b')](_0x4166('0x1c'),_0x1280b9,_0x542674||_0x4166('0x18'),_0x379e41);_0x4c1bbf[_0x4166('0x18')](_0x379e41);}else{logger[_0x4166('0x1b')](_0x4166('0x1d'),_0x1280b9,_0x542674||_0x4166('0x18'));_0x4c1bbf[_0x4166('0x1e')]();}}else{_0x4c1bbf[_0x4166('0x18')]();}}catch(_0x205272){logger['error'](_0x4166('0x1f'),_0x1280b9,_0x205272['message']);_0x4c1bbf[_0x4166('0x1e')]();}}}catch(_0x3b8ea4){logger['error'](_0x4166('0x11'),_0x1280b9,JSON[_0x4166('0x20')](_0x3b8ea4));_0x4c1bbf['stop']();}};};