The activity package (pkg:activity) is the Activity tab. It shows the current identity's notifications (replies, mentions, discussions, site updates) grouped by day, tracks which are read, and manages the email address that the notify service sends notifications to. Every request is signed with the identity's key, so the tab only works for an identity whose key is on the device.
Responsibility
Discover the notify service of the configured server and talk to it with signed DAG-CBOR requests.
Validate the answer, group it into local calendar days and compute unread state.
Mark one notification or all of them as read.
Set, change, re-verify and remove the email address, and poll while verification is pending.
Keep the signed timestamp inside the service's 20 second window without signing on every frame.
Files
File | Role | Documented in |
|---|---|---|
Service discovery, endpoint paths, the signed request | ||
Wire types, snapshot validation, presentation, read rules, email input | ||
| ||
Shapes, | ||
| State, resource, mutation, four tasks, actions | |
17 Bun tests against the mock | all three pages | |
7 Contract tests against the local test server | ||
The fixture service |
Data flow
flowchart TD
TAB["Activity tab becomes active"] --> WAKE["task activityWake runs action activityAsk"]
WAKE --> STAMP["state: activityAskServer, activityAskAccount, activityAskAt"]
STAMP --> RES["resource activityData = activityLoad(server, account, active, utcOffset) with activityAskAt"]
RES --> SRC["sources.activityLoad"]
SRC --> KEY["signerFor: key from the secret store"]
SRC --> CFG["resolveNotifyUrl: GET server/hm/api/config"]
CFG --> REQ["notificationRequest: signed POST, application/cbor"]
REQ --> PARSE["parseSnapshot and identity check"]
PARSE --> PRES["present: days, rows, unread, email state"]
PRES --> SCREEN["ActivityScreen and ActivityEmailScreen"]
SCREEN --> ACT["actions: mark read, set email, resend, remove"]
ACT --> MUT["mutation activityChanged = activityApply(...)"]
MUT --> REQ
MUT --> COMMIT["committed snapshot handed to the next activityLoad"]Rules the package follows
Time is captured by a Contract action and passed in. client.ts says so directly: "time is captured by the calling Contract action, never by an ambient clock". The pattern is described in State, refresh and stale-reply patterns.
Data is scoped by owner. ActivityPage carries account and server, and the root shows it only when both match the current ones: "never display retained data for another owner".
A response for another identity is refused.
Signed requests never follow redirects.
Tests never contact the hosted service: every Contract test starts with fail fetch "https://hyper.media/hm/api/notify", and the local test server answers 403 on hosted notify paths.
Dependencies
Identity for signerFor.
Crypto: signed envelopes for createNotifyEnvelope.
Read: ids for document hrefs and avatar URLs.
Discuss for the thread route that comment notifications open.
In this section
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime