Built motion from commit 092f8824.|2.5.49
[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 _0x06db=['consequence','fromString','getMustacheRender','replace','length','map','stop','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','condition','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','error','[%s][GOTOIF]\x20eval\x20error:\x20%s','message','[%s][GOTOIF]\x20%s','stringify','validate','lodash','html-to-text','../../../../config/logger','routing','string','number','priority\x20false\x20is\x20a\x20number'];(function(_0x9ad57e,_0x4900ac){var _0x3e3596=function(_0x40ac78){while(--_0x40ac78){_0x9ad57e['push'](_0x9ad57e['shift']());}};_0x3e3596(++_0x4900ac);}(_0x06db,0x106));var _0xb06d=function(_0x5950c6,_0x575c86){_0x5950c6=_0x5950c6-0x0;var _0xc2bc8a=_0x06db[_0x5950c6];return _0xc2bc8a;};'use strict';var schema=require(_0xb06d('0x0'));var _=require(_0xb06d('0x1'));var htmlToText=require(_0xb06d('0x2'));var utils=require('./utils');var logger=require(_0xb06d('0x3'))(_0xb06d('0x4'));var gotoif=schema({'condition':{'type':_0xb06d('0x5'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0xb06d('0x6'),'message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':_0xb06d('0x6'),'message':_0xb06d('0x7')}});exports[_0xb06d('0x8')]=function(_0x250495,_0x36f55c){return function(_0x1e5d9e){try{var _0x40fbae={'condition':htmlToText[_0xb06d('0x9')](utils[_0xb06d('0xa')](_0x36f55c[0x0],this),{'wordwrap':![]})[_0xb06d('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x36f55c[0x1],'priorityFalse':_0x36f55c[0x2]};var _0xe3ba0c=gotoif[_0xb06d('0x0')](_0x40fbae,{'typecast':!![]});if(_0xe3ba0c[_0xb06d('0xc')]){logger['error']('[%s][GOTOIF]\x20%s',_0x250495,_[_0xb06d('0xd')](_0xe3ba0c,'message')['join'](',\x20'));_0x1e5d9e[_0xb06d('0xe')]();}else{try{var _0x26d070=eval('('+_0x40fbae['condition']+')');var _0x26821a=_0x26d070?_0x40fbae[_0xb06d('0xf')]:_0x40fbae[_0xb06d('0x10')];logger[_0xb06d('0x11')](_0xb06d('0x12'),_0x250495,_0x40fbae[_0xb06d('0x13')],_0x26d070,_0x26821a||_0xb06d('0x14'));if(_0x26821a){var _0x26acca=_[_0xb06d('0x15')](_0x1e5d9e[_0xb06d('0x16')](),{'p':_0x26821a});if(_0x26acca>=0x0){logger[_0xb06d('0x11')](_0xb06d('0x17'),_0x250495,_0x26821a||_0xb06d('0x14'),_0x26acca);_0x1e5d9e[_0xb06d('0x14')](_0x26acca);}else{logger[_0xb06d('0x11')](_0xb06d('0x18'),_0x250495,_0x26821a||'next');_0x1e5d9e[_0xb06d('0xe')]();}}else{_0x1e5d9e[_0xb06d('0x14')]();}}catch(_0x2ad5e1){logger[_0xb06d('0x19')](_0xb06d('0x1a'),_0x250495,_0x2ad5e1[_0xb06d('0x1b')]);_0x1e5d9e[_0xb06d('0xe')]();}}}catch(_0x104ef8){logger[_0xb06d('0x19')](_0xb06d('0x1c'),_0x250495,JSON[_0xb06d('0x1d')](_0x104ef8));_0x1e5d9e['stop']();}};};