diff options
author | Zettat123 | 2023-02-16 01:29:13 +0800 |
---|---|---|
committer | GitHub | 2023-02-15 12:29:13 -0500 |
commit | 0ab22a1a020865c9906487cf7735796ff01c4fd2 (patch) | |
tree | c591b41ca81d6b8d5211eec36844f1e1977f9dce /models | |
parent | 2c04595762b5c6ecfef8a32b05de7a5ef5f7066c (diff) |
fix incorrect role labels for migrated issues and comments (#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: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'models')
-rw-r--r-- | models/issues/comment.go | 5 | ||||
-rw-r--r-- | models/issues/issue.go | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/models/issues/comment.go b/models/issues/comment.go index c935e4ac9..36e7b8e78 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -1244,3 +1244,8 @@ func FixCommentTypeLabelWithOutsideLabels(ctx context.Context) (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 62b936331..e0dcf3d26 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -2403,3 +2403,8 @@ func DeleteOrphanedIssues(ctx context.Context) 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 +} |