diff options
Diffstat (limited to 'internal')
| -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 | } | ||
