From 93904921381300ddeefab99350cba5f551e0e2b0 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 13 May 2018 23:28:56 +0000 Subject: [PATCH 1/3] ActivityPub create: discard activities from deactivated users --- lib/pleroma/web/activity_pub/activity_pub.ex | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 491ad3705..76cda0b4c 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -16,9 +16,20 @@ def get_recipients(data) do (data["to"] || []) ++ (data["cc"] || []) end + defp check_actor_is_active(actor) do + user = User.get_cached_by_ap_id(actor) + + if user.info["deactivated"] == true do + :reject + else + :ok + end + end + def insert(map, local \\ true) when is_map(map) do with nil <- Activity.get_by_ap_id(map["id"]), map <- lazy_put_activity_defaults(map), + :ok <- check_actor_is_active(map["actor"]), {:ok, map} <- MRF.filter(map), :ok <- insert_full_object(map) do {:ok, activity} = From a6a6915aaf568dda8b784438b963e341c2fc0f29 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 13 May 2018 23:33:43 +0000 Subject: [PATCH 2/3] add mix task for deactivating a user by nickname --- lib/mix/tasks/deactivate_user.ex | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lib/mix/tasks/deactivate_user.ex diff --git a/lib/mix/tasks/deactivate_user.ex b/lib/mix/tasks/deactivate_user.ex new file mode 100644 index 000000000..96b3db6e4 --- /dev/null +++ b/lib/mix/tasks/deactivate_user.ex @@ -0,0 +1,13 @@ +defmodule Mix.Tasks.DeactivateUser do + use Mix.Task + alias Pleroma.User + + @shortdoc "Toggle deactivation status for a user" + def run([nickname]) do + Mix.Task.run("app.start") + + with user <- User.get_by_nickname(nickname) do + User.deactivate(user) + end + end +end From 13d4b6d2b5d17c10fb5a95e02ff668de8eeb15ea Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 18 May 2018 22:17:56 -0500 Subject: [PATCH 3/3] remote user deactivation: fix test failures --- lib/pleroma/web/activity_pub/activity_pub.ex | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 76cda0b4c..c026f2427 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -17,10 +17,13 @@ def get_recipients(data) do end defp check_actor_is_active(actor) do - user = User.get_cached_by_ap_id(actor) - - if user.info["deactivated"] == true do - :reject + if not is_nil(actor) do + with user <- User.get_cached_by_ap_id(actor), + nil <- user.info["deactivated"] do + :ok + else + _e -> :reject + end else :ok end