From 0d5111c5c32831cc5501d25a1cf142c6cce94903 Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Thu, 3 Dec 2020 15:37:33 -0600 Subject: [PATCH] Make sure email recipients can see issue (#13820) (#13827) * Initial pass * Remove over-op Signed-off-by: jolheiser --- services/mailer/mail_issue.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/mailer/mail_issue.go b/services/mailer/mail_issue.go index 01c198984b5..30b54eb6cb3 100644 --- a/services/mailer/mail_issue.go +++ b/services/mailer/mail_issue.go @@ -122,7 +122,17 @@ func mailIssueCommentBatch(ctx *mailCommentContext, ids []int64, visited map[int if err != nil { return err } - // TODO: Check issue visibility for each user + + // Make sure all recipients can still see the issue + idx := 0 + for _, r := range recipients { + if ctx.Issue.Repo.CheckUnitUser(r, models.UnitTypeIssues) { + recipients[idx] = r + idx++ + } + } + recipients = recipients[:idx] + // TODO: Separate recipients by language for i18n mail templates tos := make([]string, len(recipients)) for i := range recipients {