|
|
@@ -38,7 +38,13 @@ defmodule Pleroma.Captcha do |
|
|
|
if !enabled do |
|
|
|
{:reply, %{type: :none}, state} |
|
|
|
else |
|
|
|
{:reply, method().new(), state} |
|
|
|
new_captcha = method().new() |
|
|
|
|
|
|
|
minutes_retained = Pleroma.Config.get!([__MODULE__, :minutes_retained]) |
|
|
|
# Wait several minutes and if the captcha is still there, delete it |
|
|
|
Process.send_after(self(), {:cleanup, new_captcha.token}, 1000 * 60 * minutes_retained) |
|
|
|
|
|
|
|
{:reply, new_captcha, state} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
@@ -47,5 +53,12 @@ defmodule Pleroma.Captcha do |
|
|
|
{:reply, method().validate(token, captcha), state} |
|
|
|
end |
|
|
|
|
|
|
|
@doc false |
|
|
|
def handle_info({:cleanup, token}, state) do |
|
|
|
method().cleanup(token) |
|
|
|
|
|
|
|
{:noreply, state} |
|
|
|
end |
|
|
|
|
|
|
|
defp method, do: Pleroma.Config.get!([__MODULE__, :method]) |
|
|
|
end |