Compare commits

...

5 Commits

Author SHA1 Message Date
Mark Felder
4733653c2a Document user deletion changes.
Looks to be more reliable so far, hopefully that holds true.
2021-02-23 11:07:39 -06:00
Mark Felder
90bf82cf45 Fix pleroma.user rm mix task test
This is not the place to be validating deletes are federated
2021-02-23 11:05:41 -06:00
Mark Felder
0714f1c440 Pleroma user.rm mix task should also call User.delete/1 2021-02-23 10:59:02 -06:00
Mark Felder
14c8912221 First step for deleting a user should be to fire off a job to deactivate the user so they can't make more posts or log in 2021-02-23 10:29:08 -06:00
Mark Felder
cc0756ec56 Deleting a user from AdminAPI should use User.delete/1 2021-02-23 10:28:54 -06:00
5 changed files with 10 additions and 20 deletions

View File

@ -86,6 +86,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Removed duplicate jobs to purge expired activities
- File extensions of some attachments were incorrectly changed. This feature has been disabled for now.
- Mix task pleroma.instance creates missing parent directories if the configuration or SQL output paths are changed.
- Improved reliability of user account deletion and cleanup
<details>
<summary>API Changes</summary>

View File

@ -8,8 +8,6 @@ defmodule Mix.Tasks.Pleroma.User do
alias Ecto.Changeset
alias Pleroma.User
alias Pleroma.UserInviteToken
alias Pleroma.Web.ActivityPub.Builder
alias Pleroma.Web.ActivityPub.Pipeline
@shortdoc "Manages Pleroma users"
@moduledoc File.read!("docs/administration/CLI_tasks/user.md")
@ -98,9 +96,8 @@ defmodule Mix.Tasks.Pleroma.User do
def run(["rm", nickname]) do
start_pleroma()
with %User{local: true} = user <- User.get_cached_by_nickname(nickname),
{:ok, delete_data, _} <- Builder.delete(user, user.ap_id),
{:ok, _delete, _} <- Pipeline.common_pipeline(delete_data, local: true) do
with %User{local: true} = user <- User.get_cached_by_nickname(nickname) do
User.delete(user)
shell_info("User #{nickname} deleted.")
else
_ -> shell_error("No local user #{nickname}")

View File

@ -10,8 +10,6 @@ defmodule Pleroma.Web.AdminAPI.UserController do
alias Pleroma.ModerationLog
alias Pleroma.User
alias Pleroma.Web.ActivityPub.Builder
alias Pleroma.Web.ActivityPub.Pipeline
alias Pleroma.Web.AdminAPI
alias Pleroma.Web.AdminAPI.AccountView
alias Pleroma.Web.AdminAPI.Search
@ -53,10 +51,7 @@ defmodule Pleroma.Web.AdminAPI.UserController do
def delete(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames}) do
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
Enum.each(users, fn user ->
{:ok, delete_data, _} = Builder.delete(admin, user.ap_id)
Pipeline.common_pipeline(delete_data, local: true)
end)
Enum.each(users, &User.delete(&1))
ModerationLog.insert_log(%{
actor: admin,

View File

@ -16,6 +16,7 @@ defmodule Pleroma.Workers.BackgroundWorker do
def perform(%Job{args: %{"op" => "delete_user", "user_id" => user_id}}) do
user = User.get_cached_by_id(user_id)
User.set_activation_async(user, false)
User.perform(:delete, user)
end

View File

@ -95,17 +95,13 @@ defmodule Mix.Tasks.Pleroma.UserTest do
clear_config([:instance, :federating], true)
user = insert(:user)
with_mock Pleroma.Web.Federator,
publish: fn _ -> nil end do
Mix.Tasks.Pleroma.User.run(["rm", user.nickname])
ObanHelpers.perform_all()
Mix.Tasks.Pleroma.User.run(["rm", user.nickname])
assert_received {:mix_shell, :info, [message]}
assert message =~ " deleted"
assert %{is_active: false} = User.get_by_nickname(user.nickname)
assert [{:ok, job_result}] = ObanHelpers.perform_all()
assert called(Pleroma.Web.Federator.publish(:_))
end
assert_received {:mix_shell, :info, [message]}
assert message =~ " deleted"
assert %{is_active: false} = User.get_by_nickname(user.nickname)
end
test "a remote user's create activity is deleted when the object has been pruned" do