1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.ObjectValidators.AnswerValidator do
8 alias Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
9 alias Pleroma.Web.ActivityPub.ObjectValidators.Types
16 # Extends from NoteValidator
18 field(:id, Types.ObjectID, primary_key: true)
19 field(:to, {:array, :string}, default: [])
20 field(:cc, {:array, :string}, default: [])
21 field(:bto, {:array, :string}, default: [])
22 field(:bcc, {:array, :string}, default: [])
25 field(:inReplyTo, :string)
26 field(:attributedTo, Types.ObjectID)
29 def cast_and_apply(data) do
32 |> apply_action(:insert)
35 def cast_and_validate(data) do
41 def cast_data(data) do
46 def changeset(struct, data) do
48 |> cast(data, __schema__(:fields))
51 def validate_data(data_cng) do
53 |> validate_inclusion(:type, ["Answer"])
54 |> validate_required([:id, :inReplyTo, :name])
55 |> CommonValidations.validate_any_presence([:cc, :to])
56 |> CommonValidations.validate_actor_presence()