Activity: notifications
The activity package: the signed notification inbox, read state and email notification settings for the current identity.

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

src/activity/client.ts

Service discovery, endpoint paths, the signed request

Notify client and signed requests

src/activity/model.ts

Wire types, snapshot validation, presentation, read rules, email input

Snapshot model and grouping

src/activity/sources.ts

activityLoad, activityApply, the committed snapshot handoff

Sources, the ask stamp and the committed snapshot

activity.contract

Shapes, ActivityScreen, ActivityEmailScreen

Screens, tasks and email settings

app.contract pkg:activity blocks

State, resource, mutation, four tasks, actions

Screens, tasks and email settings

src/activity/__tests__/activity.test.ts

17 Bun tests against the mock

all three pages

activity.test.contract

7 Contract tests against the local test server

Screens, tasks and email settings

tools/mock-notify/routes.ts

The fixture service

Mock notify 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

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime