Built motion from commit (unavailable).|2.3.1
[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 _0x7a12=['validate','lodash','html-to-text','./utils','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','consequence','fromString','getMustacheRender','length','[%s][GOTOIF]\x20%s','map','message','condition','priorityTrue','priorityFalse','info','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','error','[%s][GOTOIF]\x20eval\x20error:\x20%s','stop','stringify'];(function(_0x5aa9d6,_0x56eb8b){var _0x48f997=function(_0x2f53a0){while(--_0x2f53a0){_0x5aa9d6['push'](_0x5aa9d6['shift']());}};_0x48f997(++_0x56eb8b);}(_0x7a12,0x1c0));var _0x27a1=function(_0x272daf,_0x4619ff){_0x272daf=_0x272daf-0x0;var _0x523fee=_0x7a12[_0x272daf];return _0x523fee;};'use strict';var schema=require(_0x27a1('0x0'));var _=require(_0x27a1('0x1'));var htmlToText=require(_0x27a1('0x2'));var utils=require(_0x27a1('0x3'));var logger=require('../../../../config/logger')(_0x27a1('0x4'));var gotoif=schema({'condition':{'type':_0x27a1('0x5'),'required':!![],'message':_0x27a1('0x6')},'priorityTrue':{'type':_0x27a1('0x7'),'message':_0x27a1('0x8')},'priorityFalse':{'type':_0x27a1('0x7'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0x27a1('0x9')]=function(_0x64ccaf,_0x3784dd){return function(_0x1a341c){try{var _0x360a40={'condition':htmlToText[_0x27a1('0xa')](utils[_0x27a1('0xb')](_0x3784dd[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x3784dd[0x1],'priorityFalse':_0x3784dd[0x2]};var _0x4cd767=gotoif[_0x27a1('0x0')](_0x360a40,{'typecast':!![]});if(_0x4cd767[_0x27a1('0xc')]){logger['error'](_0x27a1('0xd'),_0x64ccaf,_[_0x27a1('0xe')](_0x4cd767,_0x27a1('0xf'))['join'](',\x20'));_0x1a341c['stop']();}else{try{var _0x191249=eval('('+_0x360a40[_0x27a1('0x10')]+')');var _0xf8ed51=_0x191249?_0x360a40[_0x27a1('0x11')]:_0x360a40[_0x27a1('0x12')];logger[_0x27a1('0x13')]('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0x64ccaf,_0x360a40['condition'],_0x191249,_0xf8ed51||_0x27a1('0x14'));if(_0xf8ed51){var _0x17df6a=_[_0x27a1('0x15')](_0x1a341c[_0x27a1('0x16')](),{'p':_0xf8ed51});if(_0x17df6a>=0x0){logger['info'](_0x27a1('0x17'),_0x64ccaf,_0xf8ed51||_0x27a1('0x14'),_0x17df6a);_0x1a341c[_0x27a1('0x14')](_0x17df6a);}else{logger[_0x27a1('0x13')]('[%s][GOTOIF]\x20priority\x20%s\x20not\x20found',_0x64ccaf,_0xf8ed51||'next');_0x1a341c['stop']();}}else{_0x1a341c[_0x27a1('0x14')]();}}catch(_0x1ac7ec){logger[_0x27a1('0x18')](_0x27a1('0x19'),_0x64ccaf,_0x1ac7ec[_0x27a1('0xf')]);_0x1a341c[_0x27a1('0x1a')]();}}}catch(_0x3d7e89){logger['error'](_0x27a1('0xd'),_0x64ccaf,JSON[_0x27a1('0x1b')](_0x3d7e89));_0x1a341c[_0x27a1('0x1a')]();}};};