Conversations: Use 'recipients' for accounts in conversation view.
According to gargron, this is the intended usage.
This commit is contained in:
parent
a2b98f6d58
commit
23c46f7e72
|
@ -12,7 +12,7 @@ defmodule Pleroma.Web.MastodonAPI.ConversationView do
|
||||||
alias Pleroma.Web.MastodonAPI.StatusView
|
alias Pleroma.Web.MastodonAPI.StatusView
|
||||||
|
|
||||||
def render("participation.json", %{participation: participation, user: user}) do
|
def render("participation.json", %{participation: participation, user: user}) do
|
||||||
participation = Repo.preload(participation, conversation: :users, recipients: [])
|
participation = Repo.preload(participation, conversation: [], recipients: [])
|
||||||
|
|
||||||
last_activity_id =
|
last_activity_id =
|
||||||
with nil <- participation.last_activity_id do
|
with nil <- participation.last_activity_id do
|
||||||
|
@ -28,7 +28,7 @@ def render("participation.json", %{participation: participation, user: user}) do
|
||||||
|
|
||||||
# Conversations return all users except the current user.
|
# Conversations return all users except the current user.
|
||||||
users =
|
users =
|
||||||
participation.conversation.users
|
participation.recipients
|
||||||
|> Enum.reject(&(&1.id == user.id))
|
|> Enum.reject(&(&1.id == user.id))
|
||||||
|
|
||||||
accounts =
|
accounts =
|
||||||
|
@ -37,20 +37,11 @@ def render("participation.json", %{participation: participation, user: user}) do
|
||||||
as: :user
|
as: :user
|
||||||
})
|
})
|
||||||
|
|
||||||
recipients =
|
|
||||||
AccountView.render("accounts.json", %{
|
|
||||||
users: participation.recipients,
|
|
||||||
as: :user
|
|
||||||
})
|
|
||||||
|
|
||||||
%{
|
%{
|
||||||
id: participation.id |> to_string(),
|
id: participation.id |> to_string(),
|
||||||
accounts: accounts,
|
accounts: accounts,
|
||||||
unread: !participation.read,
|
unread: !participation.read,
|
||||||
last_status: last_status,
|
last_status: last_status
|
||||||
pleroma: %{
|
|
||||||
recipients: recipients
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,11 +30,5 @@ test "represents a Mastodon Conversation entity" do
|
||||||
|
|
||||||
assert [account] = conversation.accounts
|
assert [account] = conversation.accounts
|
||||||
assert account.id == other_user.id
|
assert account.id == other_user.id
|
||||||
|
|
||||||
assert recipients = conversation.pleroma.recipients
|
|
||||||
recipient_ids = recipients |> Enum.map(& &1.id)
|
|
||||||
|
|
||||||
assert user.id in recipient_ids
|
|
||||||
assert other_user.id in recipient_ids
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -67,10 +67,10 @@ test "PATCH /api/v1/pleroma/conversations/:id", %{conn: conn} do
|
||||||
|
|
||||||
assert result["id"] == participation.id |> to_string
|
assert result["id"] == participation.id |> to_string
|
||||||
|
|
||||||
assert recipients = result["pleroma"]["recipients"]
|
[participation] = Participation.for_user(user)
|
||||||
recipient_ids = Enum.map(recipients, & &1["id"])
|
participation = Repo.preload(participation, :recipients)
|
||||||
|
|
||||||
assert user.id in recipient_ids
|
assert user in participation.recipients
|
||||||
assert other_user.id in recipient_ids
|
assert other_user in participation.recipients
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue