diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a52d71a..89c80d5 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -246,6 +246,13 @@ model Post { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + // Moderation "hide without delete" (Gitea #10 Phase 3) — set by an admin + // HIDE_POST action, cleared by UNHIDE_POST. Data stays intact for record + // purposes; every reader-facing query (feed/explore/profile/search/ + // hashtag/milestones) filters hiddenAt: null. Admin views intentionally + // do NOT filter on this so moderators can still see + unhide. + hiddenAt DateTime? + // Denormalized engagement counters — kept in sync transactionally at each // reaction/comment/repost create+delete site (reactions.ts, comments.ts, // reposts.ts, admin.ts deleteComment). Avoids live _count aggregation on @@ -686,7 +693,7 @@ model AdRepost { model ModerationLog { id String @id @default(cuid()) - action String @db.VarChar(50) // DELETE_POST | DELETE_COMMENT | BAN_USER | UNBAN_USER | DELETE_IMAGE | DISMISS_REPORT | CREATE_AD | UPDATE_AD | DELETE_AD | GRANT_ROLE | REVOKE_ROLE | WARN_USER | VERIFY_PET | UNVERIFY_PET | DELETE_ACCOUNT | APPROVE_VERIFICATION_REQUEST | REJECT_VERIFICATION_REQUEST + action String @db.VarChar(50) // DELETE_POST | DELETE_COMMENT | BAN_USER | UNBAN_USER | DELETE_IMAGE | DISMISS_REPORT | CREATE_AD | UPDATE_AD | DELETE_AD | GRANT_ROLE | REVOKE_ROLE | WARN_USER | VERIFY_PET | UNVERIFY_PET | DELETE_ACCOUNT | APPROVE_VERIFICATION_REQUEST | REJECT_VERIFICATION_REQUEST | HIDE_POST | UNHIDE_POST targetType String @db.VarChar(20) // POST | COMMENT | USER | IMAGE | AD | REPORT | PET targetId String reason String? @db.VarChar(500) diff --git a/src/app/p/[secret]/posts/page.tsx b/src/app/p/[secret]/posts/page.tsx index 0f58704..6ae12b5 100644 --- a/src/app/p/[secret]/posts/page.tsx +++ b/src/app/p/[secret]/posts/page.tsx @@ -3,7 +3,7 @@ import { useEffect, useState } from "react"; import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useTRPC } from "@/trpc/client"; -import { Trash2, MessageSquare, Loader2, ChevronDown, Play, ImageOff, PawPrint } from "lucide-react"; +import { Trash2, MessageSquare, Loader2, ChevronDown, Play, ImageOff, PawPrint, EyeOff, Eye } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"; @@ -45,7 +45,9 @@ export default function AdminPostsPage() { } const [commentsPostId, setCommentsPostId] = useState(null); const [deleteTarget, setDeleteTarget] = useState<{ id: string; type: "post" | "comment" } | null>(null); + const [hideTargetId, setHideTargetId] = useState(null); const [reason, setReason] = useState(""); + const [hideReason, setHideReason] = useState(""); const { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading } = useInfiniteQuery( trpc.admin.listPosts.infiniteQueryOptions( @@ -85,6 +87,29 @@ export default function AdminPostsPage() { }) ); + const hidePost = useMutation( + trpc.admin.hidePost.mutationOptions({ + onSuccess: () => { + void qc.invalidateQueries({ queryKey: trpc.admin.listPosts.queryKey() }); + setHideTargetId(null); + setHideReason(""); + }, + }) + ); + + const unhidePost = useMutation( + trpc.admin.unhidePost.mutationOptions({ + onSuccess: () => { + void qc.invalidateQueries({ queryKey: trpc.admin.listPosts.queryKey() }); + }, + }) + ); + + function confirmHide() { + if (!hideTargetId || !hideReason.trim()) return; + hidePost.mutate({ postId: hideTargetId, reason: hideReason.trim() }); + } + function confirmDelete() { if (!deleteTarget) return; if (deleteTarget.type === "post") { @@ -180,6 +205,14 @@ export default function AdminPostsPage() {