mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-22 09:18:18 +00:00
Add port if specified.
This commit is contained in:
parent
e7dc39e40c
commit
d18473f0c3
|
@ -20,13 +20,6 @@ defmodule Pleroma.Upload do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp url_for(file) do
|
defp url_for(file) do
|
||||||
host =
|
"#{Pleroma.Web.base_url()}/media/#{file}"
|
||||||
Application.get_env(:pleroma, Pleroma.Web.Endpoint)
|
|
||||||
|> Keyword.fetch!(:url)
|
|
||||||
|> Keyword.fetch!(:host)
|
|
||||||
|
|
||||||
protocol = Application.get_env(:pleroma, Pleroma.Web.Endpoint) |> Keyword.fetch!(:protocol)
|
|
||||||
|
|
||||||
"#{protocol}://#{host}/media/#{file}"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,13 +29,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_id(type) do
|
def generate_id(type) do
|
||||||
host =
|
"#{Pleroma.Web.base_url()}/#{type}/#{Ecto.UUID.generate}"
|
||||||
Application.get_env(:pleroma, Pleroma.Web.Endpoint)
|
|
||||||
|> Keyword.fetch!(:url)
|
|
||||||
|> Keyword.fetch!(:host)
|
|
||||||
|
|
||||||
protocol = Application.get_env(:pleroma, Pleroma.Web.Endpoint) |> Keyword.fetch!(:protocol)
|
|
||||||
"#{protocol}://#{host}/#{type}/#{Ecto.UUID.generate}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_public_activities(opts \\ %{}) do
|
def fetch_public_activities(opts \\ %{}) do
|
||||||
|
|
|
@ -60,4 +60,23 @@ defmodule Pleroma.Web do
|
||||||
defmacro __using__(which) when is_atom(which) do
|
defmacro __using__(which) when is_atom(which) do
|
||||||
apply(__MODULE__, which, [])
|
apply(__MODULE__, which, [])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def base_url do
|
||||||
|
settings = Application.get_env(:pleroma, Pleroma.Web.Endpoint)
|
||||||
|
host =
|
||||||
|
settings
|
||||||
|
|> Keyword.fetch!(:url)
|
||||||
|
|> Keyword.fetch!(:host)
|
||||||
|
|
||||||
|
protocol = settings |> Keyword.fetch!(:protocol)
|
||||||
|
|
||||||
|
port_fragment = with {:ok, protocol_info} <- settings |> Keyword.fetch(String.to_atom(protocol)),
|
||||||
|
{:ok, port} <- protocol_info |> Keyword.fetch(:port)
|
||||||
|
do
|
||||||
|
":#{port}"
|
||||||
|
else _e ->
|
||||||
|
""
|
||||||
|
end
|
||||||
|
"#{protocol}://#{host}#{port_fragment}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue