add mix pleroma.user delete_activities NICKNAME task

This commit is contained in:
Egor Kislitsyn 2019-03-12 22:04:08 +07:00
parent 10248d86a2
commit d013b58e84
2 changed files with 18 additions and 2 deletions

View file

@ -304,6 +304,18 @@ defmodule Mix.Tasks.Pleroma.User do
end end
end end
def run(["delete_activities", nickname]) do
Common.start_pleroma()
with %User{local: true} = user <- User.get_by_nickname(nickname) do
User.delete_user_activities(user)
Mix.shell().info("User #{nickname} deleted.")
else
_ ->
Mix.shell().error("No local user #{nickname}")
end
end
defp set_moderator(user, value) do defp set_moderator(user, value) do
info_cng = User.Info.admin_api_update(user.info, %{is_moderator: value}) info_cng = User.Info.admin_api_update(user.info, %{is_moderator: value})

View file

@ -1083,6 +1083,12 @@ defmodule Pleroma.User do
friends friends
|> Enum.each(fn followed -> User.unfollow(user, followed) end) |> Enum.each(fn followed -> User.unfollow(user, followed) end)
delete_user_activities(user)
{:ok, user}
end
def delete_user_activities(user) do
query = from(a in Activity, where: a.actor == ^user.ap_id) query = from(a in Activity, where: a.actor == ^user.ap_id)
Repo.all(query) Repo.all(query)
@ -1096,8 +1102,6 @@ defmodule Pleroma.User do
"Doing nothing" "Doing nothing"
end end
end) end)
{:ok, user}
end end
def html_filter_policy(%User{info: %{no_rich_text: true}}) do def html_filter_policy(%User{info: %{no_rich_text: true}}) do