Merge pull request #18599 from davelopez/improve_notifications_api_types

Tighten user notification API response types
This commit is contained in:
Björn Grüning
2024-07-26 09:32:47 +02:00
committed by GitHub
2 changed files with 19 additions and 9 deletions
+1 -2
View File
@@ -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
+18 -7
View File
@@ -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",