Skip to content

Allow a sent message to be purged on purpose - #51

Merged
markmnl merged 1 commit into
mainfrom
explicit-purge
Oct 22, 2026
Merged

markmnl merged 1 commit into
mainfrom
explicit-purge

Conversation

@markmnl

@markmnl markmnl commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Lets an API delete a stored message for good, so that a later reply to it is rejected as parent not found (code 6). This is for a "delete forever" that the web API will offer once no local participant still holds the message.

  • protect_msg_parts now returns early for a DELETE when the transaction has set fmsg.purge (SET LOCAL fmsg.purge = 'on'). The purger can then delete the message's msg_to, msg_add_to and msg_attachment rows and the msg row.
  • Replies keep their psha256. The purger sets their pid to NULL, which is already allowed, since pid isn't an immutable column.
  • Without the setting nothing changes: sent messages and their parts stay immutable.
  • dd.sql stays idempotent (create or replace).
  • No Go changes: validatePidReplyPath already rejects a reply whose parent hash isn't stored.

Test: TestPurgeRemovesSentMessage checks that a purge transaction removes the message (it's no longer found by hash), that its reply keeps its parent hash with pid NULL, and that deleting outside a purge is still refused. The full suite passes against Postgres 17.

🤖 Generated with Claude Code

protect_msg_parts lets a transaction that sets fmsg.purge (SET LOCAL
fmsg.purge = 'on') delete a sent message's parts, so the message can be
removed from the host. Once its row is gone, a reply to it is rejected as
parent not found. Without the setting, sent messages stay immutable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@markmnl
markmnl merged commit f5515e0 into main Oct 22, 2026
2 checks passed
@markmnl
markmnl deleted the explicit-purge branch October 22, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant