Fix account_id
, max_id
and min_id
params not working in search (#26847)
This commit is contained in:
parent
e9b528eaee
commit
3a679844e4
5 changed files with 52 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue