From 5e1a2f9cc493bfd78da821e5f75faafd9b6d0ff7 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 21 Feb 2026 14:47:07 +0100 Subject: [PATCH] fix: filter recipients for new release mails Remove recipients that are not active (e.g. done by moderation or organizational reasons) and those that have the permi ssion to read releases on that repository. --- services/mailer/mail_release.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/mailer/mail_release.go b/services/mailer/mail_release.go index 0f2ef33fe1..2111083bd4 100644 --- a/services/mailer/mail_release.go +++ b/services/mailer/mail_release.go @@ -6,8 +6,11 @@ package mailer import ( "bytes" "context" + "slices" + access_model "forgejo.org/models/perm/access" repo_model "forgejo.org/models/repo" + "forgejo.org/models/unit" user_model "forgejo.org/models/user" "forgejo.org/modules/base" "forgejo.org/modules/log" @@ -40,6 +43,12 @@ func MailNewRelease(ctx context.Context, rel *repo_model.Release) { return } + // Users are not eligible to receive this mail if they are not active or + // they don't have permissions to read releases. + recipients = slices.DeleteFunc(recipients, func(u *user_model.User) bool { + return !u.IsActive || !access_model.CheckRepoUnitUser(ctx, rel.Repo, u, unit.TypeReleases) + }) + langMap := make(map[string][]*user_model.User) for _, user := range recipients { if user.ID != rel.PublisherID {