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:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user