Add various fixes from upstream pr814
This commit is contained in:
parent
22a486383d
commit
ad3a2c49ba
5 changed files with 274 additions and 0 deletions
52
patches/pr814_07_fix-bmp-metadata-handling.patch
Normal file
52
patches/pr814_07_fix-bmp-metadata-handling.patch
Normal file
|
@ -0,0 +1,52 @@
|
|||
From 495a1a71e89f3a3b67f9948f5e241a8b195f5ecf Mon Sep 17 00:00:00 2001
|
||||
From: Oneric <oneric@oneric.stub>
|
||||
Date: Fri, 21 Jun 2024 18:30:47 +0200
|
||||
Subject: [PATCH] strip_metadata: skip BMP files
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Not _yet_ supported as of exiftool 12.87, though
|
||||
at first glance it seems like standard BMP files
|
||||
can't store any metadata besides colour profiles
|
||||
|
||||
Fixes the specific case from
|
||||
https://akkoma.dev/AkkomaGang/akkoma-fe/issues/396
|
||||
although the frontend shouldn’t get bricked regardless.
|
||||
---
|
||||
lib/pleroma/upload/filter/exiftool/strip_metadata.ex | 1 +
|
||||
.../upload/filter/exiftool/strip_location_test.exs | 9 +++++++++
|
||||
2 files changed, 10 insertions(+)
|
||||
|
||||
diff --git a/lib/pleroma/upload/filter/exiftool/strip_metadata.ex b/lib/pleroma/upload/filter/exiftool/strip_metadata.ex
|
||||
index 912ff6a92..a2604a682 100644
|
||||
--- a/lib/pleroma/upload/filter/exiftool/strip_metadata.ex
|
||||
+++ b/lib/pleroma/upload/filter/exiftool/strip_metadata.ex
|
||||
@@ -18,6 +18,7 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripMetadata do
|
||||
|
||||
# Formats not compatible with exiftool at this time
|
||||
def filter(%Pleroma.Upload{content_type: "image/webp"}), do: {:ok, :noop}
|
||||
+ def filter(%Pleroma.Upload{content_type: "image/bmp"}), do: {:ok, :noop}
|
||||
def filter(%Pleroma.Upload{content_type: "image/svg+xml"}), do: {:ok, :noop}
|
||||
|
||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
||||
diff --git a/test/pleroma/upload/filter/exiftool/strip_location_test.exs b/test/pleroma/upload/filter/exiftool/strip_location_test.exs
|
||||
index 2e017cd7e..1f798556b 100644
|
||||
--- a/test/pleroma/upload/filter/exiftool/strip_location_test.exs
|
||||
+++ b/test/pleroma/upload/filter/exiftool/strip_location_test.exs
|
||||
@@ -115,6 +115,15 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripMetadataTest do
|
||||
assert Filter.Exiftool.StripMetadata.filter(upload) == {:ok, :noop}
|
||||
end
|
||||
|
||||
+ test "verify bmp files are skipped" do
|
||||
+ upload = %Pleroma.Upload{
|
||||
+ name: "sample.bmp",
|
||||
+ content_type: "image/bmp"
|
||||
+ }
|
||||
+
|
||||
+ assert Filter.Exiftool.StripMetadata.filter(upload) == {:ok, :noop}
|
||||
+ end
|
||||
+
|
||||
test "verify svg files are skipped" do
|
||||
upload = %Pleroma.Upload{
|
||||
name: "sample.svg",
|
72
patches/pr814_08_federation-with-multi-ld-profiles.patch
Normal file
72
patches/pr814_08_federation-with-multi-ld-profiles.patch
Normal file
|
@ -0,0 +1,72 @@
|
|||
From ca182a0ae7cde1838b6f1c63b7348af7eb6b45b1 Mon Sep 17 00:00:00 2001
|
||||
From: Oneric <oneric@oneric.stub>
|
||||
Date: Thu, 20 Jun 2024 19:52:43 +0200
|
||||
Subject: [PATCH] Correctly parse content types with multiple profiles
|
||||
|
||||
Multiple profiles can be specified as a space-separated list
|
||||
and the possibility of additional profiles is explicitly brought up
|
||||
in ActivityStream spec
|
||||
---
|
||||
lib/pleroma/object/fetcher.ex | 8 ++++++--
|
||||
test/pleroma/object/fetcher_test.exs | 22 +++++++++++++++++++++-
|
||||
3 files changed, 27 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/lib/pleroma/object/fetcher.ex b/lib/pleroma/object/fetcher.ex
|
||||
index 937026e04..54ea9e74e 100644
|
||||
--- a/lib/pleroma/object/fetcher.ex
|
||||
+++ b/lib/pleroma/object/fetcher.ex
|
||||
@@ -369,8 +369,12 @@ defmodule Pleroma.Object.Fetcher do
|
||||
{"activity+json", _} ->
|
||||
{:ok, final_id, body}
|
||||
|
||||
- {"ld+json", %{"profile" => "https://www.w3.org/ns/activitystreams"}} ->
|
||||
- {:ok, final_id, body}
|
||||
+ {"ld+json", %{"profile" => profiles}} ->
|
||||
+ if "https://www.w3.org/ns/activitystreams" in String.split(profiles) do
|
||||
+ {:ok, final_id, body}
|
||||
+ else
|
||||
+ {:error, {:content_type, content_type}}
|
||||
+ end
|
||||
|
||||
_ ->
|
||||
{:error, {:content_type, content_type}}
|
||||
diff --git a/test/pleroma/object/fetcher_test.exs b/test/pleroma/object/fetcher_test.exs
|
||||
index 74f2cd31f..62dd64625 100644
|
||||
--- a/test/pleroma/object/fetcher_test.exs
|
||||
+++ b/test/pleroma/object/fetcher_test.exs
|
||||
@@ -754,7 +754,7 @@ defmodule Pleroma.Object.FetcherTest do
|
||||
assert {:ok, _, "{}"} = Fetcher.get_object("https://mastodon.social/2")
|
||||
end
|
||||
|
||||
- test "should return ok if the content type is application/ld+json with a profile" do
|
||||
+ test "should return ok if the content type is application/ld+json with the ActivityStream profile" do
|
||||
Tesla.Mock.mock(fn
|
||||
%{
|
||||
method: :get,
|
||||
@@ -774,6 +774,26 @@ defmodule Pleroma.Object.FetcherTest do
|
||||
assert {:ok, _, "{}"} = Fetcher.get_object("https://mastodon.social/2")
|
||||
end
|
||||
|
||||
+ test "should return ok if the content type is application/ld+json with several profiles" do
|
||||
+ Tesla.Mock.mock(fn
|
||||
+ %{
|
||||
+ method: :get,
|
||||
+ url: "https://mastodon.social/2"
|
||||
+ } ->
|
||||
+ %Tesla.Env{
|
||||
+ status: 200,
|
||||
+ url: "https://mastodon.social/2",
|
||||
+ headers: [
|
||||
+ {"content-type",
|
||||
+ "application/ld+json; profile=\"https://example.org/ns/superduperspec https://www.w3.org/ns/activitystreams\""}
|
||||
+ ],
|
||||
+ body: "{}"
|
||||
+ }
|
||||
+ end)
|
||||
+
|
||||
+ assert {:ok, _, "{}"} = Fetcher.get_object("https://mastodon.social/2")
|
||||
+ end
|
||||
+
|
||||
test "should not return ok with other content types" do
|
||||
Tesla.Mock.mock(fn
|
||||
%{
|
81
patches/pr814_09_fix-multi-selection-poll-counts.patch
Normal file
81
patches/pr814_09_fix-multi-selection-poll-counts.patch
Normal file
|
@ -0,0 +1,81 @@
|
|||
From d488cf476ea2ea662c5ec6acfa319331c3490d27 Mon Sep 17 00:00:00 2001
|
||||
From: Oneric <oneric@oneric.stub>
|
||||
Date: Thu, 20 Jun 2024 19:52:47 +0200
|
||||
Subject: [PATCH] Fix voters count field
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Mastodon API demands this be null unless it’s a multi-selection poll.
|
||||
Not abiding by this can mess up display in some clients.
|
||||
|
||||
Fixes: https://akkoma.dev/AkkomaGang/akkoma/issues/190
|
||||
---
|
||||
lib/pleroma/web/api_spec/schemas/poll.ex | 4 +++-
|
||||
lib/pleroma/web/mastodon_api/views/poll_view.ex | 14 +++++++++++---
|
||||
.../web/mastodon_api/views/poll_view_test.exs | 2 +-
|
||||
4 files changed, 15 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/lib/pleroma/web/api_spec/schemas/poll.ex b/lib/pleroma/web/api_spec/schemas/poll.ex
|
||||
index 943ad8bd4..13a5e8be2 100644
|
||||
--- a/lib/pleroma/web/api_spec/schemas/poll.ex
|
||||
+++ b/lib/pleroma/web/api_spec/schemas/poll.ex
|
||||
@@ -32,7 +32,9 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Poll do
|
||||
},
|
||||
voters_count: %Schema{
|
||||
type: :integer,
|
||||
- description: "How many unique accounts have voted. Number."
|
||||
+ nullable: true,
|
||||
+ description:
|
||||
+ "How many unique accounts have voted for a multi-selection poll. Number, or null if single-selection poll."
|
||||
},
|
||||
voted: %Schema{
|
||||
type: :boolean,
|
||||
diff --git a/lib/pleroma/web/mastodon_api/views/poll_view.ex b/lib/pleroma/web/mastodon_api/views/poll_view.ex
|
||||
index aa6443754..411cbd15a 100644
|
||||
--- a/lib/pleroma/web/mastodon_api/views/poll_view.ex
|
||||
+++ b/lib/pleroma/web/mastodon_api/views/poll_view.ex
|
||||
@@ -19,7 +19,7 @@ defmodule Pleroma.Web.MastodonAPI.PollView do
|
||||
expired: expired,
|
||||
multiple: multiple,
|
||||
votes_count: votes_count,
|
||||
- voters_count: voters_count(object),
|
||||
+ voters_count: voters_count(multiple, object),
|
||||
options: options,
|
||||
emojis: Pleroma.Web.MastodonAPI.StatusView.build_emojis(object.data["emoji"])
|
||||
}
|
||||
@@ -68,11 +68,19 @@ defmodule Pleroma.Web.MastodonAPI.PollView do
|
||||
end)
|
||||
end
|
||||
|
||||
- defp voters_count(%{data: %{"voters" => voters}}) when is_list(voters) do
|
||||
+ defp voters_count(false, _poll_data) do
|
||||
+ # Mastodon always sets voter count to "null" unless multiple options were selectable
|
||||
+ # Some clients may rely on this to detect multiple selection polls and it can mess
|
||||
+ # up percentages for some clients if we never got a correct remote voter count and
|
||||
+ # only count local voters here; see https://akkoma.dev/AkkomaGang/akkoma/issues/190
|
||||
+ nil
|
||||
+ end
|
||||
+
|
||||
+ defp voters_count(_multiple, %{data: %{"voters" => voters}}) when is_list(voters) do
|
||||
length(voters)
|
||||
end
|
||||
|
||||
- defp voters_count(_), do: 0
|
||||
+ defp voters_count(_, _), do: 0
|
||||
|
||||
defp voted_and_own_votes(%{object: object} = params, options) do
|
||||
if params[:for] do
|
||||
diff --git a/test/pleroma/web/mastodon_api/views/poll_view_test.exs b/test/pleroma/web/mastodon_api/views/poll_view_test.exs
|
||||
index 224b26cb9..91d95f229 100644
|
||||
--- a/test/pleroma/web/mastodon_api/views/poll_view_test.exs
|
||||
+++ b/test/pleroma/web/mastodon_api/views/poll_view_test.exs
|
||||
@@ -43,7 +43,7 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do
|
||||
%{title: "why are you even asking?", votes_count: 0}
|
||||
],
|
||||
votes_count: 0,
|
||||
- voters_count: 0
|
||||
+ voters_count: nil
|
||||
}
|
||||
|
||||
result = PollView.render("show.json", %{object: object})
|
63
patches/pr814_10_fix-swagger-ui.patch
Normal file
63
patches/pr814_10_fix-swagger-ui.patch
Normal file
|
@ -0,0 +1,63 @@
|
|||
From a3101a435bae8bba7da77bba52d80e06b85593a4 Mon Sep 17 00:00:00 2001
|
||||
From: Oneric <oneric@oneric.stub>
|
||||
Date: Thu, 20 Jun 2024 19:53:03 +0200
|
||||
Subject: [PATCH] Fix swagger-ui
|
||||
|
||||
Ever since the browser frontend switcher was introduced in
|
||||
de64c6c54aaacc4123031f2e3d5bfb9fc9c517fe /akkoma counts as
|
||||
an API prefix and thus gets skipped by frontend plugs
|
||||
breaking the old swagger ui path of /akkoma/swagger-ui.
|
||||
|
||||
Do the simple thing and change the frontend path to
|
||||
/pleroma/swaggerui which isn't an API path and can't collide
|
||||
with frontend user paths given pleroma is areserved nickname.
|
||||
|
||||
Reported in
|
||||
https://meta.akkoma.dev/t/view-all-endpoints/269/7
|
||||
https://meta.akkoma.dev/t/swagger-ui-not-loading/728
|
||||
---
|
||||
docs/docs/configuration/cheatsheet.md | 2 +-
|
||||
docs/docs/configuration/frontend_management.md | 2 +-
|
||||
lib/pleroma/web/endpoint.ex | 4 ++--
|
||||
4 files changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/docs/docs/configuration/cheatsheet.md b/docs/docs/configuration/cheatsheet.md
|
||||
index 80f5c3577..916e1cc0c 100644
|
||||
--- a/docs/docs/configuration/cheatsheet.md
|
||||
+++ b/docs/docs/configuration/cheatsheet.md
|
||||
@@ -338,7 +338,7 @@ config :pleroma, :frontends,
|
||||
|
||||
* `:primary` - The frontend that will be served at `/`
|
||||
* `:admin` - The frontend that will be served at `/pleroma/admin`
|
||||
-* `:swagger` - Config for developers to act as an API reference to be served at `/akkoma/swaggerui/` (trailing slash _needed_). Disabled by default.
|
||||
+* `:swagger` - Config for developers to act as an API reference to be served at `/pleroma/swaggerui/` (trailing slash _needed_). Disabled by default.
|
||||
* `:mastodon` - The mastodon-fe configuration. This shouldn't need to be changed. This is served at `/web` when installed.
|
||||
|
||||
### :static\_fe
|
||||
diff --git a/docs/docs/configuration/frontend_management.md b/docs/docs/configuration/frontend_management.md
|
||||
index bc5344826..8875ee279 100644
|
||||
--- a/docs/docs/configuration/frontend_management.md
|
||||
+++ b/docs/docs/configuration/frontend_management.md
|
||||
@@ -60,4 +60,4 @@ config :pleroma, :frontends,
|
||||
|
||||
Then run the [pleroma.frontend cli task](../../administration/CLI_tasks/frontend) with the name of `swagger-ui` to install the distribution files.
|
||||
|
||||
-You will now be able to view documentation at `/akkoma/swaggerui`
|
||||
+You will now be able to view documentation at `/pleroma/swaggerui`
|
||||
diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex
|
||||
index 6628fcaf3..3c9fcb48c 100644
|
||||
--- a/lib/pleroma/web/endpoint.ex
|
||||
+++ b/lib/pleroma/web/endpoint.ex
|
||||
@@ -66,10 +66,10 @@ defmodule Pleroma.Web.Endpoint do
|
||||
}
|
||||
)
|
||||
|
||||
- plug(Plug.Static.IndexHtml, at: "/akkoma/swaggerui")
|
||||
+ plug(Plug.Static.IndexHtml, at: "/pleroma/swaggerui/")
|
||||
|
||||
plug(Pleroma.Web.Plugs.FrontendStatic,
|
||||
- at: "/akkoma/swaggerui",
|
||||
+ at: "/pleroma/swaggerui",
|
||||
frontend_type: :swagger,
|
||||
gzip: true,
|
||||
if: &Pleroma.Web.Swagger.ui_enabled?/0,
|
|
@ -3,3 +3,9 @@
|
|||
# and fix delete+redraft if cleanup is enabled
|
||||
pr789_01_dont-attempt-to-delete-remote-attachs.patch
|
||||
pr789_02_attach-deletion-grace-period.patch
|
||||
# Various small things
|
||||
# (omitted PR commits not relevant for production deployments)
|
||||
pr814_07_fix-bmp-metadata-handling.patch
|
||||
pr814_08_federation-with-multi-ld-profiles.patch
|
||||
pr814_09_fix-multi-selection-poll-counts.patch
|
||||
pr814_10_fix-swagger-ui.patch
|
||||
|
|
Loading…
Reference in a new issue