logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/
commit: 73b446bb07643ae9c98d1bb547f6ecbc3f2883f0
parent 4288e2780b87e31f7055795332db4b99ea640f3e
Author: Lain Soykaf <lain@lain.com>
Date:   Wed, 24 Dec 2025 12:20:11 +0400

ActivityPubControllerTest, UserViewTest: Add failing tests for reply collection related issues.

Diffstat:

Mtest/pleroma/web/activity_pub/activity_pub_controller_test.exs57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtest/pleroma/web/activity_pub/views/user_view_test.exs12++++++++++++
2 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs @@ -462,6 +462,44 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do ) end + test "first page id includes `?page=true`", %{conn: conn} do + user = insert(:user) + note = insert(:note_activity) + note = Pleroma.Activity.get_by_id_with_object(note.id) + uuid = String.split(note.object.data["id"], "/") |> List.last() + + {:ok, _} = + CommonAPI.post(user, %{status: "reply1", in_reply_to_status_id: note.id}) + + conn = + conn + |> put_req_header("accept", "application/activity+json") + |> get("/objects/#{uuid}/replies") + + %{"id" => collection_id, "first" => %{"id" => page_id, "partOf" => part_of}} = + json_response(conn, 200) + + assert part_of == collection_id + assert String.contains?(page_id, "page=true") + end + + test "unknown query params do not crash the endpoint", %{conn: conn} do + user = insert(:user) + note = insert(:note_activity) + note = Pleroma.Activity.get_by_id_with_object(note.id) + uuid = String.split(note.object.data["id"], "/") |> List.last() + + {:ok, _} = + CommonAPI.post(user, %{status: "reply1", in_reply_to_status_id: note.id}) + + conn = + conn + |> put_req_header("accept", "application/activity+json") + |> get("/objects/#{uuid}/replies?unknown_param=1") + + assert %{"type" => "OrderedCollection"} = json_response(conn, 200) + end + test "it renders a collection page", %{ conn: conn } do @@ -500,6 +538,25 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do end describe "/activities/:uuid" do + test "it does not include a top-level replies collection on activities", %{conn: conn} do + clear_config([:activitypub, :note_replies_output_limit], 1) + + activity = insert(:note_activity) + activity = Activity.get_by_id_with_object(activity.id) + + uuid = String.split(activity.data["id"], "/") |> List.last() + + conn = + conn + |> put_req_header("accept", "application/activity+json") + |> get("/activities/#{uuid}") + + res = json_response(conn, 200) + + refute Map.has_key?(res, "replies") + assert get_in(res, ["object", "replies", "id"]) == activity.object.data["id"] <> "/replies" + end + test "it doesn't return a local-only activity", %{conn: conn} do user = insert(:user) {:ok, post} = CommonAPI.post(user, %{status: "test", visibility: "local"}) diff --git a/test/pleroma/web/activity_pub/views/user_view_test.exs b/test/pleroma/web/activity_pub/views/user_view_test.exs @@ -169,6 +169,18 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do user = Map.merge(user, %{hide_followers_count: false, hide_followers: true}) assert %{"totalItems" => 1} = UserView.render("followers.json", %{user: user}) end + + test "does not hide follower items based on `hide_follows`" do + user = insert(:user) + follower = insert(:user) + {:ok, user, _follower, _activity} = CommonAPI.follow(user, follower) + + user = Map.merge(user, %{hide_followers: false, hide_follows: true}) + follower_ap_id = follower.ap_id + + assert %{"first" => %{"orderedItems" => [^follower_ap_id]}} = + UserView.render("followers.json", %{user: user}) + end end describe "following" do