diff options
author | eugenijm <eugenijm@protonmail.com> | 2019-02-01 21:56:18 +0300 |
---|---|---|
committer | eugenijm <eugenijm@protonmail.com> | 2019-02-01 21:58:43 +0300 |
commit | d747bd98700dd8b015ef48e8a2a1df0025012b0a (patch) | |
tree | 33e96d85f882c0a4d4a0e0d9ed859dabca3167b6 /lib | |
parent | 389e6a878a7636c29f57cb4603abd33f4cca98d9 (diff) | |
download | pleroma-d747bd98700dd8b015ef48e8a2a1df0025012b0a.tar.gz |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/endpoint.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex index 2b156fdfd..ebbc5d7b5 100644 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@ -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 diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index a94eb5c73..85769c3d7 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -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", |