activitypub: short-circuit is_public?() with directMessage flag check
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 20 Jan 2019 02:30:29 +0000 (02:30 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sun, 20 Jan 2019 02:33:21 +0000 (02:33 +0000)
lib/pleroma/web/activity_pub/activity_pub.ex

index 1fedfa854f076be29b7046b12ad209238f264605..68b684c4b9abddb5e8d76df13a08e04f313efc97 100644 (file)
@@ -800,6 +800,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   def is_public?(%Object{data: %{"type" => "Tombstone"}}), do: false
   def is_public?(%Object{data: data}), do: is_public?(data)
   def is_public?(%Activity{data: data}), do: is_public?(data)
+  def is_public?(%{"directMessage" => true}), do: false
 
   def is_public?(data) do
     "https://www.w3.org/ns/activitystreams#Public" in (data["to"] ++ (data["cc"] || []))
@@ -809,6 +810,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     !is_public?(activity) && Enum.any?(activity.data["to"], &String.contains?(&1, "/followers"))
   end
 
+  def is_direct?(%Activity{data: %{"directMessage" => true}}), do: true
+  def is_direct?(%Object{data: %{"directMessage" => true}}), do: true
+
   def is_direct?(activity) do
     !is_public?(activity) && !is_private?(activity)
   end