end
end
- def dm_timeline(%{assigns: %{user: user}} = conn, _params) do
+ def dm_timeline(%{assigns: %{user: user}} = conn, params) do
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)
|> get("api/v1/timelines/home")
[_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
test "replying to a status", %{conn: conn} do