From 2cc6b1e1bd3059b564d86cb0582827c30fc5cf65 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Fri, 7 Jan 2022 17:35:56 +0000 Subject: [PATCH] Allow for varying name fields --- .../object_validators/tag_validator.ex | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex b/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex index 00d0194af..dd1bc53ed 100644 --- a/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex @@ -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]) -- 2.45.2