summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaelwenn <contact+git.pleroma.social@hacktivis.me>2020-08-27 17:05:53 +0000
committerHaelwenn <contact+git.pleroma.social@hacktivis.me>2020-08-27 17:05:53 +0000
commit6b01a09a08e14c415ac3bd48ea28c742ee7a3dc8 (patch)
tree8614fce58baf9e72b41fb3b206308f0b2911b121
parent1c05819c9b553e65ed3dcd62b098d820e1de0aea (diff)
parent5ffd20f3b5ea9781d5b17a4a72ba7312cf04936c (diff)
Merge branch '2078-list-fixes' into 'develop'
Resolve "List timeline returns incorrectly assigned Account for replies and repeats" Closes #2070 and #2078 See merge request pleroma/pleroma!2923
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex9
-rw-r--r--test/web/mastodon_api/controllers/timeline_controller_test.exs40
3 files changed, 45 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d0eba0f79..9b616ee57 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -99,6 +99,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
</details>
### Fixed
+- Fix list pagination and other list issues.
- Support pagination in conversations API
- **Breaking**: SimplePolicy `:reject` and `:accept` allow deletions again
- Fix follower/blocks import when nicknames starts with @
diff --git a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
index 9244316ed..5272790d3 100644
--- a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
@@ -182,11 +182,10 @@ defmodule Pleroma.Web.MastodonAPI.TimelineController do
with %Pleroma.List{title: _title, following: following} <- Pleroma.List.get(id, user) do
params =
params
- |> Map.new(fn {key, value} -> {to_string(key), value} end)
- |> Map.put("type", "Create")
- |> Map.put("blocking_user", user)
- |> Map.put("user", user)
- |> Map.put("muting_user", user)
+ |> Map.put(:type, "Create")
+ |> Map.put(:blocking_user, user)
+ |> Map.put(:user, user)
+ |> Map.put(:muting_user, user)
# we must filter the following list for the user to avoid leaking statuses the user
# does not actually have permission to see (for more info, peruse security issue #270).
diff --git a/test/web/mastodon_api/controllers/timeline_controller_test.exs b/test/web/mastodon_api/controllers/timeline_controller_test.exs
index 71bac99f7..517cabcff 100644
--- a/test/web/mastodon_api/controllers/timeline_controller_test.exs
+++ b/test/web/mastodon_api/controllers/timeline_controller_test.exs
@@ -333,6 +333,46 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
describe "list" do
setup do: oauth_access(["read:lists"])
+ test "does not contain retoots", %{user: user, conn: conn} do
+ other_user = insert(:user)
+ {:ok, activity_one} = CommonAPI.post(user, %{status: "Marisa is cute."})
+ {:ok, activity_two} = CommonAPI.post(other_user, %{status: "Marisa is stupid."})
+ {:ok, _} = CommonAPI.repeat(activity_one.id, other_user)
+
+ {:ok, list} = Pleroma.List.create("name", user)
+ {:ok, list} = Pleroma.List.follow(list, other_user)
+
+ conn = get(conn, "/api/v1/timelines/list/#{list.id}")
+
+ assert [%{"id" => id}] = json_response_and_validate_schema(conn, :ok)
+
+ assert id == to_string(activity_two.id)
+ end
+
+ test "works with pagination", %{user: user, conn: conn} do
+ other_user = insert(:user)
+ {:ok, list} = Pleroma.List.create("name", user)
+ {:ok, list} = Pleroma.List.follow(list, other_user)
+
+ Enum.each(1..30, fn i ->
+ CommonAPI.post(other_user, %{status: "post number #{i}"})
+ end)
+
+ res =
+ get(conn, "/api/v1/timelines/list/#{list.id}?limit=1")
+ |> json_response_and_validate_schema(:ok)
+
+ assert length(res) == 1
+
+ [first] = res
+
+ res =
+ get(conn, "/api/v1/timelines/list/#{list.id}?max_id=#{first["id"]}&limit=30")
+ |> json_response_and_validate_schema(:ok)
+
+ assert length(res) == 29
+ end
+
test "list timeline", %{user: user, conn: conn} do
other_user = insert(:user)
{:ok, _activity_one} = CommonAPI.post(user, %{status: "Marisa is cute."})