eb4967066cc06d9093c30a6e2ba3c39b4cd4f657
[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 _0xa2c1=['condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','priority\x20true\x20is\x20a\x20number','number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','message','join','stop','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','validate','lodash','./utils','../../../../config/logger','routing','string'];(function(_0x262dec,_0x108116){var _0x3969ef=function(_0x10fb84){while(--_0x10fb84){_0x262dec['push'](_0x262dec['shift']());}};_0x3969ef(++_0x108116);}(_0xa2c1,0x8b));var _0x1a2c=function(_0x260566,_0x581190){_0x260566=_0x260566-0x0;var _0x3711b7=_0xa2c1[_0x260566];return _0x3711b7;};'use strict';var schema=require(_0x1a2c('0x0'));var _=require(_0x1a2c('0x1'));var htmlToText=require('html-to-text');var utils=require(_0x1a2c('0x2'));var logger=require(_0x1a2c('0x3'))(_0x1a2c('0x4'));var gotoif=schema({'condition':{'type':_0x1a2c('0x5'),'required':!![],'message':_0x1a2c('0x6')},'priorityTrue':{'type':'number','message':_0x1a2c('0x7')},'priorityFalse':{'type':_0x1a2c('0x8'),'message':_0x1a2c('0x9')}});exports[_0x1a2c('0xa')]=function(_0x3de1b6,_0x1364ea){return function(_0x5eae99){try{var _0x366403={'condition':htmlToText[_0x1a2c('0xb')](utils[_0x1a2c('0xc')](_0x1364ea[0x0],this),{'wordwrap':![]})[_0x1a2c('0xd')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x1364ea[0x1],'priorityFalse':_0x1364ea[0x2]};var _0x99b4c2=gotoif['validate'](_0x366403,{'typecast':!![]});if(_0x99b4c2[_0x1a2c('0xe')]){logger[_0x1a2c('0xf')](_0x1a2c('0x10'),_0x3de1b6,_['map'](_0x99b4c2,_0x1a2c('0x11'))[_0x1a2c('0x12')](',\x20'));_0x5eae99[_0x1a2c('0x13')]();}else{try{var _0xb6ca40=eval('('+_0x366403[_0x1a2c('0x14')]+')');var _0x158fac=_0xb6ca40?_0x366403[_0x1a2c('0x15')]:_0x366403[_0x1a2c('0x16')];logger[_0x1a2c('0x17')](_0x1a2c('0x18'),_0x3de1b6,_0x366403['condition'],_0xb6ca40,_0x158fac||_0x1a2c('0x19'));if(_0x158fac){var _0x374c0a=_['findIndex'](_0x5eae99['rules'](),{'p':_0x158fac});if(_0x374c0a>=0x0){logger[_0x1a2c('0x17')]('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x3de1b6,_0x158fac||_0x1a2c('0x19'),_0x374c0a);_0x5eae99[_0x1a2c('0x19')](_0x374c0a);}else{logger['info'](_0x1a2c('0x1a'),_0x3de1b6,_0x158fac||_0x1a2c('0x19'));_0x5eae99[_0x1a2c('0x13')]();}}else{_0x5eae99[_0x1a2c('0x19')]();}}catch(_0x44428f){logger['error'](_0x1a2c('0x1b'),_0x3de1b6,_0x44428f[_0x1a2c('0x11')]);_0x5eae99[_0x1a2c('0x13')]();}}}catch(_0x108469){logger[_0x1a2c('0xf')]('[%s][GOTOIF]\x20%s',_0x3de1b6,JSON[_0x1a2c('0x1c')](_0x108469));_0x5eae99['stop']();}};};