diff options
author | lain <lain@soykaf.club> | 2019-04-05 22:24:58 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-04-05 22:24:58 +0200 |
commit | ef4e67d7679766528f3efd1f59f18574e54b5e9a (patch) | |
tree | 5adbcf6c80ae8ffa874f2a57c038b3a1d3cabc74 | |
parent | d79a59c3b8646f2e760eaf59596762d88dcf01c2 (diff) | |
download | pleroma-ef4e67d7679766528f3efd1f59f18574e54b5e9a.tar.gz |
Fix and format.
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/status_view.ex | 12 | ||||
-rw-r--r-- | test/web/mastodon_api/status_view_test.exs | 12 |
2 files changed, 19 insertions, 5 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index a227d742d..f46d46acc 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -138,7 +138,15 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do |> HTML.get_cached_scrubbed_html_for_object( User.html_filter_policy(opts[:for]), activity, - __MODULE__ + "mastoapi:content" + ) + + summary = + (object["summary"] || "") + |> HTML.get_cached_scrubbed_html_for_object( + User.html_filter_policy(opts[:for]), + activity, + "mastoapi:summary" ) card = render("card.json", Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity)) @@ -163,7 +171,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do muted: false, pinned: pinned?(activity, user), sensitive: sensitive, - spoiler_text: object["summary"] || "", + spoiler_text: summary, visibility: get_visibility(object), media_attachments: attachments |> Enum.take(4), mentions: mentions, diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs index 52adab74f..9249424cd 100644 --- a/test/web/mastodon_api/status_view_test.exs +++ b/test/web/mastodon_api/status_view_test.exs @@ -69,7 +69,12 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do test "a note activity" do user = insert(:user) - {:ok, note} = CommonAPI.post(user, %{"status" => "cool test :firefox: #yeah", "spoiler_text" => "<script>alert('alerta')</script>test"}) + + {:ok, note} = + CommonAPI.post(user, %{ + "status" => "cool test :firefox: #yeah", + "spoiler_text" => "<script>alert('alerta')</script>test" + }) status = StatusView.render("status.json", %{activity: note}) @@ -88,7 +93,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do in_reply_to_account_id: nil, card: nil, reblog: nil, - content: "cool test :firefox: <a class=\"hashtag\" data-tag=\"yeah\" href=\"http://localhost:4001/tag/yeah\">#yeah</a>", + content: + "cool test :firefox: <a class=\"hashtag\" data-tag=\"yeah\" href=\"http://localhost:4001/tag/yeah\">#yeah</a>", created_at: created_at, reblogs_count: 0, replies_count: 0, @@ -99,7 +105,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do muted: false, pinned: false, sensitive: false, - spoiler_text: "test", + spoiler_text: "alert('alerta')test", visibility: "public", media_attachments: [], mentions: [AccountView.render("mention.json", %{user: user})], |