app: prayer requests' backend (APP-1.0-PLAN §4)

Private by default (the prayer team only) or shared with members after a
coordinator approves it, with the first name or "Anonymous"; fully anonymous
requests when the church allows them (off by default). Coordinators approve,
redact (the sender told what changed) or remove (with a reason); anyone on the
team can escalate to Pastoral care (email and WhatsApp at once, an Owner or
Church admin when nobody has the role): it leaves the shared list and the sender
sees nothing different. "I prayed" counts without who, "Answered!" updates,
private replies from the team, closing after 30 days (7-90) and deletion 12
months later (prayer-requests-tidy). Every list with a sender is access-logged;
messages never carry a request's text; nothing in the heartbeat. Export and
delete for a member's requests. Shared helpers: parse (http.ts), accessLog
(lib/accessLog.ts). Migration 20261203000000_prayer_requests (checked on
PostgreSQL 18: applies, no diff). 78 backend tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 10:56:53 +02:00
co-authored by Claude Opus 5.5
parent 1dd3aadb60
commit 6425a6a30d
16 changed files with 893 additions and 22 deletions
+82
View File
@@ -49,6 +49,7 @@ model Member {
prayerCommitments PrayerCommitment[]
testimonies Testimony[]
outboxMessages OutboxMessage[]
prayerRequests PrayerRequest[]
@@index([lastActiveAt])
}
@@ -284,3 +285,84 @@ model OutboxMessage {
@@index([sentAt, sendAfter])
}
// ── Prayer requests (§4) ─────────────────────────────────────────────────────────────────────
// Special personal information (POPIA s26): never in stats, the heartbeat, AI or an email's text.
// The rules (closing after 30 days, fully anonymous requests, emergency numbers) are in AppSetting
// `prayer_requests`. Every view of a request with its sender goes in the access log.
/// Who sees a request (P8): the prayer team only (the default), or members after approval.
enum RequestVisibility {
team
members
}
/// A shared request's moderation: waiting, approved (shown to members) or removed (with a reason).
/// Team-only requests are never moderated (`none`).
enum RequestModeration {
none
pending
approved
removed
}
model PrayerRequest {
id String @id @default(uuid())
memberId String
member Member @relation(fields: [memberId], references: [id], onDelete: Cascade)
text String
visibility RequestVisibility @default(team)
/// For members: show the submitter's first name (else "Anonymous").
showName Boolean @default(false)
/// Fully anonymous (P9, when the church allows it): the prayer team doesn't see who sent it either.
anonymous Boolean @default(false)
moderation RequestModeration @default(none)
/// A coordinator edited out names or details; the submitter is told what changed.
redactedAt DateTime?
redactionNote String?
removedReason String?
moderatedById String?
moderatedAt DateTime?
/// Safeguarding (§4): sent to Pastoral care at once; it leaves the shared list; the submitter sees nothing different.
escalatedAt DateTime?
escalatedById String?
escalationNote String?
/// Closes itself then (30 days by default), unless closed before.
closesAt DateTime
closedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
updates PrayerRequestUpdate[]
prayers RequestPrayer[]
@@index([moderation, createdAt])
@@index([memberId])
@@index([closedAt])
@@index([closesAt])
}
/// "Answered!" from the submitter (shown with the request), or a private reply from the prayer team
/// (to the submitter alone).
model PrayerRequestUpdate {
id String @id @default(uuid())
requestId String
request PrayerRequest @relation(fields: [requestId], references: [id], onDelete: Cascade)
/// `submitter` or `team`.
author String
authorId String?
text String
createdAt DateTime @default(now())
@@index([requestId, createdAt])
}
/// "I prayed" on a shared request: the submitter sees how many, never who.
model RequestPrayer {
id String @id @default(uuid())
requestId String
request PrayerRequest @relation(fields: [requestId], references: [id], onDelete: Cascade)
memberId String
createdAt DateTime @default(now())
@@unique([requestId, memberId])
}