mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 11:54:33 +03:00
Removed Subscriptions without Prices from BREAD API
refs https://github.com/TryGhost/Team/issues/1243 It's possible to get into strange states where a subscription in Ghost doesn't have an associated Price. This then has knock on effects because we're dealing with data in an undefined state. Rather than add guards against this throughout the entire stack, we stop returning it from the BREAD API. It might be worth considering removing these subscriptions from the response of the repository, but for now this is the most minimal change that fixes the problem.
This commit is contained in:
parent
928ff629fd
commit
188423b1ed
@ -172,6 +172,7 @@ module.exports = class MemberBREADService {
|
|||||||
|
|
||||||
const member = model.toJSON(options);
|
const member = model.toJSON(options);
|
||||||
|
|
||||||
|
member.subscriptions = member.subscriptions.filter(sub => !!sub.price);
|
||||||
this.attachSubscriptionsToMember(member);
|
this.attachSubscriptionsToMember(member);
|
||||||
|
|
||||||
this.attachOffersToSubscriptions(member, subscriptionOffers);
|
this.attachOffersToSubscriptions(member, subscriptionOffers);
|
||||||
@ -317,6 +318,7 @@ module.exports = class MemberBREADService {
|
|||||||
const members = page.data.map(model => model.toJSON(options));
|
const members = page.data.map(model => model.toJSON(options));
|
||||||
|
|
||||||
const data = members.map((member) => {
|
const data = members.map((member) => {
|
||||||
|
member.subscriptions = member.subscriptions.filter(sub => !!sub.price);
|
||||||
this.attachSubscriptionsToMember(member);
|
this.attachSubscriptionsToMember(member);
|
||||||
if (!originalWithRelated.includes('products')) {
|
if (!originalWithRelated.includes('products')) {
|
||||||
delete member.products;
|
delete member.products;
|
||||||
|
Loading…
Reference in New Issue
Block a user