From d6d02686a9d3f9476c9276177ba943bbad8eb810 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Fri, 7 Jun 2024 14:22:17 -0300 Subject: [PATCH] nip29: NewGroupFromMetadataEvent() --- nip29/group.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nip29/group.go b/nip29/group.go index 3027bc4..5741b4b 100644 --- a/nip29/group.go +++ b/nip29/group.go @@ -63,6 +63,20 @@ func NewGroup(gadstr string) (Group, error) { }, nil } +func NewGroupFromMetadataEvent(relayURL string, evt *nostr.Event) (Group, error) { + g := Group{ + Address: GroupAddress{ + Relay: relayURL, + ID: evt.Tags.GetD(), + }, + Name: evt.Tags.GetD(), + Members: make(map[string]*Role), + } + + err := g.MergeInMetadataEvent(evt) + return g, err +} + func (group Group) ToMetadataEvent() *nostr.Event { evt := &nostr.Event{ Kind: nostr.KindSimpleGroupMetadata,