0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Added dummy subscription to comped members

refs https://github.com/TryGhost/Team/issues/873

This includes the update to @tryghost/members-api which includes the new
MemberBREADService which is used to handle the logic for controller
methods outside of the controller.

With it, we've introduced the concept of a dummy subscription for comped
members. This gives API consumers a way to get the created_at date for a
comped members access to a product.
This commit is contained in:
Fabien O'Carroll 2021-08-25 14:54:38 +02:00
parent 4e47c63e73
commit 76311484df
3 changed files with 8 additions and 20 deletions

View file

@ -66,27 +66,15 @@ module.exports = {
},
permissions: true,
async query(frame) {
const defaultWithRelated = ['labels', 'stripeSubscriptions', 'stripeSubscriptions.customer', 'stripeSubscriptions.stripePrice', 'stripeSubscriptions.stripePrice.stripeProduct'];
let member = await membersService.api.memberBREADService.read(frame.data, frame.options);
if (!frame.options.withRelated) {
frame.options.withRelated = defaultWithRelated;
} else {
frame.options.withRelated = frame.options.withRelated.concat(defaultWithRelated);
}
if (frame.options.withRelated.includes('email_recipients')) {
frame.options.withRelated.push('email_recipients.email');
}
let model = await membersService.api.members.get(frame.data, frame.options);
if (!model) {
if (!member) {
throw new errors.NotFoundError({
message: i18n.t('errors.api.members.memberNotFound')
});
}
return model;
return member;
}
},

View file

@ -73,7 +73,7 @@
"@tryghost/limit-service": "0.6.1",
"@tryghost/logging": "0.1.5",
"@tryghost/magic-link": "1.0.10",
"@tryghost/members-api": "1.26.0",
"@tryghost/members-api": "1.27.2",
"@tryghost/members-csv": "1.1.5",
"@tryghost/members-importer": "0.3.1",
"@tryghost/members-ssr": "1.0.11",

View file

@ -908,10 +908,10 @@
jsonwebtoken "^8.5.1"
lodash "^4.17.15"
"@tryghost/members-api@1.26.0":
version "1.26.0"
resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-1.26.0.tgz#ad4d02df3718d3a7956f72bf8ba98a40e7b999bd"
integrity sha512-/WqACOSfeZVZYjQRttEh18HsAUw6O3GVXxl+fRu9WkQHoii9RE3Q/nnT06h9jLMA33Fz5dzMUjz7Kwr9Y0XB9w==
"@tryghost/members-api@1.27.2":
version "1.27.2"
resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-1.27.2.tgz#2c3731d63a3ea01ed50a9ce78e0e8aaac46c7b55"
integrity sha512-mzNRmLKOzyKXooNL5Z6S91zpLozdlJDAsY7SJHz13ETeksRy6om3jhDz696WCNmiIKS3yArRMi9dzEwS2KbGzQ==
dependencies:
"@tryghost/debug" "^0.1.2"
"@tryghost/errors" "^0.2.9"