Migrate callers from attach-child/detach-child to relate/unrelate API

Switch all cross-service relation calls to the new registry-aware
relate/unrelate/can-relate actions, and consolidate per-service
container-nav fragment fetches into the generic relations handler.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 09:24:52 +00:00
parent 53c4a0a1e0
commit d2f1da4944
9 changed files with 65 additions and 70 deletions

View File

@@ -7,7 +7,6 @@ from sqlalchemy.ext.asyncio import AsyncSession
from shared.contracts.dtos import MarketPlaceDTO
from shared.infrastructure.actions import call_action, ActionError
from shared.infrastructure.data_client import fetch_data
from shared.services.registry import services
@@ -41,11 +40,11 @@ async def create_market(sess: AsyncSession, post_id: int, name: str) -> MarketPl
if not post.is_page:
raise MarketError("Markets can only be created on pages, not posts.")
raw_pc = await fetch_data("blog", "page-config",
params={"container_type": "page", "container_id": post_id},
required=False)
if raw_pc is None or not (raw_pc.get("features") or {}).get("market"):
raise MarketError("Market feature is not enabled for this page. Enable it in page settings first.")
check = await call_action("relations", "can-relate", payload={
"relation_type": "page->market", "from_id": post_id,
})
if not check.get("allowed"):
raise MarketError(check.get("reason", "Cannot create market for this page."))
try:
result = await call_action("market", "create-marketplace", payload={