From 600f428db4752114cff31283896d960299f80355 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 11 Mar 2019 19:23:21 +0100 Subject: [PATCH 1/2] WebPush: Add activity id to the push messages. Makes it easier to relate the push to a given status. --- lib/pleroma/web/push/impl.ex | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex index 33f912d34..4d65ca5d5 100644 --- a/lib/pleroma/web/push/impl.ex +++ b/lib/pleroma/web/push/impl.ex @@ -20,7 +20,7 @@ defmodule Pleroma.Web.Push.Impl do @doc "Performs sending notifications for user subscriptions" @spec perform_send(Notification.t()) :: list(any) - def perform_send(%{activity: %{data: %{"type" => activity_type}}, user_id: user_id} = notif) + def perform_send(%{activity: %{data: %{"type" => activity_type}, id: activity_id}, user_id: user_id} = notif) when activity_type in @types do actor = User.get_cached_by_ap_id(notif.activity.data["actor"]) @@ -37,7 +37,10 @@ def perform_send(%{activity: %{data: %{"type" => activity_type}}, user_id: user_ notification_id: notif.id, notification_type: type, icon: avatar_url, - preferred_locale: "en" + preferred_locale: "en", + pleroma: %{ + activity_id: activity_id + } } |> Jason.encode!() |> push_message(build_sub(subscription), gcm_api_key, subscription) From 07277879e595e803f903ac88d66f4b4eb98cc263 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 11 Mar 2019 19:32:21 +0100 Subject: [PATCH 2/2] Linting. --- lib/pleroma/web/push/impl.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex index 4d65ca5d5..0437ffd00 100644 --- a/lib/pleroma/web/push/impl.ex +++ b/lib/pleroma/web/push/impl.ex @@ -20,7 +20,10 @@ defmodule Pleroma.Web.Push.Impl do @doc "Performs sending notifications for user subscriptions" @spec perform_send(Notification.t()) :: list(any) - def perform_send(%{activity: %{data: %{"type" => activity_type}, id: activity_id}, user_id: user_id} = notif) + def perform_send( + %{activity: %{data: %{"type" => activity_type}, id: activity_id}, user_id: user_id} = + notif + ) when activity_type in @types do actor = User.get_cached_by_ap_id(notif.activity.data["actor"])