Merge branch 'object-fetch-errors' into 'develop'

Object fetch errors

See merge request pleroma/pleroma!1881
This commit is contained in:
kaniini 2019-10-25 00:22:50 +00:00
commit 40a2a92a1f
2 changed files with 10 additions and 1 deletions

View file

@ -90,6 +90,9 @@ def fetch_object_from_id(id, options \\ []) do
{:fetch_object, %Object{} = object} -> {:fetch_object, %Object{} = object} ->
{:ok, object} {:ok, object}
{:fetch, {:error, error}} ->
{:error, error}
e -> e ->
e e
end end
@ -110,6 +113,9 @@ def fetch_object_from_id!(id, options \\ []) do
with {:ok, object} <- fetch_object_from_id(id, options) do with {:ok, object} <- fetch_object_from_id(id, options) do
object object
else else
{:error, %Tesla.Mock.Error{}} ->
nil
e -> e ->
Logger.error("Error while fetching #{id}: #{inspect(e)}") Logger.error("Error while fetching #{id}: #{inspect(e)}")
nil nil
@ -170,6 +176,9 @@ def fetch_and_contain_remote_object_from_id(id) when is_binary(id) do
{:scheme, _} -> {:scheme, _} ->
{:error, "Unsupported URI scheme"} {:error, "Unsupported URI scheme"}
{:error, e} ->
{:error, e}
e -> e ->
{:error, e} {:error, e}
end end

View file

@ -720,7 +720,7 @@ test "it fails for incoming deletes with spoofed origin" do
assert capture_log(fn -> assert capture_log(fn ->
:error = Transmogrifier.handle_incoming(data) :error = Transmogrifier.handle_incoming(data)
end) =~ end) =~
"[error] Could not decode user at fetch http://mastodon.example.org/users/gargron, {:error, {:error, :nxdomain}}" "[error] Could not decode user at fetch http://mastodon.example.org/users/gargron, {:error, :nxdomain}"
assert Activity.get_by_id(activity.id) assert Activity.get_by_id(activity.id)
end end