mirror of
https://github.com/fiatjaf/nak.git
synced 2024-11-22 16:19:07 -05:00
fix bug with kind being set to zero and replaced silently.
This commit is contained in:
parent
795e98bc2e
commit
6a7a5eb26e
9
event.go
9
event.go
|
@ -15,6 +15,7 @@ import (
|
||||||
"github.com/nbd-wtf/go-nostr/nip19"
|
"github.com/nbd-wtf/go-nostr/nip19"
|
||||||
"github.com/nbd-wtf/go-nostr/nson"
|
"github.com/nbd-wtf/go-nostr/nson"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
const CATEGORY_EVENT_FIELDS = "EVENT FIELDS"
|
const CATEGORY_EVENT_FIELDS = "EVENT FIELDS"
|
||||||
|
@ -129,20 +130,20 @@ example:
|
||||||
Tags: make(nostr.Tags, 0, 3),
|
Tags: make(nostr.Tags, 0, 3),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kindWasSupplied := true
|
||||||
mustRehashAndResign := false
|
mustRehashAndResign := false
|
||||||
if stdinEvent != "" {
|
if stdinEvent != "" {
|
||||||
if err := json.Unmarshal([]byte(stdinEvent), &evt); err != nil {
|
if err := json.Unmarshal([]byte(stdinEvent), &evt); err != nil {
|
||||||
lineProcessingError(c, "invalid event received from stdin: %s", err)
|
lineProcessingError(c, "invalid event received from stdin: %s", err)
|
||||||
continue
|
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
|
evt.Kind = kind
|
||||||
mustRehashAndResign = true
|
mustRehashAndResign = true
|
||||||
} else if evt.Kind == 0 {
|
|
||||||
evt.Kind = 1
|
|
||||||
mustRehashAndResign = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if content := c.String("content"); content != "" {
|
if content := c.String("content"); content != "" {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user