diff options
author | kolaente <konrad@kola-entertainments.de> | 2018-05-09 18:29:04 +0200 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2018-05-09 19:29:04 +0300 |
commit | 95f2e2b57beedcdeb2b9623dc86e26f252fdd7bd (patch) | |
tree | ebfeb5b898f72fc57ac1fe9680374fdb4bc91aeb /models/issue_comment.go | |
parent | 238a997ec0b5d3e3bed0e55edcacebb44f86d373 (diff) | |
download | gitea-95f2e2b57beedcdeb2b9623dc86e26f252fdd7bd.tar.gz gitea-95f2e2b57beedcdeb2b9623dc86e26f252fdd7bd.zip |
Multiple assignees (#3705)
Diffstat (limited to 'models/issue_comment.go')
-rw-r--r-- | models/issue_comment.go | 112 |
1 files changed, 51 insertions, 61 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go index aedb124863..2c5875c29c 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -81,23 +81,22 @@ const ( // Comment represents a comment in commit and issue page. type Comment struct { - ID int64 `xorm:"pk autoincr"` - Type CommentType - PosterID int64 `xorm:"INDEX"` - Poster *User `xorm:"-"` - IssueID int64 `xorm:"INDEX"` - LabelID int64 - Label *Label `xorm:"-"` - OldMilestoneID int64 - MilestoneID int64 - OldMilestone *Milestone `xorm:"-"` - Milestone *Milestone `xorm:"-"` - OldAssigneeID int64 - AssigneeID int64 - Assignee *User `xorm:"-"` - OldAssignee *User `xorm:"-"` - OldTitle string - NewTitle string + ID int64 `xorm:"pk autoincr"` + Type CommentType + PosterID int64 `xorm:"INDEX"` + Poster *User `xorm:"-"` + IssueID int64 `xorm:"INDEX"` + LabelID int64 + Label *Label `xorm:"-"` + OldMilestoneID int64 + MilestoneID int64 + OldMilestone *Milestone `xorm:"-"` + Milestone *Milestone `xorm:"-"` + AssigneeID int64 + RemovedAssignee bool + Assignee *User `xorm:"-"` + OldTitle string + NewTitle string CommitID int64 Line int64 @@ -247,18 +246,9 @@ func (c *Comment) LoadMilestone() error { return nil } -// LoadAssignees if comment.Type is CommentTypeAssignees, then load assignees -func (c *Comment) LoadAssignees() error { +// LoadAssigneeUser if comment.Type is CommentTypeAssignees, then load assignees +func (c *Comment) LoadAssigneeUser() error { var err error - if c.OldAssigneeID > 0 { - c.OldAssignee, err = getUserByID(x, c.OldAssigneeID) - if err != nil { - if !IsErrUserNotExist(err) { - return err - } - c.OldAssignee = NewGhostUser() - } - } if c.AssigneeID > 0 { c.Assignee, err = getUserByID(x, c.AssigneeID) @@ -324,21 +314,21 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err LabelID = opts.Label.ID } comment := &Comment{ - Type: opts.Type, - PosterID: opts.Doer.ID, - Poster: opts.Doer, - IssueID: opts.Issue.ID, - LabelID: LabelID, - OldMilestoneID: opts.OldMilestoneID, - MilestoneID: opts.MilestoneID, - OldAssigneeID: opts.OldAssigneeID, - AssigneeID: opts.AssigneeID, - CommitID: opts.CommitID, - CommitSHA: opts.CommitSHA, - Line: opts.LineNum, - Content: opts.Content, - OldTitle: opts.OldTitle, - NewTitle: opts.NewTitle, + Type: opts.Type, + PosterID: opts.Doer.ID, + Poster: opts.Doer, + IssueID: opts.Issue.ID, + LabelID: LabelID, + OldMilestoneID: opts.OldMilestoneID, + MilestoneID: opts.MilestoneID, + RemovedAssignee: opts.RemovedAssignee, + AssigneeID: opts.AssigneeID, + CommitID: opts.CommitID, + CommitSHA: opts.CommitSHA, + Line: opts.LineNum, + Content: opts.Content, + OldTitle: opts.OldTitle, + NewTitle: opts.NewTitle, } if _, err = e.Insert(comment); err != nil { return nil, err @@ -480,14 +470,14 @@ func createMilestoneComment(e *xorm.Session, doer *User, repo *Repository, issue }) } -func createAssigneeComment(e *xorm.Session, doer *User, repo *Repository, issue *Issue, oldAssigneeID, assigneeID int64) (*Comment, error) { +func createAssigneeComment(e *xorm.Session, doer *User, repo *Repository, issue *Issue, assigneeID int64, removedAssignee bool) (*Comment, error) { return createComment(e, &CreateCommentOptions{ - Type: CommentTypeAssignees, - Doer: doer, - Repo: repo, - Issue: issue, - OldAssigneeID: oldAssigneeID, - AssigneeID: assigneeID, + Type: CommentTypeAssignees, + Doer: doer, + Repo: repo, + Issue: issue, + RemovedAssignee: removedAssignee, + AssigneeID: assigneeID, }) } @@ -548,17 +538,17 @@ type CreateCommentOptions struct { Issue *Issue Label *Label - OldMilestoneID int64 - MilestoneID int64 - OldAssigneeID int64 - AssigneeID int64 - OldTitle string - NewTitle string - CommitID int64 - CommitSHA string - LineNum int64 - Content string - Attachments []string // UUIDs of attachments + OldMilestoneID int64 + MilestoneID int64 + AssigneeID int64 + RemovedAssignee bool + OldTitle string + NewTitle string + CommitID int64 + CommitSHA string + LineNum int64 + Content string + Attachments []string // UUIDs of attachments } // CreateComment creates comment of issue or commit. |