From b228d22736c25de684e2eed6154623ca4b5d02bd Mon Sep 17 00:00:00 2001 From: guillep2k <18600385+guillep2k@users.noreply.github.com> Date: Thu, 12 Sep 2019 18:52:33 -0300 Subject: [PATCH] Add reviewrs as participants (#8124) --- models/issue.go | 2 +- routers/repo/issue.go | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/models/issue.go b/models/issue.go index 20af154b36..27f6ba0bca 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1446,7 +1446,7 @@ func getParticipantsByIssueID(e Engine, issueID int64) ([]*User, error) { userIDs := make([]int64, 0, 5) if err := e.Table("comment").Cols("poster_id"). Where("`comment`.issue_id = ?", issueID). - And("`comment`.type = ?", CommentTypeComment). + And("`comment`.type in (?,?,?)", CommentTypeComment, CommentTypeCode, CommentTypeReview). And("`user`.is_active = ?", true). And("`user`.prohibit_login = ?", false). Join("INNER", "`user`", "`user`.id = `comment`.poster_id"). diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 12c38b8620..583ca51a16 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -805,17 +805,7 @@ func ViewIssue(ctx *context.Context) { return } marked[comment.PosterID] = comment.ShowTag - - isAdded := false - for j := range participants { - if comment.Poster == participants[j] { - isAdded = true - break - } - } - if !isAdded && !issue.IsPoster(comment.Poster.ID) { - participants = append(participants, comment.Poster) - } + participants = addParticipant(comment.Poster, participants) } else if comment.Type == models.CommentTypeLabel { if err = comment.LoadLabel(); err != nil { ctx.ServerError("LoadLabel", err) @@ -851,6 +841,7 @@ func ViewIssue(ctx *context.Context) { ctx.ServerError("LoadReview", err) return } + participants = addParticipant(comment.Poster, participants) if comment.Review == nil { continue } @@ -1573,3 +1564,12 @@ func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) { "html": html, }) } + +func addParticipant(poster *models.User, participants []*models.User) []*models.User { + for _, part := range participants { + if poster.ID == part.ID { + return participants + } + } + return append(participants, poster) +}