5739f42ca8288962df21a3cc2d0cdba77e1cf89d
[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 _0x9bb5=['html-to-text','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','fromString','getMustacheRender','replace','length','[%s][GOTOIF]\x20%s','map','join','stop','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','error','stringify','validate','lodash'];(function(_0x4be49f,_0x4f4dbf){var _0x39cfe8=function(_0x537aa6){while(--_0x537aa6){_0x4be49f['push'](_0x4be49f['shift']());}};_0x39cfe8(++_0x4f4dbf);}(_0x9bb5,0x12a));var _0x59bb=function(_0x1c1ad8,_0x42a963){_0x1c1ad8=_0x1c1ad8-0x0;var _0x471fc3=_0x9bb5[_0x1c1ad8];return _0x471fc3;};'use strict';var schema=require(_0x59bb('0x0'));var _=require(_0x59bb('0x1'));var htmlToText=require(_0x59bb('0x2'));var utils=require(_0x59bb('0x3'));var logger=require(_0x59bb('0x4'))(_0x59bb('0x5'));var gotoif=schema({'condition':{'type':_0x59bb('0x6'),'required':!![],'message':_0x59bb('0x7')},'priorityTrue':{'type':_0x59bb('0x8'),'message':_0x59bb('0x9')},'priorityFalse':{'type':_0x59bb('0x8'),'message':_0x59bb('0xa')}});exports['consequence']=function(_0x44fcc4,_0x8aabb1){return function(_0x247606){try{var _0x5a26d2={'condition':htmlToText[_0x59bb('0xb')](utils[_0x59bb('0xc')](_0x8aabb1[0x0],this),{'wordwrap':![]})[_0x59bb('0xd')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x8aabb1[0x1],'priorityFalse':_0x8aabb1[0x2]};var _0x3b4509=gotoif['validate'](_0x5a26d2,{'typecast':!![]});if(_0x3b4509[_0x59bb('0xe')]){logger['error'](_0x59bb('0xf'),_0x44fcc4,_[_0x59bb('0x10')](_0x3b4509,'message')[_0x59bb('0x11')](',\x20'));_0x247606[_0x59bb('0x12')]();}else{try{var _0x537fae=eval('('+_0x5a26d2[_0x59bb('0x13')]+')');var _0x122366=_0x537fae?_0x5a26d2[_0x59bb('0x14')]:_0x5a26d2[_0x59bb('0x15')];logger[_0x59bb('0x16')](_0x59bb('0x17'),_0x44fcc4,_0x5a26d2['condition'],_0x537fae,_0x122366||'next');if(_0x122366){var _0x359b1a=_['findIndex'](_0x247606[_0x59bb('0x18')](),{'p':_0x122366});if(_0x359b1a>=0x0){logger[_0x59bb('0x16')](_0x59bb('0x19'),_0x44fcc4,_0x122366||_0x59bb('0x1a'),_0x359b1a);_0x247606[_0x59bb('0x1a')](_0x359b1a);}else{logger[_0x59bb('0x16')](_0x59bb('0x1b'),_0x44fcc4,_0x122366||_0x59bb('0x1a'));_0x247606['stop']();}}else{_0x247606[_0x59bb('0x1a')]();}}catch(_0x54242b){logger[_0x59bb('0x1c')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x44fcc4,_0x54242b['message']);_0x247606[_0x59bb('0x12')]();}}}catch(_0x5c534c){logger['error'](_0x59bb('0xf'),_0x44fcc4,JSON[_0x59bb('0x1d')](_0x5c534c));_0x247606['stop']();}};};