Files
Scrobbler/src/scrobbler/federation/protocol/addressing.py
T
mattandClaude Sonnet 5 dce90400e6
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 12s
CI / federation-interop (push) Successful in 1m1s
CI / test (push) Successful in 2m19s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
Post vocabulary and visibility addressing (phase 3, step 3)
Pure additions to federation/protocol:
- vocab: note() (a Note, no @context of its own — always embedded in
  a Create), create() (wraps an object with the post's addressing),
  delete() (a Tombstone, the shape Mastodon sends), hashtag() (name
  only; we don't serve tag pages), ordered_collection_page() for
  outbox paging, and ordered_collection() gains an optional `first`
  link
- addressing.py: one function turning a visibility (followers/
  unlisted/public) into (to, cc), unit-tested for each value

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 11:39:59 +01:00

27 lines
1016 B
Python

"""to/cc addressing for our posts, by visibility."""
from scrobbler.federation.protocol.vocab import PUBLIC
VISIBILITIES = ("followers", "unlisted", "public")
def address(visibility: str, followers_url: str) -> tuple[list[str], list[str]]:
"""(to, cc) for a Note/Create/Delete with this visibility.
followers: to followers, no cc (never reaches a public timeline or search).
unlisted: to followers, cc Public (visible to anyone who looks, not pushed to feeds).
public: to Public, cc followers (the normal public-post shape).
"""
if visibility not in VISIBILITIES:
raise ValueError(f"unknown visibility: {visibility!r}")
if visibility == "public":
return [PUBLIC], [followers_url]
if visibility == "unlisted":
return [followers_url], [PUBLIC]
return [followers_url], []
def is_public_or_unlisted(visibility: str) -> bool:
"""Whether a post at this visibility may be listed in the public outbox."""
return visibility in ("public", "unlisted")