Compare commits
5 Commits
feature/sa
...
fix/user-d
Author | SHA1 | Date | |
---|---|---|---|
|
4733653c2a | ||
|
90bf82cf45 | ||
|
0714f1c440 | ||
|
14c8912221 | ||
|
cc0756ec56 |
@ -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>
|
||||
|
@ -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}")
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user