mirror of
https://github.com/fiatjaf/khatru.git
synced 2025-03-19 06:12:44 +01:00
23 lines
448 B
Go
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, ""
|
|
}
|
|
}
|