7624f906722691a14686bf702b87542b3f426f76
[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 _0x0951=['number','priority\x20false\x20is\x20a\x20number','consequence','replace','length','error','[%s][GOTOIF]\x20%s','map','message','join','stop','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stringify','validate','lodash','./utils','../../../../config/logger','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','priority\x20true\x20is\x20a\x20number'];(function(_0x5b1db5,_0x559cd7){var _0x39995c=function(_0x18c72f){while(--_0x18c72f){_0x5b1db5['push'](_0x5b1db5['shift']());}};_0x39995c(++_0x559cd7);}(_0x0951,0x172));var _0x1095=function(_0x57ccd4,_0x1f326d){_0x57ccd4=_0x57ccd4-0x0;var _0xe17b6e=_0x0951[_0x57ccd4];return _0xe17b6e;};'use strict';var schema=require(_0x1095('0x0'));var _=require(_0x1095('0x1'));var htmlToText=require('html-to-text');var utils=require(_0x1095('0x2'));var logger=require(_0x1095('0x3'))('routing');var gotoif=schema({'condition':{'type':_0x1095('0x4'),'required':!![],'message':_0x1095('0x5')},'priorityTrue':{'type':'number','message':_0x1095('0x6')},'priorityFalse':{'type':_0x1095('0x7'),'message':_0x1095('0x8')}});exports[_0x1095('0x9')]=function(_0x50d6a4,_0x37a2e7){return function(_0x12d525){try{var _0x3457ab={'condition':htmlToText['fromString'](utils['getMustacheRender'](_0x37a2e7[0x0],this),{'wordwrap':![]})[_0x1095('0xa')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x37a2e7[0x1],'priorityFalse':_0x37a2e7[0x2]};var _0x1c9679=gotoif[_0x1095('0x0')](_0x3457ab,{'typecast':!![]});if(_0x1c9679[_0x1095('0xb')]){logger[_0x1095('0xc')](_0x1095('0xd'),_0x50d6a4,_[_0x1095('0xe')](_0x1c9679,_0x1095('0xf'))[_0x1095('0x10')](',\x20'));_0x12d525[_0x1095('0x11')]();}else{try{var _0xf3049f=eval('('+_0x3457ab[_0x1095('0x12')]+')');var _0x589e19=_0xf3049f?_0x3457ab[_0x1095('0x13')]:_0x3457ab[_0x1095('0x14')];logger[_0x1095('0x15')](_0x1095('0x16'),_0x50d6a4,_0x3457ab['condition'],_0xf3049f,_0x589e19||_0x1095('0x17'));if(_0x589e19){var _0x4eaa9e=_[_0x1095('0x18')](_0x12d525[_0x1095('0x19')](),{'p':_0x589e19});if(_0x4eaa9e>=0x0){logger['info'](_0x1095('0x1a'),_0x50d6a4,_0x589e19||_0x1095('0x17'),_0x4eaa9e);_0x12d525[_0x1095('0x17')](_0x4eaa9e);}else{logger[_0x1095('0x15')](_0x1095('0x1b'),_0x50d6a4,_0x589e19||_0x1095('0x17'));_0x12d525[_0x1095('0x11')]();}}else{_0x12d525['next']();}}catch(_0x2e8c21){logger['error']('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x50d6a4,_0x2e8c21[_0x1095('0xf')]);_0x12d525[_0x1095('0x11')]();}}}catch(_0x7a7aff){logger[_0x1095('0xc')](_0x1095('0xd'),_0x50d6a4,JSON[_0x1095('0x1c')](_0x7a7aff));_0x12d525[_0x1095('0x11')]();}};};