From f2efe24cf8b668de160bb893d2b40a7c6151ba78 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 1 Jun 2019 03:23:21 +0000 Subject: [PATCH] visibility: if litepub:directMessage is asserted, always report the object as "direct" visibility --- lib/pleroma/web/activity_pub/visibility.ex | 3 +++ test/web/activity_pub/visibilty_test.exs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/pleroma/web/activity_pub/visibility.ex b/lib/pleroma/web/activity_pub/visibility.ex index 93b50ee47..8965e3253 100644 --- a/lib/pleroma/web/activity_pub/visibility.ex +++ b/lib/pleroma/web/activity_pub/visibility.ex @@ -66,6 +66,9 @@ def get_visibility(object) do Enum.any?(to, &String.contains?(&1, "/followers")) -> "private" + object.data["directMessage"] == true -> + "direct" + length(cc) > 0 -> "private" diff --git a/test/web/activity_pub/visibilty_test.exs b/test/web/activity_pub/visibilty_test.exs index e2584f635..466d980dc 100644 --- a/test/web/activity_pub/visibilty_test.exs +++ b/test/web/activity_pub/visibilty_test.exs @@ -117,4 +117,8 @@ test "get_visibility", %{ assert Visibility.get_visibility(direct) == "direct" assert Visibility.get_visibility(unlisted) == "unlisted" end + + test "get_visibility with directMessage flag" do + assert Visibility.get_visibility(%{data: %{"directMessage" => true}}) == "direct" + end end