Skip to content

Commit

Permalink
Merge pull request #2753 from ClearlyClaire/glitch-soc/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream changes up to 4743657
  • Loading branch information
ClearlyClaire authored Jun 23, 2024
2 parents 1090611 + 3b46079 commit be3d60c
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.14
20.15
4 changes: 0 additions & 4 deletions .rubocop/rails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ Rails/FilePath:
Rails/HttpStatus:
EnforcedStyle: numeric

Rails/LexicallyScopedActionFilter:
Exclude:
- app/controllers/auth/* # Conflicts with `Lint/UselessMethodDefinition` for inherited controller actions

Rails/NegateInclude:
Enabled: false

Expand Down
8 changes: 0 additions & 8 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ Rails/OutputSafety:
Exclude:
- 'config/initializers/simple_form.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedMethods, AllowedPatterns.
# AllowedMethods: ==, equal?, eql?
Style/ClassEqualityComparison:
Exclude:
- 'app/helpers/jsonld_helper.rb'
- 'app/serializers/activitypub/outbox_serializer.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedVars.
Style/FetchEnvVar:
Expand Down
18 changes: 9 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ ARG NODE_MAJOR_VERSION="20"
# Debian image to use for base image, change with [--build-arg DEBIAN_VERSION="bookworm"]
ARG DEBIAN_VERSION="bookworm"
# Node image to use for base image based on combined variables (ex: 20-bookworm-slim)
FROM docker.io/node:${NODE_MAJOR_VERSION}-${DEBIAN_VERSION}-slim as node
FROM docker.io/node:${NODE_MAJOR_VERSION}-${DEBIAN_VERSION}-slim AS node
# Ruby image to use for base image based on combined variables (ex: 3.3.x-slim-bookworm)
FROM docker.io/ruby:${RUBY_VERSION}-slim-${DEBIAN_VERSION} as ruby
FROM docker.io/ruby:${RUBY_VERSION}-slim-${DEBIAN_VERSION} AS ruby

# Resulting version string is vX.X.X-MASTODON_VERSION_PRERELEASE+MASTODON_VERSION_METADATA
# Example: v4.3.0-nightly.2023.11.09+pr-123456
Expand Down Expand Up @@ -117,7 +117,7 @@ RUN \
;

# Create temporary build layer from base image
FROM ruby as build
FROM ruby AS build

# Copy Node package configuration files into working directory
COPY package.json yarn.lock .yarnrc.yml /opt/mastodon/
Expand Down Expand Up @@ -185,7 +185,7 @@ RUN \
corepack prepare --activate;

# Create temporary libvips specific build layer from build layer
FROM build as libvips
FROM build AS libvips

# libvips version to compile, change with [--build-arg VIPS_VERSION="8.15.2"]
# renovate: datasource=github-releases depName=libvips packageName=libvips/libvips
Expand All @@ -205,7 +205,7 @@ RUN \
ninja install;

# Create temporary ffmpeg specific build layer from build layer
FROM build as ffmpeg
FROM build AS ffmpeg

# ffmpeg version to compile, change with [--build-arg FFMPEG_VERSION="7.0.x"]
# renovate: datasource=repology depName=ffmpeg packageName=openpkg_current/ffmpeg
Expand Down Expand Up @@ -247,7 +247,7 @@ RUN \
make install;

# Create temporary bundler specific build layer from build layer
FROM build as bundler
FROM build AS bundler

ARG TARGETPLATFORM

Expand All @@ -269,7 +269,7 @@ RUN \
bundle install -j"$(nproc)";

# Create temporary node specific build layer from build layer
FROM build as yarn
FROM build AS yarn

ARG TARGETPLATFORM

Expand All @@ -286,7 +286,7 @@ RUN \
yarn workspaces focus --production @mastodon/mastodon;

# Create temporary assets build layer from build layer
FROM build as precompiler
FROM build AS precompiler

# Copy Mastodon sources into precompiler layer
COPY . /opt/mastodon/
Expand All @@ -310,7 +310,7 @@ RUN \
rm -fr /opt/mastodon/tmp;

# Prep final Mastodon Ruby layer
FROM ruby as mastodon
FROM ruby AS mastodon

ARG TARGETPLATFORM

Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ gem 'oj', '~> 3.14'
gem 'ox', '~> 2.14'
gem 'parslet'
gem 'premailer-rails'
gem 'public_suffix', '~> 5.0'
gem 'public_suffix', '~> 6.0'
gem 'pundit', '~> 2.3'
gem 'rack-attack', '~> 6.6'
gem 'rack-cors', '~> 2.0', require: 'rack/cors'
Expand Down Expand Up @@ -105,7 +105,7 @@ gem 'private_address_check', '~> 0.5'
gem 'opentelemetry-api', '~> 1.2.5'

group :opentelemetry do
gem 'opentelemetry-exporter-otlp', '~> 0.27.0', require: false
gem 'opentelemetry-exporter-otlp', '~> 0.28.0', require: false
gem 'opentelemetry-instrumentation-active_job', '~> 0.7.1', require: false
gem 'opentelemetry-instrumentation-active_model_serializers', '~> 0.20.1', require: false
gem 'opentelemetry-instrumentation-concurrent_ruby', '~> 0.21.2', require: false
Expand Down
26 changes: 14 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ GEM
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
aes_key_wrap (1.1.0)
android_key_attestation (0.3.0)
annotate (3.2.0)
Expand Down Expand Up @@ -143,7 +143,7 @@ GEM
brpoplpush-redis_script (0.1.3)
concurrent-ruby (~> 1.0, >= 1.0.5)
redis (>= 1.0, < 6)
builder (3.2.4)
builder (3.3.0)
bundler-audit (0.9.1)
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
Expand Down Expand Up @@ -195,7 +195,7 @@ GEM
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise-two-factor (5.0.0)
devise-two-factor (5.1.0)
activesupport (~> 7.0)
devise (~> 4.0)
railties (~> 7.0)
Expand Down Expand Up @@ -226,7 +226,7 @@ GEM
htmlentities (~> 4.3.3)
launchy (~> 2.1)
mail (~> 2.7)
erubi (1.12.0)
erubi (1.13.0)
et-orbi (1.2.11)
tzinfo
excon (0.110.0)
Expand Down Expand Up @@ -398,6 +398,7 @@ GEM
llhttp-ffi (0.5.0)
ffi-compiler (~> 1.0)
rake (~> 13.0)
logger (1.6.0)
lograge (0.14.0)
actionpack (>= 4)
activesupport (>= 4)
Expand Down Expand Up @@ -489,8 +490,8 @@ GEM
opentelemetry-api (1.2.5)
opentelemetry-common (0.20.1)
opentelemetry-api (~> 1.0)
opentelemetry-exporter-otlp (0.27.0)
google-protobuf (~> 3.14)
opentelemetry-exporter-otlp (0.28.0)
google-protobuf (>= 3.18)
googleapis-common-protos-types (~> 1.3)
opentelemetry-api (~> 1.1)
opentelemetry-common (~> 0.20)
Expand Down Expand Up @@ -602,7 +603,7 @@ GEM
railties (>= 7.0.0)
psych (5.1.2)
stringio
public_suffix (5.1.1)
public_suffix (6.0.0)
puma (6.4.2)
nio4r (~> 2.0)
pundit (2.3.2)
Expand Down Expand Up @@ -675,7 +676,7 @@ GEM
link_header (~> 0.0, >= 0.0.8)
rdf-normalize (0.7.0)
rdf (~> 3.3)
rdoc (6.6.3.1)
rdoc (6.7.0)
psych (>= 4.0.0)
redcarpet (3.6.0)
redis (4.8.1)
Expand Down Expand Up @@ -771,8 +772,9 @@ GEM
scenic (1.8.0)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
selenium-webdriver (4.21.1)
selenium-webdriver (4.22.0)
base64 (~> 0.2)
logger (~> 1.4)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
Expand Down Expand Up @@ -972,7 +974,7 @@ DEPENDENCIES
omniauth-saml (~> 2.0)
omniauth_openid_connect (~> 0.6.1)
opentelemetry-api (~> 1.2.5)
opentelemetry-exporter-otlp (~> 0.27.0)
opentelemetry-exporter-otlp (~> 0.28.0)
opentelemetry-instrumentation-active_job (~> 0.7.1)
opentelemetry-instrumentation-active_model_serializers (~> 0.20.1)
opentelemetry-instrumentation-concurrent_ruby (~> 0.21.2)
Expand All @@ -994,7 +996,7 @@ DEPENDENCIES
premailer-rails
private_address_check (~> 0.5)
propshaft
public_suffix (~> 5.0)
public_suffix (~> 6.0)
puma (~> 6.3)
pundit (~> 2.3)
rack (~> 2.2.7)
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/auth/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def new
super(&:build_invite_request)
end

def edit # rubocop:disable Lint/UselessMethodDefinition
super
end

def create # rubocop:disable Lint/UselessMethodDefinition
super
end

def update
super do |resource|
resource.clear_other_sessions(current_session.session_id) if resource.saved_change_to_encrypted_password?
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/jsonld_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def patch_for_forwarding!(original, compacted)
def safe_for_forwarding?(original, compacted)
original.without('@context', 'signature').all? do |key, value|
compacted_value = compacted[key]
return false unless value.class == compacted_value.class
return false unless value.instance_of?(compacted_value.class)

if value.is_a?(Hash)
safe_for_forwarding?(value, compacted_value)
Expand Down
9 changes: 2 additions & 7 deletions app/lib/cache_buster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@

class CacheBuster
def initialize(options = {})
Rails.application.deprecators[:mastodon].warn('Default values for the cache buster secret header name and values will be removed in Mastodon 4.3. Please set them explicitely if you rely on those.') unless options[:http_method] || (options[:secret] && options[:secret_header])

@secret_header = options[:secret_header] ||
(options[:http_method] ? nil : 'Secret-Header')
@secret = options[:secret] ||
(options[:http_method] ? nil : 'True')

@secret_header = options[:secret_header]
@secret = options[:secret]
@http_method = options[:http_method] || 'GET'
end

Expand Down
15 changes: 10 additions & 5 deletions app/lib/link_details_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,21 @@ def structured_data
end

def document
@document ||= Nokogiri::HTML(@html, nil, encoding)
@document ||= detect_encoding_and_parse_document
end

def encoding
@encoding ||= begin
guess = detector.detect(@html, @html_charset)
guess&.fetch(:confidence, 0).to_i > 60 ? guess&.fetch(:encoding, nil) : nil
def detect_encoding_and_parse_document
[detect_encoding, nil, @html_charset, 'UTF-8'].uniq.each do |encoding|
document = Nokogiri::HTML(@html, nil, encoding)
return document if document.to_s.valid_encoding?
end
end

def detect_encoding
guess = detector.detect(@html, @html_charset)
guess&.fetch(:confidence, 0).to_i > 60 ? guess&.fetch(:encoding, nil) : nil
end

def detector
@detector ||= CharlockHolmes::EncodingDetector.new.tap do |detector|
detector.strip_tags = true
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/activitypub/outbox_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class ActivityPub::OutboxSerializer < ActivityPub::CollectionSerializer
def self.serializer_for(model, options)
if model.class.name == 'ActivityPub::ActivityPresenter'
if model.instance_of?(::ActivityPub::ActivityPresenter)
ActivityPub::ActivitySerializer
else
super
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class AddAttachmentAvatarToAccounts < ActiveRecord::Migration[4.2]
def self.up
def up
change_table :accounts do |t|
# The following corresponds to `t.attachment :avatar` in an older version of Paperclip
t.string :avatar_file_name
Expand All @@ -11,7 +11,7 @@ def self.up
end
end

def self.down
def down
remove_attachment :accounts, :avatar
end
end
4 changes: 2 additions & 2 deletions db/migrate/20160305115639_add_devise_to_users.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class AddDeviseToUsers < ActiveRecord::Migration[4.2]
def self.up
def up
change_table(:users, bulk: true) do |t|
## Database authenticatable
t.string :encrypted_password, null: false, default: ''
Expand All @@ -24,7 +24,7 @@ def self.up
add_index :users, :reset_password_token, unique: true
end

def self.down
def down
remove_index :users, :reset_password_token

remove_column :users, :encrypted_password
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class AddAttachmentHeaderToAccounts < ActiveRecord::Migration[4.2]
def self.up
def up
change_table :accounts do |t|
# The following corresponds to `t.attachment :header` in an older version of Paperclip
t.string :header_file_name
Expand All @@ -11,7 +11,7 @@ def self.up
end
end

def self.down
def down
remove_attachment :accounts, :header
end
end
4 changes: 2 additions & 2 deletions db/migrate/20161006213403_rails_settings_migration.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class RailsSettingsMigration < ActiveRecord::Migration[5.0]
def self.up
def up
create_table :settings do |t|
t.string :var, null: false
t.text :value
Expand All @@ -11,7 +11,7 @@ def self.up
add_index :settings, [:target_type, :target_id, :var], unique: true
end

def self.down
def down
drop_table :settings
end
end
4 changes: 2 additions & 2 deletions db/migrate/20170330164118_add_attachment_data_to_imports.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class AddAttachmentDataToImports < ActiveRecord::Migration[4.2]
def self.up
def up
change_table :imports do |t|
# The following corresponds to `t.attachment :data` in an older version of Paperclip
t.string :data_file_name
Expand All @@ -11,7 +11,7 @@ def self.up
end
end

def self.down
def down
remove_attachment :imports, :data
end
end
Loading

0 comments on commit be3d60c

Please sign in to comment.