From 9aabff48835d55cf284229298ad86c07fa1fce30 Mon Sep 17 00:00:00 2001 From: csaurus Date: Sun, 13 May 2018 15:33:59 -0400 Subject: [PATCH] Fix tests. --- lib/pleroma/web/activity_pub/activity_pub.ex | 21 ++++++++++++------- .../web/mastodon_api/views/status_view.ex | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index d5d00d4a2..4b2ecfa3c 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -40,18 +40,23 @@ def insert(map, local \\ true) when is_map(map) do end def stream_out(activity) do + public = "https://www.w3.org/ns/activitystreams#Public" + if activity.data["type"] in ["Create", "Announce"] do Pleroma.Web.Streamer.stream("user", activity) - visibility = Pleroma.Web.MastodonAPI.StatusView.get_visibility(activity.data["object"]) + if Enum.member?(activity.data["to"], public) do + Pleroma.Web.Streamer.stream("public", activity) - case visibility do - "public" -> - Pleroma.Web.Streamer.stream("public", activity) - if activity.local, do: Pleroma.Web.Streamer.stream("public:local", activity) - - "direct" -> - Pleroma.Web.Streamer.stream("direct", activity) + if activity.local do + Pleroma.Web.Streamer.stream("public:local", activity) + end + else + if !Enum.member?(activity.data["cc"] || [], public) && + !Enum.member?( + activity.data["to"], + User.get_by_ap_id(activity.data["actor"]).follower_address + ), do: Pleroma.Web.Streamer.stream("direct", activity) end end end diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 5c6fd05f3..301234412 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -195,6 +195,7 @@ def get_visibility(object) do cond do public in to -> "public" public in cc -> "unlisted" + # this should use the sql for the object's activity Enum.any?(to, &String.contains?(&1, "/followers")) -> "private" true -> "direct" end