MastodonAPI: Add pagination to private messages.
This commit is contained in:
parent
0ce5623134
commit
2cf40237ff
@ -278,9 +278,12 @@ def user_statuses(%{assigns: %{user: reading_user}} = conn, params) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def dm_timeline(%{assigns: %{user: user}} = conn, _params) do
|
def dm_timeline(%{assigns: %{user: user}} = conn, params) do
|
||||||
query =
|
query =
|
||||||
ActivityPub.fetch_activities_query([user.ap_id], %{"type" => "Create", visibility: "direct"})
|
ActivityPub.fetch_activities_query(
|
||||||
|
[user.ap_id],
|
||||||
|
Map.merge(params, %{"type" => "Create", visibility: "direct"})
|
||||||
|
)
|
||||||
|
|
||||||
activities = Repo.all(query)
|
activities = Repo.all(query)
|
||||||
|
|
||||||
|
@ -178,6 +178,32 @@ test "direct timeline", %{conn: conn} do
|
|||||||
|> get("api/v1/timelines/home")
|
|> get("api/v1/timelines/home")
|
||||||
|
|
||||||
[_s1, _s2] = json_response(res_conn, 200)
|
[_s1, _s2] = json_response(res_conn, 200)
|
||||||
|
|
||||||
|
# Test pagination
|
||||||
|
Enum.each(1..20, fn _ ->
|
||||||
|
{:ok, _} =
|
||||||
|
CommonAPI.post(user_one, %{
|
||||||
|
"status" => "Hi @#{user_two.nickname}!",
|
||||||
|
"visibility" => "direct"
|
||||||
|
})
|
||||||
|
end)
|
||||||
|
|
||||||
|
res_conn =
|
||||||
|
conn
|
||||||
|
|> assign(:user, user_two)
|
||||||
|
|> get("api/v1/timelines/direct")
|
||||||
|
|
||||||
|
statuses = json_response(res_conn, 200)
|
||||||
|
assert length(statuses) == 20
|
||||||
|
|
||||||
|
res_conn =
|
||||||
|
conn
|
||||||
|
|> assign(:user, user_two)
|
||||||
|
|> get("api/v1/timelines/direct", %{max_id: List.last(statuses)["id"]})
|
||||||
|
|
||||||
|
[status] = json_response(res_conn, 200)
|
||||||
|
|
||||||
|
assert status["url"] != direct.data["id"]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "replying to a status", %{conn: conn} do
|
test "replying to a status", %{conn: conn} do
|
||||||
|
Loading…
Reference in New Issue
Block a user