activitypub: allow is_public?() to work on any type of map representing an AS2 object
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 17 Jan 2019 23:17:59 +0000 (23:17 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 17 Jan 2019 23:21:31 +0000 (23:21 +0000)
lib/pleroma/web/activity_pub/activity_pub.ex

index 8c852edbd82a57e644eab89122f34186c9cd6b18..92c5ce2aea090340f1b861ab54c9f0f0deaadcad 100644 (file)
@@ -797,13 +797,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     end
   end
 
-  def is_public?(%Object{data: %{"type" => "Tombstone"}}) do
-    false
-  end
+  def is_public?(%Object{data: %{"type" => "Tombstone"}}), do: false
+  def is_public?(%Activity{data: data}), do: is_public?(data)
 
-  def is_public?(activity) do
-    "https://www.w3.org/ns/activitystreams#Public" in (activity.data["to"] ++
-                                                         (activity.data["cc"] || []))
+  def is_public?(data) do
+    "https://www.w3.org/ns/activitystreams#Public" in (data["to"] ++ (data["cc"] || []))
   end
 
   def visible_for_user?(activity, nil) do