app: announcements, devotionals and events' backend (APP-1.0-PLAN §5-§7)
Announcements: public or members-only, pinned, a campus, a publish time and an end, an optional button, markdown text; Content admins write them; the heartbeat counts the last 30 days; "also send it" flags kept for §8. Devotionals: Cross Code's from the Hub each night and on Sync now (the next 2 weeks from today in the church's timezone, with the licence; exactly those days replaced, the rest kept, a Hub outage changes nothing), or the church's own by its Devotional writers, by hand or the same CSV import as the Hub's (preview, then replace or skip days already filled). Only KJV and BSB; the passage with its copyright line and Read in YouVersion; today's or the most recent; the archive by month; members-only ones; the acknowledgements. Events: simple events in the church's timezone, and the feed both ways as the Website's (publish its own as crosscode.event/1 with removals; read-only copies of Cross Events' and the Website's, Register on the Events site, canonical to the origin). Jobs event-feed (15 min) and crosscode-devotionals (01:15). Migration 20261204000000_content (checked on PostgreSQL 18: applies, no diff). 93 backend tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -80,19 +80,20 @@ model Session {
|
||||
/// the shared email and WhatsApp settings, and Events / the Website for the event feed (§7, §8).
|
||||
/// The secret is encrypted.
|
||||
model ProductLink {
|
||||
installId String @id
|
||||
product String
|
||||
url String
|
||||
publicKey String
|
||||
secret String
|
||||
connectedAt DateTime @default(now())
|
||||
connectedById String?
|
||||
installId String @id
|
||||
product String
|
||||
url String
|
||||
publicKey String
|
||||
secret String
|
||||
connectedAt DateTime @default(now())
|
||||
connectedById String?
|
||||
/// Show this sibling's events in the App (the event feed, §7). Accounts has none.
|
||||
showEvents Boolean @default(true)
|
||||
lastSyncAt DateTime?
|
||||
lastGoodAt DateTime?
|
||||
lastSyncError String?
|
||||
updatedAt DateTime @updatedAt
|
||||
showEvents Boolean @default(true)
|
||||
lastSyncAt DateTime?
|
||||
lastGoodAt DateTime?
|
||||
lastSyncError String?
|
||||
updatedAt DateTime @updatedAt
|
||||
importedEvents ImportedEvent[]
|
||||
}
|
||||
|
||||
/// Nonces of link messages seen in the last hour (replays are refused).
|
||||
@@ -366,3 +367,123 @@ model RequestPrayer {
|
||||
|
||||
@@unique([requestId, memberId])
|
||||
}
|
||||
|
||||
// ── Announcements (§5) ───────────────────────────────────────────────────────────────────────
|
||||
|
||||
enum AnnouncementAudience {
|
||||
everyone
|
||||
members
|
||||
}
|
||||
|
||||
/// News from the church: public ones are pages of their own (SEO, §11); members-only ones are noindex.
|
||||
model Announcement {
|
||||
id String @id @default(uuid())
|
||||
slug String @unique
|
||||
title String
|
||||
/// Markdown, shown sanitised (no HTML).
|
||||
body String
|
||||
imageUrl String?
|
||||
buttonLabel String?
|
||||
buttonUrl String?
|
||||
/// A campus's slug from the church profile, or null for every campus.
|
||||
campus String?
|
||||
audience AnnouncementAudience @default(everyone)
|
||||
pinned Boolean @default(false)
|
||||
/// Shown from then (now or later); a draft has none.
|
||||
publishAt DateTime?
|
||||
/// Hidden after this, if set.
|
||||
endsAt DateTime?
|
||||
/// Also send it at the publish time (to members who chose announcements, §8).
|
||||
sendEmail Boolean @default(false)
|
||||
sendWhatsApp Boolean @default(false)
|
||||
/// When the sends were queued (once).
|
||||
sentAt DateTime?
|
||||
createdById String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([publishAt])
|
||||
}
|
||||
|
||||
// ── Devotionals (§6) ─────────────────────────────────────────────────────────────────────────
|
||||
// `crosscode.devotional/1`: Cross Code's (from the Hub, the next 2 weeks each night) and the
|
||||
// church's own, side by side; Settings → Devotionals (AppSetting `devotionals_source`) picks which
|
||||
// one shows. One per day per source.
|
||||
|
||||
enum DevotionalSource {
|
||||
crosscode
|
||||
church
|
||||
}
|
||||
|
||||
model Devotional {
|
||||
id String @id @default(uuid())
|
||||
source DevotionalSource
|
||||
/// The Hub's id for Cross Code's (`crosscode.devotional/1` `id`).
|
||||
originId String?
|
||||
/// The local day it's for (YYYY-MM-DD, the church's timezone).
|
||||
date String
|
||||
title String
|
||||
reference String
|
||||
/// `passageLocationSchema`: book, chapter and verses (for the YouVersion link).
|
||||
location Json
|
||||
translation String
|
||||
passageText String
|
||||
/// Markdown, shown sanitised.
|
||||
body String
|
||||
prayer String?
|
||||
author String?
|
||||
/// Only for signed-in members (noindex); public by default (§6).
|
||||
membersOnly Boolean @default(false)
|
||||
createdById String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([source, date])
|
||||
@@index([date])
|
||||
}
|
||||
|
||||
// ── Events (§7) ──────────────────────────────────────────────────────────────────────────────
|
||||
// As the Website's: simple events made in the App, read-only copies of the siblings' events (the
|
||||
// feed), and removals listed for 90 days.
|
||||
|
||||
model SimpleEvent {
|
||||
id String @id @default(uuid())
|
||||
slug String @unique
|
||||
title String
|
||||
startsAt DateTime
|
||||
endsAt DateTime?
|
||||
allDay Boolean @default(false)
|
||||
timezone String @default("Africa/Johannesburg")
|
||||
location String?
|
||||
description String?
|
||||
imageUrl String?
|
||||
link String?
|
||||
cancelled Boolean @default(false)
|
||||
publishedAt DateTime?
|
||||
updatedBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([startsAt])
|
||||
}
|
||||
|
||||
model ImportedEvent {
|
||||
id String @id @default(uuid())
|
||||
linkId String
|
||||
link ProductLink @relation(fields: [linkId], references: [installId], onDelete: Cascade)
|
||||
originProduct String
|
||||
originId String
|
||||
startsAt DateTime
|
||||
endsAt DateTime
|
||||
data Json
|
||||
syncedAt DateTime @default(now())
|
||||
|
||||
@@unique([originProduct, originId])
|
||||
@@index([startsAt])
|
||||
@@index([linkId])
|
||||
}
|
||||
|
||||
model FeedRemoval {
|
||||
eventId String @id
|
||||
removedAt DateTime @default(now())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user