forked from AkkomaGang/akkoma
Don't error on rich media fail
This commit is contained in:
parent
778b213945
commit
30e13a8785
2 changed files with 10 additions and 0 deletions
|
@ -97,6 +97,11 @@ def rich_media_get(url) 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
|
||||
|
|
|
@ -81,4 +81,9 @@ test "refuses to crawl URLs of private network from posts" 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
|
||||
|
|
Loading…
Reference in a new issue