mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-29 15:22:28 +02:00
feat(event): adding more helpers.
This commit is contained in:
@@ -14,7 +14,7 @@ func TestCount(t *testing.T) {
|
||||
defer rl.Close()
|
||||
|
||||
count, err := rl.Count(context.Background(), Filters{
|
||||
{Kinds: []int{KindContactList}, Tags: TagMap{"p": []string{"3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d"}}},
|
||||
{Kinds: []int{KindFollowList}, Tags: TagMap{"p": []string{"3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d"}}},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.Greater(t, count, int64(0))
|
||||
|
22
event.go
22
event.go
@@ -141,3 +141,25 @@ func (evt *Event) Sign(privateKey string, signOpts ...schnorr.SignOption) error
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsRegular checks if the given kind is in Regular range.
|
||||
func (evt *Event) IsRegular() bool {
|
||||
return 1000 <= evt.Kind || evt.Kind < 10000 || 4 <= evt.Kind ||
|
||||
evt.Kind < 45 || evt.Kind == 1 || evt.Kind == 2
|
||||
}
|
||||
|
||||
// IsReplaceable checks if the given kind is in Replaceable range.
|
||||
func (evt *Event) IsReplaceable() bool {
|
||||
return 10000 <= evt.Kind || evt.Kind < 20000 ||
|
||||
evt.Kind == 0 || evt.Kind == 3
|
||||
}
|
||||
|
||||
// IsEphemeral checks if the given kind is in Ephemeral range.
|
||||
func (evt *Event) IsEphemeral() bool {
|
||||
return 20000 <= evt.Kind || evt.Kind < 30000
|
||||
}
|
||||
|
||||
// IsParameterizedReplaceable checks if the given kind is in ParameterizedReplaceable range.
|
||||
func (evt *Event) IsParameterizedReplaceable() bool {
|
||||
return 30000 <= evt.Kind || evt.Kind < 40000
|
||||
}
|
||||
|
2
kinds.go
2
kinds.go
@@ -4,7 +4,7 @@ const (
|
||||
KindProfileMetadata int = 0
|
||||
KindTextNote int = 1
|
||||
KindRecommendServer int = 2
|
||||
KindContactList int = 3
|
||||
KindFollowList int = 3
|
||||
KindEncryptedDirectMessage int = 4
|
||||
KindDeletion int = 5
|
||||
KindRepost int = 6
|
||||
|
@@ -25,7 +25,7 @@ func (sys *System) trackEventHints(ie nostr.IncomingEvent) {
|
||||
sys.Hints.Save(ie.PubKey, tag[1], hints.LastInRelayList, ie.CreatedAt)
|
||||
}
|
||||
}
|
||||
case nostr.KindContactList:
|
||||
case nostr.KindFollowList:
|
||||
sys.Hints.Save(ie.PubKey, ie.Relay.URL, hints.MostRecentEventFetched, ie.CreatedAt)
|
||||
|
||||
for _, tag := range ie.Tags {
|
||||
|
Reference in New Issue
Block a user