Merge commit 'b1d89071384ef028c97a3d28cf8cf6bc0ca6c4ce' into glitch-soc/merge-upstream

This commit is contained in:
Claire
2023-09-15 21:06:45 +02:00
33 changed files with 759 additions and 327 deletions
+22
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