Campuses backend: model, admin/public API, events per campus, filters

- Campus model, Event.campusId (null = all campuses), User.homeCampusId,
  per-campus summary recipients; campuses_enabled setting (off by default)
- /api/campuses: public list and landing page, admin CRUD/order/archive,
  "everyone at campus X" audience (home campus + optional 12-month registrants)
- Events: campus on create/update (audited when moved), ?campus= on the
  public list (with church-wide events) and staff list; campus included
- Home campus on the profile; cleared when anonymising
- Overview stats ?campus= filter; campus summary recipients; campus on
  ticket PDFs; heartbeat reports the real campus setting
- Migration also adds hub_update_requested, missing since 1.42.0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 16:23:33 +02:00
co-authored by Claude Opus 5.5
parent 388ba26c33
commit e138d4811d
15 changed files with 650 additions and 23 deletions
@@ -1422,7 +1422,13 @@ async function sendReceiptToUser(paymentId, requesterId, channel) {
async function sendDailyEventSummaries(now = new Date()) {
try {
const today = new Date(now);
const notifyInclude = { createdBy: { select: { id: true, name: true, email: true } }, notifyRecipients: { select: { id: true, name: true, email: true } } };
// Campus summary recipients (Site settings → Campuses) also get their campus's events.
const campusesOn = await require('./campuses').campusesEnabled();
const notifyInclude = {
createdBy: { select: { id: true, name: true, email: true } },
notifyRecipients: { select: { id: true, name: true, email: true } },
...(campusesOn ? { campus: { select: { notifyRecipients: { select: { email: true } } } } } : {}),
};
let events = await prisma.event.findMany({
where: { isActive: true, startDate: { gte: today }, requiresRegistration: true },
include: notifyInclude,
@@ -1462,6 +1468,7 @@ async function sendDailyEventSummaries(now = new Date()) {
: 0;
const { subject, text, html } = buildDailySummary(ev, registrations, payments, now, waitlistCount);
const to = buildEventNotifyRecipientList(ev);
for (const u of ev.campus?.notifyRecipients || []) if (u.email && !to.includes(u.email)) to.push(u.email);
if (to.length) await sendMail({ to: to.join(','), subject, html, text });
}));
} catch (e) {