fix: filter out excluded notification agents from user preferences

The webhook notification field was inconsistently showing up for some users despite being excluded in the backend. This was happening because the frontend was displaying all notification preferences without filtering out the excluded agents.

Changes:
- Added excludedAgents array to match backend's excluded notification types
- Filter notification preferences in both edit and create user flows
- Prevents webhook, email, and mobile notification fields from appearing in user preferences

This change aligns the frontend behavior with the backend's intended design where webhook notifications are managed globally rather than per-user.

Fixes #5196
This commit is contained in:
tidusjar 2025-05-14 22:16:34 +01:00
parent acb679f99d
commit c9ab4f4f9f

View file

@ -37,6 +37,13 @@ export class UserManagementUserComponent implements OnInit {
private appUrl: string = this.customizationFacade.appUrl();
private accessToken: string;
// List of excluded notification agents that should not be shown in user preferences
private readonly excludedAgents = [
INotificationAgent.Email,
INotificationAgent.Mobile,
INotificationAgent.Webhook
];
constructor(private identityService: IdentityService,
private notificationService: MessageService,
private router: Router,
@ -74,9 +81,15 @@ export class UserManagementUserComponent implements OnInit {
}
});
if(this.edit) {
this.identityService.getNotificationPreferencesForUser(this.userId).subscribe(x => this.notificationPreferences = x);
this.identityService.getNotificationPreferencesForUser(this.userId).subscribe(x => {
// Filter out excluded notification agents
this.notificationPreferences = x.filter(pref => !this.excludedAgents.includes(pref.agent));
});
} else {
this.identityService.getNotificationPreferences().subscribe(x => this.notificationPreferences = x);
this.identityService.getNotificationPreferences().subscribe(x => {
// Filter out excluded notification agents
this.notificationPreferences = x.filter(pref => !this.excludedAgents.includes(pref.agent));
});
}
this.sonarrService.getQualityProfilesWithoutSettings().subscribe(x => {
this.sonarrQualities = x;