generated from nhcarrigan/template
feat: implement comment reporting system
Added comprehensive comment reporting infrastructure similar to profile reporting. API Changes: - New CommentReport model in Prisma schema with relations to User and Comment - CommentReportService with CRUD operations, duplicate prevention, and rate limiting - API routes at /comment-reports for creating and managing comment reports - Updated CommentService to include hasPendingReports flag for all comments Frontend Changes: - Created shared CommentDisplayComponent for reusable comment display with report button - Updated ReportModalComponent to handle both profile and comment reports - CommentReportService for API communication - Integrated CommentDisplayComponent into games-list component - Comments with pending reports show "[comment pending admin review]" message Features: - Users can report comments they didn't write - Duplicate prevention (one pending report per comment per user) - Rate limiting (5 pending reports maximum per user) - Admins can review and action comment reports - Comments are hidden during review to prevent abuse Remaining Work: - Need to integrate CommentDisplayComponent into remaining media components (books, music, art, shows, manga) - Need to extend admin-reports page to display comment reports alongside profile reports
This commit is contained in:
+43
-20
@@ -205,33 +205,36 @@ model User {
|
||||
suggestions Suggestion[]
|
||||
likes Like[]
|
||||
refreshTokens RefreshToken[]
|
||||
reportsMade ProfileReport[] @relation("Reporter")
|
||||
reportsReceived ProfileReport[] @relation("ReportedUser")
|
||||
reportsReviewed ProfileReport[] @relation("Reviewer")
|
||||
reportsMade ProfileReport[] @relation("Reporter")
|
||||
reportsReceived ProfileReport[] @relation("ReportedUser")
|
||||
reportsReviewed ProfileReport[] @relation("Reviewer")
|
||||
commentReportsMade CommentReport[] @relation("CommentReporter")
|
||||
commentReportsReviewed CommentReport[] @relation("CommentReviewer")
|
||||
|
||||
@@index([slug], map: "User_slug_key")
|
||||
}
|
||||
|
||||
model Comment {
|
||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||
content String
|
||||
rawContent String?
|
||||
userId String @db.ObjectId
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
gameId String? @db.ObjectId
|
||||
game Game? @relation(fields: [gameId], references: [id])
|
||||
bookId String? @db.ObjectId
|
||||
book Book? @relation(fields: [bookId], references: [id])
|
||||
musicId String? @db.ObjectId
|
||||
music Music? @relation(fields: [musicId], references: [id])
|
||||
artId String? @db.ObjectId
|
||||
art Art? @relation(fields: [artId], references: [id])
|
||||
showId String? @db.ObjectId
|
||||
show Show? @relation(fields: [showId], references: [id])
|
||||
mangaId String? @db.ObjectId
|
||||
manga Manga? @relation(fields: [mangaId], references: [id])
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
userId String @db.ObjectId
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
gameId String? @db.ObjectId
|
||||
game Game? @relation(fields: [gameId], references: [id])
|
||||
bookId String? @db.ObjectId
|
||||
book Book? @relation(fields: [bookId], references: [id])
|
||||
musicId String? @db.ObjectId
|
||||
music Music? @relation(fields: [musicId], references: [id])
|
||||
artId String? @db.ObjectId
|
||||
art Art? @relation(fields: [artId], references: [id])
|
||||
showId String? @db.ObjectId
|
||||
show Show? @relation(fields: [showId], references: [id])
|
||||
mangaId String? @db.ObjectId
|
||||
manga Manga? @relation(fields: [mangaId], references: [id])
|
||||
reports CommentReport[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model AuditLog {
|
||||
@@ -369,3 +372,23 @@ model ProfileReport {
|
||||
@@index([reporterId])
|
||||
@@index([status])
|
||||
}
|
||||
|
||||
model CommentReport {
|
||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||
reportedCommentId String @db.ObjectId
|
||||
reportedComment Comment @relation(fields: [reportedCommentId], references: [id])
|
||||
reporterId String @db.ObjectId
|
||||
reporter User @relation("CommentReporter", fields: [reporterId], references: [id])
|
||||
reason ReportReason
|
||||
details String
|
||||
status ReportStatus @default(PENDING)
|
||||
reviewedBy String? @db.ObjectId
|
||||
reviewer User? @relation("CommentReviewer", fields: [reviewedBy], references: [id])
|
||||
reviewNotes String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([reportedCommentId])
|
||||
@@index([reporterId])
|
||||
@@index([status])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user