khatru/plugins/events.go
2023-08-10 14:32:11 -03:00

23 lines
448 B
Go

package plugins
import (
"context"
"github.com/nbd-wtf/go-nostr"
)
func PreventTooManyIndexableTags(max int) func(context.Context, *nostr.Event) (bool, string) {
return func(ctx context.Context, event *nostr.Event) (reject bool, msg string) {
ntags := 0
for _, tag := range event.Tags {
if len(tag) > 0 && len(tag[0]) == 1 {
ntags++
}
}
if ntags > max {
return true, "too many indexable tags"
}
return false, ""
}
}