Merge branch 'delete-account-fix' into 'develop'
[akkoma] / lib / pleroma / captcha / service.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Captcha.Service do
6 @doc """
7 Request new captcha from a captcha service.
8
9 Returns:
10
11 Type/Name of the service, the token to identify the captcha,
12 the data of the answer and service-specific data to use the newly created captcha
13 """
14 @callback new() :: %{
15 type: atom(),
16 token: String.t(),
17 answer_data: any()
18 }
19
20 @doc """
21 Validated the provided captcha solution.
22
23 Arguments:
24 * `token` the captcha is associated with
25 * `captcha` solution of the captcha to validate
26 * `answer_data` is the data needed to validate the answer (presumably encrypted)
27
28 Returns:
29
30 `true` if captcha is valid, `false` if not
31 """
32 @callback validate(
33 token :: String.t(),
34 captcha :: String.t(),
35 answer_data :: any()
36 ) :: :ok | {:error, String.t()}
37 end