aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/push
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-03-14 22:33:20 +0300
committerrinpatch <rinpatch@sdf.org>2019-03-14 22:33:20 +0300
commitcbdd11c38111fd7c195983f40265b675e1201d4e (patch)
tree44c63ed6430a743cfe589fed5213467a0dd6dabb /lib/pleroma/web/push
parent355f285a8693934fbc8205c2c9ecde0a758fc158 (diff)
parent34fc0dca2e879bcbb73acc80fdc72678411d0ebf (diff)
downloadpleroma-cbdd11c38111fd7c195983f40265b675e1201d4e.tar.gz
Merge develop to bump elixir version in the CI so I don't get failing formatting
Diffstat (limited to 'lib/pleroma/web/push')
-rw-r--r--lib/pleroma/web/push/impl.ex18
-rw-r--r--lib/pleroma/web/push/push.ex6
-rw-r--r--lib/pleroma/web/push/subscription.ex4
3 files changed, 17 insertions, 11 deletions
diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex
index 33f912d34..863573185 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
@@ -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}}, 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 +40,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)
diff --git a/lib/pleroma/web/push/push.ex b/lib/pleroma/web/push/push.ex
index 951dab535..5259e8e33 100644
--- a/lib/pleroma/web/push/push.ex
+++ b/lib/pleroma/web/push/push.ex
@@ -13,15 +13,15 @@ defmodule Pleroma.Web.Push do
# Client API #
##############
- def start_link() do
+ def start_link do
GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
end
- def vapid_config() do
+ def vapid_config do
Application.get_env(:web_push_encryption, :vapid_details, [])
end
- def enabled() do
+ def enabled do
case vapid_config() do
[] -> false
list when is_list(list) -> true
diff --git a/lib/pleroma/web/push/subscription.ex b/lib/pleroma/web/push/subscription.ex
index c90bd2bda..da301fbbc 100644
--- a/lib/pleroma/web/push/subscription.ex
+++ b/lib/pleroma/web/push/subscription.ex
@@ -82,8 +82,8 @@ defmodule Pleroma.Web.Push.Subscription do
end
# Some webpush clients (e.g. iOS Toot!) use an non urlsafe base64 as an encoding for the key.
- # However, the web push rfs specify to use base64 urlsafe, and the `web_push_encryption` library we use
- # requires the key to be properly encoded. So we just convert base64 to urlsafe base64.
+ # However, the web push rfs specify to use base64 urlsafe, and the `web_push_encryption` library
+ # we use requires the key to be properly encoded. So we just convert base64 to urlsafe base64.
defp ensure_base64_urlsafe(string) do
string
|> String.replace("+", "-")