mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
pointer.MatchesEvent()
This commit is contained in:
parent
2d941907e3
commit
550cf835be
13
pointers.go
13
pointers.go
@ -7,6 +7,7 @@ import (
|
||||
type Pointer interface {
|
||||
AsTagReference() string
|
||||
AsTag() Tag
|
||||
MatchesEvent(Event) bool
|
||||
}
|
||||
|
||||
type ProfilePointer struct {
|
||||
@ -14,7 +15,8 @@ type ProfilePointer struct {
|
||||
Relays []string `json:"relays,omitempty"`
|
||||
}
|
||||
|
||||
func (ep ProfilePointer) AsTagReference() string { return ep.PublicKey }
|
||||
func (ep ProfilePointer) MatchesEvent(_ Event) bool { return false }
|
||||
func (ep ProfilePointer) AsTagReference() string { return ep.PublicKey }
|
||||
|
||||
func (ep ProfilePointer) AsTag() Tag {
|
||||
if len(ep.Relays) > 0 {
|
||||
@ -30,7 +32,8 @@ type EventPointer struct {
|
||||
Kind int `json:"kind,omitempty"`
|
||||
}
|
||||
|
||||
func (ep EventPointer) AsTagReference() string { return ep.ID }
|
||||
func (ep EventPointer) MatchesEvent(evt Event) bool { return evt.ID == ep.ID }
|
||||
func (ep EventPointer) AsTagReference() string { return ep.ID }
|
||||
|
||||
func (ep EventPointer) AsTag() Tag {
|
||||
if len(ep.Relays) > 0 {
|
||||
@ -50,6 +53,12 @@ type EntityPointer struct {
|
||||
Relays []string `json:"relays,omitempty"`
|
||||
}
|
||||
|
||||
func (ep EntityPointer) MatchesEvent(evt Event) bool {
|
||||
return ep.PublicKey == evt.PubKey &&
|
||||
ep.Kind == evt.Kind &&
|
||||
evt.Tags.GetD() == ep.Identifier
|
||||
}
|
||||
|
||||
func (ep EntityPointer) AsTagReference() string {
|
||||
return fmt.Sprintf("%d:%s:%s", ep.Kind, ep.PublicKey, ep.Identifier)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user