adapt to since and until not being pointers.

This commit is contained in:
fiatjaf
2025-05-08 09:59:03 -03:00
parent f799c65779
commit aadcc73906
8 changed files with 20 additions and 27 deletions

View File

@@ -140,11 +140,10 @@ var bunker = &cli.Command{
printBunkerInfo() printBunkerInfo()
// subscribe to relays // subscribe to relays
now := nostr.Now()
events := sys.Pool.SubscribeMany(ctx, relayURLs, nostr.Filter{ events := sys.Pool.SubscribeMany(ctx, relayURLs, nostr.Filter{
Kinds: []nostr.Kind{nostr.KindNostrConnect}, Kinds: []nostr.Kind{nostr.KindNostrConnect},
Tags: nostr.TagMap{"p": []string{pubkey.Hex()}}, Tags: nostr.TagMap{"p": []string{pubkey.Hex()}},
Since: &now, Since: nostr.Now(),
LimitZero: true, LimitZero: true,
}, nostr.SubscriptionOptions{ }, nostr.SubscriptionOptions{
Label: "nak-bunker", Label: "nak-bunker",

View File

@@ -46,13 +46,13 @@ var count = &cli.Command{
Usage: "shortcut for --tag p=<value>", Usage: "shortcut for --tag p=<value>",
Category: CATEGORY_FILTER_ATTRIBUTES, Category: CATEGORY_FILTER_ATTRIBUTES,
}, },
&cli.IntFlag{ &NaturalTimeFlag{
Name: "since", Name: "since",
Aliases: []string{"s"}, Aliases: []string{"s"},
Usage: "only accept events newer than this (unix timestamp)", Usage: "only accept events newer than this (unix timestamp)",
Category: CATEGORY_FILTER_ATTRIBUTES, Category: CATEGORY_FILTER_ATTRIBUTES,
}, },
&cli.IntFlag{ &NaturalTimeFlag{
Name: "until", Name: "until",
Aliases: []string{"u"}, Aliases: []string{"u"},
Usage: "only accept events older than this (unix timestamp)", Usage: "only accept events older than this (unix timestamp)",
@@ -122,14 +122,13 @@ var count = &cli.Command{
} }
} }
if since := c.Int("since"); since != 0 { if c.IsSet("since") {
ts := nostr.Timestamp(since) filter.Since = getNaturalDate(c, "since")
filter.Since = &ts
} }
if until := c.Int("until"); until != 0 { if c.IsSet("until") {
ts := nostr.Timestamp(until) filter.Until = getNaturalDate(c, "until")
filter.Until = &ts
} }
if limit := c.Int("limit"); limit != 0 { if limit := c.Int("limit"); limit != 0 {
filter.Limit = int(limit) filter.Limit = int(limit)
} }

2
go.mod
View File

@@ -16,6 +16,7 @@ require (
github.com/mailru/easyjson v0.9.0 github.com/mailru/easyjson v0.9.0
github.com/mark3labs/mcp-go v0.8.3 github.com/mark3labs/mcp-go v0.8.3
github.com/markusmobius/go-dateparser v1.2.3 github.com/markusmobius/go-dateparser v1.2.3
github.com/mattn/go-tty v0.0.7
github.com/stretchr/testify v1.10.0 github.com/stretchr/testify v1.10.0
github.com/urfave/cli/v3 v3.0.0-beta1 github.com/urfave/cli/v3 v3.0.0-beta1
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 golang.org/x/exp v0.0.0-20250305212735-054e65f0b394
@@ -59,7 +60,6 @@ require (
github.com/magefile/mage v1.14.0 // indirect github.com/magefile/mage v1.14.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-tty v0.0.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect

2
go.sum
View File

@@ -1,8 +1,6 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
fiatjaf.com/lib v0.3.1 h1:/oFQwNtFRfV+ukmOCxfBEAuayoLwXp4wu2/fz5iHpwA= fiatjaf.com/lib v0.3.1 h1:/oFQwNtFRfV+ukmOCxfBEAuayoLwXp4wu2/fz5iHpwA=
fiatjaf.com/lib v0.3.1/go.mod h1:Ycqq3+mJ9jAWu7XjbQI1cVr+OFgnHn79dQR5oTII47g= fiatjaf.com/lib v0.3.1/go.mod h1:Ycqq3+mJ9jAWu7XjbQI1cVr+OFgnHn79dQR5oTII47g=
fiatjaf.com/nostr v0.0.0-20250506031545-0d99789a54e2 h1:WDjFQ8hPUAvTDKderZ0NC6vaRBBxODPchKER4wuQdG8=
fiatjaf.com/nostr v0.0.0-20250506031545-0d99789a54e2/go.mod h1:VPs38Fc8J1XAErV750CXAmMUqIq3XEX9VZVj/LuQzzM=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/FastFilter/xorfilter v0.2.1 h1:lbdeLG9BdpquK64ZsleBS8B4xO/QW1IM0gMzF7KaBKc= github.com/FastFilter/xorfilter v0.2.1 h1:lbdeLG9BdpquK64ZsleBS8B4xO/QW1IM0gMzF7KaBKc=
github.com/FastFilter/xorfilter v0.2.1/go.mod h1:aumvdkhscz6YBZF9ZA/6O4fIoNod4YR50kIVGGZ7l9I= github.com/FastFilter/xorfilter v0.2.1/go.mod h1:aumvdkhscz6YBZF9ZA/6O4fIoNod4YR50kIVGGZ7l9I=

View File

@@ -50,10 +50,10 @@ func gatherKeyerFromArguments(ctx context.Context, c *cli.Command) (nostr.Keyer,
if bunker != nil { if bunker != nil {
kr = keyer.NewBunkerSignerFromBunkerClient(bunker) kr = keyer.NewBunkerSignerFromBunkerClient(bunker)
} else { } else {
kr, err = keyer.NewPlainKeySigner(key) kr = keyer.NewPlainKeySigner(key)
} }
return kr, key, err return kr, key, nil
} }
func gatherSecretKeyOrBunkerFromArguments(ctx context.Context, c *cli.Command) (nostr.SecretKey, *nip46.BunkerClient, error) { func gatherSecretKeyOrBunkerFromArguments(ctx context.Context, c *cli.Command) (nostr.SecretKey, *nip46.BunkerClient, error) {

View File

@@ -183,8 +183,8 @@ func (n *ViewDir) publishNote() {
func (n *ViewDir) Getattr(_ context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno { func (n *ViewDir) Getattr(_ context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno {
now := nostr.Now() now := nostr.Now()
if n.filter.Until != nil { if n.filter.Until != 0 {
now = *n.filter.Until now = n.filter.Until
} }
aMonthAgo := now - 30*24*60*60 aMonthAgo := now - 30*24*60*60
out.Mtime = uint64(aMonthAgo) out.Mtime = uint64(aMonthAgo)
@@ -199,14 +199,14 @@ func (n *ViewDir) Opendir(ctx context.Context) syscall.Errno {
if n.paginate { if n.paginate {
now := nostr.Now() now := nostr.Now()
if n.filter.Until != nil { if n.filter.Until != 0 {
now = *n.filter.Until now = n.filter.Until
} }
aMonthAgo := now - 30*24*60*60 aMonthAgo := now - 30*24*60*60
n.filter.Since = &aMonthAgo n.filter.Since = aMonthAgo
filter := n.filter filter := n.filter
filter.Until = &aMonthAgo filter.Until = aMonthAgo
n.AddChild("@previous", n.NewPersistentInode( n.AddChild("@previous", n.NewPersistentInode(
n.root.ctx, n.root.ctx,

7
req.go
View File

@@ -286,13 +286,10 @@ func applyFlagsToFilter(c *cli.Command, filter *nostr.Filter) error {
} }
if c.IsSet("since") { if c.IsSet("since") {
nts := getNaturalDate(c, "since") filter.Since = getNaturalDate(c, "since")
filter.Since = &nts
} }
if c.IsSet("until") { if c.IsSet("until") {
nts := getNaturalDate(c, "until") filter.Until = getNaturalDate(c, "until")
filter.Until = &nts
} }
if limit := c.Uint("limit"); limit != 0 { if limit := c.Uint("limit"); limit != 0 {

View File

@@ -240,7 +240,7 @@ var wallet = &cli.Command{
if mint := c.String("mint"); mint != "" { if mint := c.String("mint"); mint != "" {
sourceMint = "http" + nostr.NormalizeURL(mint)[2:] sourceMint = "http" + nostr.NormalizeURL(mint)[2:]
} }
proofs, mint, err := w.Send(ctx, amount, nip60.SendOptions{ proofs, mint, err := w.SendInternal(ctx, amount, nip60.SendOptions{
SpecificSourceMint: sourceMint, SpecificSourceMint: sourceMint,
}) })
if err != nil { if err != nil {