From aa37313416c155a37b40e09617eb2fe524edbf0b Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 20 Jan 2019 02:30:29 +0000 Subject: [PATCH] activitypub: short-circuit is_public?() with directMessage flag check --- lib/pleroma/web/activity_pub/activity_pub.ex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 1fedfa854..68b684c4b 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -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