WebPush: Add activity id to the push messages.
authorlain <lain@soykaf.club>
Mon, 11 Mar 2019 18:23:21 +0000 (19:23 +0100)
committerlain <lain@soykaf.club>
Mon, 11 Mar 2019 18:23:21 +0000 (19:23 +0100)
Makes it easier to relate the push to a given status.

lib/pleroma/web/push/impl.ex

index 33f912d346bddb8a0c60211eda04d456fa2f62c7..4d65ca5d546a9803c78b97fde1b3e0b85eefbc32 100644 (file)
@@ -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 @@ defmodule Pleroma.Web.Push.Impl do
         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)