projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Migrations: generate unset user keys
[akkoma]
/
lib
/
pleroma
/
web
/
activity_pub
/
object_validators
/
question_options_validator.ex
diff --git
a/lib/pleroma/web/activity_pub/object_validators/question_options_validator.ex
b/lib/pleroma/web/activity_pub/object_validators/question_options_validator.ex
index 9bc7e0cc0886cf5d25d21cc1cedd8a3c65471bb5..ddcd1be7ca1c7a025e9f6ba5812849da676d0656 100644
(file)
--- a/
lib/pleroma/web/activity_pub/object_validators/question_options_validator.ex
+++ b/
lib/pleroma/web/activity_pub/object_validators/question_options_validator.ex
@@
-1,46
+1,36
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-202
0
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-202
1
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionOptionsValidator do
use Ecto.Schema
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionOptionsValidator do
use Ecto.Schema
- alias Pleroma.Web.ActivityPub.ObjectValidators.QuestionOptionsRepliesValidator
-
import Ecto.Changeset
@primary_key false
embedded_schema do
field(:name, :string)
import Ecto.Changeset
@primary_key false
embedded_schema do
field(:name, :string)
- embeds_one(:replies, QuestionOptionsRepliesValidator)
+
+ embeds_one :replies, Replies, primary_key: false do
+ field(:totalItems, :integer)
+ field(:type, :string)
+ end
+
field(:type, :string)
end
def changeset(struct, data) do
struct
|> cast(data, [:name, :type])
field(:type, :string)
end
def changeset(struct, data) do
struct
|> cast(data, [:name, :type])
- |> cast_embed(:replies)
+ |> cast_embed(:replies
, with: &replies_changeset/2
)
|> validate_inclusion(:type, ["Note"])
|> validate_required([:name, :type])
end
|> validate_inclusion(:type, ["Note"])
|> validate_required([:name, :type])
end
-end
-
-defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionOptionsRepliesValidator do
- use Ecto.Schema
-
- import Ecto.Changeset
- @primary_key false
-
- embedded_schema do
- field(:totalItems, :integer)
- field(:type, :string)
- end
-
- def changeset(struct, data) do
+ def replies_changeset(struct, data) do
struct
struct
- |> cast(data,
__schema__(:fields)
)
+ |> cast(data,
[:totalItems, :type]
)
|> validate_inclusion(:type, ["Collection"])
|> validate_required([:type])
end
|> validate_inclusion(:type, ["Collection"])
|> validate_required([:type])
end