From 619802b82727319722b2fdcf935c64e2fee23e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KMY=EF=BC=88=E9=9B=AA=E3=81=82=E3=81=99=E3=81=8B=EF=BC=89?= Date: Wed, 27 Mar 2024 12:11:11 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=E3=83=89=E3=83=A1=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=83=96=E3=83=AD=E3=83=83=E3=82=AF=E3=81=AE=E3=83=88=E3=83=AC?= =?UTF-8?q?=E3=83=B3=E3=83=89=E6=8E=B2=E8=BC=89=E3=82=92=E6=8B=92=E5=90=A6?= =?UTF-8?q?=E3=81=AB=E3=80=81=E3=83=8F=E3=83=83=E3=82=B7=E3=83=A5=E3=82=BF?= =?UTF-8?q?=E3=82=B0=E3=81=8C=E5=90=AB=E3=81=BE=E3=82=8C=E3=81=AA=E3=81=84?= =?UTF-8?q?=E5=95=8F=E9=A1=8C=20(#676)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/trends/tags.rb | 1 + spec/models/trends/tags_spec.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/app/models/trends/tags.rb b/app/models/trends/tags.rb index 03707d68704695..5b00fca7ec994a 100644 --- a/app/models/trends/tags.rb +++ b/app/models/trends/tags.rb @@ -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? diff --git a/spec/models/trends/tags_spec.rb b/spec/models/trends/tags_spec.rb index f2818fca87bed5..91ca91f078b98d 100644 --- a/spec/models/trends/tags_spec.rb +++ b/spec/models/trends/tags_spec.rb @@ -23,6 +23,33 @@ 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