fix: include account_id in FCM push payload (#15260)

## Description

- fcm_push_data didn't include the account id, so mobile clients had no
way to know which account a push notification belonged to. This adds
account_id to the FCM payload (it was already present in push_event_data
for ActionCable, just not FCM).
- Prerequisite for the mobile-side fix for
[chatwoot-mobile-app#1121](https://github.com/chatwoot/chatwoot-mobile-app/pull/1121)
(opening a conversation from a notification for a non-active account).
- Added a spec asserting fcm_push_data includes the account id.

Fixes
[CW-4235](https://linear.app/chatwoot/issue/CW-4235/the-conversation-fails-to-open-when-the-notifications-account-differs)

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Devi R
2026-08-12 08:40:51 +05:30
committed by GitHub
parent 7ed7bdcef4
commit 8397fa7eaf
2 changed files with 7 additions and 1 deletions

View File

@@ -81,7 +81,8 @@ class Notification < ApplicationRecord
notification_type: notification_type,
primary_actor_id: primary_actor_id,
primary_actor_type: primary_actor_type,
primary_actor: primary_actor.push_event_data.with_indifferent_access.slice('conversation_id', 'id')
primary_actor: primary_actor.push_event_data.with_indifferent_access.slice('conversation_id', 'id'),
account_id: account_id
}
end

View File

@@ -184,6 +184,11 @@ has been assigned to you"
'id' => notification.primary_actor.display_id
})
end
it 'includes the account id so the mobile app can open the conversation in the right account' do
notification = create(:notification, notification_type: 'conversation_creation')
expect(notification.fcm_push_data[:account_id]).to eq(notification.account_id)
end
end
context 'when primary actor is deleted' do