Skip to content

Commit

Permalink
use eventstore.RelayWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Jul 15, 2024
1 parent 7bd7458 commit 9b56ffd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion add-event.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func AddEvent(ctx context.Context, relay Relay, evt *nostr.Event) (accepted bool
}

store := relay.Storage(ctx)
wrapper := &eventstore.RelayWrapper{
Store: store,
}
advancedSaver, _ := store.(AdvancedSaver)

if !relay.AcceptEvent(ctx, evt) {
Expand All @@ -31,7 +34,7 @@ func AddEvent(ctx context.Context, relay Relay, evt *nostr.Event) (accepted bool
advancedSaver.BeforeSave(ctx, evt)
}

if saveErr := store.SaveEvent(ctx, evt); saveErr != nil {
if saveErr := wrapper.Publish(ctx, *evt); saveErr != nil {
switch saveErr {
case eventstore.ErrDupEvent:
return true, saveErr.Error()
Expand Down

0 comments on commit 9b56ffd

Please sign in to comment.