api/instance/translator_languages: only query service if enabled
The instance controller already had code for an {:enabled, false}
return, just nothing actually checked or produced this value.
This was especially noticeable when using mastodon-fe and not having a
valid API token for the default DeepL service configured. Mastodon-fe
proactively queries this endpoint and upon receiving a 403 response
the controller raised an exception leading to this exception and
call trace being spammed in logs.
This commit is contained in:
parent
f48125fcb4
commit
c1e70540b4
2 changed files with 4 additions and 1 deletions
|
|
@ -42,6 +42,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- fixed potential data inconsistencies and API ordering for rediscovered partially pruned objects
|
||||
- fixed tagged (mentioned) but not addressed users receiving notifications about
|
||||
statuses they are not actually allowed to access
|
||||
- fixed tranlator service being queried for supported languages even if not enabled
|
||||
|
||||
### Changed
|
||||
- New installations (not existing instances) now default to the `simple` full-text-search config
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@ defmodule Pleroma.Akkoma.Translator do
|
|||
module = Pleroma.Config.get([:translator, :module])
|
||||
|
||||
@cachex.fetch!(:translations_cache, "languages:#{module}}", fn _ ->
|
||||
with {:ok, source_languages, dest_languages} <- module.languages() do
|
||||
with {_, true} <- {:enabled, Pleroma.Config.get([:translator, :enabled])},
|
||||
{:ok, source_languages, dest_languages} <- module.languages() do
|
||||
{:commit, {:ok, source_languages, dest_languages}}
|
||||
else
|
||||
{:enabled, _} -> {:commit, {:enabled, false}}
|
||||
{:error, err} -> {:ignore, {:error, err}}
|
||||
end
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue