0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Removed archived newsletters from Portal settings

Archived newsletters won't be shown in Portal for selection, this change filters to only include active newsletters in Portal settings.
This commit is contained in:
Rishabh 2022-04-20 14:12:38 +05:30
parent 6092b31c40
commit 5a2219bec3

View file

@ -9,6 +9,7 @@ const settingsCache = require('../../../shared/settings-cache');
const {formattedMemberResponse} = require('./utils');
const labsService = require('../../../shared/labs');
const config = require('../../../shared/config');
const getNewslettersServiceInstance = require('../newsletters');
// @TODO: This piece of middleware actually belongs to the frontend, not to the member app
// Need to figure a way to separate these things (e.g. frontend actually talks to members API)
@ -134,8 +135,15 @@ const getPortalProductPrices = async function () {
};
const getSiteNewsletters = async function () {
const newsletters = await models.Newsletter.findAll();
return newsletters.toJSON();
try {
const newsletterService = getNewslettersServiceInstance({NewsletterModel: models.Newsletter});
return await newsletterService.browse({filter: 'status:active', limit: 'all'});
} catch (err) {
logging.warn('Failed to fetch site newsletters');
logging.warn(err.message);
return [];
}
};
const getMemberSiteData = async function (req, res) {