Chore: FCM Push Fixes (#934)

This commit is contained in:
Sojan Jose
2020-06-09 17:42:18 +05:30
committed by GitHub
parent 40481f6462
commit 8b022311c0
6 changed files with 92 additions and 21 deletions

View File

@@ -38,6 +38,29 @@ class Notification < ApplicationRecord
after_create_commit :process_notification_delivery
def push_event_data
{
id: id,
notification_type: notification_type,
primary_actor: primary_actor&.push_event_data,
read_at: read_at,
secondary_actor: secondary_actor&.push_event_data,
user: user&.push_event_data,
created_at: created_at
}
end
# TODO: move to a data presenter
def push_message_title
if notification_type == 'conversation_creation'
return "A new conversation [ID -#{primary_actor.display_id}] has been created in #{primary_actor.inbox.name}"
end
return "A new conversation [ID -#{primary_actor.display_id}] has been assigned to you." if notification_type == 'conversation_assignment'
''
end
private
def process_notification_delivery