mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-17 10:39:17 +00:00
Cleaned up FEP-fffd commits a bit
This commit is contained in:
parent
4887df12d7
commit
df25d86999
|
@ -7,7 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
## Unreleased
|
||||
|
||||
## Added
|
||||
|
||||
- Support for [FEP-fffd](https://codeberg.org/fediverse/fep/src/branch/main/fep/fffd/fep-fffd.md) (proxy objects)
|
||||
|
||||
## Changed
|
||||
|
||||
## Fixed
|
||||
|
|
|
@ -53,12 +53,11 @@ def cast_data(data) do
|
|||
|
||||
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_list(url) do
|
||||
if is_map(List.first(url)) do
|
||||
Map.put(data, "url", List.first(url)["href"])
|
||||
else
|
||||
Map.put(data, "url", List.first(url))
|
||||
end
|
||||
data
|
||||
|> Map.put("url", List.first(url))
|
||||
|> fix_url()
|
||||
end
|
||||
|
||||
defp fix_url(data), do: data
|
||||
|
|
|
@ -50,14 +50,17 @@ test "note with url array validates", %{note: note} do
|
|||
end
|
||||
|
||||
test "note with url array validates if contains a link object", %{note: note} do
|
||||
note = Map.put(note, "url", [%{
|
||||
"type" => "Link",
|
||||
"href" => "https://remote.example/link"
|
||||
}])
|
||||
note =
|
||||
Map.put(note, "url", [
|
||||
%{
|
||||
"type" => "Link",
|
||||
"href" => "https://remote.example/link"
|
||||
}
|
||||
])
|
||||
|
||||
%{valid?: true} = ArticleNotePageValidator.cast_and_validate(note)
|
||||
end
|
||||
|
||||
|
||||
test "a note with a language validates" do
|
||||
insert(:user, %{ap_id: "https://mastodon.social/users/akkoma_ap_integration_tester"})
|
||||
note = File.read!("test/fixtures/mastodon/note_with_language.json") |> Jason.decode!()
|
||||
|
|
Loading…
Reference in a new issue