|
# retoor <retoor@molodetz.nl>
|
|
|
|
from .._shared import endpoint, field
|
|
|
|
GROUP = {
|
|
"slug": "notifications",
|
|
"title": "Notifications",
|
|
"intro": """
|
|
# Notifications
|
|
|
|
Read your notification feed and mark items read. The unread counts endpoint backs the badges
|
|
in the navigation bar. Deliver these to the browser with [Web Push](/docs/push.html).
|
|
|
|
Every endpoint follows the shared [Conventions & Errors](/docs/conventions.html) (auth, content
|
|
negotiation, pagination, status codes); see [Authentication](/docs/authentication.html) for the
|
|
four ways to sign requests.
|
|
""",
|
|
"endpoints": [
|
|
endpoint(
|
|
id="notifications-list",
|
|
method="GET",
|
|
path="/notifications",
|
|
title="View notifications",
|
|
summary="Render your notifications. Returns an HTML page.",
|
|
auth="user",
|
|
interactive=True,
|
|
params=[
|
|
field("before", "query", "string", False, "", "Pagination cursor.")
|
|
],
|
|
),
|
|
endpoint(
|
|
id="notifications-counts",
|
|
method="GET",
|
|
path="/notifications/counts",
|
|
title="Unread counts",
|
|
summary="Unread notification and message counts.",
|
|
auth="public",
|
|
notes=[
|
|
'Guests receive `{ "notifications": 0, "messages": 0 }` instead of an error, so the navigation badge works before login.'
|
|
],
|
|
sample_response={"notifications": 2, "messages": 1},
|
|
),
|
|
endpoint(
|
|
id="notifications-open",
|
|
method="GET",
|
|
path="/notifications/open/{notification_uid}",
|
|
title="Open a notification",
|
|
summary="Mark a notification read and redirect to its target.",
|
|
auth="user",
|
|
interactive=False,
|
|
params=[
|
|
field(
|
|
"notification_uid",
|
|
"path",
|
|
"string",
|
|
True,
|
|
"NOTIFICATION_UID",
|
|
"UID of the notification.",
|
|
)
|
|
],
|
|
),
|
|
endpoint(
|
|
id="notifications-mark-read",
|
|
method="POST",
|
|
path="/notifications/mark-read/{notification_uid}",
|
|
title="Mark one read",
|
|
summary="Mark a single notification as read.",
|
|
auth="user",
|
|
params=[
|
|
field(
|
|
"notification_uid",
|
|
"path",
|
|
"string",
|
|
True,
|
|
"NOTIFICATION_UID",
|
|
"UID of the notification.",
|
|
)
|
|
],
|
|
),
|
|
endpoint(
|
|
id="notifications-mark-all-read",
|
|
method="POST",
|
|
path="/notifications/mark-all-read",
|
|
title="Mark all read",
|
|
summary="Mark every notification as read.",
|
|
auth="user",
|
|
),
|
|
],
|
|
}
|