0
0
Fork 0

Fix account_id, max_id and min_id params not working in search (#26847)

This commit is contained in:
Eugen Rochko 2023-09-08 14:25:00 +02:00 committed by GitHub
parent e9b528eaee
commit 3a679844e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 7 deletions

View file

@ -8,6 +8,7 @@ class StatusesSearchService < BaseService
@limit = options[:limit].to_i
@offset = options[:offset].to_i
convert_deprecated_options!
status_search_results
end
@ -28,4 +29,25 @@ class StatusesSearchService < BaseService
def parsed_query
SearchQueryTransformer.new.apply(SearchQueryParser.new.parse(@query), current_account: @account)
end
def convert_deprecated_options!
syntax_options = []
if @options[:account_id]
username = Account.select(:username, :domain).find(@options[:account_id]).acct
syntax_options << "from:@#{username}"
end
if @options[:min_id]
timestamp = Mastodon::Snowflake.to_time(@options[:min_id])
syntax_options << "after:\"#{timestamp.iso8601}\""
end
if @options[:max_id]
timestamp = Mastodon::Snowflake.to_time(@options[:max_id])
syntax_options << "before:\"#{timestamp.iso8601}\""
end
@query = "#{@query} #{syntax_options.join(' ')}".strip if syntax_options.any?
end
end