mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-04-08 02:31:36 +02:00
include more details in comments' shadow copies
(useful in case the comment was deleted)
This commit is contained in:
parent
e483517c7c
commit
957cda9f09
1 changed files with 5 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue