Built motion from commit 9d7072cc.|2.5.39
[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 _0x36ce=['findIndex','info','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stop','message','validate','lodash','html-to-text','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','map','join','condition','priorityTrue','priorityFalse','next'];(function(_0x52c294,_0x117a22){var _0x1df50d=function(_0x219693){while(--_0x219693){_0x52c294['push'](_0x52c294['shift']());}};_0x1df50d(++_0x117a22);}(_0x36ce,0x162));var _0xe36c=function(_0x20b5fd,_0x51d8e9){_0x20b5fd=_0x20b5fd-0x0;var _0x12767b=_0x36ce[_0x20b5fd];return _0x12767b;};'use strict';var schema=require(_0xe36c('0x0'));var _=require(_0xe36c('0x1'));var htmlToText=require(_0xe36c('0x2'));var utils=require(_0xe36c('0x3'));var logger=require(_0xe36c('0x4'))(_0xe36c('0x5'));var gotoif=schema({'condition':{'type':_0xe36c('0x6'),'required':!![],'message':_0xe36c('0x7')},'priorityTrue':{'type':_0xe36c('0x8'),'message':_0xe36c('0x9')},'priorityFalse':{'type':_0xe36c('0x8'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0xe36c('0xa')]=function(_0xec31fb,_0x1afcd2){return function(_0x258314){try{var _0x31aa89={'condition':htmlToText[_0xe36c('0xb')](utils[_0xe36c('0xc')](_0x1afcd2[0x0],this),{'wordwrap':![]})[_0xe36c('0xd')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x1afcd2[0x1],'priorityFalse':_0x1afcd2[0x2]};var _0x33e0d6=gotoif[_0xe36c('0x0')](_0x31aa89,{'typecast':!![]});if(_0x33e0d6[_0xe36c('0xe')]){logger[_0xe36c('0xf')](_0xe36c('0x10'),_0xec31fb,_[_0xe36c('0x11')](_0x33e0d6,'message')[_0xe36c('0x12')](',\x20'));_0x258314['stop']();}else{try{var _0x40b569=eval('('+_0x31aa89[_0xe36c('0x13')]+')');var _0x5aeb05=_0x40b569?_0x31aa89[_0xe36c('0x14')]:_0x31aa89[_0xe36c('0x15')];logger['info']('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0xec31fb,_0x31aa89[_0xe36c('0x13')],_0x40b569,_0x5aeb05||_0xe36c('0x16'));if(_0x5aeb05){var _0x9b6cf3=_[_0xe36c('0x17')](_0x258314['rules'](),{'p':_0x5aeb05});if(_0x9b6cf3>=0x0){logger[_0xe36c('0x18')](_0xe36c('0x19'),_0xec31fb,_0x5aeb05||'next',_0x9b6cf3);_0x258314[_0xe36c('0x16')](_0x9b6cf3);}else{logger[_0xe36c('0x18')](_0xe36c('0x1a'),_0xec31fb,_0x5aeb05||_0xe36c('0x16'));_0x258314[_0xe36c('0x1b')]();}}else{_0x258314['next']();}}catch(_0x5c2946){logger[_0xe36c('0xf')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0xec31fb,_0x5c2946[_0xe36c('0x1c')]);_0x258314[_0xe36c('0x1b')]();}}}catch(_0x473d97){logger[_0xe36c('0xf')]('[%s][GOTOIF]\x20%s',_0xec31fb,JSON['stringify'](_0x473d97));_0x258314[_0xe36c('0x1b')]();}};};