Skip to content

Commit

Permalink
Merge branch 'main' into temp2_for-taruntarun
Browse files Browse the repository at this point in the history
  • Loading branch information
mayaeh committed Apr 4, 2024
2 parents 232dbb2 + c6da3ee commit 6d020e0
Show file tree
Hide file tree
Showing 71 changed files with 993 additions and 449 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ module.exports = defineConfig({
"message": "Use typed hooks `useAppDispatch` and `useAppSelector` instead."
}
],
"@typescript-eslint/restrict-template-expressions": ['warn', { allowNumber: true }],
'jsdoc/require-jsdoc': 'off',

// Those rules set stricter rules for TS files
Expand Down
2 changes: 1 addition & 1 deletion .haml-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ linters:
MiddleDot:
enabled: true
LineLength:
max: 320
max: 300
ViewLength:
max: 200 # Override default value of 100 inherited from rubocop
12 changes: 6 additions & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Layout/FirstHashElementIndentation:
# Reason: Currently disabled in .rubocop_todo.yml
# https://docs.rubocop.org/rubocop/cops_layout.html#layoutlinelength
Layout/LineLength:
Max: 320 # Default of 120 causes a duplicate entry in generated todo file
Max: 300 # Default of 120 causes a duplicate entry in generated todo file

## Disable most Metrics/*Length cops
# Reason: those are often triggered and force significant refactors when this happend
Expand Down Expand Up @@ -142,11 +142,6 @@ RSpec/NamedSubject:
RSpec/NotToNot:
EnforcedStyle: to_not

# Reason: Prevailing style uses numeric status codes, matches Rails/HttpStatus
# https://docs.rubocop.org/rubocop-rspec/cops_rspec_rails.html#rspecrailshttpstatus
RSpec/Rails/HttpStatus:
EnforcedStyle: numeric

# Reason: Match overrides from Rspec/FilePath rule above
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecspecfilepathformat
RSpec/SpecFilePathFormat:
Expand All @@ -157,6 +152,11 @@ RSpec/SpecFilePathFormat:
OEmbedController: oembed_controller
OStatus: ostatus

# Reason: Prevailing style uses numeric status codes, matches Rails/HttpStatus
# https://docs.rubocop.org/rubocop-rspec/cops_rspec_rails.html#rspecrailshttpstatus
RSpecRails/HttpStatus:
EnforcedStyle: numeric

# Reason:
# https://docs.rubocop.org/rubocop/cops_style.html#styleclassandmodulechildren
Style/ClassAndModuleChildren:
Expand Down
6 changes: 2 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.60.2.
# using RuboCop version 1.62.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -36,7 +36,7 @@ Metrics/PerceivedComplexity:

# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 20 # Override default of 5
Max: 18

RSpec/MultipleExpectations:
Max: 7
Expand Down Expand Up @@ -88,7 +88,6 @@ Style/FetchEnvVar:
Exclude:
- 'app/lib/redis_configuration.rb'
- 'app/lib/translation_service.rb'
- 'config/environments/development.rb'
- 'config/environments/production.rb'
- 'config/initializers/2_limited_federation_mode.rb'
- 'config/initializers/3_omniauth.rb'
Expand Down Expand Up @@ -144,7 +143,6 @@ Style/GuardClause:
- 'lib/mastodon/cli/accounts.rb'
- 'lib/mastodon/cli/maintenance.rb'
- 'lib/mastodon/cli/media.rb'
- 'lib/paperclip/attachment_extensions.rb'
- 'lib/tasks/repo.rake'

# This cop supports safe autocorrection (--autocorrect).
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1.4
# syntax=docker/dockerfile:1.7

# Please see https://docs.docker.com/engine/reference/builder for information about
# the extended buildx capabilities used in this file.
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ gem 'nsa'
gem 'oj', '~> 3.14'
gem 'ox', '~> 2.14'
gem 'parslet'
gem 'posix-spawn'
gem 'public_suffix', '~> 5.0'
gem 'pundit', '~> 2.3'
gem 'premailer-rails'
Expand All @@ -89,7 +88,7 @@ gem 'sidekiq-unique-jobs', '~> 7.1'
gem 'sidekiq-bulk', '~> 0.2.0'
gem 'simple-navigation', '~> 4.4'
gem 'simple_form', '~> 5.2'
gem 'stoplight', '~> 3.0.1'
gem 'stoplight', '~> 4.1'
gem 'strong_migrations', '1.8.0'
gem 'tty-prompt', '~> 0.23', require: false
gem 'twitter-text', '~> 3.1.0'
Expand Down
31 changes: 16 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ GEM
awrence (1.2.1)
aws-eventstream (1.3.0)
aws-partitions (1.899.0)
aws-sdk-core (3.191.4)
aws-sdk-core (3.191.5)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.78.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.146.0)
aws-sdk-s3 (1.146.1)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
Expand Down Expand Up @@ -245,7 +245,7 @@ GEM
tzinfo
excon (0.110.0)
fabrication (2.31.0)
faker (3.3.0)
faker (3.3.1)
i18n (>= 1.8.11, < 2)
faraday (1.10.3)
faraday-em_http (~> 1.0)
Expand Down Expand Up @@ -273,7 +273,7 @@ GEM
faraday_middleware (1.2.0)
faraday (~> 1.0)
fast_blank (1.0.1)
fastimage (2.3.0)
fastimage (2.3.1)
ffi (1.16.3)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
Expand Down Expand Up @@ -398,8 +398,8 @@ GEM
language_server-protocol (3.17.0.3)
launchy (2.5.2)
addressable (~> 2.8)
letter_opener (1.8.1)
launchy (>= 2.2, < 3)
letter_opener (1.10.0)
launchy (>= 2.2, < 4)
letter_opener_web (2.0.0)
actionmailer (>= 5.2)
letter_opener (~> 1.7)
Expand Down Expand Up @@ -509,7 +509,6 @@ GEM
pg (1.5.6)
pghero (3.4.1)
activerecord (>= 6)
posix-spawn (0.3.15)
premailer (1.23.0)
addressable
css_parser (>= 1.12.0)
Expand All @@ -526,7 +525,7 @@ GEM
railties (>= 7.0.0)
psych (5.1.2)
stringio
public_suffix (5.0.4)
public_suffix (5.0.5)
puma (6.4.2)
nio4r (~> 2.0)
pundit (2.3.1)
Expand Down Expand Up @@ -666,18 +665,21 @@ GEM
rubocop (~> 1.41)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-performance (1.20.2)
rubocop-performance (1.21.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.24.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (2.27.1)
rubocop-rspec (2.28.0)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-rspec_rails (~> 2.28)
rubocop-rspec_rails (2.28.2)
rubocop (~> 1.40)
ruby-prof (1.7.0)
ruby-progressbar (1.13.0)
ruby-saml (1.15.0)
Expand All @@ -695,7 +697,7 @@ GEM
scenic (1.7.0)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
selenium-webdriver (4.18.1)
selenium-webdriver (4.19.0)
base64 (~> 0.2)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
Expand Down Expand Up @@ -732,7 +734,7 @@ GEM
smart_properties (1.17.0)
stackprof (0.2.26)
statsd-ruby (1.5.0)
stoplight (3.0.2)
stoplight (4.1.0)
redlock (~> 1.0)
stringio (3.1.0)
strong_migrations (1.8.0)
Expand Down Expand Up @@ -898,7 +900,6 @@ DEPENDENCIES
parslet
pg (~> 1.5)
pghero
posix-spawn
premailer-rails
private_address_check (~> 0.5)
propshaft
Expand Down Expand Up @@ -941,7 +942,7 @@ DEPENDENCIES
simplecov (~> 0.22)
simplecov-lcov (~> 0.8)
stackprof
stoplight (~> 3.0.1)
stoplight (~> 4.1)
strong_migrations (= 1.8.0)
test-prof
thor (~> 1.2)
Expand Down
11 changes: 5 additions & 6 deletions app/controllers/concerns/signature_verification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def signed_request_actor
compare_signed_string = build_signed_string(include_query_string: false)
return actor unless verify_signature(actor, signature, compare_signed_string).nil?

actor = stoplight_wrap_request { actor_refresh_key!(actor) }
actor = stoplight_wrapper.run { actor_refresh_key!(actor) }

raise SignatureVerificationError, "Could not refresh public key #{signature_params['keyId']}" if actor.nil?

Expand Down Expand Up @@ -226,10 +226,10 @@ def actor_from_key_id(key_id)
end

if key_id.start_with?('acct:')
stoplight_wrap_request { ResolveAccountService.new.call(key_id.delete_prefix('acct:'), suppress_errors: false) }
stoplight_wrapper.run { ResolveAccountService.new.call(key_id.delete_prefix('acct:'), suppress_errors: false) }
elsif !ActivityPub::TagManager.instance.local_uri?(key_id)
account = ActivityPub::TagManager.instance.uri_to_actor(key_id)
account ||= stoplight_wrap_request { ActivityPub::FetchRemoteKeyService.new.call(key_id, suppress_errors: false) }
account ||= stoplight_wrapper.run { ActivityPub::FetchRemoteKeyService.new.call(key_id, suppress_errors: false) }
account
end
rescue Mastodon::PrivateNetworkAddressError => e
Expand All @@ -238,12 +238,11 @@ def actor_from_key_id(key_id)
raise SignatureVerificationError, e.message
end

def stoplight_wrap_request(&block)
Stoplight("source:#{request.remote_ip}", &block)
def stoplight_wrapper
Stoplight("source:#{request.remote_ip}")
.with_threshold(1)
.with_cool_off_time(5.minutes.seconds)
.with_error_handler { |error, handle| error.is_a?(HTTP::Error) || error.is_a?(OpenSSL::SSL::SSLError) ? handle.call(error) : raise(error) }
.run
end

def actor_refresh_key!(actor)
Expand Down
22 changes: 22 additions & 0 deletions app/javascript/mastodon/api_types/media_attachments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// See app/serializers/rest/media_attachment_serializer.rb

export type MediaAttachmentType =
| 'image'
| 'gifv'
| 'video'
| 'unknown'
| 'audio';

export interface ApiMediaAttachmentJSON {
id: string;
type: MediaAttachmentType;
url: string;
preview_url: string;
remoteUrl: string;
preview_remote_url: string;
text_url: string;
// TODO: how to define this?
meta: unknown;
description?: string;
blurhash: string;
}
23 changes: 23 additions & 0 deletions app/javascript/mastodon/api_types/polls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { ApiCustomEmojiJSON } from './custom_emoji';

// See app/serializers/rest/poll_serializer.rb

export interface ApiPollOptionJSON {
title: string;
votes_count: number;
}

export interface ApiPollJSON {
id: string;
expires_at: string;
expired: boolean;
multiple: boolean;
votes_count: number;
voters_count: number;

options: ApiPollOptionJSON[];
emojis: ApiCustomEmojiJSON[];

voted: boolean;
own_votes: number[];
}
Loading

0 comments on commit 6d020e0

Please sign in to comment.