[MastodonAPI] Add streaming of hashtags
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Tue, 7 Aug 2018 20:45:40 +0000 (22:45 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Mon, 27 Aug 2018 13:08:25 +0000 (15:08 +0200)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/mastodon_api/mastodon_socket.ex

index 68b3987866f71ea97f2896e7a2379ac322451987..749ffbcd48bda62ac3320b54561b67bd05b7f302 100644 (file)
@@ -84,6 +84,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
           Pleroma.Web.Streamer.stream("public:local", activity)
         end
 
+        activity.data["object"]["tag"]
+        |> Enum.map(fn tag -> Pleroma.Web.Streamer.stream("hashtag:" <> tag, activity) end)
+
         if activity.data["object"]["attachment"] != [] do
           Pleroma.Web.Streamer.stream("public:media", activity)
 
index 17429390677b13328e74327622cb06210cbfd8f0..bc628ba566fb6a858d3c458a07fb9e711d7e4427 100644 (file)
@@ -23,16 +23,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonSocket do
                 "public:local:media",
                 "user",
                 "direct",
-                "list"
+                "list",
+                "hashtag"
               ] <- params["stream"] do
       topic = if stream == "list", do: "list:#{params["list"]}", else: stream
+      socket_stream = if stream == "hashtag", do: "hashtag:#{params["tag"]}", else: stream
 
       socket =
         socket
         |> assign(:topic, topic)
         |> assign(:user, user)
 
-      Pleroma.Web.Streamer.add_socket(params["stream"], socket)
+      Pleroma.Web.Streamer.add_socket(socket_stream, socket)
       {:ok, socket}
     else
       _e -> :error