B Providers/ActivityPub: Ensure that nothing explodes on unexpected input.
This commit is contained in:
parent
60ec42cb9c
commit
5b3e4cf49b
2 changed files with 9 additions and 0 deletions
|
@ -16,4 +16,7 @@ def build_tags(%{object: %{data: %{"id" => object_id}}}) do
|
||||||
def build_tags(%{user: user}) do
|
def build_tags(%{user: user}) do
|
||||||
[{:link, [rel: "alternate", type: "application/activity+json", href: user.ap_id], []}]
|
[{:link, [rel: "alternate", type: "application/activity+json", href: user.ap_id], []}]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@impl Provider
|
||||||
|
def build_tags(_), do: []
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,4 +31,10 @@ test "it renders a link for a post" do
|
||||||
[rel: "alternate", type: "application/activity+json", href: object.data["id"]], []}
|
[rel: "alternate", type: "application/activity+json", href: object.data["id"]], []}
|
||||||
] == result
|
] == result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it returns an empty array for anything else" do
|
||||||
|
result = ActivityPub.build_tags(%{})
|
||||||
|
|
||||||
|
assert result == []
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue