Add: 検索許可「ローカルとフォロワー」 (#60)

This commit is contained in:
KMY(雪あすか) 2023-10-05 16:37:27 +09:00 committed by GitHub
parent deb8642e95
commit 235bef36d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 210 additions and 25 deletions

View file

@ -26,7 +26,7 @@ class AccountStatusesFilter
scope.merge!(no_reblogs_scope) if exclude_reblogs?
scope.merge!(hashtag_scope) if tagged?
available_searchabilities = [:public, :unlisted, :private, :direct, :limited, nil]
available_searchabilities = [:public, :public_unlisted, :unlisted, :private, :direct, :limited, nil]
available_visibilities = [:public, :public_unlisted, :login, :unlisted, :private, :direct, :limited]
available_searchabilities = [:public] if domain_block&.reject_send_not_public_searchability

View file

@ -23,7 +23,7 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
to_index.map do |object|
# This is unlikely to happen, but the post may have been
# un-interacted with since it was queued for indexing
if object.searchable_by.empty? && %w(public private).exclude?(object.searchability)
if object.searchable_by.empty? && %w(public public_unlisted private).exclude?(object.searchability)
deleted += 1
{ delete: { _id: object.id } }
else

View file

@ -89,10 +89,10 @@ class SearchQueryTransformer < Parslet::Transform
public_index,
searchability_limited,
]
definition_should << searchability_public if %i(public).include?(@searchability)
definition_should << searchability_private if %i(public unlisted private).include?(@searchability)
definition_should << searchable_by_me if %i(public unlisted private direct).include?(@searchability)
definition_should << self_posts if %i(public unlisted private direct).exclude?(@searchability)
definition_should << searchability_public if %i(public public_unlisted).include?(@searchability)
definition_should << searchability_private if %i(public public_unlisted unlisted private).include?(@searchability)
definition_should << searchable_by_me if %i(public public_unlisted unlisted private direct).include?(@searchability)
definition_should << self_posts if %i(public public_unlisted unlisted private direct).exclude?(@searchability)
{
bool: {
@ -199,8 +199,8 @@ class SearchQueryTransformer < Parslet::Transform
def following_account_ids
return @following_account_ids if defined?(@following_account_ids)
account_exists_sql = Account.where('accounts.id = follows.target_account_id').where(searchability: %w(public private)).reorder(nil).select(1).to_sql
status_exists_sql = Status.where('statuses.account_id = follows.target_account_id').where(reblog_of_id: nil).where(searchability: %w(public private)).reorder(nil).select(1).to_sql
account_exists_sql = Account.where('accounts.id = follows.target_account_id').where(searchability: %w(public public_unlisted private)).reorder(nil).select(1).to_sql
status_exists_sql = Status.where('statuses.account_id = follows.target_account_id').where(reblog_of_id: nil).where(searchability: %w(public public_unlisted private)).reorder(nil).select(1).to_sql
following_accounts = Follow.where(account_id: @options[:current_account].id).merge(Account.where("EXISTS (#{account_exists_sql})").or(Account.where("EXISTS (#{status_exists_sql})")))
@following_account_ids = following_accounts.pluck(:target_account_id)
end