LikeValidator: Fix up missing recipients.

This commit is contained in:
lain 2020-05-04 17:08:31 +02:00
commit e03c301ebe
2 changed files with 44 additions and 3 deletions

View file

@ -36,6 +36,19 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
assert LikeValidator.cast_and_validate(valid_like).valid?
end
test "sets the 'to' field to the object actor if no recipients are given", %{
valid_like: valid_like,
user: user
} do
without_recipients =
valid_like
|> Map.delete("to")
{:ok, object, _meta} = ObjectValidator.validate(without_recipients, [])
assert object["to"] == [user.ap_id]
end
test "it errors when the actor is missing or not known", %{valid_like: valid_like} do
without_actor = Map.delete(valid_like, "actor")