4a2ada1232f54e76a1c2705e206d1d946437244c
[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 _0x7bea=['routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','length','map','message','stop','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','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','[%s][GOTOIF]\x20%s','stringify','validate','./utils'];(function(_0x49ca18,_0x5e6d05){var _0x145d54=function(_0x30b9be){while(--_0x30b9be){_0x49ca18['push'](_0x49ca18['shift']());}};_0x145d54(++_0x5e6d05);}(_0x7bea,0x103));var _0xa7be=function(_0x1bcc92,_0x4929b8){_0x1bcc92=_0x1bcc92-0x0;var _0x88406a=_0x7bea[_0x1bcc92];return _0x88406a;};'use strict';var schema=require(_0xa7be('0x0'));var _=require('lodash');var htmlToText=require('html-to-text');var utils=require(_0xa7be('0x1'));var logger=require('../../../../config/logger')(_0xa7be('0x2'));var gotoif=schema({'condition':{'type':_0xa7be('0x3'),'required':!![],'message':_0xa7be('0x4')},'priorityTrue':{'type':_0xa7be('0x5'),'message':_0xa7be('0x6')},'priorityFalse':{'type':_0xa7be('0x5'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0xa7be('0x7')]=function(_0x132f46,_0x45d84c){return function(_0x406cee){try{var _0x415250={'condition':htmlToText[_0xa7be('0x8')](utils[_0xa7be('0x9')](_0x45d84c[0x0],this),{'wordwrap':![]})[_0xa7be('0xa')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x45d84c[0x1],'priorityFalse':_0x45d84c[0x2]};var _0x23606b=gotoif['validate'](_0x415250,{'typecast':!![]});if(_0x23606b[_0xa7be('0xb')]){logger['error']('[%s][GOTOIF]\x20%s',_0x132f46,_[_0xa7be('0xc')](_0x23606b,_0xa7be('0xd'))['join'](',\x20'));_0x406cee[_0xa7be('0xe')]();}else{try{var _0x505d22=eval('('+_0x415250[_0xa7be('0xf')]+')');var _0x4ec18c=_0x505d22?_0x415250[_0xa7be('0x10')]:_0x415250[_0xa7be('0x11')];logger[_0xa7be('0x12')](_0xa7be('0x13'),_0x132f46,_0x415250['condition'],_0x505d22,_0x4ec18c||_0xa7be('0x14'));if(_0x4ec18c){var _0x9b6269=_[_0xa7be('0x15')](_0x406cee[_0xa7be('0x16')](),{'p':_0x4ec18c});if(_0x9b6269>=0x0){logger[_0xa7be('0x12')](_0xa7be('0x17'),_0x132f46,_0x4ec18c||_0xa7be('0x14'),_0x9b6269);_0x406cee[_0xa7be('0x14')](_0x9b6269);}else{logger[_0xa7be('0x12')](_0xa7be('0x18'),_0x132f46,_0x4ec18c||_0xa7be('0x14'));_0x406cee[_0xa7be('0xe')]();}}else{_0x406cee['next']();}}catch(_0x34783e){logger[_0xa7be('0x19')](_0xa7be('0x1a'),_0x132f46,_0x34783e[_0xa7be('0xd')]);_0x406cee[_0xa7be('0xe')]();}}}catch(_0x14a50f){logger[_0xa7be('0x19')](_0xa7be('0x1b'),_0x132f46,JSON[_0xa7be('0x1c')](_0x14a50f));_0x406cee['stop']();}};};