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 OpenApiSpex.Schema
|
||||||
alias Pleroma.Web.ApiSpec.Schemas.ApiError
|
alias Pleroma.Web.ApiSpec.Schemas.ApiError
|
||||||
alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
|
alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
|
||||||
|
alias Pleroma.Web.ApiSpec.Schemas.Attachment
|
||||||
|
|
||||||
import Pleroma.Web.ApiSpec.Helpers
|
import Pleroma.Web.ApiSpec.Helpers
|
||||||
|
|
||||||
|
|
@ -396,19 +397,29 @@ defmodule Pleroma.Web.ApiSpec.PleromaUtilOperation do
|
||||||
|
|
||||||
def uploaded_media_operation do
|
def uploaded_media_operation do
|
||||||
%Operation{
|
%Operation{
|
||||||
tags: ["Media"],
|
tags: ["Media attachments"],
|
||||||
summary: "List media uploaded by the current user",
|
summary: "List media uploaded by the current user",
|
||||||
security: [%{"oAuth" => ["read:accounts"]}],
|
security: [%{"oAuth" => ["read:accounts"]}],
|
||||||
operationId: "PleromaAPI.UtilController.uploaded_media",
|
operationId: "PleromaAPI.UtilController.uploaded_media",
|
||||||
|
parameters: [
|
||||||
|
Operation.parameter(
|
||||||
|
:offset,
|
||||||
|
:query,
|
||||||
|
%Schema{type: :integer, default: 0},
|
||||||
|
"Offset for uploaded media pagination"
|
||||||
|
)
|
||||||
|
],
|
||||||
responses: %{
|
responses: %{
|
||||||
200 =>
|
200 =>
|
||||||
Operation.response("Success", "application/json", %Schema{
|
Operation.response("Success", "application/json", %Schema{
|
||||||
type: :object,
|
type: :array,
|
||||||
properties: %{
|
items: %Schema{
|
||||||
aliases: %Schema{
|
type: :object,
|
||||||
type: :array,
|
properties: %{
|
||||||
items: %Schema{type: :string},
|
uploaded: %Schema{
|
||||||
example: ["foo@example.org"]
|
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
|
end
|
||||||
|
|
||||||
def uploaded_media(
|
def uploaded_media(
|
||||||
%{assigns: %{user: user}} = conn,
|
%{assigns: %{user: user}, private: %{open_api_spex: %{params: %{ offset: offset }}}} = conn,
|
||||||
_
|
_
|
||||||
) do
|
) do
|
||||||
|
|
||||||
result =
|
result =
|
||||||
Pleroma.Upload.list_uploaded_by(user, 0, 50)
|
Pleroma.Upload.list_uploaded_by(user, offset, 50)
|
||||||
|> Enum.map(
|
|> Enum.map(
|
||||||
fn %Pleroma.Object{ id: id, data: %{ "url" => [ mediaUrl ], "name" => name }, inserted_at: uploaded } ->
|
fn %Pleroma.Object{ id: id, data: %{ "url" => [ mediaUrl ], "name" => name }, inserted_at: uploaded } ->
|
||||||
%{
|
%{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue