1 package validation
2 3 import (
4 "time"
5 6 "next.orly.dev/pkg/nostr/encoders/event"
7 )
8 9 // ValidateTimestamp checks that the event timestamp is not too far in the future.
10 // maxFutureSeconds is the maximum allowed seconds ahead of current time.
11 func ValidateTimestamp(ev *event.E, maxFutureSeconds int64) Result {
12 now := time.Now().Unix()
13 if ev.CreatedAt > now+maxFutureSeconds {
14 return Invalid("timestamp too far in the future")
15 }
16 return OK()
17 }
18