Skip to content

Commit

Permalink
fix bug with kind being set to zero and replaced silently.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Nov 13, 2023
1 parent 795e98b commit 6a7a5eb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/nbd-wtf/go-nostr/nip19"
"github.com/nbd-wtf/go-nostr/nson"
"github.com/urfave/cli/v2"
"golang.org/x/exp/slices"
)

const CATEGORY_EVENT_FIELDS = "EVENT FIELDS"
Expand Down Expand Up @@ -129,20 +130,20 @@ example:
Tags: make(nostr.Tags, 0, 3),
}

kindWasSupplied := true
mustRehashAndResign := false
if stdinEvent != "" {
if err := json.Unmarshal([]byte(stdinEvent), &evt); err != nil {
lineProcessingError(c, "invalid event received from stdin: %s", err)
continue
}
kindWasSupplied = strings.Contains(stdinEvent, `"kind"`)
}
kindWasSupplied = slices.Contains(c.FlagNames(), "kind")

if kind := c.Int("kind"); kind != 0 {
if kind := c.Int("kind"); kindWasSupplied {
evt.Kind = kind
mustRehashAndResign = true
} else if evt.Kind == 0 {
evt.Kind = 1
mustRehashAndResign = true
}

if content := c.String("content"); content != "" {
Expand Down

0 comments on commit 6a7a5eb

Please sign in to comment.