mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2025-01-03 13:58:41 +00:00
Merge branch 'follow-validator' into 'develop'
Do not require a cc field when validating an incoming Follow activity See merge request pleroma/pleroma!4212
This commit is contained in:
commit
72b5974f81
5 changed files with 14 additions and 3 deletions
1
changelog.d/follow-validator.fix
Normal file
1
changelog.d/follow-validator.fix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Improve the FollowValidator to successfully incoming activities with an errant cc field.
|
|
@ -29,7 +29,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AcceptRejectValidator do
|
||||||
|
|
||||||
defp validate_data(cng) do
|
defp validate_data(cng) do
|
||||||
cng
|
cng
|
||||||
|> validate_required([:id, :type, :actor, :to, :cc, :object])
|
|> validate_required([:id, :type, :actor, :to, :object])
|
||||||
|> validate_inclusion(:type, ["Accept", "Reject"])
|
|> validate_inclusion(:type, ["Accept", "Reject"])
|
||||||
|> validate_actor_presence()
|
|> validate_actor_presence()
|
||||||
|> validate_object_presence(allowed_types: ["Follow"])
|
|> validate_object_presence(allowed_types: ["Follow"])
|
||||||
|
|
|
@ -29,7 +29,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.BlockValidator do
|
||||||
|
|
||||||
defp validate_data(cng) do
|
defp validate_data(cng) do
|
||||||
cng
|
cng
|
||||||
|> validate_required([:id, :type, :actor, :to, :cc, :object])
|
|> validate_required([:id, :type, :actor, :to, :object])
|
||||||
|> validate_inclusion(:type, ["Block"])
|
|> validate_inclusion(:type, ["Block"])
|
||||||
|> CommonValidations.validate_actor_presence()
|
|> CommonValidations.validate_actor_presence()
|
||||||
|> CommonValidations.validate_actor_presence(field_name: :object)
|
|> CommonValidations.validate_actor_presence(field_name: :object)
|
||||||
|
|
|
@ -29,7 +29,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.FollowValidator do
|
||||||
|
|
||||||
defp validate_data(cng) do
|
defp validate_data(cng) do
|
||||||
cng
|
cng
|
||||||
|> validate_required([:id, :type, :actor, :to, :cc, :object])
|
|> validate_required([:id, :type, :actor, :to, :object])
|
||||||
|> validate_inclusion(:type, ["Follow"])
|
|> validate_inclusion(:type, ["Follow"])
|
||||||
|> validate_inclusion(:state, ~w{pending reject accept})
|
|> validate_inclusion(:state, ~w{pending reject accept})
|
||||||
|> validate_actor_presence()
|
|> validate_actor_presence()
|
||||||
|
|
|
@ -22,5 +22,15 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.FollowValidationTest do
|
||||||
test "validates a basic follow object", %{valid_follow: valid_follow} do
|
test "validates a basic follow object", %{valid_follow: valid_follow} do
|
||||||
assert {:ok, _follow, []} = ObjectValidator.validate(valid_follow, [])
|
assert {:ok, _follow, []} = ObjectValidator.validate(valid_follow, [])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "supports a nil cc", %{valid_follow: valid_follow} do
|
||||||
|
valid_follow_with_nil_cc = Map.put(valid_follow, "cc", nil)
|
||||||
|
assert {:ok, _follow, []} = ObjectValidator.validate(valid_follow_with_nil_cc, [])
|
||||||
|
end
|
||||||
|
|
||||||
|
test "supports an empty cc", %{valid_follow: valid_follow} do
|
||||||
|
valid_follow_with_empty_cc = Map.put(valid_follow, "cc", [])
|
||||||
|
assert {:ok, _follow, []} = ObjectValidator.validate(valid_follow_with_empty_cc, [])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue