Fix various issues reported by Dializer

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-01-06 18:48:48 +01:00
parent 1319985047
commit 26b1ea401a
12 changed files with 27 additions and 25 deletions

View File

@@ -108,15 +108,15 @@ defmodule Mobilizon.Federation.ActivityPub.Actor do
@doc """
Create an actor inside our database from username, using WebFinger to find out its AP ID and then fetch it
"""
@spec make_actor_from_nickname(nickname :: String.t(), preload :: boolean) ::
@spec make_actor_from_nickname(nickname :: String.t(), options :: Keyword.t()) ::
{:ok, Actor.t()} | {:error, make_actor_errors | WebFinger.finger_errors()}
def make_actor_from_nickname(nickname, preload \\ false) do
def make_actor_from_nickname(nickname, options \\ []) do
Logger.debug("Fingering actor from nickname #{nickname}")
case WebFinger.finger(nickname) do
{:ok, url} when is_binary(url) ->
Logger.debug("Matched #{nickname} to URL #{url}, now making actor")
make_actor_from_url(url, preload: preload)
make_actor_from_url(url, options)
{:error, e} ->
{:error, e}

View File

@@ -20,7 +20,7 @@ defmodule Mobilizon.Federation.ActivityPub.Audience do
@doc """
Get audience for an entity
"""
@spec get_audience(Entity.t()) :: audience()
@spec get_audience(Entity.t() | Participant.t()) :: audience()
def get_audience(%Event{} = event) do
extract_actors_from_event(event)
end

View File

@@ -190,7 +190,7 @@ defmodule Mobilizon.Federation.ActivityPub.Refresher do
# If we're handling an activity
@spec handling_element(map()) :: {:ok, any, struct} | :error
@spec handling_element(String.t()) :: {:ok, struct} | {:error, any()}
@spec handling_element(String.t()) :: {:ok, struct} | {:ok, atom, struct} | {:error, any()}
defp handling_element(%{"type" => activity_type} = data)
when activity_type in ["Create", "Update", "Delete"] do
object = get_in(data, ["object"])