forked from potsda.mn/mobilizon
Improve AP error handling
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
3163c22c4f
commit
4fd6ecf53d
|
@ -101,6 +101,10 @@ defmodule Mobilizon.Federation.ActivityPub do
|
||||||
{:existing, entity} ->
|
{:existing, entity} ->
|
||||||
handle_existing_entity(url, entity, options)
|
handle_existing_entity(url, entity, options)
|
||||||
|
|
||||||
|
{:error, e} ->
|
||||||
|
Logger.warn("Something failed while fetching url #{inspect(e)}")
|
||||||
|
{:error, e}
|
||||||
|
|
||||||
e ->
|
e ->
|
||||||
Logger.warn("Something failed while fetching url #{inspect(e)}")
|
Logger.warn("Something failed while fetching url #{inspect(e)}")
|
||||||
{:error, e}
|
{:error, e}
|
||||||
|
|
|
@ -48,7 +48,8 @@ defmodule Mobilizon.Federation.ActivityPub.Actor do
|
||||||
@doc """
|
@doc """
|
||||||
Create an actor locally by its URL (AP ID)
|
Create an actor locally by its URL (AP ID)
|
||||||
"""
|
"""
|
||||||
@spec make_actor_from_url(String.t(), boolean()) :: {:ok, %Actor{}} | {:error, any()}
|
@spec make_actor_from_url(String.t(), boolean()) ::
|
||||||
|
{:ok, %Actor{}} | {:error, :actor_deleted} | {:error, :http_error} | {:error, any()}
|
||||||
def make_actor_from_url(url, preload \\ false) do
|
def make_actor_from_url(url, preload \\ false) do
|
||||||
if are_same_origin?(url, Endpoint.url()) do
|
if are_same_origin?(url, Endpoint.url()) do
|
||||||
{:error, "Can't make a local actor from URL"}
|
{:error, "Can't make a local actor from URL"}
|
||||||
|
@ -62,6 +63,9 @@ defmodule Mobilizon.Federation.ActivityPub.Actor do
|
||||||
Logger.info("Actor was deleted")
|
Logger.info("Actor was deleted")
|
||||||
{:error, :actor_deleted}
|
{:error, :actor_deleted}
|
||||||
|
|
||||||
|
{:error, :http_error} ->
|
||||||
|
{:error, :http_error}
|
||||||
|
|
||||||
{:error, e} ->
|
{:error, e} ->
|
||||||
Logger.warn("Failed to make actor from url")
|
Logger.warn("Failed to make actor from url")
|
||||||
{:error, e}
|
{:error, e}
|
||||||
|
|
|
@ -60,6 +60,12 @@ defmodule Mobilizon.Federation.ActivityPub.Refresher do
|
||||||
:ok <- fetch_collection(events_url, on_behalf_of) do
|
:ok <- fetch_collection(events_url, on_behalf_of) do
|
||||||
:ok
|
:ok
|
||||||
else
|
else
|
||||||
|
{:error, :actor_deleted} ->
|
||||||
|
{:error, :actor_deleted}
|
||||||
|
|
||||||
|
{:error, :http_error} ->
|
||||||
|
{:error, :http_error}
|
||||||
|
|
||||||
{:error, err} ->
|
{:error, err} ->
|
||||||
Logger.error("Error while refreshing a group")
|
Logger.error("Error while refreshing a group")
|
||||||
|
|
||||||
|
@ -68,6 +74,7 @@ defmodule Mobilizon.Federation.ActivityPub.Refresher do
|
||||||
)
|
)
|
||||||
|
|
||||||
Logger.debug(inspect(err))
|
Logger.debug(inspect(err))
|
||||||
|
{:error, err}
|
||||||
|
|
||||||
err ->
|
err ->
|
||||||
Logger.error("Error while refreshing a group")
|
Logger.error("Error while refreshing a group")
|
||||||
|
@ -77,6 +84,7 @@ defmodule Mobilizon.Federation.ActivityPub.Refresher do
|
||||||
)
|
)
|
||||||
|
|
||||||
Logger.debug(inspect(err))
|
Logger.debug(inspect(err))
|
||||||
|
err
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue