From 37da4dd8ca3cc0d339b0b3472a32283711a04ee2 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Fri, 13 Feb 2026 16:12:26 +0530 Subject: [PATCH] fix: invalidate inbox cache key immediately on delete --- app/controllers/api/v1/accounts/inboxes_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/accounts/inboxes_controller.rb b/app/controllers/api/v1/accounts/inboxes_controller.rb index 322c7c7fe..9e544a8b5 100644 --- a/app/controllers/api/v1/accounts/inboxes_controller.rb +++ b/app/controllers/api/v1/accounts/inboxes_controller.rb @@ -66,7 +66,12 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController end def destroy - ::DeleteObjectJob.perform_later(@inbox, Current.user, request.ip) if @inbox.present? + if @inbox.present? + # Invalidate cache immediately so frontends don't serve stale data + # while the async DeleteObjectJob is still in the queue. + Current.account.update_cache_key('inbox') + ::DeleteObjectJob.perform_later(@inbox, Current.user, request.ip) + end render status: :ok, json: { message: I18n.t('messages.inbox_deletetion_response') } end