Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85824986
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/pleroma/web/metadata/providers/activity_pub.ex b/lib/pleroma/web/metadata/providers/activity_pub.ex
index 1759a5a0d..bd9f92332 100644
--- a/lib/pleroma/web/metadata/providers/activity_pub.ex
+++ b/lib/pleroma/web/metadata/providers/activity_pub.ex
@@ -1,19 +1,22 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2024 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Metadata.Providers.ActivityPub do
alias Pleroma.Web.Metadata.Providers.Provider
@behaviour Provider
@impl Provider
def build_tags(%{object: %{data: %{"id" => object_id}}}) do
[{:link, [rel: "alternate", type: "application/activity+json", href: object_id], []}]
end
@impl Provider
def build_tags(%{user: user}) do
[{:link, [rel: "alternate", type: "application/activity+json", href: user.ap_id], []}]
end
+
+ @impl Provider
+ def build_tags(_), do: []
end
diff --git a/test/pleroma/web/metadata/providers/activity_pub_test.exs b/test/pleroma/web/metadata/providers/activity_pub_test.exs
index c379ec092..c5cf78a60 100644
--- a/test/pleroma/web/metadata/providers/activity_pub_test.exs
+++ b/test/pleroma/web/metadata/providers/activity_pub_test.exs
@@ -1,34 +1,40 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2024 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Metadata.Providers.ActivityPubTest do
use Pleroma.DataCase
import Pleroma.Factory
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.Metadata.Providers.ActivityPub
setup do: clear_config([Pleroma.Web.Metadata, :unfurl_nsfw])
test "it renders a link for user info" do
user = insert(:user)
res = ActivityPub.build_tags(%{user: user})
assert res == [
{:link, [rel: "alternate", type: "application/activity+json", href: user.ap_id], []}
]
end
test "it renders a link for a post" do
user = insert(:user)
{:ok, %{id: activity_id, object: object}} = CommonAPI.post(user, %{status: "hi"})
result = ActivityPub.build_tags(%{object: object, user: user, activity_id: activity_id})
assert [
{:link,
[rel: "alternate", type: "application/activity+json", href: object.data["id"]], []}
] == result
end
+
+ test "it returns an empty array for anything else" do
+ result = ActivityPub.build_tags(%{})
+
+ assert result == []
+ end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Oct 29, 9:16 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1798668
Default Alt Text
(2 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline