conversation: remove unused users relationship
It is never used outside tests and even there its correctness and/or worth was questionable. The participations recipients or just testing over the particiaptions’ user_id seem like a better fit. In particular this was always preloaded for API responses needlessly slowing them down
This commit is contained in:
parent
263c915d40
commit
6443db213a
4 changed files with 8 additions and 9 deletions
|
|
@ -15,7 +15,6 @@ defmodule Pleroma.Conversation do
|
|||
# This is the context ap id.
|
||||
field(:ap_id, :string)
|
||||
has_many(:participations, Participation)
|
||||
has_many(:users, through: [:participations, :user])
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ defmodule Pleroma.Conversation.Participation do
|
|||
def for_user_with_pagination(user, params \\ %{}) do
|
||||
from(p in __MODULE__,
|
||||
where: p.user_id == ^user.id,
|
||||
preload: [conversation: [:users]]
|
||||
preload: [:conversation]
|
||||
)
|
||||
|> restrict_recipients(user, params)
|
||||
|> select([p], %{id: p.last_bump, entry: p})
|
||||
|
|
|
|||
|
|
@ -202,10 +202,11 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
object3 = Pleroma.Object.normalize(activity_three, fetch: false)
|
||||
|
||||
user = Repo.get(Pleroma.User, user.id)
|
||||
participation_one = Pleroma.Repo.preload(participation_one, :recipients)
|
||||
|
||||
assert participation_one.conversation.ap_id == object3.data["context"]
|
||||
assert participation_two.conversation.ap_id == object2.data["context"]
|
||||
assert participation_one.conversation.users == [user]
|
||||
assert participation_one.recipients == [user]
|
||||
|
||||
# Pagination
|
||||
assert [%{id: pid, entry: participation_one}] =
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ defmodule Pleroma.ConversationTest do
|
|||
|
||||
conversation_three =
|
||||
Conversation.get_for_ap_id(context)
|
||||
|> Repo.preload([:participations, :users])
|
||||
|> Repo.preload(participations: [:recipients])
|
||||
|
||||
assert conversation_three.id == conversation.id
|
||||
|
||||
|
|
@ -131,12 +131,11 @@ defmodule Pleroma.ConversationTest do
|
|||
tridi.id == user_id
|
||||
end)
|
||||
|
||||
assert Enum.find(conversation_three.users, fn %{id: user_id} ->
|
||||
har.id == user_id
|
||||
end)
|
||||
expected_recipients = Enum.sort([har.id, tridi.id, jafnhar.id])
|
||||
|
||||
assert Enum.find(conversation_three.users, fn %{id: user_id} ->
|
||||
tridi.id == user_id
|
||||
assert Enum.all?(conversation_three.participations, fn %{recipients: recipients} ->
|
||||
rids = Enum.map(recipients, & &1.id) |> Enum.sort()
|
||||
assert rids == expected_recipients
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue