Merge branch 'fix/support-conversations-pagination' into 'develop'
Support pagination in conversations See merge request pleroma/pleroma!2329
This commit is contained in:
commit
fc4f92c5de
|
@ -18,6 +18,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Mastodon API: Added `/api/v1/notifications/:id/dismiss` endpoint.
|
- Mastodon API: Added `/api/v1/notifications/:id/dismiss` endpoint.
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Support pagination in conversations API
|
||||||
|
|
||||||
## [2.0.2] - 2020-04-08
|
## [2.0.2] - 2020-04-08
|
||||||
### Added
|
### Added
|
||||||
- Support for Funkwhale's `Audio` activity
|
- Support for Funkwhale's `Audio` activity
|
||||||
|
|
|
@ -721,7 +721,7 @@ def move(%User{} = origin, %User{} = target, local \\ true) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp fetch_activities_for_context_query(context, opts) do
|
def fetch_activities_for_context_query(context, opts) do
|
||||||
public = [Constants.as_public()]
|
public = [Constants.as_public()]
|
||||||
|
|
||||||
recipients =
|
recipients =
|
||||||
|
|
|
@ -110,12 +110,11 @@ def conversation(%{assigns: %{user: user}} = conn, %{"id" => participation_id})
|
||||||
end
|
end
|
||||||
|
|
||||||
def conversation_statuses(
|
def conversation_statuses(
|
||||||
%{assigns: %{user: user}} = conn,
|
%{assigns: %{user: %{id: user_id} = user}} = conn,
|
||||||
%{"id" => participation_id} = params
|
%{"id" => participation_id} = params
|
||||||
) do
|
) do
|
||||||
with %Participation{} = participation <-
|
with %Participation{user_id: ^user_id} = participation <-
|
||||||
Participation.get(participation_id, preload: [:conversation]),
|
Participation.get(participation_id, preload: [:conversation]) do
|
||||||
true <- user.id == participation.user_id do
|
|
||||||
params =
|
params =
|
||||||
params
|
params
|
||||||
|> Map.put("blocking_user", user)
|
|> Map.put("blocking_user", user)
|
||||||
|
@ -124,7 +123,8 @@ def conversation_statuses(
|
||||||
|
|
||||||
activities =
|
activities =
|
||||||
participation.conversation.ap_id
|
participation.conversation.ap_id
|
||||||
|> ActivityPub.fetch_activities_for_context(params)
|
|> ActivityPub.fetch_activities_for_context_query(params)
|
||||||
|
|> Pleroma.Pagination.fetch_paginated(Map.put(params, "total", false))
|
||||||
|> Enum.reverse()
|
|> Enum.reverse()
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|
|
|
@ -169,6 +169,23 @@ test "/api/v1/pleroma/conversations/:id/statuses" do
|
||||||
id_one = activity.id
|
id_one = activity.id
|
||||||
id_two = activity_two.id
|
id_two = activity_two.id
|
||||||
assert [%{"id" => ^id_one}, %{"id" => ^id_two}] = result
|
assert [%{"id" => ^id_one}, %{"id" => ^id_two}] = result
|
||||||
|
|
||||||
|
{:ok, %{id: id_three}} =
|
||||||
|
CommonAPI.post(other_user, %{
|
||||||
|
"status" => "Bye!",
|
||||||
|
"in_reply_to_status_id" => activity.id,
|
||||||
|
"in_reply_to_conversation_id" => participation.id
|
||||||
|
})
|
||||||
|
|
||||||
|
assert [%{"id" => ^id_two}, %{"id" => ^id_three}] =
|
||||||
|
conn
|
||||||
|
|> get("/api/v1/pleroma/conversations/#{participation.id}/statuses?limit=2")
|
||||||
|
|> json_response(:ok)
|
||||||
|
|
||||||
|
assert [%{"id" => ^id_three}] =
|
||||||
|
conn
|
||||||
|
|> get("/api/v1/pleroma/conversations/#{participation.id}/statuses?min_id=#{id_two}")
|
||||||
|
|> json_response(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "PATCH /api/v1/pleroma/conversations/:id" do
|
test "PATCH /api/v1/pleroma/conversations/:id" do
|
||||||
|
|
Loading…
Reference in a new issue