Merge branch 'remake-remodel' into develop
[akkoma] / lib / pleroma / web / activity_pub / object_validators / create_validator.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateNoteValidator do
6 use Ecto.Schema
7
8 alias Pleroma.Web.ActivityPub.ObjectValidators.Types
9 alias Pleroma.Web.ActivityPub.ObjectValidators.NoteValidator
10
11 import Ecto.Changeset
12
13 @primary_key false
14
15 embedded_schema do
16 field(:id, :string, primary_key: true)
17 field(:actor, Types.ObjectID)
18 field(:type, :string)
19 field(:to, {:array, :string})
20 field(:cc, {:array, :string})
21 field(:bto, {:array, :string}, default: [])
22 field(:bcc, {:array, :string}, default: [])
23
24 embeds_one(:object, NoteValidator)
25 end
26
27 def cast_data(data) do
28 %__MODULE__{}
29 |> cast(data, __schema__(:fields))
30 end
31 end