a7cc73dea0dc7f2db21a9e5a62bcf185cb00f8e1
[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 _0xbeaf=['number','priority\x20true\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','validate','error','[%s][GOTOIF]\x20%s','map','stop','condition','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','message','stringify','lodash','html-to-text','./utils','../../../../config/logger','routing'];(function(_0x45b575,_0x49a05a){var _0x5bdfa2=function(_0x3b117c){while(--_0x3b117c){_0x45b575['push'](_0x45b575['shift']());}};_0x5bdfa2(++_0x49a05a);}(_0xbeaf,0x119));var _0xfbea=function(_0x13d07a,_0x41efc3){_0x13d07a=_0x13d07a-0x0;var _0x5ee0ee=_0xbeaf[_0x13d07a];return _0x5ee0ee;};'use strict';var schema=require('validate');var _=require(_0xfbea('0x0'));var htmlToText=require(_0xfbea('0x1'));var utils=require(_0xfbea('0x2'));var logger=require(_0xfbea('0x3'))(_0xfbea('0x4'));var gotoif=schema({'condition':{'type':'string','required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0xfbea('0x5'),'message':_0xfbea('0x6')},'priorityFalse':{'type':'number','message':'priority\x20false\x20is\x20a\x20number'}});exports[_0xfbea('0x7')]=function(_0x2da2be,_0x5ead3c){return function(_0x4fd9f0){try{var _0x2d58a7={'condition':htmlToText[_0xfbea('0x8')](utils[_0xfbea('0x9')](_0x5ead3c[0x0],this),{'wordwrap':![]})[_0xfbea('0xa')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x5ead3c[0x1],'priorityFalse':_0x5ead3c[0x2]};var _0x2e93f9=gotoif[_0xfbea('0xb')](_0x2d58a7,{'typecast':!![]});if(_0x2e93f9['length']){logger[_0xfbea('0xc')](_0xfbea('0xd'),_0x2da2be,_[_0xfbea('0xe')](_0x2e93f9,'message')['join'](',\x20'));_0x4fd9f0[_0xfbea('0xf')]();}else{try{var _0x1f3834=eval('('+_0x2d58a7[_0xfbea('0x10')]+')');var _0x208c57=_0x1f3834?_0x2d58a7['priorityTrue']:_0x2d58a7[_0xfbea('0x11')];logger[_0xfbea('0x12')](_0xfbea('0x13'),_0x2da2be,_0x2d58a7[_0xfbea('0x10')],_0x1f3834,_0x208c57||_0xfbea('0x14'));if(_0x208c57){var _0x5a2ec0=_[_0xfbea('0x15')](_0x4fd9f0['rules'](),{'p':_0x208c57});if(_0x5a2ec0>=0x0){logger[_0xfbea('0x12')]('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x2da2be,_0x208c57||'next',_0x5a2ec0);_0x4fd9f0[_0xfbea('0x14')](_0x5a2ec0);}else{logger[_0xfbea('0x12')](_0xfbea('0x16'),_0x2da2be,_0x208c57||_0xfbea('0x14'));_0x4fd9f0[_0xfbea('0xf')]();}}else{_0x4fd9f0[_0xfbea('0x14')]();}}catch(_0x415de5){logger[_0xfbea('0xc')](_0xfbea('0x17'),_0x2da2be,_0x415de5[_0xfbea('0x18')]);_0x4fd9f0[_0xfbea('0xf')]();}}}catch(_0x4cdb0a){logger[_0xfbea('0xc')](_0xfbea('0xd'),_0x2da2be,JSON[_0xfbea('0x19')](_0x4cdb0a));_0x4fd9f0[_0xfbea('0xf')]();}};};