Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tighten user notification API response types #18599

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 18 additions & 7 deletions lib/galaxy/schema/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Loading