mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-15 09:31:21 +00:00
fix: a new notification target becomes the default after the last one was removed (#33284)
This commit is contained in:
parent
fcc9284139
commit
77398eba31
1 changed files with 6 additions and 4 deletions
|
|
@ -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'))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue