diff options
author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2018-11-24 06:13:36 +0100 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2018-11-24 06:13:36 +0100 |
commit | 5346fabf142c19c8442b4421ad3f827ad050ec92 (patch) | |
tree | a54165610dde8b0015e2a8c97d2c5b3fe836e93e | |
parent | 675653ceb78e4a64d8375904e555cdd62f064e21 (diff) | |
download | pleroma-5346fabf142c19c8442b4421ad3f827ad050ec92.tar.gz |
Web.MastodonAPI.MastodonSocket: Add unauthentified websocket endpoints
reported by soka on CRTNet
-rw-r--r-- | lib/pleroma/web/mastodon_api/mastodon_socket.ex | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/pleroma/web/mastodon_api/mastodon_socket.ex b/lib/pleroma/web/mastodon_api/mastodon_socket.ex index 0f3d5ff7c..46ec5ecd2 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_socket.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_socket.ex @@ -45,6 +45,24 @@ defmodule Pleroma.Web.MastodonAPI.MastodonSocket do end end + def connect(%{"stream" => stream} = params, socket) + when stream in ["public", "public:local", "hashtag"] do + topic = + case stream do + "hashtag" -> "hashtag:#{params["tag"]}" + _ -> stream + end + + with socket = + socket + |> assign(:topic, topic) do + Pleroma.Web.Streamer.add_socket(topic, socket) + {:ok, socket} + else + _e -> :error + end + end + def id(_), do: nil def handle(:text, message, _state) do |