Built motion from commit e1760111.|2.6.18
[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 _0x1b19=['stop','priorityTrue','priorityFalse','condition','info','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','[%s][GOTOIF]\x20%s','stringify','validate','lodash','html-to-text','./utils','../../../../config/logger','routing','number','priority\x20true\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','length','error','map','message','join'];(function(_0x8a969d,_0x339d9f){var _0x1d8dc7=function(_0x283ec0){while(--_0x283ec0){_0x8a969d['push'](_0x8a969d['shift']());}};_0x1d8dc7(++_0x339d9f);}(_0x1b19,0x97));var _0x91b1=function(_0x20910e,_0x28d48a){_0x20910e=_0x20910e-0x0;var _0x47fcee=_0x1b19[_0x20910e];return _0x47fcee;};'use strict';var schema=require(_0x91b1('0x0'));var _=require(_0x91b1('0x1'));var htmlToText=require(_0x91b1('0x2'));var utils=require(_0x91b1('0x3'));var logger=require(_0x91b1('0x4'))(_0x91b1('0x5'));var gotoif=schema({'condition':{'type':'string','required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x91b1('0x6'),'message':_0x91b1('0x7')},'priorityFalse':{'type':_0x91b1('0x6'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0x91b1('0x8')]=function(_0x3b5631,_0x2c686e){return function(_0x241096){try{var _0x4e3ebe={'condition':htmlToText[_0x91b1('0x9')](utils[_0x91b1('0xa')](_0x2c686e[0x0],this),{'wordwrap':![]})[_0x91b1('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x2c686e[0x1],'priorityFalse':_0x2c686e[0x2]};var _0xf2a0da=gotoif[_0x91b1('0x0')](_0x4e3ebe,{'typecast':!![]});if(_0xf2a0da[_0x91b1('0xc')]){logger[_0x91b1('0xd')]('[%s][GOTOIF]\x20%s',_0x3b5631,_[_0x91b1('0xe')](_0xf2a0da,_0x91b1('0xf'))[_0x91b1('0x10')](',\x20'));_0x241096[_0x91b1('0x11')]();}else{try{var _0x399137=eval('('+_0x4e3ebe['condition']+')');var _0x4dfef1=_0x399137?_0x4e3ebe[_0x91b1('0x12')]:_0x4e3ebe[_0x91b1('0x13')];logger['info']('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0x3b5631,_0x4e3ebe[_0x91b1('0x14')],_0x399137,_0x4dfef1||'next');if(_0x4dfef1){var _0x4c802b=_['findIndex'](_0x241096['rules'](),{'p':_0x4dfef1});if(_0x4c802b>=0x0){logger[_0x91b1('0x15')](_0x91b1('0x16'),_0x3b5631,_0x4dfef1||'next',_0x4c802b);_0x241096[_0x91b1('0x17')](_0x4c802b);}else{logger[_0x91b1('0x15')](_0x91b1('0x18'),_0x3b5631,_0x4dfef1||_0x91b1('0x17'));_0x241096[_0x91b1('0x11')]();}}else{_0x241096[_0x91b1('0x17')]();}}catch(_0x443c38){logger['error'](_0x91b1('0x19'),_0x3b5631,_0x443c38['message']);_0x241096['stop']();}}}catch(_0x4076f0){logger[_0x91b1('0xd')](_0x91b1('0x1a'),_0x3b5631,JSON[_0x91b1('0x1b')](_0x4076f0));_0x241096[_0x91b1('0x11')]();}};};