mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-27 08:16:16 +00:00
Add accounts and last_status to conversation read response
This commit is contained in:
parent
24073f829f
commit
2662bea4e0
|
@ -1617,14 +1617,30 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
||||||
with %Participation{} = participation <-
|
with %Participation{} = participation <-
|
||||||
Repo.get_by(Participation, id: participation_id, user_id: user.id),
|
Repo.get_by(Participation, id: participation_id, user_id: user.id),
|
||||||
{:ok, participation} <- Participation.mark_as_read(participation) do
|
{:ok, participation} <- Participation.mark_as_read(participation) do
|
||||||
|
participation = Repo.preload(participation, conversation: :users)
|
||||||
|
|
||||||
|
accounts =
|
||||||
|
AccountView.render("accounts.json", %{
|
||||||
|
users: participation.conversation.users,
|
||||||
|
as: :user
|
||||||
|
})
|
||||||
|
|
||||||
|
last_activity_id =
|
||||||
|
ActivityPub.fetch_latest_activity_id_for_context(participation.conversation.ap_id, %{
|
||||||
|
"user" => user,
|
||||||
|
"blocking_user" => user
|
||||||
|
})
|
||||||
|
|
||||||
|
activity = Activity.get_by_id_with_object(last_activity_id)
|
||||||
|
|
||||||
|
last_status = StatusView.render("status.json", %{activity: activity, for: user})
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> json(%{
|
|> json(%{
|
||||||
id: participation.id,
|
id: participation.id,
|
||||||
# TODO: Add this.
|
accounts: accounts,
|
||||||
accounts: [],
|
|
||||||
unread: !participation.read,
|
unread: !participation.read,
|
||||||
# TODO: Add this.
|
last_status: last_status
|
||||||
last_status: nil
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -346,6 +346,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
||||||
|> post("/api/v1/conversations/#{res_id}/read")
|
|> post("/api/v1/conversations/#{res_id}/read")
|
||||||
|
|
||||||
assert response = json_response(res_conn, 200)
|
assert response = json_response(res_conn, 200)
|
||||||
|
assert length(response["accounts"]) == 2
|
||||||
|
assert response["last_status"]["id"] == direct.id
|
||||||
assert response["unread"] == false
|
assert response["unread"] == false
|
||||||
|
|
||||||
# (vanilla) Mastodon frontend behaviour
|
# (vanilla) Mastodon frontend behaviour
|
||||||
|
|
Loading…
Reference in a new issue