Don't error on rich media fail

This commit is contained in:
Floatingghost 2024-06-04 14:21:40 +01:00
parent 778b213945
commit 30e13a8785
2 changed files with 10 additions and 0 deletions

View file

@ -97,6 +97,11 @@ defmodule Pleroma.Web.RichMedia.Helpers do
end
with :ok <- head_check, do: Pleroma.HTTP.get(url, headers, @options)
rescue
e ->
Logger.error("Failed to fetch rich media: #{inspect(e)}")
{:error, :fetch_error}
end
defp check_content_type(headers) do

View file

@ -81,4 +81,9 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
assert %{} = Helpers.fetch_data_for_activity(activity4)
assert %{} = Helpers.fetch_data_for_activity(activity5)
end
test "catches errors in fetching" do
Tesla.Mock.mock(fn _ -> raise ArgumentError end)
assert {:error, :fetch_error} == Helpers.rich_media_get("wp-json/oembed/1.0/embed?url=http:%252F%252F")
end
end