Skip to content

Clean up note reference when deleting a reply - #184

Merged
maboukerfa merged 1 commit into
developmentfrom
fix/reply-delete-note-reference
Jun 10, 2026
Merged

Clean up note reference when deleting a reply#184
maboukerfa merged 1 commit into
developmentfrom
fix/reply-delete-note-reference

Conversation

@maboukerfa

@maboukerfa maboukerfa commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Problem

Deleting a reply (DELETE /replies/:id) only removed the reply's own triples. This left:

  • the parent note still referencing the now-deleted reply in its reply list (dangling reference), and
  • any nested child replies orphaned (their parent pointing at a deleted reply).

It also returned a 500 (NoMethodError on nil.delete) when the reply id didn't exist.

Change

DELETE /replies/:id now:

  • detaches the reply from every note that references it.
  • recursively deletes child replies, and
  • returns 404 instead of crashing when the reply doesn't exist.

Note

Note#save fires LinkedData::Utils::Notifications.new_note (rescued), so detaching a reply triggers a "new note" notification, the same pre-existing quirk that already fires when a reply is added. Left as-is to keep this change focused; happy to suppress it on this path (delete just the <note> reply <reply> triple) in a follow-up if wanted.

Deleting a reply only removed its own triples, leaving the parent note
still pointing at the now-deleted reply and orphaning any child replies.

DELETE /replies/:id now detaches the reply from every note that
references it, recursively deletes child replies, and returns 404
instead of crashing when the reply does not exist.
@maboukerfa
maboukerfa force-pushed the fix/reply-delete-note-reference branch from b22c893 to dfb2499 Compare June 5, 2026 06:42
@maboukerfa
maboukerfa merged commit b0057f2 into development Jun 10, 2026
4 checks passed
@maboukerfa
maboukerfa deleted the fix/reply-delete-note-reference branch June 10, 2026 16:03
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