01500feb54ee71544bc35eb62f83bc4d2f8d6a70
[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 _0xf629=['stop','priorityTrue','priorityFalse','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','condition','next','rules','info','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','html-to-text','./utils','../../../../config/logger','routing','string','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','validate','length','error','[%s][GOTOIF]\x20%s','map','message'];(function(_0x2f031d,_0x195e90){var _0x46962d=function(_0x527e7c){while(--_0x527e7c){_0x2f031d['push'](_0x2f031d['shift']());}};_0x46962d(++_0x195e90);}(_0xf629,0x1ce));var _0x9f62=function(_0x2b88f2,_0x408c2f){_0x2b88f2=_0x2b88f2-0x0;var _0xbf82a2=_0xf629[_0x2b88f2];return _0xbf82a2;};'use strict';var schema=require('validate');var _=require('lodash');var htmlToText=require(_0x9f62('0x0'));var utils=require(_0x9f62('0x1'));var logger=require(_0x9f62('0x2'))(_0x9f62('0x3'));var gotoif=schema({'condition':{'type':_0x9f62('0x4'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x9f62('0x5'),'message':_0x9f62('0x6')},'priorityFalse':{'type':'number','message':_0x9f62('0x7')}});exports[_0x9f62('0x8')]=function(_0x31e70f,_0x4e5327){return function(_0x55f778){try{var _0xf18d80={'condition':htmlToText[_0x9f62('0x9')](utils[_0x9f62('0xa')](_0x4e5327[0x0],this),{'wordwrap':![]})[_0x9f62('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x4e5327[0x1],'priorityFalse':_0x4e5327[0x2]};var _0x36e4b9=gotoif[_0x9f62('0xc')](_0xf18d80,{'typecast':!![]});if(_0x36e4b9[_0x9f62('0xd')]){logger[_0x9f62('0xe')](_0x9f62('0xf'),_0x31e70f,_[_0x9f62('0x10')](_0x36e4b9,_0x9f62('0x11'))['join'](',\x20'));_0x55f778[_0x9f62('0x12')]();}else{try{var _0x1dd5a=eval('('+_0xf18d80['condition']+')');var _0x3077fb=_0x1dd5a?_0xf18d80[_0x9f62('0x13')]:_0xf18d80[_0x9f62('0x14')];logger['info'](_0x9f62('0x15'),_0x31e70f,_0xf18d80[_0x9f62('0x16')],_0x1dd5a,_0x3077fb||_0x9f62('0x17'));if(_0x3077fb){var _0x195b88=_['findIndex'](_0x55f778[_0x9f62('0x18')](),{'p':_0x3077fb});if(_0x195b88>=0x0){logger[_0x9f62('0x19')](_0x9f62('0x1a'),_0x31e70f,_0x3077fb||_0x9f62('0x17'),_0x195b88);_0x55f778['next'](_0x195b88);}else{logger['info'](_0x9f62('0x1b'),_0x31e70f,_0x3077fb||_0x9f62('0x17'));_0x55f778[_0x9f62('0x12')]();}}else{_0x55f778[_0x9f62('0x17')]();}}catch(_0xe5da54){logger[_0x9f62('0xe')](_0x9f62('0x1c'),_0x31e70f,_0xe5da54[_0x9f62('0x11')]);_0x55f778[_0x9f62('0x12')]();}}}catch(_0x7878e1){logger[_0x9f62('0xe')](_0x9f62('0xf'),_0x31e70f,JSON[_0x9f62('0x1d')](_0x7878e1));_0x55f778[_0x9f62('0x12')]();}};};