Skip to content

Commit

Permalink
feat(event): adding more helpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy authored and fiatjaf committed Sep 19, 2024
1 parent c8c295f commit 47243fd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
22 changes: 22 additions & 0 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 1 deletion kinds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sdk/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 47243fd

Please sign in to comment.