logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: a3426fcaf38b5533a553e0ffe3f031c4bb27cad5
parent b6667105741c44d5ed102f6657b1b0ae77d4206b
Author: Mark Felder <feld@feld.me>
Date:   Tue, 30 Jan 2024 14:13:13 -0500

Revert "Pleroma.Web.MastodonAPI.MediaController: dialyzer errors"

This reverts commit 8cd527985780f6c9e4512f2e72f3dddbbf9b33ca.

Diffstat:

Mlib/pleroma/web/api_spec/operations/media_operation.ex14+++++++-------
Mlib/pleroma/web/mastodon_api/controllers/media_controller.ex12+++++-------
2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/lib/pleroma/web/api_spec/operations/media_operation.ex b/lib/pleroma/web/api_spec/operations/media_operation.ex @@ -36,18 +36,18 @@ defmodule Pleroma.Web.ApiSpec.MediaOperation do title: "MediaCreateRequest", description: "POST body for creating an attachment", type: :object, - required: ["file"], + required: [:file], properties: %{ - "file" => %Schema{ + file: %Schema{ type: :string, format: :binary, description: "The file to be attached, using multipart form data." }, - "description" => %Schema{ + description: %Schema{ type: :string, description: "A plain-text description of the media, for accessibility purposes." }, - "focus" => %Schema{ + focus: %Schema{ type: :string, 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", type: :object, properties: %{ - "file" => %Schema{ + file: %Schema{ type: :string, format: :binary, description: "The file to be attached, using multipart form data." }, - "description" => %Schema{ + description: %Schema{ type: :string, description: "A plain-text description of the media, for accessibility purposes." }, - "focus" => %Schema{ + focus: %Schema{ type: :string, description: "Two floating points (x,y), comma-delimited, ranging from -1.0 to 1.0." } diff --git a/lib/pleroma/web/mastodon_api/controllers/media_controller.ex b/lib/pleroma/web/mastodon_api/controllers/media_controller.ex @@ -20,12 +20,12 @@ defmodule Pleroma.Web.MastodonAPI.MediaController do defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.MediaOperation @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} <- ActivityPub.upload( file, actor: User.ap_id(user), - description: Map.get(data, "description") + description: Map.get(data, :description) ) do 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} @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} <- ActivityPub.upload( file, actor: User.ap_id(user), - description: Map.get(data, "description") + description: Map.get(data, :description) ) do 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} @doc "PUT /api/v1/media/:id" - def update(%{assigns: %{user: user}, body_params: %{"description" => description}} = conn, %{ - id: id - }) do + def update(%{assigns: %{user: user}, body_params: %{description: description}} = conn, %{id: id}) do with %Object{} = object <- Object.get_by_id(id), :ok <- Object.authorize_access(object, user), {:ok, %Object{data: data}} <- Object.update_data(object, %{"name" => description}) do