summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2021-08-11 21:29:06 +0200
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2021-08-11 21:38:10 +0200
commit61d233921cf1a5f45ade58cb562e9ffdacc291e8 (patch)
treefc9d1e3cf5de7cbe83ee90beae794244610252fc /lib
parent7c1243178b44d629f6881aa1b197641d56bbd0f1 (diff)
downloadpleroma-61d233921cf1a5f45ade58cb562e9ffdacc291e8.tar.gz
pleroma-61d233921cf1a5f45ade58cb562e9ffdacc291e8.zip
ObjectValidator.stringify_keys: filter out nil values
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/object_validator.ex1
-rw-r--r--lib/pleroma/web/push/impl.ex4
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/pleroma/web/activity_pub/object_validator.ex b/lib/pleroma/web/activity_pub/object_validator.ex
index 6e40d8b72..187cd0cfd 100644
--- a/lib/pleroma/web/activity_pub/object_validator.ex
+++ b/lib/pleroma/web/activity_pub/object_validator.ex
@@ -213,6 +213,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do
def stringify_keys(object) when is_map(object) do
object
+ |> Enum.filter(fn {_, v} -> v != nil end)
|> Map.new(fn {key, val} -> {to_string(key), stringify_keys(val)} end)
end
diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex
index 83cbdc870..28e13ef9c 100644
--- a/lib/pleroma/web/push/impl.ex
+++ b/lib/pleroma/web/push/impl.ex
@@ -124,8 +124,8 @@ defmodule Pleroma.Web.Push.Impl do
def format_body(activity, actor, object, mastodon_type \\ nil)
- def format_body(_activity, actor, %{data: %{"type" => "ChatMessage", "content" => content}}, _) do
- case content do
+ def format_body(_activity, actor, %{data: %{"type" => "ChatMessage"} = data}, _) do
+ case data["content"] do
nil -> "@#{actor.nickname}: (Attachment)"
content -> "@#{actor.nickname}: #{Utils.scrub_html_and_truncate(content, 80)}"
end