forked from AkkomaGang/akkoma
add option to not unfollow on block, and option to not federate outgoing blocks
This commit is contained in:
parent
45a935f0bd
commit
2847fc8f90
2 changed files with 22 additions and 9 deletions
|
@ -57,7 +57,10 @@ config :pleroma, :instance,
|
||||||
public: true,
|
public: true,
|
||||||
quarantined_instances: []
|
quarantined_instances: []
|
||||||
|
|
||||||
config :pleroma, :activitypub, accept_blocks: true
|
config :pleroma, :activitypub,
|
||||||
|
accept_blocks: true,
|
||||||
|
unfollow_blocked: true,
|
||||||
|
outgoing_blocks: true
|
||||||
|
|
||||||
config :pleroma, :mrf_simple,
|
config :pleroma, :mrf_simple,
|
||||||
media_removal: [],
|
media_removal: [],
|
||||||
|
|
|
@ -240,18 +240,28 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def block(blocker, blocked, activity_id \\ nil, local \\ true) do
|
@ap_config Application.get_env(:pleroma, :activitypub)
|
||||||
follow_activity = fetch_latest_follow(blocker, blocked)
|
@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
|
||||||
|
|
||||||
|
with true <- unfollow_blocked do
|
||||||
|
follow_activity = fetch_latest_follow(blocker, blocked)
|
||||||
if follow_activity do
|
if follow_activity do
|
||||||
unfollow(blocker, blocked, nil, local)
|
unfollow(blocker, blocked, nil, local)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
with true <- outgoing_blocks do
|
||||||
with block_data <- make_block_data(blocker, blocked, activity_id),
|
with block_data <- make_block_data(blocker, blocked, activity_id),
|
||||||
{:ok, activity} <- insert(block_data, local),
|
{:ok, activity} <- insert(block_data, local),
|
||||||
:ok <- maybe_federate(activity) do
|
:ok <- maybe_federate(activity) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
{:ok, nil}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unblock(blocker, blocked, activity_id \\ nil, local \\ true) do
|
def unblock(blocker, blocked, activity_id \\ nil, local \\ true) do
|
||||||
|
|
Loading…
Reference in a new issue