Validate object data for incoming Update activities

In Create validator we do not validate the object data,
but that is because the object itself will go through the
pipeline again, which is not the case for Update. Thus,
we added validation for objects in Update activities.
This commit is contained in:
Tusooa Zhu 2022-07-03 20:19:50 -04:00
commit 5ce118d970
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
2 changed files with 43 additions and 2 deletions

View file

@ -152,8 +152,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do
)
when objtype in ~w[Question Answer Audio Video Event Article Note Page] do
with {_, false} <- {:local, Access.get(meta, :local, false)},
{:ok, object_data} <- cast_and_apply(object),
meta = Keyword.put(meta, :object_data, object_data |> stringify_keys),
{_, {:ok, object_data, _}} <- {:object_validation, validate(object, meta)},
meta = Keyword.put(meta, :object_data, object_data),
{:ok, update_activity} <-
update_activity
|> UpdateValidator.cast_and_validate()
@ -169,6 +169,9 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do
object = stringify_keys(object)
{:ok, object, meta}
end
{:object_validation, e} ->
e
end
end