B Providers/ActivityPub: Ensure that nothing explodes on unexpected input.

This commit is contained in:
Lain Soykaf 2024-11-12 14:22:02 +04:00
parent 60ec42cb9c
commit 5b3e4cf49b
2 changed files with 9 additions and 0 deletions

View file

@ -16,4 +16,7 @@ def build_tags(%{object: %{data: %{"id" => object_id}}}) do
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

View file

@ -31,4 +31,10 @@ test "it renders a link for a post" do
[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