From 2847fc8f90601c693074a514d8bd0447908bf020 Mon Sep 17 00:00:00 2001 From: squidboi Date: Fri, 8 Jun 2018 17:12:16 -0700 Subject: [PATCH] add option to not unfollow on block, and option to not federate outgoing blocks --- config/config.exs | 5 +++- lib/pleroma/web/activity_pub/activity_pub.ex | 24 ++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/config/config.exs b/config/config.exs index 3292bf29c..dc2b42a8b 100644 --- a/config/config.exs +++ b/config/config.exs @@ -57,7 +57,10 @@ 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, :mrf_simple, media_removal: [], diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 75a71da98..2f7b12f97 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -240,17 +240,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) - if follow_activity do - unfollow(blocker, blocked, nil, local) + with true <- unfollow_blocked do + follow_activity = fetch_latest_follow(blocker, blocked) + 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 + {:ok, nil} end end -- 2.45.2