Add only_reblogs parameter to account statuses API
Implement filtering to show only reblogs/reposts in user status queries. This complements the existing exclude_reblogs parameter. Supports both boolean and "1" string values for consistency with other API parameters.
This commit is contained in:
parent
b082e1f86b
commit
331f21111c
3 changed files with 21 additions and 0 deletions
|
|
@ -1065,6 +1065,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
from(activity in query, where: fragment("?->>'type' != 'Announce'", activity.data))
|
||||
end
|
||||
|
||||
defp restrict_reblogs(query, %{only_reblogs: true}) do
|
||||
from(activity in query, where: fragment("?->>'type' = 'Announce'", activity.data))
|
||||
end
|
||||
|
||||
defp restrict_reblogs(query, _), do: query
|
||||
|
||||
defp restrict_muted(query, %{with_muted: true}), do: query
|
||||
|
|
|
|||
|
|
@ -143,6 +143,12 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
|||
"Include statuses from muted accounts."
|
||||
),
|
||||
Operation.parameter(:exclude_reblogs, :query, BooleanLike.schema(), "Exclude reblogs"),
|
||||
Operation.parameter(
|
||||
:only_reblogs,
|
||||
:query,
|
||||
BooleanLike.schema(),
|
||||
"Include only reblogs"
|
||||
),
|
||||
Operation.parameter(:exclude_replies, :query, BooleanLike.schema(), "Exclude replies"),
|
||||
Operation.parameter(
|
||||
:exclude_visibilities,
|
||||
|
|
|
|||
|
|
@ -469,6 +469,17 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
assert [%{"id" => ^post_id}] = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
|
||||
test "gets only a user's reblogs", %{user: user, conn: conn} do
|
||||
{:ok, %{id: post_id}} = CommonAPI.post(user, %{status: "HI!!!"})
|
||||
{:ok, %{id: reblog_id}} = CommonAPI.repeat(post_id, user)
|
||||
|
||||
conn = get(conn, "/api/v1/accounts/#{user.id}/statuses?only_reblogs=true")
|
||||
assert [%{"id" => ^reblog_id}] = json_response_and_validate_schema(conn, 200)
|
||||
|
||||
conn = get(conn, "/api/v1/accounts/#{user.id}/statuses?only_reblogs=1")
|
||||
assert [%{"id" => ^reblog_id}] = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
|
||||
test "filters user's statuses by a hashtag", %{user: user, conn: conn} do
|
||||
{:ok, %{id: post_id}} = CommonAPI.post(user, %{status: "#hashtag"})
|
||||
{:ok, _post} = CommonAPI.post(user, %{status: "hashtag"})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue