Fix: ドメインブロックのトレンド掲載を拒否に、ハッシュタグが含まれない問題 (#676)

This commit is contained in:
KMY(雪あすか) 2024-03-27 12:11:11 +09:00 committed by KMY
parent f096449e7f
commit de9ab9042f
2 changed files with 28 additions and 0 deletions

View file

@ -13,6 +13,7 @@ class Trends::Tags < Trends::Base
def register(status, at_time = Time.now.utc)
return unless !status.reblog? && %i(public public_unlisted login).include?(status.visibility.to_sym) && !status.account.silenced?
return if !status.account.local? && DomainBlock.block_trends?(status.account.domain)
status.tags.each do |tag|
add(tag, status.account_id, at_time) if tag.usable?

View file

@ -23,6 +23,33 @@ RSpec.describe Trends::Tags do
end
end
describe '#register' do
let(:tag) { Fabricate(:tag, usable: true) }
let(:account) { Fabricate(:account) }
let(:status) { Fabricate(:status, account: account, tags: [tag], created_at: at_time, updated_at: at_time) }
it 'records history' do
subject.register(status, at_time)
expect(tag.history.get(at_time).accounts).to eq 1
expect(tag.history.get(at_time).uses).to eq 1
expect(subject.send(:recently_used_ids, at_time)).to eq [tag.id]
end
context 'when account is rejected appending trends' do
let(:account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/actor') }
before do
Fabricate(:domain_block, domain: 'example.com', block_trends: true, severity: :noop)
end
it 'does not record history' do
subject.register(status, at_time)
expect(tag.history.get(at_time).accounts).to eq 0
expect(tag.history.get(at_time).uses).to eq 0
end
end
end
describe '#query' do
it 'returns a composable query scope' do
expect(subject.query).to be_a Trends::Query