From 9e68261ca7a33c8007a456e6b757643a5ab40984 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Thu, 16 Feb 2023 05:19:46 +0200 Subject: 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 Co-authored-by: zeripath Co-authored-by: Lunny Xiao --- models/issues/comment.go | 5 +++++ models/issues/issue.go | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'models/issues') diff --git a/models/issues/comment.go b/models/issues/comment.go index 6877991a93..291714799b 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -1549,3 +1549,8 @@ func FixCommentTypeLabelWithOutsideLabels() (int64, error) { return res.RowsAffected() } + +// HasOriginalAuthor returns if a comment was migrated and has an original author. +func (c *Comment) HasOriginalAuthor() bool { + return c.OriginalAuthor != "" && c.OriginalAuthorID != 0 +} diff --git a/models/issues/issue.go b/models/issues/issue.go index b9aa649d21..3e2620691a 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -2466,3 +2466,8 @@ func DeleteOrphanedIssues() error { } return nil } + +// HasOriginalAuthor returns if an issue was migrated and has an original author. +func (issue *Issue) HasOriginalAuthor() bool { + return issue.OriginalAuthor != "" && issue.OriginalAuthorID != 0 +} -- cgit v1.2.3