Built motion from commit d5e4af8c.|2.6.23
[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 _0x0a0b=['info','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','error','validate','lodash','html-to-text','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','priority\x20true\x20is\x20a\x20number','number','consequence','fromString','getMustacheRender','length','[%s][GOTOIF]\x20%s','map','message','stop','condition','priorityTrue','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','rules'];(function(_0x1b6186,_0x1ec7f2){var _0x186121=function(_0x1748a8){while(--_0x1748a8){_0x1b6186['push'](_0x1b6186['shift']());}};_0x186121(++_0x1ec7f2);}(_0x0a0b,0x199));var _0xb0a0=function(_0x165da1,_0x594868){_0x165da1=_0x165da1-0x0;var _0x322208=_0x0a0b[_0x165da1];return _0x322208;};'use strict';var schema=require(_0xb0a0('0x0'));var _=require(_0xb0a0('0x1'));var htmlToText=require(_0xb0a0('0x2'));var utils=require('./utils');var logger=require(_0xb0a0('0x3'))(_0xb0a0('0x4'));var gotoif=schema({'condition':{'type':_0xb0a0('0x5'),'required':!![],'message':_0xb0a0('0x6')},'priorityTrue':{'type':'number','message':_0xb0a0('0x7')},'priorityFalse':{'type':_0xb0a0('0x8'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0xb0a0('0x9')]=function(_0x3a3086,_0x37ebaf){return function(_0x374535){try{var _0x33aa41={'condition':htmlToText[_0xb0a0('0xa')](utils[_0xb0a0('0xb')](_0x37ebaf[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x37ebaf[0x1],'priorityFalse':_0x37ebaf[0x2]};var _0x16e2bd=gotoif['validate'](_0x33aa41,{'typecast':!![]});if(_0x16e2bd[_0xb0a0('0xc')]){logger['error'](_0xb0a0('0xd'),_0x3a3086,_[_0xb0a0('0xe')](_0x16e2bd,_0xb0a0('0xf'))['join'](',\x20'));_0x374535[_0xb0a0('0x10')]();}else{try{var _0x5c95cf=eval('('+_0x33aa41[_0xb0a0('0x11')]+')');var _0x5c8869=_0x5c95cf?_0x33aa41[_0xb0a0('0x12')]:_0x33aa41['priorityFalse'];logger['info'](_0xb0a0('0x13'),_0x3a3086,_0x33aa41[_0xb0a0('0x11')],_0x5c95cf,_0x5c8869||_0xb0a0('0x14'));if(_0x5c8869){var _0x336269=_[_0xb0a0('0x15')](_0x374535[_0xb0a0('0x16')](),{'p':_0x5c8869});if(_0x336269>=0x0){logger[_0xb0a0('0x17')](_0xb0a0('0x18'),_0x3a3086,_0x5c8869||_0xb0a0('0x14'),_0x336269);_0x374535[_0xb0a0('0x14')](_0x336269);}else{logger[_0xb0a0('0x17')](_0xb0a0('0x19'),_0x3a3086,_0x5c8869||'next');_0x374535[_0xb0a0('0x10')]();}}else{_0x374535[_0xb0a0('0x14')]();}}catch(_0x4d03cf){logger[_0xb0a0('0x1a')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x3a3086,_0x4d03cf['message']);_0x374535[_0xb0a0('0x10')]();}}}catch(_0x54e688){logger[_0xb0a0('0x1a')](_0xb0a0('0xd'),_0x3a3086,JSON['stringify'](_0x54e688));_0x374535[_0xb0a0('0x10')]();}};};