Built motion from commit (unavailable).|2.5.4
[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 _0xad68=['[%s][GOTOIF]\x20%s','map','message','join','stop','condition','next','findIndex','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','lodash','html-to-text','../../../../config/logger','routing','string','number','priority\x20false\x20is\x20a\x20number','consequence','replace','length','error'];(function(_0x1cb4b3,_0x4c3930){var _0x59c09d=function(_0x109bbe){while(--_0x109bbe){_0x1cb4b3['push'](_0x1cb4b3['shift']());}};_0x59c09d(++_0x4c3930);}(_0xad68,0xd5));var _0x8ad6=function(_0x230639,_0x20f428){_0x230639=_0x230639-0x0;var _0x5248d7=_0xad68[_0x230639];return _0x5248d7;};'use strict';var schema=require(_0x8ad6('0x0'));var _=require(_0x8ad6('0x1'));var htmlToText=require(_0x8ad6('0x2'));var utils=require('./utils');var logger=require(_0x8ad6('0x3'))(_0x8ad6('0x4'));var gotoif=schema({'condition':{'type':_0x8ad6('0x5'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x8ad6('0x6'),'message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':_0x8ad6('0x6'),'message':_0x8ad6('0x7')}});exports[_0x8ad6('0x8')]=function(_0x17c576,_0x386125){return function(_0x3e9c5d){try{var _0x542a6b={'condition':htmlToText['fromString'](utils['getMustacheRender'](_0x386125[0x0],this),{'wordwrap':![]})[_0x8ad6('0x9')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x386125[0x1],'priorityFalse':_0x386125[0x2]};var _0x58a5d9=gotoif[_0x8ad6('0x0')](_0x542a6b,{'typecast':!![]});if(_0x58a5d9[_0x8ad6('0xa')]){logger[_0x8ad6('0xb')](_0x8ad6('0xc'),_0x17c576,_[_0x8ad6('0xd')](_0x58a5d9,_0x8ad6('0xe'))[_0x8ad6('0xf')](',\x20'));_0x3e9c5d[_0x8ad6('0x10')]();}else{try{var _0x338f83=eval('('+_0x542a6b[_0x8ad6('0x11')]+')');var _0x31c711=_0x338f83?_0x542a6b['priorityTrue']:_0x542a6b['priorityFalse'];logger['info']('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0x17c576,_0x542a6b['condition'],_0x338f83,_0x31c711||_0x8ad6('0x12'));if(_0x31c711){var _0xd6041f=_[_0x8ad6('0x13')](_0x3e9c5d[_0x8ad6('0x14')](),{'p':_0x31c711});if(_0xd6041f>=0x0){logger[_0x8ad6('0x15')](_0x8ad6('0x16'),_0x17c576,_0x31c711||_0x8ad6('0x12'),_0xd6041f);_0x3e9c5d[_0x8ad6('0x12')](_0xd6041f);}else{logger[_0x8ad6('0x15')](_0x8ad6('0x17'),_0x17c576,_0x31c711||'next');_0x3e9c5d[_0x8ad6('0x10')]();}}else{_0x3e9c5d['next']();}}catch(_0xaa9d55){logger[_0x8ad6('0xb')](_0x8ad6('0x18'),_0x17c576,_0xaa9d55[_0x8ad6('0xe')]);_0x3e9c5d['stop']();}}}catch(_0x3e6c62){logger[_0x8ad6('0xb')]('[%s][GOTOIF]\x20%s',_0x17c576,JSON['stringify'](_0x3e6c62));_0x3e9c5d[_0x8ad6('0x10')]();}};};