summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2024-06-08 20:30:43 -0400
committerMark Felder <feld@feld.me>2024-06-08 22:08:12 -0400
commit3211557f742e07d5144426a71c39267480656a38 (patch)
treeaa60ce570d4f716f8f927541946713f1fae79ec7 /lib
parentb1ef6e5e9ad5afc9d556a4d88ff34c9b62f5fea2 (diff)
downloadpleroma-3211557f742e07d5144426a71c39267480656a38.tar.gz
pleroma-3211557f742e07d5144426a71c39267480656a38.zip
Render nice web push notifications for polls
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/push/impl.ex19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex
index df7e0c53f..98e7659ab 100644
--- a/lib/pleroma/web/push/impl.ex
+++ b/lib/pleroma/web/push/impl.ex
@@ -131,6 +131,24 @@ defmodule Pleroma.Web.Push.Impl do
end
def format_body(
+ %{type: "poll"} = _notification,
+ _user,
+ %{data: %{"content" => content} = data} = _object
+ ) do
+ options = Map.get(data, "anyOf") || Map.get(data, "oneOf")
+
+ content_text = content <> "\n"
+
+ options_text =
+ Enum.map(options, fn x -> "○ #{x["name"]}" end)
+ |> Enum.join("\n")
+
+ [content_text, options_text]
+ |> Enum.join("\n")
+ |> Utils.scrub_html_and_truncate(80)
+ end
+
+ def format_body(
%{activity: %{data: %{"type" => "Create"}}},
user,
%{data: %{"content" => content}}
@@ -191,6 +209,7 @@ defmodule Pleroma.Web.Push.Impl do
"update" -> "New Update"
"pleroma:chat_mention" -> "New Chat Message"
"pleroma:emoji_reaction" -> "New Reaction"
+ "poll" -> "Poll Results"
type -> "New #{String.capitalize(type || "event")}"
end
end