Merge commit '0ef43a431d353a17419ea6664ed745b5dbfbf2f9' into glitch-soc/merge-upstream

This commit is contained in:
Claire committed 2026-03-24 12:13:39 +01:00
commit 60236bffe6
99 files changed
+2171 -1313

No files matched your search

+1 -1
View File
@@ -25,7 +25,7 @@ module Account::Avatar
validates_attachment_size :avatar, less_than: AVATAR_LIMIT
remotable_attachment :avatar, AVATAR_LIMIT, suppress_errors: false
validates :avatar_description, length: { maximum: MediaAttachment::MAX_DESCRIPTION_LENGTH }
validates :avatar_description, length: { maximum: MediaAttachment::MAX_DESCRIPTION_LENGTH }, if: -> { local? && will_save_change_to_avatar_description? }
end
def avatar_original_url
+1 -1
View File
@@ -26,7 +26,7 @@ module Account::Header
validates_attachment_size :header, less_than: HEADER_LIMIT
remotable_attachment :header, HEADER_LIMIT, suppress_errors: false
validates :header_description, length: { maximum: MediaAttachment::MAX_DESCRIPTION_LENGTH }
validates :header_description, length: { maximum: MediaAttachment::MAX_DESCRIPTION_LENGTH }, if: -> { local? && will_save_change_to_header_description? }
end
def header_original_url
+1 -1
View File
@@ -231,7 +231,7 @@ module Account::Interactions
Rails.cache.fetch("followers_hash:#{id}:#{url_prefix}/") do
digest = "\x00" * 32
followers.where(Account.arel_table[:uri].matches("#{Account.sanitize_sql_like(url_prefix)}/%", false, true)).or(followers.where(uri: url_prefix)).pluck_each(:uri) do |uri|
followers.matches_uri_prefix(url_prefix).pluck_each(:uri) do |uri|
Xorcist.xor!(digest, Digest::SHA256.digest(uri))
end
digest.unpack1('H*')
+1
View File
@@ -39,6 +39,7 @@ class MediaAttachment < ApplicationRecord
enum :processing, { queued: 0, in_progress: 1, complete: 2, failed: 3 }, prefix: true
MAX_DESCRIPTION_LENGTH = 1_500
MAX_DESCRIPTION_HARD_LENGTH_LIMIT = 10_000
IMAGE_LIMIT = (ENV['MAX_IMAGE_SIZE'] || 16.megabytes).to_i
VIDEO_LIMIT = (ENV['MAX_VIDEO_SIZE'] || 99.megabytes).to_i
+20 -23
View File
@@ -47,6 +47,20 @@ class Status < ApplicationRecord
include Status::Visibility
include Status::InteractionPolicyConcern
CACHEABLE_ASSOCIATIONS = [
:application,
:conversation,
:media_attachments,
:preloadable_poll,
:status_stat,
:tags,
account: [:account_stat, user: :role],
active_mentions: :account,
tagged_objects: :object,
preview_cards_status: { preview_card: { author_account: [:account_stat, user: :role] } },
quote: { status: { account: [:account_stat, user: :role] } },
].freeze
MEDIA_ATTACHMENTS_LIMIT = 4
rate_limit by: :account, family: :statuses
@@ -82,6 +96,7 @@ class Status < ApplicationRecord
has_many :mentions, dependent: :destroy, inverse_of: :status
has_many :mentioned_accounts, through: :mentions, source: :account, class_name: 'Account'
has_many :media_attachments, dependent: :nullify
has_many :tagged_objects, dependent: :destroy
has_many :quotes, foreign_key: 'quoted_status_id', inverse_of: :quoted_status, dependent: :nullify
# The `dependent` option is enabled by the initial `mentions` association declaration
@@ -169,29 +184,11 @@ class Status < ApplicationRecord
# the `dependent: destroy` callbacks remove relevant records
before_destroy :unlink_from_conversations!, prepend: true
cache_associated :application,
:media_attachments,
:conversation,
:status_stat,
:tags,
:preloadable_poll,
quote: { status: { account: [:account_stat, user: :role] } },
preview_cards_status: { preview_card: { author_account: [:account_stat, user: :role] } },
account: [:account_stat, user: :role],
active_mentions: :account,
reblog: [
:application,
:media_attachments,
:conversation,
:status_stat,
:tags,
:preloadable_poll,
quote: { status: { account: [:account_stat, user: :role] } },
preview_cards_status: { preview_card: { author_account: [:account_stat, user: :role] } },
account: [:account_stat, user: :role],
active_mentions: :account,
],
thread: :account
cache_associated(
*CACHEABLE_ASSOCIATIONS,
reblog: [*CACHEABLE_ASSOCIATIONS],
thread: :account
)
delegate :domain, :indexable?, to: :account, prefix: true
+19
View File
@@ -0,0 +1,19 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: tagged_objects
#
# id :bigint(8) not null, primary key
# ap_type :string not null
# object_type :string
# uri :string
# created_at :datetime not null
# updated_at :datetime not null
# object_id :bigint(8)
# status_id :bigint(8) not null
#
class TaggedObject < ApplicationRecord
belongs_to :status, inverse_of: :tagged_objects
belongs_to :object, polymorphic: true, optional: true
end