mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
added a page on the home project to unsubscribe users
This commit is contained in:
@@ -2668,17 +2668,7 @@ module.exports = {
|
||||
});
|
||||
const alertId = subscriberAlert._id;
|
||||
const trackEmailAsViewedUrl = `${global.apiHost}/subscriberAlert/${incident.projectId}/${alertId}/viewed`;
|
||||
|
||||
let unsubscribeUrl;
|
||||
if (statusPageUrl) {
|
||||
unsubscribeUrl = `${global.statusHost}/status-page/${statusPage._id}/unsubscribe/${incident.monitorId._id}/${subscriber._id}`;
|
||||
} else {
|
||||
const statusPage = await StatusPageService.create({
|
||||
projectId: incident.projectId,
|
||||
});
|
||||
unsubscribeUrl = `${global.statusHost}/status-page/${statusPage._id}/unsubscribe/${incident.monitorId._id}/${subscriber._id}`;
|
||||
}
|
||||
|
||||
const unsubscribeUrl = `${global.homeHost}/unsubscribe/${incident.monitorId._id}/${subscriber._id}`;
|
||||
let alertStatus = null;
|
||||
try {
|
||||
if (templateType === 'Subscriber Incident Acknowldeged') {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"dep-check": "depcheck ./ --skip-missing=true --ignores='ejs,puppeteer'"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"cli-table": "^0.3.1",
|
||||
"compression": "^1.7.4",
|
||||
|
||||
@@ -25,6 +25,7 @@ const compression = require('compression');
|
||||
const minify = require('minify');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const productCompare = require('./config/product-compare');
|
||||
const axios = require('axios');
|
||||
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
@@ -166,6 +167,31 @@ app.get('/error-tracking', function(req, res) {
|
||||
res.redirect('/product/error-tracking');
|
||||
});
|
||||
|
||||
app.get('/unsubscribe/:monitorId/:subscriberId', async function(req, res) {
|
||||
const { monitorId, subscriberId } = req.params;
|
||||
let apiHost;
|
||||
if (process.env.FYIPE_HOST) {
|
||||
apiHost = 'https://' + process.env.FYIPE_HOST + '/api';
|
||||
} else {
|
||||
apiHost = 'http://localhost:3002/api';
|
||||
}
|
||||
|
||||
try {
|
||||
await axios({
|
||||
method: 'PUT',
|
||||
url: `${apiHost}/subscriber/unsubscribe/${monitorId}/${subscriberId}`,
|
||||
});
|
||||
|
||||
res.render('unsubscribe', {
|
||||
message: 'You have successfully unsubscribed from this monitor',
|
||||
});
|
||||
} catch (err) {
|
||||
res.render('unsubscribe', {
|
||||
message:
|
||||
'Encountered an error while trying to unsubscribe you from this monitor',
|
||||
});
|
||||
}
|
||||
});
|
||||
app.get('/product/docker-container-security', function(req, res) {
|
||||
res.render('container-security', {
|
||||
support: false,
|
||||
|
||||
32
home/views/unsubscribe.ejs
Normal file
32
home/views/unsubscribe.ejs
Normal file
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" id="contact">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fyipe | Help and Support</title>
|
||||
|
||||
<meta name="description"
|
||||
content="Fyipe monitors websites, API's, and servers and alerts your team if something goes wrong. It also keeps your customers updated about any downtime.">
|
||||
<% include ./head %>
|
||||
<link rel="stylesheet" href="/css/contact.css">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro&display=swap">
|
||||
<script src="/js/amplitude.js"></script>
|
||||
<script type="module" async>
|
||||
var IS_SAAS_SERVICE = !(window.location.href.indexOf('localhost') > -1 || window.location.href.indexOf('staging') > -1);
|
||||
if (IS_SAAS_SERVICE) {
|
||||
amplitude.getInstance().logEvent('PAGE VIEW: HOME > SUPPORT');
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="display: flex; justify-content: center;">
|
||||
<div style=" padding: 2px;background: #EEEEEE; border: 1px solid #CCCCCC;margin-top: 10px;text-align: center; width: 70%;">
|
||||
<p style="padding: 8px; margin: 0;" >
|
||||
<%= message %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
import { User } from './config';
|
||||
import queryString from 'query-string';
|
||||
import { removeQuery } from './store/store';
|
||||
import Unsubscribe from './components/Unsubscribe';
|
||||
|
||||
const userId = queryString.parse(window.location.search).userId;
|
||||
const accessToken = queryString.parse(window.location.search).accessToken;
|
||||
@@ -46,11 +45,6 @@ const App = () => (
|
||||
path="/status-page/:statusPageId/incident/:incidentId"
|
||||
component={Incident}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/status-page/unsubscribe/:monitorId/:subscriberId"
|
||||
component={Unsubscribe}
|
||||
/>
|
||||
<Redirect to="/" />
|
||||
</Switch>
|
||||
</Router>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { postApi, putApi } from '../api';
|
||||
import { postApi } from '../api';
|
||||
import errors from '../errors';
|
||||
|
||||
export const OPEN_SUBSCRIBE_MENU = 'OPEN_SUBSCRIBE_MENU';
|
||||
@@ -10,10 +10,6 @@ export const SUBSCRIBE_REQUEST = 'SUBSCRIBE_REQUEST';
|
||||
export const SUBSCRIBE_FAILURE = 'SUBSCRIBE_FAILURE';
|
||||
export const VALIDATION_ERROR = 'VALIDATION_ERROR';
|
||||
|
||||
export const UNSUBSCRIBE_REQUEST = 'UNSUBSCRIBE_REQUEST';
|
||||
export const UNSUBSCRIBE_SUCCESS = 'UNSUBSCRIBE_SUCCESS';
|
||||
export const UNSUBSCRIBE_FAILURE = 'UNSUBSCRIBE_FAILURE';
|
||||
|
||||
export const openSubscribeMenu = () => {
|
||||
return {
|
||||
type: OPEN_SUBSCRIBE_MENU,
|
||||
@@ -103,52 +99,3 @@ export const subscribeUser = (
|
||||
};
|
||||
};
|
||||
|
||||
export const unsubscribeRequest = () => {
|
||||
return {
|
||||
type: UNSUBSCRIBE_REQUEST,
|
||||
};
|
||||
};
|
||||
|
||||
export const unsubscribeSuccess = () => {
|
||||
return {
|
||||
type: UNSUBSCRIBE_SUCCESS,
|
||||
};
|
||||
};
|
||||
|
||||
export const unsubscribeFailure = data => {
|
||||
return {
|
||||
type: UNSUBSCRIBE_FAILURE,
|
||||
payload: data,
|
||||
};
|
||||
};
|
||||
|
||||
export const unsubscribeUser = (monitorId, subscriberId) => {
|
||||
return function(dispatch) {
|
||||
const promise = putApi(
|
||||
`subscriber/unsubscribe/${monitorId}/${subscriberId}`
|
||||
);
|
||||
|
||||
dispatch(unsubscribeRequest());
|
||||
|
||||
promise.then(
|
||||
() => {
|
||||
dispatch(unsubscribeSuccess());
|
||||
},
|
||||
error => {
|
||||
if (error && error.response && error.response.data)
|
||||
error = error.response.data;
|
||||
if (error && error.data) {
|
||||
error = error.data;
|
||||
}
|
||||
if (error && error.message) {
|
||||
error = error.message;
|
||||
}
|
||||
if (error.length > 100) {
|
||||
error = 'Network Error';
|
||||
}
|
||||
|
||||
dispatch(unsubscribeFailure(errors(error)));
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import PropTypes from 'prop-types';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { unsubscribeUser } from '../actions/subscribe';
|
||||
import ShouldRender from './ShouldRender';
|
||||
import { ListLoader } from './basic/Loader';
|
||||
|
||||
class Unsubscribe extends Component {
|
||||
componentDidMount() {
|
||||
const { monitorId, subscriberId } = this.props.match.params;
|
||||
this.props.unsubscribeUser(monitorId, subscriberId);
|
||||
}
|
||||
render() {
|
||||
const { requesting, error } = this.props.unsubscribe;
|
||||
return (
|
||||
<div className="innernew">
|
||||
<div
|
||||
style={{
|
||||
padding: '2px',
|
||||
background: '#EEEEEE',
|
||||
border: '1px solid #CCCCCC',
|
||||
marginTop: '10px',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
<ShouldRender if={requesting}>
|
||||
<ListLoader />
|
||||
</ShouldRender>
|
||||
<ShouldRender if={!requesting && error}>
|
||||
<p style={{ padding: 0, color: 'red' }}>{error}</p>
|
||||
</ShouldRender>
|
||||
<ShouldRender if={!requesting && !error}>
|
||||
<p style={{ padding: 0 }}>
|
||||
You have successfully unsubscribed from this monitor
|
||||
</p>
|
||||
</ShouldRender>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Unsubscribe.displayName = 'Unsubscribe';
|
||||
|
||||
Unsubscribe.propTypes = {
|
||||
match: PropTypes.object,
|
||||
unsubscribeUser: PropTypes.func.isRequired,
|
||||
unsubscribe: PropTypes.object,
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
unsubscribe: state.subscribe.unsubscribe,
|
||||
};
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
unsubscribeUser,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(withRouter(Unsubscribe));
|
||||
@@ -7,9 +7,6 @@ import {
|
||||
SUBSCRIBE_REQUEST,
|
||||
SUBSCRIBE_FAILURE,
|
||||
VALIDATION_ERROR,
|
||||
UNSUBSCRIBE_REQUEST,
|
||||
UNSUBSCRIBE_SUCCESS,
|
||||
UNSUBSCRIBE_FAILURE,
|
||||
} from '../actions/subscribe';
|
||||
|
||||
const INITIAL_STATE = {
|
||||
@@ -97,31 +94,6 @@ export default (state = INITIAL_STATE, action) => {
|
||||
},
|
||||
});
|
||||
|
||||
case UNSUBSCRIBE_REQUEST:
|
||||
return Object.assign({}, state, {
|
||||
unsubscribe: {
|
||||
requesting: true,
|
||||
success: false,
|
||||
error: null,
|
||||
},
|
||||
});
|
||||
case UNSUBSCRIBE_SUCCESS:
|
||||
return Object.assign({}, state, {
|
||||
unsubscribe: {
|
||||
requesting: false,
|
||||
success: true,
|
||||
error: null,
|
||||
},
|
||||
});
|
||||
case UNSUBSCRIBE_FAILURE:
|
||||
return Object.assign({}, state, {
|
||||
unsubscribe: {
|
||||
requesting: false,
|
||||
success: false,
|
||||
error: action.payload,
|
||||
},
|
||||
});
|
||||
|
||||
case VALIDATION_ERROR:
|
||||
return Object.assign({}, state, {
|
||||
subscribed: {
|
||||
|
||||
Reference in New Issue
Block a user