aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-08-20 19:34:47 +0000
committerlain <lain@soykaf.club>2019-08-20 19:34:47 +0000
commit74f7f308f879b26a261db3b5c1d389cea898541c (patch)
tree0c4a2ffb3249c0f6ab9fd379aa73349a0bc9de7d
parent8340fe8fcce15a22e2bef9d5db41ad58c3c009e0 (diff)
parent5171aa5b4d6be5ba911039c52fa356da068b4b4f (diff)
downloadpleroma-74f7f308f879b26a261db3b5c1d389cea898541c.tar.gz
Merge branch 'fix/admin-api-user-deletion' into 'develop'
Fix deactivated user deletion See merge request pleroma/pleroma!1546
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex12
-rw-r--r--test/user_test.exs7
3 files changed, 14 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6a412bd7f..7b0f4f40e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -46,6 +46,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- MRF: ensure that subdomain_match calls are case-insensitive
- Reverse Proxy limiting `max_body_length` was incorrectly defined and only checked `Content-Length` headers which may not be sufficient in some circumstances
- MRF: fix use of unserializable keyword lists in describe() implementations
+- ActivityPub: Deactivated user deletion
### Added
- Conversations: Add Pleroma-specific conversation endpoints and status posting extensions. Run the `bump_all_conversations` task again to create the necessary data.
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index af9749d13..172c952d4 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -65,12 +65,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
if not is_nil(actor) do
with user <- User.get_cached_by_ap_id(actor),
false <- user.info.deactivated do
- :ok
+ true
else
- _e -> :reject
+ _e -> false
end
else
- :ok
+ true
end
end
@@ -119,10 +119,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
def increase_poll_votes_if_vote(_create_data), do: :noop
- def insert(map, local \\ true, fake \\ false) when is_map(map) do
+ def insert(map, local \\ true, fake \\ false, bypass_actor_check \\ false) when is_map(map) do
with nil <- Activity.normalize(map),
map <- lazy_put_activity_defaults(map, fake),
- :ok <- check_actor_is_active(map["actor"]),
+ true <- bypass_actor_check || check_actor_is_active(map["actor"]),
{_, true} <- {:remote_limit_error, check_remote_limit(map)},
{:ok, map} <- MRF.filter(map),
{recipients, _, _} = get_recipients(map),
@@ -411,7 +411,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
"actor" => ap_id,
"object" => %{"type" => "Person", "id" => ap_id}
},
- {:ok, activity} <- insert(data, true, true),
+ {:ok, activity} <- insert(data, true, true, true),
:ok <- maybe_federate(activity) do
{:ok, user}
end
diff --git a/test/user_test.exs b/test/user_test.exs
index 27156f036..b70133a94 100644
--- a/test/user_test.exs
+++ b/test/user_test.exs
@@ -1047,6 +1047,13 @@ defmodule Pleroma.UserTest do
refute Activity.get_by_id(activity.id)
end
+ test "it deletes deactivated user" do
+ {:ok, user} = insert(:user, info: %{deactivated: true}) |> User.set_cache()
+
+ assert {:ok, _} = User.delete(user)
+ refute User.get_by_id(user.id)
+ end
+
test "it deletes a user, all follow relationships and all activities", %{user: user} do
follower = insert(:user)
{:ok, follower} = User.follow(follower, user)