]> cat aescling's git repositories - mastodon.git/commitdiff
Revert "Fix error resposes for `from` search prefix (#17963)"
authorsingle-right-quote <34298117+single-right-quote@users.noreply.github.com>
Sat, 9 Apr 2022 00:08:23 +0000 (00:08 +0000)
committersingle-right-quote <34298117+single-right-quote@users.noreply.github.com>
Sat, 9 Apr 2022 00:08:23 +0000 (00:08 +0000)
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
app/lib/search_query_transformer.rb
lib/exceptions.rb

index 77eeab5b0ba5849dc22331bdd44409b5c8fcfb8b..ddcf92200966ffef3913006a807a1c11a087e78b 100644 (file)
@@ -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
index aef05e9d9d883c1e58c76c6a3ecda9a10d7fb02d..c685d7b6fd7b0dc0cf86c83d675fa01ed5906067 100644 (file)
@@ -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
index 0c677b6605d24689d75dee2ed47715d133d2364a..eb472abaabfb67d9a853d8c38c3b77325ffdad29 100644 (file)
@@ -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