Skip to content

Commit

Permalink
fix filter building on download.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Feb 3, 2024
1 parent 5d48c0e commit e2dd1b5
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions download.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ var download = &cli.Command{
},
Action: func(ctx context.Context, c *cli.Command) error {
id := getRepositoryID()
if id == "" {
return fmt.Errorf("no repository id found in `config str.id`")
}

pk := getRepositoryPublicKey()
if pk == "" {
return fmt.Errorf("no repository pubkey found in `git config str.publickey`")
if pk == "" || id == "" {
fmt.Fprintf(os.Stderr, "no repository id and pubkey found on `git config`, this command will only work with specific naddr or nevent patches.\n")
}

limit := c.Int("limit")
Expand All @@ -58,7 +54,6 @@ var download = &cli.Command{
Kinds: []int{PatchKind},
Tags: nostr.TagMap{},
}

relays := slices.Clone(relays)

if arg != "" {
Expand All @@ -83,7 +78,7 @@ var download = &cli.Command{
fmt.Fprintf(os.Stderr, "invalid argument %s: expected an encoded kind %d or nothing\n", arg, PatchKind)
continue
}
filter.IDs = append(filter.IDs, ep.ID)
filter = nostr.Filter{IDs: []string{ep.ID}}
relays = append(relays, ep.Relays...)
case "naddr":
ep := data.(nostr.EntityPointer)
Expand All @@ -92,9 +87,16 @@ var download = &cli.Command{
continue
}

filter.Tags["a"] = []string{fmt.Sprintf("%d:%s:%s", RepoAnnouncementKind, ep.PublicKey, ep.Identifier)}
filter.Authors = append(filter.Authors, ep.PublicKey)
filter = nostr.Filter{
Limit: int(limit),
Kinds: []int{PatchKind},
Tags: nostr.TagMap{
"a": []string{fmt.Sprintf("%d:%s:%s", RepoAnnouncementKind, ep.PublicKey, ep.Identifier)},
},
}
relays = append(relays, ep.Relays...)
default:
continue
}
}

Expand Down

0 comments on commit e2dd1b5

Please sign in to comment.