Rework user deletion
This commit is contained in:
parent
0f07bcc9e3
commit
2c63c67512
5 changed files with 99 additions and 38 deletions
|
|
@ -89,8 +89,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ " deleted"
|
||||
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
assert user.info.deactivated
|
||||
refute User.get_by_nickname(user.nickname)
|
||||
end
|
||||
|
||||
test "no user to delete" do
|
||||
|
|
|
|||
|
|
@ -920,42 +920,44 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "2hu"})
|
||||
|
||||
Ecto.Adapters.SQL.Sandbox.unboxed_run(Repo, fn ->
|
||||
{:ok, _} = User.delete_user_activities(user)
|
||||
# TODO: Remove favorites, repeats, delete activities.
|
||||
refute Activity.get_by_id(activity.id)
|
||||
end)
|
||||
{:ok, _} = User.delete_user_activities(user)
|
||||
|
||||
# TODO: Remove favorites, repeats, delete activities.
|
||||
refute Activity.get_by_id(activity.id)
|
||||
end
|
||||
|
||||
test ".delete deactivates a user, all follow relationships and all create activities" do
|
||||
test ".delete deactivates a user, all follow relationships and all activities" do
|
||||
user = insert(:user)
|
||||
followed = insert(:user)
|
||||
follower = insert(:user)
|
||||
|
||||
{:ok, user} = User.follow(user, followed)
|
||||
{:ok, follower} = User.follow(follower, user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "2hu"})
|
||||
{:ok, activity_two} = CommonAPI.post(follower, %{"status" => "3hu"})
|
||||
|
||||
{:ok, _, _} = CommonAPI.favorite(activity_two.id, user)
|
||||
{:ok, _, _} = CommonAPI.favorite(activity.id, follower)
|
||||
{:ok, _, _} = CommonAPI.repeat(activity.id, follower)
|
||||
{:ok, like, _} = CommonAPI.favorite(activity_two.id, user)
|
||||
{:ok, like_two, _} = CommonAPI.favorite(activity.id, follower)
|
||||
{:ok, repeat, _} = CommonAPI.repeat(activity_two.id, user)
|
||||
|
||||
{:ok, _} = User.delete(user)
|
||||
|
||||
followed = User.get_cached_by_id(followed.id)
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
assert user.info.deactivated
|
||||
refute User.following?(follower, user)
|
||||
refute User.get_by_id(user.id)
|
||||
|
||||
refute User.following?(user, followed)
|
||||
refute User.following?(followed, follower)
|
||||
user_activities =
|
||||
user.ap_id
|
||||
|> Activity.query_by_actor()
|
||||
|> Repo.all()
|
||||
|> Enum.map(fn act -> act.data["type"] end)
|
||||
|
||||
# TODO: Remove favorites, repeats, delete activities.
|
||||
assert Enum.all?(user_activities, fn act -> act in ~w(Delete Undo) end)
|
||||
|
||||
refute Activity.get_by_id(activity.id)
|
||||
refute Activity.get_by_id(like.id)
|
||||
refute Activity.get_by_id(like_two.id)
|
||||
refute Activity.get_by_id(repeat.id)
|
||||
end
|
||||
|
||||
test "get_public_key_for_ap_id fetches a user that's not in the db" do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue