From b3c2e47ea89bab4d7b56b8ab26cc108264209cbe Mon Sep 17 00:00:00 2001 From: KMY Date: Tue, 19 Mar 2024 09:25:17 +0900 Subject: [PATCH] =?UTF-8?q?Revert=E3=81=97=E3=81=9F=E3=82=B3=E3=83=9F?= =?UTF-8?q?=E3=83=83=E3=83=88=E3=82=92=E5=BE=A9=E5=85=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../similar_profiles_source.rb | 8 ++---- app/models/account_suggestions/source.rb | 7 ++---- .../models/account_suggestions/source_spec.rb | 25 +++++++++---------- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/app/models/account_suggestions/similar_profiles_source.rb b/app/models/account_suggestions/similar_profiles_source.rb index cf1b65d832..7ecdd607e5 100644 --- a/app/models/account_suggestions/similar_profiles_source.rb +++ b/app/models/account_suggestions/similar_profiles_source.rb @@ -1,10 +1,5 @@ # frozen_string_literal: true -# Reverted this commit.temporarily because load issues. -# Whenever a manual merge occurs, be sure to check the following commits. -# Hash: ee8d0b94473df357677cd1f82581251ce0423c01 -# Message: Fix follow suggestions potentially including silenced or blocked accounts (#29306) - class AccountSuggestions::SimilarProfilesSource < AccountSuggestions::Source class QueryBuilder < AccountSearchService::QueryBuilder def must_clauses @@ -56,7 +51,8 @@ class AccountSuggestions::SimilarProfilesSource < AccountSuggestions::Source recently_followed_account_ids = account.active_relationships.recent.limit(5).pluck(:target_account_id) if Chewy.enabled? && !recently_followed_account_ids.empty? - QueryBuilder.new(recently_followed_account_ids, account).build.limit(limit).hits.pluck('_id').map(&:to_i).zip([key].cycle) + ids_from_es = QueryBuilder.new(recently_followed_account_ids, account).build.limit(limit).hits.pluck('_id').map(&:to_i) + base_account_scope(account).where(id: ids_from_es).pluck(:id).zip([key].cycle) else [] end diff --git a/app/models/account_suggestions/source.rb b/app/models/account_suggestions/source.rb index 3e0fb3782e..7afc4c80ed 100644 --- a/app/models/account_suggestions/source.rb +++ b/app/models/account_suggestions/source.rb @@ -1,10 +1,5 @@ # frozen_string_literal: true -# Reverted this commit.temporarily because load issues. -# Whenever a manual merge occurs, be sure to check the following commits. -# Hash: ee8d0b94473df357677cd1f82581251ce0423c01 -# Message: Fix follow suggestions potentially including silenced or blocked accounts (#29306) - class AccountSuggestions::Source DEFAULT_LIMIT = 10 @@ -17,6 +12,8 @@ class AccountSuggestions::Source def base_account_scope(account) Account .searchable + .where(discoverable: true) + .without_silenced .where.not(follows_sql, id: account.id) .where.not(follow_requests_sql, id: account.id) .not_excluded_by_account(account) diff --git a/spec/models/account_suggestions/source_spec.rb b/spec/models/account_suggestions/source_spec.rb index d6f979d765..1666094082 100644 --- a/spec/models/account_suggestions/source_spec.rb +++ b/spec/models/account_suggestions/source_spec.rb @@ -1,10 +1,5 @@ # frozen_string_literal: true -# Reverted this commit.temporarily because load issues. -# Whenever a manual merge occurs, be sure to check the following commits. -# Hash: ee8d0b94473df357677cd1f82581251ce0423c01 -# Message: Fix follow suggestions potentially including silenced or blocked accounts (#29306) - require 'rails_helper' RSpec.describe AccountSuggestions::Source do @@ -16,14 +11,16 @@ RSpec.describe AccountSuggestions::Source do end context 'with follows and follow requests' do - let!(:account_domain_blocked_account) { Fabricate(:account, domain: 'blocked.host') } - let!(:account) { Fabricate(:account) } - let!(:blocked_account) { Fabricate(:account) } - let!(:eligible_account) { Fabricate(:account) } - let!(:follow_recommendation_muted_account) { Fabricate(:account) } - let!(:follow_requested_account) { Fabricate(:account) } - let!(:following_account) { Fabricate(:account) } - let!(:moved_account) { Fabricate(:account, moved_to_account: Fabricate(:account)) } + let!(:account_domain_blocked_account) { Fabricate(:account, domain: 'blocked.host', discoverable: true) } + let!(:account) { Fabricate(:account, discoverable: true) } + let!(:blocked_account) { Fabricate(:account, discoverable: true) } + let!(:eligible_account) { Fabricate(:account, discoverable: true) } + let!(:follow_recommendation_muted_account) { Fabricate(:account, discoverable: true) } + let!(:follow_requested_account) { Fabricate(:account, discoverable: true) } + let!(:following_account) { Fabricate(:account, discoverable: true) } + let!(:moved_account) { Fabricate(:account, moved_to_account: Fabricate(:account), discoverable: true) } + let!(:silenced_account) { Fabricate(:account, silenced: true, discoverable: true) } + let!(:undiscoverable_account) { Fabricate(:account, discoverable: false) } before do Fabricate :account_domain_block, account: account, domain: account_domain_blocked_account.domain @@ -45,6 +42,8 @@ RSpec.describe AccountSuggestions::Source do .and not_include(follow_requested_account) .and not_include(following_account) .and not_include(moved_account) + .and not_include(silenced_account) + .and not_include(undiscoverable_account) end end end