OnEphemeralEvent()

This commit is contained in:
fiatjaf
2024-01-10 16:24:35 -03:00
parent 89ac8f1f1a
commit 8842ec2edd
2 changed files with 4 additions and 0 deletions

View File

@@ -27,6 +27,9 @@ func (rl *Relay) AddEvent(ctx context.Context, evt *nostr.Event) error {
if 20000 <= evt.Kind && evt.Kind < 30000 {
// do not store ephemeral events
for _, oee := range rl.OnEphemeralEvent {
oee(ctx, evt)
}
} else {
if evt.Kind == 0 || evt.Kind == 3 || (10000 <= evt.Kind && evt.Kind < 20000) {
// replaceable event, delete before storing

View File

@@ -57,6 +57,7 @@ type Relay struct {
OnConnect []func(ctx context.Context)
OnDisconnect []func(ctx context.Context)
OnEventSaved []func(ctx context.Context, event *nostr.Event)
OnEphemeralEvent []func(ctx context.Context, event *nostr.Event)
// editing info will affect
Info *nip11.RelayInformationDocument