Hub 2.0 step 6: AI cap and markup per church

The cap and markup move from the licence to the customer (migrated), use
is counted over all the church's installs under one lock per church, and
the licence token carries the church's cap. Settings → AI shows product.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-05 08:55:43 +02:00
co-authored by Claude Opus 5.5
parent 6e51780103
commit 59e6b9f03c
11 changed files with 138 additions and 72 deletions
+3 -2
View File
@@ -64,9 +64,10 @@ async function releaseInfo(install, version, { v2 = false } = {}) {
}
async function tokenFor(install) {
const licence = install.licenceId ? await prisma.licence.findUnique({ where: { id: install.licenceId }, include: { customer: { select: { name: true } } } }) : null;
const licence = install.licenceId ? await prisma.licence.findUnique({ where: { id: install.licenceId }, include: { customer: { select: { name: true, aiMonthlyCapCents: true } } } }) : null;
if (!licence) return null;
return licenceToken.sign(licenceToken.buildPayload(licence, install, licence.customer.name));
// The AI cap in the token is the church's (Hub 2.0).
return licenceToken.sign(licenceToken.buildPayload({ ...licence, aiMonthlyCapCents: licence.customer.aiMonthlyCapCents }, install, licence.customer.name));
}
/**