Handle Fedibird's new quoteUri field

This commit is contained in:
Alex Gleason 2022-01-28 15:55:52 -06:00 committed by tusooa
commit 32e284ed2c
No known key found for this signature in database
GPG key ID: 42AEC43D48433C51
6 changed files with 92 additions and 10 deletions

View file

@ -78,7 +78,13 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator do
defp fix_quote_url(%{"quoteUrl" => _quote_url} = data), do: data
# Fix for Fedibird
# Fedibird
# https://github.com/fedibird/mastodon/commit/dbd7ae6cf58a92ec67c512296b4daaea0d01e6ac
defp fix_quote_url(%{"quoteUri" => quote_url} = data) do
Map.put(data, "quoteUrl", quote_url)
end
# Old Fedibird (bug)
# https://github.com/fedibird/mastodon/issues/9
defp fix_quote_url(%{"quoteURL" => quote_url} = data) do
Map.put(data, "quoteUrl", quote_url)

View file

@ -180,7 +180,15 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
end
end
# Fix for Fedibird
# Fedibird
# https://github.com/fedibird/mastodon/commit/dbd7ae6cf58a92ec67c512296b4daaea0d01e6ac
def fix_quote_url(%{"quoteUri" => quote_url} = object, options) do
object
|> Map.put("quoteUrl", quote_url)
|> fix_quote_url(options)
end
# Old Fedibird (bug)
# https://github.com/fedibird/mastodon/issues/9
def fix_quote_url(%{"quoteURL" => quote_url} = object, options) do
object
@ -660,10 +668,13 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
def set_reply_to_uri(obj), do: obj
# Misskey quotes
# Despite being underscored, it's potentially more reliable for interop.
def set_quote_url(%{"quoteUrl" => quote_url} = object) when is_binary(quote_url) do
Map.put(object, "_misskey_quote", quote_url)
Map.merge(object, %{
# Fedibird quote
"quoteUri" => quote_url,
# Misskey quote
"_misskey_quote" => quote_url
})
end
def set_quote_url(obj), do: obj