diff --git a/bp/blog/ghost/ghost_sync.py b/bp/blog/ghost/ghost_sync.py index 9f52c45..bf8e37c 100644 --- a/bp/blog/ghost/ghost_sync.py +++ b/bp/blog/ghost/ghost_sync.py @@ -1023,37 +1023,39 @@ async def sync_single_post(sess: AsyncSession, ghost_id: str) -> None: post, old_status = await _upsert_post(sess, gp, author_map, tag_map) - # Emit federation events for posts (not pages) + # Publish to federation inline (posts, not pages) if not post.is_page and post.user_id: - from shared.events import emit_event + from shared.services.federation_publish import try_publish from shared.infrastructure.urls import app_url post_url = app_url("coop", f"/{post.slug}/") if post.status == "published": - event_type = "post.published" if old_status != "published" else "post.updated" - await emit_event( + activity_type = "Create" if old_status != "published" else "Update" + await try_publish( sess, - event_type=event_type, - aggregate_type="Post", - aggregate_id=post.id, - payload={ - "user_id": post.user_id, - "title": post.title or "", - "excerpt": post.custom_excerpt or post.excerpt or "", + user_id=post.user_id, + activity_type=activity_type, + object_type="Article", + object_data={ + "name": post.title or "", + "content": post.custom_excerpt or post.excerpt or "", "url": post_url, }, + source_type="Post", + source_id=post.id, ) elif old_status == "published" and post.status != "published": - # Unpublished — notify federation to send Delete - await emit_event( + await try_publish( sess, - event_type="post.unpublished", - aggregate_type="Post", - aggregate_id=post.id, - payload={ - "user_id": post.user_id, - "url": post_url, + user_id=post.user_id, + activity_type="Delete", + object_type="Tombstone", + object_data={ + "id": post_url, + "formerType": "Article", }, + source_type="Post", + source_id=post.id, ) @@ -1089,36 +1091,39 @@ async def sync_single_page(sess: AsyncSession, ghost_id: str) -> None: post, old_status = await _upsert_post(sess, gp, author_map, tag_map) - # Emit federation events for pages + # Publish to federation inline (pages) if post.user_id: - from shared.events import emit_event + from shared.services.federation_publish import try_publish from shared.infrastructure.urls import app_url post_url = app_url("coop", f"/{post.slug}/") if post.status == "published": - event_type = "post.published" if old_status != "published" else "post.updated" - await emit_event( + activity_type = "Create" if old_status != "published" else "Update" + await try_publish( sess, - event_type=event_type, - aggregate_type="Post", - aggregate_id=post.id, - payload={ - "user_id": post.user_id, - "title": post.title or "", - "excerpt": post.custom_excerpt or post.excerpt or "", + user_id=post.user_id, + activity_type=activity_type, + object_type="Article", + object_data={ + "name": post.title or "", + "content": post.custom_excerpt or post.excerpt or "", "url": post_url, }, + source_type="Post", + source_id=post.id, ) elif old_status == "published" and post.status != "published": - await emit_event( + await try_publish( sess, - event_type="post.unpublished", - aggregate_type="Post", - aggregate_id=post.id, - payload={ - "user_id": post.user_id, - "url": post_url, + user_id=post.user_id, + activity_type="Delete", + object_type="Tombstone", + object_data={ + "id": post_url, + "formerType": "Article", }, + source_type="Post", + source_id=post.id, ) diff --git a/shared b/shared index 798fe56..3bde451 160000 --- a/shared +++ b/shared @@ -1 +1 @@ -Subproject commit 798fe56165d3188fbb1adee0f4bf5fef878e9032 +Subproject commit 3bde451ce9a2e5126187489cc37ab0305d908e0d