Disable previews for any activity, but create

This commit is contained in:
rinpatch 2019-01-16 09:42:24 +03:00
parent 565caff3f4
commit dd1432d695
2 changed files with 12 additions and 3 deletions

View File

@ -71,7 +71,7 @@ defp build_attachments(activity) do
end) end)
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 content
# html content comes from DB already encoded, decode first and scrub after # html content comes from DB already encoded, decode first and scrub after
|> HtmlEntities.decode() |> HtmlEntities.decode()
@ -80,7 +80,7 @@ defp scrub_html_and_truncate(%{data: %{ "object" => %{ "content" => content}}} =
|> Formatter.truncate() |> Formatter.truncate()
end end
defp scrub_html_and_truncate(content) do defp scrub_html_and_truncate(content) when is_binary(content) do
content content
# html content comes from DB already encoded, decode first and scrub after # html content comes from DB already encoded, decode first and scrub after
|> HtmlEntities.decode() |> HtmlEntities.decode()
@ -88,6 +88,7 @@ defp scrub_html_and_truncate(content) do
|> HTML.strip_tags() |> HTML.strip_tags()
|> Formatter.truncate() |> Formatter.truncate()
end end
defp attachment_url(url) do defp attachment_url(url) do
MediaProxy.url(url) MediaProxy.url(url)
end end

View File

@ -145,7 +145,15 @@ def notice(conn, %{"id" => id}) do
%User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do
case format = get_format(conn) do case format = get_format(conn) do
"html" -> "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) represent_activity(conn, format, activity, user)