Run create subscription checks in subscriptions module (#14738)

GitOrigin-RevId: dacdf883e477b2587f9a10a069e9f63989f94498
This commit is contained in:
Thomas 2023-09-11 15:30:13 +02:00 committed by Copybot
parent 004bdd593e
commit 6be63d4f96

View file

@ -24,6 +24,7 @@ const SplitTestHandler = require('../SplitTests/SplitTestHandler')
const SubscriptionHelper = require('./SubscriptionHelper')
const Features = require('../../infrastructure/Features')
const UserGetter = require('../User/UserGetter')
const Modules = require('../../infrastructure/Modules')
const groupPlanModalOptions = Settings.groupPlanModalOptions
const validGroupPlanModalOptions = {
@ -450,6 +451,18 @@ async function createSubscription(req, res) {
return res.sendStatus(409) // conflict
}
const result = {}
await Modules.promises.hooks.fire(
'createSubscription',
req,
res,
user,
result
)
if (result.error) {
return HttpErrorHandler.unprocessableEntity(req, res)
}
try {
await SubscriptionHandler.promises.createSubscription(
user,