feat(instance): enable Exif upload filters without exiftool check

This commit is contained in:
Lain Soykaf 2026-10-27 17:29:44 +04:00
commit df280b1d6b
No known key found for this signature in database
3 changed files with 9 additions and 27 deletions

View file

@ -37,8 +37,8 @@ If any of the options are left unspecified, you will be prompted interactively.
- `--static-dir <path>` - the directory custom public files should be read from (custom emojis, frontend bundle overrides, robots.txt, etc.) - `--static-dir <path>` - the directory custom public files should be read from (custom emojis, frontend bundle overrides, robots.txt, etc.)
- `--listen-ip <ip>` - the ip the app should listen to, defaults to 127.0.0.1 - `--listen-ip <ip>` - the ip the app should listen to, defaults to 127.0.0.1
- `--listen-port <port>` - the port the app should listen to, defaults to 4000 - `--listen-port <port>` - the port the app should listen to, defaults to 4000
- `--strip-uploads-location <Y|N>` - use ExifTool to strip uploads of sensitive location data - `--strip-uploads-location <Y|N>` - strip sensitive location data from uploaded images
- `--read-uploads-description <Y|N>` - use ExifTool to read image descriptions from uploads - `--read-uploads-description <Y|N>` - read image descriptions from upload metadata
- `--anonymize-uploads <Y|N>` - randomize uploaded filenames - `--anonymize-uploads <Y|N>` - randomize uploaded filenames
- `--dedupe-uploads <Y|N>` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames - `--dedupe-uploads <Y|N>` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames
- `--skip-release-env` - skip generation the release environment file - `--skip-release-env` - skip generation the release environment file

View file

@ -162,38 +162,20 @@ defmodule Mix.Tasks.Pleroma.Instance do
) )
|> Path.expand() |> Path.expand()
{strip_uploads_location_message, strip_uploads_location_default} =
if Pleroma.Utils.command_available?("exiftool") do
{"Do you want to strip location (GPS) data from uploaded images? This requires exiftool, it was detected as installed. (y/n)",
"y"}
else
{"Do you want to strip location (GPS) data from uploaded images? This requires exiftool, it was detected as not installed, please install it if you answer yes. (y/n)",
"n"}
end
strip_uploads_location = strip_uploads_location =
get_option( get_option(
options, options,
:strip_uploads_location, :strip_uploads_location,
strip_uploads_location_message, "Do you want to strip location (GPS) data from uploaded images? (y/n)",
strip_uploads_location_default "y"
) === "y" ) === "y"
{read_uploads_description_message, read_uploads_description_default} =
if Pleroma.Utils.command_available?("exiftool") do
{"Do you want to read data from uploaded files so clients can use it to prefill fields like image description? This requires exiftool, it was detected as installed. (y/n)",
"y"}
else
{"Do you want to read data from uploaded files so clients can use it to prefill fields like image description? This requires exiftool, it was detected as not installed, please install it if you answer yes. (y/n)",
"n"}
end
read_uploads_description = read_uploads_description =
get_option( get_option(
options, options,
:read_uploads_description, :read_uploads_description,
read_uploads_description_message, "Do you want to read metadata from uploaded images so clients can prefill the media description field? (y/n)",
read_uploads_description_default "y"
) === "y" ) === "y"
anonymize_uploads = anonymize_uploads =
@ -324,14 +306,14 @@ defmodule Mix.Tasks.Pleroma.Instance do
defp upload_filters(filters) when is_map(filters) do defp upload_filters(filters) when is_map(filters) do
enabled_filters = enabled_filters =
if filters.strip_location do if filters.strip_location do
[Pleroma.Upload.Filter.Exiftool.StripLocation] [Pleroma.Upload.Filter.Exif.StripLocation]
else else
[] []
end end
enabled_filters = enabled_filters =
if filters.read_description do if filters.read_description do
enabled_filters ++ [Pleroma.Upload.Filter.Exiftool.ReadDescription] enabled_filters ++ [Pleroma.Upload.Filter.Exif.ReadDescription]
else else
enabled_filters enabled_filters
end end

View file

@ -95,7 +95,7 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
assert generated_config =~ "http: [ip: {127, 0, 0, 1}, port: 4000]" assert generated_config =~ "http: [ip: {127, 0, 0, 1}, port: 4000]"
assert generated_config =~ assert generated_config =~
"filters: [Pleroma.Upload.Filter.Exiftool.StripLocation, Pleroma.Upload.Filter.Exiftool.ReadDescription]" "filters: [Pleroma.Upload.Filter.Exif.StripLocation, Pleroma.Upload.Filter.Exif.ReadDescription]"
assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql() assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()
assert File.exists?(Path.expand("./test/instance/static/robots.txt")) assert File.exists?(Path.expand("./test/instance/static/robots.txt"))