})
end
+ def purge(%User{} = user) do
+ user
+ |> purge_user_changeset()
+ |> update_and_set_cache()
+ end
+
def delete(users) when is_list(users) do
for user <- users, do: delete(user)
end
Repo.delete(user)
end
- defp delete_or_deactivate(%User{local: false} = user), do: delete_and_invalidate_cache(user)
+ defp delete_or_purge(%User{local: false} = user), do: purge(user)
- defp delete_or_deactivate(%User{local: true} = user) do
+ defp delete_or_purge(%User{local: true} = user) do
status = account_status(user)
case status do
delete_and_invalidate_cache(user)
_ ->
- user
- |> purge_user_changeset()
- |> update_and_set_cache()
+ purge(user)
end
end
delete_outgoing_pending_follow_requests(user)
- delete_or_deactivate(user)
+ delete_or_purge(user)
end
def perform(:set_activation_async, user, status), do: set_activation(user, status)
} = user
end
+ test "delete/1 purges a remote user" do
+ user =
+ insert(:user, %{
+ name: "qqqqqqq",
+ avatar: %{"a" => "b"},
+ banner: %{"a" => "b"},
+ local: false
+ })
+
+ {:ok, job} = User.delete(user)
+ {:ok, _} = ObanHelpers.perform(job)
+ user = User.get_by_id(user.id)
+
+ assert user.name == nil
+ assert user.avatar == %{}
+ assert user.banner == %{}
+ end
+
test "get_public_key_for_ap_id fetches a user that's not in the db" do
assert {:ok, _key} = User.get_public_key_for_ap_id("http://mastodon.example.org/users/admin")
end