Merge remote-tracking branch 'parent/main' into upstream-20240507

This commit is contained in:
KMY 2024-05-07 08:05:04 +09:00
commit 89b71363ae
70 changed files with 1739 additions and 445 deletions

View file

@ -17,11 +17,9 @@
# url :string
# avatar_file_name :string
# avatar_content_type :string
# avatar_file_size :integer
# avatar_updated_at :datetime
# header_file_name :string
# header_content_type :string
# header_file_size :integer
# header_updated_at :datetime
# avatar_remote_url :string
# locked :boolean default(FALSE), not null
@ -55,6 +53,8 @@
# indexable :boolean default(FALSE), not null
# master_settings :jsonb
# remote_pending :boolean default(FALSE), not null
# avatar_file_size :bigint(8)
# header_file_size :bigint(8)
#
class Account < ApplicationRecord

View file

@ -3,6 +3,23 @@
module Status::ThreadingConcern
extend ActiveSupport::Concern
class_methods do
def permitted_statuses_from_ids(ids, account, stable: false)
statuses = Status.with_accounts(ids).to_a
account_ids = statuses.map(&:account_id).uniq
domains = statuses.filter_map(&:account_domain).uniq
relations = account&.relations_map(account_ids, domains) || {}
statuses.reject! { |status| StatusFilter.new(status, account, relations).filtered? }
if stable
statuses.sort_by! { |status| ids.index(status.id) }
else
statuses
end
end
end
def ancestors(limit, account = nil)
find_statuses_from_tree_path(ancestor_ids(limit), account)
end
@ -85,15 +102,7 @@ module Status::ThreadingConcern
end
def find_statuses_from_tree_path(ids, account, promote: false)
statuses = Status.with_accounts(ids).to_a
account_ids = statuses.map(&:account_id).uniq
domains = statuses.filter_map(&:account_domain).uniq
relations = account&.relations_map(account_ids, domains) || {}
statuses.reject! { |status| StatusFilter.new(status, account, relations).filtered? }
# Order ancestors/descendants by tree path
statuses.sort_by! { |status| ids.index(status.id) }
statuses = Status.permitted_statuses_from_ids(ids, account, stable: true)
# Bring self-replies to the top
if promote

View file

@ -22,7 +22,7 @@ module User::LdapAuthenticable
safe_username = safe_username.gsub(keys, replacement)
end
resource = joins(:account).find_by(accounts: { username: safe_username })
resource = joins(:account).merge(Account.where(Account.arel_table[:username].lower.eq safe_username.downcase)).take
if resource.blank?
resource = new(

View file

@ -9,7 +9,6 @@
# domain :string
# image_file_name :string
# image_content_type :string
# image_file_size :integer
# image_updated_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
@ -24,6 +23,7 @@
# aliases :jsonb
# is_sensitive :boolean default(FALSE), not null
# license :string
# image_file_size :bigint(8)
#
class CustomEmoji < ApplicationRecord

View file

@ -65,6 +65,8 @@ class Form::AdminSettings
hold_remote_new_accounts
stop_fetch_activity_domains
stop_link_preview_domains
app_icon
favicon
).freeze
INTEGER_KEYS = %i(
@ -114,6 +116,8 @@ class Form::AdminSettings
UPLOAD_KEYS = %i(
thumbnail
mascot
app_icon
favicon
).freeze
OVERRIDEN_SETTINGS = {

View file

@ -11,10 +11,10 @@
# updated_at :datetime not null
# data_file_name :string
# data_content_type :string
# data_file_size :integer
# data_updated_at :datetime
# account_id :bigint(8) not null
# overwrite :boolean default(FALSE), not null
# data_file_size :bigint(8)
#
# NOTE: This is a deprecated model, only kept to not break ongoing imports

View file

@ -8,7 +8,6 @@
# status_id :bigint(8)
# file_file_name :string
# file_content_type :string
# file_file_size :integer
# file_updated_at :datetime
# remote_url :string default(""), not null
# created_at :datetime not null
@ -24,9 +23,10 @@
# file_storage_schema_version :integer
# thumbnail_file_name :string
# thumbnail_content_type :string
# thumbnail_file_size :integer
# thumbnail_updated_at :datetime
# thumbnail_remote_url :string
# file_file_size :bigint(8)
# thumbnail_file_size :bigint(8)
#
class MediaAttachment < ApplicationRecord

View file

@ -10,7 +10,6 @@
# description :string default(""), not null
# image_file_name :string
# image_content_type :string
# image_file_size :integer
# image_updated_at :datetime
# type :integer default("link"), not null
# html :text default(""), not null
@ -32,6 +31,7 @@
# link_type :integer
# published_at :datetime
# image_description :string default(""), not null
# image_file_size :bigint(8)
#
class PreviewCard < ApplicationRecord

View file

@ -8,18 +8,26 @@
# var :string default(""), not null
# file_file_name :string
# file_content_type :string
# file_file_size :integer
# file_updated_at :datetime
# meta :json
# created_at :datetime not null
# updated_at :datetime not null
# blurhash :string
# file_file_size :bigint(8)
#
class SiteUpload < ApplicationRecord
include Attachmentable
FAVICON_SIZES = [16, 32, 48].freeze
APPLE_ICON_SIZES = [57, 60, 72, 76, 114, 120, 144, 152, 167, 180, 1024].freeze
ANDROID_ICON_SIZES = [36, 48, 72, 96, 144, 192, 256, 384, 512].freeze
APP_ICON_SIZES = (APPLE_ICON_SIZES + ANDROID_ICON_SIZES).uniq.freeze
STYLES = {
app_icon: APP_ICON_SIZES.each_with_object({}) { |size, hash| hash[size.to_s.to_sym] = "#{size}x#{size}#" }.freeze,
favicon: FAVICON_SIZES.each_with_object({}) { |size, hash| hash[size.to_s.to_sym] = "#{size}x#{size}#" }.freeze,
thumbnail: {
'@1x': {
format: 'png',

View file

@ -336,7 +336,7 @@ class Status < ApplicationRecord
end
def reported?
@reported ||= Report.where(target_account: account).unresolved.exists?(['? = ANY(status_ids)', id])
@reported ||= account.targeted_reports.unresolved.exists?(['? = ANY(status_ids)', id]) || account.strikes.exists?(['? = ANY(status_ids)', id.to_s])
end
def dtl?

View file

@ -39,7 +39,7 @@ class Tag < ApplicationRecord
HASHTAG_LAST_SEQUENCE = '([[:word:]_]*[[:alpha:]][[:word:]_]*)'
HASHTAG_NAME_PAT = "#{HASHTAG_FIRST_SEQUENCE}|#{HASHTAG_LAST_SEQUENCE}"
HASHTAG_RE = %r{(?<![=/)\w])#(#{HASHTAG_NAME_PAT})}i
HASHTAG_RE = %r{(?<![=/)\p{Alnum}])#(#{HASHTAG_NAME_PAT})}i
HASHTAG_NAME_RE = /\A(#{HASHTAG_NAME_PAT})\z/i
HASHTAG_INVALID_CHARS_RE = /[^[:alnum:]\u0E47-\u0E4E#{HASHTAG_SEPARATORS}]/