Add a setup question asking if the user wants to use AnalyzeMetadata

This commit is contained in:
itepechi 2023-09-27 05:32:18 +09:00
parent 7f9d011076
commit 3b7ef1bad8
1 changed files with 30 additions and 2 deletions

View File

@ -38,7 +38,8 @@ defmodule Mix.Tasks.Pleroma.Instance do
listen_port: :string,
strip_uploads: :string,
anonymize_uploads: :string,
dedupe_uploads: :string
dedupe_uploads: :string,
analyze_uploads: :string
],
aliases: [
o: :output,
@ -216,6 +217,25 @@ defmodule Mix.Tasks.Pleroma.Instance do
"n"
) === "y"
{analyze_uploads_message, analyze_uploads_default} =
if Enum.all?(["mogrify", "convert", "ffprobe"], fn x ->
Pleroma.Utils.command_available?(x)
end) do
{"Do you want to analyse the metadata of uploaded media and generate blurry thumbnails of sensitive images? This depends on Imagemagick and FFmpeg, which are detected as already installed. (y/n)",
"y"}
else
{"Do you want to analyse the metadata of uploaded media and generate blurry thumbnails of sensitive images? This depends on Imagemagick and FFmpeg, which are detected as missing. (y/n)",
"n"}
end
analyze_uploads =
get_option(
options,
:analyze_uploads,
analyze_uploads_message,
analyze_uploads_default
) === "y"
Config.put([:instance, :static_dir], static_dir)
secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
@ -258,7 +278,8 @@ defmodule Mix.Tasks.Pleroma.Instance do
upload_filters(%{
strip: strip_uploads,
anonymize: anonymize_uploads,
dedupe: dedupe_uploads
dedupe: dedupe_uploads,
analyze: analyze_uploads
})
)
@ -354,6 +375,13 @@ defmodule Mix.Tasks.Pleroma.Instance do
enabled_filters
end
enabled_filters =
if filters.analyze do
enabled_filters ++ [Pleroma.Upload.Filter.AnalyzeMetadata]
else
enabled_filters
end
enabled_filters
end
end