From 6d0beafca19869ae110d7d5aa37180b46e474fc9 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:58:36 +0200 Subject: [PATCH] Tighten user notification API response types This will exclude "broadcast" as a possible user notification response. --- client/src/api/schema/schema.ts | 3 +-- lib/galaxy/schema/notifications.py | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/client/src/api/schema/schema.ts b/client/src/api/schema/schema.ts index c10e2ba089d6..7b032f8caa49 100644 --- a/client/src/api/schema/schema.ts +++ b/client/src/api/schema/schema.ts @@ -12902,8 +12902,7 @@ export interface components { */ content: | components["schemas"]["MessageNotificationContent"] - | components["schemas"]["NewSharedItemNotificationContent"] - | components["schemas"]["BroadcastNotificationContent"]; + | components["schemas"]["NewSharedItemNotificationContent"]; /** * Create time * Format: date-time diff --git a/lib/galaxy/schema/notifications.py b/lib/galaxy/schema/notifications.py index 941752dc25e7..90bbaa346509 100644 --- a/lib/galaxy/schema/notifications.py +++ b/lib/galaxy/schema/notifications.py @@ -118,20 +118,30 @@ class NewSharedItemNotificationContent(Model): slug: str = Field(..., title="Slug", description="The slug of the shared item. Used for the link to the item.") -AnyNotificationContent = Annotated[ +NotificationContentField = Field( + default=..., + discriminator="category", + title="Content", + description="The content of the notification. The structure depends on the category.", +) + +AnyUserNotificationContent = Annotated[ Union[ MessageNotificationContent, NewSharedItemNotificationContent, + ], + NotificationContentField, +] + +AnyNotificationContent = Annotated[ + Union[ + AnyUserNotificationContent, BroadcastNotificationContent, ], - Field( - default=..., - discriminator="category", - title="Content", - description="The content of the notification. The structure depends on the category.", - ), + NotificationContentField, ] + NotificationIdField = Field( ..., title="ID", @@ -200,6 +210,7 @@ class UserNotificationResponse(NotificationResponse): """A notification response specific to the user.""" category: PersonalNotificationCategory = NotificationCategoryField + content: AnyUserNotificationContent seen_time: Optional[datetime] = Field( None, title="Seen time",