From 03c38fc895e16521cb193566d983de8a79afcfcc Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Wed, 1 Oct 2025 16:39:13 -0700 Subject: [PATCH] Fix some group related things --- zooid/groups.go | 16 +++++++++++++--- zooid/instance.go | 12 +++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/zooid/groups.go b/zooid/groups.go index b4334a7..27a2237 100644 --- a/zooid/groups.go +++ b/zooid/groups.go @@ -20,7 +20,7 @@ func MakeGroupMetadataFilter(h string) nostr.Filter { return nostr.Filter{ Kinds: []nostr.Kind{nostr.KindSimpleGroupMetadata}, Tags: nostr.TagMap{ - "a": []string{h}, + "d": []string{h}, }, } } @@ -29,7 +29,7 @@ func MakeGroupEventFilters(h string) []nostr.Filter { return []nostr.Filter{ { Tags: nostr.TagMap{ - "a": []string{h}, + "d": []string{h}, }, }, { @@ -87,9 +87,19 @@ func MakeRemoveUserEvent(h string, pubkey nostr.PubKey) nostr.Event { } func MakeMetadataEvent(event nostr.Event) nostr.Event { + tags := nostr.Tags{} + + for _, tag := range event.Tags { + if len(tag) >= 2 && tag[0] == "h" { + tags = append(tags, nostr.Tag{"d", tag[1]}) + } else { + tags = append(tags, tag) + } + } + return nostr.Event{ Kind: nostr.KindSimpleGroupMetadata, CreatedAt: event.CreatedAt, - Tags: event.Tags, + Tags: tags, } } diff --git a/zooid/instance.go b/zooid/instance.go index 2003c82..9f80bfa 100644 --- a/zooid/instance.go +++ b/zooid/instance.go @@ -73,6 +73,10 @@ func MakeInstance(filename string) (*Instance, error) { instance.Relay.Info.PubKey = &pubkey } + if instance.Config.Groups.Enabled { + instance.Relay.Info.SupportedNIPs = append(instance.Relay.Info.SupportedNIPs, 29) + } + // Handlers instance.Relay.OnConnect = instance.OnConnect @@ -87,7 +91,7 @@ func MakeInstance(filename string) (*Instance, error) { instance.Relay.RejectConnection = instance.RejectConnection instance.Relay.PreventBroadcast = instance.PreventBroadcast - // Todo: when there's a new version of khatru + // Todo: when there's a new version of khatru // instance.Relay.StartExpirationManager() // HTTP request handling @@ -311,8 +315,10 @@ func (instance *Instance) OnEvent(ctx context.Context, event nostr.Event) (rejec meta := instance.GetGroupMetadataEvent(h) - if event.Kind == nostr.KindSimpleGroupCreateGroup && !IsEmptyEvent(meta) { - return true, "invalid: that group already exists" + if event.Kind == nostr.KindSimpleGroupCreateGroup { + if !IsEmptyEvent(meta) { + return true, "invalid: that group already exists" + } } else if IsEmptyEvent(meta) { return true, "invalid: no such group exists" }