Include list id in StatusView
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
fecfe8bf89
commit
6d5ae4d2e9
5 changed files with 27 additions and 2 deletions
1
changelog.d/list-id-visibility.add
Normal file
1
changelog.d/list-id-visibility.add
Normal file
|
@ -0,0 +1 @@
|
|||
Include list id in StatusView
|
|
@ -42,6 +42,7 @@ Has these additional fields under the `pleroma` object:
|
|||
- `quotes_count`: the count of status quotes.
|
||||
- `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:
|
||||
|
||||
|
|
|
@ -249,6 +249,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)"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -465,7 +465,8 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
|
|||
parent_visible: visible_for_user?(reply_to, opts[:for]),
|
||||
pinned_at: pinned_at,
|
||||
quotes_count: object.data["quotesCount"] || 0,
|
||||
bookmark_folder: bookmark_folder
|
||||
bookmark_folder: bookmark_folder,
|
||||
list_id: get_list_id(object, client_posted_this_activity)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -835,4 +836,14 @@ defp proxied_url(url, page_url_data) do
|
|||
nil
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
|
|
|
@ -342,7 +342,8 @@ test "a note activity" do
|
|||
parent_visible: false,
|
||||
pinned_at: nil,
|
||||
quotes_count: 0,
|
||||
bookmark_folder: nil
|
||||
bookmark_folder: nil,
|
||||
list_id: nil
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -912,6 +913,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
|
||||
|
|
Loading…
Reference in a new issue