Exclude persons from being followed

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-01-22 19:44:37 +01:00
parent e6da458b49
commit a4545bcf67
4 changed files with 31 additions and 11 deletions

View File

@@ -338,7 +338,7 @@ defmodule Mobilizon.Federation.ActivityPub do
:ok <- maybe_federate(activity) do
{:ok, activity, follower}
else
{:error, err, msg} when err in [:already_following, :suspended] ->
{:error, err, msg} when err in [:already_following, :suspended, :no_person] ->
{:error, msg}
{:different_actors, _} ->

View File

@@ -131,7 +131,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Actors do
end
end
def follow(%Actor{} = follower_actor, %Actor{} = followed, _local, additional) do
def follow(%Actor{} = follower_actor, %Actor{type: type} = followed, _local, additional)
when type != :Person do
with {:ok, %Follower{} = follower} <-
Mobilizon.Actors.follow(followed, follower_actor, additional["activity_id"], false),
:ok <- FollowMailer.send_notification_to_admins(follower),
@@ -140,6 +141,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Actors do
end
end
def follow(_, _, _, _), do: {:error, :no_person, "Only group and instances can be followed"}
defp prepare_args_for_actor(args) do
args
|> maybe_sanitize_username()