Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter email receivers by user state #7426

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/identityserver/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ func (is *IdentityServer) SendNotificationEmailToUsers(ctx context.Context, noti
continue
}

// Skips over non approved users.
if receiver.State != ttnpb.State_STATE_APPROVED {
continue
}

wg.Go(func() error {
templateData, err := emailNotification.DataBuilder(
ctx,
Expand Down Expand Up @@ -147,7 +152,7 @@ func (is *IdentityServer) SendTemplateEmailToUserIDs(
return is.SendTemplateEmailToUsers(ctx, templateName, dataBuilder, receivers...)
}

var notificationEmailUserFields = store.FieldMask{"ids", "name", "primary_email_address", "admin"}
var notificationEmailUserFields = store.FieldMask{"ids", "name", "primary_email_address", "admin", "state"}

// SendNotificationEmailToUserIDs looks up the users and sends them a notification email.
func (is *IdentityServer) SendNotificationEmailToUserIDs(ctx context.Context, notification *ttnpb.Notification, receiverIDs ...*ttnpb.UserIdentifiers) error {
Expand Down
5 changes: 5 additions & 0 deletions pkg/identityserver/notification_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ func (is *IdentityServer) notifyAdminsInternal(ctx context.Context, req *ttnpb.C
if receiver.Ids.IDString() == ttnpb.SupportUserID {
continue
}

// Skips over non approved administrators.
if receiver.State != ttnpb.State_STATE_APPROVED {
continue
}
receiverUserIDs[i] = receiver.Ids
}

Expand Down
Loading