Browse Source

Use String.replace_leading instead of String.replace for getting websocket streaming api url.

Extract the login responsible for obtaining websocket URL into the corresponding
Endpoint function.
tags/v0.9.9
eugenijm 5 years ago
parent
commit
d747bd9870
2 changed files with 5 additions and 1 deletions
  1. +4
    -0
      lib/pleroma/web/endpoint.ex
  2. +1
    -1
      lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

+ 4
- 0
lib/pleroma/web/endpoint.ex View 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

+ 1
- 1
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex View 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",


Loading…
Cancel
Save