Built motion from commit ffdca78c.|2.6.24
[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 _0x907d=['error','[%s][GOTOIF]\x20%s','map','message','join','stop','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','condition','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','validate','html-to-text','../../../../config/logger','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','fromString','replace','length'];(function(_0x4ddbc6,_0x1c2d0c){var _0x3b54bb=function(_0x19de94){while(--_0x19de94){_0x4ddbc6['push'](_0x4ddbc6['shift']());}};_0x3b54bb(++_0x1c2d0c);}(_0x907d,0x10d));var _0xd907=function(_0x163742,_0x467e36){_0x163742=_0x163742-0x0;var _0x1152ac=_0x907d[_0x163742];return _0x1152ac;};'use strict';var schema=require(_0xd907('0x0'));var _=require('lodash');var htmlToText=require(_0xd907('0x1'));var utils=require('./utils');var logger=require(_0xd907('0x2'))('routing');var gotoif=schema({'condition':{'type':_0xd907('0x3'),'required':!![],'message':_0xd907('0x4')},'priorityTrue':{'type':_0xd907('0x5'),'message':_0xd907('0x6')},'priorityFalse':{'type':_0xd907('0x5'),'message':_0xd907('0x7')}});exports['consequence']=function(_0x2b4294,_0x49bd1b){return function(_0x44fde6){try{var _0xe541eb={'condition':htmlToText[_0xd907('0x8')](utils['getMustacheRender'](_0x49bd1b[0x0],this),{'wordwrap':![]})[_0xd907('0x9')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x49bd1b[0x1],'priorityFalse':_0x49bd1b[0x2]};var _0x4a46f5=gotoif[_0xd907('0x0')](_0xe541eb,{'typecast':!![]});if(_0x4a46f5[_0xd907('0xa')]){logger[_0xd907('0xb')](_0xd907('0xc'),_0x2b4294,_[_0xd907('0xd')](_0x4a46f5,_0xd907('0xe'))[_0xd907('0xf')](',\x20'));_0x44fde6[_0xd907('0x10')]();}else{try{var _0x53403f=eval('('+_0xe541eb['condition']+')');var _0x46def0=_0x53403f?_0xe541eb[_0xd907('0x11')]:_0xe541eb[_0xd907('0x12')];logger[_0xd907('0x13')](_0xd907('0x14'),_0x2b4294,_0xe541eb[_0xd907('0x15')],_0x53403f,_0x46def0||'next');if(_0x46def0){var _0x3f2539=_[_0xd907('0x16')](_0x44fde6[_0xd907('0x17')](),{'p':_0x46def0});if(_0x3f2539>=0x0){logger[_0xd907('0x13')](_0xd907('0x18'),_0x2b4294,_0x46def0||'next',_0x3f2539);_0x44fde6[_0xd907('0x19')](_0x3f2539);}else{logger[_0xd907('0x13')](_0xd907('0x1a'),_0x2b4294,_0x46def0||'next');_0x44fde6[_0xd907('0x10')]();}}else{_0x44fde6[_0xd907('0x19')]();}}catch(_0x3b3da8){logger[_0xd907('0xb')](_0xd907('0x1b'),_0x2b4294,_0x3b3da8[_0xd907('0xe')]);_0x44fde6[_0xd907('0x10')]();}}}catch(_0x131e0a){logger[_0xd907('0xb')](_0xd907('0xc'),_0x2b4294,JSON['stringify'](_0x131e0a));_0x44fde6[_0xd907('0x10')]();}};};