mirror of
https://github.com/fiatjaf/nak.git
synced 2024-11-22 16:19:07 -05:00
-since now
This commit is contained in:
parent
2d1e27f766
commit
f0d90b567c
16
req.go
16
req.go
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mailru/easyjson"
|
"github.com/mailru/easyjson"
|
||||||
|
@ -61,7 +62,7 @@ example:
|
||||||
Usage: "shortcut for --tag p=<value>",
|
Usage: "shortcut for --tag p=<value>",
|
||||||
Category: CATEGORY_FILTER_ATTRIBUTES,
|
Category: CATEGORY_FILTER_ATTRIBUTES,
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
&cli.StringFlag{
|
||||||
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)",
|
||||||
|
@ -184,9 +185,16 @@ example:
|
||||||
filter.Tags[tag[0]] = append(filter.Tags[tag[0]], tag[1])
|
filter.Tags[tag[0]] = append(filter.Tags[tag[0]], tag[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
if since := c.Int("since"); since != 0 {
|
if since := c.String("since"); since != "" {
|
||||||
ts := nostr.Timestamp(since)
|
if since == "now" {
|
||||||
filter.Since = &ts
|
ts := nostr.Now()
|
||||||
|
filter.Since = &ts
|
||||||
|
} else if i, err := strconv.Atoi(since); err == nil {
|
||||||
|
ts := nostr.Timestamp(i)
|
||||||
|
filter.Since = &ts
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("parse error: Invalid numeric literal %q", since)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if until := c.Int("until"); until != 0 {
|
if until := c.Int("until"); until != 0 {
|
||||||
ts := nostr.Timestamp(until)
|
ts := nostr.Timestamp(until)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user