configurable timeout
[akkoma] / lib / pleroma / web / mastodon_api / mastodon_api_controller.ex
index 2ad6521cc32597a96862f8577922bb5598a1fb81..396f11a70f5b2914775450de2a6e35104145f310 100644 (file)
@@ -1076,9 +1076,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   @suggestions Application.get_env(:pleroma, :suggestions)
 
   def suggestions(%{assigns: %{user: user}} = conn, _) do
-    api = Keyword.get(@suggestions, :third_party_engine, false)
+    if Keyword.get(@suggestions, :enabled, false) do
+      api = Keyword.get(@suggestions, :third_party_engine, "")
+      timeout = Keyword.get(@suggestions, :timeout, 5000)
 
-    if api do
       host =
         Application.get_env(:pleroma, Pleroma.Web.Endpoint)
         |> Keyword.get(:url)
@@ -1088,7 +1089,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
       url = String.replace(api, "{{host}}", host) |> String.replace("{{user}}", user)
 
       with {:ok, %{status_code: 200, body: body}} <-
-             @httpoison.get(url, [], timeout: 300_000, recv_timeout: 300_000),
+             @httpoison.get(url, [], timeout: timeout, recv_timeout: timeout),
            {:ok, data} <- Jason.decode(body) do
         data2 =
           Enum.slice(data, 0, 40)