CommonValidations: Remove superfluous function

The `is_active` functionality was integrated into the presence
checker.
This commit is contained in:
lain 2020-08-05 12:24:34 +02:00
parent 19c108170e
commit 00c4c6a382
4 changed files with 3 additions and 16 deletions

View file

@ -59,7 +59,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AnswerValidator do
|> validate_required([:id, :inReplyTo, :name, :attributedTo, :actor]) |> validate_required([:id, :inReplyTo, :name, :attributedTo, :actor])
|> CommonValidations.validate_any_presence([:cc, :to]) |> CommonValidations.validate_any_presence([:cc, :to])
|> CommonValidations.validate_fields_match([:actor, :attributedTo]) |> CommonValidations.validate_fields_match([:actor, :attributedTo])
|> CommonValidations.validate_actor_is_active() |> CommonValidations.validate_actor_presence()
|> CommonValidations.validate_host_match() |> CommonValidations.validate_host_match()
end end
end end

View file

@ -47,19 +47,6 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations do
end) end)
end end
def validate_actor_is_active(cng, options \\ []) do
field_name = Keyword.get(options, :field_name, :actor)
cng
|> validate_change(field_name, fn field_name, actor ->
if %User{deactivated: false} = User.get_cached_by_ap_id(actor) do
[]
else
[{field_name, "can't find user (or deactivated)"}]
end
end)
end
def validate_object_presence(cng, options \\ []) do def validate_object_presence(cng, options \\ []) do
field_name = Keyword.get(options, :field_name, :object) field_name = Keyword.get(options, :field_name, :object)
allowed_types = Keyword.get(options, :allowed_types, false) allowed_types = Keyword.get(options, :allowed_types, false)

View file

@ -55,7 +55,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateGenericValidator do
cng cng
|> validate_required([:actor, :type, :object]) |> validate_required([:actor, :type, :object])
|> validate_inclusion(:type, ["Create"]) |> validate_inclusion(:type, ["Create"])
|> validate_actor_is_active() |> validate_actor_presence()
|> validate_any_presence([:to, :cc]) |> validate_any_presence([:to, :cc])
|> validate_actors_match(meta) |> validate_actors_match(meta)
|> validate_context_match(meta) |> validate_context_match(meta)

View file

@ -114,7 +114,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionValidator do
|> validate_required([:id, :actor, :attributedTo, :type, :context]) |> validate_required([:id, :actor, :attributedTo, :type, :context])
|> CommonValidations.validate_any_presence([:cc, :to]) |> CommonValidations.validate_any_presence([:cc, :to])
|> CommonValidations.validate_fields_match([:actor, :attributedTo]) |> CommonValidations.validate_fields_match([:actor, :attributedTo])
|> CommonValidations.validate_actor_is_active() |> CommonValidations.validate_actor_presence()
|> CommonValidations.validate_any_presence([:oneOf, :anyOf]) |> CommonValidations.validate_any_presence([:oneOf, :anyOf])
|> CommonValidations.validate_host_match() |> CommonValidations.validate_host_match()
end end