Merge remote-tracking branch 'parent/main' into upstream-20250328
This commit is contained in:
commit
12ed20b6d5
257 changed files with 3505 additions and 2010 deletions
|
@ -160,7 +160,7 @@ class Account < ApplicationRecord
|
|||
scope :not_excluded_by_account, ->(account) { where.not(id: account.excluded_from_timeline_account_ids) }
|
||||
scope :not_domain_blocked_by_account, ->(account) { where(arel_table[:domain].eq(nil).or(arel_table[:domain].not_in(account.excluded_from_timeline_domains))) }
|
||||
scope :dormant, -> { joins(:account_stat).merge(AccountStat.without_recent_activity) }
|
||||
scope :with_username, ->(value) { where arel_table[:username].lower.eq(value.to_s.downcase) }
|
||||
scope :with_username, ->(value) { value.is_a?(Array) ? where(arel_table[:username].lower.in(value.map { |x| x.to_s.downcase })) : where(arel_table[:username].lower.eq(value.to_s.downcase)) }
|
||||
scope :with_domain, ->(value) { where arel_table[:domain].lower.eq(value&.to_s&.downcase) }
|
||||
scope :without_memorial, -> { where(memorial: false) }
|
||||
scope :duplicate_uris, -> { select(:uri, Arel.star.count).group(:uri).having(Arel.star.count.gt(1)) }
|
||||
|
|
|
@ -73,7 +73,14 @@ class Account::Field < ActiveModelSerializers::Model
|
|||
end
|
||||
|
||||
def extract_url_from_html
|
||||
doc = Nokogiri::HTML5.fragment(value)
|
||||
begin
|
||||
doc = Nokogiri::HTML5.fragment(value)
|
||||
rescue ArgumentError
|
||||
# This can happen if one of the Nokogumbo limits is encountered
|
||||
# Unfortunately, it does not use a more precise error class
|
||||
# nor allows more graceful handling
|
||||
return
|
||||
end
|
||||
|
||||
return if doc.nil?
|
||||
return if doc.children.size != 1
|
||||
|
|
|
@ -38,7 +38,7 @@ class CustomFilter < ApplicationRecord
|
|||
include Expireable
|
||||
include Redisable
|
||||
|
||||
enum :action, { warn: 0, hide: 1 }, suffix: :action
|
||||
enum :action, { warn: 0, hide: 1, blur: 2 }, suffix: :action
|
||||
|
||||
belongs_to :account
|
||||
has_many :keywords, class_name: 'CustomFilterKeyword', inverse_of: :custom_filter, dependent: :destroy
|
||||
|
|
|
@ -65,6 +65,7 @@ class Form::AdminSettings
|
|||
stop_link_preview_domains
|
||||
app_icon
|
||||
favicon
|
||||
min_age
|
||||
).freeze
|
||||
|
||||
INTEGER_KEYS = %i(
|
||||
|
@ -80,6 +81,7 @@ class Form::AdminSettings
|
|||
registrations_end_hour
|
||||
registrations_secondary_start_hour
|
||||
registrations_secondary_end_hour
|
||||
min_age
|
||||
).freeze
|
||||
|
||||
BOOLEAN_KEYS = %i(
|
||||
|
@ -140,6 +142,7 @@ class Form::AdminSettings
|
|||
validates :show_domain_blocks, inclusion: { in: %w(disabled users all) }, if: -> { defined?(@show_domain_blocks) }
|
||||
validates :show_domain_blocks_rationale, inclusion: { in: %w(disabled users all) }, if: -> { defined?(@show_domain_blocks_rationale) }
|
||||
validates :media_cache_retention_period, :content_cache_retention_period, :backups_retention_period, numericality: { only_integer: true }, allow_blank: true, if: -> { defined?(@media_cache_retention_period) || defined?(@content_cache_retention_period) || defined?(@backups_retention_period) }
|
||||
validates :min_age, numericality: { only_integer: true }, allow_blank: true, if: -> { defined?(@min_age) }
|
||||
validates :site_short_description, length: { maximum: DESCRIPTION_LIMIT }, if: -> { defined?(@site_short_description) }
|
||||
validates :status_page_url, url: true, allow_blank: true
|
||||
validate :validate_site_uploads
|
||||
|
|
|
@ -116,7 +116,7 @@ class MediaAttachment < ApplicationRecord
|
|||
VIDEO_PASSTHROUGH_OPTIONS = {
|
||||
video_codecs: ['h264'].freeze,
|
||||
audio_codecs: ['aac', nil].freeze,
|
||||
colorspaces: ['yuv420p'].freeze,
|
||||
colorspaces: ['yuv420p', 'yuvj420p'].freeze,
|
||||
options: {
|
||||
format: 'mp4',
|
||||
convert_options: {
|
||||
|
@ -425,8 +425,10 @@ class MediaAttachment < ApplicationRecord
|
|||
|
||||
@paths_to_cache_bust = MediaAttachment.attachment_definitions.keys.flat_map do |attachment_name|
|
||||
attachment = public_send(attachment_name)
|
||||
next if attachment.blank?
|
||||
|
||||
styles = DEFAULT_STYLES | attachment.styles.keys
|
||||
styles.map { |style| attachment.path(style) }
|
||||
styles.map { |style| attachment.url(style) }
|
||||
end.compact
|
||||
rescue => e
|
||||
# We really don't want any error here preventing media deletion
|
||||
|
|
|
@ -33,7 +33,8 @@ class Trends::Links < Trends::Base
|
|||
def register(status, at_time = Time.now.utc)
|
||||
original_status = status.proper
|
||||
|
||||
return unless (original_status.public_visibility? && status.public_visibility?) &&
|
||||
return unless original_status.public_visibility? &&
|
||||
status.public_visibility? &&
|
||||
!(original_status.account.silenced? || status.account.silenced?) &&
|
||||
!(original_status.spoiler_text? || original_status.sensitive?)
|
||||
|
||||
|
|
|
@ -5,41 +5,42 @@
|
|||
# Table name: users
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# email :string default(""), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# encrypted_password :string default(""), not null
|
||||
# reset_password_token :string
|
||||
# reset_password_sent_at :datetime
|
||||
# sign_in_count :integer default(0), not null
|
||||
# current_sign_in_at :datetime
|
||||
# last_sign_in_at :datetime
|
||||
# age_verified_at :datetime
|
||||
# approved :boolean default(TRUE), not null
|
||||
# chosen_languages :string is an Array
|
||||
# confirmation_sent_at :datetime
|
||||
# confirmation_token :string
|
||||
# confirmed_at :datetime
|
||||
# confirmation_sent_at :datetime
|
||||
# unconfirmed_email :string
|
||||
# locale :string
|
||||
# consumed_timestep :integer
|
||||
# current_sign_in_at :datetime
|
||||
# disabled :boolean default(FALSE), not null
|
||||
# email :string default(""), not null
|
||||
# encrypted_otp_secret :string
|
||||
# encrypted_otp_secret_iv :string
|
||||
# encrypted_otp_secret_salt :string
|
||||
# consumed_timestep :integer
|
||||
# otp_required_for_login :boolean default(FALSE), not null
|
||||
# encrypted_password :string default(""), not null
|
||||
# last_emailed_at :datetime
|
||||
# last_sign_in_at :datetime
|
||||
# locale :string
|
||||
# otp_backup_codes :string is an Array
|
||||
# account_id :bigint(8) not null
|
||||
# disabled :boolean default(FALSE), not null
|
||||
# invite_id :bigint(8)
|
||||
# chosen_languages :string is an Array
|
||||
# created_by_application_id :bigint(8)
|
||||
# approved :boolean default(TRUE), not null
|
||||
# otp_required_for_login :boolean default(FALSE), not null
|
||||
# otp_secret :string
|
||||
# reset_password_sent_at :datetime
|
||||
# reset_password_token :string
|
||||
# settings :text
|
||||
# sign_in_count :integer default(0), not null
|
||||
# sign_in_token :string
|
||||
# sign_in_token_sent_at :datetime
|
||||
# webauthn_id :string
|
||||
# sign_up_ip :inet
|
||||
# role_id :bigint(8)
|
||||
# settings :text
|
||||
# time_zone :string
|
||||
# otp_secret :string
|
||||
# unconfirmed_email :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :bigint(8) not null
|
||||
# created_by_application_id :bigint(8)
|
||||
# invite_id :bigint(8)
|
||||
# role_id :bigint(8)
|
||||
# webauthn_id :string
|
||||
#
|
||||
|
||||
class User < ApplicationRecord
|
||||
|
@ -116,6 +117,7 @@ class User < ApplicationRecord
|
|||
validates_with RegistrationFormTimeValidator, on: :create
|
||||
validates :website, absence: true, on: :create
|
||||
validates :confirm_password, absence: true, on: :create
|
||||
validates :date_of_birth, presence: true, date_of_birth: true, on: :create, if: -> { Setting.min_age.present? }
|
||||
validate :validate_role_elevation
|
||||
|
||||
scope :account_not_suspended, -> { joins(:account).merge(Account.without_suspended) }
|
||||
|
@ -134,6 +136,7 @@ class User < ApplicationRecord
|
|||
|
||||
before_validation :sanitize_role
|
||||
before_create :set_approved
|
||||
before_create :set_age_verified_at
|
||||
after_commit :send_pending_devise_notifications
|
||||
after_create_commit :trigger_webhooks
|
||||
|
||||
|
@ -145,7 +148,7 @@ class User < ApplicationRecord
|
|||
|
||||
delegate :can?, to: :role
|
||||
|
||||
attr_reader :invite_code
|
||||
attr_reader :invite_code, :date_of_birth
|
||||
attr_writer :external, :bypass_invite_request_check, :current_account
|
||||
|
||||
def self.those_who_can(*any_of_privileges)
|
||||
|
@ -162,6 +165,17 @@ class User < ApplicationRecord
|
|||
Rails.env.local?
|
||||
end
|
||||
|
||||
def date_of_birth=(hash_or_string)
|
||||
@date_of_birth = begin
|
||||
if hash_or_string.is_a?(Hash)
|
||||
day, month, year = hash_or_string.values_at(1, 2, 3)
|
||||
"#{day}.#{month}.#{year}"
|
||||
else
|
||||
hash_or_string
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def role
|
||||
if role_id.nil?
|
||||
UserRole.everyone
|
||||
|
@ -455,6 +469,10 @@ class User < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def set_age_verified_at
|
||||
self.age_verified_at = Time.now.utc if Setting.min_age.present?
|
||||
end
|
||||
|
||||
def grant_approval_on_confirmation?
|
||||
# Re-check approval on confirmation if the server has switched to open registrations
|
||||
open_registrations? && !sign_up_from_ip_requires_approval? && !sign_up_email_requires_approval?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue