Make sure deletes are by the same author

This commit is contained in:
Jon Staab
2026-03-23 10:03:52 -07:00
parent 1a160ec485
commit a21448c0df
3 changed files with 82 additions and 23 deletions
+27 -5
View File
@@ -102,8 +102,13 @@ describe("Repository", () => {
})
it("should handle delete events", () => {
const event = createEvent(1)
const deleteEvent = createEvent(DELETE, {tags: [["e", event.id]], created_at: now() + 100})
const pubkey = randomHex()
const event = createEvent(1, {pubkey})
const deleteEvent = createEvent(DELETE, {
pubkey,
tags: [["e", event.id]],
created_at: now() + 100,
})
repo.publish(event)
repo.publish(deleteEvent)
@@ -112,8 +117,10 @@ describe("Repository", () => {
})
it("should handle delete by address", () => {
const event = createEvent(MUTES)
const pubkey = randomHex()
const event = createEvent(MUTES, {pubkey})
const deleteEvent = createEvent(DELETE, {
pubkey,
tags: [["a", `10000:${event.pubkey}:`]],
created_at: now() + 100,
})
@@ -123,6 +130,16 @@ describe("Repository", () => {
expect(repo.isDeletedByAddress(event)).toBe(true)
})
it("should not delete events with mismatched pubkeys", () => {
const event = createEvent(1)
const deleteEvent = createEvent(DELETE, {tags: [["e", event.id]], created_at: now() + 1})
repo.publish(event)
repo.publish(deleteEvent)
expect(repo.isDeleted(event)).toBe(false)
})
})
describe("expire events", () => {
@@ -224,8 +241,13 @@ describe("Repository", () => {
})
it("should not return deleted events", () => {
const event = createEvent(1)
const deleteEvent = createEvent(DELETE, {tags: [["e", event.id]], created_at: now() + 1})
const pubkey = randomHex()
const event = createEvent(1, {pubkey})
const deleteEvent = createEvent(DELETE, {
pubkey,
tags: [["e", event.id]],
created_at: now() + 1,
})
repo.publish(event)
repo.publish(deleteEvent)