transmogrifier.ex: Add fix_summary/1
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Wed, 10 Apr 2019 00:32:04 +0000 (02:32 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Wed, 10 Apr 2019 00:32:04 +0000 (02:32 +0200)
MRF.KeywordPolicy assumes that summary is present in a activity,
and this would probably simplify code elsewhere too anyway.

lib/pleroma/web/activity_pub/transmogrifier.ex

index f733ae7e1df2789ee2981c2a4963d2ce8572f2d7..9d4cbab0bc8f3f291cb995faf4721322a5f52635 100644 (file)
@@ -83,6 +83,22 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     |> fix_content_map
     |> fix_likes
     |> fix_addressing
+    |> fix_summary
+  end
+
+  def fix_summary(%{"summary" => nil} = object) do
+    object
+    |> Map.put("summary", "")
+  end
+
+  def fix_summary(%{"summary" => _} = object) do
+    # summary is present, nothing to do
+    object
+  end
+
+  def fix_summary(object) do
+    object
+    |> Map.put("summary", "")
   end
 
   def fix_addressing_list(map, field) do