[MastodonAPI] Add streaming of hashtags

This commit is contained in:
Haelwenn (lanodan) Monnier 2018-08-07 22:45:40 +02:00
parent 5ffaa2bf69
commit 83efaa3af6
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
2 changed files with 7 additions and 2 deletions

View file

@ -84,6 +84,9 @@ def stream_out(activity) do
Pleroma.Web.Streamer.stream("public:local", activity) Pleroma.Web.Streamer.stream("public:local", activity)
end end
activity.data["object"]["tag"]
|> Enum.map(fn tag -> Pleroma.Web.Streamer.stream("hashtag:" <> tag, activity) end)
if activity.data["object"]["attachment"] != [] do if activity.data["object"]["attachment"] != [] do
Pleroma.Web.Streamer.stream("public:media", activity) Pleroma.Web.Streamer.stream("public:media", activity)

View file

@ -23,16 +23,18 @@ def connect(params, socket) do
"public:local:media", "public:local:media",
"user", "user",
"direct", "direct",
"list" "list",
"hashtag"
] <- params["stream"] do ] <- params["stream"] do
topic = if stream == "list", do: "list:#{params["list"]}", else: stream topic = if stream == "list", do: "list:#{params["list"]}", else: stream
socket_stream = if stream == "hashtag", do: "hashtag:#{params["tag"]}", else: stream
socket = socket =
socket socket
|> assign(:topic, topic) |> assign(:topic, topic)
|> assign(:user, user) |> assign(:user, user)
Pleroma.Web.Streamer.add_socket(params["stream"], socket) Pleroma.Web.Streamer.add_socket(socket_stream, socket)
{:ok, socket} {:ok, socket}
else else
_e -> :error _e -> :error