mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-12 12:32:32 +02:00
nip34: get patches from repo.
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
package nip34
|
||||
|
||||
import "github.com/nbd-wtf/go-nostr"
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
)
|
||||
|
||||
type Repository struct {
|
||||
nostr.Event
|
||||
@ -40,3 +45,17 @@ func ParseRepository(event nostr.Event) Repository {
|
||||
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repo Repository) GetPatchesSync(ctx context.Context, s nostr.RelayStore) []Patch {
|
||||
res, _ := s.QuerySync(ctx, nostr.Filter{
|
||||
Kinds: []int{nostr.KindPatch},
|
||||
Tags: nostr.TagMap{
|
||||
"a": []string{fmt.Sprintf("%d:%s:%s", nostr.KindRepositoryAnnouncement, repo.Event.PubKey, repo.ID)},
|
||||
},
|
||||
})
|
||||
patches := make([]Patch, len(res))
|
||||
for i, evt := range res {
|
||||
patches[i] = ParsePatch(*evt)
|
||||
}
|
||||
return patches
|
||||
}
|
||||
|
Reference in New Issue
Block a user