### Fixed
- Not being able to pin unlisted posts
+- Mastodon API: Handling of search timeouts (`/api/v1/search` and `/api/v2/search`)
### Changed
- Configuration: Filter.AnonymizeFilename added ability to retain file extension with custom text
plug(Pleroma.Plugs.RateLimiter, :search when action in [:search, :search2, :account_search])
def search2(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do
- accounts = User.search(query, search_options(params, user))
- statuses = Activity.search(user, query)
+ accounts = with_fallback(fn -> User.search(query, search_options(params, user)) end, [])
+ statuses = with_fallback(fn -> Activity.search(user, query) end, [])
tags_path = Web.base_url() <> "/tag/"
tags =
end
def search(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do
- accounts = User.search(query, search_options(params, user))
- statuses = Activity.search(user, query)
+ accounts = with_fallback(fn -> User.search(query, search_options(params, user)) end, [])
+ statuses = with_fallback(fn -> Activity.search(user, query) end, [])
tags =
query
for_user: user
]
end
+
+ defp with_fallback(f, fallback) do
+ try do
+ f.()
+ rescue
+ error ->
+ Logger.error("#{__MODULE__} search error: #{inspect(error)}")
+ fallback
+ end
+ end
end