Built motion from commit f0a64034.|2.6.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 _0x8921=['routing','string','number','priority\x20false\x20is\x20a\x20number','consequence','fromString','length','error','[%s][GOTOIF]\x20%s','map','message','stop','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','condition','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','stringify','validate','lodash','html-to-text','./utils','../../../../config/logger'];(function(_0x16325e,_0x459569){var _0xd75bb1=function(_0xfe7ba3){while(--_0xfe7ba3){_0x16325e['push'](_0x16325e['shift']());}};_0xd75bb1(++_0x459569);}(_0x8921,0x124));var _0x1892=function(_0x2ae79e,_0x43f911){_0x2ae79e=_0x2ae79e-0x0;var _0x3228b8=_0x8921[_0x2ae79e];return _0x3228b8;};'use strict';var schema=require(_0x1892('0x0'));var _=require(_0x1892('0x1'));var htmlToText=require(_0x1892('0x2'));var utils=require(_0x1892('0x3'));var logger=require(_0x1892('0x4'))(_0x1892('0x5'));var gotoif=schema({'condition':{'type':_0x1892('0x6'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x1892('0x7'),'message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':_0x1892('0x7'),'message':_0x1892('0x8')}});exports[_0x1892('0x9')]=function(_0x80a760,_0x115a57){return function(_0x34a75d){try{var _0x57a88f={'condition':htmlToText[_0x1892('0xa')](utils['getMustacheRender'](_0x115a57[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x115a57[0x1],'priorityFalse':_0x115a57[0x2]};var _0x33d284=gotoif[_0x1892('0x0')](_0x57a88f,{'typecast':!![]});if(_0x33d284[_0x1892('0xb')]){logger[_0x1892('0xc')](_0x1892('0xd'),_0x80a760,_[_0x1892('0xe')](_0x33d284,_0x1892('0xf'))['join'](',\x20'));_0x34a75d[_0x1892('0x10')]();}else{try{var _0x39d0bd=eval('('+_0x57a88f['condition']+')');var _0x359e9f=_0x39d0bd?_0x57a88f[_0x1892('0x11')]:_0x57a88f[_0x1892('0x12')];logger[_0x1892('0x13')](_0x1892('0x14'),_0x80a760,_0x57a88f[_0x1892('0x15')],_0x39d0bd,_0x359e9f||_0x1892('0x16'));if(_0x359e9f){var _0x441586=_[_0x1892('0x17')](_0x34a75d[_0x1892('0x18')](),{'p':_0x359e9f});if(_0x441586>=0x0){logger[_0x1892('0x13')](_0x1892('0x19'),_0x80a760,_0x359e9f||_0x1892('0x16'),_0x441586);_0x34a75d['next'](_0x441586);}else{logger[_0x1892('0x13')]('[%s][GOTOIF]\x20priority\x20%s\x20not\x20found',_0x80a760,_0x359e9f||_0x1892('0x16'));_0x34a75d[_0x1892('0x10')]();}}else{_0x34a75d[_0x1892('0x16')]();}}catch(_0x34b7f2){logger[_0x1892('0xc')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x80a760,_0x34b7f2[_0x1892('0xf')]);_0x34a75d[_0x1892('0x10')]();}}}catch(_0x59e3f3){logger['error'](_0x1892('0xd'),_0x80a760,JSON[_0x1892('0x1a')](_0x59e3f3));_0x34a75d[_0x1892('0x10')]();}};};