X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fpush%2Fimpl.ex;h=2233480c5ed9c2903f78ee246e5dbf5280e215d4;hb=60f213bb1a6b1627cd8f6bf2903a42c3f3827f1a;hp=33f912d346bddb8a0c60211eda04d456fa2f62c7;hpb=07f8c79a698e7ed139dec4adcefc0ae1ba680815;p=akkoma diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex index 33f912d34..2233480c5 100644 --- a/lib/pleroma/web/push/impl.ex +++ b/lib/pleroma/web/push/impl.ex @@ -5,13 +5,13 @@ defmodule Pleroma.Web.Push.Impl do @moduledoc "The module represents implementation push web notification" - alias Pleroma.Repo - alias Pleroma.User alias Pleroma.Activity + alias Pleroma.Notification alias Pleroma.Object - alias Pleroma.Web.Push.Subscription + alias Pleroma.Repo + alias Pleroma.User alias Pleroma.Web.Metadata.Utils - alias Pleroma.Notification + alias Pleroma.Web.Push.Subscription require Logger import Ecto.Query @@ -19,8 +19,11 @@ defmodule Pleroma.Web.Push.Impl do @types ["Create", "Follow", "Announce", "Like"] @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) + @spec perform(Notification.t()) :: list(any) | :error + def perform( + %{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,14 +40,17 @@ 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) end end - def perform_send(_) do + def perform(_) do Logger.warn("Unknown notification type") :error end