activitypub: add is_private?/is_direct? helpers
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 23 Dec 2018 15:27:08 +0000 (15:27 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sun, 20 Jan 2019 02:27:48 +0000 (02:27 +0000)
lib/pleroma/web/activity_pub/activity_pub.ex

index 130c06028f21585096c4e423a395bffdcec9a641..1fedfa854f076be29b7046b12ad209238f264605 100644 (file)
@@ -805,6 +805,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     "https://www.w3.org/ns/activitystreams#Public" in (data["to"] ++ (data["cc"] || []))
   end
 
+  def is_private?(activity) do
+    !is_public?(activity) && Enum.any?(activity.data["to"], &String.contains?(&1, "/followers"))
+  end
+
+  def is_direct?(activity) do
+    !is_public?(activity) && !is_private?(activity)
+  end
+
   def visible_for_user?(activity, nil) do
     is_public?(activity)
   end