diff --git a/policies/events.go b/policies/events.go index aa2811a..aa2019b 100644 --- a/policies/events.go +++ b/policies/events.go @@ -5,6 +5,7 @@ import ( "fmt" "slices" "strings" + "time" "github.com/nbd-wtf/go-nostr" ) @@ -79,7 +80,8 @@ func RestrictToSpecifiedKinds(kinds ...uint16) func(context.Context, *nostr.Even } } -func PreventTimestampsInThePast(thresholdSeconds nostr.Timestamp) func(context.Context, *nostr.Event) (bool, string) { +func PreventTimestampsInThePast(threshold time.Duration) func(context.Context, *nostr.Event) (bool, string) { + thresholdSeconds := nostr.Timestamp(threshold.Seconds()) return func(ctx context.Context, event *nostr.Event) (reject bool, msg string) { if nostr.Now()-event.CreatedAt > thresholdSeconds { return true, "event too old" @@ -88,7 +90,8 @@ func PreventTimestampsInThePast(thresholdSeconds nostr.Timestamp) func(context.C } } -func PreventTimestampsInTheFuture(thresholdSeconds nostr.Timestamp) func(context.Context, *nostr.Event) (bool, string) { +func PreventTimestampsInTheFuture(threshold time.Duration) func(context.Context, *nostr.Event) (bool, string) { + thresholdSeconds := nostr.Timestamp(threshold.Seconds()) return func(ctx context.Context, event *nostr.Event) (reject bool, msg string) { if event.CreatedAt-nostr.Now() > thresholdSeconds { return true, "event too much in the future"