summaryrefslogtreecommitdiffstats
path: root/models/issues
diff options
context:
space:
mode:
authorYarden Shoham <hrsi88@gmail.com>2023-02-16 05:19:46 +0200
committerGitHub <noreply@github.com>2023-02-16 11:19:46 +0800
commit9e68261ca7a33c8007a456e6b757643a5ab40984 (patch)
treeac13cc2977e1a5c43164390b9a03e410985410f9 /models/issues
parente4238583db1647e05d0d664e5b2adae80b6270dc (diff)
downloadgitea-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 'models/issues')
-rw-r--r--models/issues/comment.go5
-rw-r--r--models/issues/issue.go5
2 files changed, 10 insertions, 0 deletions
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
+}