Skip to content

Commit

Permalink
nip29: NewGroupFromMetadataEvent()
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Jun 7, 2024
1 parent b173c40 commit d6d0268
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions nip29/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d6d0268

Please sign in to comment.