From bf9cd4a0e24e2279a7560f6fb5e58d2d69362125 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 4 Feb 2021 10:11:48 -0600 Subject: [PATCH] Standardize the way we capture and use Mix.env() --- lib/pleroma/application.ex | 10 +++++----- lib/pleroma/emoji/loader.ex | 4 +++- lib/pleroma/uploaders/uploader.ex | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index 9e262235e..375507de1 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -14,7 +14,7 @@ defmodule Pleroma.Application do @name Mix.Project.config()[:name] @version Mix.Project.config()[:version] @repository Mix.Project.config()[:source_url] - @env Mix.env() + @mix_env Mix.env() def name, do: @name def version, do: @version @@ -92,15 +92,15 @@ def start(_type, _args) do Pleroma.Web.Plugs.RateLimiter.Supervisor ] ++ cachex_children() ++ - http_children(adapter, @env) ++ + http_children(adapter, @mix_env) ++ [ Pleroma.Stats, Pleroma.JobQueueMonitor, {Majic.Pool, [name: Pleroma.MajicPool, pool_size: Config.get([:majic_pool, :size], 2)]}, {Oban, Config.get(Oban)} ] ++ - task_children(@env) ++ - dont_run_in_test(@env) ++ + task_children(@mix_env) ++ + dont_run_in_test(@mix_env) ++ chat_child(chat_enabled?()) ++ [ Pleroma.Web.Endpoint, @@ -145,7 +145,7 @@ def load_custom_modules do raise "Invalid custom modules" {:ok, modules, _warnings} -> - if @env != :test do + if @mix_env != :test do Enum.each(modules, fn mod -> Logger.info("Custom module loaded: #{inspect(mod)}") end) diff --git a/lib/pleroma/emoji/loader.ex b/lib/pleroma/emoji/loader.ex index cc25dabf9..67acd7069 100644 --- a/lib/pleroma/emoji/loader.ex +++ b/lib/pleroma/emoji/loader.ex @@ -15,6 +15,8 @@ defmodule Pleroma.Emoji.Loader do require Logger + @mix_env Mix.env() + @type pattern :: Regex.t() | module() | String.t() @type patterns :: pattern() | [pattern()] @type group_patterns :: keyword(patterns()) @@ -79,7 +81,7 @@ def load do # for testing emoji.txt entries we do not want exposed in normal operation test_emoji = - if Mix.env() == :test do + if @mix_env == :test do load_from_file("test/config/emoji.txt", emoji_groups) else [] diff --git a/lib/pleroma/uploaders/uploader.ex b/lib/pleroma/uploaders/uploader.ex index af99d001c..0be878ca2 100644 --- a/lib/pleroma/uploaders/uploader.ex +++ b/lib/pleroma/uploaders/uploader.ex @@ -5,6 +5,8 @@ defmodule Pleroma.Uploaders.Uploader do import Pleroma.Web.Gettext + @mix_env Mix.env() + @moduledoc """ Defines the contract to put and get an uploaded file to any backend. """ @@ -74,7 +76,7 @@ defp handle_callback(uploader, upload) do end defp callback_timeout do - case Mix.env() do + case @mix_env do :test -> 1_000 _ -> 30_000 end