mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Ran Comped subscriptions in transaction (#360)
no-issue We were incorrectly mixing transactional and non-transactional operations. An e2e test in Ghost will be merged shortly which caught this problem.
This commit is contained in:
parent
40035c99bf
commit
73418e8749
1 changed files with 12 additions and 2 deletions
|
@ -593,7 +593,8 @@ module.exports = class MemberRepository {
|
||||||
if (!ghostProduct) {
|
if (!ghostProduct) {
|
||||||
let {data: pageData} = await this._productRepository.list({
|
let {data: pageData} = await this._productRepository.list({
|
||||||
limit: 1,
|
limit: 1,
|
||||||
filter: 'type:paid'
|
filter: 'type:paid',
|
||||||
|
...options
|
||||||
});
|
});
|
||||||
ghostProduct = (pageData && pageData[0]) || null;
|
ghostProduct = (pageData && pageData[0]) || null;
|
||||||
}
|
}
|
||||||
|
@ -966,7 +967,16 @@ module.exports = class MemberRepository {
|
||||||
}, options);
|
}, 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) {
|
if (!this._stripeAPIService.configured) {
|
||||||
throw new errors.BadRequestError(tpl(messages.noStripeConnection, {action: 'create Complimentary Subscription'}));
|
throw new errors.BadRequestError(tpl(messages.noStripeConnection, {action: 'create Complimentary Subscription'}));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue