Cleaned up FEP-fffd commits a bit
ci/woodpecker/push/build-amd64 Pipeline is pending Details
ci/woodpecker/push/build-arm64 Pipeline is pending Details
ci/woodpecker/push/docs Pipeline is pending Details
ci/woodpecker/push/lint Pipeline is pending Details
ci/woodpecker/push/test Pipeline is pending Details

This commit is contained in:
Floatingghost 2024-04-12 18:50:57 +01:00
parent 4887df12d7
commit df25d86999
3 changed files with 14 additions and 11 deletions

View File

@ -7,7 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## Unreleased ## Unreleased
## Added ## Added
- Support for [FEP-fffd](https://codeberg.org/fediverse/fep/src/branch/main/fep/fffd/fep-fffd.md) (proxy objects)
## Changed ## Changed
## Fixed ## Fixed

View File

@ -53,12 +53,11 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator do
defp fix_url(%{"url" => url} = data) when is_bitstring(url), do: data defp fix_url(%{"url" => url} = data) when is_bitstring(url), do: data
defp fix_url(%{"url" => url} = data) when is_map(url), do: Map.put(data, "url", url["href"]) defp fix_url(%{"url" => url} = data) when is_map(url), do: Map.put(data, "url", url["href"])
defp fix_url(%{"url" => url} = data) when is_list(url) do defp fix_url(%{"url" => url} = data) when is_list(url) do
if is_map(List.first(url)) do data
Map.put(data, "url", List.first(url)["href"]) |> Map.put("url", List.first(url))
else |> fix_url()
Map.put(data, "url", List.first(url))
end
end end
defp fix_url(data), do: data defp fix_url(data), do: data

View File

@ -50,14 +50,17 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
end end
test "note with url array validates if contains a link object", %{note: note} do test "note with url array validates if contains a link object", %{note: note} do
note = Map.put(note, "url", [%{ note =
"type" => "Link", Map.put(note, "url", [
"href" => "https://remote.example/link" %{
}]) "type" => "Link",
"href" => "https://remote.example/link"
}
])
%{valid?: true} = ArticleNotePageValidator.cast_and_validate(note) %{valid?: true} = ArticleNotePageValidator.cast_and_validate(note)
end end
test "a note with a language validates" do test "a note with a language validates" do
insert(:user, %{ap_id: "https://mastodon.social/users/akkoma_ap_integration_tester"}) insert(:user, %{ap_id: "https://mastodon.social/users/akkoma_ap_integration_tester"})
note = File.read!("test/fixtures/mastodon/note_with_language.json") |> Jason.decode!() note = File.read!("test/fixtures/mastodon/note_with_language.json") |> Jason.decode!()