projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'develop' into 'feat/floki-fast-html-2'
[akkoma]
/
lib
/
pleroma
/
captcha
/
kocaptcha.ex
diff --git
a/lib/pleroma/captcha/kocaptcha.ex
b/lib/pleroma/captcha/kocaptcha.ex
index a3128decb4daa8ef43acaf5aeef8aaf5a89c6b8e..337506647b373c21b9532bb924464982eeceaefb 100644
(file)
--- a/
lib/pleroma/captcha/kocaptcha.ex
+++ b/
lib/pleroma/captcha/kocaptcha.ex
@@
-1,21
+1,18
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-20
19
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-20
20
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Captcha.Kocaptcha do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Captcha.Kocaptcha do
- import Pleroma.Web.Gettext
alias Pleroma.Captcha.Service
alias Pleroma.Captcha.Service
-
@behaviour Service
@behaviour Service
- @default_endpoint "https://captcha.kotobank.ch"
@impl Service
def new do
@impl Service
def new do
- endpoint = Pleroma.Config.get
([__MODULE__, :endpoint], @default_endpoint
)
+ endpoint = Pleroma.Config.get
!([__MODULE__, :endpoint]
)
case Tesla.get(endpoint <> "/new") do
{:error, _} ->
case Tesla.get(endpoint <> "/new") do
{:error, _} ->
- %{error:
dgettext("errors", "Kocaptcha service unavailable")
}
+ %{error:
:kocaptcha_service_unavailable
}
{:ok, res} ->
json_resp = Jason.decode!(res.body)
{:ok, res} ->
json_resp = Jason.decode!(res.body)
@@
-24,7
+21,8
@@
defmodule Pleroma.Captcha.Kocaptcha do
type: :kocaptcha,
token: json_resp["token"],
url: endpoint <> json_resp["url"],
type: :kocaptcha,
token: json_resp["token"],
url: endpoint <> json_resp["url"],
- answer_data: json_resp["md5"]
+ answer_data: json_resp["md5"],
+ seconds_valid: Pleroma.Config.get([Pleroma.Captcha, :seconds_valid])
}
end
end
}
end
end
@@
-35,6
+33,6
@@
defmodule Pleroma.Captcha.Kocaptcha do
if not is_nil(captcha) and
:crypto.hash(:md5, captcha) |> Base.encode16() == String.upcase(answer_data),
do: :ok,
if not is_nil(captcha) and
:crypto.hash(:md5, captcha) |> Base.encode16() == String.upcase(answer_data),
do: :ok,
- else: {:error,
dgettext("errors", "Invalid CAPTCHA")
}
+ else: {:error,
:invalid
}
end
end
end
end