Built motion from commit da617fac.|2.6.6
[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 _0xa0ca=['condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','length','error','[%s][GOTOIF]\x20%s','map','join','stop','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','message','stringify','validate','lodash','html-to-text'];(function(_0x559aa4,_0x2a8b5b){var _0x46af01=function(_0x187999){while(--_0x187999){_0x559aa4['push'](_0x559aa4['shift']());}};_0x46af01(++_0x2a8b5b);}(_0xa0ca,0xe7));var _0xaa0c=function(_0x162252,_0x103380){_0x162252=_0x162252-0x0;var _0x44785b=_0xa0ca[_0x162252];return _0x44785b;};'use strict';var schema=require(_0xaa0c('0x0'));var _=require(_0xaa0c('0x1'));var htmlToText=require(_0xaa0c('0x2'));var utils=require('./utils');var logger=require('../../../../config/logger')('routing');var gotoif=schema({'condition':{'type':'string','required':!![],'message':_0xaa0c('0x3')},'priorityTrue':{'type':_0xaa0c('0x4'),'message':_0xaa0c('0x5')},'priorityFalse':{'type':_0xaa0c('0x4'),'message':_0xaa0c('0x6')}});exports[_0xaa0c('0x7')]=function(_0x3604db,_0x385d60){return function(_0x2b46ac){try{var _0x4514f3={'condition':htmlToText['fromString'](utils['getMustacheRender'](_0x385d60[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x385d60[0x1],'priorityFalse':_0x385d60[0x2]};var _0x2d4c92=gotoif[_0xaa0c('0x0')](_0x4514f3,{'typecast':!![]});if(_0x2d4c92[_0xaa0c('0x8')]){logger[_0xaa0c('0x9')](_0xaa0c('0xa'),_0x3604db,_[_0xaa0c('0xb')](_0x2d4c92,'message')[_0xaa0c('0xc')](',\x20'));_0x2b46ac[_0xaa0c('0xd')]();}else{try{var _0x3fbf45=eval('('+_0x4514f3[_0xaa0c('0xe')]+')');var _0x294086=_0x3fbf45?_0x4514f3[_0xaa0c('0xf')]:_0x4514f3[_0xaa0c('0x10')];logger[_0xaa0c('0x11')](_0xaa0c('0x12'),_0x3604db,_0x4514f3[_0xaa0c('0xe')],_0x3fbf45,_0x294086||_0xaa0c('0x13'));if(_0x294086){var _0x323f4c=_['findIndex'](_0x2b46ac[_0xaa0c('0x14')](),{'p':_0x294086});if(_0x323f4c>=0x0){logger['info'](_0xaa0c('0x15'),_0x3604db,_0x294086||_0xaa0c('0x13'),_0x323f4c);_0x2b46ac[_0xaa0c('0x13')](_0x323f4c);}else{logger['info'](_0xaa0c('0x16'),_0x3604db,_0x294086||'next');_0x2b46ac[_0xaa0c('0xd')]();}}else{_0x2b46ac[_0xaa0c('0x13')]();}}catch(_0x21ef2d){logger[_0xaa0c('0x9')](_0xaa0c('0x17'),_0x3604db,_0x21ef2d[_0xaa0c('0x18')]);_0x2b46ac[_0xaa0c('0xd')]();}}}catch(_0xa18446){logger[_0xaa0c('0x9')](_0xaa0c('0xa'),_0x3604db,JSON[_0xaa0c('0x19')](_0xa18446));_0x2b46ac[_0xaa0c('0xd')]();}};};