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
17 field(:id, Types.ObjectID, primary_key: true)
18 field(:to, {:array, :string}, default: [])
19 field(:cc, {:array, :string}, default: [])
21 # is this actually needed?
22 field(:bto, {:array, :string}, default: [])
23 field(:bcc, {:array, :string}, default: [])
27 field(:inReplyTo, :string)
28 field(:attributedTo, Types.ObjectID)
29 field(:actor, Types.ObjectID)
32 def cast_and_apply(data) do
35 |> apply_action(:insert)
38 def cast_and_validate(data) do
44 def cast_data(data) do
49 def changeset(struct, data) do
51 |> cast(data, __schema__(:fields))
54 def validate_data(data_cng) do
56 |> validate_inclusion(:type, ["Answer"])
57 |> validate_required([:id, :inReplyTo, :name])
58 |> CommonValidations.validate_any_presence([:cc, :to])
59 |> CommonValidations.validate_actor_presence()