]> source.dussan.org Git - gitea.git/commitdiff
Only update poster in issue/comment list if it has been loaded (#31216)
authorMax Wipfli <mail@maxwipfli.ch>
Sun, 2 Jun 2024 02:32:20 +0000 (04:32 +0200)
committerGitHub <noreply@github.com>
Sun, 2 Jun 2024 02:32:20 +0000 (10:32 +0800)
Previously, all posters were updated, even if they were not part of
posterMaps. In that case, a ghost user was erroneously inserted.

Fixes #31213.

models/issues/comment_list.go
models/issues/issue_list.go

index 6b4ad80eed59cd185163ac8ea5c172d0660dd291..61ac1c8f562e6b331014037ba27b19a7403973f0 100644 (file)
@@ -32,7 +32,9 @@ func (comments CommentList) LoadPosters(ctx context.Context) error {
        }
 
        for _, comment := range comments {
-               comment.Poster = getPoster(comment.PosterID, posterMaps)
+               if comment.Poster == nil {
+                       comment.Poster = getPoster(comment.PosterID, posterMaps)
+               }
        }
        return nil
 }
index 0dd37a04df230e83c2d72f4315080a7e9b5944cf..2c007c72ec62317ab4d1ce79544910d12fe1dd93 100644 (file)
@@ -87,7 +87,9 @@ func (issues IssueList) LoadPosters(ctx context.Context) error {
        }
 
        for _, issue := range issues {
-               issue.Poster = getPoster(issue.PosterID, posterMaps)
+               if issue.Poster == nil {
+                       issue.Poster = getPoster(issue.PosterID, posterMaps)
+               }
        }
        return nil
 }