7a50a10cc58b8eed6f729cda42c6965425f098bf
[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 _0x9b54=['next','rules','info','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','validate','html-to-text','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','consequence','fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','map','message','join','stop','priorityTrue','priorityFalse','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','condition'];(function(_0x23d1db,_0x59f7df){var _0x3635e7=function(_0x472ba9){while(--_0x472ba9){_0x23d1db['push'](_0x23d1db['shift']());}};_0x3635e7(++_0x59f7df);}(_0x9b54,0xb4));var _0x49b5=function(_0x3312be,_0x35903b){_0x3312be=_0x3312be-0x0;var _0x5154e6=_0x9b54[_0x3312be];return _0x5154e6;};'use strict';var schema=require(_0x49b5('0x0'));var _=require('lodash');var htmlToText=require(_0x49b5('0x1'));var utils=require(_0x49b5('0x2'));var logger=require(_0x49b5('0x3'))(_0x49b5('0x4'));var gotoif=schema({'condition':{'type':_0x49b5('0x5'),'required':!![],'message':_0x49b5('0x6')},'priorityTrue':{'type':_0x49b5('0x7'),'message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':_0x49b5('0x7'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0x49b5('0x8')]=function(_0x5c1a26,_0x44725f){return function(_0x1934dc){try{var _0x57eda9={'condition':htmlToText[_0x49b5('0x9')](utils[_0x49b5('0xa')](_0x44725f[0x0],this),{'wordwrap':![]})[_0x49b5('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x44725f[0x1],'priorityFalse':_0x44725f[0x2]};var _0xdb9f51=gotoif[_0x49b5('0x0')](_0x57eda9,{'typecast':!![]});if(_0xdb9f51[_0x49b5('0xc')]){logger[_0x49b5('0xd')](_0x49b5('0xe'),_0x5c1a26,_[_0x49b5('0xf')](_0xdb9f51,_0x49b5('0x10'))[_0x49b5('0x11')](',\x20'));_0x1934dc[_0x49b5('0x12')]();}else{try{var _0x25d43d=eval('('+_0x57eda9['condition']+')');var _0x1e484a=_0x25d43d?_0x57eda9[_0x49b5('0x13')]:_0x57eda9[_0x49b5('0x14')];logger['info'](_0x49b5('0x15'),_0x5c1a26,_0x57eda9[_0x49b5('0x16')],_0x25d43d,_0x1e484a||_0x49b5('0x17'));if(_0x1e484a){var _0x4e445e=_['findIndex'](_0x1934dc[_0x49b5('0x18')](),{'p':_0x1e484a});if(_0x4e445e>=0x0){logger[_0x49b5('0x19')](_0x49b5('0x1a'),_0x5c1a26,_0x1e484a||_0x49b5('0x17'),_0x4e445e);_0x1934dc[_0x49b5('0x17')](_0x4e445e);}else{logger[_0x49b5('0x19')](_0x49b5('0x1b'),_0x5c1a26,_0x1e484a||_0x49b5('0x17'));_0x1934dc[_0x49b5('0x12')]();}}else{_0x1934dc[_0x49b5('0x17')]();}}catch(_0x593669){logger[_0x49b5('0xd')](_0x49b5('0x1c'),_0x5c1a26,_0x593669['message']);_0x1934dc['stop']();}}}catch(_0x461b0d){logger[_0x49b5('0xd')](_0x49b5('0xe'),_0x5c1a26,JSON['stringify'](_0x461b0d));_0x1934dc[_0x49b5('0x12')]();}};};