From 77398eba3126eb6b3614e8bc868a268aff668e44 Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Wed, 28 Oct 2026 13:58:45 -0400 Subject: [PATCH] fix: a new notification target becomes the default after the last one was removed (#33284) --- backend/open_webui/utils/notifications.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/open_webui/utils/notifications.py b/backend/open_webui/utils/notifications.py index d004af5e70..7d824730de 100644 --- a/backend/open_webui/utils/notifications.py +++ b/backend/open_webui/utils/notifications.py @@ -129,9 +129,10 @@ async def _load_notifications(user_id: str) -> dict[str, Any]: await Users.update_user_settings_by_id(user_id, {'notifications': notifications}) else: notifications['targets'] = [target for target in targets if isinstance(target, dict)] - notifications.setdefault( - 'default_target_id', notifications['targets'][0].get('id') if notifications['targets'] else None - ) + if not notifications.get('default_target_id'): + notifications['default_target_id'] = ( + notifications['targets'][0].get('id') if notifications['targets'] else None + ) if legacy_url and not notifications.get('legacy_notification_events_migrated'): changed = False for target in notifications['targets']: @@ -172,7 +173,8 @@ async def create_target(user_id: str, payload: dict[str, Any]) -> dict[str, Any] suffix += 1 targets.append(target) notifications['targets'] = targets - notifications.setdefault('default_target_id', target['id']) + if not notifications.get('default_target_id'): + notifications['default_target_id'] = target['id'] await Users.update_user_settings_by_id(user_id, {'notifications': notifications}) return _public_target(target, notifications.get('default_target_id'))