Remove duplicate @doc blocs

Elixir 11 notifies this a lot

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-11-06 15:43:38 +01:00
parent 7c11807c14
commit 44559a71ee
16 changed files with 67 additions and 113 deletions

View File

@@ -405,7 +405,7 @@ defmodule Mobilizon.Federation.ActivityPub do
def leave(object, actor, local \\ true, additional \\ %{})
@doc """
Leave an event
Leave an event or a group
"""
def leave(
%Event{id: event_id, url: event_url} = _event,
@@ -438,9 +438,6 @@ defmodule Mobilizon.Federation.ActivityPub do
end
end
@doc """
Leave a group
"""
def leave(
%Actor{type: :Group, id: group_id, url: group_url, members_url: group_members_url},
%Actor{id: actor_id, url: actor_url},

View File

@@ -15,11 +15,23 @@ defmodule Mobilizon.Federation.ActivityPub.Audience do
@ap_public "https://www.w3.org/ns/activitystreams#Public"
@doc """
Determines the full audience based on mentions for a public audience
Determines the full audience based on mentions for an audience
Audience is:
For a public audience:
* `to` : the mentioned actors, the eventual actor we're replying to and the public
* `cc` : the actor's followers
For an unlisted audience:
* `to` : the mentioned actors, actor's followers and the eventual actor we're replying to
* `cc` : public
For a private audience:
* `to` : the mentioned actors, actor's followers and the eventual actor we're replying to
* `cc` : none
For a direct audience:
* `to` : the mentioned actors and the eventual actor we're replying to
* `cc` : none
"""
@spec get_to_and_cc(Actor.t(), list(), String.t()) :: {list(), list()}
def get_to_and_cc(%Actor{} = actor, mentions, :public) do
@@ -29,13 +41,6 @@ defmodule Mobilizon.Federation.ActivityPub.Audience do
{to, cc}
end
@doc """
Determines the full audience based on mentions based on a unlisted audience
Audience is:
* `to` : the mentioned actors, actor's followers and the eventual actor we're replying to
* `cc` : public
"""
@spec get_to_and_cc(Actor.t(), list(), String.t()) :: {list(), list()}
def get_to_and_cc(%Actor{} = actor, mentions, :unlisted) do
to = [actor.followers_url | mentions]
@@ -44,26 +49,12 @@ defmodule Mobilizon.Federation.ActivityPub.Audience do
{to, cc}
end
@doc """
Determines the full audience based on mentions based on a private audience
Audience is:
* `to` : the mentioned actors, actor's followers and the eventual actor we're replying to
* `cc` : none
"""
@spec get_to_and_cc(Actor.t(), list(), String.t()) :: {list(), list()}
def get_to_and_cc(%Actor{} = actor, mentions, :private) do
{to, cc} = get_to_and_cc(actor, mentions, :direct)
{[actor.followers_url | to], cc}
end
@doc """
Determines the full audience based on mentions based on a direct audience
Audience is:
* `to` : the mentioned actors and the eventual actor we're replying to
* `cc` : none
"""
@spec get_to_and_cc(Actor.t(), list(), String.t()) :: {list(), list()}
def get_to_and_cc(_actor, mentions, :direct) do
{mentions, []}

View File

@@ -26,6 +26,9 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
require Logger
@doc """
Handle incoming activities
"""
def handle_incoming(%{"id" => nil}), do: :error
def handle_incoming(%{"id" => ""}), do: :error
@@ -47,18 +50,16 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
end
end
@doc """
Handles a `Create` activity for `Note` (comments) objects
The following actions are performed
* Fetch the author of the activity
* Convert the ActivityStream data to the comment model format (it also finds and inserts tags)
* Get (by it's URL) or create the comment with this data
* Insert eventual mentions in the database
* Convert the comment back in ActivityStreams data
* Wrap this data back into a `Create` activity
* Return the activity and the comment object
"""
# Handles a `Create` activity for `Note` (comments) objects
#
# The following actions are performed
# * Fetch the author of the activity
# * Convert the ActivityStream data to the comment model format (it also finds and inserts tags)
# * Get (by it's URL) or create the comment with this data
# * Insert eventual mentions in the database
# * Convert the comment back in ActivityStreams data
# * Wrap this data back into a `Create` activity
# * Return the activity and the comment object
def handle_incoming(%{"type" => "Create", "object" => %{"type" => "Note"} = object}) do
Logger.info("Handle incoming to create notes")
@@ -88,18 +89,16 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
end
end
@doc """
Handles a `Create` activity for `Event` objects
The following actions are performed
* Fetch the author of the activity
* Convert the ActivityStream data to the event model format (it also finds and inserts tags)
* Get (by it's URL) or create the event with this data
* Insert eventual mentions in the database
* Convert the event back in ActivityStreams data
* Wrap this data back into a `Create` activity
* Return the activity and the event object
"""
# Handles a `Create` activity for `Event` objects
#
# The following actions are performed
# * Fetch the author of the activity
# * Convert the ActivityStream data to the event model format (it also finds and inserts tags)
# * Get (by it's URL) or create the event with this data
# * Insert eventual mentions in the database
# * Convert the event back in ActivityStreams data
# * Wrap this data back into a `Create` activity
# * Return the activity and the event object
def handle_incoming(%{"type" => "Create", "object" => %{"type" => "Event"} = object}) do
Logger.info("Handle incoming to create event")
@@ -743,10 +742,8 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
{:error, :not_supported}
end
@doc """
Handle incoming `Accept` activities wrapping a `Follow` activity
"""
def do_handle_incoming_accept_following(follow_object, %Actor{} = actor) do
# Handle incoming `Accept` activities wrapping a `Follow` activity
defp do_handle_incoming_accept_following(follow_object, %Actor{} = actor) do
with {:follow,
{:ok, %Follower{approved: false, target_actor: followed, actor: follower} = follow}} <-
{:follow, get_follow(follow_object)},
@@ -781,10 +778,8 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
end
end
@doc """
Handle incoming `Reject` activities wrapping a `Follow` activity
"""
def do_handle_incoming_reject_following(follow_object, %Actor{} = actor) do
# Handle incoming `Reject` activities wrapping a `Follow` activity
defp do_handle_incoming_reject_following(follow_object, %Actor{} = actor) do
with {:follow, {:ok, %Follower{target_actor: followed} = follow}} <-
{:follow, get_follow(follow_object)},
{:same_actor, true} <- {:same_actor, actor.id == followed.id},

View File

@@ -330,6 +330,12 @@ defmodule Mobilizon.Federation.ActivityPub.Utils do
end
@doc """
Return AS Link data from
* a `Plug.Upload` struct, stored an returned
* a `Picture`, directly returned
* a map containing picture information, stored, saved and returned
Save picture data from %Plug.Upload{} and return AS Link data.
"""
def make_picture_data(%Plug.Upload{} = picture, opts) do
@@ -342,16 +348,10 @@ defmodule Mobilizon.Federation.ActivityPub.Utils do
end
end
@doc """
Convert a picture model into an AS Link representation.
"""
def make_picture_data(%Picture{} = picture) do
Converter.Picture.model_to_as(picture)
end
@doc """
Save picture data from raw data and return AS Link data.
"""
def make_picture_data(picture) when is_map(picture) do
with {:ok, %{"url" => [%{"href" => url, "mediaType" => content_type}], "size" => size}} <-
Mobilizon.Web.Upload.store(picture.file),

View File

@@ -88,6 +88,8 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Comment do
@doc """
Make an AS comment object from an existing `Comment` structure.
A "soft-deleted" comment is a tombstone
"""
@impl Converter
@spec model_to_as(CommentModel.t()) :: map
@@ -127,9 +129,6 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Comment do
end
end
@doc """
A "soft-deleted" comment is a tombstone
"""
@impl Converter
@spec model_to_as(CommentModel.t()) :: map
def model_to_as(%CommentModel{} = comment) do