Browse Source

Autofix Rubocop Style/IfUnlessModifier (#23697)

closed-social-glitch-2
Nick Schonning 1 year ago
committed by GitHub
parent
commit
e2a3ebb271
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 55 additions and 271 deletions
  1. +0
    -106
      .rubocop_todo.yml
  2. +1
    -3
      app/controllers/admin/domain_blocks_controller.rb
  3. +2
    -6
      app/controllers/api/v1/accounts/follower_accounts_controller.rb
  4. +2
    -6
      app/controllers/api/v1/accounts/following_accounts_controller.rb
  5. +2
    -6
      app/controllers/api/v1/accounts/statuses_controller.rb
  6. +1
    -3
      app/controllers/api/v1/admin/accounts_controller.rb
  7. +2
    -6
      app/controllers/api/v1/blocks_controller.rb
  8. +2
    -6
      app/controllers/api/v1/conversations_controller.rb
  9. +2
    -6
      app/controllers/api/v1/domain_blocks_controller.rb
  10. +2
    -6
      app/controllers/api/v1/endorsements_controller.rb
  11. +2
    -6
      app/controllers/api/v1/favourites_controller.rb
  12. +2
    -6
      app/controllers/api/v1/follow_requests_controller.rb
  13. +2
    -6
      app/controllers/api/v1/lists/accounts_controller.rb
  14. +2
    -6
      app/controllers/api/v1/mutes_controller.rb
  15. +2
    -6
      app/controllers/api/v1/notifications_controller.rb
  16. +2
    -6
      app/controllers/api/v1/scheduled_statuses_controller.rb
  17. +2
    -6
      app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb
  18. +2
    -6
      app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb
  19. +1
    -3
      app/controllers/api/v2/admin/accounts_controller.rb
  20. +1
    -3
      app/controllers/auth/registrations_controller.rb
  21. +1
    -3
      app/controllers/auth/sessions_controller.rb
  22. +1
    -3
      app/controllers/filters/statuses_controller.rb
  23. +1
    -3
      app/helpers/application_helper.rb
  24. +1
    -3
      app/lib/activitypub/linked_data_signature.rb
  25. +1
    -3
      app/lib/activitypub/parser/media_attachment_parser.rb
  26. +1
    -3
      app/lib/status_finder.rb
  27. +1
    -3
      app/models/account.rb
  28. +2
    -6
      app/models/account_statuses_cleanup_policy.rb
  29. +1
    -3
      app/models/concerns/account_interactions.rb
  30. +1
    -3
      app/models/concerns/omniauthable.rb
  31. +1
    -3
      app/serializers/initial_state_serializer.rb
  32. +1
    -3
      app/serializers/rest/instance_serializer.rb
  33. +1
    -3
      app/services/activitypub/fetch_remote_actor_service.rb
  34. +1
    -3
      app/services/activitypub/process_status_update_service.rb
  35. +1
    -3
      app/services/remove_from_followers_service.rb
  36. +1
    -3
      app/services/resolve_account_service.rb
  37. +1
    -3
      app/services/search_service.rb
  38. +1
    -3
      lib/mastodon/media_cli.rb
  39. +1
    -3
      lib/mastodon/redis_config.rb
  40. +1
    -3
      spec/support/matchers/model/model_have_error_on_field.rb

+ 0
- 106
.rubocop_todo.yml View File

@ -2921,112 +2921,6 @@ Style/HashTransformValues:
- 'app/serializers/rest/web_push_subscription_serializer.rb'
- 'app/services/import_service.rb'
# Offense count: 176
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'app/controllers/admin/domain_blocks_controller.rb'
- 'app/controllers/api/v1/accounts/follower_accounts_controller.rb'
- 'app/controllers/api/v1/accounts/following_accounts_controller.rb'
- 'app/controllers/api/v1/accounts/statuses_controller.rb'
- 'app/controllers/api/v1/admin/accounts_controller.rb'
- 'app/controllers/api/v1/admin/domain_blocks_controller.rb'
- 'app/controllers/api/v1/blocks_controller.rb'
- 'app/controllers/api/v1/conversations_controller.rb'
- 'app/controllers/api/v1/domain_blocks_controller.rb'
- 'app/controllers/api/v1/emails/confirmations_controller.rb'
- 'app/controllers/api/v1/endorsements_controller.rb'
- 'app/controllers/api/v1/favourites_controller.rb'
- 'app/controllers/api/v1/filters_controller.rb'
- 'app/controllers/api/v1/follow_requests_controller.rb'
- 'app/controllers/api/v1/lists/accounts_controller.rb'
- 'app/controllers/api/v1/mutes_controller.rb'
- 'app/controllers/api/v1/notifications_controller.rb'
- 'app/controllers/api/v1/scheduled_statuses_controller.rb'
- 'app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb'
- 'app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb'
- 'app/controllers/api/v1/trends/links_controller.rb'
- 'app/controllers/api/v1/trends/statuses_controller.rb'
- 'app/controllers/api/v1/trends/tags_controller.rb'
- 'app/controllers/api/v2/admin/accounts_controller.rb'
- 'app/controllers/api/v2/search_controller.rb'
- 'app/controllers/auth/registrations_controller.rb'
- 'app/controllers/auth/sessions_controller.rb'
- 'app/controllers/concerns/localized.rb'
- 'app/controllers/concerns/rate_limit_headers.rb'
- 'app/controllers/concerns/signature_verification.rb'
- 'app/controllers/filters/statuses_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/helpers/jsonld_helper.rb'
- 'app/lib/activitypub/activity/announce.rb'
- 'app/lib/activitypub/activity/create.rb'
- 'app/lib/activitypub/activity/like.rb'
- 'app/lib/activitypub/linked_data_signature.rb'
- 'app/lib/activitypub/parser/media_attachment_parser.rb'
- 'app/lib/feed_manager.rb'
- 'app/lib/status_cache_hydrator.rb'
- 'app/lib/status_finder.rb'
- 'app/models/account.rb'
- 'app/models/account_migration.rb'
- 'app/models/account_statuses_cleanup_policy.rb'
- 'app/models/admin/import.rb'
- 'app/models/admin/status_batch_action.rb'
- 'app/models/concerns/account_avatar.rb'
- 'app/models/concerns/account_counters.rb'
- 'app/models/concerns/account_header.rb'
- 'app/models/concerns/account_interactions.rb'
- 'app/models/concerns/attachmentable.rb'
- 'app/models/concerns/ldap_authenticable.rb'
- 'app/models/concerns/omniauthable.rb'
- 'app/models/form/redirect.rb'
- 'app/models/media_attachment.rb'
- 'app/models/scheduled_status.rb'
- 'app/models/status.rb'
- 'app/models/trends.rb'
- 'app/models/trends/links.rb'
- 'app/models/trends/statuses.rb'
- 'app/models/user_role.rb'
- 'app/presenters/status_relationships_presenter.rb'
- 'app/serializers/initial_state_serializer.rb'
- 'app/serializers/rest/instance_serializer.rb'
- 'app/services/activitypub/fetch_remote_actor_service.rb'
- 'app/services/activitypub/fetch_remote_status_service.rb'
- 'app/services/activitypub/prepare_followers_synchronization_service.rb'
- 'app/services/activitypub/process_status_update_service.rb'
- 'app/services/block_domain_service.rb'
- 'app/services/fetch_link_card_service.rb'
- 'app/services/fetch_resource_service.rb'
- 'app/services/notify_service.rb'
- 'app/services/post_status_service.rb'
- 'app/services/remove_from_followers_service.rb'
- 'app/services/report_service.rb'
- 'app/services/resolve_account_service.rb'
- 'app/services/search_service.rb'
- 'app/services/unblock_domain_service.rb'
- 'app/services/update_status_service.rb'
- 'app/validators/disallowed_hashtags_validator.rb'
- 'app/validators/existing_username_validator.rb'
- 'app/validators/follow_limit_validator.rb'
- 'app/validators/import_validator.rb'
- 'app/validators/note_length_validator.rb'
- 'app/validators/poll_validator.rb'
- 'app/validators/reaction_validator.rb'
- 'app/validators/registration_form_time_validator.rb'
- 'app/workers/activitypub/delivery_worker.rb'
- 'app/workers/move_worker.rb'
- 'db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb'
- 'db/migrate/20180528141303_fix_accounts_unique_index.rb'
- 'db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb'
- 'db/migrate/20200620164023_add_fixed_lowercase_index_to_accounts.rb'
- 'lib/cli.rb'
- 'lib/mastodon/accounts_cli.rb'
- 'lib/mastodon/domains_cli.rb'
- 'lib/mastodon/maintenance_cli.rb'
- 'lib/mastodon/media_cli.rb'
- 'lib/mastodon/redis_config.rb'
- 'lib/mastodon/statuses_cli.rb'
- 'spec/support/matchers/model/model_have_error_on_field.rb'
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: InverseMethods, InverseBlocks.

+ 1
- 3
app/controllers/admin/domain_blocks_controller.rb View File

@ -90,9 +90,7 @@ module Admin
end
def action_from_button
if params[:save]
'save'
end
'save' if params[:save]
end
end
end

+ 2
- 6
app/controllers/api/v1/accounts/follower_accounts_controller.rb View File

@ -45,15 +45,11 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController
end
def next_path
if records_continue?
api_v1_account_followers_url pagination_params(max_id: pagination_max_id)
end
api_v1_account_followers_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
unless @accounts.empty?
api_v1_account_followers_url pagination_params(since_id: pagination_since_id)
end
api_v1_account_followers_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
end
def pagination_max_id

+ 2
- 6
app/controllers/api/v1/accounts/following_accounts_controller.rb View File

@ -45,15 +45,11 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
end
def next_path
if records_continue?
api_v1_account_following_index_url pagination_params(max_id: pagination_max_id)
end
api_v1_account_following_index_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
unless @accounts.empty?
api_v1_account_following_index_url pagination_params(since_id: pagination_since_id)
end
api_v1_account_following_index_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
end
def pagination_max_id

+ 2
- 6
app/controllers/api/v1/accounts/statuses_controller.rb View File

@ -39,15 +39,11 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
end
def next_path
if records_continue?
api_v1_account_statuses_url pagination_params(max_id: pagination_max_id)
end
api_v1_account_statuses_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
unless @statuses.empty?
api_v1_account_statuses_url pagination_params(min_id: pagination_since_id)
end
api_v1_account_statuses_url pagination_params(min_id: pagination_since_id) unless @statuses.empty?
end
def records_continue?

+ 1
- 3
app/controllers/api/v1/admin/accounts_controller.rb View File

@ -120,9 +120,7 @@ class Api::V1::Admin::AccountsController < Api::BaseController
translated_params[:status] = status.to_s if params[status].present?
end
if params[:staff].present?
translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id)
end
translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id) if params[:staff].present?
translated_params
end

+ 2
- 6
app/controllers/api/v1/blocks_controller.rb View File

@ -33,15 +33,11 @@ class Api::V1::BlocksController < Api::BaseController
end
def next_path
if records_continue?
api_v1_blocks_url pagination_params(max_id: pagination_max_id)
end
api_v1_blocks_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
unless paginated_blocks.empty?
api_v1_blocks_url pagination_params(since_id: pagination_since_id)
end
api_v1_blocks_url pagination_params(since_id: pagination_since_id) unless paginated_blocks.empty?
end
def pagination_max_id

+ 2
- 6
app/controllers/api/v1/conversations_controller.rb View File

@ -40,15 +40,11 @@ class Api::V1::ConversationsController < Api::BaseController
end
def next_path
if records_continue?
api_v1_conversations_url pagination_params(max_id: pagination_max_id)
end
api_v1_conversations_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
unless @conversations.empty?
api_v1_conversations_url pagination_params(min_id: pagination_since_id)
end
api_v1_conversations_url pagination_params(min_id: pagination_since_id) unless @conversations.empty?
end
def pagination_max_id

+ 2
- 6
app/controllers/api/v1/domain_blocks_controller.rb View File

@ -43,15 +43,11 @@ class Api::V1::DomainBlocksController < Api::BaseController
end
def next_path
if records_continue?
api_v1_domain_blocks_url pagination_params(max_id: pagination_max_id)
end
api_v1_domain_blocks_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
unless @blocks.empty?
api_v1_domain_blocks_url pagination_params(since_id: pagination_since_id)
end
api_v1_domain_blocks_url pagination_params(since_id: pagination_since_id) unless @blocks.empty?
end
def pagination_max_id

+ 2
- 6
app/controllers/api/v1/endorsements_controller.rb View File

@ -35,17 +35,13 @@ class Api::V1::EndorsementsController < Api::BaseController
def next_path
return if unlimited?
if records_continue?
api_v1_endorsements_url pagination_params(max_id: pagination_max_id)
end
api_v1_endorsements_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
return if unlimited?
unless @accounts.empty?
api_v1_endorsements_url pagination_params(since_id: pagination_since_id)
end
api_v1_endorsements_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
end
def pagination_max_id

+ 2
- 6
app/controllers/api/v1/favourites_controller.rb View File

@ -36,15 +36,11 @@ class Api::V1::FavouritesController < Api::BaseController
end
def next_path
if records_continue?
api_v1_favourites_url pagination_params(max_id: pagination_max_id)
end
api_v1_favourites_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
unless results.empty?
api_v1_favourites_url pagination_params(min_id: pagination_since_id)
end
api_v1_favourites_url pagination_params(min_id: pagination_since_id) unless results.empty?
end
def pagination_max_id

+ 2
- 6
app/controllers/api/v1/follow_requests_controller.rb View File

@ -53,15 +53,11 @@ class Api::V1::FollowRequestsController < Api::BaseController
end
def next_path
if records_continue?
api_v1_follow_requests_url pagination_params(max_id: pagination_max_id)
end
api_v1_follow_requests_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
unless @accounts.empty?
api_v1_follow_requests_url pagination_params(since_id: pagination_since_id)
end
api_v1_follow_requests_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
end
def pagination_max_id

+ 2
- 6
app/controllers/api/v1/lists/accounts_controller.rb View File

@ -62,17 +62,13 @@ class Api::V1::Lists::AccountsController < Api::BaseController
def next_path
return if unlimited?
if records_continue?
api_v1_list_accounts_url pagination_params(max_id: pagination_max_id)
end
api_v1_list_accounts_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
return if unlimited?
unless @accounts.empty?
api_v1_list_accounts_url pagination_params(since_id: pagination_since_id)
end
api_v1_list_accounts_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
end
def pagination_max_id

+ 2
- 6
app/controllers/api/v1/mutes_controller.rb View File

@ -33,15 +33,11 @@ class Api::V1::MutesController < Api::BaseController
end
def next_path
if records_continue?
api_v1_mutes_url pagination_params(max_id: pagination_max_id)
end
api_v1_mutes_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
unless paginated_mutes.empty?
api_v1_mutes_url pagination_params(since_id: pagination_since_id)
end
api_v1_mutes_url pagination_params(since_id: pagination_since_id) unless paginated_mutes.empty?
end
def pagination_max_id

+ 2
- 6
app/controllers/api/v1/notifications_controller.rb View File

@ -58,15 +58,11 @@ class Api::V1::NotificationsController < Api::BaseController
end
def next_path
unless @notifications.empty?
api_v1_notifications_url pagination_params(max_id: pagination_max_id)
end
api_v1_notifications_url pagination_params(max_id: pagination_max_id) unless @notifications.empty?
end
def prev_path
unless @notifications.empty?
api_v1_notifications_url pagination_params(min_id: pagination_since_id)
end
api_v1_notifications_url pagination_params(min_id: pagination_since_id) unless @notifications.empty?
end
def pagination_max_id

+ 2
- 6
app/controllers/api/v1/scheduled_statuses_controller.rb View File

@ -52,15 +52,11 @@ class Api::V1::ScheduledStatusesController < Api::BaseController
end
def next_path
if records_continue?
api_v1_scheduled_statuses_url pagination_params(max_id: pagination_max_id)
end
api_v1_scheduled_statuses_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
unless @statuses.empty?
api_v1_scheduled_statuses_url pagination_params(min_id: pagination_since_id)
end
api_v1_scheduled_statuses_url pagination_params(min_id: pagination_since_id) unless @statuses.empty?
end
def records_continue?

+ 2
- 6
app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb View File

@ -41,15 +41,11 @@ class Api::V1::Statuses::FavouritedByAccountsController < Api::BaseController
end
def next_path
if records_continue?
api_v1_status_favourited_by_index_url pagination_params(max_id: pagination_max_id)
end
api_v1_status_favourited_by_index_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
unless @accounts.empty?
api_v1_status_favourited_by_index_url pagination_params(since_id: pagination_since_id)
end
api_v1_status_favourited_by_index_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
end
def pagination_max_id

+ 2
- 6
app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb View File

@ -37,15 +37,11 @@ class Api::V1::Statuses::RebloggedByAccountsController < Api::BaseController
end
def next_path
if records_continue?
api_v1_status_reblogged_by_index_url pagination_params(max_id: pagination_max_id)
end
api_v1_status_reblogged_by_index_url pagination_params(max_id: pagination_max_id) if records_continue?
end
def prev_path
unless @accounts.empty?
api_v1_status_reblogged_by_index_url pagination_params(since_id: pagination_since_id)
end
api_v1_status_reblogged_by_index_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
end
def pagination_max_id

+ 1
- 3
app/controllers/api/v2/admin/accounts_controller.rb View File

@ -25,9 +25,7 @@ class Api::V2::Admin::AccountsController < Api::V1::Admin::AccountsController
def translated_filter_params
translated_params = filter_params.slice(*AccountFilter::KEYS)
if params[:permissions] == 'staff'
translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id)
end
translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id) if params[:permissions] == 'staff'
translated_params
end

+ 1
- 3
app/controllers/auth/registrations_controller.rb View File

@ -30,9 +30,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController
def update
super do |resource|
if resource.saved_change_to_encrypted_password?
resource.clear_other_sessions(current_session.session_id)
end
resource.clear_other_sessions(current_session.session_id) if resource.saved_change_to_encrypted_password?
end
end

+ 1
- 3
app/controllers/auth/sessions_controller.rb View File

@ -110,9 +110,7 @@ class Auth::SessionsController < Devise::SessionsController
def home_paths(resource)
paths = [about_path]
if single_user_mode? && resource.is_a?(User)
paths << short_account_path(username: resource.account)
end
paths << short_account_path(username: resource.account) if single_user_mode? && resource.is_a?(User)
paths
end

+ 1
- 3
app/controllers/filters/statuses_controller.rb View File

@ -38,9 +38,7 @@ class Filters::StatusesController < ApplicationController
end
def action_from_button
if params[:remove]
'remove'
end
'remove' if params[:remove]
end
def set_body_classes

+ 1
- 3
app/helpers/application_helper.rb View File

@ -216,9 +216,7 @@ module ApplicationHelper
state_params[:moved_to_account] = current_account.moved_to_account
end
if single_user_mode?
state_params[:owner] = Account.local.without_suspended.where('id > 0').first
end
state_params[:owner] = Account.local.without_suspended.where('id > 0').first if single_user_mode?
json = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(state_params), serializer: InitialStateSerializer).to_json
# rubocop:disable Rails/OutputSafety

+ 1
- 3
app/lib/activitypub/linked_data_signature.rb View File

@ -27,9 +27,7 @@ class ActivityPub::LinkedDataSignature
document_hash = hash(@json.without('signature'))
to_be_verified = options_hash + document_hash
if creator.keypair.public_key.verify(OpenSSL::Digest.new('SHA256'), Base64.decode64(signature), to_be_verified)
creator
end
creator if creator.keypair.public_key.verify(OpenSSL::Digest.new('SHA256'), Base64.decode64(signature), to_be_verified)
end
def sign!(creator, sign_with: nil)

+ 1
- 3
app/lib/activitypub/parser/media_attachment_parser.rb View File

@ -50,9 +50,7 @@ class ActivityPub::Parser::MediaAttachmentParser
components = begin
blurhash = @json['blurhash']
if blurhash.present? && /^[\w#$%*+,-.:;=?@\[\]^{|}~]+$/.match?(blurhash)
Blurhash.components(blurhash)
end
Blurhash.components(blurhash) if blurhash.present? && /^[\w#$%*+,-.:;=?@\[\]^{|}~]+$/.match?(blurhash)
end
components.present? && components.none? { |comp| comp > 5 }

+ 1
- 3
app/lib/status_finder.rb View File

@ -27,8 +27,6 @@ class StatusFinder
end
def verify_action!
unless recognized_params[:action] == 'show'
raise ActiveRecord::RecordNotFound
end
raise ActiveRecord::RecordNotFound unless recognized_params[:action] == 'show'
end
end

+ 1
- 3
app/models/account.rb View File

@ -313,9 +313,7 @@ class Account < ApplicationRecord
previous = old_fields.find { |item| item['value'] == attr[:value] }
if previous && previous['verified_at'].present?
attr[:verified_at] = previous['verified_at']
end
attr[:verified_at] = previous['verified_at'] if previous && previous['verified_at'].present?
fields << attr
end

+ 2
- 6
app/models/account_statuses_cleanup_policy.rb View File

@ -122,9 +122,7 @@ class AccountStatusesCleanupPolicy < ApplicationRecord
# may need to be deleted, so we'll have to start again.
redis.del("account_cleanup:#{account.id}")
end
if EXCEPTION_THRESHOLDS.map { |name| attribute_change_to_be_saved(name) }.compact.any? { |old, new| old.present? && (new.nil? || new > old) }
redis.del("account_cleanup:#{account.id}")
end
redis.del("account_cleanup:#{account.id}") if EXCEPTION_THRESHOLDS.map { |name| attribute_change_to_be_saved(name) }.compact.any? { |old, new| old.present? && (new.nil? || new > old) }
end
def validate_local_account
@ -141,9 +139,7 @@ class AccountStatusesCleanupPolicy < ApplicationRecord
# has switched to snowflake IDs significantly over 2 years ago anyway.
snowflake_id = Mastodon::Snowflake.id_at(min_status_age.seconds.ago, with_random: false)
if max_id.nil? || snowflake_id < max_id
max_id = snowflake_id
end
max_id = snowflake_id if max_id.nil? || snowflake_id < max_id
Status.where(Status.arel_table[:id].lteq(max_id))
end

+ 1
- 3
app/models/concerns/account_interactions.rb View File

@ -151,9 +151,7 @@ module AccountInteractions
remove_potential_friendship(other_account)
# When toggling a mute between hiding and allowing notifications, the mute will already exist, so the find_or_create_by! call will return the existing Mute without updating the hide_notifications attribute. Therefore, we check that hide_notifications? is what we want and set it if it isn't.
if mute.hide_notifications? != notifications
mute.update!(hide_notifications: notifications)
end
mute.update!(hide_notifications: notifications) if mute.hide_notifications? != notifications
mute
end

+ 1
- 3
app/models/concerns/omniauthable.rb View File

@ -56,9 +56,7 @@ module Omniauthable
user = User.new(user_params_from_auth(email, auth))
begin
if /\A#{URI::DEFAULT_PARSER.make_regexp(%w(http https))}\z/.match?(auth.info.image)
user.account.avatar_remote_url = auth.info.image
end
user.account.avatar_remote_url = auth.info.image if /\A#{URI::DEFAULT_PARSER.make_regexp(%w(http https))}\z/.match?(auth.info.image)
rescue Mastodon::UnexpectedResponseError
user.account.avatar_remote_url = nil
end

+ 1
- 3
app/serializers/initial_state_serializer.rb View File

@ -61,9 +61,7 @@ class InitialStateSerializer < ActiveModel::Serializer
store[:disabled_account_id] = object.disabled_account.id.to_s if object.disabled_account
store[:moved_to_account_id] = object.moved_to_account.id.to_s if object.moved_to_account
if Rails.configuration.x.single_user_mode
store[:owner] = object.owner&.id&.to_s
end
store[:owner] = object.owner&.id&.to_s if Rails.configuration.x.single_user_mode
store
end

+ 1
- 3
app/serializers/rest/instance_serializer.rb View File

@ -95,9 +95,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
end
def registrations_message
if Setting.closed_registrations_message.present?
markdown.render(Setting.closed_registrations_message)
end
markdown.render(Setting.closed_registrations_message) if Setting.closed_registrations_message.present?
end
def markdown

+ 1
- 3
app/services/activitypub/fetch_remote_actor_service.rb View File

@ -56,9 +56,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
webfinger = webfinger!("acct:#{confirmed_username}@#{confirmed_domain}")
@username, @domain = split_acct(webfinger.subject)
unless confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero?
raise Webfinger::RedirectError, "Too many webfinger redirects for URI #{@uri} (stopped at #{@username}@#{@domain})"
end
raise Webfinger::RedirectError, "Too many webfinger redirects for URI #{@uri} (stopped at #{@username}@#{@domain})" unless confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero?
raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.link('self', 'href') != @uri
rescue Webfinger::RedirectError => e

+ 1
- 3
app/services/activitypub/process_status_update_service.rb View File

@ -80,9 +80,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
# If a previously existing media attachment was significantly updated, mark
# media attachments as changed even if none were added or removed
if media_attachment_parser.significantly_changes?(media_attachment)
@media_attachments_changed = true
end
@media_attachments_changed = true if media_attachment_parser.significantly_changes?(media_attachment)
media_attachment.description = media_attachment_parser.description
media_attachment.focus = media_attachment_parser.focus

+ 1
- 3
app/services/remove_from_followers_service.rb View File

@ -7,9 +7,7 @@ class RemoveFromFollowersService < BaseService
source_account.passive_relationships.where(account_id: target_accounts).find_each do |follow|
follow.destroy
if source_account.local? && !follow.account.local? && follow.account.activitypub?
create_notification(follow)
end
create_notification(follow) if source_account.local? && !follow.account.local? && follow.account.activitypub?
end
end

+ 1
- 3
app/services/resolve_account_service.rb View File

@ -96,9 +96,7 @@ class ResolveAccountService < BaseService
@webfinger = webfinger!("acct:#{confirmed_username}@#{confirmed_domain}")
@username, @domain = split_acct(@webfinger.subject)
unless confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero?
raise Webfinger::RedirectError, "Too many webfinger redirects for URI #{uri} (stopped at #{@username}@#{@domain})"
end
raise Webfinger::RedirectError, "Too many webfinger redirects for URI #{uri} (stopped at #{@username}@#{@domain})" unless confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero?
rescue Webfinger::GoneError
@gone = true
end

+ 1
- 3
app/services/search_service.rb View File

@ -37,9 +37,7 @@ class SearchService < BaseService
def perform_statuses_search!
definition = parsed_query.apply(StatusesIndex.filter(term: { searchable_by: @account.id }))
if @options[:account_id].present?
definition = definition.filter(term: { account_id: @options[:account_id] })
end
definition = definition.filter(term: { account_id: @options[:account_id] }) if @options[:account_id].present?
if @options[:min_id].present? || @options[:max_id].present?
range = {}

+ 1
- 3
lib/mastodon/media_cli.rb View File

@ -277,9 +277,7 @@ module Mastodon
exit(1)
end
if options[:days].present?
scope = scope.where('media_attachments.id > ?', Mastodon::Snowflake.id_at(options[:days].days.ago, with_random: false))
end
scope = scope.where('media_attachments.id > ?', Mastodon::Snowflake.id_at(options[:days].days.ago, with_random: false)) if options[:days].present?
processed, aggregate = parallelize_with_progress(scope) do |media_attachment|
next if media_attachment.remote_url.blank? || (!options[:force] && media_attachment.file_file_name.present?)

+ 1
- 3
lib/mastodon/redis_config.rb View File

@ -46,6 +46,4 @@ REDIS_SIDEKIQ_PARAMS = {
namespace: sidekiq_namespace,
}.freeze
if Rails.env.test?
ENV['REDIS_NAMESPACE'] = "mastodon_test#{ENV['TEST_ENV_NUMBER']}"
end
ENV['REDIS_NAMESPACE'] = "mastodon_test#{ENV['TEST_ENV_NUMBER']}" if Rails.env.test?

+ 1
- 3
spec/support/matchers/model/model_have_error_on_field.rb View File

@ -1,8 +1,6 @@
RSpec::Matchers.define :model_have_error_on_field do |expected|
match do |record|
if record.errors.empty?
record.valid?
end
record.valid? if record.errors.empty?
record.errors.has_key?(expected)
end

Loading…
Cancel
Save