diff options
author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2021-08-12 10:29:53 +0200 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2021-08-13 17:57:50 +0200 |
commit | 27e1e4c742bb37a89e0ca91fda03b5ca8be3984a (patch) | |
tree | ab9563b6defd7314b5d8b86594ae072e9b57c1d5 | |
parent | e1175511693973ef0c5b21ea70e517893f61f4e1 (diff) | |
download | pleroma-27e1e4c742bb37a89e0ca91fda03b5ca8be3984a.tar.gz |
Activity.Search: fallback on status resolution on DB Timeout
Backport of: https://git.pleroma.social/pleroma/pleroma/-/merge_requests/3507
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/pleroma/activity/search.ex | 30 |
2 files changed, 18 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cdb665d1..369a8bbdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - TwitterAPI: Make `change_password` and `change_email` require params on body instead of query - Subscription(Bell) Notifications: Don't create from Pipeline Ingested replies - AdminAPI: Fix rendering reports containing a `nil` object +- Mastodon API: Activity Search fallbacks on status fetching after a DB Timeout/Error ## 2.4.0 - 2021-08-08 diff --git a/lib/pleroma/activity/search.ex b/lib/pleroma/activity/search.ex index ed898ba4f..a5923519c 100644 --- a/lib/pleroma/activity/search.ex +++ b/lib/pleroma/activity/search.ex @@ -26,19 +26,23 @@ defmodule Pleroma.Activity.Search do :plain end - Activity - |> Activity.with_preloaded_object() - |> Activity.restrict_deactivated_users() - |> restrict_public() - |> query_with(index_type, search_query, search_function) - |> maybe_restrict_local(user) - |> maybe_restrict_author(author) - |> maybe_restrict_blocked(user) - |> Pagination.fetch_paginated( - %{"offset" => offset, "limit" => limit, "skip_order" => index_type == :rum}, - :offset - ) - |> maybe_fetch(user, search_query) + try do + Activity + |> Activity.with_preloaded_object() + |> Activity.restrict_deactivated_users() + |> restrict_public() + |> query_with(index_type, search_query, search_function) + |> maybe_restrict_local(user) + |> maybe_restrict_author(author) + |> maybe_restrict_blocked(user) + |> Pagination.fetch_paginated( + %{"offset" => offset, "limit" => limit, "skip_order" => index_type == :rum}, + :offset + ) + |> maybe_fetch(user, search_query) + rescue + _ -> maybe_fetch([], user, search_query) + end end def maybe_restrict_author(query, %User{} = author) do |