mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Added newsletter data to member BREAD service
refs https://github.com/TryGhost/Team/issues/1469 With multiple newsletters, members can now have one or more newsletter subscriptions that is attached to them. This change updates the member BREAD service to handle attaching newsletter data to member, based on the newsletter flag. - if newsletter flag is disabled, add/edit methods delete any newsletter data attached to member - sets `newsletters` as a default relation for read/browse methods so a member always has newsletter data attached to them
This commit is contained in:
parent
aaff165a21
commit
ad226f85b3
@ -133,7 +133,8 @@ module.exports = class MemberBREADService {
|
||||
'stripeSubscriptions.stripePrice.stripeProduct',
|
||||
'stripeSubscriptions.stripePrice.stripeProduct.product',
|
||||
'products',
|
||||
'offerRedemptions'
|
||||
'offerRedemptions',
|
||||
'newsletters'
|
||||
];
|
||||
|
||||
const withRelated = new Set((options.withRelated || []).concat(defaultWithRelated));
|
||||
@ -196,6 +197,10 @@ module.exports = class MemberBREADService {
|
||||
delete data.products;
|
||||
}
|
||||
|
||||
if (!this.labsService.isSet('multipleNewsletters')) {
|
||||
delete data.newsletters;
|
||||
}
|
||||
|
||||
if (!this.stripeService.configured && (data.comped || data.stripe_customer_id)) {
|
||||
const property = data.comped ? 'comped' : 'stripe_customer_id';
|
||||
throw new errors.ValidationError({
|
||||
@ -267,6 +272,10 @@ module.exports = class MemberBREADService {
|
||||
delete data.products;
|
||||
}
|
||||
|
||||
if (!this.labsService.isSet('multipleNewsletters')) {
|
||||
delete data.newsletters;
|
||||
}
|
||||
|
||||
let model;
|
||||
|
||||
try {
|
||||
@ -306,7 +315,8 @@ module.exports = class MemberBREADService {
|
||||
'stripeSubscriptions.customer',
|
||||
'stripeSubscriptions.stripePrice',
|
||||
'stripeSubscriptions.stripePrice.stripeProduct',
|
||||
'products'
|
||||
'products',
|
||||
'newsletters'
|
||||
];
|
||||
|
||||
const originalWithRelated = options.withRelated || [];
|
||||
|
Loading…
Reference in New Issue
Block a user