diff options
author | Yarden Shoham <hrsi88@gmail.com> | 2023-02-16 05:19:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-16 11:19:46 +0800 |
commit | 9e68261ca7a33c8007a456e6b757643a5ab40984 (patch) | |
tree | ac13cc2977e1a5c43164390b9a03e410985410f9 /routers | |
parent | e4238583db1647e05d0d664e5b2adae80b6270dc (diff) | |
download | gitea-9e68261ca7a33c8007a456e6b757643a5ab40984.tar.gz gitea-9e68261ca7a33c8007a456e6b757643a5ab40984.zip |
fix incorrect role labels for migrated issues and comments (#22914) (#22923)
Backport #22914
Fix #22797.
## Reason
If a comment was migrated from other platforms, this comment may have an
original author and its poster is always not the original author. When
the `roleDescriptor` func get the poster's role descriptor for a
comment, it does not check if the comment has an original author. So the
migrated comments' original authors might be marked as incorrect roles.
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/issue.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 82abc85a19..a64d8425df 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1118,7 +1118,11 @@ func NewIssuePost(ctx *context.Context) { } // roleDescriptor returns the Role Descriptor for a comment in/with the given repo, poster and issue -func roleDescriptor(ctx stdCtx.Context, repo *repo_model.Repository, poster *user_model.User, issue *issues_model.Issue) (issues_model.RoleDescriptor, error) { +func roleDescriptor(ctx stdCtx.Context, repo *repo_model.Repository, poster *user_model.User, issue *issues_model.Issue, hasOriginalAuthor bool) (issues_model.RoleDescriptor, error) { + if hasOriginalAuthor { + return issues_model.RoleDescriptorNone, nil + } + perm, err := access_model.GetUserRepoPermission(ctx, repo, poster) if err != nil { return issues_model.RoleDescriptorNone, err @@ -1420,7 +1424,7 @@ func ViewIssue(ctx *context.Context) { // check if dependencies can be created across repositories ctx.Data["AllowCrossRepositoryDependencies"] = setting.Service.AllowCrossRepositoryDependencies - if issue.ShowRole, err = roleDescriptor(ctx, repo, issue.Poster, issue); err != nil { + if issue.ShowRole, err = roleDescriptor(ctx, repo, issue.Poster, issue, issue.HasOriginalAuthor()); err != nil { ctx.ServerError("roleDescriptor", err) return } @@ -1459,7 +1463,7 @@ func ViewIssue(ctx *context.Context) { continue } - comment.ShowRole, err = roleDescriptor(ctx, repo, comment.Poster, issue) + comment.ShowRole, err = roleDescriptor(ctx, repo, comment.Poster, issue, comment.HasOriginalAuthor()) if err != nil { ctx.ServerError("roleDescriptor", err) return @@ -1558,7 +1562,7 @@ func ViewIssue(ctx *context.Context) { continue } - c.ShowRole, err = roleDescriptor(ctx, repo, c.Poster, issue) + c.ShowRole, err = roleDescriptor(ctx, repo, c.Poster, issue, c.HasOriginalAuthor()) if err != nil { ctx.ServerError("roleDescriptor", err) return |