add bubble timeline (#100)
[akkoma] / lib / pleroma / web / mastodon_api / websocket_handler.ex
index b978167b6288f95b3e8b042fb0b9625c2429e37f..861a7ce3eb5c7d893cd6b55b850a8e08beb7ef52 100644 (file)
@@ -65,6 +65,11 @@ defmodule Pleroma.Web.MastodonAPI.WebsocketHandler do
   # We only receive pings for now
   def websocket_handle(:ping, state), do: {:ok, state}
 
+  def websocket_handle({:text, "ping"}, state) do
+    if state.timer, do: Process.cancel_timer(state.timer)
+    {:reply, {:text, "pong"}, %{state | timer: timer()}}
+  end
+
   def websocket_handle(frame, state) do
     Logger.error("#{__MODULE__} received frame: #{inspect(frame)}")
     {:ok, state}