diff --git a/app/routers/effects.py b/app/routers/effects.py index a07aaa6..b9ec4a4 100644 --- a/app/routers/effects.py +++ b/app/routers/effects.py @@ -316,6 +316,47 @@ async def list_effects( ) +@router.post("/{cid}/publish") +async def publish_effect( + cid: str, + request: Request, + ctx: UserContext = Depends(require_auth), +): + """Publish effect to L2 ActivityPub server.""" + from ..services.cache_service import CacheService + import database + + # Verify effect exists + effects_dir = get_effects_dir() + effect_dir = effects_dir / cid + if not effect_dir.exists(): + error = "Effect not found" + if wants_html(request): + return HTMLResponse(f'{error}') + raise HTTPException(404, error) + + # Use cache service to publish + cache_service = CacheService(database, get_cache_manager()) + ipfs_cid, error = await cache_service.publish_to_l2( + cid=cid, + actor_id=ctx.actor_id, + l2_server=ctx.l2_server, + auth_token=request.cookies.get("auth_token"), + ) + + if error: + if wants_html(request): + return HTMLResponse(f'{error}') + raise HTTPException(400, error) + + logger.info(f"Published effect {cid[:16]}... to L2 by {ctx.actor_id}") + + if wants_html(request): + return HTMLResponse(f'Shared: {ipfs_cid[:16]}...') + + return {"ipfs_cid": ipfs_cid, "cid": cid, "published": True} + + @router.delete("/{cid}") async def delete_effect( cid: str, diff --git a/app/templates/effects/detail.html b/app/templates/effects/detail.html index da3a975..fb389bf 100644 --- a/app/templates/effects/detail.html +++ b/app/templates/effects/detail.html @@ -141,6 +141,12 @@
+ +