Transmogrifier: federate quotes with _misskey_quote field

This commit is contained in:
Alex Gleason 2022-01-28 14:06:32 -06:00 committed by tusooa
parent cf8e425883
commit 3c8319fe9f
No known key found for this signature in database
GPG Key ID: 42AEC43D48433C51
3 changed files with 15 additions and 0 deletions

View File

@ -660,6 +660,14 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
def set_reply_to_uri(obj), do: obj 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)
end
def set_quote_url(obj), do: obj
@doc """ @doc """
Serialized Mastodon-compatible `replies` collection containing _self-replies_. Serialized Mastodon-compatible `replies` collection containing _self-replies_.
Based on Mastodon's ActivityPub::NoteSerializer#replies. Based on Mastodon's ActivityPub::NoteSerializer#replies.
@ -714,6 +722,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|> prepare_attachments |> prepare_attachments
|> set_conversation |> set_conversation
|> set_reply_to_uri |> set_reply_to_uri
|> set_quote_url
|> set_replies |> set_replies
|> strip_internal_fields |> strip_internal_fields
|> strip_internal_tags |> strip_internal_tags

View File

@ -17,6 +17,7 @@
"ostatus": "http://ostatus.org#", "ostatus": "http://ostatus.org#",
"schema": "http://schema.org#", "schema": "http://schema.org#",
"toot": "http://joinmastodon.org/ns#", "toot": "http://joinmastodon.org/ns#",
"misskey": "https://misskey-hub.net/ns#",
"value": "schema:value", "value": "schema:value",
"sensitive": "as:sensitive", "sensitive": "as:sensitive",
"litepub": "http://litepub.social/ns#", "litepub": "http://litepub.social/ns#",
@ -27,6 +28,7 @@
"@type": "@id" "@type": "@id"
}, },
"quoteUrl": "as:quoteUrl", "quoteUrl": "as:quoteUrl",
"_misskey_quote": "misskey:_misskey_quote",
"oauthRegistrationEndpoint": { "oauthRegistrationEndpoint": {
"@id": "litepub:oauthRegistrationEndpoint", "@id": "litepub:oauthRegistrationEndpoint",
"@type": "@id" "@type": "@id"

View File

@ -382,7 +382,11 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
{:ok, modified} = Transmogrifier.prepare_outgoing(quote_post.data) {:ok, modified} = Transmogrifier.prepare_outgoing(quote_post.data)
quoted_post = Object.normalize(quoted_post) quoted_post = Object.normalize(quoted_post)
assert modified["object"]["quoteUrl"] == quoted_post.data["id"] assert modified["object"]["quoteUrl"] == quoted_post.data["id"]
# Add Misskey's quote as a fallback
assert modified["object"]["_misskey_quote"] == quoted_post.data["id"]
end end
end end