Skip to content

[C2S] Add Server-Sent Events (SSE) for real-time collection streaming#2945

Draft
pfefferle wants to merge 1 commit intoadd/c2s-supportfrom
add/sse-event-stream
Draft

[C2S] Add Server-Sent Events (SSE) for real-time collection streaming#2945
pfefferle wants to merge 1 commit intoadd/c2s-supportfrom
add/sse-event-stream

Conversation

@pfefferle
Copy link
Member

Implements the SWICG ActivityPub API SSE spec so C2S clients can subscribe to live updates on outbox and inbox collections instead of polling.

Proposed changes:

  • Add Event_Stream_Controller with SSE stream endpoint (GET /actors/{id}/{collection}/stream) that requires push OAuth scope
  • Add Event_Stream signal class using transients to efficiently notify the SSE polling loop of new items
  • Add access_token query parameter fallback in OAuth Server for EventSource clients (which cannot send Authorization headers)
  • Add eventStream property to outbox and inbox collection responses
  • Add proxyEventStream to actor endpoints (proxy endpoint returns 501 for now — wp_remote_get does not support streaming)

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Ensure the plugin is active and wp-env is running
  • Check actor JSON includes proxyEventStream in endpoints:
    curl http://localhost:8888/wp-json/activitypub/1.0/actors/1 | jq '.endpoints'
    
  • Check outbox collection response includes eventStream property:
    curl http://localhost:8888/wp-json/activitypub/1.0/actors/1/outbox | jq '.eventStream'
    
  • Obtain an OAuth token with push scope, then test the SSE stream:
    curl -N "http://localhost:8888/wp-json/activitypub/1.0/actors/1/outbox/stream?access_token=TOKEN"
    
    Should receive text/event-stream headers and keepalive comments every 5 seconds
  • Publish a post while SSE connection is open — should receive an Add event with the activity JSON

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Add real-time event streaming for connected apps using Server-Sent Events.

Implement the SWICG ActivityPub API SSE spec so C2S clients can
subscribe to live updates on outbox and inbox collections instead
of polling.

- Add Event_Stream_Controller with SSE stream endpoint per collection
- Add Event_Stream signal class using transients for efficient polling
- Add access_token query parameter fallback for EventSource clients
- Add eventStream property to outbox and inbox collection responses
- Add proxyEventStream to actor endpoints (proxy returns 501 for now)
@pfefferle pfefferle self-assigned this Feb 19, 2026
@pfefferle pfefferle requested a review from a team February 19, 2026 17:21
@pfefferle pfefferle changed the title Add Server-Sent Events (SSE) for real-time collection streaming [C2S] Add Server-Sent Events (SSE) for real-time collection streaming Feb 19, 2026
@pfefferle pfefferle added this to the ActivityPub API milestone Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants