Merge remote-tracking branch 'parent/main' into kbtopic-remove-quote

This commit is contained in:
KMY 2025-06-12 10:17:21 +09:00
commit f3c3ea42c2
301 changed files with 6618 additions and 3070 deletions

View file

@ -22,7 +22,7 @@ module Attachmentable
).freeze
included do
def self.has_attached_file(name, options = {}) # rubocop:disable Naming/PredicateName
def self.has_attached_file(name, options = {}) # rubocop:disable Naming/PredicatePrefix
super
send(:"before_#{name}_validate", prepend: true) do

View file

@ -16,7 +16,7 @@ module Status::SafeReblogInsert
# The code is kept similar to ActiveRecord::Persistence code and calls it
# directly when we are not handling a reblog.
#
# https://github.com/rails/rails/blob/v7.2.1.1/activerecord/lib/active_record/persistence.rb#L238-L263
# https://github.com/rails/rails/blob/v8.0.2/activerecord/lib/active_record/persistence.rb#L238-L261
def _insert_record(connection, values, returning)
return super unless values.is_a?(Hash) && values['reblog_of_id']&.value.present?
@ -36,15 +36,13 @@ module Status::SafeReblogInsert
# Instead, we use a custom builder when a reblog is happening:
im = _compile_reblog_insert(values)
with_connection do |_c|
connection.insert(
im, "#{self} Create", primary_key || false, primary_key_value,
returning: returning
).tap do |result|
# Since we are using SELECT instead of VALUES, a non-error `nil` return is possible.
# For our purposes, it's equivalent to a foreign key constraint violation
raise ActiveRecord::InvalidForeignKey, "(reblog_of_id)=(#{values['reblog_of_id'].value}) is not present in table \"statuses\"" if result.nil?
end
connection.insert(
im, "#{self} Create", primary_key || false, primary_key_value,
returning: returning
).tap do |result|
# Since we are using SELECT instead of VALUES, a non-error `nil` return is possible.
# For our purposes, it's equivalent to a foreign key constraint violation
raise ActiveRecord::InvalidForeignKey, "(reblog_of_id)=(#{values['reblog_of_id'].value}) is not present in table \"statuses\"" if result.nil?
end
end

View file

@ -26,6 +26,8 @@ class FeaturedTag < ApplicationRecord
normalizes :name, with: ->(name) { name.strip.delete_prefix('#') }
scope :by_name, ->(name) { joins(:tag).where(tag: { name: HashtagNormalizer.new.normalize(name) }) }
before_validation :set_tag
before_create :reset_data

View file

@ -422,7 +422,7 @@ class MediaAttachment < ApplicationRecord
# Record the cache keys to burst before the file get actually deleted
def prepare_cache_bust!
return unless Rails.configuration.x.cache_buster_enabled
return unless Rails.configuration.x.cache_buster.enabled
@paths_to_cache_bust = MediaAttachment.attachment_definitions.keys.flat_map do |attachment_name|
attachment = public_send(attachment_name)
@ -439,7 +439,7 @@ class MediaAttachment < ApplicationRecord
# Once Paperclip has deleted the files, we can't recover the cache keys,
# so use the previously-saved ones
def bust_cache!
return unless Rails.configuration.x.cache_buster_enabled
return unless Rails.configuration.x.cache_buster.enabled
CacheBusterWorker.push_bulk(@paths_to_cache_bust) { |path| [path] }
rescue => e

View file

@ -7,6 +7,7 @@
# id :bigint(8) not null, primary key
# activity_uri :string
# approval_uri :string
# legacy :boolean default(FALSE), not null
# state :integer default("pending"), not null
# created_at :datetime not null
# updated_at :datetime not null
@ -46,6 +47,10 @@ class Quote < ApplicationRecord
end
end
def acceptable?
accepted? || !legacy?
end
def schedule_refresh_if_stale!
return unless quoted_status_id.present? && approval_uri.present? && updated_at <= BACKGROUND_REFRESH_INTERVAL.ago

View file

@ -91,9 +91,14 @@ class Trends::Statuses < Trends::Base
def eligible?(status)
status.created_at.past? &&
(status.public_visibility? || status.public_unlisted_visibility?) &&
status.account.discoverable? && !status.account.silenced? && !status.account.sensitized? &&
status.spoiler_text.blank? && (!status.sensitive? || status.media_attachments.none?) &&
!status.reply? && valid_locale?(status.language) && !domain_blocked?(status)
status.account.discoverable? &&
!status.account.silenced? &&
!status.account.sensitized? &&
status.spoiler_text.blank? &&
(!status.sensitive? || status.media_attachments.none?) &&
!status.reply? &&
valid_locale?(status.language) &&
!domain_blocked?(status)
end
def domain_blocked?(status)

View file

@ -17,7 +17,7 @@ module UserSettings::Glue
self.class.definition_for(key)&.type
end
def has_attribute?(key) # rubocop:disable Naming/PredicateName
def has_attribute?(key) # rubocop:disable Naming/PredicatePrefix
self.class.definition_for?(key)
end
end