You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
847 B
30 lines
847 B
package routing |
|
|
|
import ( |
|
"git.mleku.dev/mleku/nostr/encoders/event" |
|
"git.mleku.dev/mleku/nostr/encoders/kind" |
|
) |
|
|
|
// Publisher abstracts event delivery to subscribers. |
|
type Publisher interface { |
|
// Deliver sends an event to all matching subscribers. |
|
Deliver(ev *event.E) |
|
} |
|
|
|
// IsEphemeral checks if a kind is ephemeral (20000-29999). |
|
func IsEphemeral(k uint16) bool { |
|
return kind.IsEphemeral(k) |
|
} |
|
|
|
// MakeEphemeralHandler creates a handler for ephemeral events. |
|
// Ephemeral events (kinds 20000-29999): |
|
// - Are NOT persisted to the database |
|
// - Are immediately delivered to subscribers |
|
func MakeEphemeralHandler(publisher Publisher) Handler { |
|
return func(ev *event.E, authedPubkey []byte) Result { |
|
// Clone and deliver immediately without persistence |
|
cloned := ev.Clone() |
|
go publisher.Deliver(cloned) |
|
return HandledResult("") |
|
} |
|
}
|
|
|