Drop WithCreatedAtTime, WithSinceTime, WithUntilTime; nil Tags on NewEvent
This commit is contained in:
+2
-10
@@ -3,9 +3,7 @@
|
|||||||
// serialization, cryptographic signatures, and subscription filters.
|
// serialization, cryptographic signatures, and subscription filters.
|
||||||
package events
|
package events
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Tag represents a single tag within an event as an array of strings.
|
// Tag represents a single tag within an event as an array of strings.
|
||||||
// The first element identifies the tag name, the second contains the value,
|
// The first element identifies the tag name, the second contains the value,
|
||||||
@@ -26,7 +24,7 @@ type Event struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewEvent(opts ...EventOption) Event {
|
func NewEvent(opts ...EventOption) Event {
|
||||||
e := Event{Tags: make([]Tag, 0)}
|
e := Event{}
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(&e)
|
opt(&e)
|
||||||
}
|
}
|
||||||
@@ -53,12 +51,6 @@ func WithCreatedAt(t int64) EventOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithCreatedAtTime(t time.Time) EventOption {
|
|
||||||
return func(e *Event) {
|
|
||||||
e.CreatedAt = t.Unix()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func WithKind(k int) EventOption {
|
func WithKind(k int) EventOption {
|
||||||
return func(e *Event) {
|
return func(e *Event) {
|
||||||
e.Kind = k
|
e.Kind = k
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var testEvent = NewEvent(
|
|||||||
WithSig("83b71e15649c9e9da362c175f988c36404cabf357a976d869102a74451cfb8af486f6088b5631033b4927bd46cad7a0d90d7f624aefc0ac260364aa65c36071a"),
|
WithSig("83b71e15649c9e9da362c175f988c36404cabf357a976d869102a74451cfb8af486f6088b5631033b4927bd46cad7a0d90d7f624aefc0ac260364aa65c36071a"),
|
||||||
)
|
)
|
||||||
|
|
||||||
var testEventJSON = `{"id":"c7a702e6158744ca03508bbb4c90f9dbb0d6e88fefbfaa511d5ab24b4e3c48ad","pubkey":"cfa87f35acbde29ba1ab3ee42de527b2cad33ac487e80cf2d6405ea0042c8fef","created_at":1760740551,"kind":1,"tags":[],"content":"hello world","sig":"83b71e15649c9e9da362c175f988c36404cabf357a976d869102a74451cfb8af486f6088b5631033b4927bd46cad7a0d90d7f624aefc0ac260364aa65c36071a"}`
|
var testEventJSON = `{"id":"c7a702e6158744ca03508bbb4c90f9dbb0d6e88fefbfaa511d5ab24b4e3c48ad","pubkey":"cfa87f35acbde29ba1ab3ee42de527b2cad33ac487e80cf2d6405ea0042c8fef","created_at":1760740551,"kind":1,"tags":null,"content":"hello world","sig":"83b71e15649c9e9da362c175f988c36404cabf357a976d869102a74451cfb8af486f6088b5631033b4927bd46cad7a0d90d7f624aefc0ac260364aa65c36071a"}`
|
||||||
var testEventJSONBytes = []byte(testEventJSON)
|
var testEventJSONBytes = []byte(testEventJSON)
|
||||||
|
|
||||||
func expectEqualEvents(t *testing.T, got, want Event) {
|
func expectEqualEvents(t *testing.T, got, want Event) {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"git.wisehodl.dev/jay/go-roots/events"
|
"git.wisehodl.dev/jay/go-roots/events"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TagFilters maps tag names to arrays of values for tag-based filtering
|
// TagFilters maps tag names to arrays of values for tag-based filtering
|
||||||
@@ -70,20 +69,6 @@ func WithUntil(until int64) FilterOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithUntilTime(until time.Time) FilterOption {
|
|
||||||
return func(f *Filter) {
|
|
||||||
untilInt := until.Unix()
|
|
||||||
f.Until = &untilInt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func WithSinceTime(since time.Time) FilterOption {
|
|
||||||
return func(f *Filter) {
|
|
||||||
sinceInt := since.Unix()
|
|
||||||
f.Since = &sinceInt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func WithLimit(limit int) FilterOption {
|
func WithLimit(limit int) FilterOption {
|
||||||
return func(f *Filter) {
|
return func(f *Filter) {
|
||||||
ptr := limit
|
ptr := limit
|
||||||
|
|||||||
Reference in New Issue
Block a user