Skip to content

Commit

Permalink
Ran Comped subscriptions in transaction (#360)
Browse files Browse the repository at this point in the history
no-issue

We were incorrectly mixing transactional and non-transactional
operations. An e2e test in Ghost will be merged shortly which caught
this problem.
  • Loading branch information
allouis authored Feb 1, 2022
1 parent 40035c9 commit 73418e8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ghost/members-api/lib/repositories/member.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,8 @@ module.exports = class MemberRepository {
if (!ghostProduct) {
let {data: pageData} = await this._productRepository.list({
limit: 1,
filter: 'type:paid'
filter: 'type:paid',
...options
});
ghostProduct = (pageData && pageData[0]) || null;
}
Expand Down Expand Up @@ -966,7 +967,16 @@ module.exports = class MemberRepository {
}, options);
}

async setComplimentarySubscription(data, options) {
async setComplimentarySubscription(data, options = {}) {
if (!options.transacting) {
return this._Member.transaction((transacting) => {
return this.setComplimentarySubscription(data, {
...options,
transacting
});
});
}

if (!this._stripeAPIService.configured) {
throw new errors.BadRequestError(tpl(messages.noStripeConnection, {action: 'create Complimentary Subscription'}));
}
Expand Down

0 comments on commit 73418e8

Please sign in to comment.