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.NoteValidator do
8 alias Pleroma.Web.ActivityPub.ObjectValidators.Types
15 field(:id, Types.ObjectID, primary_key: true)
16 field(:to, {:array, :string}, default: [])
17 field(:cc, {:array, :string}, default: [])
18 field(:bto, {:array, :string}, default: [])
19 field(:bcc, {:array, :string}, default: [])
21 field(:tag, {:array, :map}, default: [])
23 field(:content, :string)
24 field(:context, :string)
25 field(:actor, Types.ObjectID)
26 field(:attributedTo, Types.ObjectID)
27 field(:summary, :string)
28 field(:published, Types.DateTime)
30 field(:emoji, :map, default: %{})
31 field(:sensitive, :boolean, default: false)
33 field(:attachment, {:array, :map}, default: [])
34 field(:replies_count, :integer, default: 0)
35 field(:like_count, :integer, default: 0)
36 field(:announcement_count, :integer, default: 0)
37 field(:inRepyTo, :string)
38 field(:uri, Types.Uri)
40 field(:likes, {:array, :string}, default: [])
41 field(:announcements, {:array, :string}, default: [])
44 field(:conversation, :string)
45 field(:context_id, :string)
48 def cast_and_validate(data) do
54 def cast_data(data) do
56 |> cast(data, __schema__(:fields))
59 def validate_data(data_cng) do
61 |> validate_inclusion(:type, ["Note"])
62 |> validate_required([:id, :actor, :to, :cc, :type, :content, :context])