Skip to content

Commit

Permalink
Merge pull request #118 from mattn/use-relaywrapper
Browse files Browse the repository at this point in the history
use eventstore.RelayWrapper
  • Loading branch information
mattn authored Jul 15, 2024
2 parents 7bd7458 + 9b56ffd commit d8fa9b0
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 d8fa9b0

Please sign in to comment.