Leverage existing atoms as return errors for the object fetcher
This commit is contained in:
parent
287f2c9719
commit
a2708f7fe3
|
@ -220,10 +220,10 @@ defp get_object(id) do
|
|||
end
|
||||
|
||||
{:ok, %{status: 403}} ->
|
||||
{:error, "Object fetch has been denied"}
|
||||
{:error, :forbidden}
|
||||
|
||||
{:ok, %{status: code}} when code in [404, 410] ->
|
||||
{:error, "Object has been deleted"}
|
||||
{:error, :not_found}
|
||||
|
||||
{:error, e} ->
|
||||
{:error, e}
|
||||
|
|
|
@ -15,11 +15,11 @@ def perform(%Job{args: %{"op" => "fetch_remote", "id" => id} = args}) do
|
|||
{:ok, _object} ->
|
||||
:ok
|
||||
|
||||
{:error, reason = "Object fetch has been denied"} ->
|
||||
{:cancel, reason}
|
||||
{:error, :forbidden} ->
|
||||
{:cancel, :forbidden}
|
||||
|
||||
{:error, reason = "Object has been deleted"} ->
|
||||
{:cancel, reason}
|
||||
{:error, :not_found} ->
|
||||
{:cancel, :not_found}
|
||||
|
||||
_ ->
|
||||
:error
|
||||
|
|
|
@ -220,14 +220,14 @@ test "all objects with fake directions are rejected by the object fetcher" do
|
|||
end
|
||||
|
||||
test "handle HTTP 410 Gone response" do
|
||||
assert {:error, "Object has been deleted"} ==
|
||||
assert {:error, :not_found} ==
|
||||
Fetcher.fetch_and_contain_remote_object_from_id(
|
||||
"https://mastodon.example.org/users/userisgone"
|
||||
)
|
||||
end
|
||||
|
||||
test "handle HTTP 404 response" do
|
||||
assert {:error, "Object has been deleted"} ==
|
||||
assert {:error, :not_found} ==
|
||||
Fetcher.fetch_and_contain_remote_object_from_id(
|
||||
"https://mastodon.example.org/users/userisgone404"
|
||||
)
|
||||
|
|
|
@ -137,7 +137,7 @@ test "show follow page with error when user can not be fetched by `acct` link",
|
|||
|> html_response(200)
|
||||
|
||||
assert response =~ "Error fetching user"
|
||||
end) =~ "Object has been deleted"
|
||||
end) =~ ":not_found"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue