correctly rejects parameterized replaceable that is older than current

This commit is contained in:
2024-09-20 21:09:17 +01:00
parent 00a424e903
commit f752b4e76e
2 changed files with 7 additions and 4 deletions

View File

@@ -100,7 +100,6 @@ func (r *T) QueryEvents(c Ctx, f *filter.T) (evs []*event.T, err E) {
if len(rem) > 0 {
log.T.S(rem)
}
log.I.S(ev)
// check if this matches the other filters that were not part of the index.
if extraFilter == nil || extraFilter.Matches(ev) {
// check if this event is replaced by one we already have in the result.
@@ -114,6 +113,9 @@ func (r *T) QueryEvents(c Ctx, f *filter.T) (evs []*event.T, err E) {
}
}
}
// log.I.S(ev.Tags.GetFirst(tag.New("d")).Value(),
// ev.Tags.GetFirst(tag.New("d")).Value())
if ev.Kind.IsParameterizedReplaceable() &&
ev.Tags.GetFirst(tag.New("d")) != nil {
for _, evc := range evs {

View File

@@ -10,7 +10,6 @@ import (
"realy.lol/kinds"
"realy.lol/normalize"
"realy.lol/tag"
"realy.lol/tags"
"realy.lol/ws"
)
@@ -61,9 +60,11 @@ func (w RelayWrapper) Publish(c Ctx, evt *event.T) (err E) {
f.Authors = tag.New(evt.PubKey)
f.Kinds = kinds.New(evt.Kind)
d := evt.Tags.GetFirst(tag.New("d", ""))
f.Tags = tags.New(tag.New(d.Key(), d.Value()))
log.I.F("filter for parameterized replaceable %s", f.Serialize())
log.I.S(d)
// f.Tags = tags.New(tag.New(d.Key())) // ), d.Value()))
log.I.F("filter for parameterized replaceable %s %s", f.Tags, f.Serialize())
evs, err = w.I.QueryEvents(c, f)
log.I.S(evs)
if err != nil {
return fmt.Errorf("failed to query before replacing: %w", err)
}