Key the events store by addressable coordinate (kind:pubkey:dtag), not bare d-tag #121
Labels
No labels
app:activities
app:chat
app:events
app:forum
app:libra
app:market
app:restaurant
app:tasks
app:wallet
app:webapp
bug
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aiolabs/webapp#121
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From the nostr-patterns review against NDK + welshman.
Problem
src/modules/events/stores/events.tskeys events byevent.id= the bare d-tag, andupsertEventreplaces oncreatedAt >= existing.createdAtignoring pubkey. NIP-52 calendar events (31922/31923) are addressable (parameterized-replaceable) and their d-tags are author-scoped. So a different author publishing the same d-tag with a newercreated_atwould overwrite the legit event in the store (cross-author hijack). Both NDK (events/index.ts coordinate()) and welshman (eventsByAddress) key addressable events bykind:pubkey:dtag.Proposed fix (client-side only — no DB/relay change)
${kind}:${pubkey}:${dtag}; replace only within the same coordinate (and newercreated_at). Different authors → stored separately, no hijack.getEventById(dtag)resolves by scanning/secondary-index (unambiguous for our single-publisher calendar events). AddgetByCoordinate(coord)for precise lookups.No demo-DB surgery: the store is rebuilt from the relay each session.
Testing
Unit tests (vitest): same-coordinate-newer-wins, same-coordinate-older-ignored, same-d-tag-different-pubkey → both kept (no overwrite),
getEventByIdresolves by d-tag.To be done as a PR (gap #1 of the review).