Merge remote-tracking branch 'parent/main' into upstream-20240918
This commit is contained in:
commit
4ce35dd837
188 changed files with 1994 additions and 980 deletions
|
@ -287,6 +287,10 @@ class Account < ApplicationRecord
|
|||
suspended_at.present? && !instance_actor?
|
||||
end
|
||||
|
||||
def suspended_locally?
|
||||
suspended? && suspension_origin_local?
|
||||
end
|
||||
|
||||
def suspended_permanently?
|
||||
suspended? && deletion_request.nil?
|
||||
end
|
||||
|
|
|
@ -31,10 +31,14 @@ class AccountMigration < ApplicationRecord
|
|||
validate :validate_migration_cooldown
|
||||
validate :validate_target_account
|
||||
|
||||
scope :within_cooldown, ->(now = Time.now.utc) { where(arel_table[:created_at].gteq(now - COOLDOWN_PERIOD)) }
|
||||
scope :within_cooldown, -> { where(created_at: cooldown_duration_ago..) }
|
||||
|
||||
attr_accessor :current_password, :current_username
|
||||
|
||||
def self.cooldown_duration_ago
|
||||
Time.current - COOLDOWN_PERIOD
|
||||
end
|
||||
|
||||
def save_with_challenge(current_user)
|
||||
if current_user.encrypted_password.present?
|
||||
errors.add(:current_password, :invalid) unless current_user.valid_password?(current_password)
|
||||
|
|
|
@ -74,7 +74,7 @@ class Admin::AccountAction
|
|||
end
|
||||
|
||||
def disabled_types_for_account(account)
|
||||
if account.suspended?
|
||||
if account.suspended_locally?
|
||||
%w(silence suspend)
|
||||
elsif account.silenced?
|
||||
%w(silence)
|
||||
|
|
|
@ -13,7 +13,11 @@ module Account::AttributionDomains
|
|||
|
||||
def attribution_domains_as_text=(str)
|
||||
self[:attribution_domains] = str.split.filter_map do |line|
|
||||
line.strip.delete_prefix('*.')
|
||||
line
|
||||
.strip
|
||||
.delete_prefix('http://')
|
||||
.delete_prefix('https://')
|
||||
.delete_prefix('*.')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ class CustomEmoji < ApplicationRecord
|
|||
include Attachmentable
|
||||
|
||||
LIMIT = 512.kilobytes
|
||||
MINIMUM_SHORTCODE_SIZE = 2
|
||||
|
||||
SHORTCODE_RE_FRAGMENT = '[a-zA-Z0-9_]{2,}'
|
||||
|
||||
|
@ -47,7 +48,7 @@ class CustomEmoji < ApplicationRecord
|
|||
normalizes :domain, with: ->(domain) { domain.downcase }
|
||||
|
||||
validates_attachment :image, content_type: { content_type: IMAGE_MIME_TYPES }, presence: true, size: { less_than: LIMIT }
|
||||
validates :shortcode, uniqueness: { scope: :domain }, format: { with: SHORTCODE_ONLY_RE }, length: { minimum: 2 }
|
||||
validates :shortcode, uniqueness: { scope: :domain }, format: { with: SHORTCODE_ONLY_RE }, length: { minimum: MINIMUM_SHORTCODE_SIZE }
|
||||
|
||||
scope :local, -> { where(domain: nil) }
|
||||
scope :remote, -> { where.not(domain: nil) }
|
||||
|
|
|
@ -20,13 +20,11 @@ class ListAccount < ApplicationRecord
|
|||
validates :account_id, uniqueness: { scope: :list_id }
|
||||
validate :validate_relationship
|
||||
|
||||
before_validation :set_follow
|
||||
before_validation :set_follow, unless: :list_owner_account_is_account?
|
||||
|
||||
private
|
||||
|
||||
def set_follow
|
||||
return if list.account_id == account.id
|
||||
|
||||
self.follow = Follow.find_by!(account_id: list.account_id, target_account_id: account.id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
self.follow_request = FollowRequest.find_by!(account_id: list.account_id, target_account_id: account.id)
|
||||
|
@ -39,4 +37,8 @@ class ListAccount < ApplicationRecord
|
|||
errors.add(:follow, 'mismatched accounts') if follow_id.present? && follow.target_account_id != account_id
|
||||
errors.add(:follow_request, 'mismatched accounts') if follow_request_id.present? && follow_request.target_account_id != account_id
|
||||
end
|
||||
|
||||
def list_owner_account_is_account?
|
||||
list.account_id == account_id
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,7 +39,7 @@ class PreviewCard < ApplicationRecord
|
|||
include Attachmentable
|
||||
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
||||
LIMIT = 2.megabytes
|
||||
LIMIT = Rails.configuration.x.use_vips ? 8.megabytes : 2.megabytes
|
||||
|
||||
BLURHASH_OPTIONS = {
|
||||
x_comp: 4,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue