0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00
ghost/core/frontend/services/routing/controllers/unsubscribe.js
Simon Backx ad349bb3a5
Removed GA feature flags (#14915)
refs https://github.com/TryGhost/Team/issues/1616

- Removed all GA feature flags
- Removed `tweetGridCard` alpha flag
- Changes to `members-api` and `members-importer` packages: https://github.com/TryGhost/Members/compare/%40tryghost/members-api%408.1.1...%40tryghost/members-api%408.1.2
2022-05-26 09:54:30 +02:00

24 lines
786 B
JavaScript

const debug = require('@tryghost/debug')('services:routing:controllers:unsubscribe');
const url = require('url');
const urlUtils = require('../../../../shared/url-utils');
module.exports = async function unsubscribeController(req, res) {
debug('unsubscribeController');
const {query} = url.parse(req.url, true);
if (!query || !query.uuid) {
res.writeHead(400);
return res.end('Email address not found.');
}
const redirectUrl = new URL(urlUtils.urlFor('home', true));
redirectUrl.searchParams.append('uuid', query.uuid);
if (query.newsletter) {
redirectUrl.searchParams.append('newsletter', query.newsletter);
}
redirectUrl.searchParams.append('action', 'unsubscribe');
return res.redirect(302, redirectUrl.href);
};