API and web UI for posts, previews and post settings (phase 3, step 8)
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m0s
CI / test (push) Successful in 2m53s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s

/api/v1/federation gains:
  - GET /posts, DELETE /posts/{id}: manage your own posts from the UI.
  - GET /preview/weekly: what the weekly summary would say right now, for
    the week still in progress - never posted or stored. Backed by a new
    weekly.preview() and schedule.current_week_start().
  - GET /profiles/{username}/posts/{post_uuid} (public, unauthenticated):
    backs the UI's post page, which can't itself speak ActivityPub.

Settings gain timezone/post_weekly_summary/post_milestones, already
present in sharing.EDITABLE since phase 3 step 2 but never added to
SharingSettingsSchema, so the API was silently dropping them from
responses. timezone validates against the same is_valid_timezone() the
service layer uses, with a dedicated marshmallow validator.

Fixed a real gap found while wiring the post page: ids.post_page_url()
took a username but never put it in the URL, so post.html would have
had no way to know whose post to look up. It's now ?u=<username>&id=<uuid>.

Sharing page gets a "What to post" section (weekly summary and
milestones toggles, a timezone field with a browser-supplied IANA
datalist where Intl.supportedValuesOf exists, and a live preview).
New posts.html lists a user's posts with delete (mirroring followers.js's
confirm-before-destructive-action pattern); new post.html is the public
landing page for a post's `url`, reached by browsers redirected from the
raw ActivityPub endpoint.

Verified by hand against a local dev server and a real browser: sign in,
enable sharing, preview and publish, list and delete a post, and follow
the ActivityPub redirect through to the public post page and its 404
after deletion - fixed one bug found this way (the preview box was
collapsing the summary's line breaks).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
mattandClaude Sonnet 5 committed 2026-09-26 16:24:35 +01:00
1 parent d4f3607eef
commit 0acce9b948
16 files changed
+865 -8

No files matched your search

+292
View File
@@ -1953,6 +1953,150 @@
]
}
},
"/api/v1/federation/preview/weekly": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/WeeklyPreview"
}
}
}
},
"401": {
"description": "Not authenticated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"default": {
"$ref": "#/components/responses/DEFAULT_ERROR"
}
},
"summary": "Preview this week's summary",
"description": "What it would say right now, for the week still in progress. Never posted or stored.",
"tags": [
"Federation"
],
"security": [
{
"bearerAuth": []
}
]
}
},
"/api/v1/federation/posts": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Post"
}
}
}
}
},
"401": {
"description": "Not authenticated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"default": {
"$ref": "#/components/responses/DEFAULT_ERROR"
}
},
"summary": "Your posts",
"description": "Newest first, including deleted ones (their text stays visible to you; deleted_at\nshows when).",
"tags": [
"Federation"
],
"security": [
{
"bearerAuth": []
}
]
}
},
"/api/v1/federation/posts/{post_id}": {
"delete": {
"responses": {
"409": {
"description": "Already deleted",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "No such post",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"204": {
"description": "No Content"
},
"401": {
"description": "Not authenticated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"default": {
"$ref": "#/components/responses/DEFAULT_ERROR"
}
},
"summary": "Delete a post",
"description": "Sends a Delete to whoever received it.",
"tags": [
"Federation"
],
"security": [
{
"bearerAuth": []
}
]
},
"parameters": [
{
"in": "path",
"name": "post_id",
"required": true,
"schema": {
"type": "integer",
"minimum": 0
}
}
]
},
"/api/v1/federation/profiles/{username}": {
"get": {
"responses": {
@@ -1998,6 +2142,60 @@
}
]
},
"/api/v1/federation/profiles/{username}/posts/{post_uuid}": {
"get": {
"responses": {
"404": {
"description": "Not found, not public, or deleted",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PublicPost"
}
}
}
},
"default": {
"$ref": "#/components/responses/DEFAULT_ERROR"
}
},
"summary": "A public or unlisted post",
"description": "For the web UI's post page (the browser landing spot for a Note's `url`, since it\ncan't itself speak ActivityPub).",
"tags": [
"Federation"
]
},
"parameters": [
{
"in": "path",
"name": "username",
"required": true,
"schema": {
"type": "string",
"minLength": 1
}
},
{
"in": "path",
"name": "post_uuid",
"required": true,
"schema": {
"type": "string",
"minLength": 1
}
}
]
},
"/api/v1/federation/followers": {
"get": {
"parameters": [
@@ -4183,6 +4381,19 @@
],
"maxLength": 500
},
"timezone": {
"type": "string",
"description": "IANA time zone, e.g. `Europe/London`. Decides when a week ends for the weekly summary.",
"example": "Europe/London"
},
"post_weekly_summary": {
"type": "boolean",
"description": "Post a weekly summary of your listening"
},
"post_milestones": {
"type": "boolean",
"description": "Post scrobble-count, artist-plays and top-10 milestones as you hit them"
},
"handle": {
"type": "string",
"readOnly": true,
@@ -4250,6 +4461,19 @@
],
"maxLength": 500
},
"timezone": {
"type": "string",
"description": "IANA time zone, e.g. `Europe/London`. Decides when a week ends for the weekly summary.",
"example": "Europe/London"
},
"post_weekly_summary": {
"type": "boolean",
"description": "Post a weekly summary of your listening"
},
"post_milestones": {
"type": "boolean",
"description": "Post scrobble-count, artist-plays and top-10 milestones as you hit them"
},
"handle": {
"type": "string",
"readOnly": true,
@@ -4276,6 +4500,48 @@
},
"additionalProperties": false
},
"WeeklyPreview": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"html": {
"type": "string"
}
},
"additionalProperties": false
},
"Post": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"kind": {
"type": "string",
"description": "weekly or milestone"
},
"text": {
"type": "string"
},
"visibility": {
"type": "string"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"deleted_at": {
"type": [
"string",
"null"
],
"format": "date-time"
}
},
"additionalProperties": false
},
"PublicProfile": {
"type": "object",
"properties": {
@@ -4301,6 +4567,32 @@
},
"additionalProperties": false
},
"PublicPost": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"html": {
"type": "string"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"display_name": {
"type": "string"
},
"handle": {
"type": "string",
"example": "@alice@scrobble.example"
},
"profile_url": {
"type": "string"
}
},
"additionalProperties": false
},
"Follower": {
"type": "object",
"properties": {