chore: Add display id in all conversation notifications (#3635)

- Added conversation display id in push payload for the notifications conversation_creation and conversation_assignment
This commit is contained in:
Muhsin Keloth 2021-12-21 19:59:22 +05:30 committed by GitHub
parent 307118b235
commit 262474166f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View file

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

View file

@ -78,4 +78,23 @@ RSpec.describe Notification do
expect(notification.push_message_title).to eq "[##{message.conversation.display_id}] Hey @John Peter please check this?" expect(notification.push_message_title).to eq "[##{message.conversation.display_id}] Hey @John Peter please check this?"
end end
end end
context 'when fcm push data' do
it 'returns correct data for primary actor conversation' do
notification = create(:notification, notification_type: 'conversation_creation')
expect(notification.fcm_push_data[:primary_actor]).to eq({
'id' => notification.primary_actor.display_id
})
end
it 'returns correct data for primary actor message' do
message = create(:message, sender: create(:user), content: Faker::Lorem.paragraphs(number: 2))
notification = create(:notification, notification_type: 'assigned_conversation_new_message', primary_actor: message)
expect(notification.fcm_push_data[:primary_actor]).to eq({
'id' => notification.primary_actor.id,
'conversation_id' => notification.primary_actor.conversation.display_id
})
end
end
end end