Merge remote-tracking branch 'upstream/bookwyrm-entities' into develop

This commit is contained in:
FloatingGhost 2022-01-07 17:36:21 +00:00
commit 34780cf182
2 changed files with 21 additions and 4 deletions

View file

@ -6,10 +6,10 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator do
use Ecto.Schema
alias Pleroma.EctoType.ActivityPub.ObjectValidators
alias Pleroma.Object.Fetcher
alias Pleroma.Web.ActivityPub.ObjectValidators.CommonFixes
alias Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
alias Pleroma.Web.ActivityPub.Transmogrifier
alias Pleroma.Object.Fetcher
import Ecto.Changeset

View file

@ -69,7 +69,12 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidator do
end
def changeset(struct, %{"type" => "Book"} = data) do
data = Map.put(data, "name", data["title"])
data =
if Map.has_key?(data, "title") do
Map.put(data, "name", data["title"])
else
data
end
struct
|> cast(data, [:type, :name])
@ -77,7 +82,14 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidator do
end
def changeset(struct, %{"type" => "Edition"} = data) do
data = Map.put(data, "name", data["title"])
# Sometimes it's title, sometimes name
# Don't ask me.
data =
if Map.has_key?(data, "title") do
Map.put(data, "name", data["title"])
else
data
end
struct
|> cast(data, [:type, :name])
@ -85,7 +97,12 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidator do
end
def changeset(struct, %{"type" => "Work"} = data) do
data = Map.put(data, "name", data["title"])
data =
if Map.has_key?(data, "title") do
Map.put(data, "name", data["title"])
else
data
end
struct
|> cast(data, [:type, :name])