aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/push/impl.ex
diff options
context:
space:
mode:
authorSadposter <hannah+pleroma@coffee-and-dreams.uk>2019-12-10 16:54:25 +0000
committerSadposter <hannah+pleroma@coffee-and-dreams.uk>2019-12-10 16:54:25 +0000
commit8cfaab8f04cae6fcc20a37cdb463ee0c93b71217 (patch)
tree5ea3e43a73796f264508b583051f6f2143071f00 /lib/pleroma/web/push/impl.ex
parent5abee19b63aa1577f8895b48ae69f0a51edb4dc3 (diff)
parentaac0187ec13078d2756db1671e644d6eb9c0947b (diff)
downloadpleroma-8cfaab8f04cae6fcc20a37cdb463ee0c93b71217.tar.gz
Merge branch 'develop' into 'domain-block-precedence'
# Conflicts: # lib/pleroma/user.ex
Diffstat (limited to 'lib/pleroma/web/push/impl.ex')
-rw-r--r--lib/pleroma/web/push/impl.ex29
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex
index 3de7af708..34ec1d8d9 100644
--- a/lib/pleroma/web/push/impl.ex
+++ b/lib/pleroma/web/push/impl.ex
@@ -16,14 +16,14 @@ defmodule Pleroma.Web.Push.Impl do
require Logger
import Ecto.Query
- @types ["Create", "Follow", "Announce", "Like"]
+ @types ["Create", "Follow", "Announce", "Like", "Move"]
@doc "Performs sending notifications for user subscriptions"
@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,