mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-29 15:22:28 +02:00
nip70: HasEmbeddedProtected()
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
package nip70
|
package nip70
|
||||||
|
|
||||||
import "github.com/nbd-wtf/go-nostr"
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
func IsProtected(event *nostr.Event) bool {
|
"github.com/nbd-wtf/go-nostr"
|
||||||
|
)
|
||||||
|
|
||||||
|
func IsProtected(event nostr.Event) bool {
|
||||||
for _, tag := range event.Tags {
|
for _, tag := range event.Tags {
|
||||||
if len(tag) == 1 && tag[0] == "-" {
|
if len(tag) == 1 && tag[0] == "-" {
|
||||||
return true
|
return true
|
||||||
@@ -10,3 +14,16 @@ func IsProtected(event *nostr.Event) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func HasEmbeddedProtected(event nostr.Event) bool {
|
||||||
|
if event.Kind == 6 || event.Kind == 16 {
|
||||||
|
tidx := strings.Index(event.Content, `"tags":[`)
|
||||||
|
eidx := strings.Index(event.Content, `]]`)
|
||||||
|
pidx := strings.Index(event.Content, `["-"]`)
|
||||||
|
if tidx != -1 && eidx != -1 && pidx != -1 {
|
||||||
|
return pidx > tidx && pidx < eidx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user