aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_comment.go
diff options
context:
space:
mode:
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