Skip to content

Feat/soft delete - #659

Open
Silver36-ship-it wants to merge 9 commits into
Abdulazeem-code:mainfrom
Silver36-ship-it:feat/soft-delete
Open

Feat/soft delete#659
Silver36-ship-it wants to merge 9 commits into
Abdulazeem-code:mainfrom
Silver36-ship-it:feat/soft-delete

Conversation

@Silver36-ship-it

Copy link
Copy Markdown
Contributor

Closes #18

PR Title

feat: soft delete account mappings and exclude deleted rows from lookups

Summary

This change introduces soft deletes for account federation mappings so historical audit context is preserved instead of being permanently erased when an account is unregistered or a mapping is removed.

The fix adds a nullable deleted_at timestamp to the user mapping model and updates the delete flow to set that timestamp instead of issuing a hard DELETE. All active lookup paths now explicitly filter out any rows where deleted_at is not null, preventing soft-deleted accounts from appearing in normal federation and lookup results.

What changed

  • Added deleted_at to the user mapping schema

    • Prisma model includes nullable deletedAt field mapped to deleted_at
    • Legacy SQLite registry table also includes deleted_at for compatibility with fallback/local registry logic
  • Updated the unregister flow

    • The delete endpoint now performs an update:
      • sets deleted_at = now()
      • instead of removing the row entirely
    • This preserves the historical record for auditing and compliance purposes
  • Updated lookup and filtering behavior

    • Federation queries now filter to deleted_at IS NULL
    • Normal account lookups exclude soft-deleted rows
    • Search and stats counts also ignore deleted entries
    • Webhook authentication and horizon account monitoring skip soft-deleted users
  • Legacy/local registry safety

    • Raw SQL lookups in the SQLite fallback path were updated to include deleted_at IS NULL checks so deleted rows are not returned from the local registry either

Why this matters

Hard deletes remove the record entirely, which destroys the historical trail for who was registered, when, and why it was removed. Soft deletes maintain the data while ensuring operational lookups, federation resolution, and account checks behave as if deleted rows do not exist.

Risk / impact

Low risk to normal operations:

  • Active users continue to resolve normally
  • Deleted users are hidden from active lookup flows
  • Historical records remain available for audit and later cleanup

Validation

The branch was created and pushed successfully:

  • feat/soft-delete
  • remote push confirmed successful

Notes

This change intentionally keeps soft-deleted rows in storage until a separate retention/purge process removes expired entries after the configured retention window.

@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

@Silver36-ship-it is attempting to deploy a commit to the Abdulazeem's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Abdulazeem-code

Copy link
Copy Markdown
Owner

FIX FAILED CHECKS

@Abdulazeem-code

Copy link
Copy Markdown
Owner

RESOLVE CONFLICTS

@Abdulazeem-code

Copy link
Copy Markdown
Owner

FIX FAILED CHECKS

@Abdulazeem-code

Copy link
Copy Markdown
Owner

still failing

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.

Implement Soft Deletes Instead of Hard Deletes for Accounts

2 participants