it never ends.
This commit is contained in:
@@ -3,8 +3,8 @@ package nip34
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/bluekeyes/go-gitdiff/gitdiff"
|
||||
"fiatjaf.com/nostr"
|
||||
"github.com/bluekeyes/go-gitdiff/gitdiff"
|
||||
)
|
||||
|
||||
type Patch struct {
|
||||
@@ -35,7 +35,7 @@ func ParsePatch(event nostr.Event) Patch {
|
||||
continue
|
||||
}
|
||||
patch.Repository.Kind = nostr.KindRepositoryAnnouncement
|
||||
patch.Repository.PublicKey = spl[1]
|
||||
patch.Repository.PublicKey, _ = nostr.PubKeyFromHex(spl[1])
|
||||
patch.Repository.Identifier = spl[2]
|
||||
if len(tag) >= 3 {
|
||||
patch.Repository.Relays = []string{tag[2]}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package nip34
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"fiatjaf.com/nostr"
|
||||
)
|
||||
|
||||
@@ -97,33 +94,3 @@ func (r Repository) ToEvent() *nostr.Event {
|
||||
CreatedAt: nostr.Now(),
|
||||
}
|
||||
}
|
||||
|
||||
func (repo Repository) FetchState(ctx context.Context, s nostr.RelayStore) *RepositoryState {
|
||||
res, _ := s.QuerySync(ctx, nostr.Filter{
|
||||
Kinds: []int{nostr.KindRepositoryState},
|
||||
Tags: nostr.TagMap{
|
||||
"d": []string{repo.Tags.GetD()},
|
||||
},
|
||||
})
|
||||
|
||||
if len(res) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
rs := ParseRepositoryState(*res[0])
|
||||
return &rs
|
||||
}
|
||||
|
||||
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