From 5f79f27b78a3081dfc40998b0eccccf44f84bd3b Mon Sep 17 00:00:00 2001 From: single-right-quote <34298117+single-right-quote@users.noreply.github.com> Date: Sat, 9 Apr 2022 00:08:23 +0000 Subject: [PATCH] Revert "Fix error resposes for `from` search prefix (#17963)" This reverts commit 012537452a1b9087ea085253e8d42fe4129cea42. This version of the fix is incompatible with changes introduced here, and we prefer the functionality of our change. --- app/controllers/api/v2/search_controller.rb | 4 ---- app/lib/search_query_transformer.rb | 8 ++++---- lib/exceptions.rb | 1 - 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/v2/search_controller.rb b/app/controllers/api/v2/search_controller.rb index 77eeab5b0..ddcf92200 100644 --- a/app/controllers/api/v2/search_controller.rb +++ b/app/controllers/api/v2/search_controller.rb @@ -11,10 +11,6 @@ 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 aef05e9d9..c685d7b6f 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) - username, domain = term.gsub(/\A@/, '').split('@') - domain = nil if TagManager.instance.local_domain?(domain) - account = Account.find_remote!(username, domain) + raise "Account not found: #{term}" unless account @term = account.id else - raise Mastodon::SyntaxError + raise "Unknown prefix: #{prefix}" end end end diff --git a/lib/exceptions.rb b/lib/exceptions.rb index 0c677b660..eb472abaa 100644 --- a/lib/exceptions.rb +++ b/lib/exceptions.rb @@ -10,7 +10,6 @@ module Mastodon class StreamValidationError < ValidationError; end class RaceConditionError < Error; end class RateLimitExceededError < Error; end - class SyntaxError < Error; end class UnexpectedResponseError < Error attr_reader :response -- 2.47.3