MastodonAPI: Add streaming to media tabs of federated and local TLs
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sun, 17 Jun 2018 13:01:27 +0000 (15:01 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sun, 17 Jun 2018 14:17:15 +0000 (16:17 +0200)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/mastodon_api/mastodon_socket.ex

index 267427a2377fd7af245e614ac0e1b51daa27b70c..554202f6bd6b79db6179539134ae8328bcc08e71 100644 (file)
@@ -65,6 +65,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
         if activity.local do
           Pleroma.Web.Streamer.stream("public:local", activity)
         end
+
+        if activity.data["object"]["attachment"] != [] do
+          Pleroma.Web.Streamer.stream("public:media", activity)
+
+          if activity.local do
+            Pleroma.Web.Streamer.stream("public:local:media", activity)
+          end
+        end
       else
         if !Enum.member?(activity.data["cc"] || [], public) &&
              !Enum.member?(
index 46648c366ccf1d29400eba1d1708f853941fe558..17429390677b13328e74327622cb06210cbfd8f0 100644 (file)
@@ -15,8 +15,16 @@ defmodule Pleroma.Web.MastodonAPI.MastodonSocket do
     with token when not is_nil(token) <- params["access_token"],
          %Token{user_id: user_id} <- Repo.get_by(Token, token: token),
          %User{} = user <- Repo.get(User, user_id),
-         stream when stream in ["public", "public:local", "user", "direct", "list"] <-
-           params["stream"] do
+         stream
+         when stream in [
+                "public",
+                "public:local",
+                "public:media",
+                "public:local:media",
+                "user",
+                "direct",
+                "list"
+              ] <- params["stream"] do
       topic = if stream == "list", do: "list:#{params["list"]}", else: stream
 
       socket =