fixup! Fix depreciated calls of fetch_env!/2 and get_env/2

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-09-21 10:15:28 +02:00
parent 009f90e0d7
commit d2372d5700
6 changed files with 19 additions and 27 deletions

View File

@@ -19,6 +19,8 @@ defmodule Mobilizon.Federation.ActivityPub.Federator do
@max_jobs 20
@env Application.compile_env(:mobilizon, :env)
@spec init(any()) :: {:ok, any()}
def init(args) do
{:ok, args}
@@ -83,7 +85,7 @@ defmodule Mobilizon.Federation.ActivityPub.Federator do
def enqueue(type, payload, priority \\ 1) do
Logger.debug("enqueue something with type #{inspect(type)}")
if Application.compile_env(:mobilizon, :env) == :test do
if @env == :test do
handle(type, payload)
else
GenServer.cast(__MODULE__, {:enqueue, type, payload, priority})

View File

@@ -19,6 +19,8 @@ defmodule Mobilizon.Federation.WebFinger do
require Logger
import SweetXml
@env Application.compile_env(:mobilizon, :env)
@doc """
Returns the Web Host Metadata (for `/.well-known/host-meta`) representation for the instance, following RFC6414.
"""
@@ -205,7 +207,7 @@ defmodule Mobilizon.Federation.WebFinger do
{:ok, String.t()} | {:error, :link_not_found} | {:error, any()}
defp find_webfinger_endpoint(domain) when is_binary(domain) do
Logger.debug("Calling HostMetaClient for #{domain}")
prefix = if Application.compile_env(:mobilizon, :env) !== :dev, do: "https", else: "http"
prefix = if @env !== :dev, do: "https", else: "http"
with {:ok, %Tesla.Env{status: 200, body: body}} <-
HostMetaClient.get("#{prefix}://#{domain}/.well-known/host-meta"),
@@ -230,8 +232,7 @@ defmodule Mobilizon.Federation.WebFinger do
_ ->
Logger.debug("Using default webfinger location")
prefix =
if Application.compile_env(:mobilizon, :env) !== :dev, do: "https", else: "http"
prefix = if @env !== :dev, do: "https", else: "http"
"#{prefix}://#{domain}/.well-known/webfinger?resource=acct:#{actor}"
end