Struct NotificationCursor
- Namespace
- MailFathom.Application.Notifications
- Assembly
- MailFathom.Application.dll
Marks where one page of a person's notifications ended, so the next page continues from it.
public readonly record struct NotificationCursor : IEquatable<NotificationCursor>
- Implements
- Inherited Members
Remarks
The centre is ordered newest first by the instant a notification describes, with the identifier breaking a tie, and this pairs those two values. That is what makes the walk keyset-based rather than offset-based, and the choice matters more here than on a record nobody writes to while it is read: the client polls, so a notification raised between two pages would shift an offset window and repeat or skip a row on every page after it.
The fingerprint every keyset cursor here carries is the user rather than a set of filters, because the user is the only thing this reading narrows by and it comes off the credential rather than out of the request. So a cursor is refused when it is presented by somebody it was not issued to, which is a signed-out and signed-in-again client resuming a stale walk rather than an attack — the page it would continue is scoped to the caller's own user either way.
It carries no secret and needs no signature: every value in it is one the caller already received. The encoded form is KeysetCursorPayload's, which every keyset cursor here shares.
Properties
- NotificationId
Gets the identity of that notification, which breaks a tie between two describing the same instant.
- OccurredAt
Gets the instant the last notification the page returned describes.
- UserFingerprint
Gets the fingerprint of the user this cursor was issued for.
Methods
- After(DateTimeOffset, NotificationId, string)
Creates the cursor that continues a walk after one position in the centre.
- Encode()
Writes the cursor as the opaque string a caller presents to continue the walk.
- FingerprintOf(UserId)
Reduces a user to the short stable text a cursor carries to prove whose walk it belongs to.
- TryDecode(string?, out NotificationCursor?)
Reads a cursor a caller presented.