X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fcaptcha%2Fcaptcha_service.ex;h=8d27c04f1e5a5a621c91d7ac8be3ae3b560dc972;hb=f17e0f8e4f8f6249d1de9ad8a21953cca4963045;hp=6037b708709ef4c0d4ce336eb22f371d61626651;hpb=2791ce9a1ff2365ac7256f5e1dc2324dee2f82c9;p=akkoma
diff --git a/lib/pleroma/captcha/captcha_service.ex b/lib/pleroma/captcha/captcha_service.ex
index 6037b7087..8d27c04f1 100644
--- a/lib/pleroma/captcha/captcha_service.ex
+++ b/lib/pleroma/captcha/captcha_service.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Captcha.Service do
@@ -8,9 +8,14 @@ defmodule Pleroma.Captcha.Service do
Returns:
- Service-specific data for using the newly created captcha
+ Type/Name of the service, the token to identify the captcha,
+ the data of the answer and service-specific data to use the newly created captcha
"""
- @callback new() :: map
+ @callback new() :: %{
+ type: atom(),
+ token: String.t(),
+ answer_data: any()
+ }
@doc """
Validated the provided captcha solution.
@@ -18,15 +23,15 @@ defmodule Pleroma.Captcha.Service do
Arguments:
* `token` the captcha is associated with
* `captcha` solution of the captcha to validate
+ * `answer_data` is the data needed to validate the answer (presumably encrypted)
Returns:
`true` if captcha is valid, `false` if not
"""
- @callback validate(token :: String.t(), captcha :: String.t()) :: boolean
-
- @doc """
- This function is called periodically to clean up old captchas
- """
- @callback cleanup() :: :ok
+ @callback validate(
+ token :: String.t(),
+ captcha :: String.t(),
+ answer_data :: any()
+ ) :: :ok | {:error, String.t()}
end