Add enabled check on /translation/languages
authorFloatingGhost <hannah@coffee-and-dreams.uk>
Sun, 6 Nov 2022 22:55:26 +0000 (22:55 +0000)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Sun, 6 Nov 2022 22:55:26 +0000 (22:55 +0000)
lib/pleroma/web/akkoma_api/controllers/translation_controller.ex

index 9983a7e3926e83ca45bb6542d72d9ff0fb71396f..ca9b4b64a9f067a537ebd419d47b4b6d28a9c90f 100644 (file)
@@ -21,10 +21,12 @@ defmodule Pleroma.Web.AkkomaAPI.TranslationController do
 
   @doc "GET /api/v1/akkoma/translation/languages"
   def languages(conn, _params) do
-    with {:ok, source_languages, dest_languages} <- get_languages() do
+    with {:enabled, true} <- {:enabled, Pleroma.Config.get([:translator, :enabled])},
+         {:ok, source_languages, dest_languages} <- get_languages() do
       conn
       |> json(%{source: source_languages, target: dest_languages})
     else
+      {:enabled, false} -> json(conn, %{})
       e -> IO.inspect(e)
     end
   end