diff options
| author | Clawd <ai@clawd.bot> | 2026-03-08 09:58:35 -0700 |
|---|---|---|
| committer | Clawd <ai@clawd.bot> | 2026-03-08 09:58:35 -0700 |
| commit | 975acc2bf48ddbd98d58864ba04f95b2fcca6803 (patch) | |
| tree | e83bc32a466f424e9086a6f4e10d7b4276d51946 /internal/handler | |
| parent | 4522797a0cf378cc44485ed77a01dee9643b6ebe (diff) | |
Add ephemeral event support (kinds 20000-29999)
Per NIP-01, ephemeral events are broadcast to subscribers but not
persisted to storage. This enables real-time features like typing
indicators without bloating the database.
Also adds typing-indicators.md spec for kind 20001.
Diffstat (limited to 'internal/handler')
| -rw-r--r-- | internal/handler/websocket/handler.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/handler/websocket/handler.go b/internal/handler/websocket/handler.go index c64f3f9..b591f61 100644 --- a/internal/handler/websocket/handler.go +++ b/internal/handler/websocket/handler.go | |||
| @@ -359,6 +359,14 @@ func (h *Handler) handleEvent(ctx context.Context, conn *websocket.Conn, raw []j | |||
| 359 | return nil | 359 | return nil |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | // Handle ephemeral events (kinds 20000-29999) - broadcast but don't store | ||
| 363 | if isEphemeralKind(pbEvent.Kind) { | ||
| 364 | h.subs.MatchAndFan(pbEvent) | ||
| 365 | status = "ok" | ||
| 366 | h.sendOK(ctx, conn, event.ID, true, "") | ||
| 367 | return nil | ||
| 368 | } | ||
| 369 | |||
| 362 | eventData := &storage.EventData{ | 370 | eventData := &storage.EventData{ |
| 363 | Event: pbEvent, | 371 | Event: pbEvent, |
| 364 | CanonicalJSON: canonicalJSON, | 372 | CanonicalJSON: canonicalJSON, |
| @@ -643,3 +651,10 @@ func (h *Handler) isAllowedKind(kind int32) bool { | |||
| 643 | } | 651 | } |
| 644 | return h.allowedKinds[kind] | 652 | return h.allowedKinds[kind] |
| 645 | } | 653 | } |
| 654 | |||
| 655 | // isEphemeralKind returns true if the event kind is ephemeral (20000-29999). | ||
| 656 | // Ephemeral events are broadcast to subscribers but not stored. | ||
| 657 | // See NIP-01: https://github.com/nostr-protocol/nips/blob/master/01.md | ||
| 658 | func isEphemeralKind(kind int32) bool { | ||
| 659 | return kind >= 20000 && kind < 30000 | ||
| 660 | } | ||
