Notifications API reference
Notification API route handlers.
delete_notification
delete_notification(request, notification_id, token_user_id, db)
Delete one of the caller's notifications. 404 when the caller has no such notification.
Source code in backend/app/modules/notifications/router.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
mark_notification_as_read
mark_notification_as_read(request, notification_id, token_user_id, db)
Mark a specific notification as read.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, used by the rate limiter. |
required |
notification_id
|
UuidId
|
ID of the notification to mark as read. |
required |
token_user_id
|
CurrentUserId
|
ID of the user from the access token. |
required |
db
|
DbSession
|
Database session dependency. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None. |
Source code in backend/app/modules/notifications/router.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
mark_notifications_as_read
mark_notifications_as_read(request, token_user_id, db, body=None)
Mark notifications as read.
With {"ids": [...]} (at most 100) only those are marked; an id that is not the caller's is skipped, so the
answer does not reveal which ids exist. Without a body every unread notification of the caller is marked.
Source code in backend/app/modules/notifications/router.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
read_notifications_by_id
read_notifications_by_id(notification_id, token_user_id, db)
Retrieve a notification by ID for the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notification_id
|
UuidId
|
Unique ID of the notification. |
required |
token_user_id
|
CurrentUserId
|
ID of the user from the access token. |
required |
db
|
DbSession
|
Database session dependency. |
required |
Returns:
| Type | Description |
|---|---|
NotificationRead
|
The notification. |
Source code in backend/app/modules/notifications/router.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
read_notifications_user_pagination
read_notifications_user_pagination(token_user_id, db, cursor=None, num_records=None, unread_only=False)
List a keyset slice of the caller's notifications, newest first.
Pass the next_cursor of a slice as cursor to get the following one; it is null on the last slice.
unread_only=true keeps only the notifications that have not been read, and must stay the same across the
slices of one walk.
Source code in backend/app/modules/notifications/router.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
read_unread_notifications_count
read_unread_notifications_count(token_user_id, db)
Return how many of the caller's notifications have not been read.
Source code in backend/app/modules/notifications/router.py
17 18 19 20 21 22 23 24 25 26 27 28 29 | |
Pydantic schemas for notification entities.
AccountNoticeNotificationRead
Bases: _NotificationReadBase
A Garmin-unlinked or Strava-data-deleted notification, which carries no options.
Source code in backend/app/modules/notifications/schema.py
223 224 225 226 227 228 229 | |
AccountSecurityChangedNotificationOptions
Bases: NotificationOptions
Options of the notification that a security setting of the account changed.
Attributes:
| Name | Type | Description |
|---|---|---|
change |
StrictStr
|
The kind of change. |
idp_id |
UUID | None
|
The identity provider concerned, for an unlink. |
idp_name |
StrictStr | None
|
Its name, or None when it was deleted since. |
access_type |
StrictStr | None
|
The access type the account now has, for a role change. |
backup_codes_remaining |
StrictInt | None
|
How many unused backup codes are left, for a backup code that was used. |
Source code in backend/app/modules/notifications/schema.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
AccountSecurityChangedNotificationRead
Bases: _NotificationReadBase
A security-setting-changed notification.
Source code in backend/app/modules/notifications/schema.py
246 247 248 249 250 | |
ActivityNotificationOptions
Bases: NotificationOptions
Options of a new or duplicate activity notification.
Attributes:
| Name | Type | Description |
|---|---|---|
activity_id |
UUID
|
The stored activity. |
Source code in backend/app/modules/notifications/schema.py
82 83 84 85 86 87 88 89 | |
ActivityNotificationRead
Bases: _NotificationReadBase
A new-activity or duplicate-activity notification.
Source code in backend/app/modules/notifications/schema.py
204 205 206 207 208 | |
IdpLinkedNotificationOptions
Bases: NotificationOptions
Options of the notification that a sign-in provider was linked.
Attributes:
| Name | Type | Description |
|---|---|---|
idp_id |
UUID
|
The linked identity provider. |
idp_name |
StrictStr | None
|
Its name, or None when it was deleted since. |
Source code in backend/app/modules/notifications/schema.py
117 118 119 120 121 122 123 124 125 126 | |
IdpLinkedNotificationRead
Bases: _NotificationReadBase
A sign-in-provider-linked notification.
Source code in backend/app/modules/notifications/schema.py
239 240 241 242 243 | |
NewDeviceSignInNotificationOptions
Bases: NotificationOptions
Options of the notification that the account was signed in to from a new device.
Attributes:
| Name | Type | Description |
|---|---|---|
browser |
StrictStr
|
The browser family of the sign-in. |
operating_system |
StrictStr
|
The operating-system family of the sign-in. |
ip_address |
StrictStr
|
The client address of the sign-in. |
Source code in backend/app/modules/notifications/schema.py
147 148 149 150 151 152 153 154 155 156 157 158 | |
NewDeviceSignInNotificationRead
Bases: _NotificationReadBase
A new-device-sign-in notification.
Source code in backend/app/modules/notifications/schema.py
253 254 255 256 257 | |
NoNotificationOptions
Bases: NotificationOptions
The options of a notification that carries none.
Source code in backend/app/modules/notifications/schema.py
78 79 | |
NotificationBase
Bases: BaseModel
Base schema for notification data.
Attributes:
| Name | Type | Description |
|---|---|---|
options |
dict[str, Any] | None
|
Additional metadata for the notification. |
Source code in backend/app/modules/notifications/schema.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
NotificationCreate
Bases: NotificationBase
Schema for creating a notification record.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
NotificationType
|
Type of the notification. |
user_id |
UUID
|
FK to user. |
source_event_id |
str | None
|
Durable event ID for idempotent creation. |
Source code in backend/app/modules/notifications/schema.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
NotificationOptions
Bases: BaseModel
Base of the options a notification type stores.
Unknown keys are ignored on read, so a row written by an older release still loads.
Source code in backend/app/modules/notifications/schema.py
69 70 71 72 73 74 75 | |
NotificationPage
Bases: CursorPage[NotificationRead]
One keyset slice of the caller's notifications.
The list takes inserts at the head, so offset paging would repeat and skip rows across requests.
Source code in backend/app/modules/notifications/schema.py
273 274 275 276 277 | |
NotificationUnreadCount
Bases: BaseModel
The number of notifications a user has not read.
Attributes:
| Name | Type | Description |
|---|---|---|
count |
StrictInt
|
Number of unread notifications. |
Source code in backend/app/modules/notifications/schema.py
283 284 285 286 287 288 289 290 291 292 | |
NotificationsMarkRead
Bases: BaseModel
The notifications to mark as read.
Attributes:
| Name | Type | Description |
|---|---|---|
ids |
list[UUID]
|
The notifications to mark; each must be one of the caller's. |
Source code in backend/app/modules/notifications/schema.py
295 296 297 298 299 300 301 302 303 304 305 306 | |
StravaTokenExpiredNotificationOptions
Bases: NotificationOptions
Options of the notification that a Strava account was unlinked.
Attributes:
| Name | Type | Description |
|---|---|---|
delete_on |
date | None
|
The day the Strava data is deleted when Strava access was revoked; absent when the token was only rejected. |
Source code in backend/app/modules/notifications/schema.py
106 107 108 109 110 111 112 113 114 | |
StravaTokenExpiredNotificationRead
Bases: _NotificationReadBase
A Strava-unlinked notification.
Source code in backend/app/modules/notifications/schema.py
232 233 234 235 236 | |
UserReferenceNotificationOptions
Bases: NotificationOptions
Options of a notification that names another user.
Attributes:
| Name | Type | Description |
|---|---|---|
user_id |
UUID
|
The user the notification names. |
user_name |
StrictStr
|
That user's name when the notification was created. |
user_username |
StrictStr
|
That user's username when the notification was created. |
Source code in backend/app/modules/notifications/schema.py
92 93 94 95 96 97 98 99 100 101 102 103 | |
UserReferenceNotificationRead
Bases: _NotificationReadBase
A follow-request, follow-accepted, sign-up-approval or admin-promoted notification, which names a user.
Source code in backend/app/modules/notifications/schema.py
211 212 213 214 215 216 217 218 219 220 | |