Skip to content

Commit 98764fb

Browse files
authored
Merge pull request #60 from fiatjaf/fix/grasp-kind-constraint
Enforce kind constraint in grasp ref validation and fix envconfig tag typo
2 parents fcc9475 + 52b2638 commit 98764fb

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

global/global.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var assets embed.FS
2424
var (
2525
S struct {
2626
Port string `envconfig:"PORT" default:"3334"`
27-
SFTPPort string `envconvig:"SFTP_PORT" default:"2222"`
27+
SFTPPort string `envconfig:"SFTP_PORT" default:"2222"`
2828
Host string `envconfig:"HOST" default:"localhost"`
2929
DataPath string `envconfig:"DATA_PATH" default:"./data"`
3030
NoAutoUpdates bool `envconfig:"NO_AUTO_UPDATES"`

grasp/validation.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package grasp
33
import (
44
"context"
55
"fmt"
6+
"slices"
67
"strings"
78

89
"fiatjaf.com/nostr"
@@ -77,11 +78,13 @@ func refExistsAsKind(eventId string, kinds []nostr.Kind) bool {
7778
return false
7879
}
7980

80-
for range global.IL.Main.QueryEvents(nostr.Filter{
81-
IDs: []nostr.ID{id},
82-
Kinds: kinds,
81+
// the ID query fast-path ignores the Kinds constraint, so check the kind ourselves
82+
for evt := range global.IL.Main.QueryEvents(nostr.Filter{
83+
IDs: []nostr.ID{id},
8384
}, 1) {
84-
return true
85+
if slices.Contains(kinds, evt.Kind) {
86+
return true
87+
}
8588
}
8689

8790
return false

0 commit comments

Comments
 (0)