Fix friends-of-friends recommendations suggesting already-requested accounts (#35604)
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
Chromatic / Run Chromatic (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions

This commit is contained in:
Claire 2025-07-30 18:28:26 +02:00 committed by GitHub
parent b80e95b2aa
commit e5826777b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -26,6 +26,7 @@ class AccountSuggestions::FriendsOfFriendsSource < AccountSuggestions::Source
AND NOT EXISTS (SELECT 1 FROM mutes m WHERE m.target_account_id = follows.target_account_id AND m.account_id = :id) AND NOT EXISTS (SELECT 1 FROM mutes m WHERE m.target_account_id = follows.target_account_id AND m.account_id = :id)
AND (accounts.domain IS NULL OR NOT EXISTS (SELECT 1 FROM account_domain_blocks b WHERE b.account_id = :id AND b.domain = accounts.domain)) AND (accounts.domain IS NULL OR NOT EXISTS (SELECT 1 FROM account_domain_blocks b WHERE b.account_id = :id AND b.domain = accounts.domain))
AND NOT EXISTS (SELECT 1 FROM follows f WHERE f.target_account_id = follows.target_account_id AND f.account_id = :id) AND NOT EXISTS (SELECT 1 FROM follows f WHERE f.target_account_id = follows.target_account_id AND f.account_id = :id)
AND NOT EXISTS (SELECT 1 FROM follow_requests f WHERE f.target_account_id = follows.target_account_id AND f.account_id = :id)
AND follows.target_account_id <> :id AND follows.target_account_id <> :id
AND accounts.discoverable AND accounts.discoverable
AND accounts.suspended_at IS NULL AND accounts.suspended_at IS NULL

View File

@ -16,10 +16,12 @@ RSpec.describe AccountSuggestions::FriendsOfFriendsSource do
let!(:jerk) { Fabricate(:account, discoverable: true, hide_collections: false) } let!(:jerk) { Fabricate(:account, discoverable: true, hide_collections: false) }
let!(:larry) { Fabricate(:account, discoverable: true, hide_collections: false) } let!(:larry) { Fabricate(:account, discoverable: true, hide_collections: false) }
let!(:morty) { Fabricate(:account, discoverable: true, hide_collections: false, memorial: true) } let!(:morty) { Fabricate(:account, discoverable: true, hide_collections: false, memorial: true) }
let!(:joyce) { Fabricate(:account, discoverable: true, hide_collections: false) }
context 'with follows and blocks' do context 'with follows and blocks' do
before do before do
bob.block!(jerk) bob.block!(jerk)
bob.request_follow!(joyce)
FollowRecommendationMute.create!(account: bob, target_account: neil) FollowRecommendationMute.create!(account: bob, target_account: neil)
# bob follows eugen, alice and larry # bob follows eugen, alice and larry
@ -28,8 +30,8 @@ RSpec.describe AccountSuggestions::FriendsOfFriendsSource do
# alice follows eve and mallory # alice follows eve and mallory
[john, mallory].each { |account| alice.follow!(account) } [john, mallory].each { |account| alice.follow!(account) }
# eugen follows eve, john, jerk, larry, neil and morty # eugen follows eve, john, jerk, larry, neil, morty and joyce
[eve, mallory, jerk, larry, neil, morty].each { |account| eugen.follow!(account) } [eve, mallory, jerk, larry, neil, morty, joyce].each { |account| eugen.follow!(account) }
end end
it 'returns eligible accounts', :aggregate_failures do it 'returns eligible accounts', :aggregate_failures do
@ -55,6 +57,9 @@ RSpec.describe AccountSuggestions::FriendsOfFriendsSource do
# morty is not included because his account is in memoriam # morty is not included because his account is in memoriam
expect(results).to_not include([morty.id, :friends_of_friends]) expect(results).to_not include([morty.id, :friends_of_friends])
# joyce is not included because there is already a pending follow request
expect(results).to_not include([joyce.id, :friends_of_friends])
end end
end end