Built motion from commit (unavailable).|2.5.4
[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 _0x0529=['condition','next','rules','info','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','error','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','validate','lodash','html-to-text','routing','number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','length','message','join','stop','priorityTrue','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s'];(function(_0x494022,_0xdc326c){var _0xfb72f0=function(_0x10cd99){while(--_0x10cd99){_0x494022['push'](_0x494022['shift']());}};_0xfb72f0(++_0xdc326c);}(_0x0529,0x1e9));var _0x9052=function(_0x49b2fc,_0x36ca03){_0x49b2fc=_0x49b2fc-0x0;var _0x1f0a44=_0x0529[_0x49b2fc];return _0x1f0a44;};'use strict';var schema=require(_0x9052('0x0'));var _=require(_0x9052('0x1'));var htmlToText=require(_0x9052('0x2'));var utils=require('./utils');var logger=require('../../../../config/logger')(_0x9052('0x3'));var gotoif=schema({'condition':{'type':'string','required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x9052('0x4'),'message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':_0x9052('0x4'),'message':_0x9052('0x5')}});exports[_0x9052('0x6')]=function(_0x46258a,_0x2f2a0f){return function(_0x3bd4dc){try{var _0x51c273={'condition':htmlToText[_0x9052('0x7')](utils[_0x9052('0x8')](_0x2f2a0f[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x2f2a0f[0x1],'priorityFalse':_0x2f2a0f[0x2]};var _0x26ab6a=gotoif['validate'](_0x51c273,{'typecast':!![]});if(_0x26ab6a[_0x9052('0x9')]){logger['error']('[%s][GOTOIF]\x20%s',_0x46258a,_['map'](_0x26ab6a,_0x9052('0xa'))[_0x9052('0xb')](',\x20'));_0x3bd4dc[_0x9052('0xc')]();}else{try{var _0x10741d=eval('('+_0x51c273['condition']+')');var _0x445f7b=_0x10741d?_0x51c273[_0x9052('0xd')]:_0x51c273['priorityFalse'];logger['info'](_0x9052('0xe'),_0x46258a,_0x51c273[_0x9052('0xf')],_0x10741d,_0x445f7b||_0x9052('0x10'));if(_0x445f7b){var _0x5b9ee1=_['findIndex'](_0x3bd4dc[_0x9052('0x11')](),{'p':_0x445f7b});if(_0x5b9ee1>=0x0){logger[_0x9052('0x12')](_0x9052('0x13'),_0x46258a,_0x445f7b||_0x9052('0x10'),_0x5b9ee1);_0x3bd4dc['next'](_0x5b9ee1);}else{logger[_0x9052('0x12')](_0x9052('0x14'),_0x46258a,_0x445f7b||_0x9052('0x10'));_0x3bd4dc[_0x9052('0xc')]();}}else{_0x3bd4dc[_0x9052('0x10')]();}}catch(_0x2b25bf){logger[_0x9052('0x15')](_0x9052('0x16'),_0x46258a,_0x2b25bf[_0x9052('0xa')]);_0x3bd4dc[_0x9052('0xc')]();}}}catch(_0x48de39){logger[_0x9052('0x15')]('[%s][GOTOIF]\x20%s',_0x46258a,JSON[_0x9052('0x17')](_0x48de39));_0x3bd4dc['stop']();}};};