From 0c9eac80d887cdf7f1efa582b21006248d2f83eb Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 10 Feb 2023 22:16:37 +0100 Subject: Fix unbounded recursion in post discovery (#23506) * Add a limit to how many posts can get fetched as a result of a single request * Add tests * Always pass `request_id` when processing `Announce` activities --------- Co-authored-by: nametoolong --- app/services/activitypub/fetch_replies_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/services/activitypub/fetch_replies_service.rb') diff --git a/app/services/activitypub/fetch_replies_service.rb b/app/services/activitypub/fetch_replies_service.rb index 8cb309e52..18a27e851 100644 --- a/app/services/activitypub/fetch_replies_service.rb +++ b/app/services/activitypub/fetch_replies_service.rb @@ -3,14 +3,14 @@ class ActivityPub::FetchRepliesService < BaseService include JsonLdHelper - def call(parent_status, collection_or_uri, allow_synchronous_requests = true) + def call(parent_status, collection_or_uri, allow_synchronous_requests: true, request_id: nil) @account = parent_status.account @allow_synchronous_requests = allow_synchronous_requests @items = collection_items(collection_or_uri) return if @items.nil? - FetchReplyWorker.push_bulk(filtered_replies) + FetchReplyWorker.push_bulk(filtered_replies) { |reply_uri| [reply_uri, { 'request_id' => request_id}] } @items end -- cgit From 669f6d2c0af969268c76e389ed626bce0cc9f998 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 17 Feb 2023 16:56:20 -0500 Subject: Run rubocop formatting except line length (#23632) --- .rubocop_todo.yml | 277 +-------------------- app/lib/activitypub/activity/create.rb | 4 +- app/models/concerns/expireable.rb | 2 +- app/services/activitypub/fetch_replies_service.rb | 2 +- .../20161006213403_rails_settings_migration.rb | 10 +- ...uses_for_api_v1_accounts_account_id_statuses.rb | 8 +- .../20190306145741_add_lock_version_to_polls.rb | 1 - ...20190807135426_add_comments_to_domain_blocks.rb | 1 - ...200312162302_add_status_ids_to_announcements.rb | 1 - ...00510181721_remove_duplicated_indexes_pghero.rb | 1 - db/migrate/20200628133322_create_account_notes.rb | 1 - ...340_create_account_statuses_cleanup_policies.rb | 1 - ...0729171123_fix_custom_filter_keywords_id_seq.rb | 2 +- lib/paperclip/attachment_extensions.rb | 10 +- lib/tasks/mastodon.rake | 4 +- spec/config/initializers/rack_attack_spec.rb | 10 +- .../controllers/admin/dashboard_controller_spec.rb | 8 +- .../api/v1/accounts/credentials_controller_spec.rb | 2 +- spec/controllers/api/v1/reports_controller_spec.rb | 2 +- .../favourited_by_accounts_controller_spec.rb | 2 +- .../reblogged_by_accounts_controller_spec.rb | 2 +- .../api/v2/filters/statuses_controller_spec.rb | 4 +- spec/controllers/auth/sessions_controller_spec.rb | 6 +- .../authorize_interactions_controller_spec.rb | 1 - .../settings/applications_controller_spec.rb | 2 +- .../confirmations_controller_spec.rb | 1 - .../webauthn_credentials_controller_spec.rb | 2 +- .../well_known/host_meta_controller_spec.rb | 12 +- .../custom_filter_keyword_fabricator.rb | 2 +- spec/fabricators/ip_block_fabricator.rb | 2 +- spec/fabricators/poll_vote_fabricator.rb | 2 +- spec/fabricators/status_edit_fabricator.rb | 2 +- spec/fabricators/system_key_fabricator.rb | 1 - spec/lib/activitypub/activity/create_spec.rb | 1 - spec/lib/extractor_spec.rb | 8 +- spec/lib/fast_ip_map_spec.rb | 2 +- spec/lib/link_details_extractor_spec.rb | 124 ++++----- spec/models/account/field_spec.rb | 4 +- spec/models/account_alias_spec.rb | 1 - .../models/account_statuses_cleanup_policy_spec.rb | 40 ++- spec/models/concerns/account_interactions_spec.rb | 2 +- spec/models/device_spec.rb | 1 - spec/models/encrypted_message_spec.rb | 1 - spec/models/export_spec.rb | 2 +- spec/models/login_activity_spec.rb | 1 - spec/models/one_time_key_spec.rb | 1 - spec/models/system_key_spec.rb | 1 - spec/models/trends/statuses_spec.rb | 2 +- spec/models/user_role_spec.rb | 2 +- spec/routing/api_routing_spec.rb | 72 +++--- spec/routing/well_known_routes_spec.rb | 8 +- spec/serializers/rest/account_serializer_spec.rb | 2 +- .../account_statuses_cleanup_service_spec.rb | 4 +- .../fetch_remote_status_service_spec.rb | 2 +- .../activitypub/process_account_service_spec.rb | 4 +- .../activitypub/process_collection_service_spec.rb | 12 +- .../process_status_update_service_spec.rb | 42 ++-- spec/services/bootstrap_timeline_service_spec.rb | 1 - spec/services/fetch_oembed_service_spec.rb | 1 - spec/services/import_service_spec.rb | 4 +- spec/services/remove_from_follwers_service_spec.rb | 2 +- spec/services/remove_status_service_spec.rb | 68 ++--- spec/services/resolve_account_service_spec.rb | 2 +- spec/services/resolve_url_service_spec.rb | 2 +- spec/services/update_status_service_spec.rb | 2 +- spec/support/stories/profile_stories.rb | 4 +- spec/validators/note_length_validator_spec.rb | 4 +- .../unreserved_username_validator_spec.rb | 6 +- .../activitypub/distribution_worker_spec.rb | 2 +- .../activitypub/move_distribution_worker_spec.rb | 8 +- .../accounts_statuses_cleanup_scheduler_spec.rb | 2 +- 71 files changed, 269 insertions(+), 566 deletions(-) (limited to 'app/services/activitypub/fetch_replies_service.rb') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e3a42da5b..e24ce7e32 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit` -# on 2023-02-16 04:55:24 UTC using RuboCop version 1.45.1. +# on 2023-02-16 05:53:07 UTC using RuboCop version 1.45.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 @@ -14,53 +14,6 @@ Bundler/OrderedGems: Exclude: - 'Gemfile' -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_argument, with_fixed_indentation -Layout/ArgumentAlignment: - Exclude: - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith. -# SupportedStylesAlignWith: either, start_of_block, start_of_line -Layout/BlockAlignment: - Exclude: - - 'spec/controllers/api/v1/accounts/credentials_controller_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/ClosingParenthesisIndentation: - Exclude: - - 'spec/controllers/auth/sessions_controller_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/CommentIndentation: - Exclude: - - 'db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb' - -# Offense count: 22 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: leading, trailing -Layout/DotPosition: - Exclude: - - 'lib/paperclip/attachment_extensions.rb' - - 'spec/routing/api_routing_spec.rb' - - 'spec/routing/well_known_routes_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/ElseAlignment: - Exclude: - - 'db/migrate/20161006213403_rails_settings_migration.rb' - # Offense count: 81 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLineAfterGuardClause: @@ -183,73 +136,6 @@ Layout/EmptyLineAfterMagicComment: - 'spec/controllers/api/v1/accounts/statuses_controller_spec.rb' - 'spec/models/tag_spec.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLines: - Exclude: - - 'spec/controllers/authorize_interactions_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb' - - 'spec/lib/activitypub/activity/create_spec.rb' - -# Offense count: 9 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Exclude: - - 'spec/fabricators/system_key_fabricator.rb' - - 'spec/models/account_alias_spec.rb' - - 'spec/models/device_spec.rb' - - 'spec/models/encrypted_message_spec.rb' - - 'spec/models/login_activity_spec.rb' - - 'spec/models/one_time_key_spec.rb' - - 'spec/models/system_key_spec.rb' - - 'spec/services/bootstrap_timeline_service_spec.rb' - - 'spec/services/fetch_oembed_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith, Severity. -# SupportedStylesAlignWith: keyword, variable, start_of_line -Layout/EndAlignment: - Exclude: - - 'db/migrate/20161006213403_rails_settings_migration.rb' - -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'spec/config/initializers/rack_attack_spec.rb' - - 'spec/controllers/api/v2/filters/statuses_controller_spec.rb' - - 'spec/fabricators/custom_filter_keyword_fabricator.rb' - - 'spec/fabricators/poll_vote_fabricator.rb' - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - - 'spec/services/import_service_spec.rb' - - 'spec/services/resolve_account_service_spec.rb' - - 'spec/services/resolve_url_service_spec.rb' - - 'spec/validators/note_length_validator_spec.rb' - - 'spec/validators/unreserved_username_validator_spec.rb' - - 'spec/workers/activitypub/move_distribution_worker_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstArgumentIndentation: - Exclude: - - 'spec/services/remove_status_service_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/FirstArrayElementIndentation: - Exclude: - - 'spec/controllers/admin/dashboard_controller_spec.rb' - - 'spec/workers/activitypub/move_distribution_worker_spec.rb' - # Offense count: 113 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. @@ -276,49 +162,6 @@ Layout/HashAlignment: - 'spec/models/admin/account_action_spec.rb' - 'spec/models/concerns/account_interactions_spec.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Layout/HeredocIndentation: - Exclude: - - 'spec/controllers/well_known/host_meta_controller_spec.rb' - - 'spec/lib/link_details_extractor_spec.rb' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: normal, indented_internal_methods -Layout/IndentationConsistency: - Exclude: - - 'spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb' - - 'spec/models/trends/statuses_spec.rb' - - 'spec/services/import_service_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Width, AllowedPatterns. -Layout/IndentationWidth: - Exclude: - - 'db/migrate/20161006213403_rails_settings_migration.rb' - - 'spec/controllers/api/v1/accounts/credentials_controller_spec.rb' - - 'spec/services/account_statuses_cleanup_service_spec.rb' - - 'spec/services/import_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. -Layout/LeadingCommentSpace: - Exclude: - - 'lib/paperclip/attachment_extensions.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, EnforcedStyle. -# SupportedStyles: space, no_space -Layout/LineContinuationSpacing: - Exclude: - - 'spec/support/stories/profile_stories.rb' - # Offense count: 577 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. @@ -326,124 +169,6 @@ Layout/LineContinuationSpacing: Layout/LineLength: Enabled: false -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Exclude: - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. -# SupportedStylesForExponentOperator: space, no_space -Layout/SpaceAroundOperators: - Exclude: - - 'spec/services/activitypub/fetch_remote_status_service_spec.rb' - - 'spec/validators/note_length_validator_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceBeforeBlockBraces: - Exclude: - - 'spec/controllers/api/v1/reports_controller_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/SpaceBeforeFirstArg: - Exclude: - - 'spec/fabricators/custom_filter_keyword_fabricator.rb' - - 'spec/fabricators/poll_vote_fabricator.rb' - - 'spec/models/concerns/account_interactions_spec.rb' - -# Offense count: 24 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBrackets: space, no_space -Layout/SpaceInsideArrayLiteralBrackets: - Exclude: - - 'db/migrate/20161006213403_rails_settings_migration.rb' - - 'spec/controllers/settings/applications_controller_spec.rb' - - 'spec/lib/extractor_spec.rb' - - 'spec/models/export_spec.rb' - - 'spec/services/activitypub/process_account_service_spec.rb' - - 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Exclude: - - 'spec/lib/fast_ip_map_spec.rb' - - 'spec/models/user_role_spec.rb' - - 'spec/serializers/rest/account_serializer_spec.rb' - - 'spec/workers/activitypub/distribution_worker_spec.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Exclude: - - 'app/lib/activitypub/activity/create.rb' - - 'app/services/activitypub/fetch_replies_service.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - - 'spec/services/update_status_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, compact, no_space -Layout/SpaceInsideParens: - Exclude: - - 'spec/validators/unreserved_username_validator_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceInsideStringInterpolation: - Exclude: - - 'spec/controllers/auth/sessions_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb' - - 'spec/services/activitypub/process_account_service_spec.rb' - -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: final_newline, final_blank_line -Layout/TrailingEmptyLines: - Exclude: - - 'db/migrate/20190306145741_add_lock_version_to_polls.rb' - - 'db/migrate/20190807135426_add_comments_to_domain_blocks.rb' - - 'db/migrate/20200312162302_add_status_ids_to_announcements.rb' - - 'db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb' - - 'db/migrate/20200628133322_create_account_notes.rb' - - 'db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb' - - 'spec/fabricators/ip_block_fabricator.rb' - - 'spec/fabricators/status_edit_fabricator.rb' - -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Exclude: - - 'app/models/concerns/expireable.rb' - - 'db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb' - - 'lib/tasks/mastodon.rake' - - 'spec/models/account/field_spec.rb' - - 'spec/services/remove_from_follwers_service_spec.rb' - # Offense count: 14 # Configuration parameters: AllowedMethods, AllowedPatterns. Lint/AmbiguousBlockAssociation: diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 487b65223..f82112c02 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -327,7 +327,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity def resolve_thread(status) return unless status.reply? && status.thread.nil? && Request.valid_url?(in_reply_to_uri) - ThreadResolveWorker.perform_async(status.id, in_reply_to_uri, { 'request_id' => @options[:request_id]}) + ThreadResolveWorker.perform_async(status.id, in_reply_to_uri, { 'request_id' => @options[:request_id] }) end def fetch_replies(status) @@ -338,7 +338,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity return unless replies.nil? uri = value_or_id(collection) - ActivityPub::FetchRepliesWorker.perform_async(status.id, uri, { 'request_id' => @options[:request_id]}) unless uri.nil? + ActivityPub::FetchRepliesWorker.perform_async(status.id, uri, { 'request_id' => @options[:request_id] }) unless uri.nil? end def conversation_from_uri(uri) diff --git a/app/models/concerns/expireable.rb b/app/models/concerns/expireable.rb index 4d902abcb..c64fc7d80 100644 --- a/app/models/concerns/expireable.rb +++ b/app/models/concerns/expireable.rb @@ -17,7 +17,7 @@ module Expireable end def expires_in=(interval) - self.expires_at = interval.present? ? interval.to_i.seconds.from_now : nil + self.expires_at = interval.present? ? interval.to_i.seconds.from_now : nil @expires_in = interval end diff --git a/app/services/activitypub/fetch_replies_service.rb b/app/services/activitypub/fetch_replies_service.rb index 18a27e851..4128df9ca 100644 --- a/app/services/activitypub/fetch_replies_service.rb +++ b/app/services/activitypub/fetch_replies_service.rb @@ -10,7 +10,7 @@ class ActivityPub::FetchRepliesService < BaseService @items = collection_items(collection_or_uri) return if @items.nil? - FetchReplyWorker.push_bulk(filtered_replies) { |reply_uri| [reply_uri, { 'request_id' => request_id}] } + FetchReplyWorker.push_bulk(filtered_replies) { |reply_uri| [reply_uri, { 'request_id' => request_id }] } @items end diff --git a/db/migrate/20161006213403_rails_settings_migration.rb b/db/migrate/20161006213403_rails_settings_migration.rb index 9d565cb5c..02932610c 100644 --- a/db/migrate/20161006213403_rails_settings_migration.rb +++ b/db/migrate/20161006213403_rails_settings_migration.rb @@ -1,8 +1,8 @@ MIGRATION_BASE_CLASS = if ActiveRecord::VERSION::MAJOR >= 5 - ActiveRecord::Migration[5.0] -else - ActiveRecord::Migration[4.2] -end + ActiveRecord::Migration[5.0] + else + ActiveRecord::Migration[4.2] + end class RailsSettingsMigration < MIGRATION_BASE_CLASS def self.up @@ -12,7 +12,7 @@ class RailsSettingsMigration < MIGRATION_BASE_CLASS t.references :target, null: false, polymorphic: true, index: { name: 'index_settings_on_target_type_and_target_id' } t.timestamps null: true end - add_index :settings, [ :target_type, :target_id, :var ], unique: true + add_index :settings, [:target_type, :target_id, :var], unique: true end def self.down diff --git a/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb index b29e62803..a3f883fcb 100644 --- a/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb +++ b/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb @@ -4,9 +4,9 @@ class ImproveIndexOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord::Mi disable_ddl_transaction! def change - # These changes ware reverted by migration 20180514140000. - # add_index :statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently - # add_index :statuses, [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently - # remove_index :statuses, column: [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 + # These changes ware reverted by migration 20180514140000. + # add_index :statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently + # add_index :statuses, [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently + # remove_index :statuses, column: [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 end end diff --git a/db/migrate/20190306145741_add_lock_version_to_polls.rb b/db/migrate/20190306145741_add_lock_version_to_polls.rb index 5bb8cd3b4..c9fa471ad 100644 --- a/db/migrate/20190306145741_add_lock_version_to_polls.rb +++ b/db/migrate/20190306145741_add_lock_version_to_polls.rb @@ -21,4 +21,3 @@ class AddLockVersionToPolls < ActiveRecord::Migration[5.2] remove_column :polls, :lock_version end end - diff --git a/db/migrate/20190807135426_add_comments_to_domain_blocks.rb b/db/migrate/20190807135426_add_comments_to_domain_blocks.rb index b660a71ad..79b9f0212 100644 --- a/db/migrate/20190807135426_add_comments_to_domain_blocks.rb +++ b/db/migrate/20190807135426_add_comments_to_domain_blocks.rb @@ -4,4 +4,3 @@ class AddCommentsToDomainBlocks < ActiveRecord::Migration[5.2] add_column :domain_blocks, :public_comment, :text end end - diff --git a/db/migrate/20200312162302_add_status_ids_to_announcements.rb b/db/migrate/20200312162302_add_status_ids_to_announcements.rb index 42aa6513d..704d3773e 100644 --- a/db/migrate/20200312162302_add_status_ids_to_announcements.rb +++ b/db/migrate/20200312162302_add_status_ids_to_announcements.rb @@ -3,4 +3,3 @@ class AddStatusIdsToAnnouncements < ActiveRecord::Migration[5.2] add_column :announcements, :status_ids, :bigint, array: true end end - diff --git a/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb b/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb index 1d6ba1fe9..59bb1b9e2 100644 --- a/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb +++ b/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb @@ -19,4 +19,3 @@ class RemoveDuplicatedIndexesPghero < ActiveRecord::Migration[5.2] add_index :markers, :user_id, name: :index_markers_on_user_id unless index_exists?(:markers, :user_id, name: :index_markers_on_user_id) end end - diff --git a/db/migrate/20200628133322_create_account_notes.rb b/db/migrate/20200628133322_create_account_notes.rb index 664727e60..022e0ff3a 100644 --- a/db/migrate/20200628133322_create_account_notes.rb +++ b/db/migrate/20200628133322_create_account_notes.rb @@ -10,4 +10,3 @@ class CreateAccountNotes < ActiveRecord::Migration[5.2] end end end - diff --git a/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb b/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb index 28cfb6ef5..db168676a 100644 --- a/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb +++ b/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb @@ -17,4 +17,3 @@ class CreateAccountStatusesCleanupPolicies < ActiveRecord::Migration[6.1] end end end - diff --git a/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb b/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb index 7ed34a3ef..eb437c86c 100644 --- a/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb +++ b/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb @@ -5,7 +5,7 @@ class FixCustomFilterKeywordsIdSeq < ActiveRecord::Migration[6.1] def up # 20220613110711 manually inserts items with set `id` in the database, but - # we also need to bump the sequence number, otherwise + # we also need to bump the sequence number, otherwise safety_assured do execute <<-SQL.squish BEGIN; diff --git a/lib/paperclip/attachment_extensions.rb b/lib/paperclip/attachment_extensions.rb index d66a17623..7f82138aa 100644 --- a/lib/paperclip/attachment_extensions.rb +++ b/lib/paperclip/attachment_extensions.rb @@ -8,7 +8,7 @@ module Paperclip # monkey-patch to avoid unlinking too avoid unlinking source file too early # see https://github.com/kreeti/kt-paperclip/issues/64 - def post_process_style(name, style) #:nodoc: + def post_process_style(name, style) # :nodoc: raise "Style #{name} has no processors defined." if style.processors.blank? intermediate_files = [] @@ -16,16 +16,16 @@ module Paperclip # if we're processing the original, close + unlink the source tempfile intermediate_files << original if name == :original - @queued_for_write[name] = style.processors. - inject(original) do |file, processor| + @queued_for_write[name] = style.processors + .inject(original) do |file, processor| file = Paperclip.processor(processor).make(file, style.processor_options, self) intermediate_files << file unless file == original file end unadapted_file = @queued_for_write[name] - @queued_for_write[name] = Paperclip.io_adapters. - for(@queued_for_write[name], @options[:adapter_options]) + @queued_for_write[name] = Paperclip.io_adapters + .for(@queued_for_write[name], @options[:adapter_options]) unadapted_file.close if unadapted_file.respond_to?(:close) @queued_for_write[name] rescue Paperclip::Errors::NotIdentifiedByImageMagickError => e diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 1184e5273..477daa01b 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -286,13 +286,13 @@ namespace :mastodon do q.required true q.modify :strip end - + linksharing_access_key = prompt.ask('Storj Linksharing access key (uplink share --register --public --readonly=true --disallow-lists --not-after=none sj://bucket):') do |q| q.required true q.modify :strip end env['S3_ALIAS_HOST'] = "link.storjshare.io/raw/#{linksharing_access_key}/#{env['S3_BUCKET']}" - + when 'Google Cloud Storage' env['S3_ENABLED'] = 'true' env['S3_PROTOCOL'] = 'https' diff --git a/spec/config/initializers/rack_attack_spec.rb b/spec/config/initializers/rack_attack_spec.rb index 581021cb9..03695f5fd 100644 --- a/spec/config/initializers/rack_attack_spec.rb +++ b/spec/config/initializers/rack_attack_spec.rb @@ -35,12 +35,12 @@ describe Rack::Attack do let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } } context 'for exact path' do - let(:path) { '/auth' } + let(:path) { '/auth' } it_behaves_like 'throttled endpoint' end context 'for path with format' do - let(:path) { '/auth.html' } + let(:path) { '/auth.html' } it_behaves_like 'throttled endpoint' end end @@ -50,7 +50,7 @@ describe Rack::Attack do let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } } context 'for exact path' do - let(:path) { '/api/v1/accounts' } + let(:path) { '/api/v1/accounts' } it_behaves_like 'throttled endpoint' end @@ -70,12 +70,12 @@ describe Rack::Attack do let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } } context 'for exact path' do - let(:path) { '/auth/sign_in' } + let(:path) { '/auth/sign_in' } it_behaves_like 'throttled endpoint' end context 'for path with format' do - let(:path) { '/auth/sign_in.html' } + let(:path) { '/auth/sign_in.html' } it_behaves_like 'throttled endpoint' end end diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb index 6231a09a2..ab3738fcd 100644 --- a/spec/controllers/admin/dashboard_controller_spec.rb +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -8,10 +8,10 @@ describe Admin::DashboardController, type: :controller do describe 'GET #index' do before do allow(Admin::SystemCheck).to receive(:perform).and_return([ - Admin::SystemCheck::Message.new(:database_schema_check), - Admin::SystemCheck::Message.new(:rules_check, nil, admin_rules_path), - Admin::SystemCheck::Message.new(:sidekiq_process_check, 'foo, bar'), - ]) + Admin::SystemCheck::Message.new(:database_schema_check), + Admin::SystemCheck::Message.new(:rules_check, nil, admin_rules_path), + Admin::SystemCheck::Message.new(:sidekiq_process_check, 'foo, bar'), + ]) sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')) end diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb index b2557d957..89cc8acad 100644 --- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb @@ -70,7 +70,7 @@ describe Api::V1::Accounts::CredentialsController do it 'returns http success' do expect(response).to have_http_status(200) end - end + end describe 'with invalid data' do before do diff --git a/spec/controllers/api/v1/reports_controller_spec.rb b/spec/controllers/api/v1/reports_controller_spec.rb index dbc64e704..78a72b95b 100644 --- a/spec/controllers/api/v1/reports_controller_spec.rb +++ b/spec/controllers/api/v1/reports_controller_spec.rb @@ -20,7 +20,7 @@ RSpec.describe Api::V1::ReportsController, type: :controller do let(:target_account) { status.account } let(:category) { nil } let(:forward) { nil } - let(:rule_ids){ nil } + let(:rule_ids) { nil } before do allow(AdminMailer).to receive(:new_report).and_return(double('email', deliver_later: nil)) diff --git a/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb b/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb index 7cc77f430..4dcaba6bd 100644 --- a/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :control it 'returns accounts who favorited the status' do get :index, params: { status_id: status.id, limit: 2 } expect(body_as_json.size).to eq 2 - expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s]) + expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s]) end it 'does not return blocked users' do diff --git a/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb b/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb index 8d4a6f91c..dc36d4ca0 100644 --- a/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controll it 'returns accounts who reblogged the status' do get :index, params: { status_id: status.id, limit: 2 } expect(body_as_json.size).to eq 2 - expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s]) + expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s]) end it 'does not return blocked users' do diff --git a/spec/controllers/api/v2/filters/statuses_controller_spec.rb b/spec/controllers/api/v2/filters/statuses_controller_spec.rb index 9740c1eb3..969b2ea73 100644 --- a/spec/controllers/api/v2/filters/statuses_controller_spec.rb +++ b/spec/controllers/api/v2/filters/statuses_controller_spec.rb @@ -64,7 +64,7 @@ RSpec.describe Api::V2::Filters::StatusesController, type: :controller do end describe 'GET #show' do - let(:scopes) { 'read:filters' } + let(:scopes) { 'read:filters' } let!(:status_filter) { Fabricate(:custom_filter_status, custom_filter: filter) } before do @@ -90,7 +90,7 @@ RSpec.describe Api::V2::Filters::StatusesController, type: :controller do end describe 'DELETE #destroy' do - let(:scopes) { 'write:filters' } + let(:scopes) { 'write:filters' } let(:status_filter) { Fabricate(:custom_filter_status, custom_filter: filter) } before do diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb index d3db7aa1a..64433ddf4 100644 --- a/spec/controllers/auth/sessions_controller_spec.rb +++ b/spec/controllers/auth/sessions_controller_spec.rb @@ -339,11 +339,11 @@ RSpec.describe Auth::SessionsController, type: :controller do external_id: public_key_credential.id, public_key: public_key_credential.public_key, sign_count: '1000' - ) + ) user.webauthn_credentials.take end - let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http' }://#{Rails.configuration.x.web_domain}" } + let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http'}://#{Rails.configuration.x.web_domain}" } let(:fake_client) { WebAuthn::FakeClient.new(domain) } @@ -400,7 +400,7 @@ RSpec.describe Auth::SessionsController, type: :controller do describe 'GET #webauthn_options' do context 'with WebAuthn and OTP enabled as second factor' do - let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http' }://#{Rails.configuration.x.web_domain}" } + let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http'}://#{Rails.configuration.x.web_domain}" } let(:fake_client) { WebAuthn::FakeClient.new(domain) } diff --git a/spec/controllers/authorize_interactions_controller_spec.rb b/spec/controllers/authorize_interactions_controller_spec.rb index 44f52df69..e52103941 100644 --- a/spec/controllers/authorize_interactions_controller_spec.rb +++ b/spec/controllers/authorize_interactions_controller_spec.rb @@ -99,7 +99,6 @@ describe AuthorizeInteractionsController do allow(ResolveAccountService).to receive(:new).and_return(service) allow(service).to receive(:call).with('user@hostname').and_return(target_account) - post :create, params: { acct: 'acct:user@hostname' } expect(account.following?(target_account)).to be true diff --git a/spec/controllers/settings/applications_controller_spec.rb b/spec/controllers/settings/applications_controller_spec.rb index 1292e9ff8..9074574e4 100644 --- a/spec/controllers/settings/applications_controller_spec.rb +++ b/spec/controllers/settings/applications_controller_spec.rb @@ -73,7 +73,7 @@ describe Settings::ApplicationsController do name: 'My New App', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', website: 'http://google.com', - scopes: [ 'read', 'write', 'follow' ] + scopes: ['read', 'write', 'follow'] } } response diff --git a/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb index 569c8322b..0b807b280 100644 --- a/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb @@ -5,7 +5,6 @@ require 'rails_helper' describe Settings::TwoFactorAuthentication::ConfirmationsController do render_views - shared_examples 'renders :new' do it 'renders the new view' do subject diff --git a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb index fe53b4dfc..06989ffd2 100644 --- a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb @@ -7,7 +7,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do render_views let(:user) { Fabricate(:user) } - let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http' }://#{Rails.configuration.x.web_domain}" } + let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http'}://#{Rails.configuration.x.web_domain}" } let(:fake_client) { WebAuthn::FakeClient.new(domain) } def add_webauthn_credential(user) diff --git a/spec/controllers/well_known/host_meta_controller_spec.rb b/spec/controllers/well_known/host_meta_controller_spec.rb index c02aa0d59..654bad406 100644 --- a/spec/controllers/well_known/host_meta_controller_spec.rb +++ b/spec/controllers/well_known/host_meta_controller_spec.rb @@ -9,12 +9,12 @@ describe WellKnown::HostMetaController, type: :controller do expect(response).to have_http_status(200) expect(response.media_type).to eq 'application/xrd+xml' - expect(response.body).to eq < - - - -XML + expect(response.body).to eq <<~XML + + + + + XML end end end diff --git a/spec/fabricators/custom_filter_keyword_fabricator.rb b/spec/fabricators/custom_filter_keyword_fabricator.rb index 0f101dcd1..201566cbe 100644 --- a/spec/fabricators/custom_filter_keyword_fabricator.rb +++ b/spec/fabricators/custom_filter_keyword_fabricator.rb @@ -1,4 +1,4 @@ Fabricator(:custom_filter_keyword) do custom_filter - keyword 'discourse' + keyword 'discourse' end diff --git a/spec/fabricators/ip_block_fabricator.rb b/spec/fabricators/ip_block_fabricator.rb index 31dc336e6..1797f6877 100644 --- a/spec/fabricators/ip_block_fabricator.rb +++ b/spec/fabricators/ip_block_fabricator.rb @@ -3,4 +3,4 @@ Fabricator(:ip_block) do severity "" expires_at "2020-10-08 22:20:37" comment "MyText" -end \ No newline at end of file +end diff --git a/spec/fabricators/poll_vote_fabricator.rb b/spec/fabricators/poll_vote_fabricator.rb index 51f9b006e..c06e61f67 100644 --- a/spec/fabricators/poll_vote_fabricator.rb +++ b/spec/fabricators/poll_vote_fabricator.rb @@ -1,5 +1,5 @@ Fabricator(:poll_vote) do account poll - choice 0 + choice 0 end diff --git a/spec/fabricators/status_edit_fabricator.rb b/spec/fabricators/status_edit_fabricator.rb index 21b793747..3141759e5 100644 --- a/spec/fabricators/status_edit_fabricator.rb +++ b/spec/fabricators/status_edit_fabricator.rb @@ -4,4 +4,4 @@ Fabricator(:status_edit) do text "MyText" spoiler_text "MyText" media_attachments_changed false -end \ No newline at end of file +end diff --git a/spec/fabricators/system_key_fabricator.rb b/spec/fabricators/system_key_fabricator.rb index f808495e0..c744bb286 100644 --- a/spec/fabricators/system_key_fabricator.rb +++ b/spec/fabricators/system_key_fabricator.rb @@ -1,3 +1,2 @@ Fabricator(:system_key) do - end diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index 1a25395fa..cd0f2df6e 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -408,7 +408,6 @@ RSpec.describe ActivityPub::Activity::Create do end end - context 'with media attachments with long description' do let(:object_json) do { diff --git a/spec/lib/extractor_spec.rb b/spec/lib/extractor_spec.rb index dba4bd0bb..9c9f5ef04 100644 --- a/spec/lib/extractor_spec.rb +++ b/spec/lib/extractor_spec.rb @@ -20,7 +20,7 @@ describe Extractor do text = '@screen_name' extracted = Extractor.extract_mentions_or_lists_with_indices(text) expect(extracted).to eq [ - { screen_name: 'screen_name', indices: [ 0, 12 ] } + { screen_name: 'screen_name', indices: [0, 12] } ] end @@ -44,19 +44,19 @@ describe Extractor do it 'does not exclude normal hash text before ://' do text = '#hashtag://' extracted = Extractor.extract_hashtags_with_indices(text) - expect(extracted).to eq [ { hashtag: 'hashtag', indices: [ 0, 8 ] } ] + expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }] end it 'excludes http://' do text = '#hashtaghttp://' extracted = Extractor.extract_hashtags_with_indices(text) - expect(extracted).to eq [ { hashtag: 'hashtag', indices: [ 0, 8 ] } ] + expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }] end it 'excludes https://' do text = '#hashtaghttps://' extracted = Extractor.extract_hashtags_with_indices(text) - expect(extracted).to eq [ { hashtag: 'hashtag', indices: [ 0, 8 ] } ] + expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }] end it 'yields hashtags if a block is given' do diff --git a/spec/lib/fast_ip_map_spec.rb b/spec/lib/fast_ip_map_spec.rb index c66f64828..78b3ddb05 100644 --- a/spec/lib/fast_ip_map_spec.rb +++ b/spec/lib/fast_ip_map_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' describe FastIpMap do describe '#include?' do - subject { described_class.new([IPAddr.new('20.4.0.0/16'), IPAddr.new('145.22.30.0/24'), IPAddr.new('189.45.86.3')])} + subject { described_class.new([IPAddr.new('20.4.0.0/16'), IPAddr.new('145.22.30.0/24'), IPAddr.new('189.45.86.3')]) } it 'returns true for an exact match' do expect(subject.include?(IPAddr.new('189.45.86.3'))).to be true diff --git a/spec/lib/link_details_extractor_spec.rb b/spec/lib/link_details_extractor_spec.rb index 7ea867c61..7eb15ced3 100644 --- a/spec/lib/link_details_extractor_spec.rb +++ b/spec/lib/link_details_extractor_spec.rb @@ -39,17 +39,17 @@ RSpec.describe LinkDetailsExtractor do let(:original_url) { 'https://example.com/page.html' } context 'and is wrapped in CDATA tags' do - let(:html) { <<-HTML } - - - - - - + let(:html) { <<~HTML } + + + + + + HTML describe '#title' do @@ -78,57 +78,57 @@ RSpec.describe LinkDetailsExtractor do end context 'but the first tag is invalid JSON' do - let(:html) { <<-HTML } - - - - - - - + let(:html) { <<~HTML } + + + + + + + HTML describe '#title' do diff --git a/spec/models/account/field_spec.rb b/spec/models/account/field_spec.rb index 0ac9769bc..40bbee025 100644 --- a/spec/models/account/field_spec.rb +++ b/spec/models/account/field_spec.rb @@ -97,7 +97,7 @@ RSpec.describe Account::Field, type: :model do expect(subject.verifiable?).to be false end end - + context 'for text which is blank' do let(:value) { '' } @@ -149,7 +149,7 @@ RSpec.describe Account::Field, type: :model do expect(subject.verifiable?).to be false end end - + context 'for text which is blank' do let(:value) { '' } diff --git a/spec/models/account_alias_spec.rb b/spec/models/account_alias_spec.rb index 27ec215aa..c48b804b2 100644 --- a/spec/models/account_alias_spec.rb +++ b/spec/models/account_alias_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe AccountAlias, type: :model do - end diff --git a/spec/models/account_statuses_cleanup_policy_spec.rb b/spec/models/account_statuses_cleanup_policy_spec.rb index 684a1aa41..f11684516 100644 --- a/spec/models/account_statuses_cleanup_policy_spec.rb +++ b/spec/models/account_statuses_cleanup_policy_spec.rb @@ -16,16 +16,15 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do context 'when widening a policy' do let!(:account_statuses_cleanup_policy) do Fabricate(:account_statuses_cleanup_policy, - account: account, - keep_direct: true, - keep_pinned: true, - keep_polls: true, - keep_media: true, - keep_self_fav: true, - keep_self_bookmark: true, - min_favs: 1, - min_reblogs: 1 - ) + account: account, + keep_direct: true, + keep_pinned: true, + keep_polls: true, + keep_media: true, + keep_self_fav: true, + keep_self_bookmark: true, + min_favs: 1, + min_reblogs: 1) end before do @@ -96,16 +95,15 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do context 'when narrowing a policy' do let!(:account_statuses_cleanup_policy) do Fabricate(:account_statuses_cleanup_policy, - account: account, - keep_direct: false, - keep_pinned: false, - keep_polls: false, - keep_media: false, - keep_self_fav: false, - keep_self_bookmark: false, - min_favs: nil, - min_reblogs: nil - ) + account: account, + keep_direct: false, + keep_pinned: false, + keep_polls: false, + keep_media: false, + keep_self_fav: false, + keep_self_bookmark: false, + min_favs: nil, + min_reblogs: nil) end it 'does not unnecessarily invalidate last_inspected' do @@ -232,7 +230,7 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end describe '#compute_cutoff_id' do - let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) } + let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) } let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) } subject { account_statuses_cleanup_policy.compute_cutoff_id } diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index 5cb4a83f7..e628384d0 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -400,7 +400,7 @@ describe AccountInteractions do subject { account.domain_blocking?(domain) } context 'blocking the domain' do - it' returns true' do + it ' returns true' do account_domain_block = Fabricate(:account_domain_block, domain: domain) account.domain_blocks << account_domain_block is_expected.to be true diff --git a/spec/models/device_spec.rb b/spec/models/device_spec.rb index f56fbf978..307552e91 100644 --- a/spec/models/device_spec.rb +++ b/spec/models/device_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe Device, type: :model do - end diff --git a/spec/models/encrypted_message_spec.rb b/spec/models/encrypted_message_spec.rb index 1238d57b6..64f9c6912 100644 --- a/spec/models/encrypted_message_spec.rb +++ b/spec/models/encrypted_message_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe EncryptedMessage, type: :model do - end diff --git a/spec/models/export_spec.rb b/spec/models/export_spec.rb index 135d7a36b..5202ae9e1 100644 --- a/spec/models/export_spec.rb +++ b/spec/models/export_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Export do let(:account) { Fabricate(:account) } let(:target_accounts) do - [ {}, { username: 'one', domain: 'local.host' } ].map(&method(:Fabricate).curry(2).call(:account)) + [{}, { username: 'one', domain: 'local.host' }].map(&method(:Fabricate).curry(2).call(:account)) end describe 'to_csv' do diff --git a/spec/models/login_activity_spec.rb b/spec/models/login_activity_spec.rb index ba2d207c9..12d8c4363 100644 --- a/spec/models/login_activity_spec.rb +++ b/spec/models/login_activity_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe LoginActivity, type: :model do - end diff --git a/spec/models/one_time_key_spec.rb b/spec/models/one_time_key_spec.rb index 34598334c..4b231c600 100644 --- a/spec/models/one_time_key_spec.rb +++ b/spec/models/one_time_key_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe OneTimeKey, type: :model do - end diff --git a/spec/models/system_key_spec.rb b/spec/models/system_key_spec.rb index a138bc131..86f07f964 100644 --- a/spec/models/system_key_spec.rb +++ b/spec/models/system_key_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe SystemKey, type: :model do - end diff --git a/spec/models/trends/statuses_spec.rb b/spec/models/trends/statuses_spec.rb index 5f338a65e..98a8c7264 100644 --- a/spec/models/trends/statuses_spec.rb +++ b/spec/models/trends/statuses_spec.rb @@ -76,7 +76,7 @@ RSpec.describe Trends::Statuses do before do 13.times { reblog(status1, today) } 13.times { reblog(status2, today) } - 4.times { reblog(status3, today) } + 4.times { reblog(status3, today) } end context do diff --git a/spec/models/user_role_spec.rb b/spec/models/user_role_spec.rb index 28019593e..abf7d0e27 100644 --- a/spec/models/user_role_spec.rb +++ b/spec/models/user_role_spec.rb @@ -58,7 +58,7 @@ RSpec.describe UserRole, type: :model do end describe '#permissions_as_keys=' do - let(:input) { } + let(:input) {} before do subject.permissions_as_keys = input diff --git a/spec/routing/api_routing_spec.rb b/spec/routing/api_routing_spec.rb index 2683ccb8d..a822fba4c 100644 --- a/spec/routing/api_routing_spec.rb +++ b/spec/routing/api_routing_spec.rb @@ -5,99 +5,99 @@ require 'rails_helper' describe 'API routes' do describe 'Credentials routes' do it 'routes to verify credentials' do - expect(get('/api/v1/accounts/verify_credentials')). - to route_to('api/v1/accounts/credentials#show') + expect(get('/api/v1/accounts/verify_credentials')) + .to route_to('api/v1/accounts/credentials#show') end it 'routes to update credentials' do - expect(patch('/api/v1/accounts/update_credentials')). - to route_to('api/v1/accounts/credentials#update') + expect(patch('/api/v1/accounts/update_credentials')) + .to route_to('api/v1/accounts/credentials#update') end end describe 'Account routes' do it 'routes to statuses' do - expect(get('/api/v1/accounts/user/statuses')). - to route_to('api/v1/accounts/statuses#index', account_id: 'user') + expect(get('/api/v1/accounts/user/statuses')) + .to route_to('api/v1/accounts/statuses#index', account_id: 'user') end it 'routes to followers' do - expect(get('/api/v1/accounts/user/followers')). - to route_to('api/v1/accounts/follower_accounts#index', account_id: 'user') + expect(get('/api/v1/accounts/user/followers')) + .to route_to('api/v1/accounts/follower_accounts#index', account_id: 'user') end it 'routes to following' do - expect(get('/api/v1/accounts/user/following')). - to route_to('api/v1/accounts/following_accounts#index', account_id: 'user') + expect(get('/api/v1/accounts/user/following')) + .to route_to('api/v1/accounts/following_accounts#index', account_id: 'user') end it 'routes to search' do - expect(get('/api/v1/accounts/search')). - to route_to('api/v1/accounts/search#show') + expect(get('/api/v1/accounts/search')) + .to route_to('api/v1/accounts/search#show') end it 'routes to relationships' do - expect(get('/api/v1/accounts/relationships')). - to route_to('api/v1/accounts/relationships#index') + expect(get('/api/v1/accounts/relationships')) + .to route_to('api/v1/accounts/relationships#index') end end describe 'Statuses routes' do it 'routes reblogged_by' do - expect(get('/api/v1/statuses/123/reblogged_by')). - to route_to('api/v1/statuses/reblogged_by_accounts#index', status_id: '123') + expect(get('/api/v1/statuses/123/reblogged_by')) + .to route_to('api/v1/statuses/reblogged_by_accounts#index', status_id: '123') end it 'routes favourited_by' do - expect(get('/api/v1/statuses/123/favourited_by')). - to route_to('api/v1/statuses/favourited_by_accounts#index', status_id: '123') + expect(get('/api/v1/statuses/123/favourited_by')) + .to route_to('api/v1/statuses/favourited_by_accounts#index', status_id: '123') end it 'routes reblog' do - expect(post('/api/v1/statuses/123/reblog')). - to route_to('api/v1/statuses/reblogs#create', status_id: '123') + expect(post('/api/v1/statuses/123/reblog')) + .to route_to('api/v1/statuses/reblogs#create', status_id: '123') end it 'routes unreblog' do - expect(post('/api/v1/statuses/123/unreblog')). - to route_to('api/v1/statuses/reblogs#destroy', status_id: '123') + expect(post('/api/v1/statuses/123/unreblog')) + .to route_to('api/v1/statuses/reblogs#destroy', status_id: '123') end it 'routes favourite' do - expect(post('/api/v1/statuses/123/favourite')). - to route_to('api/v1/statuses/favourites#create', status_id: '123') + expect(post('/api/v1/statuses/123/favourite')) + .to route_to('api/v1/statuses/favourites#create', status_id: '123') end it 'routes unfavourite' do - expect(post('/api/v1/statuses/123/unfavourite')). - to route_to('api/v1/statuses/favourites#destroy', status_id: '123') + expect(post('/api/v1/statuses/123/unfavourite')) + .to route_to('api/v1/statuses/favourites#destroy', status_id: '123') end it 'routes mute' do - expect(post('/api/v1/statuses/123/mute')). - to route_to('api/v1/statuses/mutes#create', status_id: '123') + expect(post('/api/v1/statuses/123/mute')) + .to route_to('api/v1/statuses/mutes#create', status_id: '123') end it 'routes unmute' do - expect(post('/api/v1/statuses/123/unmute')). - to route_to('api/v1/statuses/mutes#destroy', status_id: '123') + expect(post('/api/v1/statuses/123/unmute')) + .to route_to('api/v1/statuses/mutes#destroy', status_id: '123') end end describe 'Timeline routes' do it 'routes to home timeline' do - expect(get('/api/v1/timelines/home')). - to route_to('api/v1/timelines/home#show') + expect(get('/api/v1/timelines/home')) + .to route_to('api/v1/timelines/home#show') end it 'routes to public timeline' do - expect(get('/api/v1/timelines/public')). - to route_to('api/v1/timelines/public#show') + expect(get('/api/v1/timelines/public')) + .to route_to('api/v1/timelines/public#show') end it 'routes to tag timeline' do - expect(get('/api/v1/timelines/tag/test')). - to route_to('api/v1/timelines/tag#show', id: 'test') + expect(get('/api/v1/timelines/tag/test')) + .to route_to('api/v1/timelines/tag#show', id: 'test') end end end diff --git a/spec/routing/well_known_routes_spec.rb b/spec/routing/well_known_routes_spec.rb index 2e25605c2..03a562843 100644 --- a/spec/routing/well_known_routes_spec.rb +++ b/spec/routing/well_known_routes_spec.rb @@ -2,14 +2,14 @@ require 'rails_helper' describe 'the host-meta route' do it 'routes to correct place with xml format' do - expect(get('/.well-known/host-meta')). - to route_to('well_known/host_meta#show', format: 'xml') + expect(get('/.well-known/host-meta')) + .to route_to('well_known/host_meta#show', format: 'xml') end end describe 'the webfinger route' do it 'routes to correct place with json format' do - expect(get('/.well-known/webfinger')). - to route_to('well_known/webfinger#show') + expect(get('/.well-known/webfinger')) + .to route_to('well_known/webfinger#show') end end diff --git a/spec/serializers/rest/account_serializer_spec.rb b/spec/serializers/rest/account_serializer_spec.rb index 5b08d5aca..3bca06b73 100644 --- a/spec/serializers/rest/account_serializer_spec.rb +++ b/spec/serializers/rest/account_serializer_spec.rb @@ -5,7 +5,7 @@ require 'rails_helper' describe REST::AccountSerializer do let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) } let(:user) { Fabricate(:user, role: role) } - let(:account) { user.account} + let(:account) { user.account } subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer).to_json) } diff --git a/spec/services/account_statuses_cleanup_service_spec.rb b/spec/services/account_statuses_cleanup_service_spec.rb index 257655c41..a30e14ab6 100644 --- a/spec/services/account_statuses_cleanup_service_spec.rb +++ b/spec/services/account_statuses_cleanup_service_spec.rb @@ -42,8 +42,8 @@ describe AccountStatusesCleanupService, type: :service do context 'when called repeatedly with a budget of 2' do it 'reports 2 then 1 deleted statuses' do - expect(subject.call(account_policy, 2)).to eq 2 - expect(subject.call(account_policy, 2)).to eq 1 + expect(subject.call(account_policy, 2)).to eq 2 + expect(subject.call(account_policy, 2)).to eq 1 end it 'actually deletes the statuses in the expected order' do diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index a81dcad81..d6145c9b8 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb @@ -298,7 +298,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do first: { type: 'CollectionPage', partOf: "https://foo.bar/@foo/#{i}/replies", - items: ["https://foo.bar/@foo/#{i+1}"], + items: ["https://foo.bar/@foo/#{i + 1}"], }, }, attributedTo: ActivityPub::TagManager.instance.uri_for(sender), diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 2b20d17b1..40caa6eb0 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -172,10 +172,10 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do { type: 'Mention', href: "https://foo.test/users/#{i + 1}", - name: "@user#{i + 1 }", + name: "@user#{i + 1}", } ], - to: [ 'as:Public', "https://foo.test/users/#{i + 1}" ] + to: ['as:Public', "https://foo.test/users/#{i + 1}"] }.with_indifferent_access featured_json = { '@context': ['https://www.w3.org/ns/activitystreams'], diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index a308cede7..cb60e1cb8 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -95,11 +95,11 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do context 'when receiving a fabricated status' do let!(:actor) do Fabricate(:account, - username: 'bob', - domain: 'example.com', - uri: 'https://example.com/users/bob', - public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuuYyoyfsRkYnXRotMsId\nW3euBDDfiv9oVqOxUVC7bhel8KednIMrMCRWFAkgJhbrlzbIkjVr68o1MP9qLcn7\nCmH/BXHp7yhuFTr4byjdJKpwB+/i2jNEsvDH5jR8WTAeTCe0x/QHg21V3F7dSI5m\nCCZ/1dSIyOXLRTWVlfDlm3rE4ntlCo+US3/7oSWbg/4/4qEnt1HC32kvklgScxua\n4LR5ATdoXa5bFoopPWhul7MJ6NyWCyQyScUuGdlj8EN4kmKQJvphKHrI9fvhgOuG\nTvhTR1S5InA4azSSchY0tXEEw/VNxraeX0KPjbgr6DPcwhPd/m0nhVDq0zVyVBBD\nMwIDAQAB\n-----END PUBLIC KEY-----\n", - private_key: nil) + username: 'bob', + domain: 'example.com', + uri: 'https://example.com/users/bob', + public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuuYyoyfsRkYnXRotMsId\nW3euBDDfiv9oVqOxUVC7bhel8KednIMrMCRWFAkgJhbrlzbIkjVr68o1MP9qLcn7\nCmH/BXHp7yhuFTr4byjdJKpwB+/i2jNEsvDH5jR8WTAeTCe0x/QHg21V3F7dSI5m\nCCZ/1dSIyOXLRTWVlfDlm3rE4ntlCo+US3/7oSWbg/4/4qEnt1HC32kvklgScxua\n4LR5ATdoXa5bFoopPWhul7MJ6NyWCyQyScUuGdlj8EN4kmKQJvphKHrI9fvhgOuG\nTvhTR1S5InA4azSSchY0tXEEw/VNxraeX0KPjbgr6DPcwhPd/m0nhVDq0zVyVBBD\nMwIDAQAB\n-----END PUBLIC KEY-----\n", + private_key: nil) end let(:payload) do @@ -107,7 +107,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do '@context': [ 'https://www.w3.org/ns/activitystreams', nil, - {'object': 'https://www.w3.org/ns/activitystreams#object'} + { 'object': 'https://www.w3.org/ns/activitystreams#object' } ], 'id': 'https://example.com/users/bob/fake-status/activity', 'type': 'Create', diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 750369d57..04292c507 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -104,20 +104,19 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end context 'when the status has not been explicitly edited and features a poll' do - let(:account) { Fabricate(:account, domain: 'example.com') } + let(:account) { Fabricate(:account, domain: 'example.com') } let!(:expiration) { 10.days.from_now.utc } let!(:status) do Fabricate(:status, - text: 'Hello world', - account: account, - poll_attributes: { - options: %w(Foo Bar), - account: account, - multiple: false, - hide_totals: false, - expires_at: expiration - } - ) + text: 'Hello world', + account: account, + poll_attributes: { + options: %w(Foo Bar), + account: account, + multiple: false, + hide_totals: false, + expires_at: expiration + }) end let(:payload) do @@ -156,20 +155,19 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end context 'when the status changes a poll despite being not explicitly marked as updated' do - let(:account) { Fabricate(:account, domain: 'example.com') } + let(:account) { Fabricate(:account, domain: 'example.com') } let!(:expiration) { 10.days.from_now.utc } let!(:status) do Fabricate(:status, - text: 'Hello world', - account: account, - poll_attributes: { - options: %w(Foo Bar), - account: account, - multiple: false, - hide_totals: false, - expires_at: expiration - } - ) + text: 'Hello world', + account: account, + poll_attributes: { + options: %w(Foo Bar), + account: account, + multiple: false, + hide_totals: false, + expires_at: expiration + }) end let(:payload) do diff --git a/spec/services/bootstrap_timeline_service_spec.rb b/spec/services/bootstrap_timeline_service_spec.rb index 16f3e9962..149f6e6df 100644 --- a/spec/services/bootstrap_timeline_service_spec.rb +++ b/spec/services/bootstrap_timeline_service_spec.rb @@ -32,6 +32,5 @@ RSpec.describe BootstrapTimelineService, type: :service do expect(service).to_not have_received(:call) end end - end end diff --git a/spec/services/fetch_oembed_service_spec.rb b/spec/services/fetch_oembed_service_spec.rb index 88f0113ed..da2a8d0d1 100644 --- a/spec/services/fetch_oembed_service_spec.rb +++ b/spec/services/fetch_oembed_service_spec.rb @@ -151,7 +151,6 @@ describe FetchOEmbedService, type: :service do expect(subject.format).to eq :json end end - end context 'when endpoint is cached' do diff --git a/spec/services/import_service_spec.rb b/spec/services/import_service_spec.rb index e2d182920..217d0ee24 100644 --- a/spec/services/import_service_spec.rb +++ b/spec/services/import_service_spec.rb @@ -178,7 +178,7 @@ RSpec.describe ImportService, type: :service do context 'utf-8 encoded domains' do subject { ImportService.new } - let!(:nare) { Fabricate(:account, username: 'nare', domain: 'թութ.հայ', locked: false, protocol: :activitypub, inbox_url: 'https://թութ.հայ/inbox') } + let!(:nare) { Fabricate(:account, username: 'nare', domain: 'թութ.հայ', locked: false, protocol: :activitypub, inbox_url: 'https://թութ.հայ/inbox') } # Make sure to not actually go to the remote server before do @@ -189,7 +189,7 @@ RSpec.describe ImportService, type: :service do let(:import) { Import.create(account: account, type: 'following', data: csv) } it 'follows the listed account' do - expect(account.follow_requests.count).to eq 0 + expect(account.follow_requests.count).to eq 0 subject.call(import) expect(account.follow_requests.count).to eq 1 end diff --git a/spec/services/remove_from_follwers_service_spec.rb b/spec/services/remove_from_follwers_service_spec.rb index a83f6f49a..9b9c846cf 100644 --- a/spec/services/remove_from_follwers_service_spec.rb +++ b/spec/services/remove_from_follwers_service_spec.rb @@ -7,7 +7,7 @@ RSpec.describe RemoveFromFollowersService, type: :service do describe 'local' do let(:sender) { Fabricate(:account, username: 'alice') } - + before do Follow.create(account: sender, target_account: bob) subject.call(bob, sender) diff --git a/spec/services/remove_status_service_spec.rb b/spec/services/remove_status_service_spec.rb index 482068d58..e253052f3 100644 --- a/spec/services/remove_status_service_spec.rb +++ b/spec/services/remove_status_service_spec.rb @@ -37,29 +37,29 @@ RSpec.describe RemoveStatusService, type: :service do it 'sends Delete activity to followers' do subject.call(@status) expect(a_request(:post, 'http://example.com/inbox').with( - body: hash_including({ - 'type' => 'Delete', - 'object' => { - 'type' => 'Tombstone', - 'id' => ActivityPub::TagManager.instance.uri_for(@status), - 'atomUri' => OStatus::TagManager.instance.uri_for(@status), - }, - }) - )).to have_been_made.once + body: hash_including({ + 'type' => 'Delete', + 'object' => { + 'type' => 'Tombstone', + 'id' => ActivityPub::TagManager.instance.uri_for(@status), + 'atomUri' => OStatus::TagManager.instance.uri_for(@status), + }, + }) + )).to have_been_made.once end it 'sends Delete activity to rebloggers' do subject.call(@status) expect(a_request(:post, 'http://example2.com/inbox').with( - body: hash_including({ - 'type' => 'Delete', - 'object' => { - 'type' => 'Tombstone', - 'id' => ActivityPub::TagManager.instance.uri_for(@status), - 'atomUri' => OStatus::TagManager.instance.uri_for(@status), - }, - }) - )).to have_been_made.once + body: hash_including({ + 'type' => 'Delete', + 'object' => { + 'type' => 'Tombstone', + 'id' => ActivityPub::TagManager.instance.uri_for(@status), + 'atomUri' => OStatus::TagManager.instance.uri_for(@status), + }, + }) + )).to have_been_made.once end it 'remove status from notifications' do @@ -78,14 +78,14 @@ RSpec.describe RemoveStatusService, type: :service do it 'sends Undo activity to followers' do subject.call(@status) expect(a_request(:post, 'http://example.com/inbox').with( - body: hash_including({ - 'type' => 'Undo', - 'object' => hash_including({ - 'type' => 'Announce', - 'object' => ActivityPub::TagManager.instance.uri_for(@original_status), - }), - }) - )).to have_been_made.once + body: hash_including({ + 'type' => 'Undo', + 'object' => hash_including({ + 'type' => 'Announce', + 'object' => ActivityPub::TagManager.instance.uri_for(@original_status), + }), + }) + )).to have_been_made.once end end @@ -98,14 +98,14 @@ RSpec.describe RemoveStatusService, type: :service do it 'sends Undo activity to followers' do subject.call(@status) expect(a_request(:post, 'http://example.com/inbox').with( - body: hash_including({ - 'type' => 'Undo', - 'object' => hash_including({ - 'type' => 'Announce', - 'object' => ActivityPub::TagManager.instance.uri_for(@original_status), - }), - }) - )).to have_been_made.once + body: hash_including({ + 'type' => 'Undo', + 'object' => hash_including({ + 'type' => 'Announce', + 'object' => ActivityPub::TagManager.instance.uri_for(@original_status), + }), + }) + )).to have_been_made.once end end end diff --git a/spec/services/resolve_account_service_spec.rb b/spec/services/resolve_account_service_spec.rb index 654606bea..1df30ea57 100644 --- a/spec/services/resolve_account_service_spec.rb +++ b/spec/services/resolve_account_service_spec.rb @@ -190,7 +190,7 @@ RSpec.describe ResolveAccountService, type: :service do context 'with an already-known acct: URI changing ActivityPub id' do let!(:old_account) { Fabricate(:account, username: 'foo', domain: 'ap.example.com', uri: 'https://old.example.com/users/foo', last_webfingered_at: nil) } - let!(:status) { Fabricate(:status, account: old_account, text: 'foo') } + let!(:status) { Fabricate(:status, account: old_account, text: 'foo') } it 'returns new remote account' do account = subject.call('foo@ap.example.com') diff --git a/spec/services/resolve_url_service_spec.rb b/spec/services/resolve_url_service_spec.rb index b3e3defbf..3598311ee 100644 --- a/spec/services/resolve_url_service_spec.rb +++ b/spec/services/resolve_url_service_spec.rb @@ -133,7 +133,7 @@ describe ResolveURLService, type: :service do let!(:status) { Fabricate(:status, account: poster, visibility: :public) } let(:url) { 'https://link.to/foobar' } let(:status_url) { ActivityPub::TagManager.instance.url_for(status) } - let(:uri) { ActivityPub::TagManager.instance.uri_for(status) } + let(:uri) { ActivityPub::TagManager.instance.uri_for(status) } before do stub_request(:get, url).to_return(status: 302, headers: { 'Location' => status_url }) diff --git a/spec/services/update_status_service_spec.rb b/spec/services/update_status_service_spec.rb index 16e981d2b..a7364ca8b 100644 --- a/spec/services/update_status_service_spec.rb +++ b/spec/services/update_status_service_spec.rb @@ -111,7 +111,7 @@ RSpec.describe UpdateStatusService, type: :service do context 'when poll changes' do let(:account) { Fabricate(:account) } - let!(:status) { Fabricate(:status, text: 'Foo', account: account, poll_attributes: {options: %w(Foo Bar), account: account, multiple: false, hide_totals: false, expires_at: 7.days.from_now }) } + let!(:status) { Fabricate(:status, text: 'Foo', account: account, poll_attributes: { options: %w(Foo Bar), account: account, multiple: false, hide_totals: false, expires_at: 7.days.from_now }) } let!(:poll) { status.poll } let!(:voter) { Fabricate(:account) } diff --git a/spec/support/stories/profile_stories.rb b/spec/support/stories/profile_stories.rb index 0c4a14d1c..de7ae17e6 100644 --- a/spec/support/stories/profile_stories.rb +++ b/spec/support/stories/profile_stories.rb @@ -20,8 +20,8 @@ module ProfileStories end def with_alice_as_local_user - @alice_bio = '@alice and @bob are fictional characters commonly used as'\ - 'placeholder names in #cryptology, as well as #science and'\ + @alice_bio = '@alice and @bob are fictional characters commonly used as' \ + 'placeholder names in #cryptology, as well as #science and' \ 'engineering 📖 literature. Not affiliated with @pepe.' @alice = Fabricate( diff --git a/spec/validators/note_length_validator_spec.rb b/spec/validators/note_length_validator_spec.rb index 6e9b4e132..390ac8d90 100644 --- a/spec/validators/note_length_validator_spec.rb +++ b/spec/validators/note_length_validator_spec.rb @@ -15,7 +15,7 @@ describe NoteLengthValidator do end it 'counts URLs as 23 characters flat' do - text = ('a' * 476) + " http://#{'b' * 30}.com/example" + text = ('a' * 476) + " http://#{'b' * 30}.com/example" account = double(note: text, errors: double(add: nil)) subject.validate_each(account, 'note', text) @@ -23,7 +23,7 @@ describe NoteLengthValidator do end it 'does not count non-autolinkable URLs as 23 characters flat' do - text = ('a' * 476) + "http://#{'b' * 30}.com/example" + text = ('a' * 476) + "http://#{'b' * 30}.com/example" account = double(note: text, errors: double(add: nil)) subject.validate_each(account, 'note', text) diff --git a/spec/validators/unreserved_username_validator_spec.rb b/spec/validators/unreserved_username_validator_spec.rb index 746b3866c..e2f051b08 100644 --- a/spec/validators/unreserved_username_validator_spec.rb +++ b/spec/validators/unreserved_username_validator_spec.rb @@ -11,10 +11,10 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do let(:validator) { described_class.new } let(:account) { double(username: username, errors: errors) } - let(:errors ) { double(add: nil) } + let(:errors) { double(add: nil) } context '@username.blank?' do - let(:username) { nil } + let(:username) { nil } it 'not calls errors.add' do expect(errors).not_to have_received(:add).with(:username, any_args) @@ -22,7 +22,7 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do end context '!@username.blank?' do - let(:username) { 'f' } + let(:username) { 'f' } context 'reserved_username?' do let(:reserved_username) { true } diff --git a/spec/workers/activitypub/distribution_worker_spec.rb b/spec/workers/activitypub/distribution_worker_spec.rb index 3a5900d9b..7f63e197b 100644 --- a/spec/workers/activitypub/distribution_worker_spec.rb +++ b/spec/workers/activitypub/distribution_worker_spec.rb @@ -34,7 +34,7 @@ describe ActivityPub::DistributionWorker do end context 'with direct status' do - let(:mentioned_account) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://foo.bar/inbox')} + let(:mentioned_account) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') } before do status.update(visibility: :direct) diff --git a/spec/workers/activitypub/move_distribution_worker_spec.rb b/spec/workers/activitypub/move_distribution_worker_spec.rb index af8c44cc0..57941065a 100644 --- a/spec/workers/activitypub/move_distribution_worker_spec.rb +++ b/spec/workers/activitypub/move_distribution_worker_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe ActivityPub::MoveDistributionWorker do subject { described_class.new } - let(:migration) { Fabricate(:account_migration) } + let(:migration) { Fabricate(:account_migration) } let(:follower) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example.com') } let(:blocker) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example2.com') } @@ -15,9 +15,9 @@ describe ActivityPub::MoveDistributionWorker do it 'delivers to followers and known blockers' do expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [ - [kind_of(String), migration.account.id, 'http://example.com'], - [kind_of(String), migration.account.id, 'http://example2.com'] - ]) + [kind_of(String), migration.account.id, 'http://example.com'], + [kind_of(String), migration.account.id, 'http://example2.com'] + ]) subject.perform(migration.id) end end diff --git a/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb b/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb index 8f20725c8..8faf04836 100644 --- a/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb +++ b/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb @@ -82,7 +82,7 @@ describe Scheduler::AccountsStatusesCleanupScheduler do describe '#get_budget' do context 'on a single thread' do - let(:process_set_stub) { [ { 'concurrency' => 1, 'queues' => ['push', 'default'] } ] } + let(:process_set_stub) { [{ 'concurrency' => 1, 'queues' => ['push', 'default'] }] } it 'returns a low value' do expect(subject.compute_budget).to be < 10 -- cgit From 717683d1c39d2fe85d1cc3f5223e1f4cf43f1900 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Mon, 20 Feb 2023 00:58:28 -0500 Subject: Autofix Rubocop remaining Layout rules (#23679) --- .rubocop_todo.yml | 148 --------------------- Capfile | 1 + app/controllers/api/v1/tags_controller.rb | 1 + app/controllers/application_controller.rb | 1 + .../concerns/session_tracking_concern.rb | 1 + app/controllers/concerns/signature_verification.rb | 1 + app/helpers/application_helper.rb | 1 + app/helpers/languages_helper.rb | 1 + app/lib/activitypub/activity.rb | 1 + app/lib/activitypub/linked_data_signature.rb | 2 +- app/lib/activitypub/tag_manager.rb | 2 + app/lib/ostatus/tag_manager.rb | 32 ++--- app/lib/request.rb | 1 + app/lib/settings/scoped_settings.rb | 2 + app/lib/status_filter.rb | 1 + app/lib/tag_manager.rb | 1 + app/lib/webfinger.rb | 1 + app/models/account.rb | 2 + app/models/account/field.rb | 4 +- app/models/account_conversation.rb | 2 + app/models/account_domain_block.rb | 1 + app/models/account_moderation_note.rb | 1 + app/models/account_note.rb | 1 + app/models/account_pin.rb | 1 + app/models/account_stat.rb | 1 + app/models/account_summary.rb | 1 + app/models/account_warning.rb | 13 +- app/models/admin/import.rb | 1 + app/models/backup.rb | 1 + app/models/block.rb | 1 + app/models/bookmark.rb | 1 + app/models/canonical_email_block.rb | 1 + app/models/conversation.rb | 1 + app/models/conversation_mute.rb | 1 + app/models/custom_emoji.rb | 1 + app/models/custom_filter.rb | 3 + app/models/custom_filter_keyword.rb | 1 + app/models/custom_filter_status.rb | 1 + app/models/device.rb | 1 + app/models/domain_block.rb | 1 + app/models/email_domain_block.rb | 1 + app/models/encrypted_message.rb | 1 + app/models/favourite.rb | 2 + app/models/featured_tag.rb | 1 + app/models/follow.rb | 1 + app/models/follow_recommendation.rb | 1 + app/models/follow_recommendation_suppression.rb | 1 + app/models/follow_request.rb | 1 + app/models/form/admin_settings.rb | 1 + app/models/identity.rb | 1 + app/models/import.rb | 1 + app/models/instance.rb | 1 + app/models/invite.rb | 1 + app/models/ip_block.rb | 1 + app/models/list.rb | 1 + app/models/list_account.rb | 1 + app/models/login_activity.rb | 1 + app/models/media_attachment.rb | 3 +- app/models/mention.rb | 1 + app/models/mute.rb | 1 + app/models/notification.rb | 11 +- app/models/one_time_key.rb | 1 + app/models/poll.rb | 8 +- app/models/poll_vote.rb | 1 + app/models/preview_card.rb | 1 + app/models/preview_card_provider.rb | 1 + app/models/relay.rb | 1 + app/models/report.rb | 1 + app/models/report_note.rb | 1 + app/models/session_activation.rb | 2 + app/models/setting.rb | 4 + app/models/site_upload.rb | 1 + app/models/status.rb | 1 + app/models/status_edit.rb | 2 + app/models/status_pin.rb | 1 + app/models/status_stat.rb | 1 + app/models/tag.rb | 1 + app/models/unavailable_domain.rb | 1 + app/models/user.rb | 4 + app/models/user_ip.rb | 1 + app/models/user_role.rb | 2 + app/models/web/push_subscription.rb | 1 + app/models/web/setting.rb | 1 + app/models/webauthn_credential.rb | 1 + app/presenters/account_relationships_presenter.rb | 18 +-- .../activitypub/fetch_remote_actor_service.rb | 1 + .../activitypub/fetch_remote_status_service.rb | 1 + app/services/activitypub/fetch_replies_service.rb | 1 + .../activitypub/process_account_service.rb | 2 + app/services/favourite_service.rb | 1 + app/services/keys/claim_service.rb | 6 +- app/services/keys/query_service.rb | 6 +- app/services/notify_service.rb | 1 + app/services/post_status_service.rb | 3 + app/services/vote_service.rb | 2 + app/validators/follow_limit_validator.rb | 1 + app/validators/unreserved_username_validator.rb | 2 + .../accounts_statuses_cleanup_scheduler.rb | 2 + app/workers/web/push_notification_worker.rb | 12 +- config.ru | 1 + ...314181829_migrate_open_registrations_setting.rb | 2 + ...43559_preserve_old_layout_for_existing_users.rb | 1 + ...431_add_case_insensitive_btree_index_to_tags.rb | 1 + .../20220613110834_add_action_to_custom_filters.rb | 1 + .../20200917193528_migrate_notifications_type.rb | 10 +- ...110802_remove_whole_word_from_custom_filters.rb | 1 + ...0903_remove_irreversible_from_custom_filters.rb | 1 + .../20221101190723_backfill_admin_action_logs.rb | 13 ++ ...21206114142_backfill_admin_action_logs_again.rb | 13 ++ lib/mastodon/domains_cli.rb | 2 + lib/sanitize_ext/sanitize_config.rb | 12 +- lib/tasks/auto_annotate_models.rake | 70 +++++----- lib/tasks/mastodon.rake | 16 +-- .../api/v1/accounts/statuses_controller_spec.rb | 1 + spec/models/admin/account_action_spec.rb | 4 +- spec/models/concerns/account_interactions_spec.rb | 4 +- spec/models/tag_spec.rb | 1 + 117 files changed, 265 insertions(+), 261 deletions(-) (limited to 'app/services/activitypub/fetch_replies_service.rb') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0f98d25d6..e667a7786 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -14,154 +14,6 @@ Bundler/OrderedGems: Exclude: - 'Gemfile' -# Offense count: 81 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLineAfterGuardClause: - Exclude: - - 'app/controllers/api/v1/tags_controller.rb' - - 'app/controllers/application_controller.rb' - - 'app/controllers/concerns/session_tracking_concern.rb' - - 'app/controllers/concerns/signature_verification.rb' - - 'app/helpers/application_helper.rb' - - 'app/lib/activitypub/activity.rb' - - 'app/lib/activitypub/tag_manager.rb' - - 'app/lib/request.rb' - - 'app/lib/settings/scoped_settings.rb' - - 'app/lib/status_filter.rb' - - 'app/lib/tag_manager.rb' - - 'app/lib/webfinger.rb' - - 'app/models/account.rb' - - 'app/models/account_conversation.rb' - - 'app/models/admin/import.rb' - - 'app/models/custom_filter.rb' - - 'app/models/favourite.rb' - - 'app/models/form/admin_settings.rb' - - 'app/models/poll.rb' - - 'app/models/session_activation.rb' - - 'app/models/setting.rb' - - 'app/models/status_edit.rb' - - 'app/models/user.rb' - - 'app/models/user_role.rb' - - 'app/services/activitypub/fetch_remote_actor_service.rb' - - 'app/services/activitypub/fetch_remote_status_service.rb' - - 'app/services/activitypub/fetch_replies_service.rb' - - 'app/services/activitypub/process_account_service.rb' - - 'app/services/favourite_service.rb' - - 'app/services/notify_service.rb' - - 'app/services/post_status_service.rb' - - 'app/services/vote_service.rb' - - 'app/validators/follow_limit_validator.rb' - - 'app/validators/unreserved_username_validator.rb' - - 'app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb' - - 'db/migrate/20190314181829_migrate_open_registrations_setting.rb' - - 'db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb' - - 'db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb' - - 'db/post_migrate/20221101190723_backfill_admin_action_logs.rb' - - 'db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb' - - 'lib/mastodon/domains_cli.rb' - -# Offense count: 71 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLineAfterMagicComment: - Exclude: - - 'Capfile' - - 'app/helpers/languages_helper.rb' - - 'app/models/account.rb' - - 'app/models/account_conversation.rb' - - 'app/models/account_domain_block.rb' - - 'app/models/account_moderation_note.rb' - - 'app/models/account_note.rb' - - 'app/models/account_pin.rb' - - 'app/models/account_stat.rb' - - 'app/models/account_summary.rb' - - 'app/models/account_warning.rb' - - 'app/models/backup.rb' - - 'app/models/block.rb' - - 'app/models/bookmark.rb' - - 'app/models/canonical_email_block.rb' - - 'app/models/conversation.rb' - - 'app/models/conversation_mute.rb' - - 'app/models/custom_emoji.rb' - - 'app/models/custom_filter.rb' - - 'app/models/custom_filter_keyword.rb' - - 'app/models/custom_filter_status.rb' - - 'app/models/device.rb' - - 'app/models/domain_block.rb' - - 'app/models/email_domain_block.rb' - - 'app/models/encrypted_message.rb' - - 'app/models/favourite.rb' - - 'app/models/featured_tag.rb' - - 'app/models/follow.rb' - - 'app/models/follow_recommendation.rb' - - 'app/models/follow_recommendation_suppression.rb' - - 'app/models/follow_request.rb' - - 'app/models/identity.rb' - - 'app/models/import.rb' - - 'app/models/instance.rb' - - 'app/models/invite.rb' - - 'app/models/ip_block.rb' - - 'app/models/list.rb' - - 'app/models/list_account.rb' - - 'app/models/login_activity.rb' - - 'app/models/media_attachment.rb' - - 'app/models/mention.rb' - - 'app/models/mute.rb' - - 'app/models/notification.rb' - - 'app/models/one_time_key.rb' - - 'app/models/poll.rb' - - 'app/models/poll_vote.rb' - - 'app/models/preview_card.rb' - - 'app/models/preview_card_provider.rb' - - 'app/models/relay.rb' - - 'app/models/report.rb' - - 'app/models/report_note.rb' - - 'app/models/session_activation.rb' - - 'app/models/setting.rb' - - 'app/models/site_upload.rb' - - 'app/models/status.rb' - - 'app/models/status_edit.rb' - - 'app/models/status_pin.rb' - - 'app/models/status_stat.rb' - - 'app/models/tag.rb' - - 'app/models/unavailable_domain.rb' - - 'app/models/user.rb' - - 'app/models/user_ip.rb' - - 'app/models/web/push_subscription.rb' - - 'app/models/web/setting.rb' - - 'app/models/webauthn_credential.rb' - - 'config.ru' - - 'db/migrate/20220613110834_add_action_to_custom_filters.rb' - - 'db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb' - - 'db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb' - - 'spec/controllers/api/v1/accounts/statuses_controller_spec.rb' - - 'spec/models/tag_spec.rb' - -# Offense count: 113 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/HashAlignment: - Exclude: - - 'app/lib/activitypub/linked_data_signature.rb' - - 'app/lib/ostatus/tag_manager.rb' - - 'app/models/account/field.rb' - - 'app/models/account_warning.rb' - - 'app/models/media_attachment.rb' - - 'app/models/notification.rb' - - 'app/models/poll.rb' - - 'app/presenters/account_relationships_presenter.rb' - - 'app/services/keys/claim_service.rb' - - 'app/services/keys/query_service.rb' - - 'app/workers/web/push_notification_worker.rb' - - 'db/post_migrate/20200917193528_migrate_notifications_type.rb' - - 'lib/sanitize_ext/sanitize_config.rb' - - 'lib/tasks/auto_annotate_models.rake' - - 'lib/tasks/mastodon.rake' - - 'spec/models/admin/account_action_spec.rb' - - 'spec/models/concerns/account_interactions_spec.rb' - # Offense count: 581 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. diff --git a/Capfile b/Capfile index bf3ae7e24..86efa5bac 100644 --- a/Capfile +++ b/Capfile @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'capistrano/setup' require 'capistrano/deploy' require 'capistrano/scm/git' diff --git a/app/controllers/api/v1/tags_controller.rb b/app/controllers/api/v1/tags_controller.rb index 272362c31..a08fd2187 100644 --- a/app/controllers/api/v1/tags_controller.rb +++ b/app/controllers/api/v1/tags_controller.rb @@ -25,6 +25,7 @@ class Api::V1::TagsController < Api::BaseController def set_or_create_tag return not_found unless Tag::HASHTAG_NAME_RE.match?(params[:id]) + @tag = Tag.find_normalized(params[:id]) || Tag.new(name: Tag.normalize(params[:id]), display_name: params[:id]) end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 615536b96..ad70e28ab 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -128,6 +128,7 @@ class ApplicationController < ActionController::Base def current_theme return Setting.theme unless Themes.instance.names.include? current_user&.setting_theme + current_user.setting_theme end diff --git a/app/controllers/concerns/session_tracking_concern.rb b/app/controllers/concerns/session_tracking_concern.rb index eaaa4ac59..3f56c0d02 100644 --- a/app/controllers/concerns/session_tracking_concern.rb +++ b/app/controllers/concerns/session_tracking_concern.rb @@ -13,6 +13,7 @@ module SessionTrackingConcern def set_session_activity return unless session_needs_update? + current_session.touch end diff --git a/app/controllers/concerns/signature_verification.rb b/app/controllers/concerns/signature_verification.rb index 9c04ab4ca..b0a087d53 100644 --- a/app/controllers/concerns/signature_verification.rb +++ b/app/controllers/concerns/signature_verification.rb @@ -165,6 +165,7 @@ module SignatureVerification end raise SignatureVerificationError, "Invalid Digest value. The provided Digest value is not a SHA-256 digest. Given digest: #{sha256[1]}" if digest_size != 32 + raise SignatureVerificationError, "Invalid Digest value. Computed SHA-256 digest: #{body_digest}; given: #{sha256[1]}" end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1f93b33f5..08020a65a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -105,6 +105,7 @@ module ApplicationHelper def can?(action, record) return false if record.nil? + policy(record).public_send("#{action}?") end diff --git a/app/helpers/languages_helper.rb b/app/helpers/languages_helper.rb index bb35ce08c..584394758 100644 --- a/app/helpers/languages_helper.rb +++ b/app/helpers/languages_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # rubocop:disable Metrics/ModuleLength, Style/WordArray module LanguagesHelper diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 900428e92..5d9596254 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -153,6 +153,7 @@ class ActivityPub::Activity def fetch_remote_original_status if object_uri.start_with?('http') return if ActivityPub::TagManager.instance.local_uri?(object_uri) + ActivityPub::FetchRemoteStatusService.new.call(object_uri, id: true, on_behalf_of: @account.followers.local.first, request_id: @options[:request_id]) elsif @object['url'].present? ::FetchRemoteStatusService.new.call(@object['url'], request_id: @options[:request_id]) diff --git a/app/lib/activitypub/linked_data_signature.rb b/app/lib/activitypub/linked_data_signature.rb index 61759649a..ea59879f3 100644 --- a/app/lib/activitypub/linked_data_signature.rb +++ b/app/lib/activitypub/linked_data_signature.rb @@ -32,7 +32,7 @@ class ActivityPub::LinkedDataSignature def sign!(creator, sign_with: nil) options = { - 'type' => 'RsaSignature2017', + 'type' => 'RsaSignature2017', 'creator' => ActivityPub::TagManager.instance.key_uri_for(creator), 'created' => Time.now.utc.iso8601, } diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb index 3d6b28ef5..a65a9565a 100644 --- a/app/lib/activitypub/tag_manager.rb +++ b/app/lib/activitypub/tag_manager.rb @@ -26,6 +26,7 @@ class ActivityPub::TagManager target.instance_actor? ? about_more_url(instance_actor: true) : short_account_url(target) when :note, :comment, :activity return activity_account_status_url(target.account, target) if target.reblog? + short_account_status_url(target.account, target) end end @@ -38,6 +39,7 @@ class ActivityPub::TagManager target.instance_actor? ? instance_actor_url : account_url(target) when :note, :comment, :activity return activity_account_status_url(target.account, target) if target.reblog? + account_status_url(target.account, target) when :emoji emoji_url(target) diff --git a/app/lib/ostatus/tag_manager.rb b/app/lib/ostatus/tag_manager.rb index 4f4501312..7d8131622 100644 --- a/app/lib/ostatus/tag_manager.rb +++ b/app/lib/ostatus/tag_manager.rb @@ -5,27 +5,27 @@ class OStatus::TagManager include RoutingHelper VERBS = { - post: 'http://activitystrea.ms/schema/1.0/post', - share: 'http://activitystrea.ms/schema/1.0/share', - favorite: 'http://activitystrea.ms/schema/1.0/favorite', - unfavorite: 'http://activitystrea.ms/schema/1.0/unfavorite', - delete: 'http://activitystrea.ms/schema/1.0/delete', - follow: 'http://activitystrea.ms/schema/1.0/follow', + post: 'http://activitystrea.ms/schema/1.0/post', + share: 'http://activitystrea.ms/schema/1.0/share', + favorite: 'http://activitystrea.ms/schema/1.0/favorite', + unfavorite: 'http://activitystrea.ms/schema/1.0/unfavorite', + delete: 'http://activitystrea.ms/schema/1.0/delete', + follow: 'http://activitystrea.ms/schema/1.0/follow', request_friend: 'http://activitystrea.ms/schema/1.0/request-friend', - authorize: 'http://activitystrea.ms/schema/1.0/authorize', - reject: 'http://activitystrea.ms/schema/1.0/reject', - unfollow: 'http://ostatus.org/schema/1.0/unfollow', - block: 'http://mastodon.social/schema/1.0/block', - unblock: 'http://mastodon.social/schema/1.0/unblock', + authorize: 'http://activitystrea.ms/schema/1.0/authorize', + reject: 'http://activitystrea.ms/schema/1.0/reject', + unfollow: 'http://ostatus.org/schema/1.0/unfollow', + block: 'http://mastodon.social/schema/1.0/block', + unblock: 'http://mastodon.social/schema/1.0/unblock', }.freeze TYPES = { - activity: 'http://activitystrea.ms/schema/1.0/activity', - note: 'http://activitystrea.ms/schema/1.0/note', - comment: 'http://activitystrea.ms/schema/1.0/comment', - person: 'http://activitystrea.ms/schema/1.0/person', + activity: 'http://activitystrea.ms/schema/1.0/activity', + note: 'http://activitystrea.ms/schema/1.0/note', + comment: 'http://activitystrea.ms/schema/1.0/comment', + person: 'http://activitystrea.ms/schema/1.0/person', collection: 'http://activitystrea.ms/schema/1.0/collection', - group: 'http://activitystrea.ms/schema/1.0/group', + group: 'http://activitystrea.ms/schema/1.0/group', }.freeze COLLECTIONS = { diff --git a/app/lib/request.rb b/app/lib/request.rb index be6a69b3f..85716f999 100644 --- a/app/lib/request.rb +++ b/app/lib/request.rb @@ -182,6 +182,7 @@ class Request contents = truncated_body(limit) raise Mastodon::LengthValidationError if contents.bytesize > limit + contents end end diff --git a/app/lib/settings/scoped_settings.rb b/app/lib/settings/scoped_settings.rb index 1e18d6d46..3ad57cc1e 100644 --- a/app/lib/settings/scoped_settings.rb +++ b/app/lib/settings/scoped_settings.rb @@ -34,6 +34,7 @@ module Settings Setting.default_settings.each do |key, default_value| next if records.key?(key) || default_value.is_a?(Hash) + records[key] = Setting.new(var: key, value: default_value) end @@ -54,6 +55,7 @@ module Settings if db_val default_value = ScopedSettings.default_settings[key] return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash) + db_val.value else ScopedSettings.default_settings[key] diff --git a/app/lib/status_filter.rb b/app/lib/status_filter.rb index b6c80b801..c0e6f3331 100644 --- a/app/lib/status_filter.rb +++ b/app/lib/status_filter.rb @@ -11,6 +11,7 @@ class StatusFilter def filtered? return false if !account.nil? && account.id == status.account_id + blocked_by_policy? || (account_present? && filtered_status?) || silenced_account? end diff --git a/app/lib/tag_manager.rb b/app/lib/tag_manager.rb index a1d12a654..7fbf4437d 100644 --- a/app/lib/tag_manager.rb +++ b/app/lib/tag_manager.rb @@ -25,6 +25,7 @@ class TagManager def local_url?(url) uri = Addressable::URI.parse(url).normalize return false unless uri.host + domain = uri.host + (uri.port ? ":#{uri.port}" : '') TagManager.instance.web_domain?(domain) diff --git a/app/lib/webfinger.rb b/app/lib/webfinger.rb index 42ddef47b..ae8a3b1ea 100644 --- a/app/lib/webfinger.rb +++ b/app/lib/webfinger.rb @@ -57,6 +57,7 @@ class Webfinger if res.code == 200 body = res.body_with_limit raise Webfinger::Error, "Request for #{@uri} returned empty response" if body.empty? + body elsif res.code == 404 && use_fallback body_from_host_meta diff --git a/app/models/account.rb b/app/models/account.rb index d33110d55..09c450f2a 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: accounts @@ -539,6 +540,7 @@ class Account < ApplicationRecord def ensure_keys! return unless local? && private_key.blank? && public_key.blank? + generate_keys save! end diff --git a/app/models/account/field.rb b/app/models/account/field.rb index 98c29726d..2bada6954 100644 --- a/app/models/account/field.rb +++ b/app/models/account/field.rb @@ -14,8 +14,8 @@ class Account::Field < ActiveModelSerializers::Model @account = account super( - name: sanitize(attributes['name']), - value: sanitize(attributes['value']), + name: sanitize(attributes['name']), + value: sanitize(attributes['value']), verified_at: attributes['verified_at']&.to_datetime, ) end diff --git a/app/models/account_conversation.rb b/app/models/account_conversation.rb index 45e74bbeb..b3ddc04c1 100644 --- a/app/models/account_conversation.rb +++ b/app/models/account_conversation.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_conversations @@ -107,6 +108,7 @@ class AccountConversation < ApplicationRecord def push_to_streaming_api return if destroyed? || !subscribed_to_timeline? + PushConversationWorker.perform_async(id) end diff --git a/app/models/account_domain_block.rb b/app/models/account_domain_block.rb index 3aaffde9a..af1e6a68d 100644 --- a/app/models/account_domain_block.rb +++ b/app/models/account_domain_block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_domain_blocks diff --git a/app/models/account_moderation_note.rb b/app/models/account_moderation_note.rb index 22e312bb2..ff399bab0 100644 --- a/app/models/account_moderation_note.rb +++ b/app/models/account_moderation_note.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_moderation_notes diff --git a/app/models/account_note.rb b/app/models/account_note.rb index b338bc92f..9bc704d98 100644 --- a/app/models/account_note.rb +++ b/app/models/account_note.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_notes diff --git a/app/models/account_pin.rb b/app/models/account_pin.rb index b51d3d4cd..6c78e8c44 100644 --- a/app/models/account_pin.rb +++ b/app/models/account_pin.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_pins diff --git a/app/models/account_stat.rb b/app/models/account_stat.rb index a5d71a5b8..834f8ba4c 100644 --- a/app/models/account_stat.rb +++ b/app/models/account_stat.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_stats diff --git a/app/models/account_summary.rb b/app/models/account_summary.rb index 3a3cebc55..0d8835b83 100644 --- a/app/models/account_summary.rb +++ b/app/models/account_summary.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_summaries diff --git a/app/models/account_warning.rb b/app/models/account_warning.rb index a181cd18d..4f8cc5320 100644 --- a/app/models/account_warning.rb +++ b/app/models/account_warning.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_warnings @@ -17,13 +18,13 @@ class AccountWarning < ApplicationRecord enum action: { - none: 0, - disable: 1_000, + none: 0, + disable: 1_000, mark_statuses_as_sensitive: 1_250, - delete_statuses: 1_500, - sensitive: 2_000, - silence: 3_000, - suspend: 4_000, + delete_statuses: 1_500, + sensitive: 2_000, + silence: 3_000, + suspend: 4_000, }, _suffix: :action before_validation :before_validate diff --git a/app/models/admin/import.rb b/app/models/admin/import.rb index fecde4878..0fd4bdb82 100644 --- a/app/models/admin/import.rb +++ b/app/models/admin/import.rb @@ -56,6 +56,7 @@ class Admin::Import def validate_data return if data.nil? + errors.add(:data, I18n.t('imports.errors.over_rows_processing_limit', count: ROWS_PROCESSING_LIMIT)) if csv_row_count > ROWS_PROCESSING_LIMIT rescue CSV::MalformedCSVError => e errors.add(:data, I18n.t('imports.errors.invalid_csv_file', error: e.message)) diff --git a/app/models/backup.rb b/app/models/backup.rb index 277b9395b..bec3cbfe5 100644 --- a/app/models/backup.rb +++ b/app/models/backup.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: backups diff --git a/app/models/block.rb b/app/models/block.rb index bf3e07600..b42c1569b 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: blocks diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb index 6334ef0df..04b660372 100644 --- a/app/models/bookmark.rb +++ b/app/models/bookmark.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: bookmarks diff --git a/app/models/canonical_email_block.rb b/app/models/canonical_email_block.rb index 1eb69ac67..d09df6f5e 100644 --- a/app/models/canonical_email_block.rb +++ b/app/models/canonical_email_block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: canonical_email_blocks diff --git a/app/models/conversation.rb b/app/models/conversation.rb index 4dfaea889..5de259962 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: conversations diff --git a/app/models/conversation_mute.rb b/app/models/conversation_mute.rb index 52c1a33e0..31f8e1966 100644 --- a/app/models/conversation_mute.rb +++ b/app/models/conversation_mute.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: conversation_mutes diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb index 304805659..3d7900226 100644 --- a/app/models/custom_emoji.rb +++ b/app/models/custom_emoji.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: custom_emojis diff --git a/app/models/custom_filter.rb b/app/models/custom_filter.rb index 781bf4db8..d85e196e9 100644 --- a/app/models/custom_filter.rb +++ b/app/models/custom_filter.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: custom_filters @@ -101,6 +102,7 @@ class CustomFilter < ApplicationRecord status_matches = [status.id, status.reblog_of_id].compact & rules[:status_ids] if rules[:status_ids].present? next if keyword_matches.blank? && status_matches.blank? + FilterResultPresenter.new(filter: filter, keyword_matches: keyword_matches, status_matches: status_matches) end end @@ -111,6 +113,7 @@ class CustomFilter < ApplicationRecord def invalidate_cache! return unless @should_invalidate_cache + @should_invalidate_cache = false Rails.cache.delete("filters:v3:#{account_id}") diff --git a/app/models/custom_filter_keyword.rb b/app/models/custom_filter_keyword.rb index e0d0289ae..3158b3b79 100644 --- a/app/models/custom_filter_keyword.rb +++ b/app/models/custom_filter_keyword.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: custom_filter_keywords diff --git a/app/models/custom_filter_status.rb b/app/models/custom_filter_status.rb index e748d6963..0a5650204 100644 --- a/app/models/custom_filter_status.rb +++ b/app/models/custom_filter_status.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: custom_filter_statuses diff --git a/app/models/device.rb b/app/models/device.rb index 97d0d2774..5dc6cf1e6 100644 --- a/app/models/device.rb +++ b/app/models/device.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: devices diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb index 190f5ba2e..fbb045416 100644 --- a/app/models/domain_block.rb +++ b/app/models/domain_block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: domain_blocks diff --git a/app/models/email_domain_block.rb b/app/models/email_domain_block.rb index 3a56e4f2a..276e7d31a 100644 --- a/app/models/email_domain_block.rb +++ b/app/models/email_domain_block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: email_domain_blocks diff --git a/app/models/encrypted_message.rb b/app/models/encrypted_message.rb index 7b4e32283..3e7e95594 100644 --- a/app/models/encrypted_message.rb +++ b/app/models/encrypted_message.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: encrypted_messages diff --git a/app/models/favourite.rb b/app/models/favourite.rb index 2f355739a..042f72bea 100644 --- a/app/models/favourite.rb +++ b/app/models/favourite.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: favourites @@ -38,6 +39,7 @@ class Favourite < ApplicationRecord def decrement_cache_counters return if association(:status).loaded? && status.marked_for_destruction? + status&.decrement_count!(:favourites_count) end diff --git a/app/models/featured_tag.rb b/app/models/featured_tag.rb index 70f949b6a..587dcf991 100644 --- a/app/models/featured_tag.rb +++ b/app/models/featured_tag.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: featured_tags diff --git a/app/models/follow.rb b/app/models/follow.rb index e5cecbbc1..108f5c5d5 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: follows diff --git a/app/models/follow_recommendation.rb b/app/models/follow_recommendation.rb index 501f8ecb6..602d32985 100644 --- a/app/models/follow_recommendation.rb +++ b/app/models/follow_recommendation.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: follow_recommendations diff --git a/app/models/follow_recommendation_suppression.rb b/app/models/follow_recommendation_suppression.rb index 170506b85..a9dbbfc18 100644 --- a/app/models/follow_recommendation_suppression.rb +++ b/app/models/follow_recommendation_suppression.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: follow_recommendation_suppressions diff --git a/app/models/follow_request.rb b/app/models/follow_request.rb index 9034250c0..78f79c18f 100644 --- a/app/models/follow_request.rb +++ b/app/models/follow_request.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: follow_requests diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 95c53084a..de965cb0b 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -128,6 +128,7 @@ class Form::AdminSettings def validate_site_uploads UPLOAD_KEYS.each do |key| next unless instance_variable_defined?("@#{key}") + upload = instance_variable_get("@#{key}") next if upload.valid? diff --git a/app/models/identity.rb b/app/models/identity.rb index 8cc65aef4..6f10fed4d 100644 --- a/app/models/identity.rb +++ b/app/models/identity.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: identities diff --git a/app/models/import.rb b/app/models/import.rb index cd33eb07b..21634005e 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: imports diff --git a/app/models/instance.rb b/app/models/instance.rb index edbf02a6d..1f96d3728 100644 --- a/app/models/instance.rb +++ b/app/models/instance.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: instances diff --git a/app/models/invite.rb b/app/models/invite.rb index 7ea4e2f98..8e816cef0 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: invites diff --git a/app/models/ip_block.rb b/app/models/ip_block.rb index 31343f0e1..99783050b 100644 --- a/app/models/ip_block.rb +++ b/app/models/ip_block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: ip_blocks diff --git a/app/models/list.rb b/app/models/list.rb index 7b8cf6636..bd1bdbd24 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: lists diff --git a/app/models/list_account.rb b/app/models/list_account.rb index 785923c4c..a5767d3d8 100644 --- a/app/models/list_account.rb +++ b/app/models/list_account.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: list_accounts diff --git a/app/models/login_activity.rb b/app/models/login_activity.rb index 52a0fd01d..2b7b37f8e 100644 --- a/app/models/login_activity.rb +++ b/app/models/login_activity.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: login_activities diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index c6f2352e0..08abd4e43 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: media_attachments @@ -372,7 +373,7 @@ class MediaAttachment < ApplicationRecord return {} if width.nil? { - width: width, + width: width, height: height, size: "#{width}x#{height}", aspect: width.to_f / height, diff --git a/app/models/mention.rb b/app/models/mention.rb index d01a88e32..2348b2905 100644 --- a/app/models/mention.rb +++ b/app/models/mention.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: mentions diff --git a/app/models/mute.rb b/app/models/mute.rb index 578345ef6..8fc542262 100644 --- a/app/models/mute.rb +++ b/app/models/mute.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: mutes diff --git a/app/models/notification.rb b/app/models/notification.rb index 01155c363..3eaf557b0 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: notifications @@ -19,12 +20,12 @@ class Notification < ApplicationRecord include Paginable LEGACY_TYPE_CLASS_MAP = { - 'Mention' => :mention, - 'Status' => :reblog, - 'Follow' => :follow, + 'Mention' => :mention, + 'Status' => :reblog, + 'Follow' => :follow, 'FollowRequest' => :follow_request, - 'Favourite' => :favourite, - 'Poll' => :poll, + 'Favourite' => :favourite, + 'Poll' => :poll, }.freeze TYPES = %i( diff --git a/app/models/one_time_key.rb b/app/models/one_time_key.rb index 8ada34824..23604e2f7 100644 --- a/app/models/one_time_key.rb +++ b/app/models/one_time_key.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: one_time_keys diff --git a/app/models/poll.rb b/app/models/poll.rb index af3b09315..dd35e953b 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: polls @@ -74,9 +75,9 @@ class Poll < ApplicationRecord def initialize(poll, id, title, votes_count) super( - poll: poll, - id: id, - title: title, + poll: poll, + id: id, + title: title, votes_count: votes_count, ) end @@ -105,6 +106,7 @@ class Poll < ApplicationRecord def reset_parent_cache return if status_id.nil? + Rails.cache.delete("statuses/#{status_id}") end diff --git a/app/models/poll_vote.rb b/app/models/poll_vote.rb index ad24eb691..00eaedd12 100644 --- a/app/models/poll_vote.rb +++ b/app/models/poll_vote.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: poll_votes diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb index d25fe6dad..6bce16562 100644 --- a/app/models/preview_card.rb +++ b/app/models/preview_card.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: preview_cards diff --git a/app/models/preview_card_provider.rb b/app/models/preview_card_provider.rb index d61fe6020..1dd95fc91 100644 --- a/app/models/preview_card_provider.rb +++ b/app/models/preview_card_provider.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: preview_card_providers diff --git a/app/models/relay.rb b/app/models/relay.rb index e9c425743..a5fa03a99 100644 --- a/app/models/relay.rb +++ b/app/models/relay.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: relays diff --git a/app/models/report.rb b/app/models/report.rb index fe6c292c5..a9940459d 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: reports diff --git a/app/models/report_note.rb b/app/models/report_note.rb index 6d7167e0e..74b46027e 100644 --- a/app/models/report_note.rb +++ b/app/models/report_note.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: report_notes diff --git a/app/models/session_activation.rb b/app/models/session_activation.rb index 0b7fa6fe4..10c3a6c25 100644 --- a/app/models/session_activation.rb +++ b/app/models/session_activation.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: session_activations @@ -51,6 +52,7 @@ class SessionActivation < ApplicationRecord def deactivate(id) return unless id + where(session_id: id).destroy_all end diff --git a/app/models/setting.rb b/app/models/setting.rb index c6558d692..3bdc6ffb4 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: settings @@ -30,6 +31,7 @@ class Setting < RailsSettings::Base default_value = default_settings[key] return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash) + db_val.value else default_settings[key] @@ -43,6 +45,7 @@ class Setting < RailsSettings::Base default_settings.each do |key, default_value| next if records.key?(key) || default_value.is_a?(Hash) + records[key] = Setting.new(var: key, value: default_value) end @@ -51,6 +54,7 @@ class Setting < RailsSettings::Base def default_settings return {} unless RailsSettings::Default.enabled? + RailsSettings::Default.instance end end diff --git a/app/models/site_upload.rb b/app/models/site_upload.rb index 167131fdd..e17668110 100644 --- a/app/models/site_upload.rb +++ b/app/models/site_upload.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: site_uploads diff --git a/app/models/status.rb b/app/models/status.rb index 44a297a08..2eb47d72c 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: statuses diff --git a/app/models/status_edit.rb b/app/models/status_edit.rb index dd2d5fc1e..683441bb5 100644 --- a/app/models/status_edit.rb +++ b/app/models/status_edit.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: status_edits @@ -45,6 +46,7 @@ class StatusEdit < ApplicationRecord def emojis return @emojis if defined?(@emojis) + @emojis = CustomEmoji.from_text([spoiler_text, text].join(' '), status.account.domain) end diff --git a/app/models/status_pin.rb b/app/models/status_pin.rb index 93a0ea1c0..dae4a5b4e 100644 --- a/app/models/status_pin.rb +++ b/app/models/status_pin.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: status_pins diff --git a/app/models/status_stat.rb b/app/models/status_stat.rb index 437861d1c..d101cc178 100644 --- a/app/models/status_stat.rb +++ b/app/models/status_stat.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: status_stats diff --git a/app/models/tag.rb b/app/models/tag.rb index 98001d60a..554a92d90 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: tags diff --git a/app/models/unavailable_domain.rb b/app/models/unavailable_domain.rb index dfc0ef14e..c3f2f20e9 100644 --- a/app/models/unavailable_domain.rb +++ b/app/models/unavailable_domain.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: unavailable_domains diff --git a/app/models/user.rb b/app/models/user.rb index c767f8984..5e106dee5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: users @@ -492,12 +493,14 @@ class User < ApplicationRecord def sanitize_languages return if chosen_languages.nil? + chosen_languages.reject!(&:blank?) self.chosen_languages = nil if chosen_languages.empty? end def sanitize_role return if role.nil? + self.role = nil if role.everyone? end @@ -516,6 +519,7 @@ class User < ApplicationRecord def notify_staff_about_pending_account! User.those_who_can(:manage_users).includes(:account).find_each do |u| next unless u.allows_pending_account_emails? + AdminMailer.new_pending_account(u.account, self).deliver_later end end diff --git a/app/models/user_ip.rb b/app/models/user_ip.rb index 1da615762..38287c2a6 100644 --- a/app/models/user_ip.rb +++ b/app/models/user_ip.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: user_ips diff --git a/app/models/user_role.rb b/app/models/user_role.rb index 74dfdc220..a1b91dc0f 100644 --- a/app/models/user_role.rb +++ b/app/models/user_role.rb @@ -163,6 +163,7 @@ class UserRole < ApplicationRecord def in_permissions?(privilege) raise ArgumentError, "Unknown privilege: #{privilege}" unless FLAGS.key?(privilege) + computed_permissions & FLAGS[privilege] == FLAGS[privilege] end @@ -172,6 +173,7 @@ class UserRole < ApplicationRecord def validate_own_role_edition return unless defined?(@current_account) && @current_account.user_role.id == id + errors.add(:permissions_as_keys, :own_role) if permissions_changed? errors.add(:position, :own_role) if position_changed? end diff --git a/app/models/web/push_subscription.rb b/app/models/web/push_subscription.rb index dfaadf5cc..0ffbe068e 100644 --- a/app/models/web/push_subscription.rb +++ b/app/models/web/push_subscription.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: web_push_subscriptions diff --git a/app/models/web/setting.rb b/app/models/web/setting.rb index 99588d26c..3d5efe664 100644 --- a/app/models/web/setting.rb +++ b/app/models/web/setting.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: web_settings diff --git a/app/models/webauthn_credential.rb b/app/models/webauthn_credential.rb index 48abfc1d4..4fa31ece5 100644 --- a/app/models/webauthn_credential.rb +++ b/app/models/webauthn_credential.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: webauthn_credentials diff --git a/app/presenters/account_relationships_presenter.rb b/app/presenters/account_relationships_presenter.rb index ab8bac412..5d2b5435d 100644 --- a/app/presenters/account_relationships_presenter.rb +++ b/app/presenters/account_relationships_presenter.rb @@ -70,16 +70,16 @@ class AccountRelationshipsPresenter def cache_uncached! @uncached_account_ids.each do |account_id| maps_for_account = { - following: { account_id => following[account_id] }, - followed_by: { account_id => followed_by[account_id] }, - blocking: { account_id => blocking[account_id] }, - blocked_by: { account_id => blocked_by[account_id] }, - muting: { account_id => muting[account_id] }, - requested: { account_id => requested[account_id] }, - requested_by: { account_id => requested_by[account_id] }, + following: { account_id => following[account_id] }, + followed_by: { account_id => followed_by[account_id] }, + blocking: { account_id => blocking[account_id] }, + blocked_by: { account_id => blocked_by[account_id] }, + muting: { account_id => muting[account_id] }, + requested: { account_id => requested[account_id] }, + requested_by: { account_id => requested_by[account_id] }, domain_blocking: { account_id => domain_blocking[account_id] }, - endorsed: { account_id => endorsed[account_id] }, - account_note: { account_id => account_note[account_id] }, + endorsed: { account_id => endorsed[account_id] }, + account_note: { account_id => account_note[account_id] }, } Rails.cache.write("relationship:#{@current_account_id}:#{account_id}", maps_for_account, expires_in: 1.day) diff --git a/app/services/activitypub/fetch_remote_actor_service.rb b/app/services/activitypub/fetch_remote_actor_service.rb index e8992b845..ee0eaff08 100644 --- a/app/services/activitypub/fetch_remote_actor_service.rb +++ b/app/services/activitypub/fetch_remote_actor_service.rb @@ -50,6 +50,7 @@ class ActivityPub::FetchRemoteActorService < BaseService if @username.casecmp(confirmed_username).zero? && @domain.casecmp(confirmed_domain).zero? raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.link('self', 'href') != @uri + return end diff --git a/app/services/activitypub/fetch_remote_status_service.rb b/app/services/activitypub/fetch_remote_status_service.rb index aea80f078..ab0acf7f0 100644 --- a/app/services/activitypub/fetch_remote_status_service.rb +++ b/app/services/activitypub/fetch_remote_status_service.rb @@ -56,6 +56,7 @@ class ActivityPub::FetchRemoteStatusService < BaseService def trustworthy_attribution?(uri, attributed_to) return false if uri.nil? || attributed_to.nil? + Addressable::URI.parse(uri).normalized_host.casecmp(Addressable::URI.parse(attributed_to).normalized_host).zero? end diff --git a/app/services/activitypub/fetch_replies_service.rb b/app/services/activitypub/fetch_replies_service.rb index 4128df9ca..3fe150ba2 100644 --- a/app/services/activitypub/fetch_replies_service.rb +++ b/app/services/activitypub/fetch_replies_service.rb @@ -36,6 +36,7 @@ class ActivityPub::FetchRepliesService < BaseService return collection_or_uri if collection_or_uri.is_a?(Hash) return unless @allow_synchronous_requests return if invalid_origin?(collection_or_uri) + fetch_resource_without_id_validation(collection_or_uri, nil, true) end diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 2da9096c7..603e4cf48 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -226,6 +226,7 @@ class ActivityPub::ProcessAccountService < BaseService def property_values return unless @json['attachment'].is_a?(Array) + as_array(@json['attachment']).select { |attachment| attachment['type'] == 'PropertyValue' }.map { |attachment| attachment.slice('name', 'value') } end @@ -289,6 +290,7 @@ class ActivityPub::ProcessAccountService < BaseService def domain_block return @domain_block if defined?(@domain_block) + @domain_block = DomainBlock.rule_for(@domain) end diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb index dc7fe8855..6fdc92a17 100644 --- a/app/services/favourite_service.rb +++ b/app/services/favourite_service.rb @@ -40,6 +40,7 @@ class FavouriteService < BaseService def bump_potential_friendship(account, status) ActivityTracker.increment('activity:interactions') return if account.following?(status.account_id) + PotentialFriendshipTracker.record(account.id, status.account_id, :favourite) end diff --git a/app/services/keys/claim_service.rb b/app/services/keys/claim_service.rb index 0451c3cb1..ebce9cce7 100644 --- a/app/services/keys/claim_service.rb +++ b/app/services/keys/claim_service.rb @@ -9,10 +9,10 @@ class Keys::ClaimService < BaseService def initialize(account, device_id, key_attributes = {}) super( - account: account, + account: account, device_id: device_id, - key_id: key_attributes[:key_id], - key: key_attributes[:key], + key_id: key_attributes[:key_id], + key: key_attributes[:key], signature: key_attributes[:signature], ) end diff --git a/app/services/keys/query_service.rb b/app/services/keys/query_service.rb index 404854c9f..14c9d9205 100644 --- a/app/services/keys/query_service.rb +++ b/app/services/keys/query_service.rb @@ -23,9 +23,9 @@ class Keys::QueryService < BaseService def initialize(attributes = {}) super( - device_id: attributes[:device_id], - name: attributes[:name], - identity_key: attributes[:identity_key], + device_id: attributes[:device_id], + name: attributes[:name], + identity_key: attributes[:identity_key], fingerprint_key: attributes[:fingerprint_key], ) @claim_url = attributes[:claim_url] diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb index c7454fc60..4c7acbcac 100644 --- a/app/services/notify_service.rb +++ b/app/services/notify_service.rb @@ -31,6 +31,7 @@ class NotifyService < BaseService def following_sender? return @following_sender if defined?(@following_sender) + @following_sender = @recipient.following?(@notification.from_account) || @recipient.requested?(@notification.from_account) end diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 258af8827..ea27f374e 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -86,6 +86,7 @@ class PostStatusService < BaseService def safeguard_mentions!(status) return if @options[:allowed_mentions].nil? + expected_account_ids = @options[:allowed_mentions].map(&:to_i) unexpected_accounts = status.mentions.map(&:account).to_a.reject { |mentioned_account| expected_account_ids.include?(mentioned_account.id) } @@ -175,8 +176,10 @@ class PostStatusService < BaseService def bump_potential_friendship! return if !@status.reply? || @account.id == @status.in_reply_to_account_id + ActivityTracker.increment('activity:interactions') return if @account.following?(@status.in_reply_to_account_id) + PotentialFriendshipTracker.record(@account.id, @status.in_reply_to_account_id, :reply) end diff --git a/app/services/vote_service.rb b/app/services/vote_service.rb index 114ec285c..9ebf5a98d 100644 --- a/app/services/vote_service.rb +++ b/app/services/vote_service.rb @@ -44,11 +44,13 @@ class VoteService < BaseService def distribute_poll! return if @poll.hide_totals? + ActivityPub::DistributePollUpdateWorker.perform_in(3.minutes, @poll.status.id) end def queue_final_poll_check! return unless @poll.expires? + PollExpirationNotifyWorker.perform_at(@poll.expires_at + 5.minutes, @poll.id) end diff --git a/app/validators/follow_limit_validator.rb b/app/validators/follow_limit_validator.rb index 409bf0176..c619cb9a3 100644 --- a/app/validators/follow_limit_validator.rb +++ b/app/validators/follow_limit_validator.rb @@ -6,6 +6,7 @@ class FollowLimitValidator < ActiveModel::Validator def validate(follow) return if follow.account.nil? || !follow.account.local? + follow.errors.add(:base, I18n.t('users.follow_limit_reached', limit: self.class.limit_for_account(follow.account))) if limit_reached?(follow.account) end diff --git a/app/validators/unreserved_username_validator.rb b/app/validators/unreserved_username_validator.rb index 974f3ba62..f82f4b91d 100644 --- a/app/validators/unreserved_username_validator.rb +++ b/app/validators/unreserved_username_validator.rb @@ -13,12 +13,14 @@ class UnreservedUsernameValidator < ActiveModel::Validator def pam_controlled? return false unless Devise.pam_authentication && Devise.pam_controlled_service + Rpam2.account(Devise.pam_controlled_service, @username).present? end def reserved_username? return true if pam_controlled? return false unless Setting.reserved_usernames + Setting.reserved_usernames.include?(@username.downcase) end end diff --git a/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb b/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb index cc5b6e137..09e0b37f0 100644 --- a/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb +++ b/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb @@ -62,6 +62,7 @@ class Scheduler::AccountsStatusesCleanupScheduler # The idea here is to loop through all policies at least once until the budget is exhausted # and start back after the last processed account otherwise break if budget.zero? || (num_processed_accounts.zero? && first_policy_id.nil?) + first_policy_id = nil end end @@ -73,6 +74,7 @@ class Scheduler::AccountsStatusesCleanupScheduler def under_load? return true if Sidekiq::Stats.new.retry_size > MAX_RETRY_SIZE + queue_under_load?('default', MAX_DEFAULT_SIZE, MAX_DEFAULT_LATENCY) || queue_under_load?('push', MAX_PUSH_SIZE, MAX_PUSH_LATENCY) || queue_under_load?('pull', MAX_PULL_SIZE, MAX_PULL_LATENCY) end diff --git a/app/workers/web/push_notification_worker.rb b/app/workers/web/push_notification_worker.rb index 1ed5bb9e0..7e9691aab 100644 --- a/app/workers/web/push_notification_worker.rb +++ b/app/workers/web/push_notification_worker.rb @@ -22,13 +22,13 @@ class Web::PushNotificationWorker request = Request.new(:post, @subscription.endpoint, body: payload.fetch(:ciphertext), http_client: http_client) request.add_headers( - 'Content-Type' => 'application/octet-stream', - 'Ttl' => TTL, - 'Urgency' => URGENCY, + 'Content-Type' => 'application/octet-stream', + 'Ttl' => TTL, + 'Urgency' => URGENCY, 'Content-Encoding' => 'aesgcm', - 'Encryption' => "salt=#{Webpush.encode64(payload.fetch(:salt)).delete('=')}", - 'Crypto-Key' => "dh=#{Webpush.encode64(payload.fetch(:server_public_key)).delete('=')};#{@subscription.crypto_key_header}", - 'Authorization' => @subscription.authorization_header + 'Encryption' => "salt=#{Webpush.encode64(payload.fetch(:salt)).delete('=')}", + 'Crypto-Key' => "dh=#{Webpush.encode64(payload.fetch(:server_public_key)).delete('=')};#{@subscription.crypto_key_header}", + 'Authorization' => @subscription.authorization_header ) request.perform do |response| diff --git a/config.ru b/config.ru index 5e071f530..afd13e211 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,5 @@ # frozen_string_literal: true + # This file is used by Rack-based servers to start the application. require File.expand_path('config/environment', __dir__) diff --git a/db/migrate/20190314181829_migrate_open_registrations_setting.rb b/db/migrate/20190314181829_migrate_open_registrations_setting.rb index e5fe95009..d2f6bf2c1 100644 --- a/db/migrate/20190314181829_migrate_open_registrations_setting.rb +++ b/db/migrate/20190314181829_migrate_open_registrations_setting.rb @@ -2,6 +2,7 @@ class MigrateOpenRegistrationsSetting < ActiveRecord::Migration[5.2] def up open_registrations = Setting.find_by(var: 'open_registrations') return if open_registrations.nil? || open_registrations.value + setting = Setting.where(var: 'registrations_mode').first_or_initialize(var: 'registrations_mode') setting.update(value: 'none') end @@ -9,6 +10,7 @@ class MigrateOpenRegistrationsSetting < ActiveRecord::Migration[5.2] def down registrations_mode = Setting.find_by(var: 'registrations_mode') return if registrations_mode.nil? + setting = Setting.where(var: 'open_registrations').first_or_initialize(var: 'open_registrations') setting.update(value: registrations_mode.value == 'open') end diff --git a/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb b/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb index 19e86fbfe..1c18b85cb 100644 --- a/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb +++ b/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb @@ -8,6 +8,7 @@ class PreserveOldLayoutForExistingUsers < ActiveRecord::Migration[5.2] User.where(User.arel_table[:current_sign_in_at].gteq(1.month.ago)).find_each do |user| next if Setting.unscoped.where(thing_type: 'User', thing_id: user.id, var: 'advanced_layout').exists? + user.settings.advanced_layout = true end end diff --git a/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb b/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb index 7f6a2c6dd..a3cc854d7 100644 --- a/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb +++ b/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb @@ -11,6 +11,7 @@ class AddCaseInsensitiveBtreeIndexToTags < ActiveRecord::Migration[5.2] rescue ActiveRecord::StatementInvalid => e remove_index :tags, name: 'index_tags_on_name_lower_btree' raise CorruptionError, 'index_tags_on_name_lower_btree' if e.is_a?(ActiveRecord::RecordNotUnique) + raise e end diff --git a/db/migrate/20220613110834_add_action_to_custom_filters.rb b/db/migrate/20220613110834_add_action_to_custom_filters.rb index 9427a66fc..c1daf3c94 100644 --- a/db/migrate/20220613110834_add_action_to_custom_filters.rb +++ b/db/migrate/20220613110834_add_action_to_custom_filters.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require Rails.root.join('lib', 'mastodon', 'migration_helpers') class AddActionToCustomFilters < ActiveRecord::Migration[6.1] diff --git a/db/post_migrate/20200917193528_migrate_notifications_type.rb b/db/post_migrate/20200917193528_migrate_notifications_type.rb index 88e423084..9dc9ecd48 100644 --- a/db/post_migrate/20200917193528_migrate_notifications_type.rb +++ b/db/post_migrate/20200917193528_migrate_notifications_type.rb @@ -4,12 +4,12 @@ class MigrateNotificationsType < ActiveRecord::Migration[5.2] disable_ddl_transaction! TYPES_TO_MIGRATE = { - 'Mention' => :mention, - 'Status' => :reblog, - 'Follow' => :follow, + 'Mention' => :mention, + 'Status' => :reblog, + 'Follow' => :follow, 'FollowRequest' => :follow_request, - 'Favourite' => :favourite, - 'Poll' => :poll, + 'Favourite' => :favourite, + 'Poll' => :poll, }.freeze def up diff --git a/db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb b/db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb index 7ef0749e5..99c3366a2 100644 --- a/db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb +++ b/db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require Rails.root.join('lib', 'mastodon', 'migration_helpers') class RemoveWholeWordFromCustomFilters < ActiveRecord::Migration[6.1] diff --git a/db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb b/db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb index 6ed8bcfee..1c366ee53 100644 --- a/db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb +++ b/db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require Rails.root.join('lib', 'mastodon', 'migration_helpers') class RemoveIrreversibleFromCustomFilters < ActiveRecord::Migration[6.1] diff --git a/db/post_migrate/20221101190723_backfill_admin_action_logs.rb b/db/post_migrate/20221101190723_backfill_admin_action_logs.rb index 6ab76a8f7..fa2ddbbca 100644 --- a/db/post_migrate/20221101190723_backfill_admin_action_logs.rb +++ b/db/post_migrate/20221101190723_backfill_admin_action_logs.rb @@ -79,11 +79,13 @@ class BackfillAdminActionLogs < ActiveRecord::Migration[6.1] safety_assured do AdminActionLog.includes(:account).where(target_type: 'Account', human_identifier: nil).find_each do |log| next if log.account.nil? + log.update_attribute('human_identifier', log.account.acct) end AdminActionLog.includes(user: :account).where(target_type: 'User', human_identifier: nil).find_each do |log| next if log.user.nil? + log.update_attribute('human_identifier', log.user.account.acct) log.update_attribute('route_param', log.user.account_id) end @@ -92,57 +94,68 @@ class BackfillAdminActionLogs < ActiveRecord::Migration[6.1] AdminActionLog.includes(:domain_block).where(target_type: 'DomainBlock').find_each do |log| next if log.domain_block.nil? + log.update_attribute('human_identifier', log.domain_block.domain) end AdminActionLog.includes(:domain_allow).where(target_type: 'DomainAllow').find_each do |log| next if log.domain_allow.nil? + log.update_attribute('human_identifier', log.domain_allow.domain) end AdminActionLog.includes(:email_domain_block).where(target_type: 'EmailDomainBlock').find_each do |log| next if log.email_domain_block.nil? + log.update_attribute('human_identifier', log.email_domain_block.domain) end AdminActionLog.includes(:unavailable_domain).where(target_type: 'UnavailableDomain').find_each do |log| next if log.unavailable_domain.nil? + log.update_attribute('human_identifier', log.unavailable_domain.domain) end AdminActionLog.includes(status: :account).where(target_type: 'Status', human_identifier: nil).find_each do |log| next if log.status.nil? + log.update_attribute('human_identifier', log.status.account.acct) log.update_attribute('permalink', log.status.uri) end AdminActionLog.includes(account_warning: :account).where(target_type: 'AccountWarning', human_identifier: nil).find_each do |log| next if log.account_warning.nil? + log.update_attribute('human_identifier', log.account_warning.account.acct) end AdminActionLog.includes(:announcement).where(target_type: 'Announcement', human_identifier: nil).find_each do |log| next if log.announcement.nil? + log.update_attribute('human_identifier', log.announcement.text) end AdminActionLog.includes(:ip_block).where(target_type: 'IpBlock', human_identifier: nil).find_each do |log| next if log.ip_block.nil? + log.update_attribute('human_identifier', "#{log.ip_block.ip}/#{log.ip_block.ip.prefix}") end AdminActionLog.includes(:custom_emoji).where(target_type: 'CustomEmoji', human_identifier: nil).find_each do |log| next if log.custom_emoji.nil? + log.update_attribute('human_identifier', log.custom_emoji.shortcode) end AdminActionLog.includes(:canonical_email_block).where(target_type: 'CanonicalEmailBlock', human_identifier: nil).find_each do |log| next if log.canonical_email_block.nil? + log.update_attribute('human_identifier', log.canonical_email_block.canonical_email_hash) end AdminActionLog.includes(appeal: :account).where(target_type: 'Appeal', human_identifier: nil).find_each do |log| next if log.appeal.nil? + log.update_attribute('human_identifier', log.appeal.account.acct) log.update_attribute('route_param', log.appeal.account_warning_id) end diff --git a/db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb b/db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb index 42b7f3625..9c7ac7120 100644 --- a/db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb +++ b/db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb @@ -79,11 +79,13 @@ class BackfillAdminActionLogsAgain < ActiveRecord::Migration[6.1] safety_assured do AdminActionLog.includes(:account).where(target_type: 'Account', human_identifier: nil).find_each do |log| next if log.account.nil? + log.update_attribute('human_identifier', log.account.acct) end AdminActionLog.includes(user: :account).where(target_type: 'User', human_identifier: nil).find_each do |log| next if log.user.nil? + log.update_attribute('human_identifier', log.user.account.acct) log.update_attribute('route_param', log.user.account_id) end @@ -92,57 +94,68 @@ class BackfillAdminActionLogsAgain < ActiveRecord::Migration[6.1] AdminActionLog.includes(:domain_block).where(target_type: 'DomainBlock').find_each do |log| next if log.domain_block.nil? + log.update_attribute('human_identifier', log.domain_block.domain) end AdminActionLog.includes(:domain_allow).where(target_type: 'DomainAllow').find_each do |log| next if log.domain_allow.nil? + log.update_attribute('human_identifier', log.domain_allow.domain) end AdminActionLog.includes(:email_domain_block).where(target_type: 'EmailDomainBlock').find_each do |log| next if log.email_domain_block.nil? + log.update_attribute('human_identifier', log.email_domain_block.domain) end AdminActionLog.includes(:unavailable_domain).where(target_type: 'UnavailableDomain').find_each do |log| next if log.unavailable_domain.nil? + log.update_attribute('human_identifier', log.unavailable_domain.domain) end AdminActionLog.includes(status: :account).where(target_type: 'Status', human_identifier: nil).find_each do |log| next if log.status.nil? + log.update_attribute('human_identifier', log.status.account.acct) log.update_attribute('permalink', log.status.uri) end AdminActionLog.includes(account_warning: :account).where(target_type: 'AccountWarning', human_identifier: nil).find_each do |log| next if log.account_warning.nil? + log.update_attribute('human_identifier', log.account_warning.account.acct) end AdminActionLog.includes(:announcement).where(target_type: 'Announcement', human_identifier: nil).find_each do |log| next if log.announcement.nil? + log.update_attribute('human_identifier', log.announcement.text) end AdminActionLog.includes(:ip_block).where(target_type: 'IpBlock', human_identifier: nil).find_each do |log| next if log.ip_block.nil? + log.update_attribute('human_identifier', "#{log.ip_block.ip}/#{log.ip_block.ip.prefix}") end AdminActionLog.includes(:custom_emoji).where(target_type: 'CustomEmoji', human_identifier: nil).find_each do |log| next if log.custom_emoji.nil? + log.update_attribute('human_identifier', log.custom_emoji.shortcode) end AdminActionLog.includes(:canonical_email_block).where(target_type: 'CanonicalEmailBlock', human_identifier: nil).find_each do |log| next if log.canonical_email_block.nil? + log.update_attribute('human_identifier', log.canonical_email_block.canonical_email_hash) end AdminActionLog.includes(appeal: :account).where(target_type: 'Appeal', human_identifier: nil).find_each do |log| next if log.appeal.nil? + log.update_attribute('human_identifier', log.appeal.account.acct) log.update_attribute('route_param', log.appeal.account_warning_id) end diff --git a/lib/mastodon/domains_cli.rb b/lib/mastodon/domains_cli.rb index f24a54e7e..41ea5b152 100644 --- a/lib/mastodon/domains_cli.rb +++ b/lib/mastodon/domains_cli.rb @@ -148,6 +148,7 @@ module Mastodon begin Request.new(:get, "https://#{domain}/api/v1/instance").perform do |res| next unless res.code == 200 + stats[domain] = Oj.load(res.to_s) end @@ -161,6 +162,7 @@ module Mastodon Request.new(:get, "https://#{domain}/api/v1/instance/activity").perform do |res| next unless res.code == 200 + stats[domain]['activity'] = Oj.load(res.to_s) end rescue StandardError diff --git a/lib/sanitize_ext/sanitize_config.rb b/lib/sanitize_ext/sanitize_config.rb index d5e62897f..dc39e9c90 100644 --- a/lib/sanitize_ext/sanitize_config.rb +++ b/lib/sanitize_ext/sanitize_config.rb @@ -72,7 +72,7 @@ class Sanitize elements: %w(p br span a), attributes: { - 'a' => %w(href rel class), + 'a' => %w(href rel class), 'span' => %w(class), }, @@ -98,17 +98,17 @@ class Sanitize attributes: merge( RELAXED[:attributes], - 'audio' => %w(controls), - 'embed' => %w(height src type width), + 'audio' => %w(controls), + 'embed' => %w(height src type width), 'iframe' => %w(allowfullscreen frameborder height scrolling src width), 'source' => %w(src type), - 'video' => %w(controls height loop width), - 'div' => [:data] + 'video' => %w(controls height loop width), + 'div' => [:data] ), protocols: merge( RELAXED[:protocols], - 'embed' => { 'src' => HTTP_PROTOCOLS }, + 'embed' => { 'src' => HTTP_PROTOCOLS }, 'iframe' => { 'src' => HTTP_PROTOCOLS }, 'source' => { 'src' => HTTP_PROTOCOLS } ) diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake index a374e33ad..4b5997920 100644 --- a/lib/tasks/auto_annotate_models.rake +++ b/lib/tasks/auto_annotate_models.rake @@ -3,42 +3,42 @@ if Rails.env.development? task :set_annotation_options do Annotate.set_defaults( - 'routes' => 'false', - 'models' => 'true', - 'position_in_routes' => 'before', - 'position_in_class' => 'before', - 'position_in_test' => 'before', - 'position_in_fixture' => 'before', - 'position_in_factory' => 'before', - 'position_in_serializer' => 'before', - 'show_foreign_keys' => 'false', - 'show_indexes' => 'false', - 'simple_indexes' => 'false', - 'model_dir' => 'app/models', - 'root_dir' => '', - 'include_version' => 'false', - 'require' => '', - 'exclude_tests' => 'true', - 'exclude_fixtures' => 'true', - 'exclude_factories' => 'true', - 'exclude_serializers' => 'true', - 'exclude_scaffolds' => 'true', - 'exclude_controllers' => 'true', - 'exclude_helpers' => 'true', - 'ignore_model_sub_dir' => 'false', - 'ignore_columns' => nil, - 'ignore_routes' => nil, - 'ignore_unknown_models' => 'false', + 'routes' => 'false', + 'models' => 'true', + 'position_in_routes' => 'before', + 'position_in_class' => 'before', + 'position_in_test' => 'before', + 'position_in_fixture' => 'before', + 'position_in_factory' => 'before', + 'position_in_serializer' => 'before', + 'show_foreign_keys' => 'false', + 'show_indexes' => 'false', + 'simple_indexes' => 'false', + 'model_dir' => 'app/models', + 'root_dir' => '', + 'include_version' => 'false', + 'require' => '', + 'exclude_tests' => 'true', + 'exclude_fixtures' => 'true', + 'exclude_factories' => 'true', + 'exclude_serializers' => 'true', + 'exclude_scaffolds' => 'true', + 'exclude_controllers' => 'true', + 'exclude_helpers' => 'true', + 'ignore_model_sub_dir' => 'false', + 'ignore_columns' => nil, + 'ignore_routes' => nil, + 'ignore_unknown_models' => 'false', 'hide_limit_column_types' => 'integer,boolean', - 'skip_on_db_migrate' => 'false', - 'format_bare' => 'true', - 'format_rdoc' => 'false', - 'format_markdown' => 'false', - 'sort' => 'false', - 'force' => 'false', - 'trace' => 'false', - 'wrapper_open' => nil, - 'wrapper_close' => nil + 'skip_on_db_migrate' => 'false', + 'format_bare' => 'true', + 'format_rdoc' => 'false', + 'format_markdown' => 'false', + 'sort' => 'false', + 'force' => 'false', + 'trace' => 'false', + 'wrapper_open' => nil, + 'wrapper_close' => nil ) end diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 179a730bc..f919ba989 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -399,14 +399,14 @@ namespace :mastodon do end ActionMailer::Base.smtp_settings = { - port: env['SMTP_PORT'], - address: env['SMTP_SERVER'], - user_name: env['SMTP_LOGIN'].presence, - password: env['SMTP_PASSWORD'].presence, - domain: env['LOCAL_DOMAIN'], - authentication: env['SMTP_AUTH_METHOD'] == 'none' ? nil : env['SMTP_AUTH_METHOD'] || :plain, - openssl_verify_mode: env['SMTP_OPENSSL_VERIFY_MODE'], - enable_starttls: enable_starttls, + port: env['SMTP_PORT'], + address: env['SMTP_SERVER'], + user_name: env['SMTP_LOGIN'].presence, + password: env['SMTP_PASSWORD'].presence, + domain: env['LOCAL_DOMAIN'], + authentication: env['SMTP_AUTH_METHOD'] == 'none' ? nil : env['SMTP_AUTH_METHOD'] || :plain, + openssl_verify_mode: env['SMTP_OPENSSL_VERIFY_MODE'], + enable_starttls: enable_starttls, enable_starttls_auto: enable_starttls_auto, } diff --git a/spec/controllers/api/v1/accounts/statuses_controller_spec.rb b/spec/controllers/api/v1/accounts/statuses_controller_spec.rb index 4630fac90..e57c37179 100644 --- a/spec/controllers/api/v1/accounts/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/statuses_controller_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'rails_helper' describe Api::V1::Accounts::StatusesController do diff --git a/spec/models/admin/account_action_spec.rb b/spec/models/admin/account_action_spec.rb index 4516df2c2..7248356e5 100644 --- a/spec/models/admin/account_action_spec.rb +++ b/spec/models/admin/account_action_spec.rb @@ -12,9 +12,9 @@ RSpec.describe Admin::AccountAction, type: :model do before do account_action.assign_attributes( - type: type, + type: type, current_account: account, - target_account: target_account + target_account: target_account ) end diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index ed3fc056b..50ff0b149 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -149,8 +149,8 @@ describe AccountInteractions do let(:mute) do Fabricate(:mute, - account: account, - target_account: target_account, + account: account, + target_account: target_account, hide_notifications: hide_notifications) end diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 7043449c5..4d6e5c380 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'rails_helper' RSpec.describe Tag do -- cgit