QuestionValidator: Use AttachmentValidator

This commit is contained in:
Haelwenn (lanodan) Monnier 2020-06-20 00:07:39 +02:00
parent fe6924d00d
commit 435a65b976
No known key found for this signature in database
GPG Key ID: D5B7A8E43C997DEE

View File

@ -6,6 +6,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionValidator do
use Ecto.Schema use Ecto.Schema
alias Pleroma.Web.ActivityPub.Utils alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator
alias Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations alias Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
alias Pleroma.Web.ActivityPub.ObjectValidators.QuestionOptionsValidator alias Pleroma.Web.ActivityPub.ObjectValidators.QuestionOptionsValidator
alias Pleroma.Web.ActivityPub.ObjectValidators.Types alias Pleroma.Web.ActivityPub.ObjectValidators.Types
@ -34,8 +35,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionValidator do
# TODO: Write type # TODO: Write type
field(:emoji, :map, default: %{}) field(:emoji, :map, default: %{})
field(:sensitive, :boolean, default: false) field(:sensitive, :boolean, default: false)
# TODO: Write type embeds_many(:attachment, AttachmentValidator)
field(:attachment, {:array, :map}, default: [])
field(:replies_count, :integer, default: 0) field(:replies_count, :integer, default: 0)
field(:like_count, :integer, default: 0) field(:like_count, :integer, default: 0)
field(:announcement_count, :integer, default: 0) field(:announcement_count, :integer, default: 0)
@ -99,7 +99,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionValidator do
data = fix(data) data = fix(data)
struct struct
|> cast(data, __schema__(:fields) -- [:anyOf, :oneOf]) |> cast(data, __schema__(:fields) -- [:anyOf, :oneOf, :attachment])
|> cast_embed(:attachment)
|> cast_embed(:anyOf) |> cast_embed(:anyOf)
|> cast_embed(:oneOf) |> cast_embed(:oneOf)
end end