Use String.replace_leading instead of String.replace for getting websocket streaming...
authoreugenijm <eugenijm@protonmail.com>
Fri, 1 Feb 2019 18:56:18 +0000 (21:56 +0300)
committereugenijm <eugenijm@protonmail.com>
Fri, 1 Feb 2019 18:58:43 +0000 (21:58 +0300)
Extract the login responsible for obtaining websocket URL into the corresponding
Endpoint function.

lib/pleroma/web/endpoint.ex
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

index 2b156fdfd5489df1d9c4926ea05cabd5ca535285..ebbc5d7b5ec48becc65ad8ddac08a1c4aa0b3277 100644 (file)
@@ -82,4 +82,8 @@ defmodule Pleroma.Web.Endpoint do
     port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
     {:ok, Keyword.put(config, :http, [:inet6, port: port])}
   end
+
+  def websocket_url do
+    String.replace_leading(static_url(), "http", "ws")
+  end
 end
index a94eb5c73f8f2b5e34b80ffbb1f54385f1dea907..85769c3d7d42aad14ec5a9e25c48978d17ac7726 100644 (file)
@@ -138,7 +138,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
       version: "#{@mastodon_api_level} (compatible; #{Pleroma.Application.named_version()})",
       email: Keyword.get(instance, :email),
       urls: %{
-        streaming_api: String.replace(Pleroma.Web.Endpoint.static_url(), "http", "ws")
+        streaming_api: Pleroma.Web.Endpoint.websocket_url()
       },
       stats: Stats.get_stats(),
       thumbnail: Web.base_url() <> "/instance/thumbnail.jpeg",