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

+50 -1
View File
@@ -1,6 +1,12 @@
from marshmallow import Schema, fields, validate
from marshmallow import Schema, ValidationError, fields, validate
from scrobbler.federation.models import VISIBILITIES
from scrobbler.federation.protocol.schedule import is_valid_timezone
def _valid_timezone(value: str) -> None:
if not is_valid_timezone(value):
raise ValidationError("Not a known time zone.")
class SharingSettingsSchema(Schema):
@@ -20,6 +26,24 @@ class SharingSettingsSchema(Schema):
indexable = fields.Boolean(metadata={"description": "Posts may be indexed for search"})
display_name = fields.String(allow_none=True, validate=validate.Length(max=100))
bio = fields.String(allow_none=True, validate=validate.Length(max=500))
timezone = fields.String(
validate=_valid_timezone,
metadata={
"description": (
"IANA time zone, e.g. `Europe/London`. Decides when a week ends for the "
"weekly summary."
),
"example": "Europe/London",
},
)
post_weekly_summary = fields.Boolean(
metadata={"description": "Post a weekly summary of your listening"}
)
post_milestones = fields.Boolean(
metadata={
"description": "Post scrobble-count, artist-plays and top-10 milestones as you hit them"
}
)
handle = fields.String(dump_only=True, metadata={"example": "@alice@scrobble.example"})
actor_url = fields.String(dump_only=True)
profile_url = fields.String(dump_only=True)
@@ -61,3 +85,28 @@ class BlockSchema(Schema):
display_name = fields.String(allow_none=True)
actor_url = fields.String()
since = fields.DateTime()
class PostSchema(Schema):
id = fields.Integer()
kind = fields.String(metadata={"description": "weekly or milestone"})
text = fields.String()
visibility = fields.String()
created_at = fields.DateTime()
deleted_at = fields.DateTime(allow_none=True)
class WeeklyPreviewSchema(Schema):
text = fields.String()
html = fields.String()
class PublicPostSchema(Schema):
"""A public or unlisted post, for the web UI's post page (post.html)."""
text = fields.String()
html = fields.String()
created_at = fields.DateTime()
display_name = fields.String()
handle = fields.String(metadata={"example": "@alice@scrobble.example"})
profile_url = fields.String()