From 681bd55e5595db092d0e0a0470097336f010f129 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Wed, 11 Mar 2026 10:49:41 -0300 Subject: [PATCH] replace "no-text" with "supported_kinds". --- nip29/group.go | 37 +++++++++++++++++++++++-------------- nip29/moderation_actions.go | 11 ----------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/nip29/group.go b/nip29/group.go index 5837d25..eac2058 100644 --- a/nip29/group.go +++ b/nip29/group.go @@ -4,6 +4,7 @@ import ( "fmt" "net/url" "slices" + "strconv" "strings" "fiatjaf.com/nostr" @@ -55,12 +56,12 @@ type Group struct { // indicates that relays should hide group metadata from non-members Hidden bool - // indicates that text messages are not allowed in the group - NoText bool - // indicates that the group supports audio/video live chat Livekit bool + // indicates which event kinds this group supports + SupportedKinds []nostr.Kind + Roles []*Role InviteCodes []string @@ -75,7 +76,6 @@ func (group Group) String() string { maybeRestricted := "" maybeHidden := "" maybeClosed := "" - maybeNoText := "" if group.Private { maybePrivate = " private" @@ -89,9 +89,6 @@ func (group Group) String() string { if group.Closed { maybeClosed = " closed" } - if group.NoText { - maybeNoText = " no-text" - } maybeLivekit := "" if group.Livekit { @@ -123,7 +120,6 @@ func (group Group) String() string { maybeRestricted, maybeHidden, maybeClosed, - maybeNoText, maybeLivekit, group.Picture, group.About, @@ -190,14 +186,19 @@ func (group Group) ToMetadataEvent() nostr.Event { if group.Closed { evt.Tags = append(evt.Tags, nostr.Tag{"closed"}) } - if group.NoText { - evt.Tags = append(evt.Tags, nostr.Tag{"no-text"}) - } - if group.Livekit { evt.Tags = append(evt.Tags, nostr.Tag{"livekit"}) } + if group.SupportedKinds != nil { + tag := make(nostr.Tag, 1, 1+len(group.SupportedKinds)) + tag[0] = "supported_kinds" + for _, kind := range group.SupportedKinds { + tag = append(tag, strconv.Itoa(int(kind))) + } + evt.Tags = append(evt.Tags, tag) + } + return evt } @@ -282,10 +283,18 @@ func (group *Group) MergeInMetadataEvent(evt *nostr.Event) error { group.Closed = true case "hidden": group.Hidden = true - case "no-text": - group.NoText = true case "livekit": group.Livekit = true + case "supported_kinds": + kinds := make([]nostr.Kind, 0, len(tag)-1) + for _, raw := range tag[1:] { + kind, err := strconv.Atoi(raw) + if err != nil { + continue + } + kinds = append(kinds, nostr.Kind(kind)) + } + group.SupportedKinds = kinds default: if len(tag) >= 2 { switch tag[0] { diff --git a/nip29/moderation_actions.go b/nip29/moderation_actions.go index bde3ffb..58e1c43 100644 --- a/nip29/moderation_actions.go +++ b/nip29/moderation_actions.go @@ -123,12 +123,6 @@ var moderationActionFactories = map[nostr.Kind]func(nostr.Event) (Action, error) case "public": edit.PrivateValue = &n ok = true - case "no-text": - edit.NoTextValue = &y - ok = true - case "text": - edit.NoTextValue = &n - ok = true case "livekit": edit.LivekitValue = &y ok = true @@ -250,7 +244,6 @@ type EditMetadata struct { ClosedValue *bool HiddenValue *bool PrivateValue *bool - NoTextValue *bool LivekitValue *bool When nostr.Timestamp } @@ -279,9 +272,6 @@ func (a EditMetadata) Apply(group *Group) { if a.PrivateValue != nil { group.Private = *a.PrivateValue } - if a.NoTextValue != nil { - group.NoText = *a.NoTextValue - } if a.LivekitValue != nil { group.Livekit = *a.LivekitValue } @@ -310,7 +300,6 @@ func (a DeleteGroup) Apply(group *Group) { group.Private = true group.Restricted = true group.Hidden = true - group.NoText = true group.Name = "[deleted]" group.About = "" group.Picture = ""