diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-09-27 18:17:02 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-09-27 19:59:22 -0400 |
| commit | eff129bc1f29bcb1b2b9d10c6b49ab886edc83d6 (patch) | |
| tree | b82892a6cf40f771998a85e5530012bab80157dc /docs/api.md | |
| parent | 68e3dce3c2e588376c6510783e908941360ac80e (diff) | |
Make `/api/events` a firehose endpoint.
It now includes events for all channels. Clients are responsible for filtering.
The schema for channel events has changed; it now includes a channel name and ID, in the same format as the sender's name and ID. They also now include a `"type"` field, whose only valid value (as of this writing) is `"message"`.
This is groundwork for delivering message deletion (expiry) events to clients, and notifying clients of channel lifecycle events.
Diffstat (limited to 'docs/api.md')
| -rw-r--r-- | docs/api.md | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/docs/api.md b/docs/api.md index 8bb3c0b..8b31941 100644 --- a/docs/api.md +++ b/docs/api.md @@ -152,18 +152,6 @@ Subscribes to events. This endpoint returns an `application/event-stream` respon The returned stream may terminate, to limit the number of outstanding messages held by the server. Clients can and should repeat the request, using the `Last-Event-Id` header to resume from where they left off. Events will be replayed from that point, and the stream will resume. -#### Query parameters - -This endpoint accepts the following query parameters: - -* `channel`: a channel ID to subscribe to. Events for this channel will be included in the response. This parameter may be provided multiple times. Clients should not subscribe to the same channel more than once in a single request. - -Browsers generally limit the number of open connections, often to embarrassingly low limits. Clients should subscribe to multiple streams in a single request, and should not subscribe to each stream individually. - -Requests without a subscription return an empty stream. - -(If you're wondering: it has to be query parameters or something equivalent to it, since `EventSource` can only issue `GET` requests.) - #### Request headers This endpoint accepts an optional `Last-Event-Id` header for resuming an interrupted stream. If this header is provided, it must be set to the `id` field sent with the last event the client has processed. When `Last-Event-Id` is sent, the response will resume immediately after the corresponding event. If this header is omitted, then the stream will start from the beginning. @@ -179,13 +167,17 @@ The returned event stream is a sequence of events: ```json id: 1234 data: { -data: "channel": "C9876cyyz", -data: "id": "Mabcd1234", -data: "sender": { -data: "id": "L1234abcd", -data: "name": "example username" -data: }, -data: "body": "my amazing thoughts, by bob", -data: "sent_at": "2024-09-19T02:30:50.915462Z" +data: "type": "message", +data: "at": "2024-09-27T23:19:10.208147Z", +data: "id": "Mxnjcf3y41prfry9", +data: "channel": { +data: "id": "C9876cyyz", +data: "name": "example channel 2" +data: }, +data: "sender": { +data: "id": "L1234abcd", +data: "name": "example username" +data: }, +data: "body": "beep" data: } ``` |
