Mastodon API: Fix list streaming
authorKokaKiwi <kokakiwi@kokakiwi.net>
Sun, 11 Nov 2018 03:33:14 +0000 (04:33 +0100)
committerKokaKiwi <kokakiwi@kokakiwi.net>
Sun, 11 Nov 2018 13:18:15 +0000 (14:18 +0100)
lib/pleroma/web/mastodon_api/mastodon_socket.ex

index bc628ba566fb6a858d3c458a07fb9e711d7e4427..0f3d5ff7c8832bf74cb213b2a7d331da2aa21767 100644 (file)
@@ -26,15 +26,19 @@ defmodule Pleroma.Web.MastodonAPI.MastodonSocket do
                 "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
+      topic =
+        case stream do
+          "hashtag" -> "hashtag:#{params["tag"]}"
+          "list" -> "list:#{params["list"]}"
+          _ -> stream
+        end
 
       socket =
         socket
         |> assign(:topic, topic)
         |> assign(:user, user)
 
-      Pleroma.Web.Streamer.add_socket(socket_stream, socket)
+      Pleroma.Web.Streamer.add_socket(topic, socket)
       {:ok, socket}
     else
       _e -> :error