aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Strizhakov <alex.strizhakov@gmail.com>2021-01-26 14:35:31 +0300
committerAlexander Strizhakov <alex.strizhakov@gmail.com>2021-02-01 14:11:11 +0300
commitb6a72680e2a20e30fa4e9dbc3f4f60e4c51dd63f (patch)
tree8d0ee777dbaaee4af7d9e8c3827a6661351fcf3b
parentc3110c46f36c1cdfb1fb30855dfba709373548eb (diff)
downloadpleroma-b6a72680e2a20e30fa4e9dbc3f4f60e4c51dd63f.tar.gz
added only_media flag to home timeline
-rw-r--r--lib/pleroma/web/api_spec/operations/timeline_operation.ex1
-rw-r--r--test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs60
2 files changed, 61 insertions, 0 deletions
diff --git a/lib/pleroma/web/api_spec/operations/timeline_operation.ex b/lib/pleroma/web/api_spec/operations/timeline_operation.ex
index 2f44cb70d..7b2fe48a5 100644
--- a/lib/pleroma/web/api_spec/operations/timeline_operation.ex
+++ b/lib/pleroma/web/api_spec/operations/timeline_operation.ex
@@ -26,6 +26,7 @@ defmodule Pleroma.Web.ApiSpec.TimelineOperation do
parameters: [
local_param(),
remote_param(),
+ only_media_param(),
with_muted_param(),
exclude_visibilities_param(),
reply_visibility_param() | pagination_params()
diff --git a/test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs
index 30118f74e..d8cc3c9b9 100644
--- a/test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs
@@ -166,6 +166,66 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
assert resp4 == []
end
+
+ test "only_media flag", %{conn: conn, user: user} do
+ other = insert(:user)
+ {:ok, _, other} = User.follow(user, other)
+
+ without_media =
+ insert(:note_activity,
+ user: other,
+ recipients: ["https://www.w3.org/ns/activitystreams#Public", User.ap_followers(other)]
+ )
+
+ obj =
+ insert(:note, %{
+ data: %{
+ "attachment" => [
+ %{
+ "mediaType" => "image/jpeg",
+ "name" => "an_image.jpg",
+ "type" => "Document",
+ "url" => [
+ %{
+ "href" =>
+ "http://localhost:4001/media/8270697e-104f-4a54-a7c1-514bb6713f2c/some_image.jpg",
+ "mediaType" => "image/jpeg",
+ "type" => "Link"
+ }
+ ]
+ }
+ ]
+ },
+ user: other
+ })
+
+ with_media =
+ insert(:note_activity, %{
+ note: obj,
+ recipients: ["https://www.w3.org/ns/activitystreams#Public", User.ap_followers(other)],
+ user: other
+ })
+
+ resp1 =
+ conn
+ |> get("/api/v1/timelines/home")
+ |> json_response_and_validate_schema(200)
+
+ without_filter_ids = Enum.map(resp1, & &1["id"])
+
+ assert without_media.id in without_filter_ids
+ assert with_media.id in without_filter_ids
+
+ resp2 =
+ conn
+ |> get("/api/v1/timelines/home?only_media=true")
+ |> json_response_and_validate_schema(200)
+
+ only_media_ids = Enum.map(resp2, & &1["id"])
+
+ refute without_media.id in only_media_ids
+ assert with_media.id in only_media_ids
+ end
end
describe "public" do