1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.ObjectValidators.BlockValidator do
8 alias Pleroma.EctoType.ActivityPub.ObjectValidators
11 import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
16 field(:id, ObjectValidators.ObjectID, primary_key: true)
18 field(:actor, ObjectValidators.ObjectID)
19 field(:to, ObjectValidators.Recipients, default: [])
20 field(:cc, ObjectValidators.Recipients, default: [])
21 field(:object, ObjectValidators.ObjectID)
24 def cast_data(data) do
26 |> cast(data, __schema__(:fields))
29 def validate_data(cng) do
31 |> validate_required([:id, :type, :actor, :to, :cc, :object])
32 |> validate_inclusion(:type, ["Block"])
33 |> validate_actor_presence()
34 |> validate_actor_presence(field_name: :object)
37 def cast_and_validate(data) do