Built motion from commit cb845558.|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 _0x5e02=['[%s][GOTOIF]\x20%s','map','join','stop','condition','priorityTrue','priorityFalse','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','findIndex','rules','info','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','message','stringify','lodash','./utils','../../../../config/logger','routing','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','validate','error'];(function(_0x188ac3,_0x2d6e71){var _0x4c82ca=function(_0x20d7a7){while(--_0x20d7a7){_0x188ac3['push'](_0x188ac3['shift']());}};_0x4c82ca(++_0x2d6e71);}(_0x5e02,0x11f));var _0x25e0=function(_0x286386,_0x1293a2){_0x286386=_0x286386-0x0;var _0x1d7821=_0x5e02[_0x286386];return _0x1d7821;};'use strict';var schema=require('validate');var _=require(_0x25e0('0x0'));var htmlToText=require('html-to-text');var utils=require(_0x25e0('0x1'));var logger=require(_0x25e0('0x2'))(_0x25e0('0x3'));var gotoif=schema({'condition':{'type':'string','required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x25e0('0x4'),'message':_0x25e0('0x5')},'priorityFalse':{'type':'number','message':_0x25e0('0x6')}});exports[_0x25e0('0x7')]=function(_0x19a66e,_0x446eb6){return function(_0x4d5e90){try{var _0x675403={'condition':htmlToText[_0x25e0('0x8')](utils[_0x25e0('0x9')](_0x446eb6[0x0],this),{'wordwrap':![]})[_0x25e0('0xa')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x446eb6[0x1],'priorityFalse':_0x446eb6[0x2]};var _0x5504b6=gotoif[_0x25e0('0xb')](_0x675403,{'typecast':!![]});if(_0x5504b6['length']){logger[_0x25e0('0xc')](_0x25e0('0xd'),_0x19a66e,_[_0x25e0('0xe')](_0x5504b6,'message')[_0x25e0('0xf')](',\x20'));_0x4d5e90[_0x25e0('0x10')]();}else{try{var _0x1c8bef=eval('('+_0x675403[_0x25e0('0x11')]+')');var _0x11448e=_0x1c8bef?_0x675403[_0x25e0('0x12')]:_0x675403[_0x25e0('0x13')];logger['info'](_0x25e0('0x14'),_0x19a66e,_0x675403[_0x25e0('0x11')],_0x1c8bef,_0x11448e||'next');if(_0x11448e){var _0x36cf86=_[_0x25e0('0x15')](_0x4d5e90[_0x25e0('0x16')](),{'p':_0x11448e});if(_0x36cf86>=0x0){logger[_0x25e0('0x17')](_0x25e0('0x18'),_0x19a66e,_0x11448e||_0x25e0('0x19'),_0x36cf86);_0x4d5e90['next'](_0x36cf86);}else{logger['info'](_0x25e0('0x1a'),_0x19a66e,_0x11448e||_0x25e0('0x19'));_0x4d5e90[_0x25e0('0x10')]();}}else{_0x4d5e90[_0x25e0('0x19')]();}}catch(_0xb98090){logger['error'](_0x25e0('0x1b'),_0x19a66e,_0xb98090[_0x25e0('0x1c')]);_0x4d5e90[_0x25e0('0x10')]();}}}catch(_0x183b14){logger[_0x25e0('0xc')](_0x25e0('0xd'),_0x19a66e,JSON[_0x25e0('0x1d')](_0x183b14));_0x4d5e90[_0x25e0('0x10')]();}};};