mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
Revert "Pleroma.Web.MastodonAPI.MediaController: dialyzer errors"
This reverts commit 8cd5279857
.
This commit is contained in:
parent
b666710574
commit
a3426fcaf3
2 changed files with 12 additions and 14 deletions
|
@ -36,18 +36,18 @@ defmodule Pleroma.Web.ApiSpec.MediaOperation do
|
||||||
title: "MediaCreateRequest",
|
title: "MediaCreateRequest",
|
||||||
description: "POST body for creating an attachment",
|
description: "POST body for creating an attachment",
|
||||||
type: :object,
|
type: :object,
|
||||||
required: ["file"],
|
required: [:file],
|
||||||
properties: %{
|
properties: %{
|
||||||
"file" => %Schema{
|
file: %Schema{
|
||||||
type: :string,
|
type: :string,
|
||||||
format: :binary,
|
format: :binary,
|
||||||
description: "The file to be attached, using multipart form data."
|
description: "The file to be attached, using multipart form data."
|
||||||
},
|
},
|
||||||
"description" => %Schema{
|
description: %Schema{
|
||||||
type: :string,
|
type: :string,
|
||||||
description: "A plain-text description of the media, for accessibility purposes."
|
description: "A plain-text description of the media, for accessibility purposes."
|
||||||
},
|
},
|
||||||
"focus" => %Schema{
|
focus: %Schema{
|
||||||
type: :string,
|
type: :string,
|
||||||
description: "Two floating points (x,y), comma-delimited, ranging from -1.0 to 1.0."
|
description: "Two floating points (x,y), comma-delimited, ranging from -1.0 to 1.0."
|
||||||
}
|
}
|
||||||
|
@ -79,16 +79,16 @@ defmodule Pleroma.Web.ApiSpec.MediaOperation do
|
||||||
description: "POST body for updating an attachment",
|
description: "POST body for updating an attachment",
|
||||||
type: :object,
|
type: :object,
|
||||||
properties: %{
|
properties: %{
|
||||||
"file" => %Schema{
|
file: %Schema{
|
||||||
type: :string,
|
type: :string,
|
||||||
format: :binary,
|
format: :binary,
|
||||||
description: "The file to be attached, using multipart form data."
|
description: "The file to be attached, using multipart form data."
|
||||||
},
|
},
|
||||||
"description" => %Schema{
|
description: %Schema{
|
||||||
type: :string,
|
type: :string,
|
||||||
description: "A plain-text description of the media, for accessibility purposes."
|
description: "A plain-text description of the media, for accessibility purposes."
|
||||||
},
|
},
|
||||||
"focus" => %Schema{
|
focus: %Schema{
|
||||||
type: :string,
|
type: :string,
|
||||||
description: "Two floating points (x,y), comma-delimited, ranging from -1.0 to 1.0."
|
description: "Two floating points (x,y), comma-delimited, ranging from -1.0 to 1.0."
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@ defmodule Pleroma.Web.MastodonAPI.MediaController do
|
||||||
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.MediaOperation
|
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.MediaOperation
|
||||||
|
|
||||||
@doc "POST /api/v1/media"
|
@doc "POST /api/v1/media"
|
||||||
def create(%{assigns: %{user: user}, body_params: %{"file" => file} = data} = conn, _) do
|
def create(%{assigns: %{user: user}, body_params: %{file: file} = data} = conn, _) do
|
||||||
with {:ok, object} <-
|
with {:ok, object} <-
|
||||||
ActivityPub.upload(
|
ActivityPub.upload(
|
||||||
file,
|
file,
|
||||||
actor: User.ap_id(user),
|
actor: User.ap_id(user),
|
||||||
description: Map.get(data, "description")
|
description: Map.get(data, :description)
|
||||||
) do
|
) do
|
||||||
attachment_data = Map.put(object.data, "id", object.id)
|
attachment_data = Map.put(object.data, "id", object.id)
|
||||||
|
|
||||||
|
@ -36,12 +36,12 @@ defmodule Pleroma.Web.MastodonAPI.MediaController do
|
||||||
def create(_conn, _data), do: {:error, :bad_request}
|
def create(_conn, _data), do: {:error, :bad_request}
|
||||||
|
|
||||||
@doc "POST /api/v2/media"
|
@doc "POST /api/v2/media"
|
||||||
def create2(%{assigns: %{user: user}, body_params: %{"file" => file} = data} = conn, _) do
|
def create2(%{assigns: %{user: user}, body_params: %{file: file} = data} = conn, _) do
|
||||||
with {:ok, object} <-
|
with {:ok, object} <-
|
||||||
ActivityPub.upload(
|
ActivityPub.upload(
|
||||||
file,
|
file,
|
||||||
actor: User.ap_id(user),
|
actor: User.ap_id(user),
|
||||||
description: Map.get(data, "description")
|
description: Map.get(data, :description)
|
||||||
) do
|
) do
|
||||||
attachment_data = Map.put(object.data, "id", object.id)
|
attachment_data = Map.put(object.data, "id", object.id)
|
||||||
|
|
||||||
|
@ -54,9 +54,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaController do
|
||||||
def create2(_conn, _data), do: {:error, :bad_request}
|
def create2(_conn, _data), do: {:error, :bad_request}
|
||||||
|
|
||||||
@doc "PUT /api/v1/media/:id"
|
@doc "PUT /api/v1/media/:id"
|
||||||
def update(%{assigns: %{user: user}, body_params: %{"description" => description}} = conn, %{
|
def update(%{assigns: %{user: user}, body_params: %{description: description}} = conn, %{id: id}) do
|
||||||
id: id
|
|
||||||
}) do
|
|
||||||
with %Object{} = object <- Object.get_by_id(id),
|
with %Object{} = object <- Object.get_by_id(id),
|
||||||
:ok <- Object.authorize_access(object, user),
|
:ok <- Object.authorize_access(object, user),
|
||||||
{:ok, %Object{data: data}} <- Object.update_data(object, %{"name" => description}) do
|
{:ok, %Object{data: data}} <- Object.update_data(object, %{"name" => description}) do
|
||||||
|
|
Loading…
Reference in a new issue