Web.MastodonAPI.MastodonSocket: Add unauthentified websocket endpoints

reported by soka on CRTNet
This commit is contained in:
Haelwenn (lanodan) Monnier 2018-11-24 06:13:36 +01:00
parent 675653ceb7
commit 5346fabf14
No known key found for this signature in database
GPG Key ID: D5B7A8E43C997DEE
1 changed files with 18 additions and 0 deletions

View File

@ -45,6 +45,24 @@ def connect(params, socket) do
end end
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 id(_), do: nil
def handle(:text, message, _state) do def handle(:text, message, _state) do