basic: fix kind filtering (0 != nil).

This commit is contained in:
fiatjaf
2022-01-01 10:24:34 -03:00
parent e7286f0658
commit 61f21dd3a6

View File

@@ -28,16 +28,12 @@ func (b *BasicRelay) QueryEvents(
params = append(params, filter.ID)
}
if filter.Kind != nil && *filter.Kind != 0 {
if filter.Kind != nil {
conditions = append(conditions, "kind = ?")
params = append(params, filter.Kind)
}
if filter.Authors != nil {
if len(filter.Authors) == 0 {
// authors being [] means you won't get anything
return
} else {
inkeys := make([]string, 0, len(filter.Authors))
for _, key := range filter.Authors {
// to prevent sql attack here we will check if
@@ -48,8 +44,11 @@ func (b *BasicRelay) QueryEvents(
}
inkeys = append(inkeys, fmt.Sprintf("'%x'", parsed))
}
conditions = append(conditions, `pubkey IN (`+strings.Join(inkeys, ",")+`)`)
if len(inkeys) == 0 {
// authors being [] means you won't get anything
return
}
conditions = append(conditions, `pubkey IN (`+strings.Join(inkeys, ",")+`)`)
}
if filter.TagEvent != "" {