Merge branch 'list-id-visibility' into fork

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-09-06 09:12:29 +02:00
commit 8fa2d73835
5 changed files with 27 additions and 2 deletions

View file

@ -0,0 +1 @@
Include list id in StatusView

View file

@ -43,6 +43,7 @@ Has these additional fields under the `pleroma` object:
- `event`: event information if the post is an event, `null` otherwise.
- `non_anonymous`: true if the source post specifies the poll results are not anonymous. Currently only implemented by Smithereen.
- `bookmark_folder`: the ID of the folder bookmark is stored within (if any).
- `list_id`: the ID of the list the post is addressed to (if any, only returned to author).
The `GET /api/v1/statuses/:id/source` endpoint additionally has the following attributes:

View file

@ -260,6 +260,12 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
nullable: true,
description:
"A datetime (ISO 8601) that states when the post was pinned or `null` if the post is not pinned"
},
list_id: %Schema{
type: :integer,
nullable: true,
description:
"The ID of the list the post is addressed to (if any, only returned to author)"
}
}
},

View file

@ -467,7 +467,8 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
content_type: opts[:with_source] && (object.data["content_type"] || "text/plain"),
quotes_count: object.data["quotesCount"] || 0,
event: build_event(object.data, opts[:for]),
bookmark_folder: bookmark_folder
bookmark_folder: bookmark_folder,
list_id: get_list_id(object, client_posted_this_activity)
}
}
end
@ -919,4 +920,14 @@ def build_source_location(_), do: nil
defp get_language(%{data: %{"language" => "und"}}), do: nil
defp get_language(object), do: object.data["language"]
defp get_list_id(object, client_posted_this_activity) do
with true <- client_posted_this_activity,
%{data: %{"listMessage" => list_ap_id}} when is_binary(list_ap_id) <- object,
%{id: list_id} <- Pleroma.List.get_by_ap_id(list_ap_id) do
list_id
else
_ -> nil
end
end
end

View file

@ -344,7 +344,8 @@ test "a note activity" do
quotes_count: 0,
content_type: nil,
event: nil,
bookmark_folder: nil
bookmark_folder: nil,
list_id: nil
}
}
@ -935,6 +936,11 @@ test "visibility/list" do
status = StatusView.render("show.json", activity: activity)
assert status.visibility == "list"
assert status.pleroma.list_id == nil
status = StatusView.render("show.json", activity: activity, for: user)
assert status.pleroma.list_id == list.id
end
test "has a field for parent visibility" do