Merge branch 'dialyzer-fixes' into 'develop'

Dialyzer fixes, some reverts

See merge request pleroma/pleroma!4049
This commit is contained in:
feld 2024-01-30 20:32:32 +00:00
commit 1bba02863d
51 changed files with 217 additions and 182 deletions

View File

@ -51,7 +51,6 @@ defmodule Pleroma.Upload do
| {:size_limit, nil | non_neg_integer()}
| {:uploader, module()}
| {:filters, [module()]}
| {:actor, String.t()}
@type t :: %__MODULE__{
id: String.t(),

View File

@ -2559,9 +2559,9 @@ def confirmation_changeset(user, set_confirmation: confirmed?) do
cast(user, params, [:is_confirmed, :confirmation_token])
end
@spec approval_changeset(User.t(), keyword()) :: Ecto.Changeset.t()
def approval_changeset(user, set_approval: approved?) do
cast(user, %{is_approved: approved?}, [:is_approved])
@spec approval_changeset(Ecto.Changeset.t(), keyword()) :: Ecto.Changeset.t()
def approval_changeset(changeset, set_approval: approved?) do
cast(changeset, %{is_approved: approved?}, [:is_approved])
end
@spec add_pinned_object_id(User.t(), String.t()) :: {:ok, User.t()} | {:error, term()}

View File

@ -128,7 +128,7 @@ def show(conn, _params) do
end
end
def update(%{body_params: %{"configs" => configs}} = conn, _) do
def update(%{body_params: %{configs: configs}} = conn, _) do
with :ok <- configurable_from_database() do
results =
configs

View File

@ -27,7 +27,7 @@ def show(conn, %{name: document_name}) do
end
end
def update(%{body_params: %{"file" => file}} = conn, %{name: document_name}) do
def update(%{body_params: %{file: file}} = conn, %{name: document_name}) do
with {:ok, url} <- InstanceDocument.put(document_name, file.path) do
json(conn, %{"url" => url})
end

View File

@ -40,7 +40,7 @@ def create(%{body_params: params} = conn, _) do
end
@doc "Revokes invite by token"
def revoke(%{body_params: %{"token" => token}} = conn, _) do
def revoke(%{body_params: %{token: token}} = conn, _) do
with {:ok, invite} <- UserInviteToken.find_by_token(token),
{:ok, updated_invite} = UserInviteToken.update_invite(invite, %{used: true}) do
render(conn, "show.json", invite: updated_invite)
@ -51,7 +51,7 @@ def revoke(%{body_params: %{"token" => token}} = conn, _) do
end
@doc "Sends registration invite via email"
def email(%{assigns: %{user: user}, body_params: %{"email" => email} = params} = conn, _) do
def email(%{assigns: %{user: user}, body_params: %{email: email} = params} = conn, _) do
with {_, false} <- {:registrations_open, Config.get([:instance, :registrations_open])},
{_, true} <- {:invites_enabled, Config.get([:instance, :invites_enabled])},
{:ok, invite_token} <- UserInviteToken.create_invite(),
@ -60,7 +60,7 @@ def email(%{assigns: %{user: user}, body_params: %{"email" => email} = params} =
|> Pleroma.Emails.UserEmail.user_invitation_email(
invite_token,
email,
params["name"]
params[:name]
)
|> Pleroma.Emails.Mailer.deliver() do
json_response(conn, :no_content, "")

View File

@ -59,12 +59,12 @@ defp paginate_entries(entries, page, page_size) do
Enum.slice(entries, offset, page_size)
end
def delete(%{assigns: %{user: _}, body_params: %{"urls" => urls}} = conn, _) do
def delete(%{assigns: %{user: _}, body_params: %{urls: urls}} = conn, _) do
MediaProxy.remove_from_banned_urls(urls)
json(conn, %{})
end
def purge(%{assigns: %{user: _}, body_params: %{"urls" => urls, "ban" => ban}} = conn, _) do
def purge(%{assigns: %{user: _}, body_params: %{urls: urls, ban: ban}} = conn, _) do
MediaProxy.Invalidation.purge(urls)
if ban do

View File

@ -31,7 +31,7 @@ def index(conn, _params) do
end
end
def follow(%{assigns: %{user: admin}, body_params: %{"relay_url" => target}} = conn, _) do
def follow(%{assigns: %{user: admin}, body_params: %{relay_url: target}} = conn, _) do
with {:ok, _message} <- Relay.follow(target) do
ModerationLog.insert_log(%{action: "relay_follow", actor: admin, target: target})
@ -44,11 +44,8 @@ def follow(%{assigns: %{user: admin}, body_params: %{"relay_url" => target}} = c
end
end
def unfollow(
%{assigns: %{user: admin}, body_params: %{"relay_url" => target} = params} = conn,
_
) do
with {:ok, _message} <- Relay.unfollow(target, %{force: params["force"]}) do
def unfollow(%{assigns: %{user: admin}, body_params: %{relay_url: target} = params} = conn, _) do
with {:ok, _message} <- Relay.unfollow(target, %{force: params[:force]}) do
ModerationLog.insert_log(%{action: "relay_unfollow", actor: admin, target: target})
json(conn, target)

View File

@ -45,7 +45,7 @@ def show(conn, %{id: id}) do
end
end
def update(%{assigns: %{user: admin}, body_params: %{"reports" => reports}} = conn, _) do
def update(%{assigns: %{user: admin}, body_params: %{reports: reports}} = conn, _) do
result =
Enum.map(reports, fn report ->
case CommonAPI.update_report_state(report.id, report.state) do
@ -73,7 +73,7 @@ def update(%{assigns: %{user: admin}, body_params: %{"reports" => reports}} = co
end
end
def notes_create(%{assigns: %{user: user}, body_params: %{"content" => content}} = conn, %{
def notes_create(%{assigns: %{user: user}, body_params: %{content: content}} = conn, %{
id: report_id
}) do
with {:ok, _} <- ReportNote.create(user.id, report_id, content),

View File

@ -53,11 +53,11 @@ defmodule Pleroma.Web.AdminAPI.UserController do
def delete(conn, %{nickname: nickname}) do
conn
|> Map.put(:body_params, %{"nicknames" => [nickname]})
|> Map.put(:body_params, %{nicknames: [nickname]})
|> delete(%{})
end
def delete(%{assigns: %{user: admin}, body_params: %{"nicknames" => nicknames}} = conn, _) do
def delete(%{assigns: %{user: admin}, body_params: %{nicknames: nicknames}} = conn, _) do
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
Enum.each(users, fn user ->
@ -78,8 +78,8 @@ def follow(
%{
assigns: %{user: admin},
body_params: %{
"follower" => follower_nick,
"followed" => followed_nick
follower: follower_nick,
followed: followed_nick
}
} = conn,
_
@ -103,8 +103,8 @@ def unfollow(
%{
assigns: %{user: admin},
body_params: %{
"follower" => follower_nick,
"followed" => followed_nick
follower: follower_nick,
followed: followed_nick
}
} = conn,
_
@ -124,7 +124,7 @@ def unfollow(
json(conn, "ok")
end
def create(%{assigns: %{user: admin}, body_params: %{"users" => users}} = conn, _) do
def create(%{assigns: %{user: admin}, body_params: %{users: users}} = conn, _) do
changesets =
users
|> Enum.map(fn %{nickname: nickname, email: email, password: password} ->
@ -202,7 +202,7 @@ def toggle_activation(%{assigns: %{user: admin}} = conn, %{nickname: nickname})
render(conn, "show.json", user: updated_user)
end
def activate(%{assigns: %{user: admin}, body_params: %{"nicknames" => nicknames}} = conn, _) do
def activate(%{assigns: %{user: admin}, body_params: %{nicknames: nicknames}} = conn, _) do
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
{:ok, updated_users} = User.set_activation(users, true)
@ -215,7 +215,7 @@ def activate(%{assigns: %{user: admin}, body_params: %{"nicknames" => nicknames}
render(conn, "index.json", users: updated_users)
end
def deactivate(%{assigns: %{user: admin}, body_params: %{"nicknames" => nicknames}} = conn, _) do
def deactivate(%{assigns: %{user: admin}, body_params: %{nicknames: nicknames}} = conn, _) do
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
{:ok, updated_users} = User.set_activation(users, false)
@ -228,7 +228,7 @@ def deactivate(%{assigns: %{user: admin}, body_params: %{"nicknames" => nickname
render(conn, "index.json", users: updated_users)
end
def approve(%{assigns: %{user: admin}, body_params: %{"nicknames" => nicknames}} = conn, _) do
def approve(%{assigns: %{user: admin}, body_params: %{nicknames: nicknames}} = conn, _) do
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
{:ok, updated_users} = User.approve(users)
@ -241,7 +241,7 @@ def approve(%{assigns: %{user: admin}, body_params: %{"nicknames" => nicknames}}
render(conn, "index.json", users: updated_users)
end
def suggest(%{assigns: %{user: admin}, body_params: %{"nicknames" => nicknames}} = conn, _) do
def suggest(%{assigns: %{user: admin}, body_params: %{nicknames: nicknames}} = conn, _) do
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
{:ok, updated_users} = User.set_suggestion(users, true)
@ -254,7 +254,7 @@ def suggest(%{assigns: %{user: admin}, body_params: %{"nicknames" => nicknames}}
render(conn, "index.json", users: updated_users)
end
def unsuggest(%{assigns: %{user: admin}, body_params: %{"nicknames" => nicknames}} = conn, _) do
def unsuggest(%{assigns: %{user: admin}, body_params: %{nicknames: nicknames}} = conn, _) do
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
{:ok, updated_users} = User.set_suggestion(users, false)

View File

@ -27,10 +27,12 @@ def init(opts) do
@impl Plug
def call(conn, %{operation_id: operation_id, render_error: render_error}) do
def call(conn, %{operation_id: operation_id, render_error: render_error} = opts) do
{spec, operation_lookup} = PutApiSpec.get_spec_and_operation_lookup(conn)
operation = operation_lookup[operation_id]
cast_opts = opts |> Map.take([:replace_params]) |> Map.to_list()
content_type =
case Conn.get_req_header(conn, "content-type") do
[header_value | _] ->
@ -44,7 +46,7 @@ def call(conn, %{operation_id: operation_id, render_error: render_error}) do
conn = Conn.put_private(conn, :operation_id, operation_id)
case cast_and_validate(spec, operation, conn, content_type, strict?()) do
case cast_and_validate(spec, operation, conn, content_type, strict?(), cast_opts) do
{:ok, conn} ->
conn
@ -94,11 +96,11 @@ def call(
def call(conn, opts), do: OpenApiSpex.Plug.CastAndValidate.call(conn, opts)
defp cast_and_validate(spec, operation, conn, content_type, true = _strict) do
OpenApiSpex.cast_and_validate(spec, operation, conn, content_type)
defp cast_and_validate(spec, operation, conn, content_type, true = _strict, cast_opts) do
OpenApiSpex.cast_and_validate(spec, operation, conn, content_type, cast_opts)
end
defp cast_and_validate(spec, operation, conn, content_type, false = _strict) do
defp cast_and_validate(spec, operation, conn, content_type, false = _strict, cast_opts) do
case OpenApiSpex.cast_and_validate(spec, operation, conn, content_type) do
{:ok, conn} ->
{:ok, conn}
@ -123,7 +125,7 @@ defp cast_and_validate(spec, operation, conn, content_type, false = _strict) do
end)
conn = %Conn{conn | query_params: query_params}
OpenApiSpex.cast_and_validate(spec, operation, conn, content_type)
OpenApiSpex.cast_and_validate(spec, operation, conn, content_type, cast_opts)
end
end

View File

@ -62,7 +62,7 @@ def with_relationships_param do
Operation.parameter(
:with_relationships,
:query,
BooleanLike,
BooleanLike.schema(),
"Embed relationships into accounts. **If this parameter is not set account's `pleroma.relationship` is going to be `null`.**"
)
end

View File

@ -122,22 +122,27 @@ def statuses_operation do
parameters:
[
%Reference{"$ref": "#/components/parameters/accountIdOrNickname"},
Operation.parameter(:pinned, :query, BooleanLike, "Include only pinned statuses"),
Operation.parameter(
:pinned,
:query,
BooleanLike.schema(),
"Include only pinned statuses"
),
Operation.parameter(:tagged, :query, :string, "With tag"),
Operation.parameter(
:only_media,
:query,
BooleanLike,
BooleanLike.schema(),
"Include only statuses with media attached"
),
Operation.parameter(
:with_muted,
:query,
BooleanLike,
BooleanLike.schema(),
"Include statuses from muted accounts."
),
Operation.parameter(:exclude_reblogs, :query, BooleanLike, "Exclude reblogs"),
Operation.parameter(:exclude_replies, :query, BooleanLike, "Exclude replies"),
Operation.parameter(:exclude_reblogs, :query, BooleanLike.schema(), "Exclude reblogs"),
Operation.parameter(:exclude_replies, :query, BooleanLike.schema(), "Exclude replies"),
Operation.parameter(
:exclude_visibilities,
:query,
@ -147,7 +152,7 @@ def statuses_operation do
Operation.parameter(
:with_muted,
:query,
BooleanLike,
BooleanLike.schema(),
"Include reactions from muted accounts."
)
] ++ pagination_params(),
@ -882,9 +887,9 @@ defp follow_by_uri_request do
description: "POST body for muting an account",
type: :object,
properties: %{
"uri" => %Schema{type: :string, nullable: true, format: :uri}
uri: %Schema{type: :string, nullable: true, format: :uri}
},
required: ["uri"]
required: [:uri]
}
end
@ -925,7 +930,7 @@ defp note_request do
description: "POST body for adding a note for an account",
type: :object,
properties: %{
"comment" => %Schema{
comment: %Schema{
type: :string,
description: "Account note body"
}

View File

@ -47,7 +47,7 @@ def update_operation do
request_body("Parameters", %Schema{
type: :object,
properties: %{
"configs" => %Schema{
configs: %Schema{
type: :array,
items: %Schema{
type: :object,

View File

@ -61,9 +61,9 @@ defp update_request do
title: "UpdateRequest",
description: "POST body for uploading the file",
type: :object,
required: ["file"],
required: [:file],
properties: %{
"file" => %Schema{
file: %Schema{
type: :string,
format: :binary,
description: "The file to be uploaded, using multipart form data."

View File

@ -79,9 +79,9 @@ def revoke_operation do
"Parameters",
%Schema{
type: :object,
required: ["token"],
required: [:token],
properties: %{
"token" => %Schema{type: :string}
token: %Schema{type: :string}
}
},
required: true
@ -106,10 +106,10 @@ def email_operation do
"Parameters",
%Schema{
type: :object,
required: ["email"],
required: [:email],
properties: %{
"email" => %Schema{type: :string, format: :email},
"name" => %Schema{type: :string}
email: %Schema{type: :string, format: :email},
name: %Schema{type: :string}
}
},
required: true

View File

@ -78,9 +78,9 @@ def delete_operation do
"Parameters",
%Schema{
type: :object,
required: ["urls"],
required: [:urls],
properties: %{
"urls" => %Schema{type: :array, items: %Schema{type: :string, format: :uri}}
urls: %Schema{type: :array, items: %Schema{type: :string, format: :uri}}
}
},
required: true
@ -104,10 +104,10 @@ def purge_operation do
"Parameters",
%Schema{
type: :object,
required: ["urls"],
required: [:urls],
properties: %{
"urls" => %Schema{type: :array, items: %Schema{type: :string, format: :uri}},
"ban" => %Schema{type: :boolean, default: true}
urls: %Schema{type: :array, items: %Schema{type: :string, format: :uri}},
ban: %Schema{type: :boolean, default: true}
}
},
required: true

View File

@ -87,7 +87,7 @@ defp relay_url do
%Schema{
type: :object,
properties: %{
"relay_url" => %Schema{type: :string, format: :uri}
relay_url: %Schema{type: :string, format: :uri}
}
}
end
@ -96,8 +96,8 @@ defp relay_unfollow do
%Schema{
type: :object,
properties: %{
"relay_url" => %Schema{type: :string, format: :uri},
"force" => %Schema{type: :boolean, default: false}
relay_url: %Schema{type: :string, format: :uri},
force: %Schema{type: :boolean, default: false}
}
}
end

View File

@ -107,7 +107,7 @@ def notes_create_operation do
request_body("Parameters", %Schema{
type: :object,
properties: %{
"content" => %Schema{type: :string, description: "The message"}
content: %Schema{type: :string, description: "The message"}
}
}),
security: [%{"oAuth" => ["admin:write:reports"]}],
@ -141,7 +141,7 @@ def report_state do
end
def id_param do
Operation.parameter(:id, :path, FlakeID, "Report ID",
Operation.parameter(:id, :path, FlakeID.schema(), "Report ID",
example: "9umDrYheeY451cQnEe",
required: true
)
@ -199,9 +199,9 @@ defp account_admin do
defp update_request do
%Schema{
type: :object,
required: ["reports"],
required: [:reports],
properties: %{
"reports" => %Schema{
reports: %Schema{
type: :array,
items: %Schema{
type: :object,

View File

@ -50,7 +50,7 @@ def index_operation do
%Schema{
type: :object,
properties: %{
"users" => %Schema{type: :array, items: user()},
users: %Schema{type: :array, items: user()},
count: %Schema{type: :integer},
page_size: %Schema{type: :integer}
}
@ -75,7 +75,7 @@ def create_operation do
description: "POST body for creating users",
type: :object,
properties: %{
"users" => %Schema{
users: %Schema{
type: :array,
items: %Schema{
type: :object,
@ -168,8 +168,8 @@ def follow_operation do
%Schema{
type: :object,
properties: %{
"follower" => %Schema{type: :string, description: "Follower nickname"},
"followed" => %Schema{type: :string, description: "Followed nickname"}
follower: %Schema{type: :string, description: "Follower nickname"},
followed: %Schema{type: :string, description: "Followed nickname"}
}
}
),
@ -193,8 +193,8 @@ def unfollow_operation do
%Schema{
type: :object,
properties: %{
"follower" => %Schema{type: :string, description: "Follower nickname"},
"followed" => %Schema{type: :string, description: "Followed nickname"}
follower: %Schema{type: :string, description: "Follower nickname"},
followed: %Schema{type: :string, description: "Followed nickname"}
}
}
),
@ -219,7 +219,7 @@ def approve_operation do
description: "POST body for approving multiple users",
type: :object,
properties: %{
"nicknames" => %Schema{
nicknames: %Schema{
type: :array,
items: %Schema{type: :string}
}
@ -251,7 +251,7 @@ def suggest_operation do
description: "POST body for adding multiple suggested users",
type: :object,
properties: %{
"nicknames" => %Schema{
nicknames: %Schema{
type: :array,
items: %Schema{type: :string}
}
@ -283,7 +283,7 @@ def unsuggest_operation do
description: "POST body for removing multiple suggested users",
type: :object,
properties: %{
"nicknames" => %Schema{
nicknames: %Schema{
type: :array,
items: %Schema{type: :string}
}
@ -332,7 +332,7 @@ def activate_operation do
description: "POST body for deleting multiple users",
type: :object,
properties: %{
"nicknames" => %Schema{
nicknames: %Schema{
type: :array,
items: %Schema{type: :string}
}
@ -364,7 +364,7 @@ def deactivate_operation do
description: "POST body for deleting multiple users",
type: :object,
properties: %{
"nicknames" => %Schema{
nicknames: %Schema{
type: :array,
items: %Schema{type: :string}
}
@ -404,7 +404,7 @@ def delete_operation do
description: "POST body for deleting multiple users",
type: :object,
properties: %{
"nicknames" => %Schema{
nicknames: %Schema{
type: :array,
items: %Schema{type: :string}
}

View File

@ -137,7 +137,12 @@ def index_operation do
"Deprecated due to no support for pagination. Using [/api/v2/pleroma/chats](#operation/ChatController.index2) instead is recommended.",
operationId: "ChatController.index",
parameters: [
Operation.parameter(:with_muted, :query, BooleanLike, "Include chats from muted users")
Operation.parameter(
:with_muted,
:query,
BooleanLike.schema(),
"Include chats from muted users"
)
],
responses: %{
200 => Operation.response("The chats of the user", "application/json", chats_response())
@ -156,7 +161,12 @@ def index2_operation do
summary: "Retrieve list of chats",
operationId: "ChatController.index2",
parameters: [
Operation.parameter(:with_muted, :query, BooleanLike, "Include chats from muted users")
Operation.parameter(
:with_muted,
:query,
BooleanLike.schema(),
"Include chats from muted users"
)
| pagination_params()
],
responses: %{
@ -368,9 +378,9 @@ def mark_as_read do
title: "MarkAsReadRequest",
description: "POST body for marking a number of chat messages as read",
type: :object,
required: ["last_read_id"],
required: [:last_read_id],
properties: %{
"last_read_id" => %Schema{
last_read_id: %Schema{
type: :string,
description: "The content of your message."
}

View File

@ -29,7 +29,7 @@ def index_operation do
"Order by recent activity or account creation",
required: nil
),
Operation.parameter(:local, :query, BooleanLike, "Include local users only")
Operation.parameter(:local, :query, BooleanLike.schema(), "Include local users only")
] ++ pagination_params(),
responses: %{
200 =>

View File

@ -21,7 +21,7 @@ def index_operation do
summary:
"Get an object of emoji to account mappings with accounts that reacted to the post",
parameters: [
Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
Operation.parameter(:id, :path, FlakeID.schema(), "Status ID", required: true),
Operation.parameter(:emoji, :path, :string, "Filter by a single unicode emoji",
required: nil
),
@ -45,7 +45,7 @@ def create_operation do
tags: ["Emoji reactions"],
summary: "React to a post with a unicode emoji",
parameters: [
Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
Operation.parameter(:id, :path, FlakeID.schema(), "Status ID", required: true),
Operation.parameter(:emoji, :path, :string, "A single character unicode emoji",
required: true
)
@ -64,7 +64,7 @@ def delete_operation do
tags: ["Emoji reactions"],
summary: "Remove a reaction to a post with a unicode emoji",
parameters: [
Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
Operation.parameter(:id, :path, FlakeID.schema(), "Status ID", required: true),
Operation.parameter(:emoji, :path, :string, "A single character unicode emoji",
required: true
)

View File

@ -62,7 +62,7 @@ def index_operation do
Operation.parameter(
:with_muted,
:query,
BooleanLike,
BooleanLike.schema(),
"Include the notifications from muted users"
)
] ++ pagination_params(),

View File

@ -142,7 +142,7 @@ def birthdays_operation do
end
defp id_param do
Operation.parameter(:id, :path, FlakeID, "Account ID",
Operation.parameter(:id, :path, FlakeID.schema(), "Account ID",
example: "9umDrYheeY451cQnEe",
required: true
)

View File

@ -36,9 +36,9 @@ def create_operation do
defp create_request do
%Schema{
type: :object,
required: ["file"],
required: [:file],
properties: %{
"file" => %Schema{
file: %Schema{
description:
"File needs to be uploaded with the multipart request or link to remote file",
anyOf: [
@ -46,12 +46,12 @@ defp create_request do
%Schema{type: :string, format: :uri}
]
},
"shortcode" => %Schema{
shortcode: %Schema{
type: :string,
description:
"Shortcode for new emoji, must be unique for all emoji. If not sended, shortcode will be taken from original filename."
},
"filename" => %Schema{
filename: %Schema{
type: :string,
description:
"New emoji file name. If not specified will be taken from original filename."
@ -81,21 +81,21 @@ def update_operation do
defp update_request do
%Schema{
type: :object,
required: ["shortcode", "new_shortcode", "new_filename"],
required: [:shortcode, :new_shortcode, :new_filename],
properties: %{
"shortcode" => %Schema{
shortcode: %Schema{
type: :string,
description: "Emoji file shortcode"
},
"new_shortcode" => %Schema{
new_shortcode: %Schema{
type: :string,
description: "New emoji file shortcode"
},
"new_filename" => %Schema{
new_filename: %Schema{
type: :string,
description: "New filename for emoji file"
},
"force" => %Schema{
force: %Schema{
type: :boolean,
description: "With true value to overwrite existing emoji with new shortcode",
default: false

View File

@ -130,15 +130,15 @@ def download_operation do
defp download_request do
%Schema{
type: :object,
required: ["url", "name"],
required: [:url, :name],
properties: %{
"url" => %Schema{
url: %Schema{
type: :string,
format: :uri,
description: "URL of the instance to download from"
},
"name" => %Schema{type: :string, format: :uri, description: "Pack Name"},
"as" => %Schema{type: :string, format: :uri, description: "Save as"}
name: %Schema{type: :string, format: :uri, description: "Pack Name"},
as: %Schema{type: :string, format: :uri, description: "Save as"}
}
}
end
@ -302,7 +302,27 @@ defp files_object do
defp update_request do
%Schema{
type: :object,
properties: %{"metadata" => metadata()}
properties: %{
metadata: %Schema{
type: :object,
description: "Metadata to replace the old one",
properties: %{
license: %Schema{type: :string},
homepage: %Schema{type: :string, format: :uri},
description: %Schema{type: :string},
"fallback-src": %Schema{
type: :string,
format: :uri,
description: "Fallback url to download pack from"
},
"fallback-src-sha256": %Schema{
type: :string,
description: "SHA256 encoded for fallback pack archive"
},
"share-files": %Schema{type: :boolean, description: "Is pack allowed for sharing?"}
}
}
}
}
end

View File

@ -39,7 +39,7 @@ def update_operation do
%Schema{
type: :object,
properties: %{
"file" => %Schema{type: :string, format: :binary}
file: %Schema{type: :string, format: :binary}
}
},
required: true

View File

@ -24,11 +24,8 @@ def mark_as_read_operation do
request_body("Parameters", %Schema{
type: :object,
properties: %{
"id" => %Schema{type: :integer, description: "A single notification ID to read"},
"max_id" => %Schema{
type: :integer,
description: "Read all notifications up to this ID"
}
id: %Schema{type: :integer, description: "A single notification ID to read"},
max_id: %Schema{type: :integer, description: "Read all notifications up to this ID"}
}
}),
security: [%{"oAuth" => ["write:notifications"]}],

View File

@ -37,7 +37,7 @@ def quotes_operation do
end
def id_param do
Operation.parameter(:id, :path, FlakeID, "Status ID",
Operation.parameter(:id, :path, FlakeID.schema(), "Status ID",
example: "9umDrYheeY451cQnEe",
required: true
)

View File

@ -47,7 +47,7 @@ def vote_operation do
end
defp id_param do
Operation.parameter(:id, :path, FlakeID, "Poll ID",
Operation.parameter(:id, :path, FlakeID.schema(), "Poll ID",
example: "123",
required: true
)

View File

@ -88,7 +88,7 @@ def delete_operation do
end
defp id_param do
Operation.parameter(:id, :path, FlakeID, "Poll ID",
Operation.parameter(:id, :path, FlakeID.schema(), "Poll ID",
example: "123",
required: true
)

View File

@ -70,7 +70,7 @@ def search_operation do
Operation.parameter(
:account_id,
:query,
FlakeID,
FlakeID.schema(),
"If provided, statuses returned will be authored only by this account"
),
Operation.parameter(
@ -116,7 +116,7 @@ def search2_operation do
Operation.parameter(
:account_id,
:query,
FlakeID,
FlakeID.schema(),
"If provided, statuses returned will be authored only by this account"
),
Operation.parameter(

View File

@ -39,7 +39,7 @@ def index_operation do
Operation.parameter(
:with_muted,
:query,
BooleanLike,
BooleanLike.schema(),
"Include reactions from muted acccounts."
)
],
@ -82,7 +82,7 @@ def show_operation do
Operation.parameter(
:with_muted,
:query,
BooleanLike,
BooleanLike.schema(),
"Include reactions from muted acccounts."
)
],
@ -685,7 +685,7 @@ def poll_params do
end
def id_param do
Operation.parameter(:id, :path, FlakeID, "Status ID",
Operation.parameter(:id, :path, FlakeID.schema(), "Status ID",
example: "9umDrYheeY451cQnEe",
required: true
)

View File

@ -176,7 +176,12 @@ defp instance_param do
end
defp with_muted_param do
Operation.parameter(:with_muted, :query, BooleanLike, "Include activities by muted users")
Operation.parameter(
:with_muted,
:query,
BooleanLike.schema(),
"Include activities by muted users"
)
end
defp exclude_visibilities_param do

View File

@ -146,13 +146,13 @@ def update_notification_settings_operation do
Operation.parameter(
:block_from_strangers,
:query,
BooleanLike,
BooleanLike.schema(),
"blocks notifications from accounts you do not follow"
),
Operation.parameter(
:hide_notification_contents,
:query,
BooleanLike,
BooleanLike.schema(),
"removes the contents of a message from the push notification"
)
],
@ -404,10 +404,10 @@ defp remote_interaction_request do
title: "RemoteInteractionRequest",
description: "POST body for remote interaction",
type: :object,
required: ["ap_id", "profile"],
required: [:ap_id, :profile],
properties: %{
"ap_id" => %Schema{type: :string, description: "Profile or status ActivityPub ID"},
"profile" => %Schema{type: :string, description: "Remote profile webfinger"}
ap_id: %Schema{type: :string, description: "Profile or status ActivityPub ID"},
profile: %Schema{type: :string, description: "Remote profile webfinger"}
}
}
end

View File

@ -61,9 +61,9 @@ def mutes_operation do
defp import_request do
%Schema{
type: :object,
required: ["list"],
required: [:list],
properties: %{
"list" => %Schema{
list: %Schema{
description:
"STRING or FILE containing a whitespace-separated list of accounts to import.",
anyOf: [

View File

@ -93,10 +93,7 @@ def assign_account_by_id(conn, _) do
end
def try_render(conn, target, params) when is_binary(target) do
case render(conn, target, params) do
nil -> render_error(conn, :not_implemented, "Can't display this activity")
res -> res
end
render(conn, target, params)
end
def try_render(conn, _, _) do

View File

@ -472,7 +472,7 @@ def unblock(%{assigns: %{user: blocker, account: blocked}} = conn, _params) do
@doc "POST /api/v1/accounts/:id/note"
def note(
%{assigns: %{user: noter, account: target}, body_params: %{"comment" => comment}} = conn,
%{assigns: %{user: noter, account: target}, body_params: %{comment: comment}} = conn,
_params
) do
with {:ok, _user_note} <- UserNote.create(noter, target, comment) do
@ -513,7 +513,7 @@ def remove_from_followers(%{assigns: %{user: followed, account: follower}} = con
end
@doc "POST /api/v1/follows"
def follow_by_uri(%{body_params: %{"uri" => uri}} = conn, _) do
def follow_by_uri(%{body_params: %{uri: uri}} = conn, _) do
case User.get_cached_by_nickname(uri) do
%User{} = user ->
conn

View File

@ -8,7 +8,7 @@ defmodule Pleroma.Web.MastodonAPI.DomainBlockController do
alias Pleroma.User
alias Pleroma.Web.Plugs.OAuthScopesPlug
plug(Pleroma.Web.ApiSpec.CastAndValidate)
plug(Pleroma.Web.ApiSpec.CastAndValidate, replace_params: false)
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.DomainBlockOperation
plug(
@ -27,23 +27,31 @@ def index(%{assigns: %{user: user}} = conn, _) do
end
@doc "POST /api/v1/domain_blocks"
def create(%{assigns: %{user: blocker}, body_params: %{domain: domain}} = conn, _params) do
def create(
%{assigns: %{user: blocker}, private: %{open_api_spex: %{body_params: %{domain: domain}}}} =
conn,
_params
) do
User.block_domain(blocker, domain)
json(conn, %{})
end
def create(%{assigns: %{user: blocker}} = conn, %{domain: domain}) do
def create(%{assigns: %{user: blocker}} = conn, %{"domain" => domain}) do
User.block_domain(blocker, domain)
json(conn, %{})
end
@doc "DELETE /api/v1/domain_blocks"
def delete(%{assigns: %{user: blocker}, body_params: %{domain: domain}} = conn, _params) do
def delete(
%{assigns: %{user: blocker}, private: %{open_api_spex: %{body_params: %{domain: domain}}}} =
conn,
_params
) do
User.unblock_domain(blocker, domain)
json(conn, %{})
end
def delete(%{assigns: %{user: blocker}} = conn, %{domain: domain}) do
def delete(%{assigns: %{user: blocker}} = conn, %{"domain" => domain}) do
User.unblock_domain(blocker, domain)
json(conn, %{})
end

View File

@ -796,8 +796,6 @@ defp build_image_url(%URI{} = image_url_data, %URI{} = page_url_data) do
URI.merge(page_url_data, image_url_data) |> to_string
end
defp build_image_url(_, _), do: nil
defp get_source_text(%{"content" => content} = _source) do
content
end

View File

@ -56,7 +56,7 @@ defp handle_preview(conn, url) do
media_proxy_url = MediaProxy.url(url)
with {:ok, %{status: status} = head_response} when status in 200..299 <-
Pleroma.HTTP.request("HEAD", media_proxy_url, [], [], pool: :media) do
Pleroma.HTTP.request(:head, media_proxy_url, "", [], pool: :media) do
content_type = Tesla.get_header(head_response, "content-type")
content_length = Tesla.get_header(head_response, "content-length")
content_length = content_length && String.to_integer(content_length)

View File

@ -120,7 +120,7 @@ def mark_message_as_read(
end
def mark_as_read(
%{body_params: %{"last_read_id" => last_read_id}, assigns: %{user: user}} = conn,
%{body_params: %{last_read_id: last_read_id}, assigns: %{user: user}} = conn,
%{id: id}
) do
with {:ok, chat} <- Chat.get_by_user_and_id(user, id),

View File

@ -23,11 +23,11 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileController do
defdelegate open_api_operation(action), to: ApiSpec.PleromaEmojiFileOperation
def create(%{body_params: params} = conn, %{name: pack_name}) do
filename = params["filename"] || get_filename(params["file"])
shortcode = params["shortcode"] || Path.basename(filename, Path.extname(filename))
filename = params[:filename] || get_filename(params[:file])
shortcode = params[:shortcode] || Path.basename(filename, Path.extname(filename))
with {:ok, pack} <- Pack.load_pack(pack_name),
{:ok, file} <- get_file(params["file"]),
{:ok, file} <- get_file(params[:file]),
{:ok, pack} <- Pack.add_file(pack, shortcode, filename, file) do
json(conn, pack.files)
else
@ -49,10 +49,10 @@ def create(%{body_params: params} = conn, %{name: pack_name}) do
end
end
def update(%{body_params: %{"shortcode" => shortcode} = params} = conn, %{name: pack_name}) do
new_shortcode = params["new_shortcode"]
new_filename = params["new_filename"]
force = params["force"]
def update(%{body_params: %{shortcode: shortcode} = params} = conn, %{name: pack_name}) do
new_shortcode = params[:new_shortcode]
new_filename = params[:new_filename]
force = params[:force]
with {:ok, pack} <- Pack.load_pack(pack_name),
{:ok, pack} <- Pack.update_file(pack, shortcode, new_shortcode, new_filename, force) do
@ -128,9 +128,9 @@ defp handle_error(conn, {:error, error}, opts) do
defp get_filename(%Plug.Upload{filename: filename}), do: filename
defp get_filename(url) when is_binary(url), do: Path.basename(url)
defp get_file(%Plug.Upload{} = file), do: {:ok, file}
def get_file(%Plug.Upload{} = file), do: {:ok, file}
defp get_file(url) when is_binary(url) do
def get_file(url) when is_binary(url) do
with {:ok, %Tesla.Env{body: body, status: code, headers: headers}}
when code in 200..299 <- Pleroma.HTTP.get(url) do
path = Plug.Upload.random_file!("emoji")

View File

@ -109,8 +109,8 @@ def archive(conn, %{name: name}) do
end
end
def download(%{body_params: %{"url" => url, "name" => name} = params} = conn, _) do
with {:ok, _pack} <- Pack.download(name, url, params["as"]) do
def download(%{body_params: %{url: url, name: name} = params} = conn, _) do
with {:ok, _pack} <- Pack.download(name, url, params[:as]) do
json(conn, "ok")
else
{:error, :not_shareable} ->
@ -184,7 +184,7 @@ def delete(conn, %{name: name}) do
end
end
def update(%{body_params: %{"metadata" => metadata}} = conn, %{name: name}) do
def update(%{body_params: %{metadata: metadata}} = conn, %{name: name}) do
with {:ok, pack} <- Pack.update_metadata(name, metadata) do
json(conn, pack.pack)
else

View File

@ -22,9 +22,9 @@ def show(%{assigns: %{user: user}} = conn, _params) do
end
@doc "PUT /api/v1/pleroma/mascot"
def update(%{assigns: %{user: user}, body_params: %{"file" => file}} = conn, _) do
with {_, "image" <> _} <- {:content_type, file.content_type},
{_, {:ok, object}} <- {:upload, ActivityPub.upload(file, actor: User.ap_id(user))} do
def update(%{assigns: %{user: user}, body_params: %{file: file}} = conn, _) do
with {:content_type, "image" <> _} <- {:content_type, file.content_type},
{:ok, object} <- ActivityPub.upload(file, actor: User.ap_id(user)) do
attachment = render_attachment(object)
{:ok, _user} = User.mascot_update(user, attachment)

View File

@ -16,7 +16,7 @@ defmodule Pleroma.Web.PleromaAPI.NotificationController do
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaNotificationOperation
def mark_as_read(%{assigns: %{user: user}, body_params: %{"id" => notification_id}} = conn, _) do
def mark_as_read(%{assigns: %{user: user}, body_params: %{id: notification_id}} = conn, _) do
with {:ok, notification} <- Notification.read_one(user, notification_id) do
render(conn, "show.json", notification: notification, for: user)
else
@ -27,7 +27,7 @@ def mark_as_read(%{assigns: %{user: user}, body_params: %{"id" => notification_i
end
end
def mark_as_read(%{assigns: %{user: user}, body_params: %{"max_id" => max_id}} = conn, _) do
def mark_as_read(%{assigns: %{user: user}, body_params: %{max_id: max_id}} = conn, _) do
notifications =
user
|> Notification.set_read_up_to(max_id)

View File

@ -18,11 +18,11 @@ defmodule Pleroma.Web.PleromaAPI.UserImportController do
plug(Pleroma.Web.ApiSpec.CastAndValidate)
defdelegate open_api_operation(action), to: ApiSpec.UserImportOperation
def follow(%{body_params: %{"list" => %Plug.Upload{path: path}}} = conn, _) do
follow(%Plug.Conn{conn | body_params: %{"list" => File.read!(path)}}, %{})
def follow(%{body_params: %{list: %Plug.Upload{path: path}}} = conn, _) do
follow(%Plug.Conn{conn | body_params: %{list: File.read!(path)}}, %{})
end
def follow(%{assigns: %{user: follower}, body_params: %{"list" => list}} = conn, _) do
def follow(%{assigns: %{user: follower}, body_params: %{list: list}} = conn, _) do
identifiers =
list
|> String.split("\n")
@ -35,20 +35,20 @@ def follow(%{assigns: %{user: follower}, body_params: %{"list" => list}} = conn,
json(conn, "job started")
end
def blocks(%{body_params: %{"list" => %Plug.Upload{path: path}}} = conn, _) do
blocks(%Plug.Conn{conn | body_params: %{"list" => File.read!(path)}}, %{})
def blocks(%{body_params: %{list: %Plug.Upload{path: path}}} = conn, _) do
blocks(%Plug.Conn{conn | body_params: %{list: File.read!(path)}}, %{})
end
def blocks(%{assigns: %{user: blocker}, body_params: %{"list" => list}} = conn, _) do
def blocks(%{assigns: %{user: blocker}, body_params: %{list: list}} = conn, _) do
User.Import.blocks_import(blocker, prepare_user_identifiers(list))
json(conn, "job started")
end
def mutes(%{body_params: %{"list" => %Plug.Upload{path: path}}} = conn, _) do
mutes(%Plug.Conn{conn | body_params: %{"list" => File.read!(path)}}, %{})
def mutes(%{body_params: %{list: %Plug.Upload{path: path}}} = conn, _) do
mutes(%Plug.Conn{conn | body_params: %{list: File.read!(path)}}, %{})
end
def mutes(%{assigns: %{user: user}, body_params: %{"list" => list}} = conn, _) do
def mutes(%{assigns: %{user: user}, body_params: %{list: list}} = conn, _) do
User.Import.mutes_import(user, prepare_user_identifiers(list))
json(conn, "job started")
end

View File

@ -150,10 +150,7 @@ def remote_subscribe(conn, %{"status" => %{"status_id" => id, "profile" => profi
end
end
def remote_interaction(
%{body_params: %{"ap_id" => ap_id, "profile" => profile}} = conn,
_params
) do
def remote_interaction(%{body_params: %{ap_id: ap_id, profile: profile}} = conn, _params) do
with {:ok, %{"subscribe_address" => template}} <- WebFinger.finger(profile) do
conn
|> json(%{url: String.replace(template, "{uri}", ap_id)})

View File

@ -88,7 +88,7 @@
"nodex": {:git, "https://git.pleroma.social/pleroma/nodex", "cb6730f943cfc6aad674c92161be23a8411f15d1", [ref: "cb6730f943cfc6aad674c92161be23a8411f15d1"]},
"oban": {:hex, :oban, "2.13.6", "a0cb1bce3bd393770512231fb5a3695fa19fd3af10d7575bf73f837aee7abf43", [:mix], [{:ecto_sql, "~> 3.6", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3c1c5eb16f377b3cbbf2ea14be24d20e3d91285af9d1ac86260b7c2af5464887"},
"octo_fetch": {:hex, :octo_fetch, "0.4.0", "074b5ecbc08be10b05b27e9db08bc20a3060142769436242702931c418695b19", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "cf8be6f40cd519d7000bb4e84adcf661c32e59369ca2827c4e20042eda7a7fc6"},
"open_api_spex": {:hex, :open_api_spex, "3.18.1", "0a73cd5dbcba7d32952dd9738c6819892933d9bae1642f04c9f200281524dd31", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 3.0 or ~> 4.0 or ~> 5.0", [hex: :poison, repo: "hexpm", optional: true]}, {:ymlr, "~> 2.0 or ~> 3.0 or ~> 4.0", [hex: :ymlr, repo: "hexpm", optional: true]}], "hexpm", "f52933cddecca675e42ead660379ae2d3853f57f5a35d201eaed85e2e81517d1"},
"open_api_spex": {:hex, :open_api_spex, "3.18.2", "8c855e83bfe8bf81603d919d6e892541eafece3720f34d1700b58024dadde247", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 3.0 or ~> 4.0 or ~> 5.0", [hex: :poison, repo: "hexpm", optional: true]}, {:ymlr, "~> 2.0 or ~> 3.0 or ~> 4.0", [hex: :ymlr, repo: "hexpm", optional: true]}], "hexpm", "aa3e6dcfc0ad6a02596b2172662da21c9dd848dac145ea9e603f54e3d81b8d2b"},
"parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"},
"pbkdf2_elixir": {:hex, :pbkdf2_elixir, "1.2.1", "9cbe354b58121075bd20eb83076900a3832324b7dd171a6895fab57b6bb2752c", [:mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}], "hexpm", "d3b40a4a4630f0b442f19eca891fcfeeee4c40871936fed2f68e1c4faa30481f"},
"phoenix": {:hex, :phoenix, "1.7.10", "02189140a61b2ce85bb633a9b6fd02dff705a5f1596869547aeb2b2b95edd729", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "cf784932e010fd736d656d7fead6a584a4498efefe5b8227e9f383bf15bb79d0"},

View File

@ -873,7 +873,7 @@ test "tuples with more than two values", %{conn: conn} do
%{
"tuple" => [
":_",
"Plug.Cowboy.Handler",
"Phoenix.Endpoint.Cowboy2Handler",
%{"tuple" => ["Pleroma.Web.Endpoint", []]}
]
}
@ -937,7 +937,7 @@ test "tuples with more than two values", %{conn: conn} do
%{
"tuple" => [
":_",
"Plug.Cowboy.Handler",
"Phoenix.Endpoint.Cowboy2Handler",
%{"tuple" => ["Pleroma.Web.Endpoint", []]}
]
}

View File

@ -182,7 +182,7 @@ test "responds with 424 Failed Dependency if HEAD request to media proxy fails",
media_proxy_url: media_proxy_url
} do
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 500, body: ""}
end)
@ -197,7 +197,7 @@ test "redirects to media proxy URI on unsupported content type", %{
media_proxy_url: media_proxy_url
} do
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "application/pdf"}]}
end)
@ -217,7 +217,7 @@ test "with `static=true` and GIF image preview requested, responds with JPEG ima
clear_config([:media_preview_proxy, :min_content_length], 1_000_000_000)
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{
status: 200,
body: "",
@ -242,7 +242,7 @@ test "with GIF image preview requested and no `static` param, redirects to media
media_proxy_url: media_proxy_url
} do
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/gif"}]}
end)
@ -260,7 +260,7 @@ test "with `static` param and non-GIF image preview requested, " <>
media_proxy_url: media_proxy_url
} do
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/jpeg"}]}
end)
@ -280,7 +280,7 @@ test "with :min_content_length setting not matched by Content-Length header, " <
clear_config([:media_preview_proxy, :min_content_length], 100_000)
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{
status: 200,
body: "",
@ -302,7 +302,7 @@ test "thumbnails PNG images into PNG", %{
assert_dependencies_installed()
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/png"}]}
%{method: :get, url: ^media_proxy_url} ->
@ -324,7 +324,7 @@ test "thumbnails JPEG images into JPEG", %{
assert_dependencies_installed()
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/jpeg"}]}
%{method: :get, url: ^media_proxy_url} ->
@ -344,7 +344,7 @@ test "redirects to media proxy URI in case of thumbnailing error", %{
media_proxy_url: media_proxy_url
} do
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/jpeg"}]}
%{method: :get, url: ^media_proxy_url} ->