AP C2S: reject Flag activities, add visibility refutes to some tests
This commit is contained in:
parent
7f3b3c2491
commit
21b2fd1e05
2 changed files with 11 additions and 0 deletions
|
|
@ -482,6 +482,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
|||
{:ok, activity}
|
||||
end
|
||||
|
||||
# We currently lack a Flag ObjectValidator since both CommonAPI and Transmogrifier
|
||||
# both send it straight to ActivityPub.flag and C2S currently has to go through
|
||||
# the normal pipeline which requires an ObjectValidator.
|
||||
# TODO: Add a Flag Activity ObjectValidator
|
||||
defp validate_visibility(_, %{"type" => "Flag"}) do
|
||||
{:error, "Flag activities aren't currently supported in C2S"}
|
||||
end
|
||||
|
||||
defp validate_visibility(%User{} = user, %{"type" => type, "object" => object} = activity) do
|
||||
with {_, %Object{} = normalized_object} <-
|
||||
{:normalize, Object.normalize(object, fetch: false)},
|
||||
|
|
|
|||
|
|
@ -1712,6 +1712,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
{:ok, post} = CommonAPI.post(user, %{status: "cofe", visibility: "private"})
|
||||
|
||||
assert Pleroma.Web.ActivityPub.Visibility.private?(post)
|
||||
refute Pleroma.Web.ActivityPub.Visibility.visible_for_user?(post, stranger)
|
||||
|
||||
post_object = Object.normalize(post, fetch: false)
|
||||
|
||||
|
|
@ -1737,6 +1738,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
{:ok, post} = CommonAPI.post(user, %{status: "cofe", visibility: "private"})
|
||||
|
||||
assert Pleroma.Web.ActivityPub.Visibility.private?(post)
|
||||
refute Pleroma.Web.ActivityPub.Visibility.visible_for_user?(post, stranger)
|
||||
|
||||
post_object = Object.normalize(post, fetch: false)
|
||||
|
||||
|
|
@ -1762,6 +1764,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
{:ok, post} = CommonAPI.post(user, %{status: "cofe", visibility: "private"})
|
||||
|
||||
assert Pleroma.Web.ActivityPub.Visibility.private?(post)
|
||||
refute Pleroma.Web.ActivityPub.Visibility.visible_for_user?(post, stranger)
|
||||
|
||||
post_object = Object.normalize(post, fetch: false)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue