mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 13:22:56 +01:00
add nip40 helper.
This commit is contained in:
parent
de19a457e3
commit
8fb5cd112d
22
nip40/nip40.go
Normal file
22
nip40/nip40.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package nip40
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/nbd-wtf/go-nostr"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetExpiration returns the expiration timestamp for this event, or -1 if no "expiration" tag exists or
|
||||||
|
// if it is invalid.
|
||||||
|
func GetExpiration(tags nostr.Tags) nostr.Timestamp {
|
||||||
|
for _, tag := range tags {
|
||||||
|
if len(tag) >= 2 && tag[0] == "expiration" {
|
||||||
|
if ts, err := strconv.ParseInt(tag[1], 10, 64); err == nil {
|
||||||
|
return nostr.Timestamp(ts)
|
||||||
|
} else {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user