
This allows discovering a page represents an ActivityPub object and also where to find the underlying representation. Other servers already implement this and some tools came to rely or profit from it. The alternate link is provided both with the "application/activity+json" format as used by Mastodon and the standard-compliant media type. Just like the feed provider, ActivityPub links are always enabled unless access to local posts is restricted and not configurable. The commit is based on earlier work by Charlotte 🦝 Deleńkec but with fixes and some tweaks. Co-authored-by: Charlotte 🦝 Deleńkec <lotte@chir.rs>
35 lines
835 B
Elixir
35 lines
835 B
Elixir
# Akkoma: Magically expressive social media
|
|
# Copyright © 2025 Akkoma Authors <https://akkoma.dev/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.Web.Metadata.Providers.ApUrl do
|
|
alias Pleroma.Web.Metadata.Providers.Provider
|
|
|
|
@behaviour Provider
|
|
|
|
defp alt_link(uri, type) do
|
|
{
|
|
:link,
|
|
[rel: "alternate", href: uri, type: type],
|
|
[]
|
|
}
|
|
end
|
|
|
|
defp ap_alt_links(uri) do
|
|
[
|
|
alt_link(uri, "application/activity+json"),
|
|
alt_link(uri, "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")
|
|
]
|
|
end
|
|
|
|
@impl Provider
|
|
def build_tags(%{object: %{data: %{"id" => ap_id}}}) when is_binary(ap_id) do
|
|
ap_alt_links(ap_id)
|
|
end
|
|
|
|
def build_tags(%{user: %{ap_id: ap_id}}) when is_binary(ap_id) do
|
|
ap_alt_links(ap_id)
|
|
end
|
|
|
|
def build_tags(_), do: []
|
|
end
|