1
0
Fork 0
forked from mirrors/akkoma

Enable AnonymizeFilenames on all uploads

This commit is contained in:
FloatingGhost 2023-08-04 15:37:15 +01:00
parent 1a88d9278b
commit 0b2ec0ccee
3 changed files with 21 additions and 11 deletions

View file

@ -16,6 +16,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- other distributions are stable only - other distributions are stable only
- Support for Elixir 1.15 - Support for Elixir 1.15
- 1.14 is still supported - 1.14 is still supported
- OTP26 is currently "unsupported". It will probably work, but due to the way
it handles map ordering, the test suite will not pass for it as yet.
## Changed ## Changed
@ -25,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
If you use debian OTP builds you will have to update your local system to If you use debian OTP builds you will have to update your local system to
bookworm (currently: stable). bookworm (currently: stable).
- Blocks/Mutes now return from max ID to min ID, in line with mastodon. - Blocks/Mutes now return from max ID to min ID, in line with mastodon.
- The AnonymizeFilename filter is now enabled by default.
## Fixed ## Fixed

View file

@ -63,6 +63,9 @@ defmodule Pleroma.Upload do
blurhash: String.t(), blurhash: String.t(),
path: String.t() path: String.t()
} }
@always_enabled_filters [Pleroma.Upload.Filter.AnonymizeFilename]
defstruct [:id, :name, :tempfile, :content_type, :width, :height, :blurhash, :path] defstruct [:id, :name, :tempfile, :content_type, :width, :height, :blurhash, :path]
@spec store(source, options :: [option()]) :: {:ok, Map.t()} | {:error, any()} @spec store(source, options :: [option()]) :: {:ok, Map.t()} | {:error, any()}
@ -132,7 +135,11 @@ defp get_opts(opts) do
activity_type: Keyword.get(opts, :activity_type, activity_type), activity_type: Keyword.get(opts, :activity_type, activity_type),
size_limit: Keyword.get(opts, :size_limit, size_limit), size_limit: Keyword.get(opts, :size_limit, size_limit),
uploader: Keyword.get(opts, :uploader, Pleroma.Config.get([__MODULE__, :uploader])), uploader: Keyword.get(opts, :uploader, Pleroma.Config.get([__MODULE__, :uploader])),
filters: Keyword.get(opts, :filters, Pleroma.Config.get([__MODULE__, :filters])), filters:
Enum.uniq(
Keyword.get(opts, :filters, Pleroma.Config.get([__MODULE__, :filters])) ++
@always_enabled_filters
),
description: Keyword.get(opts, :description), description: Keyword.get(opts, :description),
base_url: base_url() base_url: base_url()
} }

View file

@ -1784,21 +1784,21 @@ test "getting a list of mutes" do
|> get("/api/v1/mutes") |> get("/api/v1/mutes")
|> json_response_and_validate_schema(200) |> json_response_and_validate_schema(200)
assert [id1, id2, id3] == Enum.map(result, & &1["id"]) assert [id3, id2, id1] == Enum.map(result, & &1["id"])
result = result =
conn conn
|> get("/api/v1/mutes?limit=1") |> get("/api/v1/mutes?limit=1")
|> json_response_and_validate_schema(200) |> json_response_and_validate_schema(200)
assert [%{"id" => ^id1}] = result assert [%{"id" => ^id3}] = result
result = result =
conn conn
|> get("/api/v1/mutes?since_id=#{id1}") |> get("/api/v1/mutes?since_id=#{id1}")
|> json_response_and_validate_schema(200) |> json_response_and_validate_schema(200)
assert [%{"id" => ^id2}, %{"id" => ^id3}] = result assert [%{"id" => ^id3}, %{"id" => ^id2}] = result
result = result =
conn conn
@ -1812,7 +1812,7 @@ test "getting a list of mutes" do
|> get("/api/v1/mutes?since_id=#{id1}&limit=1") |> get("/api/v1/mutes?since_id=#{id1}&limit=1")
|> json_response_and_validate_schema(200) |> json_response_and_validate_schema(200)
assert [%{"id" => ^id2}] = result assert [%{"id" => ^id3}] = result
end end
test "list of mutes with with_relationships parameter" do test "list of mutes with with_relationships parameter" do
@ -1831,7 +1831,7 @@ test "list of mutes with with_relationships parameter" do
assert [ assert [
%{ %{
"id" => ^id1, "id" => ^id3,
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}} "pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
}, },
%{ %{
@ -1839,7 +1839,7 @@ test "list of mutes with with_relationships parameter" do
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}} "pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
}, },
%{ %{
"id" => ^id3, "id" => ^id1,
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}} "pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
} }
] = ] =
@ -1864,7 +1864,7 @@ test "getting a list of blocks" do
|> get("/api/v1/blocks") |> get("/api/v1/blocks")
|> json_response_and_validate_schema(200) |> json_response_and_validate_schema(200)
assert [id1, id2, id3] == Enum.map(result, & &1["id"]) assert [id3, id2, id1] == Enum.map(result, & &1["id"])
result = result =
conn conn
@ -1872,7 +1872,7 @@ test "getting a list of blocks" do
|> get("/api/v1/blocks?limit=1") |> get("/api/v1/blocks?limit=1")
|> json_response_and_validate_schema(200) |> json_response_and_validate_schema(200)
assert [%{"id" => ^id1}] = result assert [%{"id" => ^id3}] = result
result = result =
conn conn
@ -1880,7 +1880,7 @@ test "getting a list of blocks" do
|> get("/api/v1/blocks?since_id=#{id1}") |> get("/api/v1/blocks?since_id=#{id1}")
|> json_response_and_validate_schema(200) |> json_response_and_validate_schema(200)
assert [%{"id" => ^id2}, %{"id" => ^id3}] = result assert [%{"id" => ^id3}, %{"id" => ^id2}] = result
result = result =
conn conn
@ -1896,7 +1896,7 @@ test "getting a list of blocks" do
|> get("/api/v1/blocks?since_id=#{id1}&limit=1") |> get("/api/v1/blocks?since_id=#{id1}&limit=1")
|> json_response_and_validate_schema(200) |> json_response_and_validate_schema(200)
assert [%{"id" => ^id2}] = result assert [%{"id" => ^id3}] = result
end end
test "list of blocks with with_relationships parameter" do test "list of blocks with with_relationships parameter" do