aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/push/impl.ex
diff options
context:
space:
mode:
authorMaksim Pechnikov <parallel588@gmail.com>2019-12-09 19:41:43 +0300
committerMaksim Pechnikov <parallel588@gmail.com>2019-12-09 19:41:43 +0300
commit2b821036c4bd84cee51c9fcace5a4b3764c3bba1 (patch)
tree811d75ef4b0442f3f2102d873fab4e10c777e7f1 /lib/pleroma/web/push/impl.ex
parent5876a9cb79e53f932d63e457610852031669a222 (diff)
parent0d2c13a119302d0d217a7cb61c28a01c620b1b61 (diff)
downloadpleroma-2b821036c4bd84cee51c9fcace5a4b3764c3bba1.tar.gz
Merge branch 'develop' into issue/1383
Diffstat (limited to 'lib/pleroma/web/push/impl.ex')
-rw-r--r--lib/pleroma/web/push/impl.ex27
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex
index a6a924d02..34ec1d8d9 100644
--- a/lib/pleroma/web/push/impl.ex
+++ b/lib/pleroma/web/push/impl.ex
@@ -22,8 +22,8 @@ defmodule Pleroma.Web.Push.Impl do
@spec perform(Notification.t()) :: list(any) | :error
def perform(
%{
- activity: %{data: %{"type" => activity_type}, id: activity_id} = activity,
- user_id: user_id
+ activity: %{data: %{"type" => activity_type}} = activity,
+ user: %User{id: user_id}
} = notif
)
when activity_type in @types do
@@ -39,18 +39,17 @@ defmodule Pleroma.Web.Push.Impl do
for subscription <- fetch_subsriptions(user_id),
get_in(subscription.data, ["alerts", type]) do
%{
- title: format_title(notif),
access_token: subscription.token.token,
- body: format_body(notif, actor, object),
notification_id: notif.id,
notification_type: type,
icon: avatar_url,
preferred_locale: "en",
pleroma: %{
- activity_id: activity_id,
+ activity_id: notif.activity.id,
direct_conversation_id: direct_conversation_id
}
}
+ |> Map.merge(build_content(notif, actor, object))
|> Jason.encode!()
|> push_message(build_sub(subscription), gcm_api_key, subscription)
end
@@ -100,6 +99,24 @@ defmodule Pleroma.Web.Push.Impl do
}
end
+ def build_content(
+ %{
+ activity: %{data: %{"directMessage" => true}},
+ user: %{notification_settings: %{privacy_option: true}}
+ },
+ actor,
+ _
+ ) do
+ %{title: "New Direct Message", body: "@#{actor.nickname}"}
+ end
+
+ def build_content(notif, actor, object) do
+ %{
+ title: format_title(notif),
+ body: format_body(notif, actor, object)
+ }
+ end
+
def format_body(
%{activity: %{data: %{"type" => "Create"}}},
actor,