diff --git a/config/config.exs b/config/config.exs index d5db9ef8..0b4f676f 100644 --- a/config/config.exs +++ b/config/config.exs @@ -21,7 +21,8 @@ config :safira, spotlight_duration: String.to_integer(System.get_env("SPOTLIGHT_DURATION") || "30"), discord_bot_url: System.get_env("DISCORD_BOT_URL"), discord_bot_api_key: System.get_env("DISCORD_BOT_API_KEY"), - discord_invite_url: System.get_env("DISCORD_INVITE_URL") + discord_invite_url: System.get_env("DISCORD_INVITE_URL"), + max_cv_file_size: String.to_integer(System.get_env("MAX_CV_SIZE") || "8000000") # Configures the endpoint config :safira, SafiraWeb.Endpoint, diff --git a/lib/safira/email.ex b/lib/safira/email.ex index 3c94d8fe..fd4e2755 100644 --- a/lib/safira/email.ex +++ b/lib/safira/email.ex @@ -4,11 +4,11 @@ defmodule Safira.Email do """ # use Bamboo.Phoenix, view: Safira.FeedbackView import Bamboo.Email - + @from_email Application.compile_env!(:safira, :from_email) def send_reset_email(to_email, token) do new_email() |> to(to_email) - |> from(System.get_env("FROM_EMAIL")) + |> from(@from_email) |> subject("[SEI '23] Reset password instructions") |> html_body(build_reset_password_email_text(token)) |> Safira.Mailer.deliver_now() diff --git a/lib/safira/interaction/interaction.ex b/lib/safira/interaction/interaction.ex index f94d205c..40a9f113 100644 --- a/lib/safira/interaction/interaction.ex +++ b/lib/safira/interaction/interaction.ex @@ -17,6 +17,8 @@ defmodule Safira.Interaction do alias Safira.Repo + @token_bonus Application.compile_env!(:safira, :token_bonus) + @doc """ Returns the list of bonuses. @@ -134,7 +136,7 @@ defmodule Safira.Interaction do |> Multi.update( :update_attendee, Attendee.update_token_balance_changeset(attendee, %{ - token_balance: attendee.token_balance + Application.fetch_env!(:safira, :token_bonus) + token_balance: attendee.token_balance + @token_bonus }) ) |> Multi.insert_or_update(:daily_token, fn %{update_attendee: attendee} -> diff --git a/lib/safira/roulette/roulette.ex b/lib/safira/roulette/roulette.ex index c8121761..fa96162c 100644 --- a/lib/safira/roulette/roulette.ex +++ b/lib/safira/roulette/roulette.ex @@ -18,6 +18,10 @@ defmodule Safira.Roulette do alias Safira.Roulette.Prize alias Safira.Store + @roulette_cost Application.compile_env!(:safira, :roulette_cost) + @roulette_tokens_min Application.compile_env!(:safira, :roulette_tokens_min) + @roulette_tokens_max Application.compile_env!(:safira, :roulette_tokens_max) + @doc """ Returns the list of prizes. @@ -247,7 +251,7 @@ defmodule Safira.Roulette do |> Multi.update( :attendee, Attendee.update_token_balance_changeset(attendee, %{ - token_balance: attendee.token_balance - Application.fetch_env!(:safira, :roulette_cost) + token_balance: attendee.token_balance - @roulette_cost }) ) # prize after spinning @@ -330,8 +334,8 @@ defmodule Safira.Roulette do end defp calculate_tokens(attendee) do - min = Application.fetch_env!(:safira, :roulette_tokens_min) - max = Application.fetch_env!(:safira, :roulette_tokens_max) + min = @roulette_tokens_min + max = @roulette_tokens_max tokens = Enum.random(min..max) Multi.new() diff --git a/lib/safira/web/uploaders/cv.ex b/lib/safira/web/uploaders/cv.ex index ed091185..febf2951 100644 --- a/lib/safira/web/uploaders/cv.ex +++ b/lib/safira/web/uploaders/cv.ex @@ -16,7 +16,7 @@ defmodule Safira.CV do @versions [:original] @acl :public_read - @max_file_size String.to_integer(System.get_env("MAX_CV_FILE_SIZE") || "8000000") + @max_file_size Application.compile_env!(:safira, :max_cv_file_size) def validate({file, _}) do size = file_size(file) diff --git a/lib/safira_web/views/bonus_view.ex b/lib/safira_web/views/bonus_view.ex index 6af2ad0c..d1213ab1 100644 --- a/lib/safira_web/views/bonus_view.ex +++ b/lib/safira_web/views/bonus_view.ex @@ -1,6 +1,8 @@ defmodule SafiraWeb.BonusView do use SafiraWeb, :view + @token_bonus Application.compile_env!(:safira, :token_bonus) + def render("bonus.json", changes) do attendee = Map.get(changes, :update_attendee) bonus = Map.get(changes, :upsert_bonus) @@ -8,7 +10,7 @@ defmodule SafiraWeb.BonusView do %{ name: attendee.name, attendee_id: attendee.id, - token_bonus: Application.fetch_env!(:safira, :token_bonus), + token_bonus: @token_bonus, bonus_count: bonus.count, company_id: bonus.company_id }