diff options
author | Maksim Pechnikov <parallel588@gmail.com> | 2019-10-29 21:33:17 +0300 |
---|---|---|
committer | Maksim Pechnikov <parallel588@gmail.com> | 2019-11-28 22:13:11 +0300 |
commit | 04a8ffbe84c6d40709860e75fffa0330a2db690f (patch) | |
tree | 037b79301ef01dd723e5e4f839b6e4c92f71f901 /lib/pleroma/web/push/impl.ex | |
parent | a52da55eb9c6bbf8a08bf1d90d59a48dc25f5907 (diff) | |
download | pleroma-04a8ffbe84c6d40709860e75fffa0330a2db690f.tar.gz |
added privacy option to push notifications
Diffstat (limited to 'lib/pleroma/web/push/impl.ex')
-rw-r--r-- | lib/pleroma/web/push/impl.ex | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex index 3de7af708..53f93c1ed 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, |