summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/config.exs7
-rw-r--r--lib/pleroma/user.ex11
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex24
3 files changed, 32 insertions, 10 deletions
diff --git a/config/config.exs b/config/config.exs
index 5e57af87b..e1a77d3e1 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -57,7 +57,12 @@ config :pleroma, :instance,
public: true,
quarantined_instances: []
-config :pleroma, :activitypub, accept_blocks: true
+config :pleroma, :activitypub,
+ accept_blocks: true,
+ unfollow_blocked: true,
+ outgoing_blocks: true
+
+config :pleroma, :user, deny_follow_blocked: true
config :pleroma, :mrf_rejectnonpublic,
allow_followersonly: false,
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index b27397e13..1fcec479f 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -168,6 +168,9 @@ defmodule Pleroma.User do
end
end
+ @user_config Application.get_env(:pleroma, :user)
+ @deny_follow_blocked Keyword.get(@user_config, :deny_follow_blocked)
+
def maybe_direct_follow(%User{} = follower, %User{info: info} = followed) do
user_info = user_info(followed)
@@ -178,7 +181,8 @@ defmodule Pleroma.User do
false
# if the users are blocking each other, we shouldn't even be here, but check for it anyway
- User.blocks?(follower, followed) == true or User.blocks?(followed, follower) == true ->
+ @deny_follow_blocked and
+ (User.blocks?(follower, followed) or User.blocks?(followed, follower)) ->
false
# if OStatus, then there is no three-way handshake to follow
@@ -205,6 +209,9 @@ defmodule Pleroma.User do
end
end
+ @user_config Application.get_env(:pleroma, :user)
+ @deny_follow_blocked Keyword.get(@user_config, :deny_follow_blocked)
+
def follow(%User{} = follower, %User{info: info} = followed) do
ap_followers = followed.follower_address
@@ -212,7 +219,7 @@ defmodule Pleroma.User do
following?(follower, followed) or info["deactivated"] ->
{:error, "Could not follow user: #{followed.nickname} is already on your list."}
- blocks?(followed, follower) ->
+ @deny_follow_blocked and blocks?(followed, follower) ->
{:error, "Could not follow user: #{followed.nickname} blocked you."}
true ->
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 267427a23..b174af7ce 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -242,17 +242,27 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
end
end
+ @ap_config Application.get_env(:pleroma, :activitypub)
+ @unfollow_blocked Keyword.get(@ap_config, :unfollow_blocked)
+ @outgoing_blocks Keyword.get(@ap_config, :outgoing_blocks)
+
def block(blocker, blocked, activity_id \\ nil, local \\ true) do
- follow_activity = fetch_latest_follow(blocker, blocked)
+ with true <- @unfollow_blocked do
+ follow_activity = fetch_latest_follow(blocker, blocked)
- if follow_activity do
- unfollow(blocker, blocked, nil, local)
+ if follow_activity do
+ unfollow(blocker, blocked, nil, local)
+ end
end
- with block_data <- make_block_data(blocker, blocked, activity_id),
- {:ok, activity} <- insert(block_data, local),
- :ok <- maybe_federate(activity) do
- {:ok, activity}
+ with true <- @outgoing_blocks do
+ with block_data <- make_block_data(blocker, blocked, activity_id),
+ {:ok, activity} <- insert(block_data, local),
+ :ok <- maybe_federate(activity) do
+ {:ok, activity}
+ end
+ else
+ _e -> {:ok, nil}
end
end