Skip to content

Commit

Permalink
Merge pull request #7426 from TheThingsNetwork/fix/support-access-req…
Browse files Browse the repository at this point in the history
…uested-changes

Filter email receivers by user state
  • Loading branch information
johanstokking authored Dec 6, 2024
2 parents 5dfb513 + da33718 commit b8f6e79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit b8f6e79

Please sign in to comment.