Pagination and schema fixes for the media management endpoint
This commit is contained in:
parent
70de22bf9b
commit
0f21f6e802
2 changed files with 20 additions and 9 deletions
|
|
@ -7,6 +7,7 @@ defmodule Pleroma.Web.ApiSpec.PleromaUtilOperation do
|
|||
alias OpenApiSpex.Schema
|
||||
alias Pleroma.Web.ApiSpec.Schemas.ApiError
|
||||
alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
|
||||
alias Pleroma.Web.ApiSpec.Schemas.Attachment
|
||||
|
||||
import Pleroma.Web.ApiSpec.Helpers
|
||||
|
||||
|
|
@ -396,19 +397,29 @@ defmodule Pleroma.Web.ApiSpec.PleromaUtilOperation do
|
|||
|
||||
def uploaded_media_operation do
|
||||
%Operation{
|
||||
tags: ["Media"],
|
||||
tags: ["Media attachments"],
|
||||
summary: "List media uploaded by the current user",
|
||||
security: [%{"oAuth" => ["read:accounts"]}],
|
||||
operationId: "PleromaAPI.UtilController.uploaded_media",
|
||||
parameters: [
|
||||
Operation.parameter(
|
||||
:offset,
|
||||
:query,
|
||||
%Schema{type: :integer, default: 0},
|
||||
"Offset for uploaded media pagination"
|
||||
)
|
||||
],
|
||||
responses: %{
|
||||
200 =>
|
||||
Operation.response("Success", "application/json", %Schema{
|
||||
type: :object,
|
||||
properties: %{
|
||||
aliases: %Schema{
|
||||
type: :array,
|
||||
items: %Schema{type: :string},
|
||||
example: ["foo@example.org"]
|
||||
type: :array,
|
||||
items: %Schema{
|
||||
type: :object,
|
||||
properties: %{
|
||||
uploaded: %Schema{
|
||||
type: :string, description: "Date and time when the attachment was uploaded", format: :"date-time"
|
||||
},
|
||||
attachment: Attachment
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -278,12 +278,12 @@ defmodule Pleroma.Web.PleromaAPI.UtilController do
|
|||
end
|
||||
|
||||
def uploaded_media(
|
||||
%{assigns: %{user: user}} = conn,
|
||||
%{assigns: %{user: user}, private: %{open_api_spex: %{params: %{ offset: offset }}}} = conn,
|
||||
_
|
||||
) do
|
||||
|
||||
result =
|
||||
Pleroma.Upload.list_uploaded_by(user, 0, 50)
|
||||
Pleroma.Upload.list_uploaded_by(user, offset, 50)
|
||||
|> Enum.map(
|
||||
fn %Pleroma.Object{ id: id, data: %{ "url" => [ mediaUrl ], "name" => name }, inserted_at: uploaded } ->
|
||||
%{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue