mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
nip34: get patches from repo.
This commit is contained in:
parent
9c4ea87d0b
commit
c362be0e82
2
go.mod
2
go.mod
@ -3,6 +3,7 @@ module github.com/nbd-wtf/go-nostr
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/bluekeyes/go-gitdiff v0.7.1
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2
|
||||
github.com/btcsuite/btcd/btcutil v1.1.3
|
||||
github.com/gobwas/httphead v0.1.0
|
||||
@ -20,7 +21,6 @@ require (
|
||||
require (
|
||||
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect
|
||||
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect
|
||||
github.com/bluekeyes/go-gitdiff v0.7.1 // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user