end
def with_relationships_param do
- Operation.parameter(:with_relationships, :query, BooleanLike, "Include relationships")
+ Operation.parameter(
+ :with_relationships,
+ :query,
+ BooleanLike,
+ "Embed relationships into accounts."
+ )
end
def empty_object_response do
apply(__MODULE__, operation, [])
end
+ # Note: `with_relationships` param is not supported (PleromaFE uses this op for autocomplete)
def account_search_operation do
%Operation{
tags: ["Search"],
:query,
%Schema{allOf: [BooleanLike], default: false},
"Only include accounts that the user is following"
- ),
- with_relationships_param()
+ )
],
responses: %{
200 =>
:query,
%Schema{allOf: [BooleanLike], default: false},
"Only include accounts that the user is following"
- )
- | pagination_params()
+ ),
+ with_relationships_param() | pagination_params()
],
responses: %{
200 => Operation.response("Results", "application/json", results2())
alias OpenApiSpex.Schema
alias Pleroma.Web.ApiSpec.AccountOperation
alias Pleroma.Web.ApiSpec.Schemas.ApiError
- alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
alias Pleroma.Web.ApiSpec.Schemas.FlakeID
alias Pleroma.Web.ApiSpec.Schemas.ScheduledStatus
alias Pleroma.Web.ApiSpec.Schemas.Status
summary: "Bookmarked statuses",
description: "Statuses the user has bookmarked",
operationId: "StatusController.bookmarks",
- parameters: [
- Operation.parameter(:with_relationships, :query, BooleanLike, "Include relationships")
- | pagination_params()
- ],
+ parameters: pagination_params(),
security: [%{"oAuth" => ["read:bookmarks"]}],
responses: %{
200 => Operation.response("Array of Statuses", "application/json", array_of_statuses())
local_param(),
with_muted_param(),
exclude_visibilities_param(),
- reply_visibility_param(),
- with_relationships_param() | pagination_params()
+ reply_visibility_param() | pagination_params()
],
operationId: "TimelineController.home",
responses: %{
only_media_param(),
with_muted_param(),
exclude_visibilities_param(),
- reply_visibility_param(),
- with_relationships_param() | pagination_params()
+ reply_visibility_param() | pagination_params()
],
operationId: "TimelineController.public",
responses: %{
local_param(),
only_media_param(),
with_muted_param(),
- exclude_visibilities_param(),
- with_relationships_param() | pagination_params()
+ exclude_visibilities_param() | pagination_params()
],
operationId: "TimelineController.hashtag",
responses: %{
required: true
),
with_muted_param(),
- exclude_visibilities_param(),
- with_relationships_param() | pagination_params()
+ exclude_visibilities_param() | pagination_params()
],
operationId: "TimelineController.list",
responses: %{
def put_if_exist(map, key, value), do: Map.put(map, key, value)
- def with_relationships?(params) do
- # To do: change to `truthy_param?(params["with_relationships"])` once PleromaFE supports it
- not explicitly_falsy_param?(params["with_relationships"])
+ @doc """
+ Returns true if request specifies to include embedded relationships in account objects.
+ May only be used in selected account-related endpoints; has no effect for status- or
+ notification-related endpoints.
+ """
+ # Intended for PleromaFE: https://git.pleroma.social/pleroma/pleroma-fe/-/issues/838
+ def embed_relationships?(params) do
+ # To do once OpenAPI transition mess is over: just `truthy_param?(params[:with_relationships])`
+ params
+ |> Map.get(:with_relationships, params["with_relationships"])
+ |> truthy_param?()
end
end
add_link_headers: 2,
truthy_param?: 1,
assign_account_by_id: 2,
- with_relationships?: 1,
+ embed_relationships?: 1,
json_response: 3
]
for: for_user,
users: followers,
as: :user,
- embed_relationships: with_relationships?(params)
+ embed_relationships: embed_relationships?(params)
)
end
for: for_user,
users: followers,
as: :user,
- embed_relationships: with_relationships?(params)
+ embed_relationships: embed_relationships?(params)
)
end
conn
|> put_view(AccountView)
- # https://git.pleroma.social/pleroma/pleroma-fe/-/issues/838#note_59223
|> render("index.json",
users: accounts,
for: user,
- as: :user,
- embed_relationships: ControllerHelper.with_relationships?(params)
+ as: :user
)
end
offset: params[:offset],
type: params[:type],
author: get_author(params),
- embed_relationships: ControllerHelper.with_relationships?(params),
+ embed_relationships: ControllerHelper.embed_relationships?(params),
for_user: user
]
|> Enum.filter(&elem(&1, 1))
users: accounts,
for: options[:for_user],
as: :user,
- # https://git.pleroma.social/pleroma/pleroma-fe/-/issues/838#note_59223
embed_relationships: options[:embed_relationships]
)
end