diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-04-08 23:07:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 23:07:00 +0200 |
commit | 9309c53d21df806d57dd59dbc59a807d2f8b8b11 (patch) | |
tree | 76da7fad9be426213cafdc7f43cba5f00a047caa /app | |
parent | c483101b4ae7d9f22ea43921c512f479e16e98ca (diff) | |
parent | eff62528debf33591c921b28ae2609c948161860 (diff) |
Merge pull request #1738 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/api/v2/search_controller.rb | 4 | ||||
-rw-r--r-- | app/lib/search_query_transformer.rb | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/app/controllers/api/v2/search_controller.rb b/app/controllers/api/v2/search_controller.rb index ddcf92200..77eeab5b0 100644 --- a/app/controllers/api/v2/search_controller.rb +++ b/app/controllers/api/v2/search_controller.rb @@ -11,6 +11,10 @@ class Api::V2::SearchController < Api::BaseController def index @search = Search.new(search_results) render json: @search, serializer: REST::SearchSerializer + rescue Mastodon::SyntaxError + unprocessable_entity + rescue ActiveRecord::RecordNotFound + not_found end private diff --git a/app/lib/search_query_transformer.rb b/app/lib/search_query_transformer.rb index c685d7b6f..aef05e9d9 100644 --- a/app/lib/search_query_transformer.rb +++ b/app/lib/search_query_transformer.rb @@ -88,14 +88,14 @@ class SearchQueryTransformer < Parslet::Transform case prefix when 'from' @filter = :account_id - username, domain = term.split('@') - account = Account.find_remote(username, domain) - raise "Account not found: #{term}" unless account + username, domain = term.gsub(/\A@/, '').split('@') + domain = nil if TagManager.instance.local_domain?(domain) + account = Account.find_remote!(username, domain) @term = account.id else - raise "Unknown prefix: #{prefix}" + raise Mastodon::SyntaxError end end end |