Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into combofeeds
Browse files Browse the repository at this point in the history
  • Loading branch information
jakkarth committed Mar 15, 2024
2 parents 4c34868 + b834f41 commit 3187774
Show file tree
Hide file tree
Showing 525 changed files with 9,484 additions and 4,270 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module.exports = defineConfig({
'react/react-in-jsx-scope': 'off', // not needed with new JSX transform
'react/self-closing-comp': 'error',

// recommended values found in https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/index.js
// recommended values found in https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/v6.8.0/src/index.js#L46
'jsx-a11y/accessible-emoji': 'warn',
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/label-has-associated-control': 'off',
Expand Down Expand Up @@ -176,7 +176,7 @@ module.exports = defineConfig({
},
],

// See https://github.com/import-js/eslint-plugin-import/blob/main/config/recommended.js
// See https://github.com/import-js/eslint-plugin-import/blob/v2.29.1/config/recommended.js
'import/extensions': [
'error',
'always',
Expand Down
4 changes: 2 additions & 2 deletions 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 All @@ -29,7 +29,7 @@ ARG MASTODON_VERSION_METADATA=""
# See: https://docs.joinmastodon.org/admin/config/#rails_serve_static_files
ARG RAILS_SERVE_STATIC_FILES="true"
# Allow to use YJIT compiler
# See: https://github.com/ruby/ruby/blob/master/doc/yjit/yjit.md
# See: https://github.com/ruby/ruby/blob/v3_2_3/doc/yjit/yjit.md
ARG RUBY_YJIT_ENABLE="1"
# Timezone used by the Docker container and runtime, change with [--build-arg TZ=Europe/Berlin]
ARG TZ="Etc/UTC"
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
13 changes: 7 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,11 @@ GEM
statsd-ruby (~> 1.4, >= 1.4.0)
oj (3.16.3)
bigdecimal (>= 3.0)
omniauth (2.1.1)
omniauth (2.1.2)
hashie (>= 3.4.6)
rack (>= 2.2.3)
rack-protection
omniauth-cas (3.0.0.beta.1)
omniauth-cas (3.0.0)
addressable (~> 2.8)
nokogiri (~> 1.12)
omniauth (~> 2.1)
Expand Down Expand Up @@ -505,7 +505,7 @@ GEM
parslet (2.0.0)
pastel (0.8.0)
tty-color (~> 0.5)
pg (1.5.5)
pg (1.5.6)
pghero (3.4.1)
activerecord (>= 6)
posix-spawn (0.3.15)
Expand Down Expand Up @@ -543,8 +543,9 @@ GEM
httpclient
json-jwt (>= 1.11.0)
rack (>= 2.1.0)
rack-protection (3.0.5)
rack
rack-protection (3.2.0)
base64 (>= 0.1.0)
rack (~> 2.2, >= 2.2.4)
rack-proxy (0.7.6)
rack
rack-session (1.0.2)
Expand Down Expand Up @@ -743,7 +744,7 @@ GEM
unicode-display_width (>= 1.1.1, < 3)
terrapin (1.0.1)
climate_control
test-prof (1.3.1)
test-prof (1.3.2)
thor (1.3.1)
tilt (2.3.0)
timeout (0.4.1)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/rules_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def set_rule
end

def resource_params
params.require(:rule).permit(:text, :priority)
params.require(:rule).permit(:text, :hint, :priority)
end
end
end
54 changes: 9 additions & 45 deletions app/controllers/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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 @@ -19,51 +20,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 @@ -74,6 +30,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
8 changes: 2 additions & 6 deletions app/controllers/api/v1/accounts/statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,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
8 changes: 2 additions & 6 deletions app/controllers/api/v1/admin/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,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
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,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
8 changes: 2 additions & 6 deletions app/controllers/api/v1/admin/domain_allows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,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
8 changes: 2 additions & 6 deletions app/controllers/api/v1/admin/domain_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,8 @@ def prev_path
api_v1_admin_domain_blocks_url(pagination_params(min_id: pagination_since_id)) unless @domain_blocks.empty?
end

def pagination_max_id
@domain_blocks.last.id
end

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

def records_continue?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,8 @@ def prev_path
api_v1_admin_email_domain_blocks_url(pagination_params(min_id: pagination_since_id)) unless @email_domain_blocks.empty?
end

def pagination_max_id
@email_domain_blocks.last.id
end

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

def records_continue?
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/api/v1/admin/ip_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,8 @@ def prev_path
api_v1_admin_ip_blocks_url(pagination_params(min_id: pagination_since_id)) unless @ip_blocks.empty?
end

def pagination_max_id
@ip_blocks.last.id
end

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

def records_continue?
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/api/v1/admin/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,8 @@ def prev_path
api_v1_admin_reports_url(pagination_params(min_id: pagination_since_id)) unless @reports.empty?
end

def pagination_max_id
@reports.last.id
end

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

def records_continue?
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/api/v1/admin/tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@ def prev_path
api_v1_admin_tags_url(pagination_params(min_id: pagination_since_id)) unless @tags.empty?
end

def pagination_max_id
@tags.last.id
end

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

def records_continue?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ def prev_path
api_v1_admin_trends_links_preview_card_providers_url(pagination_params(min_id: pagination_since_id)) unless @providers.empty?
end

def pagination_max_id
@providers.last.id
end

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

def records_continue?
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/api/v1/blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ def prev_path
api_v1_blocks_url pagination_params(since_id: pagination_since_id) unless paginated_blocks.empty?
end

def pagination_max_id
paginated_blocks.last.id
end

def pagination_since_id
paginated_blocks.first.id
def pagination_collection
paginated_blocks
end

def records_continue?
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/api/v1/bookmarks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ def prev_path
api_v1_bookmarks_url pagination_params(min_id: pagination_since_id) unless results.empty?
end

def pagination_max_id
results.last.id
end

def pagination_since_id
results.first.id
def pagination_collection
results
end

def records_continue?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,8 @@ def prev_path
api_v1_crypto_encrypted_messages_url pagination_params(min_id: pagination_since_id) unless @encrypted_messages.empty?
end

def pagination_max_id
@encrypted_messages.last.id
end

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

def records_continue?
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/api/v1/domain_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,8 @@ def prev_path
api_v1_domain_blocks_url pagination_params(since_id: pagination_since_id) unless @blocks.empty?
end

def pagination_max_id
@blocks.last.id
end

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

def records_continue?
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/api/v1/endorsements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ def prev_path
api_v1_endorsements_url pagination_params(since_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
Loading

0 comments on commit 3187774

Please sign in to comment.