|> validate_required([:id, :inReplyTo, :name, :attributedTo, :actor])
|> CommonValidations.validate_any_presence([:cc, :to])
|> CommonValidations.validate_fields_match([:actor, :attributedTo])
- |> CommonValidations.validate_actor_is_active()
+ |> CommonValidations.validate_actor_presence()
|> CommonValidations.validate_host_match()
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
field_name = Keyword.get(options, :field_name, :object)
allowed_types = Keyword.get(options, :allowed_types, false)
cng
|> validate_required([:actor, :type, :object])
|> validate_inclusion(:type, ["Create"])
- |> validate_actor_is_active()
+ |> validate_actor_presence()
|> validate_any_presence([:to, :cc])
|> validate_actors_match(meta)
|> validate_context_match(meta)
|> validate_required([:id, :actor, :attributedTo, :type, :context])
|> CommonValidations.validate_any_presence([:cc, :to])
|> CommonValidations.validate_fields_match([:actor, :attributedTo])
- |> CommonValidations.validate_actor_is_active()
+ |> CommonValidations.validate_actor_presence()
|> CommonValidations.validate_any_presence([:oneOf, :anyOf])
|> CommonValidations.validate_host_match()
end