dorfteich/packages/shared/src/watches.ts
Claude Fable 5 f4f27cbe78
All checks were successful
CI / Lint, typecheck, test (push) Successful in 3m23s
CI / Build container images (push) Has been skipped
CD / Build and push images (push) Successful in 3m47s
CD / Deploy to Test (push) Successful in 11s
CD / Smoke tests against Test (push) Successful in 1m14s
CD / Promote to Int (push) Successful in 10s
CI / Auth e2e pack (push) Successful in 5m28s
CI / Import/export fidelity gate (push) Successful in 46s
Add watches: follow pages and ponds with auto-watch preferences (#93)
New watches table (polymorphic target, unique per user+target; page purge
removes its rows via the trash service, and the list endpoint drops
targets the user can no longer read). Endpoints: idempotent PUT/DELETE
/watches/{page|pond}/:id gated by read access (404 hides the target),
GET state for the header toggles, and GET /users/me/watches resolving
names and links. Auto-watch hooks: creating a page and commenting
subscribe the actor, each behind a new user preference
(autoWatchOwnPages / autoWatchOnComment, default on) editable via the
profile PATCH and surfaced as checkboxes in the settings. UI: watch
toggle on the page header and the pond settings header, watch list with
unwatch in the account settings; new watches i18n namespace (de+en).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EwZ4jR4KFAPvpjWevfUGX1
2026-07-11 22:59:11 +02:00

30 lines
763 B
TypeScript

/**
* Watches (issue #93, data-model.md §watches): explicit per-user
* subscriptions to pages or whole ponds — the input side of the
* notification model (#94).
*/
export const WATCH_TARGET_TYPES = ['page', 'pond'] as const;
export type WatchTargetType = (typeof WATCH_TARGET_TYPES)[number];
export interface WatchView {
id: string;
targetType: WatchTargetType;
targetId: string;
/** Page title or pond name. */
name: string;
/** Link target: `/p/<pondSlug>` for ponds, `/p/<pondSlug>/<slug>` for pages. */
pondSlug: string;
slug: string | null;
createdAt: string;
}
export interface WatchListView {
watches: WatchView[];
}
/** The toggle state the page/pond headers need. */
export interface WatchStateView {
watched: boolean;
}