Built motion from commit 9c91e9f5.|2.6.29
[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 _0x58eb=['priorityTrue','info','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','validate','lodash','html-to-text','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20false\x20is\x20a\x20number','fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','map','message','stop','condition'];(function(_0x25bad1,_0x4d8ede){var _0x4868c5=function(_0x30eee2){while(--_0x30eee2){_0x25bad1['push'](_0x25bad1['shift']());}};_0x4868c5(++_0x4d8ede);}(_0x58eb,0x6f));var _0xb58e=function(_0x16d10f,_0x2ba2d5){_0x16d10f=_0x16d10f-0x0;var _0x50c823=_0x58eb[_0x16d10f];return _0x50c823;};'use strict';var schema=require(_0xb58e('0x0'));var _=require(_0xb58e('0x1'));var htmlToText=require(_0xb58e('0x2'));var utils=require('./utils');var logger=require(_0xb58e('0x3'))(_0xb58e('0x4'));var gotoif=schema({'condition':{'type':_0xb58e('0x5'),'required':!![],'message':_0xb58e('0x6')},'priorityTrue':{'type':'number','message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':_0xb58e('0x7'),'message':_0xb58e('0x8')}});exports['consequence']=function(_0x419b42,_0x8efeb){return function(_0x13e832){try{var _0x4812a8={'condition':htmlToText[_0xb58e('0x9')](utils[_0xb58e('0xa')](_0x8efeb[0x0],this),{'wordwrap':![]})[_0xb58e('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x8efeb[0x1],'priorityFalse':_0x8efeb[0x2]};var _0x9b0f65=gotoif[_0xb58e('0x0')](_0x4812a8,{'typecast':!![]});if(_0x9b0f65[_0xb58e('0xc')]){logger[_0xb58e('0xd')](_0xb58e('0xe'),_0x419b42,_[_0xb58e('0xf')](_0x9b0f65,_0xb58e('0x10'))['join'](',\x20'));_0x13e832[_0xb58e('0x11')]();}else{try{var _0x59524b=eval('('+_0x4812a8[_0xb58e('0x12')]+')');var _0x5aad62=_0x59524b?_0x4812a8[_0xb58e('0x13')]:_0x4812a8['priorityFalse'];logger[_0xb58e('0x14')]('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0x419b42,_0x4812a8[_0xb58e('0x12')],_0x59524b,_0x5aad62||_0xb58e('0x15'));if(_0x5aad62){var _0x48ab24=_[_0xb58e('0x16')](_0x13e832[_0xb58e('0x17')](),{'p':_0x5aad62});if(_0x48ab24>=0x0){logger[_0xb58e('0x14')](_0xb58e('0x18'),_0x419b42,_0x5aad62||_0xb58e('0x15'),_0x48ab24);_0x13e832[_0xb58e('0x15')](_0x48ab24);}else{logger[_0xb58e('0x14')](_0xb58e('0x19'),_0x419b42,_0x5aad62||_0xb58e('0x15'));_0x13e832[_0xb58e('0x11')]();}}else{_0x13e832[_0xb58e('0x15')]();}}catch(_0x1d9577){logger[_0xb58e('0xd')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x419b42,_0x1d9577['message']);_0x13e832[_0xb58e('0x11')]();}}}catch(_0x45593f){logger[_0xb58e('0xd')]('[%s][GOTOIF]\x20%s',_0x419b42,JSON['stringify'](_0x45593f));_0x13e832[_0xb58e('0x11')]();}};};