Hub 2.9.0: whether people can sign in

- An Events install's page shows its sign-in mode, whether it's linked to the church's Accounts,
  and the last sign-in failure (Events 3.5.0 heartbeat, contracts 1.13.0 vendored).
- Alerts: signs in through Accounts but isn't linked (critical), linked to the wrong Accounts, a
  sign-in failed in the last 24 hours, an Accounts nothing is linked to while the church has Events.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 12:56:41 +02:00
co-authored by Claude Opus 5.5
parent 1150a82ecc
commit 894f2b2771
12 changed files with 130 additions and 19 deletions
+10 -6
View File
@@ -12,7 +12,7 @@ const { ymd, today } = require('../utils/billing/dates');
const { linkedProductsFor } = require('../utils/protocol');
const { audit } = require('../utils/audit');
const { getSettings, setSettings } = require('../utils/settings');
const { problems, compareVersions } = require('../utils/alerts');
const { problems, compareVersions, churchesOf } = require('../utils/alerts');
const licenceToken = require('../utils/licenceToken');
const { smtpConfigured, testSmtp } = require('../utils/mail');
const { VERSION_RE, sortReleases, syncLatestVersion, latestVersions, unmetRequirementsFor } = require('../utils/releases');
@@ -43,8 +43,9 @@ function dateOrNull(v) {
}
// The health of an install at a glance, for lists. `latest` is the latest version per product.
function summary(install, settings, latest = {}, now = new Date()) {
const current = problems(install, { ...settings, latest_versions: latest }, now);
function summary(install, settings, latest = {}, now = new Date(), church = undefined) {
// Hub 2.9.0: `church` (churchesOf) lets the sign-in checks compare with the church's Accounts.
const current = problems({ ...install, church }, { ...settings, latest_versions: latest }, now);
const latestForProduct = latest[install.product] || null;
const worst = current.some(p => p.level === 'critical') ? 'critical' : current.some(p => p.level === 'warning') ? 'warning' : 'ok';
return {
@@ -69,7 +70,8 @@ function summary(install, settings, latest = {}, now = new Date()) {
router.get('/dashboard', wrap(async (req, res) => {
const [settings, latest] = await Promise.all([getSettings(), latestVersions()]);
const installs = await prisma.install.findMany({ where: { releasedAt: null }, include: { licence: true, customer: true }, orderBy: { name: 'asc' } });
const rows = installs.map(i => summary(i, settings, latest));
const churches = churchesOf(installs);
const rows = installs.map(i => summary(i, settings, latest, new Date(), churches.get(i.customerId)));
const [customers, licences, openAlerts, billed, sentInvoices] = await Promise.all([
prisma.customer.count(),
prisma.licence.groupBy({ by: ['product', 'status'], _count: { _all: true } }),
@@ -227,7 +229,8 @@ router.post('/licences/:id/release', wrap(async (req, res) => {
router.get('/installs', wrap(async (req, res) => {
const [settings, latest] = await Promise.all([getSettings(), latestVersions()]);
const installs = await prisma.install.findMany({ include: { licence: true, customer: true }, orderBy: { name: 'asc' } });
res.json(installs.map(i => summary(i, settings, latest)));
const churches = churchesOf(installs.filter(i => !i.releasedAt));
res.json(installs.map(i => summary(i, settings, latest, new Date(), churches.get(i.customerId))));
}));
router.get('/installs/:id', wrap(async (req, res) => {
@@ -251,12 +254,13 @@ router.get('/installs/:id', wrap(async (req, res) => {
}
const target = latest[install.product] || null;
const behind = !!(target && install.version && compareVersions(install.version, target) < 0);
const church = churchesOf(await prisma.install.findMany({ where: { customerId: install.customerId, releasedAt: null }, select: { id: true, product: true, customerId: true } })).get(install.customerId);
const [aiStatus, aiMonths, aiHelpers, unmet] = await Promise.all([
ai.statusFor(install), ai.usageByMonth(install.id), ai.usageByHelper(install.id),
behind ? unmetRequirementsFor(install, target) : [],
]);
res.json({
...safe, licence, summary: summary(install, settings, latest), heartbeats, ai: { status: aiStatus, months: aiMonths, helpers: aiHelpers },
...safe, licence, summary: summary(install, settings, latest, new Date(), church), heartbeats, ai: { status: aiStatus, months: aiMonths, helpers: aiHelpers },
// What updating to the latest version needs from the church's other products (Hub 2.0).
update: { latestVersion: target, behind, unmetRequirements: unmet },
// The church's other installs this one is told about (protocol v2), and the ones it isn't.