CommonValidations: Remove superfluous function
The `is_active` functionality was integrated into the presence checker.
This commit is contained in:
parent
19c108170e
commit
00c4c6a382
|
@ -59,7 +59,7 @@ def validate_data(data_cng) 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
|
||||||
|
|
|
@ -47,19 +47,6 @@ def validate_actor_presence(cng, options \\ []) 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)
|
||||||
|
|
|
@ -55,7 +55,7 @@ def validate_data(cng, meta \\ []) 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)
|
||||||
|
|
|
@ -114,7 +114,7 @@ def validate_data(data_cng) 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
|
||||||
|
|
Loading…
Reference in New Issue