You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
449 B
17 lines
449 B
package validation |
|
|
|
import ( |
|
"time" |
|
|
|
"git.mleku.dev/mleku/nostr/encoders/event" |
|
) |
|
|
|
// ValidateTimestamp checks that the event timestamp is not too far in the future. |
|
// maxFutureSeconds is the maximum allowed seconds ahead of current time. |
|
func ValidateTimestamp(ev *event.E, maxFutureSeconds int64) Result { |
|
now := time.Now().Unix() |
|
if ev.CreatedAt > now+maxFutureSeconds { |
|
return Invalid("timestamp too far in the future") |
|
} |
|
return OK() |
|
}
|
|
|