Fix in memoriam accounts appearing in follow recommendations (#31474)
Co-authored-by: Utkarsh Wankar <46633523+kernal053@users.noreply.github.com>
This commit is contained in:
parent
d2e4be0456
commit
d4f135bc6d
5 changed files with 11 additions and 2 deletions
|
@ -144,6 +144,7 @@ class Account < ApplicationRecord
|
||||||
scope :dormant, -> { joins(:account_stat).merge(AccountStat.without_recent_activity) }
|
scope :dormant, -> { joins(:account_stat).merge(AccountStat.without_recent_activity) }
|
||||||
scope :with_username, ->(value) { where arel_table[:username].lower.eq(value.to_s.downcase) }
|
scope :with_username, ->(value) { where arel_table[:username].lower.eq(value.to_s.downcase) }
|
||||||
scope :with_domain, ->(value) { where arel_table[:domain].lower.eq(value&.to_s&.downcase) }
|
scope :with_domain, ->(value) { where arel_table[:domain].lower.eq(value&.to_s&.downcase) }
|
||||||
|
scope :without_memorial, -> { where(memorial: false) }
|
||||||
|
|
||||||
after_update_commit :trigger_update_webhooks
|
after_update_commit :trigger_update_webhooks
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ class AccountSuggestions::FriendsOfFriendsSource < AccountSuggestions::Source
|
||||||
AND accounts.suspended_at IS NULL
|
AND accounts.suspended_at IS NULL
|
||||||
AND accounts.silenced_at IS NULL
|
AND accounts.silenced_at IS NULL
|
||||||
AND accounts.moved_to_account_id IS NULL
|
AND accounts.moved_to_account_id IS NULL
|
||||||
|
AND accounts.memorial = FALSE
|
||||||
AND follow_recommendation_mutes.target_account_id IS NULL
|
AND follow_recommendation_mutes.target_account_id IS NULL
|
||||||
GROUP BY accounts.id, account_stats.id
|
GROUP BY accounts.id, account_stats.id
|
||||||
ORDER BY frequency DESC, account_stats.followers_count ASC
|
ORDER BY frequency DESC, account_stats.followers_count ASC
|
||||||
|
|
|
@ -14,6 +14,7 @@ class AccountSuggestions::Source
|
||||||
.searchable
|
.searchable
|
||||||
.where(discoverable: true)
|
.where(discoverable: true)
|
||||||
.without_silenced
|
.without_silenced
|
||||||
|
.without_memorial
|
||||||
.where.not(follows_sql, id: account.id)
|
.where.not(follows_sql, id: account.id)
|
||||||
.where.not(follow_requests_sql, id: account.id)
|
.where.not(follow_requests_sql, id: account.id)
|
||||||
.not_excluded_by_account(account)
|
.not_excluded_by_account(account)
|
||||||
|
|
|
@ -15,6 +15,7 @@ RSpec.describe AccountSuggestions::FriendsOfFriendsSource do
|
||||||
let!(:john) { Fabricate(:account, discoverable: true, hide_collections: false) }
|
let!(:john) { Fabricate(:account, discoverable: true, hide_collections: false) }
|
||||||
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) }
|
||||||
|
|
||||||
context 'with follows and blocks' do
|
context 'with follows and blocks' do
|
||||||
before do
|
before do
|
||||||
|
@ -27,8 +28,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 and neil
|
# eugen follows eve, john, jerk, larry, neil and morty
|
||||||
[eve, mallory, jerk, larry, neil].each { |account| eugen.follow!(account) }
|
[eve, mallory, jerk, larry, neil, morty].each { |account| eugen.follow!(account) }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns eligible accounts', :aggregate_failures do
|
it 'returns eligible accounts', :aggregate_failures do
|
||||||
|
@ -51,6 +52,9 @@ RSpec.describe AccountSuggestions::FriendsOfFriendsSource do
|
||||||
|
|
||||||
# the suggestion for neil has already been rejected
|
# the suggestion for neil has already been rejected
|
||||||
expect(results).to_not include([neil.id, :friends_of_friends])
|
expect(results).to_not include([neil.id, :friends_of_friends])
|
||||||
|
|
||||||
|
# morty is not included because his account is in memoriam
|
||||||
|
expect(results).to_not include([morty.id, :friends_of_friends])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ RSpec.describe AccountSuggestions::Source do
|
||||||
let!(:moved_account) { Fabricate(:account, moved_to_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!(:silenced_account) { Fabricate(:account, silenced: true, discoverable: true) }
|
||||||
let!(:undiscoverable_account) { Fabricate(:account, discoverable: false) }
|
let!(:undiscoverable_account) { Fabricate(:account, discoverable: false) }
|
||||||
|
let!(:memorial_account) { Fabricate(:account, memorial: true, discoverable: true) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Fabricate :account_domain_block, account: account, domain: account_domain_blocked_account.domain
|
Fabricate :account_domain_block, account: account, domain: account_domain_blocked_account.domain
|
||||||
|
@ -44,6 +45,7 @@ RSpec.describe AccountSuggestions::Source do
|
||||||
.and not_include(moved_account)
|
.and not_include(moved_account)
|
||||||
.and not_include(silenced_account)
|
.and not_include(silenced_account)
|
||||||
.and not_include(undiscoverable_account)
|
.and not_include(undiscoverable_account)
|
||||||
|
.and not_include(memorial_account)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue