diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/chat.ex | 10 | ||||
-rw-r--r-- | lib/pleroma/user.ex | 1 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/pleroma/chat.ex b/lib/pleroma/chat.ex index bacff24b5..a1ccc4a00 100644 --- a/lib/pleroma/chat.ex +++ b/lib/pleroma/chat.ex @@ -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 diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 51f5bc8ea..73895afe8 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -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) |