Add WARNING-level logging to federation publish handler

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-21 23:12:05 +00:00
parent 68941b97f6
commit a28add8640

View File

@@ -30,14 +30,17 @@ async def _try_publish(
) -> None:
"""Publish an AP activity if federation is available and user has a profile."""
if not services.has("federation"):
log.warning("_try_publish: no federation service")
return
if not user_id:
log.warning("_try_publish: no user_id for %s#%s", source_type, source_id)
return
# Check user has an ActorProfile (chose a username)
actor = await services.federation.get_actor_by_user_id(session, user_id)
if not actor:
log.warning("_try_publish: no ActorProfile for user_id=%s", user_id)
return
# Don't re-publish if we already have an activity for this source
@@ -45,8 +48,10 @@ async def _try_publish(
session, source_type, source_id,
)
if existing and activity_type == "Create":
log.warning("_try_publish: already published %s#%s", source_type, source_id)
return # Already published
log.warning("_try_publish: publishing %s/%s for %s#%d user=%s", activity_type, object_type, source_type, source_id, user_id)
try:
await services.federation.publish_activity(
session,
@@ -57,7 +62,7 @@ async def _try_publish(
source_type=source_type,
source_id=source_id,
)
log.info(
log.warning(
"Published %s/%s for %s#%d by user %d",
activity_type, object_type, source_type, source_id, user_id,
)