Merge branch 'bugfix/status-search-fallback' into 'develop'
Activity.Search: resolve status on DB Timeout Closes #2566 See merge request pleroma/pleroma!3507
This commit is contained in:
commit
7afabe1cc6
2 changed files with 20 additions and 13 deletions
|
@ -15,6 +15,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
## Unreleased-patch
|
||||||
|
- Mastodon API: Activity Search fallbacks on status fetching after a DB Timeout/Error
|
||||||
|
|
||||||
## 2.4.0 - 2021-08-xx
|
## 2.4.0 - 2021-08-xx
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -26,19 +26,23 @@ def search(user, search_query, options \\ []) do
|
||||||
:plain
|
:plain
|
||||||
end
|
end
|
||||||
|
|
||||||
Activity
|
try do
|
||||||
|> Activity.with_preloaded_object()
|
Activity
|
||||||
|> Activity.restrict_deactivated_users()
|
|> Activity.with_preloaded_object()
|
||||||
|> restrict_public()
|
|> Activity.restrict_deactivated_users()
|
||||||
|> query_with(index_type, search_query, search_function)
|
|> restrict_public()
|
||||||
|> maybe_restrict_local(user)
|
|> query_with(index_type, search_query, search_function)
|
||||||
|> maybe_restrict_author(author)
|
|> maybe_restrict_local(user)
|
||||||
|> maybe_restrict_blocked(user)
|
|> maybe_restrict_author(author)
|
||||||
|> Pagination.fetch_paginated(
|
|> maybe_restrict_blocked(user)
|
||||||
%{"offset" => offset, "limit" => limit, "skip_order" => index_type == :rum},
|
|> Pagination.fetch_paginated(
|
||||||
:offset
|
%{"offset" => offset, "limit" => limit, "skip_order" => index_type == :rum},
|
||||||
)
|
:offset
|
||||||
|> maybe_fetch(user, search_query)
|
)
|
||||||
|
|> maybe_fetch(user, search_query)
|
||||||
|
rescue
|
||||||
|
_ -> maybe_fetch([], user, search_query)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_restrict_author(query, %User{} = author) do
|
def maybe_restrict_author(query, %User{} = author) do
|
||||||
|
|
Loading…
Reference in a new issue