app: uploaded images for announcements, campaigns and events (APP-1.0-PLAN §10)

Photos (JPEG, PNG, WebP, checked by their bytes) uploaded in the admin are
turned upright, stripped of their metadata and kept at most 2000 px wide in
backend/uploads (UPLOAD_DIR), served at /api/uploads (never a listing, a
sandboxing CSP). Content keeps the image's full address, so an upload and an
image from elsewhere work alike. 5 GB included or the licence's storage
limit; an image still in use can't be deleted. The announcement, campaign
and event forms get Upload a photo next to the address. Migration media.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 14:47:33 +02:00
co-authored by Claude Opus 5.5
parent 13eaaffb95
commit c934f47b28
15 changed files with 337 additions and 4 deletions
@@ -0,0 +1,22 @@
-- Church App 1.0.0: uploads (docs/APP-1.0-PLAN.md §10): images uploaded in the admin.
-- CreateTable
CREATE TABLE "MediaAsset" (
"id" TEXT NOT NULL,
"filename" TEXT NOT NULL,
"mime" TEXT NOT NULL,
"bytes" INTEGER NOT NULL,
"width" INTEGER,
"height" INTEGER,
"alt" TEXT NOT NULL DEFAULT '',
"uploadedBy" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "MediaAsset_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "MediaAsset_filename_key" ON "MediaAsset"("filename");
-- CreateIndex
CREATE INDEX "MediaAsset_createdAt_idx" ON "MediaAsset"("createdAt");
+20
View File
@@ -332,6 +332,26 @@ model NotificationSettings {
/// Messages sent per local day and channel, for the heartbeat (`messages.email30d`, `whatsapp30d`).
/// Counts only: kept when a member or their messages are deleted. `key` is `<day>:<channel>`.
// ── Uploads (§10) ────────────────────────────────────────────────────────────────────────────
/// An image uploaded in the admin (announcements, campaigns, events), kept in backend/uploads and
/// served at /api/uploads/<filename>: turned upright, stripped of its metadata (a phone photo can
/// carry where it was taken), at most 2000 px wide.
model MediaAsset {
id String @id @default(uuid())
/// YYYY/MM/<uuid>.<ext>, under the uploads folder.
filename String @unique
mime String
bytes Int
width Int?
height Int?
alt String @default("")
uploadedBy String?
createdAt DateTime @default(now())
@@index([createdAt])
}
model MessageCount {
key String @id
day String