mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-09 17:55:11 +00:00
Merge branch '2064-image-blanking' into 'develop'
Resolve "Make default image description blank" Closes #2064 See merge request pleroma/pleroma!2899
This commit is contained in:
commit
3d5d8c05c9
|
@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
## [unreleased]
|
||||
|
||||
### Changed
|
||||
- **Breaking:** The default descriptions on uploads are now empty. The old behavior (filename as default) can be configured, see the cheat sheet.
|
||||
- **Breaking:** Added the ObjectAgePolicy to the default set of MRFs. This will delist and strip the follower collection of any message received that is older than 7 days. This will stop users from seeing very old messages in the timelines. The messages can still be viewed on the user's page and in conversations. They also still trigger notifications.
|
||||
- **Breaking:** Elixir >=1.9 is now required (was >= 1.8)
|
||||
- **Breaking:** Configuration: `:auto_linker, :opts` moved to `:pleroma, Pleroma.Formatter`. Old config namespace is deprecated.
|
||||
|
|
|
@ -72,7 +72,8 @@ config :pleroma, Pleroma.Upload,
|
|||
pool: :upload
|
||||
]
|
||||
],
|
||||
filename_display_max_length: 30
|
||||
filename_display_max_length: 30,
|
||||
default_description: nil
|
||||
|
||||
config :pleroma, Pleroma.Uploaders.Local, uploads: "uploads"
|
||||
|
||||
|
|
|
@ -21,7 +21,10 @@ config :logger, :console,
|
|||
|
||||
config :pleroma, :auth, oauth_consumer_strategies: []
|
||||
|
||||
config :pleroma, Pleroma.Upload, filters: [], link_name: false
|
||||
config :pleroma, Pleroma.Upload,
|
||||
filters: [],
|
||||
link_name: false,
|
||||
default_description: :filename
|
||||
|
||||
config :pleroma, Pleroma.Uploaders.Local, uploads: "test/uploads"
|
||||
|
||||
|
|
|
@ -552,6 +552,7 @@ the source code is here: [kocaptcha](https://github.com/koto-bank/kocaptcha). Th
|
|||
* `proxy_remote`: If you're using a remote uploader, Pleroma will proxy media requests instead of redirecting to it.
|
||||
* `proxy_opts`: Proxy options, see `Pleroma.ReverseProxy` documentation.
|
||||
* `filename_display_max_length`: Set max length of a filename to display. 0 = no limit. Default: 30.
|
||||
* `default_description`: Sets which default description an image has if none is set explicitly. Options: nil (default) - Don't set a default, :filename - use the filename of the file, a string (e.g. "attachment") - Use this string
|
||||
|
||||
!!! warning
|
||||
`strip_exif` has been replaced by `Pleroma.Upload.Filter.Mogrify`.
|
||||
|
|
|
@ -56,6 +56,15 @@ defmodule Pleroma.Upload do
|
|||
}
|
||||
defstruct [:id, :name, :tempfile, :content_type, :path]
|
||||
|
||||
defp get_description(opts, upload) do
|
||||
case {opts[:description], Pleroma.Config.get([Pleroma.Upload, :default_description])} do
|
||||
{description, _} when is_binary(description) -> description
|
||||
{_, :filename} -> upload.name
|
||||
{_, str} when is_binary(str) -> str
|
||||
_ -> ""
|
||||
end
|
||||
end
|
||||
|
||||
@spec store(source, options :: [option()]) :: {:ok, Map.t()} | {:error, any()}
|
||||
def store(upload, opts \\ []) do
|
||||
opts = get_opts(opts)
|
||||
|
@ -63,7 +72,7 @@ defmodule Pleroma.Upload do
|
|||
with {:ok, upload} <- prepare_upload(upload, opts),
|
||||
upload = %__MODULE__{upload | path: upload.path || "#{upload.id}/#{upload.name}"},
|
||||
{:ok, upload} <- Pleroma.Upload.Filter.filter(opts.filters, upload),
|
||||
description = Map.get(opts, :description) || upload.name,
|
||||
description = get_description(opts, upload),
|
||||
{_, true} <-
|
||||
{:description_limit,
|
||||
String.length(description) <= Pleroma.Config.get([:instance, :description_limit])},
|
||||
|
|
|
@ -990,13 +990,39 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
end
|
||||
|
||||
describe "uploading files" do
|
||||
test "copies the file to the configured folder" do
|
||||
file = %Plug.Upload{
|
||||
setup do
|
||||
test_file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
%{test_file: test_file}
|
||||
end
|
||||
|
||||
test "sets a description if given", %{test_file: file} do
|
||||
{:ok, %Object{} = object} = ActivityPub.upload(file, description: "a cool file")
|
||||
assert object.data["name"] == "a cool file"
|
||||
end
|
||||
|
||||
test "it sets the default description depending on the configuration", %{test_file: file} do
|
||||
clear_config([Pleroma.Upload, :default_description])
|
||||
|
||||
Pleroma.Config.put([Pleroma.Upload, :default_description], nil)
|
||||
{:ok, %Object{} = object} = ActivityPub.upload(file)
|
||||
assert object.data["name"] == ""
|
||||
|
||||
Pleroma.Config.put([Pleroma.Upload, :default_description], :filename)
|
||||
{:ok, %Object{} = object} = ActivityPub.upload(file)
|
||||
assert object.data["name"] == "an_image.jpg"
|
||||
|
||||
Pleroma.Config.put([Pleroma.Upload, :default_description], "unnamed attachment")
|
||||
{:ok, %Object{} = object} = ActivityPub.upload(file)
|
||||
assert object.data["name"] == "unnamed attachment"
|
||||
end
|
||||
|
||||
test "copies the file to the configured folder", %{test_file: file} do
|
||||
clear_config([Pleroma.Upload, :default_description], :filename)
|
||||
{:ok, %Object{} = object} = ActivityPub.upload(file)
|
||||
assert object.data["name"] == "an_image.jpg"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue