Skip to content

Commit

Permalink
Fix own posts not getting delivered to own lists (mastodon#24810)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored and Michael Mitchell committed May 3, 2023
1 parent cd22ad0 commit 6d91f95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/models/concerns/account_interactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ def followers_for_local_distribution
end

def lists_for_local_distribution
lists.joins(account: :user)
.where.not(list_accounts: { follow_id: nil })
scope = lists.joins(account: :user)
scope.where.not(list_accounts: { follow_id: nil }).or(scope.where(account_id: id))
.where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago)
end

Expand Down
8 changes: 6 additions & 2 deletions spec/models/concerns/account_interactions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@
end

describe '#lists_for_local_distribution' do
let(:account) { Fabricate(:user, current_sign_in_at: Time.now.utc).account }
let!(:inactive_follower_user) { Fabricate(:user, current_sign_in_at: 5.years.ago) }
let!(:follower_user) { Fabricate(:user, current_sign_in_at: Time.now.utc) }
let!(:follow_request_user) { Fabricate(:user, current_sign_in_at: Time.now.utc) }
Expand All @@ -693,6 +694,8 @@
let!(:follower_list) { Fabricate(:list, account: follower_user.account) }
let!(:follow_request_list) { Fabricate(:list, account: follow_request_user.account) }

let!(:self_list) { Fabricate(:list, account: account) }

before do
inactive_follower_user.account.follow!(account)
follower_user.account.follow!(account)
Expand All @@ -701,10 +704,11 @@
inactive_follower_list.accounts << account
follower_list.accounts << account
follow_request_list.accounts << account
self_list.accounts << account
end

it 'includes only the list from the active follower' do
expect(account.lists_for_local_distribution.to_a).to eq [follower_list]
it 'includes only the list from the active follower and from oneself' do
expect(account.lists_for_local_distribution.to_a).to contain_exactly(follower_list, self_list)
end
end
end

0 comments on commit 6d91f95

Please sign in to comment.