Built motion from commit 10af8726.|2.6.34
[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 _0x6ccb=['[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stop','stringify','validate','lodash','./utils','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20false\x20is\x20a\x20number','fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','map','message','join','condition','priorityTrue','priorityFalse','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','rules','info'];(function(_0x2a7eb9,_0x4c6cac){var _0x448808=function(_0x34d55c){while(--_0x34d55c){_0x2a7eb9['push'](_0x2a7eb9['shift']());}};_0x448808(++_0x4c6cac);}(_0x6ccb,0x109));var _0xb6cc=function(_0x50d5a5,_0x423e3c){_0x50d5a5=_0x50d5a5-0x0;var _0x2561f6=_0x6ccb[_0x50d5a5];return _0x2561f6;};'use strict';var schema=require(_0xb6cc('0x0'));var _=require(_0xb6cc('0x1'));var htmlToText=require('html-to-text');var utils=require(_0xb6cc('0x2'));var logger=require('../../../../config/logger')(_0xb6cc('0x3'));var gotoif=schema({'condition':{'type':_0xb6cc('0x4'),'required':!![],'message':_0xb6cc('0x5')},'priorityTrue':{'type':_0xb6cc('0x6'),'message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':'number','message':_0xb6cc('0x7')}});exports['consequence']=function(_0x24a568,_0x308aca){return function(_0x198143){try{var _0x494245={'condition':htmlToText[_0xb6cc('0x8')](utils[_0xb6cc('0x9')](_0x308aca[0x0],this),{'wordwrap':![]})[_0xb6cc('0xa')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x308aca[0x1],'priorityFalse':_0x308aca[0x2]};var _0x22397c=gotoif['validate'](_0x494245,{'typecast':!![]});if(_0x22397c[_0xb6cc('0xb')]){logger[_0xb6cc('0xc')](_0xb6cc('0xd'),_0x24a568,_[_0xb6cc('0xe')](_0x22397c,_0xb6cc('0xf'))[_0xb6cc('0x10')](',\x20'));_0x198143['stop']();}else{try{var _0x39c7a4=eval('('+_0x494245[_0xb6cc('0x11')]+')');var _0x33d503=_0x39c7a4?_0x494245[_0xb6cc('0x12')]:_0x494245[_0xb6cc('0x13')];logger['info'](_0xb6cc('0x14'),_0x24a568,_0x494245[_0xb6cc('0x11')],_0x39c7a4,_0x33d503||_0xb6cc('0x15'));if(_0x33d503){var _0x26b24f=_[_0xb6cc('0x16')](_0x198143[_0xb6cc('0x17')](),{'p':_0x33d503});if(_0x26b24f>=0x0){logger[_0xb6cc('0x18')](_0xb6cc('0x19'),_0x24a568,_0x33d503||_0xb6cc('0x15'),_0x26b24f);_0x198143[_0xb6cc('0x15')](_0x26b24f);}else{logger[_0xb6cc('0x18')](_0xb6cc('0x1a'),_0x24a568,_0x33d503||_0xb6cc('0x15'));_0x198143['stop']();}}else{_0x198143[_0xb6cc('0x15')]();}}catch(_0x786a3a){logger[_0xb6cc('0xc')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x24a568,_0x786a3a[_0xb6cc('0xf')]);_0x198143[_0xb6cc('0x1b')]();}}}catch(_0x254ce0){logger[_0xb6cc('0xc')](_0xb6cc('0xd'),_0x24a568,JSON[_0xb6cc('0x1c')](_0x254ce0));_0x198143[_0xb6cc('0x1b')]();}};};