Built motion from commit (unavailable).|2.5.31
[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 _0xec09=['[%s][GOTOIF]\x20eval\x20error:\x20%s','validate','lodash','../../../../config/logger','string','number','priority\x20true\x20is\x20a\x20number','fromString','replace','length','error','[%s][GOTOIF]\x20%s','map','message','stop','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found'];(function(_0x559335,_0x3f211b){var _0x44f033=function(_0x1dce2b){while(--_0x1dce2b){_0x559335['push'](_0x559335['shift']());}};_0x44f033(++_0x3f211b);}(_0xec09,0xd9));var _0x9ec0=function(_0x55fec7,_0x33caf4){_0x55fec7=_0x55fec7-0x0;var _0x2474cc=_0xec09[_0x55fec7];return _0x2474cc;};'use strict';var schema=require(_0x9ec0('0x0'));var _=require(_0x9ec0('0x1'));var htmlToText=require('html-to-text');var utils=require('./utils');var logger=require(_0x9ec0('0x2'))('routing');var gotoif=schema({'condition':{'type':_0x9ec0('0x3'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x9ec0('0x4'),'message':_0x9ec0('0x5')},'priorityFalse':{'type':'number','message':'priority\x20false\x20is\x20a\x20number'}});exports['consequence']=function(_0x28b06f,_0x690bd4){return function(_0x38494e){try{var _0x90f949={'condition':htmlToText[_0x9ec0('0x6')](utils['getMustacheRender'](_0x690bd4[0x0],this),{'wordwrap':![]})[_0x9ec0('0x7')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x690bd4[0x1],'priorityFalse':_0x690bd4[0x2]};var _0x3f19bf=gotoif[_0x9ec0('0x0')](_0x90f949,{'typecast':!![]});if(_0x3f19bf[_0x9ec0('0x8')]){logger[_0x9ec0('0x9')](_0x9ec0('0xa'),_0x28b06f,_[_0x9ec0('0xb')](_0x3f19bf,_0x9ec0('0xc'))['join'](',\x20'));_0x38494e[_0x9ec0('0xd')]();}else{try{var _0x569528=eval('('+_0x90f949[_0x9ec0('0xe')]+')');var _0x54b375=_0x569528?_0x90f949[_0x9ec0('0xf')]:_0x90f949[_0x9ec0('0x10')];logger[_0x9ec0('0x11')](_0x9ec0('0x12'),_0x28b06f,_0x90f949[_0x9ec0('0xe')],_0x569528,_0x54b375||_0x9ec0('0x13'));if(_0x54b375){var _0x1807c0=_[_0x9ec0('0x14')](_0x38494e[_0x9ec0('0x15')](),{'p':_0x54b375});if(_0x1807c0>=0x0){logger[_0x9ec0('0x11')]('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x28b06f,_0x54b375||'next',_0x1807c0);_0x38494e[_0x9ec0('0x13')](_0x1807c0);}else{logger[_0x9ec0('0x11')](_0x9ec0('0x16'),_0x28b06f,_0x54b375||_0x9ec0('0x13'));_0x38494e[_0x9ec0('0xd')]();}}else{_0x38494e[_0x9ec0('0x13')]();}}catch(_0x1e023c){logger['error'](_0x9ec0('0x17'),_0x28b06f,_0x1e023c[_0x9ec0('0xc')]);_0x38494e[_0x9ec0('0xd')]();}}}catch(_0x3cbe04){logger['error']('[%s][GOTOIF]\x20%s',_0x28b06f,JSON['stringify'](_0x3cbe04));_0x38494e['stop']();}};};