diff options
author | lain <lain@soykaf.club> | 2020-12-18 17:44:46 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-12-18 17:44:46 +0100 |
commit | 713612c37725c81b0906b03528c9eaa474816c7d (patch) | |
tree | 553b3f7c24875b7ed0fbb58375dcd6904206f47e /lib/pleroma/captcha.ex | |
parent | 9a744d49c824e0a7d9963b00893fb2091e3ac4ab (diff) | |
download | pleroma-713612c37725c81b0906b03528c9eaa474816c7d.tar.gz |
Cachex: Make caching provider switchable at runtime.
Defaults to Cachex.
Diffstat (limited to 'lib/pleroma/captcha.ex')
-rw-r--r-- | lib/pleroma/captcha.ex | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/pleroma/captcha.ex b/lib/pleroma/captcha.ex index 6ab754b6f..990003dcd 100644 --- a/lib/pleroma/captcha.ex +++ b/lib/pleroma/captcha.ex @@ -7,6 +7,8 @@ defmodule Pleroma.Captcha do alias Plug.Crypto.KeyGenerator alias Plug.Crypto.MessageEncryptor + @cachex Pleroma.Config.get([:cachex, :provider], Cachex) + @doc """ Ask the configured captcha service for a new captcha """ @@ -86,7 +88,7 @@ defmodule Pleroma.Captcha do end defp validate_usage(token) do - if is_nil(Cachex.get!(:used_captcha_cache, token)) do + if is_nil(@cachex.get!(:used_captcha_cache, token)) do :ok else {:error, :already_used} @@ -95,7 +97,7 @@ defmodule Pleroma.Captcha do defp mark_captcha_as_used(token) do ttl = seconds_valid() |> :timer.seconds() - Cachex.put(:used_captcha_cache, token, true, ttl: ttl) + @cachex.put(:used_captcha_cache, token, true, ttl: ttl) end defp method, do: Pleroma.Config.get!([__MODULE__, :method]) |