mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-14 05:02:24 +00:00
fix: make sure to use unaltered fields when saving a shadow copy for updated profiles or comments (#8533)
Follow-up of !6977 ### Manual testing - User **S** creates an organization **O** and posts a comment **C** (on a random issue); - User **R** report as abuse the comment **C**, the organization **O** as well as the user **S**; - User **S** changes the content of comment **C** and the description of organization **O** as well as the description of their own profile; - Check (within DB) that shadow copies are being created (and linked to corresponding abuse reports) for comment **C**, organization **O** and user **S** and the content is the one from the moment when the reports were submitted (therefore before the updates made by **S**). Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8533 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: floss4good <floss4good@disroot.org> Co-committed-by: floss4good <floss4good@disroot.org>
This commit is contained in:
parent
b83a554921
commit
95e8bbd5f0
11 changed files with 173 additions and 11 deletions
|
@ -1156,7 +1156,7 @@ func UpdateComment(ctx context.Context, c *Comment, contentVersion int, doer *us
|
|||
defer committer.Close()
|
||||
|
||||
// If the comment was reported as abusive, a shadow copy should be created before first update.
|
||||
if err := IfNeededCreateShadowCopyForComment(ctx, c); err != nil {
|
||||
if err := IfNeededCreateShadowCopyForComment(ctx, c, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -1197,7 +1197,7 @@ func DeleteComment(ctx context.Context, comment *Comment) error {
|
|||
e := db.GetEngine(ctx)
|
||||
|
||||
// If the comment was reported as abusive, a shadow copy should be created before deletion.
|
||||
if err := IfNeededCreateShadowCopyForComment(ctx, comment); err != nil {
|
||||
if err := IfNeededCreateShadowCopyForComment(ctx, comment, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue