WebPush: Don't break on contentless chat messages.

This commit is contained in:
lain 2020-06-06 09:46:07 +02:00
commit 4e8c0eecd5
2 changed files with 32 additions and 0 deletions

View file

@ -124,6 +124,13 @@ 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
nil -> "@#{actor.nickname}: (Attachment)"
content -> "@#{actor.nickname}: #{Utils.scrub_html_and_truncate(content, 80)}"
end
end
def format_body(
%{activity: %{data: %{"type" => "Create"}}},
actor,