Refactor the ActivityPub module
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -14,7 +14,7 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Flag do
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Reports.Report
|
||||
|
||||
alias Mobilizon.Federation.ActivityPub
|
||||
alias Mobilizon.Federation.ActivityPub.Actor, as: ActivityPubActor
|
||||
alias Mobilizon.Federation.ActivityPub.Relay
|
||||
alias Mobilizon.Federation.ActivityStream.{Converter, Convertible}
|
||||
|
||||
@@ -65,10 +65,11 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Flag do
|
||||
|
||||
@spec as_to_model(map) :: map
|
||||
def as_to_model(%{"object" => objects} = object) do
|
||||
with {:ok, %Actor{} = reporter} <- ActivityPub.get_or_fetch_actor_by_url(object["actor"]),
|
||||
with {:ok, %Actor{} = reporter} <-
|
||||
ActivityPubActor.get_or_fetch_actor_by_url(object["actor"]),
|
||||
%Actor{} = reported <-
|
||||
Enum.reduce_while(objects, nil, fn url, _ ->
|
||||
case ActivityPub.get_or_fetch_actor_by_url(url) do
|
||||
case ActivityPubActor.get_or_fetch_actor_by_url(url) do
|
||||
{:ok, %Actor{} = actor} ->
|
||||
{:halt, actor}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user