1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.ObjectValidators.FollowValidator do
9 import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
16 import Elixir.Pleroma.Web.ActivityPub.ObjectValidators.CommonFields
22 field(:state, :string, default: "pending")
25 def cast_data(data) do
27 |> cast(data, __schema__(:fields))
30 defp validate_data(cng) do
32 |> validate_required([:id, :type, :actor, :to, :cc, :object])
33 |> validate_inclusion(:type, ["Follow"])
34 |> validate_inclusion(:state, ~w{pending reject accept})
35 |> validate_actor_presence()
36 |> validate_actor_presence(field_name: :object)
39 def cast_and_validate(data) do