mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-26 16:02:18 +00:00
User: Don't unfollow on block when the relevant setting is set.
This commit is contained in:
parent
c3383d4fab
commit
15a8b70318
|
@ -1309,7 +1309,8 @@ defmodule Pleroma.User do
|
||||||
|
|
||||||
unsubscribe(blocked, blocker)
|
unsubscribe(blocked, blocker)
|
||||||
|
|
||||||
if following?(blocked, blocker), do: unfollow(blocked, blocker)
|
unfollowing_blocked = Config.get([:activitypub, :unfollow_blocked], true)
|
||||||
|
if unfollowing_blocked && following?(blocked, blocker), do: unfollow(blocked, blocker)
|
||||||
|
|
||||||
{:ok, blocker} = update_follower_count(blocker)
|
{:ok, blocker} = update_follower_count(blocker)
|
||||||
{:ok, blocker, _} = Participation.mark_all_as_read(blocker, blocked)
|
{:ok, blocker, _} = Participation.mark_all_as_read(blocker, blocked)
|
||||||
|
|
|
@ -6,7 +6,6 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.BlockValidator do
|
||||||
use Ecto.Schema
|
use Ecto.Schema
|
||||||
|
|
||||||
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
||||||
alias Pleroma.User
|
|
||||||
|
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
|
import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
|
||||||
|
@ -33,7 +32,6 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.BlockValidator do
|
||||||
|> validate_inclusion(:type, ["Block"])
|
|> validate_inclusion(:type, ["Block"])
|
||||||
|> validate_actor_presence()
|
|> validate_actor_presence()
|
||||||
|> validate_actor_presence(field_name: :object)
|
|> validate_actor_presence(field_name: :object)
|
||||||
|> validate_block_acceptance()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def cast_and_validate(data) do
|
def cast_and_validate(data) do
|
||||||
|
@ -41,15 +39,4 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.BlockValidator do
|
||||||
|> cast_data
|
|> cast_data
|
||||||
|> validate_data
|
|> validate_data
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_block_acceptance(cng) do
|
|
||||||
actor = get_field(cng, :actor) |> User.get_cached_by_ap_id()
|
|
||||||
|
|
||||||
if actor.local || Pleroma.Config.get([:activitypub, :unfollow_blocked], true) do
|
|
||||||
cng
|
|
||||||
else
|
|
||||||
cng
|
|
||||||
|> add_error(:actor, "Not accepting remote blocks")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -680,11 +680,5 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
|
||||||
|
|
||||||
assert {:error, _cng} = ObjectValidator.validate(block, [])
|
assert {:error, _cng} = ObjectValidator.validate(block, [])
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns an error if don't accept remote blocks", %{valid_block: valid_block} do
|
|
||||||
clear_config([:activitypub, :unfollow_blocked], false)
|
|
||||||
|
|
||||||
assert {:error, _cng} = ObjectValidator.validate(valid_block, [])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,6 +87,22 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
||||||
refute User.following?(blocked, user)
|
refute User.following?(blocked, user)
|
||||||
assert User.blocks?(user, blocked)
|
assert User.blocks?(user, blocked)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it blocks but does not unfollow if the relevant setting is set", %{
|
||||||
|
user: user,
|
||||||
|
blocked: blocked,
|
||||||
|
block: block
|
||||||
|
} do
|
||||||
|
clear_config([:activitypub, :unfollow_blocked], false)
|
||||||
|
assert User.following?(user, blocked)
|
||||||
|
assert User.following?(blocked, user)
|
||||||
|
|
||||||
|
{:ok, _, _} = SideEffects.handle(block)
|
||||||
|
|
||||||
|
refute User.following?(user, blocked)
|
||||||
|
assert User.following?(blocked, user)
|
||||||
|
assert User.blocks?(user, blocked)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "update users" do
|
describe "update users" do
|
||||||
|
|
Loading…
Reference in a new issue