Compare commits
1 Commits
feature/sa
...
delete-cha
Author | SHA1 | Date | |
---|---|---|---|
|
c18a9004fd |
@ -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.
|
||||
- Delete chats when deleting user.
|
||||
|
||||
<details>
|
||||
<summary>API Changes</summary>
|
||||
|
@ -8,7 +8,6 @@ defmodule Pleroma.Chat do
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
|
||||
alias Pleroma.Chat
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
|
||||
@ -89,9 +88,16 @@ defmodule Pleroma.Chat do
|
||||
|
||||
@spec for_user_query(FlakeId.Ecto.CompatType.t()) :: Ecto.Query.t()
|
||||
def for_user_query(user_id) do
|
||||
from(c in Chat,
|
||||
from(c in __MODULE__,
|
||||
where: c.user_id == ^user_id,
|
||||
order_by: [desc: c.updated_at]
|
||||
)
|
||||
end
|
||||
|
||||
def delete_all_by_user(%User{id: user_id, ap_id: ap_id}) do
|
||||
__MODULE__
|
||||
|> where(user_id: ^user_id)
|
||||
|> or_where(recipient: ^ap_id)
|
||||
|> Repo.delete_all()
|
||||
end
|
||||
end
|
||||
|
@ -1763,6 +1763,7 @@ defmodule Pleroma.User do
|
||||
end)
|
||||
|
||||
delete_user_activities(user)
|
||||
Pleroma.Chat.delete_all_by_user(user)
|
||||
delete_notifications_from_user_activities(user)
|
||||
|
||||
delete_outgoing_pending_follow_requests(user)
|
||||
|
@ -9,6 +9,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
|
||||
alias Pleroma.Chat
|
||||
alias Pleroma.HTML
|
||||
alias Pleroma.ModerationLog
|
||||
alias Pleroma.Repo
|
||||
@ -108,11 +109,17 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "test"})
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, follower)
|
||||
{:ok, _, _, _} = CommonAPI.follow(follower, user)
|
||||
user = Repo.get(User, user.id)
|
||||
|
||||
{:ok, _create} = CommonAPI.post_chat_message(user, follower, "sup")
|
||||
|
||||
user = refresh_record(user)
|
||||
assert user.note_count == 1
|
||||
assert user.follower_count == 1
|
||||
assert user.following_count == 1
|
||||
assert user.is_active
|
||||
assert %Chat{} = chat = Chat.get(user.id, follower.ap_id)
|
||||
|
||||
assert [%Chat.MessageReference{}] = Chat.MessageReference.for_chat_query(chat) |> Repo.all()
|
||||
|
||||
with_mock Pleroma.Web.Federator,
|
||||
publish: fn _ -> nil end,
|
||||
@ -143,7 +150,9 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
|
||||
assert user.following_count == 0
|
||||
assert user.bio == ""
|
||||
assert user.name == nil
|
||||
|
||||
assert [] == Chat.MessageReference.for_chat_query(chat) |> Repo.all()
|
||||
assert Chat.get(user.id, follower.ap_id) == nil
|
||||
assert Chat.get(follower.id, user.ap_id) == nil
|
||||
assert called(Pleroma.Web.Federator.publish(:_))
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user