diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 62ce3b7b5..0779872fe 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -228,15 +228,7 @@ def render( tags = if possibly_sensitive, do: Enum.uniq(["nsfw" | tags]), else: tags - summary = activity.data["object"]["summary"] - content = object["content"] - - content = - if !!summary and summary != "" do - "#{activity.data["object"]["summary"]}
#{content}" - else - content - end + {summary, content} = render_content(object) html = HtmlSanitizeEx.basic_html(content) @@ -266,4 +258,35 @@ def render( "visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object) } end + + def render_content(%{"type" => "Note"} = object) do + summary = object["summary"] + content = + if !!summary and summary != "" do + "

#{summary}

#{object["content"]}" + else + object["content"] + end + + {summary, content} + end + + def render_content(%{"type" => "Article"} = object) do + summary = object["name"] || object["summary"] + content = + if !!summary and summary != "" do + "

#{summary}

#{object["content"]}" + else + object["content"] + end + + {summary, content} + end + + def render_content(object) do + summary = object["summary"] || "Unhandled activity type: #{object["type"]}" + content = "

#{summary}

#{object["content"]}" + + {summary, content} + end end