Publishing core: post, fan out, delete (phase 3, step 4)
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m1s
CI / test (push) Successful in 2m26s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m1s
CI / test (push) Successful in 2m26s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
federation/publishing/base.py: - publish(user_id, username, kind, key, text=, html=): idempotent — refuses (returns None, doesn't post) if the user has stopped sharing or a post with that key already exists, including when two worker passes race (caught as a duplicate-key error at commit, not raised). Builds Note + Create addressed from the user's current visibility, stores both, and fans out one delivery per distinct accepted follower's inbox (shared inbox preferred). - delete_post(user_id, username, post): sends Delete(Tombstone) to the same followers and tombstones the row; a no-op if already deleted. Addressed by the post's own visibility at the time it was posted, not the user's current setting. - delete_all_for(user_id, username): deletes every live post, for turning sharing off. Wired into PATCH /settings: turning sharing off now deletes every live post *before* rejecting followers (reject_all removes the followers that accepted_inboxes() needs). The phase 2 farewell-actor mechanism already covers these deliveries with no changes, since it just checks for any pending delivery on the user's activities. Small supporting changes: activities.store() made public (used from publishing now, not just activities.py's own narrow helpers); followers.accepted_inboxes() for fan-out; ids.py gains followers_url/note_url/post_page_url; sharing.settings_for()'s unsaved default object now sets every field a caller might read, not just the ones the old callers happened to need. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
dce90400e6
commit
b16ba116c4
10 files changed
+408
-11
No files matched your search
@@ -5,7 +5,7 @@ from flask_smorest import Blueprint, abort
|
||||
|
||||
from scrobbler.api.decorators import authenticated
|
||||
from scrobbler.extensions import db
|
||||
from scrobbler.federation import activities, sharing
|
||||
from scrobbler.federation import activities, publishing, sharing
|
||||
from scrobbler.federation import followers as follower_state
|
||||
from scrobbler.federation import metrics as fed_metrics
|
||||
from scrobbler.federation.models import FederationBlock, FederationFollower
|
||||
@@ -69,7 +69,7 @@ def update_settings(changes):
|
||||
|
||||
Turning sharing on makes you findable as your handle. Your handle can't change once
|
||||
people follow you. Visibility changes apply to new posts only. Turning sharing off
|
||||
removes all your followers (each is told).
|
||||
deletes your posts and removes all your followers (each is told).
|
||||
"""
|
||||
try:
|
||||
settings, toggled = sharing.update(g.user.id, changes)
|
||||
@@ -78,7 +78,9 @@ def update_settings(changes):
|
||||
if toggled is not None:
|
||||
fed_metrics.sharing_changes_total.labels(change="enabled" if toggled else "disabled").inc()
|
||||
if toggled is False:
|
||||
# Tell every follower (a Reject each), then forget them
|
||||
# Delete every live post first: reject_all removes the followers that
|
||||
# accepted_inboxes() needs to know where to send the Deletes.
|
||||
publishing.delete_all_for(g.user.id, g.user.username)
|
||||
follower_state.reject_all(g.user.id, g.user.username)
|
||||
db.session.commit()
|
||||
return _settings_body(g.user, settings)
|
||||
|
||||
Reference in new issue
Block a user