mirror of
https://github.com/fiatjaf/nak.git
synced 2025-12-08 16:48:51 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
242b028656 | ||
|
|
f0d90b567c |
31
req.go
31
req.go
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/mailru/easyjson"
|
||||
@@ -61,13 +62,13 @@ example:
|
||||
Usage: "shortcut for --tag p=<value>",
|
||||
Category: CATEGORY_FILTER_ATTRIBUTES,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "since",
|
||||
Aliases: []string{"s"},
|
||||
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)",
|
||||
@@ -184,13 +185,27 @@ example:
|
||||
filter.Tags[tag[0]] = append(filter.Tags[tag[0]], tag[1])
|
||||
}
|
||||
|
||||
if since := c.Int("since"); since != 0 {
|
||||
ts := nostr.Timestamp(since)
|
||||
filter.Since = &ts
|
||||
if since := c.String("since"); since != "" {
|
||||
if since == "now" {
|
||||
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 {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user