mirror of
https://github.com/aljazceru/khatru.git
synced 2026-01-15 11:24:19 +01:00
34 lines
703 B
Go
34 lines
703 B
Go
package plugins
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/nbd-wtf/go-nostr"
|
|
)
|
|
|
|
func NoPrefixFilters(ctx context.Context, filter nostr.Filter) (reject bool, msg string) {
|
|
for _, id := range filter.IDs {
|
|
if len(id) != 64 {
|
|
return true, fmt.Sprintf("filters can only contain full ids")
|
|
}
|
|
}
|
|
for _, pk := range filter.Authors {
|
|
if len(pk) != 64 {
|
|
return true, fmt.Sprintf("filters can only contain full pubkeys")
|
|
}
|
|
}
|
|
|
|
return false, ""
|
|
}
|
|
|
|
func NoComplexFilters(ctx context.Context, filter nostr.Filter) (reject bool, msg string) {
|
|
items := len(filter.Tags) + len(filter.Kinds)
|
|
|
|
if items > 4 && len(filter.Tags) > 2 {
|
|
return true, "too many things to filter for"
|
|
}
|
|
|
|
return false, ""
|
|
}
|