aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_comment.go
diff options
context:
space:
mode:
author赵智超 <1012112796@qq.com>2020-10-13 03:55:13 +0800
committerGitHub <noreply@github.com>2020-10-12 20:55:13 +0100
commit8be3e439c2b3a90fcb639b732008486b85314b8d (patch)
tree0d941779b1c545c4bfa41d8d54c1bf0f219a43eb /models/issue_comment.go
parentb546eda7a8fa17d86cf9722c9f7bcca009d40443 (diff)
downloadgitea-8be3e439c2b3a90fcb639b732008486b85314b8d.tar.gz
gitea-8be3e439c2b3a90fcb639b732008486b85314b8d.zip
Add team support for review request (#12039)
Add team support for review request Block #11355 Signed-off-by: a1012112796 <1012112796@qq.com> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'models/issue_comment.go')
-rw-r--r--models/issue_comment.go29
1 files changed, 26 insertions, 3 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go
index 726ed7472b..270a10e240 100644
--- a/models/issue_comment.go
+++ b/models/issue_comment.go
@@ -137,6 +137,8 @@ type Comment struct {
AssigneeID int64
RemovedAssignee bool
Assignee *User `xorm:"-"`
+ AssigneeTeamID int64 `xorm:"NOT NULL DEFAULT 0"`
+ AssigneeTeam *Team `xorm:"-"`
ResolveDoerID int64
ResolveDoer *User `xorm:"-"`
OldTitle string
@@ -487,11 +489,11 @@ func (c *Comment) UpdateAttachments(uuids []string) error {
return sess.Commit()
}
-// LoadAssigneeUser if comment.Type is CommentTypeAssignees, then load assignees
-func (c *Comment) LoadAssigneeUser() error {
+// LoadAssigneeUserAndTeam if comment.Type is CommentTypeAssignees, then load assignees
+func (c *Comment) LoadAssigneeUserAndTeam() error {
var err error
- if c.AssigneeID > 0 {
+ if c.AssigneeID > 0 && c.Assignee == nil {
c.Assignee, err = getUserByID(x, c.AssigneeID)
if err != nil {
if !IsErrUserNotExist(err) {
@@ -499,6 +501,25 @@ func (c *Comment) LoadAssigneeUser() error {
}
c.Assignee = NewGhostUser()
}
+ } else if c.AssigneeTeamID > 0 && c.AssigneeTeam == nil {
+ if err = c.LoadIssue(); err != nil {
+ return err
+ }
+
+ if err = c.Issue.LoadRepo(); err != nil {
+ return err
+ }
+
+ if err = c.Issue.Repo.GetOwner(); err != nil {
+ return err
+ }
+
+ if c.Issue.Repo.Owner.IsOrganization() {
+ c.AssigneeTeam, err = GetTeamByID(c.AssigneeTeamID)
+ if err != nil && !IsErrTeamNotExist(err) {
+ return err
+ }
+ }
}
return nil
}
@@ -685,6 +706,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
ProjectID: opts.ProjectID,
RemovedAssignee: opts.RemovedAssignee,
AssigneeID: opts.AssigneeID,
+ AssigneeTeamID: opts.AssigneeTeamID,
CommitID: opts.CommitID,
CommitSHA: opts.CommitSHA,
Line: opts.LineNum,
@@ -849,6 +871,7 @@ type CreateCommentOptions struct {
OldProjectID int64
ProjectID int64
AssigneeID int64
+ AssigneeTeamID int64
RemovedAssignee bool
OldTitle string
NewTitle string