Revert "Extended Search" to add in properly

This reverts commit 93a73ce9db.
This commit is contained in:
Skye 2023-02-04 19:56:07 +09:00
parent b98a2f01be
commit 919292c7c3
Signed by: me
GPG key ID: 0104BC05F41B77B8
9 changed files with 4 additions and 55 deletions

View file

@ -238,7 +238,7 @@ SMTP_FROM_ADDRESS=notifications@example.com
# SAML_ATTRIBUTES_STATEMENTS_FULL_NAME="urn:oid:2.16.840.1.113730.3.1.241" # SAML_ATTRIBUTES_STATEMENTS_FULL_NAME="urn:oid:2.16.840.1.113730.3.1.241"
# SAML_ATTRIBUTES_STATEMENTS_FIRST_NAME="urn:oid:2.5.4.42" # SAML_ATTRIBUTES_STATEMENTS_FIRST_NAME="urn:oid:2.5.4.42"
# SAML_ATTRIBUTES_STATEMENTS_LAST_NAME="urn:oid:2.5.4.4" # SAML_ATTRIBUTES_STATEMENTS_LAST_NAME="urn:oid:2.5.4.4"
# SAML_UID_ATTRIBUTE="urn:oid:0.9.2342.19200300.100.1.1" # SAML_UID_ATTRIBUTE="urn:oid:0.9.2342.19200300.100.1.1"
# SAML_ATTRIBUTES_STATEMENTS_VERIFIED= # SAML_ATTRIBUTES_STATEMENTS_VERIFIED=
# SAML_ATTRIBUTES_STATEMENTS_VERIFIED_EMAIL= # SAML_ATTRIBUTES_STATEMENTS_VERIFIED_EMAIL=
@ -286,12 +286,6 @@ MAX_REACTIONS=1
# Customize the number of hashtags shown in 'Explore' # Customize the number of hashtags shown in 'Explore'
# MAX_TRENDING_TAGS=10 # MAX_TRENDING_TAGS=10
# Scope of full-text searches:
# - public: search any status with public visibility
# - public_or_unlisted: search any status with public or unlisted visibility
# - classic: searches only a user's own statuses, favs, bookmarks, and mentions
# SEARCH_SCOPE=public
# Maximum custom emoji file sizes # Maximum custom emoji file sizes
# If undefined or smaller than MAX_EMOJI_SIZE, the value # If undefined or smaller than MAX_EMOJI_SIZE, the value
# of MAX_EMOJI_SIZE will be used for MAX_REMOTE_EMOJI_SIZE # of MAX_EMOJI_SIZE will be used for MAX_REMOTE_EMOJI_SIZE

View file

@ -65,7 +65,6 @@ class StatusesIndex < Chewy::Index
root date_detection: false do root date_detection: false do
field :id, type: 'long' field :id, type: 'long'
field :account_id, type: 'long' field :account_id, type: 'long'
field :visibility, type: 'keyword'
field :text, type: 'text', value: ->(status) { status.searchable_text } do field :text, type: 'text', value: ->(status) { status.searchable_text } do
field :stemmed, type: 'text', analyzer: 'content' field :stemmed, type: 'text', analyzer: 'content'

View file

@ -85,8 +85,6 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
attach_tags(@status) attach_tags(@status)
end end
StatusesIndex.import! @status
resolve_thread(@status) resolve_thread(@status)
fetch_replies(@status) fetch_replies(@status)
distribute distribute

View file

@ -25,9 +25,7 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
# on the results of the filter, so this filtering happens here instead # on the results of the filter, so this filtering happens here instead
bulk.map! do |entry| bulk.map! do |entry|
new_entry = begin new_entry = begin
if entry[:index] && if entry[:index] && entry.dig(:index, :data, 'searchable_by').blank?
entry.dig(:index, :data, 'searchable_by').blank? &&
Rails.configuration.x.search_scope == :classic
{ delete: entry[:index].except(:data) } { delete: entry[:index].except(:data) }
else else
entry entry
@ -60,21 +58,13 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
end end
def scopes def scopes
classic_scopes = [ [
local_statuses_scope, local_statuses_scope,
local_mentions_scope, local_mentions_scope,
local_favourites_scope, local_favourites_scope,
local_votes_scope, local_votes_scope,
local_bookmarks_scope, local_bookmarks_scope,
] ]
case Rails.configuration.x.search_scope
when :public
classic_scopes + [public_scope]
when :public_or_unlisted
classic_scopes + [public_or_unlisted_scope]
else
classic_scopes
end
end end
def local_mentions_scope def local_mentions_scope
@ -96,12 +86,4 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
def local_statuses_scope def local_statuses_scope
Status.local.select('"statuses"."id", COALESCE("statuses"."reblog_of_id", "statuses"."id") AS status_id') Status.local.select('"statuses"."id", COALESCE("statuses"."reblog_of_id", "statuses"."id") AS status_id')
end end
def public_scope
Status.with_public_visibility.select('"statuses"."id", "statuses"."id" AS status_id')
end
def public_or_unlisted_scope
Status.with_public_or_unlisted_visibility.select('"statuses"."id", "statuses"."id" AS status_id')
end
end end

View file

@ -104,7 +104,6 @@ class Status < ApplicationRecord
scope :without_replies, -> { where('statuses.reply = FALSE OR statuses.in_reply_to_account_id = statuses.account_id') } scope :without_replies, -> { where('statuses.reply = FALSE OR statuses.in_reply_to_account_id = statuses.account_id') }
scope :without_reblogs, -> { where('statuses.reblog_of_id IS NULL') } scope :without_reblogs, -> { where('statuses.reblog_of_id IS NULL') }
scope :with_public_visibility, -> { where(visibility: :public) } scope :with_public_visibility, -> { where(visibility: :public) }
scope :with_public_or_unlisted_visibility, -> { where(visibility: [:public, :unlisted]) }
scope :tagged_with, ->(tag_ids) { joins(:statuses_tags).where(statuses_tags: { tag_id: tag_ids }) } scope :tagged_with, ->(tag_ids) { joins(:statuses_tags).where(statuses_tags: { tag_id: tag_ids }) }
scope :excluding_silenced_accounts, -> { left_outer_joins(:account).where(accounts: { silenced_at: nil }) } scope :excluding_silenced_accounts, -> { left_outer_joins(:account).where(accounts: { silenced_at: nil }) }
scope :including_silenced_accounts, -> { left_outer_joins(:account).where.not(accounts: { silenced_at: nil }) } scope :including_silenced_accounts, -> { left_outer_joins(:account).where.not(accounts: { silenced_at: nil }) }

View file

@ -90,8 +90,6 @@ class ActivityPub::ProcessAccountService < BaseService
set_fetchable_attributes! unless @options[:only_key] || @account.suspended? set_fetchable_attributes! unless @options[:only_key] || @account.suspended?
@account.save_with_optional_media! @account.save_with_optional_media!
AccountsIndex.import! @account
end end
def set_immediate_protocol_attributes! def set_immediate_protocol_attributes!

View file

@ -54,8 +54,6 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
broadcast_updates! broadcast_updates!
end end
StatusesIndex.import! @status
forward_activity! if significant_changes? && @status_parser.edited_at > last_edit_date forward_activity! if significant_changes? && @status_parser.edited_at > last_edit_date
end end

View file

@ -35,14 +35,7 @@ class SearchService < BaseService
end end
def perform_statuses_search! def perform_statuses_search!
statuses_index = StatusesIndex.filter(term: { searchable_by: @account.id }) definition = parsed_query.apply(StatusesIndex.filter(term: { searchable_by: @account.id }))
case Rails.configuration.x.search_scope
when :public
statuses_index = statuses_index.filter.or(term: { visibility: 'public' })
when :public_or_unlisted
statuses_index = statuses_index.filter.or(terms: { visibility: ['public', 'unlisted'] })
end
definition = parsed_query.apply(statuses_index)
if @options[:account_id].present? if @options[:account_id].present?
definition = definition.filter(term: { account_id: @options[:account_id] }) definition = definition.filter(term: { account_id: @options[:account_id] })

View file

@ -1,12 +0,0 @@
# frozen_string_literal: true
Rails.application.configure do
config.x.search_scope = case
when ENV['SEARCH_SCOPE'] == 'public'
:public
when ENV['SEARCH_SCOPE'] == 'public_or_unlisted'
:public_or_unlisted
else
:classic
end
end