From 5c48fe11386113ffc897b2367b9de30a10bb33ff Mon Sep 17 00:00:00 2001
From: FloatingGhost <hannah@coffee-and-dreams.uk>
Date: Fri, 7 Jan 2022 17:31:13 +0000
Subject: [PATCH 1/2] make credo happy

---
 .../object_validators/article_note_page_validator.ex            | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex b/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex
index 6beeca225..016929da0 100644
--- a/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex
+++ b/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex
@@ -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
 

From 2cc6b1e1bd3059b564d86cb0582827c30fc5cf65 Mon Sep 17 00:00:00 2001
From: FloatingGhost <hannah@coffee-and-dreams.uk>
Date: Fri, 7 Jan 2022 17:35:56 +0000
Subject: [PATCH 2/2] 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 @@ def changeset(struct, %{"type" => "Emoji"} = data) 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 @@ def changeset(struct, %{"type" => "Book"} = data) 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 @@ def changeset(struct, %{"type" => "Edition"} = data) 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])