Built motion from commit (unavailable).|2.5.12
[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 _0xf1b1=['message','join','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','findIndex','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','stop','lodash','html-to-text','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','consequence','fromString','getMustacheRender','replace','validate','length','error','map'];(function(_0x53972a,_0xdd86a1){var _0x2d8aa9=function(_0x381551){while(--_0x381551){_0x53972a['push'](_0x53972a['shift']());}};_0x2d8aa9(++_0xdd86a1);}(_0xf1b1,0x1cf));var _0x1f1b=function(_0xb65ffb,_0x2cc0af){_0xb65ffb=_0xb65ffb-0x0;var _0x58f55c=_0xf1b1[_0xb65ffb];return _0x58f55c;};'use strict';var schema=require('validate');var _=require(_0x1f1b('0x0'));var htmlToText=require(_0x1f1b('0x1'));var utils=require('./utils');var logger=require('../../../../config/logger')('routing');var gotoif=schema({'condition':{'type':_0x1f1b('0x2'),'required':!![],'message':_0x1f1b('0x3')},'priorityTrue':{'type':'number','message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':'number','message':'priority\x20false\x20is\x20a\x20number'}});exports[_0x1f1b('0x4')]=function(_0x29409c,_0x55855b){return function(_0x221d44){try{var _0x2c74b1={'condition':htmlToText[_0x1f1b('0x5')](utils[_0x1f1b('0x6')](_0x55855b[0x0],this),{'wordwrap':![]})[_0x1f1b('0x7')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x55855b[0x1],'priorityFalse':_0x55855b[0x2]};var _0x5920c9=gotoif[_0x1f1b('0x8')](_0x2c74b1,{'typecast':!![]});if(_0x5920c9[_0x1f1b('0x9')]){logger[_0x1f1b('0xa')]('[%s][GOTOIF]\x20%s',_0x29409c,_[_0x1f1b('0xb')](_0x5920c9,_0x1f1b('0xc'))[_0x1f1b('0xd')](',\x20'));_0x221d44['stop']();}else{try{var _0x196fc8=eval('('+_0x2c74b1[_0x1f1b('0xe')]+')');var _0x42ea5a=_0x196fc8?_0x2c74b1[_0x1f1b('0xf')]:_0x2c74b1[_0x1f1b('0x10')];logger[_0x1f1b('0x11')](_0x1f1b('0x12'),_0x29409c,_0x2c74b1[_0x1f1b('0xe')],_0x196fc8,_0x42ea5a||'next');if(_0x42ea5a){var _0x5a4c78=_[_0x1f1b('0x13')](_0x221d44['rules'](),{'p':_0x42ea5a});if(_0x5a4c78>=0x0){logger['info'](_0x1f1b('0x14'),_0x29409c,_0x42ea5a||_0x1f1b('0x15'),_0x5a4c78);_0x221d44['next'](_0x5a4c78);}else{logger[_0x1f1b('0x11')](_0x1f1b('0x16'),_0x29409c,_0x42ea5a||_0x1f1b('0x15'));_0x221d44['stop']();}}else{_0x221d44[_0x1f1b('0x15')]();}}catch(_0x490d11){logger[_0x1f1b('0xa')](_0x1f1b('0x17'),_0x29409c,_0x490d11['message']);_0x221d44['stop']();}}}catch(_0x492277){logger[_0x1f1b('0xa')]('[%s][GOTOIF]\x20%s',_0x29409c,JSON['stringify'](_0x492277));_0x221d44[_0x1f1b('0x18')]();}};};