From: Haelwenn (lanodan) Monnier Date: Sat, 24 Nov 2018 05:13:36 +0000 (+0100) Subject: Web.MastodonAPI.MastodonSocket: Add unauthentified websocket endpoints X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=5346fabf142c19c8442b4421ad3f827ad050ec92;p=akkoma Web.MastodonAPI.MastodonSocket: Add unauthentified websocket endpoints reported by soka on CRTNet --- 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