diff options
author | William Pitcock <nenolod@dereferenced.org> | 2018-06-24 06:14:17 +0000 |
---|---|---|
committer | William Pitcock <nenolod@dereferenced.org> | 2018-06-27 13:38:00 +0000 |
commit | ea982e7503767f645dc26235e04c541ce976de71 (patch) | |
tree | 62be450d7d6497b8c89c8e8838ccdaaeb650a988 | |
parent | 121c1f62306e416f1f6106d1751b55a5eb9f9075 (diff) | |
download | pleroma-ea982e7503767f645dc26235e04c541ce976de71.tar.gz |
mastodon api: add interpreter for Article activity types
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/status_view.ex | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 59898457b..f7ad87bad 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -128,7 +128,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do in_reply_to_id: reply_to && to_string(reply_to.id), in_reply_to_account_id: reply_to_user && to_string(reply_to_user.id), reblog: nil, - content: HtmlSanitizeEx.basic_html(object["content"]), + content: render_content(object), created_at: created_at, reblogs_count: announcement_count, favourites_count: like_count, @@ -207,4 +207,20 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do "direct" end end + + def render_content(%{"type" => "Article"} = object) do + summary = object["name"] + content = + if !!summary and summary != "" do + "<p><a href=\"#{object["url"]}\">#{summary}</a></p>#{object["content"]}" + else + object["content"] + end + + HtmlSanitizeEx.basic_html(content) + end + + def render_content(object) do + HtmlSanitizeEx.basic_html(object["content"]) + end end |