From 957cda9f09042b49f86f76713bde6473659123c8 Mon Sep 17 00:00:00 2001 From: floss4good Date: Fri, 4 Apr 2025 00:08:28 +0300 Subject: [PATCH] include more details in comments' shadow copies (useful in case the comment was deleted) --- models/issues/moderation.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/models/issues/moderation.go b/models/issues/moderation.go index 0d855f33a9..ecd78c86c6 100644 --- a/models/issues/moderation.go +++ b/models/issues/moderation.go @@ -14,6 +14,8 @@ import ( // CommentData represents a trimmed down comment that is used for preserving // only the fields needed for abusive content reports (mainly string fields). type CommentData struct { + PosterID int64 + IssueID int64 Content string ContentVersion int CreatedUnix timeutil.TimeStamp @@ -24,6 +26,8 @@ type CommentData struct { // (keeping only the fields relevant for moderation purposes) func newCommentData(comment *Comment) CommentData { return CommentData{ + PosterID: comment.PosterID, + IssueID: comment.IssueID, Content: comment.Content, ContentVersion: comment.ContentVersion, CreatedUnix: comment.CreatedUnix, @@ -33,9 +37,8 @@ func newCommentData(comment *Comment) CommentData { // IfNeededCreateShadowCopyForComment checks if for the given comment there are any reports of abusive content submitted // and if found a shadow copy of relevant comment fields will be stored into DB and linked to the above report(s). -// This function should be called when a comment is deleted or updated. +// This function should be called before a comment is deleted or updated. func IfNeededCreateShadowCopyForComment(ctx context.Context, comment *Comment) error { - // TODO check comment.Type? if moderation.IsReported(ctx, moderation.ReportedContentTypeComment, comment.ID) { commentData := newCommentData(comment) content, err := json.Marshal(commentData)