Built motion from commit (unavailable).|2.5.11
[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 _0x4034=['priority\x20false\x20is\x20a\x20number','consequence','fromString','replace','length','error','[%s][GOTOIF]\x20%s','map','stop','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','condition','next','rules','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','message','stringify','validate','lodash','html-to-text','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number'];(function(_0x1bf809,_0x536f55){var _0x1caa4e=function(_0x9f9636){while(--_0x9f9636){_0x1bf809['push'](_0x1bf809['shift']());}};_0x1caa4e(++_0x536f55);}(_0x4034,0x136));var _0x4403=function(_0x17bcce,_0x39ec4a){_0x17bcce=_0x17bcce-0x0;var _0x47fccb=_0x4034[_0x17bcce];return _0x47fccb;};'use strict';var schema=require(_0x4403('0x0'));var _=require(_0x4403('0x1'));var htmlToText=require(_0x4403('0x2'));var utils=require('./utils');var logger=require(_0x4403('0x3'))(_0x4403('0x4'));var gotoif=schema({'condition':{'type':_0x4403('0x5'),'required':!![],'message':_0x4403('0x6')},'priorityTrue':{'type':_0x4403('0x7'),'message':_0x4403('0x8')},'priorityFalse':{'type':_0x4403('0x7'),'message':_0x4403('0x9')}});exports[_0x4403('0xa')]=function(_0xe58756,_0x536b7e){return function(_0x3af9d7){try{var _0x316ac2={'condition':htmlToText[_0x4403('0xb')](utils['getMustacheRender'](_0x536b7e[0x0],this),{'wordwrap':![]})[_0x4403('0xc')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x536b7e[0x1],'priorityFalse':_0x536b7e[0x2]};var _0x5bfc2f=gotoif[_0x4403('0x0')](_0x316ac2,{'typecast':!![]});if(_0x5bfc2f[_0x4403('0xd')]){logger[_0x4403('0xe')](_0x4403('0xf'),_0xe58756,_[_0x4403('0x10')](_0x5bfc2f,'message')['join'](',\x20'));_0x3af9d7[_0x4403('0x11')]();}else{try{var _0x539b16=eval('('+_0x316ac2['condition']+')');var _0xaef824=_0x539b16?_0x316ac2[_0x4403('0x12')]:_0x316ac2[_0x4403('0x13')];logger[_0x4403('0x14')](_0x4403('0x15'),_0xe58756,_0x316ac2[_0x4403('0x16')],_0x539b16,_0xaef824||_0x4403('0x17'));if(_0xaef824){var _0x15fb96=_['findIndex'](_0x3af9d7[_0x4403('0x18')](),{'p':_0xaef824});if(_0x15fb96>=0x0){logger[_0x4403('0x14')]('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0xe58756,_0xaef824||_0x4403('0x17'),_0x15fb96);_0x3af9d7[_0x4403('0x17')](_0x15fb96);}else{logger[_0x4403('0x14')](_0x4403('0x19'),_0xe58756,_0xaef824||_0x4403('0x17'));_0x3af9d7[_0x4403('0x11')]();}}else{_0x3af9d7[_0x4403('0x17')]();}}catch(_0x45bad6){logger[_0x4403('0xe')](_0x4403('0x1a'),_0xe58756,_0x45bad6[_0x4403('0x1b')]);_0x3af9d7[_0x4403('0x11')]();}}}catch(_0x2639b3){logger[_0x4403('0xe')]('[%s][GOTOIF]\x20%s',_0xe58756,JSON[_0x4403('0x1c')](_0x2639b3));_0x3af9d7[_0x4403('0x11')]();}};};