2021-06-15 19:01:22 +03:00
|
|
|
const debug = require('@tryghost/debug')('services:routing:controllers:unsubscribe');
|
2019-11-15 12:36:49 +03:00
|
|
|
const path = require('path');
|
|
|
|
const megaService = require('../../../../server/services/mega');
|
|
|
|
const helpers = require('../../../services/routing/helpers');
|
|
|
|
|
2021-01-28 21:07:45 +03:00
|
|
|
module.exports = async function unsubscribeController(req, res) {
|
2019-11-15 12:36:49 +03:00
|
|
|
debug('unsubscribeController');
|
|
|
|
|
|
|
|
let data = {};
|
|
|
|
|
|
|
|
try {
|
|
|
|
data.member = await megaService.mega.handleUnsubscribeRequest(req);
|
|
|
|
} catch (err) {
|
|
|
|
data.error = err.message;
|
|
|
|
}
|
|
|
|
|
|
|
|
const templateName = 'unsubscribe';
|
|
|
|
|
|
|
|
res.routerOptions = {
|
|
|
|
type: 'custom',
|
|
|
|
templates: templateName,
|
|
|
|
defaultTemplate: path.resolve(__dirname, '../../../views/', templateName)
|
|
|
|
};
|
|
|
|
|
|
|
|
return helpers.renderer(req, res, data);
|
|
|
|
};
|