Merge remote-tracking branch 'parent/stable-4.3' into upstream-20241005
This commit is contained in:
commit
cc857e57c6
132 changed files with 775 additions and 312 deletions
|
@ -21,7 +21,7 @@ class AccountFilter
|
|||
end
|
||||
|
||||
def results
|
||||
scope = Account.includes(:account_stat, user: [:ips, :invite_request]).without_instance_actor.reorder(nil)
|
||||
scope = Account.includes(:account_stat, user: [:ips, :invite_request]).without_instance_actor
|
||||
|
||||
relevant_params.each do |key, value|
|
||||
next if key.to_s == 'page'
|
||||
|
|
|
@ -14,7 +14,7 @@ class Admin::TagFilter
|
|||
end
|
||||
|
||||
def results
|
||||
scope = Tag.reorder(nil)
|
||||
scope = Tag.all
|
||||
|
||||
params.each do |key, value|
|
||||
next if key == :page
|
||||
|
|
|
@ -6,10 +6,13 @@ module Account::Avatar
|
|||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
||||
LIMIT = 2.megabytes
|
||||
|
||||
AVATAR_DIMENSIONS = [400, 400].freeze
|
||||
AVATAR_GEOMETRY = [AVATAR_DIMENSIONS.first, AVATAR_DIMENSIONS.last].join('x')
|
||||
|
||||
class_methods do
|
||||
def avatar_styles(file)
|
||||
styles = { original: { geometry: '400x400#', file_geometry_parser: FastGeometryParser } }
|
||||
styles[:static] = { geometry: '400x400#', format: 'png', convert_options: '-coalesce', file_geometry_parser: FastGeometryParser } if file.content_type == 'image/gif'
|
||||
styles = { original: { geometry: "#{AVATAR_GEOMETRY}#", file_geometry_parser: FastGeometryParser } }
|
||||
styles[:static] = { geometry: "#{AVATAR_GEOMETRY}#", format: 'png', convert_options: '-coalesce', file_geometry_parser: FastGeometryParser } if file.content_type == 'image/gif'
|
||||
styles
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,10 @@ module Account::Header
|
|||
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
||||
LIMIT = 2.megabytes
|
||||
MAX_PIXELS = 750_000 # 1500x500px
|
||||
|
||||
HEADER_DIMENSIONS = [1500, 500].freeze
|
||||
HEADER_GEOMETRY = [HEADER_DIMENSIONS.first, HEADER_DIMENSIONS.last].join('x')
|
||||
MAX_PIXELS = HEADER_DIMENSIONS.first * HEADER_DIMENSIONS.last
|
||||
|
||||
class_methods do
|
||||
def header_styles(file)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
class RemoteFollow
|
||||
include ActiveModel::Validations
|
||||
include RoutingHelper
|
||||
include WebfingerHelper
|
||||
|
||||
attr_accessor :acct, :addressable_template
|
||||
|
||||
|
@ -66,7 +65,7 @@ class RemoteFollow
|
|||
end
|
||||
|
||||
def acct_resource
|
||||
@acct_resource ||= webfinger!("acct:#{acct}")
|
||||
@acct_resource ||= Webfinger.new("acct:#{acct}").perform
|
||||
rescue Webfinger::Error, HTTP::ConnectionError
|
||||
nil
|
||||
end
|
||||
|
|
|
@ -18,13 +18,25 @@ class ReportFilter
|
|||
def results
|
||||
scope = Report.unresolved
|
||||
|
||||
params.each do |key, value|
|
||||
relevant_params.each do |key, value|
|
||||
scope = scope.merge scope_for(key, value)
|
||||
end
|
||||
|
||||
scope
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def relevant_params
|
||||
params.tap do |args|
|
||||
args.delete(:target_origin) if origin_is_remote_and_domain_present?
|
||||
end
|
||||
end
|
||||
|
||||
def origin_is_remote_and_domain_present?
|
||||
params[:target_origin] == 'remote' && params[:by_target_domain].present?
|
||||
end
|
||||
|
||||
def scope_for(key, value)
|
||||
case key.to_sym
|
||||
when :by_target_domain
|
||||
|
|
|
@ -28,6 +28,8 @@ class SessionActivation < ApplicationRecord
|
|||
|
||||
before_create :assign_access_token
|
||||
|
||||
DEFAULT_SCOPES = %w(read write follow).freeze
|
||||
|
||||
class << self
|
||||
def active?(id)
|
||||
id && exists?(session_id: id)
|
||||
|
@ -64,7 +66,7 @@ class SessionActivation < ApplicationRecord
|
|||
{
|
||||
application_id: Doorkeeper::Application.find_by(superapp: true)&.id,
|
||||
resource_owner_id: user_id,
|
||||
scopes: 'read write follow',
|
||||
scopes: DEFAULT_SCOPES.join(' '),
|
||||
expires_in: Doorkeeper.configuration.access_token_expires_in,
|
||||
use_refresh_token: Doorkeeper.configuration.refresh_token_enabled?,
|
||||
}
|
||||
|
|
|
@ -74,7 +74,8 @@ class User < ApplicationRecord
|
|||
REACTION_DECK_MAX = 256
|
||||
|
||||
devise :two_factor_authenticatable,
|
||||
otp_secret_encryption_key: Rails.configuration.x.otp_secret
|
||||
otp_secret_encryption_key: Rails.configuration.x.otp_secret,
|
||||
otp_secret_length: 32
|
||||
|
||||
include LegacyOtpSecret # Must be after the above `devise` line in order to override the legacy method
|
||||
|
||||
|
|
|
@ -29,26 +29,6 @@ class Web::PushSubscription < ApplicationRecord
|
|||
|
||||
delegate :locale, to: :associated_user
|
||||
|
||||
def encrypt(payload)
|
||||
Webpush::Encryption.encrypt(payload, key_p256dh, key_auth)
|
||||
end
|
||||
|
||||
def audience
|
||||
@audience ||= Addressable::URI.parse(endpoint).normalized_site
|
||||
end
|
||||
|
||||
def crypto_key_header
|
||||
p256ecdsa = vapid_key.public_key_for_push_header
|
||||
|
||||
"p256ecdsa=#{p256ecdsa}"
|
||||
end
|
||||
|
||||
def authorization_header
|
||||
jwt = JWT.encode({ aud: audience, exp: 24.hours.from_now.to_i, sub: "mailto:#{contact_email}" }, vapid_key.curve, 'ES256', typ: 'JWT')
|
||||
|
||||
"WebPush #{jwt}"
|
||||
end
|
||||
|
||||
def pushable?(notification)
|
||||
policy_allows_notification?(notification) && alert_enabled_for_notification_type?(notification)
|
||||
end
|
||||
|
@ -92,14 +72,6 @@ class Web::PushSubscription < ApplicationRecord
|
|||
)
|
||||
end
|
||||
|
||||
def vapid_key
|
||||
@vapid_key ||= Webpush::VapidKey.from_keys(Rails.configuration.x.vapid_public_key, Rails.configuration.x.vapid_private_key)
|
||||
end
|
||||
|
||||
def contact_email
|
||||
@contact_email ||= ::Setting.site_contact_email
|
||||
end
|
||||
|
||||
def alert_enabled_for_notification_type?(notification)
|
||||
truthy?(data&.dig('alerts', notification.type.to_s))
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue