From 551721e41a0bd98bb840baca48415a781cc463a7 Mon Sep 17 00:00:00 2001 From: Ilja Date: Sun, 20 Feb 2022 12:59:42 +0100 Subject: [PATCH] Rename the new module --- docs/configuration/cheatsheet.md | 4 ++-- .../optional/media_graphics_packages.md | 2 +- lib/mix/tasks/pleroma/instance.ex | 18 +++++++++--------- lib/pleroma/application_requirements.ex | 2 +- .../upload/filter/{ => exiftool}/exiftool.ex | 0 .../read_description.ex} | 2 +- test/mix/tasks/pleroma/instance_test.exs | 4 ++-- .../filter/{ => exiftool}/exiftool_test.exs | 0 .../read_description_test.exs} | 14 +++++++------- 9 files changed, 23 insertions(+), 23 deletions(-) rename lib/pleroma/upload/filter/{ => exiftool}/exiftool.ex (100%) rename lib/pleroma/upload/filter/{exiftool_read_data.ex => exiftool/read_description.ex} (96%) rename test/pleroma/upload/filter/{ => exiftool}/exiftool_test.exs (100%) rename test/pleroma/upload/filter/{exiftool_read_data_test.exs => exiftool/read_description_test.exs} (88%) diff --git a/docs/configuration/cheatsheet.md b/docs/configuration/cheatsheet.md index f1624b651..985a22a1d 100644 --- a/docs/configuration/cheatsheet.md +++ b/docs/configuration/cheatsheet.md @@ -633,9 +633,9 @@ This filter only strips the GPS and location metadata with Exiftool leaving colo 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. diff --git a/docs/installation/optional/media_graphics_packages.md b/docs/installation/optional/media_graphics_packages.md index 47e2ef3fb..e43c748ea 100644 --- a/docs/installation/optional/media_graphics_packages.md +++ b/docs/installation/optional/media_graphics_packages.md @@ -30,4 +30,4 @@ 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.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`) diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex index d206e1622..40a8a2320 100644 --- a/lib/mix/tasks/pleroma/instance.ex +++ b/lib/mix/tasks/pleroma/instance.ex @@ -35,7 +35,7 @@ defmodule Mix.Tasks.Pleroma.Instance do listen_ip: :string, listen_port: :string, strip_uploads: :string, - read_uploads_data: :string, + read_uploads_description: :string, anonymize_uploads: :string, dedupe_uploads: :string ], @@ -179,7 +179,7 @@ defmodule Mix.Tasks.Pleroma.Instance do strip_uploads_default ) === "y" - {read_uploads_data_message, read_uploads_data_default} = + {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"} @@ -188,12 +188,12 @@ defmodule Mix.Tasks.Pleroma.Instance do "n"} end - read_uploads_data = + read_uploads_description = get_option( options, - :read_uploads_data, - read_uploads_data_message, - read_uploads_data_default + :read_uploads_description, + read_uploads_description_message, + read_uploads_description_default ) === "y" anonymize_uploads = @@ -248,7 +248,7 @@ defmodule Mix.Tasks.Pleroma.Instance do upload_filters: upload_filters(%{ strip: strip_uploads, - read_data: read_uploads_data, + read_description: read_uploads_description, anonymize: anonymize_uploads, dedupe: dedupe_uploads }) @@ -323,8 +323,8 @@ defmodule Mix.Tasks.Pleroma.Instance do end enabled_filters = - if filters.read_data do - enabled_filters ++ [Pleroma.Upload.Filter.ExiftoolReadData] + if filters.read_description do + enabled_filters ++ [Pleroma.Upload.Filter.Exiftool.ReadDescription] else enabled_filters end diff --git a/lib/pleroma/application_requirements.ex b/lib/pleroma/application_requirements.ex index ea1ee71c0..117aa88cb 100644 --- a/lib/pleroma/application_requirements.ex +++ b/lib/pleroma/application_requirements.ex @@ -165,7 +165,7 @@ defmodule Pleroma.ApplicationRequirements do defp check_system_commands!(:ok) do filter_commands_statuses = [ 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.Mogrifun, "mogrify"), check_filter(Pleroma.Upload.Filter.AnalyzeMetadata, "mogrify"), diff --git a/lib/pleroma/upload/filter/exiftool.ex b/lib/pleroma/upload/filter/exiftool/exiftool.ex similarity index 100% rename from lib/pleroma/upload/filter/exiftool.ex rename to lib/pleroma/upload/filter/exiftool/exiftool.ex diff --git a/lib/pleroma/upload/filter/exiftool_read_data.ex b/lib/pleroma/upload/filter/exiftool/read_description.ex similarity index 96% rename from lib/pleroma/upload/filter/exiftool_read_data.ex rename to lib/pleroma/upload/filter/exiftool/read_description.ex index c8bedfbf8..3f7b7c798 100644 --- a/lib/pleroma/upload/filter/exiftool_read_data.ex +++ b/lib/pleroma/upload/filter/exiftool/read_description.ex @@ -2,7 +2,7 @@ # Copyright © 2017-2021 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only -defmodule Pleroma.Upload.Filter.ExiftoolReadData do +defmodule Pleroma.Upload.Filter.Exiftool.ReadDescription do @moduledoc """ 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. diff --git a/test/mix/tasks/pleroma/instance_test.exs b/test/mix/tasks/pleroma/instance_test.exs index e72aab701..265b679f7 100644 --- a/test/mix/tasks/pleroma/instance_test.exs +++ b/test/mix/tasks/pleroma/instance_test.exs @@ -69,7 +69,7 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do "./test/../test/instance/static/", "--strip-uploads", "y", - "--read-uploads-data", + "--read-uploads-description", "y", "--dedupe-uploads", "n", @@ -95,7 +95,7 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do assert generated_config =~ "http: [ip: {127, 0, 0, 1}, port: 4000]" 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.exists?(Path.expand("./test/instance/static/robots.txt")) diff --git a/test/pleroma/upload/filter/exiftool_test.exs b/test/pleroma/upload/filter/exiftool/exiftool_test.exs similarity index 100% rename from test/pleroma/upload/filter/exiftool_test.exs rename to test/pleroma/upload/filter/exiftool/exiftool_test.exs diff --git a/test/pleroma/upload/filter/exiftool_read_data_test.exs b/test/pleroma/upload/filter/exiftool/read_description_test.exs similarity index 88% rename from test/pleroma/upload/filter/exiftool_read_data_test.exs rename to test/pleroma/upload/filter/exiftool/read_description_test.exs index 0861d293a..0e97b424b 100644 --- a/test/pleroma/upload/filter/exiftool_read_data_test.exs +++ b/test/pleroma/upload/filter/exiftool/read_description_test.exs @@ -2,7 +2,7 @@ # Copyright © 2017-2021 Pleroma Authors # 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 alias Pleroma.Upload.Filter @@ -29,7 +29,7 @@ defmodule Pleroma.Upload.Filter.ExiftoolReadDataTest do description: "Eight different owls" } - assert Filter.ExiftoolReadData.filter(uploads) == + assert Filter.Exiftool.ReadDescription.filter(uploads) == {:ok, :noop} end @@ -46,7 +46,7 @@ defmodule Pleroma.Upload.Filter.ExiftoolReadDataTest do description: "Pictures of eight different owls" } - assert Filter.ExiftoolReadData.filter(@uploads) == + assert Filter.Exiftool.ReadDescription.filter(@uploads) == {:ok, :filtered, uploads_after} end @@ -67,7 +67,7 @@ defmodule Pleroma.Upload.Filter.ExiftoolReadDataTest do description: "Pictures of eight different owls - iptc" } - assert Filter.ExiftoolReadData.filter(upload) == + assert Filter.Exiftool.ReadDescription.filter(upload) == {:ok, :filtered, upload_after} end @@ -80,14 +80,14 @@ defmodule Pleroma.Upload.Filter.ExiftoolReadDataTest do description: nil } - assert Filter.ExiftoolReadData.filter(uploads) == + assert Filter.Exiftool.ReadDescription.filter(uploads) == {:ok, :filtered, uploads} end test "Return nil when image description from EXIF data exceeds the maximum length" do clear_config([:instance, :description_limit], 5) - assert Filter.ExiftoolReadData.filter(@uploads) == + assert Filter.Exiftool.ReadDescription.filter(@uploads) == {:ok, :filtered, @uploads} end @@ -100,7 +100,7 @@ defmodule Pleroma.Upload.Filter.ExiftoolReadDataTest do description: nil } - assert Filter.ExiftoolReadData.filter(uploads) == + assert Filter.Exiftool.ReadDescription.filter(uploads) == {:ok, :filtered, uploads} end end