Skip to content

Auto-delete assets and account data when a deletion-confirmed account is cleaned up - #186

Merged
oveldman merged 13 commits into
mainfrom
feature/172-auto-delete-assets-account
Jul 10, 2026
Merged

Auto-delete assets and account data when a deletion-confirmed account is cleaned up#186
oveldman merged 13 commits into
mainfrom
feature/172-auto-delete-assets-account

Conversation

@oveldman

Copy link
Copy Markdown
Contributor

Summary

Implements the automated account deletion cleanup flow (issue #172). When an administrator confirms an account deletion, a nightly background service (and a new manual trigger) now permanently removes the account's assets from object storage, hard-deletes all associated asset records and audit logs, and marks the account as Deleted — completing the full GDPR deletion lifecycle.

Changes

  • Domain — added Account.Delete(clock) method with AccountErrors.DeletionNotConfirmed guard; added AccountDeletedEvent; added AuditErrors.DeleteFailed
  • Application — added DeleteRequestedAccountsUseCase that processes all DeletionConfirmed accounts and dispatches AccountDeletedEvent; added AssetAccountEventHandler (deletes S3 content + asset records) and AuditAccountEventHandler (deletes audit logs) as domain event handlers
  • Infrastructure — implemented IAccountRepository.GetConfirmedDeletionAccounts() and DeleteAsync(UserId); IAssetRepository.GetAssetsAsync(UserId), DeleteAsync(UserId), DeleteAsync(Asset); IAuditRepository.DeleteAsync(UserId)
  • API — added POST /host-services/manual-triggers/clean-up/accounts manual trigger endpoint (Administrator policy)
  • Hosted service — added DeleteRequestedAccountsService running daily at Cleanup:TriggerHourUtc
  • Admin UI — added "Clean Up Deleted Accounts" card to the Manual Triggers page
  • Tests — integration test covering the full cleanup flow (account + asset deletion); 6 component tests for all three manual trigger cards

How to Test

  • Create an account via POST /accounts/me, request deletion via POST /accounts/me/deletion-request, confirm it via POST /accounts/{userId}/confirm-deletion
  • Upload an asset under the same user before confirming deletion
  • Call POST /host-services/manual-triggers/clean-up/accounts (requires Administrator JWT)
  • Verify the account status is Deleted in the database and GET /assets/{id} returns 404 for the user's asset
  • Alternatively run the integration test: dotnet test tests/MadWorldEU.Byakko.Controller.Api.IntegrationTests/ --filter "Manually trigger account deletion cleanup"

Checklist

  • Code builds without errors
  • Changes have been tested locally
  • No new warnings introduced

@oveldman oveldman self-assigned this Jul 10, 2026
@oveldman oveldman added the enhancement New feature or request label Jul 10, 2026
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
66.9% Coverage on New Code (required ≥ 80%)
5.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@oveldman
oveldman merged commit ac2df7a into main Jul 10, 2026
9 of 10 checks passed
@oveldman
oveldman deleted the feature/172-auto-delete-assets-account branch July 10, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Send confirmation emails to users when a deletion request is submitted and when the account is deleted

1 participant