From dd1432d6955a72b8483717978d61a505e0608bbc Mon Sep 17 00:00:00 2001 From: rinpatch Date: Wed, 16 Jan 2019 09:42:24 +0300 Subject: [PATCH] Disable previews for any activity, but create --- lib/pleroma/web/metadata/opengraph.ex | 5 +++-- lib/pleroma/web/ostatus/ostatus_controller.ex | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/web/metadata/opengraph.ex b/lib/pleroma/web/metadata/opengraph.ex index 33ff075c6..b15856974 100644 --- a/lib/pleroma/web/metadata/opengraph.ex +++ b/lib/pleroma/web/metadata/opengraph.ex @@ -71,7 +71,7 @@ defp build_attachments(activity) do end) end - defp scrub_html_and_truncate(%{data: %{ "object" => %{ "content" => content}}} = activity) do + defp scrub_html_and_truncate(%{data: %{"object" => %{"content" => content}}} = activity) do content # html content comes from DB already encoded, decode first and scrub after |> HtmlEntities.decode() @@ -80,7 +80,7 @@ defp scrub_html_and_truncate(%{data: %{ "object" => %{ "content" => content}}} = |> Formatter.truncate() end - defp scrub_html_and_truncate(content) do + defp scrub_html_and_truncate(content) when is_binary(content) do content # html content comes from DB already encoded, decode first and scrub after |> HtmlEntities.decode() @@ -88,6 +88,7 @@ defp scrub_html_and_truncate(content) do |> HTML.strip_tags() |> Formatter.truncate() end + defp attachment_url(url) do MediaProxy.url(url) end diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index 2a47519d1..f7ba57389 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -145,7 +145,15 @@ def notice(conn, %{"id" => id}) do %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do case format = get_format(conn) do "html" -> - Fallback.RedirectController.redirector_with_meta(conn, %{activity: activity, user: user}) + # Only Create actvities have a map at object + if is_map(activity.data["object"]) do + Fallback.RedirectController.redirector_with_meta(conn, %{ + activity: activity, + user: user + }) + else + Fallback.RedirectController.redirector(conn, nil) + end _ -> represent_activity(conn, format, activity, user)