595ab983a7f50ab9ef9f5187addbaa16d2ef5923
[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 _0x5b10=['[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','info','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','validate','lodash','html-to-text','./utils','../../../../config/logger','routing','string','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','error','[%s][GOTOIF]\x20%s','message','stop','condition','priorityTrue'];(function(_0x59211a,_0x6d794f){var _0xa75140=function(_0x111197){while(--_0x111197){_0x59211a['push'](_0x59211a['shift']());}};_0xa75140(++_0x6d794f);}(_0x5b10,0xf1));var _0x05b1=function(_0x1f690d,_0x196032){_0x1f690d=_0x1f690d-0x0;var _0x3cf980=_0x5b10[_0x1f690d];return _0x3cf980;};'use strict';var schema=require(_0x05b1('0x0'));var _=require(_0x05b1('0x1'));var htmlToText=require(_0x05b1('0x2'));var utils=require(_0x05b1('0x3'));var logger=require(_0x05b1('0x4'))(_0x05b1('0x5'));var gotoif=schema({'condition':{'type':_0x05b1('0x6'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x05b1('0x7'),'message':_0x05b1('0x8')},'priorityFalse':{'type':_0x05b1('0x7'),'message':_0x05b1('0x9')}});exports[_0x05b1('0xa')]=function(_0x195248,_0x21598e){return function(_0x3268b4){try{var _0x4c95fb={'condition':htmlToText[_0x05b1('0xb')](utils[_0x05b1('0xc')](_0x21598e[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x21598e[0x1],'priorityFalse':_0x21598e[0x2]};var _0xca46b0=gotoif[_0x05b1('0x0')](_0x4c95fb,{'typecast':!![]});if(_0xca46b0['length']){logger[_0x05b1('0xd')](_0x05b1('0xe'),_0x195248,_['map'](_0xca46b0,_0x05b1('0xf'))['join'](',\x20'));_0x3268b4[_0x05b1('0x10')]();}else{try{var _0x2170b4=eval('('+_0x4c95fb[_0x05b1('0x11')]+')');var _0x4be4e7=_0x2170b4?_0x4c95fb[_0x05b1('0x12')]:_0x4c95fb['priorityFalse'];logger['info'](_0x05b1('0x13'),_0x195248,_0x4c95fb[_0x05b1('0x11')],_0x2170b4,_0x4be4e7||_0x05b1('0x14'));if(_0x4be4e7){var _0x56a400=_['findIndex'](_0x3268b4['rules'](),{'p':_0x4be4e7});if(_0x56a400>=0x0){logger['info'](_0x05b1('0x15'),_0x195248,_0x4be4e7||_0x05b1('0x14'),_0x56a400);_0x3268b4[_0x05b1('0x14')](_0x56a400);}else{logger[_0x05b1('0x16')](_0x05b1('0x17'),_0x195248,_0x4be4e7||_0x05b1('0x14'));_0x3268b4[_0x05b1('0x10')]();}}else{_0x3268b4[_0x05b1('0x14')]();}}catch(_0xd98f47){logger['error'](_0x05b1('0x18'),_0x195248,_0xd98f47[_0x05b1('0xf')]);_0x3268b4['stop']();}}}catch(_0x186d83){logger[_0x05b1('0xd')](_0x05b1('0xe'),_0x195248,JSON[_0x05b1('0x19')](_0x186d83));_0x3268b4[_0x05b1('0x10')]();}};};