Skip to content

Commit

Permalink
chore: Strip unnecessary data from push payload (#2924)
Browse files Browse the repository at this point in the history
  • Loading branch information
sojan-official committed Sep 9, 2021
1 parent 2821777 commit 9c4ce9a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions app/models/notification.rb
Expand Up @@ -60,6 +60,16 @@ def push_event_data
}
end

def fcm_push_data
{
id: id,
notification_type: notification_type,
primary_actor_id: primary_actor_id,
primary_actor_type: primary_actor_type,
primary_actor: primary_actor.push_event_data.slice(:conversation_id)
}
end

# TODO: move to a data presenter
def push_message_title
case notification_type
Expand Down
5 changes: 3 additions & 2 deletions app/services/notification/push_notification_service.rb
Expand Up @@ -94,9 +94,10 @@ def fcm_options
{
notification: {
title: notification.notification_type.titleize,
body: notification.push_message_title
body: notification.push_message_title,
sound: 'default'
},
data: { notification: notification.push_event_data.to_json },
data: { notification: notification.fcm_push_data.to_json },
collapse_key: "chatwoot_#{notification.primary_actor_type.downcase}_#{notification.primary_actor_id}"
}
end
Expand Down

0 comments on commit 9c4ce9a

Please sign in to comment.