-until now

This commit is contained in:
Yasuhiro Matsumoto 2023-12-12 21:34:50 +09:00
parent f1a0824804
commit 4b554b4540
No known key found for this signature in database
GPG Key ID: 622DE34DC490584B
1 changed files with 11 additions and 4 deletions

15
req.go
View File

@ -68,7 +68,7 @@ example:
Usage: "only accept events newer than this (unix timestamp)",
Category: CATEGORY_FILTER_ATTRIBUTES,
},
&cli.IntFlag{
&cli.StringFlag{
Name: "until",
Aliases: []string{"u"},
Usage: "only accept events older than this (unix timestamp)",
@ -196,9 +196,16 @@ example:
return fmt.Errorf("parse error: Invalid numeric literal %q", since)
}
}
if until := c.Int("until"); until != 0 {
ts := nostr.Timestamp(until)
filter.Until = &ts
if until := c.String("until"); until != "" {
if until == "now" {
ts := nostr.Now()
filter.Until = &ts
} else if i, err := strconv.Atoi(until); err == nil {
ts := nostr.Timestamp(i)
filter.Until = &ts
} else {
return fmt.Errorf("parse error: Invalid numeric literal %q", until)
}
}
if limit := c.Int("limit"); limit != 0 {
filter.Limit = limit