mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-05-08 17:50:33 +02:00
Add NIP-22 support
This commit is contained in:
parent
ef0717afb6
commit
dcd5030fcd
1
kinds.go
1
kinds.go
@ -25,6 +25,7 @@ const (
|
||||
KindChannelMuteUser int = 44
|
||||
KindChess int = 64
|
||||
KindMergeRequests int = 818
|
||||
KindComment int = 1111
|
||||
KindBid int = 1021
|
||||
KindBidConfirmation int = 1022
|
||||
KindOpenTimestamps int = 1040
|
||||
|
24
nip22/nip22.go
Normal file
24
nip22/nip22.go
Normal file
@ -0,0 +1,24 @@
|
||||
package nip22
|
||||
|
||||
import "github.com/nbd-wtf/go-nostr"
|
||||
|
||||
func GetThreadRoot(tags nostr.Tags) *nostr.Tag {
|
||||
for _, tag := range tags {
|
||||
if tag[0] == "E" || tag[0] == "A" || tag[0] == "I" {
|
||||
return &tag
|
||||
}
|
||||
}
|
||||
empty := nostr.Tag{}
|
||||
return &empty
|
||||
}
|
||||
|
||||
func GetImmediateReply(tags nostr.Tags) *nostr.Tag {
|
||||
for _, tag := range tags {
|
||||
if tag[0] == "e" || tag[0] == "a" || tag[0] == "i" {
|
||||
return &tag
|
||||
}
|
||||
}
|
||||
|
||||
empty := nostr.Tag{}
|
||||
return &empty
|
||||
}
|
23
sdk/thread.go
Normal file
23
sdk/thread.go
Normal file
@ -0,0 +1,23 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
"github.com/nbd-wtf/go-nostr/nip10"
|
||||
"github.com/nbd-wtf/go-nostr/nip22"
|
||||
)
|
||||
|
||||
func GetThreadRoot(evt *nostr.Event) *nostr.Tag {
|
||||
if evt.Kind == nostr.KindComment {
|
||||
return nip22.GetThreadRoot(evt.Tags)
|
||||
} else {
|
||||
return nip10.GetThreadRoot(evt.Tags)
|
||||
}
|
||||
}
|
||||
|
||||
func GetImmediateReply(evt *nostr.Event) *nostr.Tag {
|
||||
if evt.Kind == nostr.KindComment {
|
||||
return nip22.GetImmediateReply(evt.Tags)
|
||||
} else {
|
||||
return nip10.GetImmediateReply(evt.Tags)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user