Rename the new module
This commit is contained in:
parent
cd316d7269
commit
551721e41a
|
@ -633,9 +633,9 @@ This filter only strips the GPS and location metadata with Exiftool leaving colo
|
||||||
|
|
||||||
No specific configuration.
|
No specific configuration.
|
||||||
|
|
||||||
#### Pleroma.Upload.Filter.ExiftoolReadData
|
#### Pleroma.Upload.Filter.Exiftool.ReadDescription
|
||||||
|
|
||||||
This filter only reads metadata with Exiftool so clients can prefill the media description field.
|
This filter reads the ImageDescription and iptc:Caption-Abstract fields with Exiftool so clients can prefill the media description field.
|
||||||
|
|
||||||
No specific configuration.
|
No specific configuration.
|
||||||
|
|
||||||
|
|
|
@ -30,4 +30,4 @@ It is required for the following Pleroma features:
|
||||||
|
|
||||||
It is required for the following Pleroma features:
|
It is required for the following Pleroma features:
|
||||||
* `Pleroma.Upload.Filters.Exiftool` upload filter (related config: `Plaroma.Upload/filters` in `config/config.exs`)
|
* `Pleroma.Upload.Filters.Exiftool` upload filter (related config: `Plaroma.Upload/filters` in `config/config.exs`)
|
||||||
* `Pleroma.Upload.Filters.ExiftoolReadData` upload filter (related config: `Plaroma.Upload/filters` in `config/config.exs`)
|
* `Pleroma.Upload.Filters.Exiftool.ReadDescription` upload filter (related config: `Plaroma.Upload/filters` in `config/config.exs`)
|
||||||
|
|
|
@ -35,7 +35,7 @@ def run(["gen" | rest]) do
|
||||||
listen_ip: :string,
|
listen_ip: :string,
|
||||||
listen_port: :string,
|
listen_port: :string,
|
||||||
strip_uploads: :string,
|
strip_uploads: :string,
|
||||||
read_uploads_data: :string,
|
read_uploads_description: :string,
|
||||||
anonymize_uploads: :string,
|
anonymize_uploads: :string,
|
||||||
dedupe_uploads: :string
|
dedupe_uploads: :string
|
||||||
],
|
],
|
||||||
|
@ -179,7 +179,7 @@ def run(["gen" | rest]) do
|
||||||
strip_uploads_default
|
strip_uploads_default
|
||||||
) === "y"
|
) === "y"
|
||||||
|
|
||||||
{read_uploads_data_message, read_uploads_data_default} =
|
{read_uploads_description_message, read_uploads_description_default} =
|
||||||
if Pleroma.Utils.command_available?("exiftool") do
|
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)",
|
{"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"}
|
"y"}
|
||||||
|
@ -188,12 +188,12 @@ def run(["gen" | rest]) do
|
||||||
"n"}
|
"n"}
|
||||||
end
|
end
|
||||||
|
|
||||||
read_uploads_data =
|
read_uploads_description =
|
||||||
get_option(
|
get_option(
|
||||||
options,
|
options,
|
||||||
:read_uploads_data,
|
:read_uploads_description,
|
||||||
read_uploads_data_message,
|
read_uploads_description_message,
|
||||||
read_uploads_data_default
|
read_uploads_description_default
|
||||||
) === "y"
|
) === "y"
|
||||||
|
|
||||||
anonymize_uploads =
|
anonymize_uploads =
|
||||||
|
@ -248,7 +248,7 @@ def run(["gen" | rest]) do
|
||||||
upload_filters:
|
upload_filters:
|
||||||
upload_filters(%{
|
upload_filters(%{
|
||||||
strip: strip_uploads,
|
strip: strip_uploads,
|
||||||
read_data: read_uploads_data,
|
read_description: read_uploads_description,
|
||||||
anonymize: anonymize_uploads,
|
anonymize: anonymize_uploads,
|
||||||
dedupe: dedupe_uploads
|
dedupe: dedupe_uploads
|
||||||
})
|
})
|
||||||
|
@ -323,8 +323,8 @@ defp upload_filters(filters) when is_map(filters) do
|
||||||
end
|
end
|
||||||
|
|
||||||
enabled_filters =
|
enabled_filters =
|
||||||
if filters.read_data do
|
if filters.read_description do
|
||||||
enabled_filters ++ [Pleroma.Upload.Filter.ExiftoolReadData]
|
enabled_filters ++ [Pleroma.Upload.Filter.Exiftool.ReadDescription]
|
||||||
else
|
else
|
||||||
enabled_filters
|
enabled_filters
|
||||||
end
|
end
|
||||||
|
|
|
@ -165,7 +165,7 @@ defp do_check_rum!(setting, migrate) do
|
||||||
defp check_system_commands!(:ok) do
|
defp check_system_commands!(:ok) do
|
||||||
filter_commands_statuses = [
|
filter_commands_statuses = [
|
||||||
check_filter(Pleroma.Upload.Filter.Exiftool, "exiftool"),
|
check_filter(Pleroma.Upload.Filter.Exiftool, "exiftool"),
|
||||||
check_filter(Pleroma.Upload.Filter.ExiftoolReadData, "exiftool"),
|
check_filter(Pleroma.Upload.Filter.Exiftool.ReadDescription, "exiftool"),
|
||||||
check_filter(Pleroma.Upload.Filter.Mogrify, "mogrify"),
|
check_filter(Pleroma.Upload.Filter.Mogrify, "mogrify"),
|
||||||
check_filter(Pleroma.Upload.Filter.Mogrifun, "mogrify"),
|
check_filter(Pleroma.Upload.Filter.Mogrifun, "mogrify"),
|
||||||
check_filter(Pleroma.Upload.Filter.AnalyzeMetadata, "mogrify"),
|
check_filter(Pleroma.Upload.Filter.AnalyzeMetadata, "mogrify"),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Upload.Filter.ExiftoolReadData do
|
defmodule Pleroma.Upload.Filter.Exiftool.ReadDescription do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Gets the description from the related EXIF tags and provides them in the response if no description is provided yet.
|
Gets the description from the related EXIF tags and provides them in the response if no description is provided yet.
|
||||||
It will first check ImageDescription, when that's too long or empty, it will check iptc:Caption-Abstract.
|
It will first check ImageDescription, when that's too long or empty, it will check iptc:Caption-Abstract.
|
|
@ -69,7 +69,7 @@ test "running gen" do
|
||||||
"./test/../test/instance/static/",
|
"./test/../test/instance/static/",
|
||||||
"--strip-uploads",
|
"--strip-uploads",
|
||||||
"y",
|
"y",
|
||||||
"--read-uploads-data",
|
"--read-uploads-description",
|
||||||
"y",
|
"y",
|
||||||
"--dedupe-uploads",
|
"--dedupe-uploads",
|
||||||
"n",
|
"n",
|
||||||
|
@ -95,7 +95,7 @@ test "running gen" 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, Pleroma.Upload.Filter.ExiftoolReadData]"
|
"filters: [Pleroma.Upload.Filter.Exiftool, Pleroma.Upload.Filter.Exiftool.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"))
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Upload.Filter.ExiftoolReadDataTest do
|
defmodule Pleroma.Upload.Filter.Exiftool.ReadDescriptionTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: true
|
||||||
alias Pleroma.Upload.Filter
|
alias Pleroma.Upload.Filter
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ test "keeps description when not empty" do
|
||||||
description: "Eight different owls"
|
description: "Eight different owls"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert Filter.ExiftoolReadData.filter(uploads) ==
|
assert Filter.Exiftool.ReadDescription.filter(uploads) ==
|
||||||
{:ok, :noop}
|
{:ok, :noop}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ test "otherwise returns ImageDescription when present" do
|
||||||
description: "Pictures of eight different owls"
|
description: "Pictures of eight different owls"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert Filter.ExiftoolReadData.filter(@uploads) ==
|
assert Filter.Exiftool.ReadDescription.filter(@uploads) ==
|
||||||
{:ok, :filtered, uploads_after}
|
{:ok, :filtered, uploads_after}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ test "otherwise returns iptc:Caption-Abstract when present" do
|
||||||
description: "Pictures of eight different owls - iptc"
|
description: "Pictures of eight different owls - iptc"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert Filter.ExiftoolReadData.filter(upload) ==
|
assert Filter.Exiftool.ReadDescription.filter(upload) ==
|
||||||
{:ok, :filtered, upload_after}
|
{:ok, :filtered, upload_after}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -80,14 +80,14 @@ test "otherwise returns nil" do
|
||||||
description: nil
|
description: nil
|
||||||
}
|
}
|
||||||
|
|
||||||
assert Filter.ExiftoolReadData.filter(uploads) ==
|
assert Filter.Exiftool.ReadDescription.filter(uploads) ==
|
||||||
{:ok, :filtered, uploads}
|
{:ok, :filtered, uploads}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "Return nil when image description from EXIF data exceeds the maximum length" do
|
test "Return nil when image description from EXIF data exceeds the maximum length" do
|
||||||
clear_config([:instance, :description_limit], 5)
|
clear_config([:instance, :description_limit], 5)
|
||||||
|
|
||||||
assert Filter.ExiftoolReadData.filter(@uploads) ==
|
assert Filter.Exiftool.ReadDescription.filter(@uploads) ==
|
||||||
{:ok, :filtered, @uploads}
|
{:ok, :filtered, @uploads}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ test "Return nil when image description from EXIF data can't be read" do
|
||||||
description: nil
|
description: nil
|
||||||
}
|
}
|
||||||
|
|
||||||
assert Filter.ExiftoolReadData.filter(uploads) ==
|
assert Filter.Exiftool.ReadDescription.filter(uploads) ==
|
||||||
{:ok, :filtered, uploads}
|
{:ok, :filtered, uploads}
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue