Skip to content

Commit

Permalink
Merge pull request #659 from kmycode/upstream-20240319
Browse files Browse the repository at this point in the history
Upstream 20240319
  • Loading branch information
kmycode authored Mar 19, 2024
2 parents ab4fd52 + 48747d0 commit eb9f576
Show file tree
Hide file tree
Showing 498 changed files with 5,817 additions and 3,738 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ services:
hard: -1

libretranslate:
image: libretranslate/libretranslate:v1.5.5
image: libretranslate/libretranslate:v1.5.6
restart: unless-stopped
volumes:
- lt-data:/home/libretranslate/.local
Expand Down
2 changes: 2 additions & 0 deletions .haml-lint_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ linters:

ViewLength:
exclude:
- 'app/views/admin/accounts/index.html.haml'
- 'app/views/admin/instances/show.html.haml'
- 'app/views/admin/ng_rules/_ng_rule_fields.html.haml'
- 'app/views/admin/settings/discovery/show.html.haml'
- 'app/views/settings/preferences/appearance/show.html.haml'
- 'app/views/settings/preferences/other/show.html.haml'

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ 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.2.0-nightly.2023.11.09+something
# Overwrite existance of 'alpha.0' in version.rb [--build-arg MASTODON_VERSION_PRERELEASE="nightly.2023.11.09"]
# Overwrite existence of 'alpha.0' in version.rb [--build-arg MASTODON_VERSION_PRERELEASE="nightly.2023.11.09"]
ARG MASTODON_VERSION_PRERELEASE=""
# Append build metadata or fork information to version.rb [--build-arg MASTODON_VERSION_METADATA="something"]
ARG MASTODON_VERSION_METADATA=""
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ group :test do
# RSpec helpers for email specs
gem 'email_spec'

# Extra RSpec extenion methods and helpers for sidekiq
# Extra RSpec extension methods and helpers for sidekiq
gem 'rspec-sidekiq', '~> 4.0'

# Browser integration testing
Expand Down
22 changes: 11 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ GEM
terminal-table (>= 1.5.1)
idn-ruby (0.1.5)
io-console (0.7.2)
irb (1.11.2)
irb (1.12.0)
rdoc
reline (>= 0.4.2)
jmespath (1.6.2)
Expand All @@ -372,7 +372,7 @@ GEM
json-ld-preloaded (3.3.0)
json-ld (~> 3.3)
rdf (~> 3.3)
json-schema (4.1.1)
json-schema (4.2.0)
addressable (>= 2.8)
jsonapi-renderer (0.2.2)
jwt (2.7.1)
Expand Down Expand Up @@ -455,7 +455,7 @@ GEM
net-smtp (0.4.0.1)
net-protocol
nio4r (2.5.9)
nokogiri (1.16.2)
nokogiri (1.16.3)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nsa (0.3.0)
Expand Down Expand Up @@ -607,7 +607,7 @@ GEM
redlock (1.3.2)
redis (>= 3.0.0, < 6.0)
regexp_parser (2.9.0)
reline (0.4.2)
reline (0.4.3)
io-console (~> 0.5)
request_store (1.5.1)
rack (>= 1.4)
Expand All @@ -622,16 +622,16 @@ GEM
chunky_png (~> 1.0)
rqrcode_core (~> 1.0)
rqrcode_core (1.2.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (~> 3.13.0)
rspec-github (2.4.0)
rspec-core (~> 3.0)
rspec-mocks (3.12.6)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (~> 3.13.0)
rspec-rails (6.1.1)
actionpack (>= 6.1)
activesupport (>= 6.1)
Expand All @@ -647,7 +647,7 @@ GEM
rspec-expectations (~> 3.0)
rspec-mocks (~> 3.0)
sidekiq (>= 5, < 8)
rspec-support (3.12.1)
rspec-support (3.13.1)
rubocop (1.60.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/activitypub/base_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# frozen_string_literal: true

class ActivityPub::BaseController < Api::BaseController
include SignatureVerification
include AccountOwnedConcern

skip_before_action :require_authenticated_user!
skip_before_action :require_not_suspended!
skip_around_action :set_locale
Expand Down
3 changes: 0 additions & 3 deletions app/controllers/activitypub/claims_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# frozen_string_literal: true

class ActivityPub::ClaimsController < ActivityPub::BaseController
include SignatureVerification
include AccountOwnedConcern

skip_before_action :authenticate_user!

before_action :require_account_signature!
Expand Down
3 changes: 0 additions & 3 deletions app/controllers/activitypub/collections_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# frozen_string_literal: true

class ActivityPub::CollectionsController < ActivityPub::BaseController
include SignatureVerification
include AccountOwnedConcern

vary_by -> { 'Signature' if authorized_fetch_mode? }

before_action :require_account_signature!, if: :authorized_fetch_mode?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# frozen_string_literal: true

class ActivityPub::FollowersSynchronizationsController < ActivityPub::BaseController
include SignatureVerification
include AccountOwnedConcern

vary_by -> { 'Signature' if authorized_fetch_mode? }

before_action :require_account_signature!
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/activitypub/inboxes_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

class ActivityPub::InboxesController < ActivityPub::BaseController
include SignatureVerification
include JsonLdHelper
include AccountOwnedConcern

before_action :skip_unknown_actor_activity
before_action :require_actor_signature!
Expand Down
3 changes: 0 additions & 3 deletions app/controllers/activitypub/outboxes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
class ActivityPub::OutboxesController < ActivityPub::BaseController
LIMIT = 20

include SignatureVerification
include AccountOwnedConcern

vary_by -> { 'Signature' if authorized_fetch_mode? || page_requested? }

before_action :require_account_signature!, if: :authorized_fetch_mode?
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/activitypub/replies_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

class ActivityPub::RepliesController < ActivityPub::BaseController
include SignatureVerification
include Authorization
include AccountOwnedConcern

DESCENDANTS_LIMIT = 60

Expand Down
58 changes: 13 additions & 45 deletions app/controllers/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Api::BaseController < ApplicationController
include Api::AccessTokenTrackingConcern
include Api::CachingConcern
include Api::ContentSecurityPolicy
include Api::ErrorHandling

skip_before_action :require_functional!, unless: :limited_federation_mode?

Expand All @@ -18,51 +19,6 @@ class Api::BaseController < ApplicationController

protect_from_forgery with: :null_session

rescue_from ActiveRecord::RecordInvalid, Mastodon::ValidationError do |e|
render json: { error: e.to_s }, status: 422
end

rescue_from ActiveRecord::RecordNotUnique do
render json: { error: 'Duplicate record' }, status: 422
end

rescue_from Date::Error do
render json: { error: 'Invalid date supplied' }, status: 422
end

rescue_from ActiveRecord::RecordNotFound do
render json: { error: 'Record not found' }, status: 404
end

rescue_from HTTP::Error, Mastodon::UnexpectedResponseError do
render json: { error: 'Remote data could not be fetched' }, status: 503
end

rescue_from OpenSSL::SSL::SSLError do
render json: { error: 'Remote SSL certificate could not be verified' }, status: 503
end

rescue_from Mastodon::NotPermittedError do
render json: { error: 'This action is not allowed' }, status: 403
end

rescue_from Seahorse::Client::NetworkingError do |e|
Rails.logger.warn "Storage server error: #{e}"
render json: { error: 'There was a temporary problem serving your request, please try again' }, status: 503
end

rescue_from Mastodon::RaceConditionError, Stoplight::Error::RedLight do
render json: { error: 'There was a temporary problem serving your request, please try again' }, status: 503
end

rescue_from Mastodon::RateLimitExceededError do
render json: { error: I18n.t('errors.429') }, status: 429
end

rescue_from ActionController::ParameterMissing, Mastodon::InvalidParameterError do |e|
render json: { error: e.to_s }, status: 400
end

def doorkeeper_unauthorized_render_options(error: nil)
{ json: { error: error.try(:description) || 'Not authorized' } }
end
Expand All @@ -73,6 +29,14 @@ def doorkeeper_forbidden_render_options(*)

protected

def pagination_max_id
pagination_collection.last.id
end

def pagination_since_id
pagination_collection.first.id
end

def set_pagination_headers(next_path = nil, prev_path = nil)
links = []
links << [next_path, [%w(rel next)]] if next_path
Expand Down Expand Up @@ -140,6 +104,10 @@ def disallow_unauthenticated_api_access?

private

def insert_pagination_headers
set_pagination_headers(next_path, prev_path)
end

def pagination_options_invalid?
params.slice(:limit, :offset).values.map(&:to_i).any?(&:negative?)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ def paginated_follows
)
end

def insert_pagination_headers
set_pagination_headers(next_path, prev_path)
end

def next_path
api_v1_account_followers_url pagination_params(max_id: pagination_max_id) if records_continue?
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ def paginated_follows
)
end

def insert_pagination_headers
set_pagination_headers(next_path, prev_path)
end

def next_path
api_v1_account_following_index_url pagination_params(max_id: pagination_max_id) if records_continue?
end
Expand Down
12 changes: 2 additions & 10 deletions app/controllers/api/v1/accounts/statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ def pagination_params(core_params)
params.slice(:limit, *AccountStatusesFilter::KEYS).permit(:limit, *AccountStatusesFilter::KEYS).merge(core_params)
end

def insert_pagination_headers
set_pagination_headers(next_path, prev_path)
end

def next_path
api_v1_account_statuses_url pagination_params(max_id: pagination_max_id) if records_continue?
end
Expand All @@ -53,11 +49,7 @@ def records_continue?
@statuses.size == limit_param(DEFAULT_STATUSES_LIMIT)
end

def pagination_max_id
@statuses.last.id
end

def pagination_since_id
@statuses.first.id
def pagination_collection
@statuses
end
end
12 changes: 2 additions & 10 deletions app/controllers/api/v1/admin/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ def translated_filter_params
translated_params
end

def insert_pagination_headers
set_pagination_headers(next_path, prev_path)
end

def next_path
api_v1_admin_accounts_url(pagination_params(max_id: pagination_max_id)) if records_continue?
end
Expand All @@ -137,12 +133,8 @@ def prev_path
api_v1_admin_accounts_url(pagination_params(min_id: pagination_since_id)) unless @accounts.empty?
end

def pagination_max_id
@accounts.last.id
end

def pagination_since_id
@accounts.first.id
def pagination_collection
@accounts
end

def records_continue?
Expand Down
12 changes: 2 additions & 10 deletions app/controllers/api/v1/admin/canonical_email_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ def set_canonical_email_block
@canonical_email_block = CanonicalEmailBlock.find(params[:id])
end

def insert_pagination_headers
set_pagination_headers(next_path, prev_path)
end

def next_path
api_v1_admin_canonical_email_blocks_url(pagination_params(max_id: pagination_max_id)) if records_continue?
end
Expand All @@ -77,12 +73,8 @@ def prev_path
api_v1_admin_canonical_email_blocks_url(pagination_params(min_id: pagination_since_id)) unless @canonical_email_blocks.empty?
end

def pagination_max_id
@canonical_email_blocks.last.id
end

def pagination_since_id
@canonical_email_blocks.first.id
def pagination_collection
@canonical_email_blocks
end

def records_continue?
Expand Down
12 changes: 2 additions & 10 deletions app/controllers/api/v1/admin/domain_allows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ def filtered_domain_allows
DomainAllow.all
end

def insert_pagination_headers
set_pagination_headers(next_path, prev_path)
end

def next_path
api_v1_admin_domain_allows_url(pagination_params(max_id: pagination_max_id)) if records_continue?
end
Expand All @@ -73,12 +69,8 @@ def prev_path
api_v1_admin_domain_allows_url(pagination_params(min_id: pagination_since_id)) unless @domain_allows.empty?
end

def pagination_max_id
@domain_allows.last.id
end

def pagination_since_id
@domain_allows.first.id
def pagination_collection
@domain_allows
end

def records_continue?
Expand Down
Loading

0 comments on commit eb9f576

Please sign in to comment.