Files
nostrlib/khatru/policies/kind_validation.go
2025-04-15 08:51:25 -03:00

30 lines
479 B
Go

package policies
import (
"context"
"encoding/json"
"fiatjaf.com/nostr"
)
func ValidateKind(ctx context.Context, evt *nostr.Event) (bool, string) {
switch evt.Kind {
case 0:
var m struct {
Name string `json:"name"`
}
json.Unmarshal([]byte(evt.Content), &m)
if m.Name == "" {
return true, "missing json name in kind 0"
}
case 1:
return false, ""
case 2:
return true, "this kind has been deprecated"
}
// TODO: all other kinds
return false, ""
}