mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
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.
This commit is contained in:
parent
f154efcd58
commit
feabaab4bd
1 changed files with 9 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue