diff options
author | href <href@random.sh> | 2018-12-08 17:34:13 +0100 |
---|---|---|
committer | href <href@random.sh> | 2018-12-14 13:05:48 +0100 |
commit | d8984b7bf83e1ee076a73aab682db0f2673e3735 (patch) | |
tree | c0d848b1229b204aaeddac898cecc71589a77b68 /lib | |
parent | 7facbb2b8d68abc608d6d36f21207d5c0f131029 (diff) | |
download | pleroma-d8984b7bf83e1ee076a73aab682db0f2673e3735.tar.gz |
Push: add missing notification_type field
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/push/push.ex | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/pleroma/web/push/push.ex b/lib/pleroma/web/push/push.ex index 4af3e159a..8b59e54cb 100644 --- a/lib/pleroma/web/push/push.ex +++ b/lib/pleroma/web/push/push.ex @@ -58,14 +58,15 @@ defmodule Pleroma.Web.Push do body = Jason.encode!(%{ title: format_title(notification), + access_token: record.token.token, body: format_body(notification, actor), notification_id: notification.id, + notification_type: format_type(notification), icon: User.avatar_url(actor), - preferred_locale: "en", - access_token: record.token.token + preferred_locale: "en" }) - case WebPushEncryption.send_web_push(body, subscription, @gcm_api_key) do + case WebPushEncryption.send_web_push(body, subscription) do {:ok, %{status_code: code}} when 400 <= code and code < 500 -> Logger.debug("Removing subscription record") Repo.delete!(record) @@ -92,6 +93,16 @@ defmodule Pleroma.Web.Push do {:noreply, state} end + # https://github.com/tootsuite/mastodon/blob/master/app/models/notification.rb#L19 + defp format_type(%{activity: %{data: %{"type" => type}}}) do + case type do + "Create" -> "mention" + "Follow" -> "follow" + "Announce" -> "reblog" + "Favorite" -> "favourite" + end + end + defp format_title(%{activity: %{data: %{"type" => type}}}) do case type do "Create" -> "New Mention" |