Built motion from commit (unavailable).|2.5.14
[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 _0x30e0=['findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','stop','stringify','validate','lodash','./utils','../../../../config/logger','string','number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','map','message','join','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','condition','next'];(function(_0x3ebb04,_0x1a63a6){var _0x535db0=function(_0x651fb4){while(--_0x651fb4){_0x3ebb04['push'](_0x3ebb04['shift']());}};_0x535db0(++_0x1a63a6);}(_0x30e0,0x115));var _0x030e=function(_0x212b03,_0x1f1b50){_0x212b03=_0x212b03-0x0;var _0x423115=_0x30e0[_0x212b03];return _0x423115;};'use strict';var schema=require(_0x030e('0x0'));var _=require(_0x030e('0x1'));var htmlToText=require('html-to-text');var utils=require(_0x030e('0x2'));var logger=require(_0x030e('0x3'))('routing');var gotoif=schema({'condition':{'type':_0x030e('0x4'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x030e('0x5'),'message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':'number','message':_0x030e('0x6')}});exports[_0x030e('0x7')]=function(_0x3c7026,_0x62ef97){return function(_0x2bb56e){try{var _0x39d7b2={'condition':htmlToText[_0x030e('0x8')](utils[_0x030e('0x9')](_0x62ef97[0x0],this),{'wordwrap':![]})[_0x030e('0xa')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x62ef97[0x1],'priorityFalse':_0x62ef97[0x2]};var _0x154bee=gotoif['validate'](_0x39d7b2,{'typecast':!![]});if(_0x154bee[_0x030e('0xb')]){logger[_0x030e('0xc')](_0x030e('0xd'),_0x3c7026,_[_0x030e('0xe')](_0x154bee,_0x030e('0xf'))[_0x030e('0x10')](',\x20'));_0x2bb56e['stop']();}else{try{var _0x5514b7=eval('('+_0x39d7b2['condition']+')');var _0x4855bf=_0x5514b7?_0x39d7b2[_0x030e('0x11')]:_0x39d7b2[_0x030e('0x12')];logger[_0x030e('0x13')](_0x030e('0x14'),_0x3c7026,_0x39d7b2[_0x030e('0x15')],_0x5514b7,_0x4855bf||_0x030e('0x16'));if(_0x4855bf){var _0x66c264=_[_0x030e('0x17')](_0x2bb56e[_0x030e('0x18')](),{'p':_0x4855bf});if(_0x66c264>=0x0){logger['info'](_0x030e('0x19'),_0x3c7026,_0x4855bf||'next',_0x66c264);_0x2bb56e[_0x030e('0x16')](_0x66c264);}else{logger['info'](_0x030e('0x1a'),_0x3c7026,_0x4855bf||_0x030e('0x16'));_0x2bb56e['stop']();}}else{_0x2bb56e[_0x030e('0x16')]();}}catch(_0xa8f7a3){logger[_0x030e('0xc')](_0x030e('0x1b'),_0x3c7026,_0xa8f7a3[_0x030e('0xf')]);_0x2bb56e[_0x030e('0x1c')]();}}}catch(_0x5e8742){logger['error'](_0x030e('0xd'),_0x3c7026,JSON[_0x030e('0x1d')](_0x5e8742));_0x2bb56e[_0x030e('0x1c')]();}};};