Fix tests.
authorcsaurus <csaurus@mailbox.org>
Sun, 13 May 2018 19:33:59 +0000 (15:33 -0400)
committercsaurus <csaurus@mailbox.org>
Sun, 13 May 2018 19:33:59 +0000 (15:33 -0400)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/mastodon_api/views/status_view.ex

index d5d00d4a2726f0e5802af5b901836683a7c1b04d..4b2ecfa3c251faa41a91a1eec2502bdcfbee349f 100644 (file)
@@ -40,18 +40,23 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub 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
index 5c6fd05f3a82eeb07adf9408a6adbdf8ceaa8aed..3012344121240b3737272c3336b159a09b956985 100644 (file)
@@ -195,6 +195,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView 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