alias Pleroma.Web.MastodonAPI.StatusView
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 =
with nil <- participation.last_activity_id do
# Conversations return all users except the current user.
users =
- participation.conversation.users
+ participation.recipients
|> Enum.reject(&(&1.id == user.id))
accounts =
as: :user
})
- recipients =
- AccountView.render("accounts.json", %{
- users: participation.recipients,
- as: :user
- })
-
%{
id: participation.id |> to_string(),
accounts: accounts,
unread: !participation.read,
- last_status: last_status,
- pleroma: %{
- recipients: recipients
- }
+ last_status: last_status
}
end
end
assert [account] = conversation.accounts
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
assert result["id"] == participation.id |> to_string
- assert recipients = result["pleroma"]["recipients"]
- recipient_ids = Enum.map(recipients, & &1["id"])
+ [participation] = Participation.for_user(user)
+ participation = Repo.preload(participation, :recipients)
- assert user.id in recipient_ids
- assert other_user.id in recipient_ids
+ assert user in participation.recipients
+ assert other_user in participation.recipients
end
end