whisper-money/app/Http/Middleware
Víctor Falcón b7ff4e074d Move residual-encryption cleanup out of Inertia share() into a queued job
HandleInertiaRequests::share() is an Inertia shared-data provider and should be
read-only, but it ran a DELETE + UPDATE against the user on every non-API web
GET to purge the leftover encryption salt and EncryptedMessage once a user no
longer had any encrypted accounts or transactions. Writing to the database
while resolving render props is a side effect in the wrong place.

The existing encryption commands do not cover this case: both
NotifyEncryptedDataRemovalCommand and DeleteEncryptedDataAccountsCommand target
users who *still* have encrypted data, whereas this cleanup finalizes users who
have *finished* decrypting. To preserve that eventual-cleanup semantics without
writing during the render, the work now goes to a new
PurgeResidualEncryptionArtifactsJob dispatched from share(). The job re-checks
the condition on execution and is idempotent, so repeat dispatches are no-ops.

The two ->exists() checks stay because they still feed the hasEncryptedAccounts
and hasEncryptedTransactions props.

Tests: InertiaSharedDataTest asserts a web GET no longer mutates the user inline
and instead queues the job (and does not queue it when there is no salt); a new
PurgeResidualEncryptionArtifactsJobTest covers the clear, the two 'still has
encrypted data' guards, and the null-salt no-op.
2026-07-04 20:18:49 +02:00
..
BlockDemoAccountActions.php feat: Spanish localization (#74) 2026-02-08 11:58:08 +01:00
EnsureOnboardingComplete.php chore: upgrade Laravel 12 to 13 (#242) 2026-03-25 12:56:33 +00:00
EnsureUserIsSubscribed.php feat(paywall): require a plan when the user has accepted AI (#564) 2026-06-19 14:18:49 +00:00
HandleAppearance.php chore: upgrade Laravel 12 to 13 (#242) 2026-03-25 12:56:33 +00:00
HandleInertiaRequests.php Move residual-encryption cleanup out of Inertia share() into a queued job 2026-07-04 20:18:49 +02:00
SetLocale.php refactor: centralize duplicated provider & locale keys into enums (#543) 2026-06-16 13:43:14 +00:00
SetSentryUser.php Add Sentry user context (#348) 2026-05-04 13:26:50 +01:00
TrackLastActiveAt.php feat(users): track last login and last active timestamps (#516) 2026-06-10 11:01:30 +02:00
WithoutSsr.php Disable SSR for dashboard routes and extract API routes (#19) 2025-12-08 19:21:48 +01:00