Add visibility: search operator

This commit is contained in:
Vyr Cossont 2023-04-11 10:27:50 -07:00
parent 82aff41ddd
commit bf6f975237
4 changed files with 25 additions and 20 deletions

View file

@ -73,6 +73,7 @@ Metrics/BlockLength:
- 'app/models/concerns/omniauthable.rb'
- 'app/models/concerns/pam_authenticable.rb'
- 'app/models/concerns/remotable.rb'
- 'app/services/search_service.rb'
- 'app/services/suspend_account_service.rb'
- 'app/services/unsuspend_account_service.rb'
- 'app/views/accounts/show.rss.ruby'
@ -113,6 +114,7 @@ Metrics/ClassLength:
- 'app/lib/feed_manager.rb'
- 'app/lib/link_details_extractor.rb'
- 'app/lib/request.rb'
- 'app/lib/search_query_transformer.rb'
- 'app/lib/text_formatter.rb'
- 'app/lib/user_settings_decorator.rb'
- 'app/mailers/user_mailer.rb'
@ -136,6 +138,7 @@ Metrics/ClassLength:
- 'app/services/import_service.rb'
- 'app/services/notify_service.rb'
- 'app/services/post_status_service.rb'
- 'app/services/search_service.rb'
- 'app/services/update_status_service.rb'
- 'lib/paperclip/color_extractor.rb'

View file

@ -9,7 +9,7 @@ class SearchQueryParser < Parslet::Parser
rule(:operator) { (str('+') | str('-')).as(:operator) }
# See SearchQueryTransformer::PrefixClause::initialize for list of legal prefix operators.
# These are explictly enumerated here so they don't get mistaken for URLs.
rule(:prefix) { ((str('domain') | str('is') | str('has') | str('lang') | str('before') | str('after') | str('from') | str('mentions') | str('to') | str('scope') | str('sort')).as(:prefix) >> colon) }
rule(:prefix) { ((str('domain') | str('is') | str('has') | str('lang') | str('before') | str('after') | str('from') | str('mentions') | str('to') | str('scope') | str('sort') | str('visibility')).as(:prefix) >> colon) }
# See CustomEmoji::SHORTCODE_RE_FRAGMENT and SCAN_RE for emoji grammar.
rule(:shortcode) { (colon >> match('[a-zA-Z0-9_]').repeat(2).as(:shortcode) >> colon) }
rule(:hashtag) { (hash >> match('[^\s#]').repeat(1).as(:hashtag)) }

View file

@ -241,7 +241,7 @@ class SearchQueryTransformer < Parslet::Transform
when 'has'
initialize_has(term)
when 'lang'
when 'lang', 'visibility'
@search_types = %i(statuses)
when 'before', 'after'

View file

@ -2,23 +2,25 @@
Rails.application.configure do
# STATUS_SEARCH_SCOPE was previously known as SEARCH_SCOPE and only covered statuses.
config.x.status_search_scope = case
when (ENV['STATUS_SEARCH_SCOPE'] || ENV['SEARCH_SCOPE']) == 'discoverable'
:discoverable
when (ENV['STATUS_SEARCH_SCOPE'] || ENV['SEARCH_SCOPE']) == 'public'
:public
when (ENV['STATUS_SEARCH_SCOPE'] || ENV['SEARCH_SCOPE']) == 'public_or_unlisted'
:public_or_unlisted
else
:classic
end
status_search_scope = (ENV['STATUS_SEARCH_SCOPE'] || ENV.fetch('SEARCH_SCOPE', nil))
config.x.status_search_scope = case status_search_scope
when 'discoverable'
:discoverable
when 'public'
:public
when 'public_or_unlisted'
:public_or_unlisted
else
:classic
end
config.x.account_search_scope = case
when ENV['ACCOUNT_SEARCH_SCOPE'] == 'all'
:all
when ENV['ACCOUNT_SEARCH_SCOPE'] == 'discoverable'
:discoverable
else
:classic
end
account_search_scope = ENV.fetch('ACCOUNT_SEARCH_SCOPE', nil)
config.x.account_search_scope = case account_search_scope
when 'all'
:all
when 'discoverable'
:discoverable
else
:classic
end
end