Add restrictions on which quote posts can trend (#35507)
Some checks failed
Bundler Audit / security (push) Waiting to run
Check i18n / check-i18n (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
Haml Linting / lint (push) Waiting to run
Ruby Linting / lint (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
Chromatic / Run Chromatic (push) Has been cancelled
JavaScript Linting / lint (push) Has been cancelled
JavaScript Testing / test (push) Has been cancelled

This commit is contained in:
Claire 2025-07-24 17:45:12 +02:00 committed by GitHub
parent 847b37552a
commit a863e68d17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 9 deletions

View File

@ -90,14 +90,28 @@ class Trends::Statuses < Trends::Base
def eligible?(status)
status.created_at.past? &&
status.public_visibility? &&
status.account.discoverable? &&
!status.account.silenced? &&
!status.account.sensitized? &&
status.spoiler_text.blank? &&
!status.sensitive? &&
opted_into_trends?(status) &&
!sensitive_content?(status) &&
!status.reply? &&
valid_locale?(status.language)
valid_locale?(status.language) &&
(status.quote.nil? || trendable_quote?(status.quote))
end
def opted_into_trends?(status)
status.public_visibility? &&
status.account.discoverable? &&
!status.account.silenced?
end
def sensitive_content?(status)
status.account.sensitized? || status.spoiler_text.present? || status.sensitive?
end
def trendable_quote?(quote)
quote.acceptable? &&
quote.quoted_status.present? &&
opted_into_trends?(quote.quoted_status) &&
!sensitive_content?(quote.quoted_status)
end
def calculate_scores(statuses, at_time)

View File

@ -111,12 +111,16 @@ RSpec.describe Trends::Statuses do
let!(:yesterday) { today - 1.day }
let!(:status_foo) { Fabricate(:status, text: 'Foo', language: 'en', trendable: true, created_at: yesterday) }
let!(:status_bar) { Fabricate(:status, text: 'Bar', language: 'en', trendable: true, created_at: today) }
let!(:status_bar) { Fabricate(:status, text: 'Bar', language: 'en', trendable: true, created_at: today, quote: Quote.new(state: :accepted, quoted_status: status_foo)) }
let!(:status_baz) { Fabricate(:status, text: 'Baz', language: 'en', trendable: true, created_at: today) }
let!(:untrendable) { Fabricate(:status, text: 'Untrendable', language: 'en', trendable: true, visibility: :unlisted) }
let!(:untrendable_quote) { Fabricate(:status, text: 'Untrendable quote!', language: 'en', trendable: true, created_at: today, quote: Quote.new(state: :accepted, quoted_status: untrendable)) }
before do
default_threshold_value.times { reblog(status_foo, today) }
default_threshold_value.times { reblog(status_bar, today) }
default_threshold_value.times { reblog(untrendable, today) }
default_threshold_value.times { reblog(untrendable_quote, today) }
(default_threshold_value - 1).times { reblog(status_baz, today) }
end
@ -129,7 +133,7 @@ RSpec.describe Trends::Statuses do
results = subject.query.limit(10).to_a
expect(results).to eq [status_bar, status_foo]
expect(results).to_not include(status_baz)
expect(results).to_not include(status_baz, untrendable, untrendable_quote)
end
end