Commit 7afabe1c authored by rinpatch's avatar rinpatch 💬
Browse files

Merge branch 'bugfix/status-search-fallback' into 'develop'

Activity.Search: resolve status on DB Timeout

Closes #2566

See merge request !3507
parents 3a7b54be 6455b967
Pipeline #37107 passed with stages
in 91 minutes and 1 second
......@@ -15,6 +15,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Removed
## Unreleased-patch
- Mastodon API: Activity Search fallbacks on status fetching after a DB Timeout/Error
## 2.4.0 - 2021-08-xx
### Changed
......
......@@ -26,19 +26,23 @@ def search(user, search_query, options \\ []) 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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment