Autofix Rubocop Style/IfUnlessModifier (#23697)
parent
22cdd53335
commit
793f8c7dd5
|
@ -2921,112 +2921,6 @@ Style/HashTransformValues:
|
||||||
- 'app/serializers/rest/web_push_subscription_serializer.rb'
|
- 'app/serializers/rest/web_push_subscription_serializer.rb'
|
||||||
- 'app/services/import_service.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
|
# Offense count: 3
|
||||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||||
# Configuration parameters: InverseMethods, InverseBlocks.
|
# Configuration parameters: InverseMethods, InverseBlocks.
|
||||||
|
|
|
@ -90,9 +90,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def action_from_button
|
def action_from_button
|
||||||
if params[:save]
|
'save' if params[:save]
|
||||||
'save'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,15 +45,11 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
api_v1_account_followers_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_account_followers_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless @accounts.empty?
|
api_v1_account_followers_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||||
api_v1_account_followers_url pagination_params(since_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -45,15 +45,11 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
api_v1_account_following_index_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_account_following_index_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless @accounts.empty?
|
api_v1_account_following_index_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||||
api_v1_account_following_index_url pagination_params(since_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -39,15 +39,11 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
api_v1_account_statuses_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_account_statuses_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless @statuses.empty?
|
api_v1_account_statuses_url pagination_params(min_id: pagination_since_id) unless @statuses.empty?
|
||||||
api_v1_account_statuses_url pagination_params(min_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def records_continue?
|
def records_continue?
|
||||||
|
|
|
@ -120,9 +120,7 @@ class Api::V1::Admin::AccountsController < Api::BaseController
|
||||||
translated_params[:status] = status.to_s if params[status].present?
|
translated_params[:status] = status.to_s if params[status].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:staff].present?
|
translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id) if params[:staff].present?
|
||||||
translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id)
|
|
||||||
end
|
|
||||||
|
|
||||||
translated_params
|
translated_params
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,15 +33,11 @@ class Api::V1::BlocksController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
api_v1_blocks_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_blocks_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless paginated_blocks.empty?
|
api_v1_blocks_url pagination_params(since_id: pagination_since_id) unless paginated_blocks.empty?
|
||||||
api_v1_blocks_url pagination_params(since_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -40,15 +40,11 @@ class Api::V1::ConversationsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
api_v1_conversations_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_conversations_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless @conversations.empty?
|
api_v1_conversations_url pagination_params(min_id: pagination_since_id) unless @conversations.empty?
|
||||||
api_v1_conversations_url pagination_params(min_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -43,15 +43,11 @@ class Api::V1::DomainBlocksController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
api_v1_domain_blocks_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_domain_blocks_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless @blocks.empty?
|
api_v1_domain_blocks_url pagination_params(since_id: pagination_since_id) unless @blocks.empty?
|
||||||
api_v1_domain_blocks_url pagination_params(since_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -35,17 +35,13 @@ class Api::V1::EndorsementsController < Api::BaseController
|
||||||
def next_path
|
def next_path
|
||||||
return if unlimited?
|
return if unlimited?
|
||||||
|
|
||||||
if records_continue?
|
api_v1_endorsements_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_endorsements_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
return if unlimited?
|
return if unlimited?
|
||||||
|
|
||||||
unless @accounts.empty?
|
api_v1_endorsements_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||||
api_v1_endorsements_url pagination_params(since_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -36,15 +36,11 @@ class Api::V1::FavouritesController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
api_v1_favourites_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_favourites_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless results.empty?
|
api_v1_favourites_url pagination_params(min_id: pagination_since_id) unless results.empty?
|
||||||
api_v1_favourites_url pagination_params(min_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -53,15 +53,11 @@ class Api::V1::FollowRequestsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
api_v1_follow_requests_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_follow_requests_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless @accounts.empty?
|
api_v1_follow_requests_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||||
api_v1_follow_requests_url pagination_params(since_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -62,17 +62,13 @@ class Api::V1::Lists::AccountsController < Api::BaseController
|
||||||
def next_path
|
def next_path
|
||||||
return if unlimited?
|
return if unlimited?
|
||||||
|
|
||||||
if records_continue?
|
api_v1_list_accounts_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_list_accounts_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
return if unlimited?
|
return if unlimited?
|
||||||
|
|
||||||
unless @accounts.empty?
|
api_v1_list_accounts_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||||
api_v1_list_accounts_url pagination_params(since_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -33,15 +33,11 @@ class Api::V1::MutesController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
api_v1_mutes_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_mutes_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless paginated_mutes.empty?
|
api_v1_mutes_url pagination_params(since_id: pagination_since_id) unless paginated_mutes.empty?
|
||||||
api_v1_mutes_url pagination_params(since_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -58,15 +58,11 @@ class Api::V1::NotificationsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
unless @notifications.empty?
|
api_v1_notifications_url pagination_params(max_id: pagination_max_id) unless @notifications.empty?
|
||||||
api_v1_notifications_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless @notifications.empty?
|
api_v1_notifications_url pagination_params(min_id: pagination_since_id) unless @notifications.empty?
|
||||||
api_v1_notifications_url pagination_params(min_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -52,15 +52,11 @@ class Api::V1::ScheduledStatusesController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
api_v1_scheduled_statuses_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_scheduled_statuses_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless @statuses.empty?
|
api_v1_scheduled_statuses_url pagination_params(min_id: pagination_since_id) unless @statuses.empty?
|
||||||
api_v1_scheduled_statuses_url pagination_params(min_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def records_continue?
|
def records_continue?
|
||||||
|
|
|
@ -41,15 +41,11 @@ class Api::V1::Statuses::FavouritedByAccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
api_v1_status_favourited_by_index_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_status_favourited_by_index_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless @accounts.empty?
|
api_v1_status_favourited_by_index_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||||
api_v1_status_favourited_by_index_url pagination_params(since_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -37,15 +37,11 @@ class Api::V1::Statuses::RebloggedByAccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
api_v1_status_reblogged_by_index_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
api_v1_status_reblogged_by_index_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless @accounts.empty?
|
api_v1_status_reblogged_by_index_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||||
api_v1_status_reblogged_by_index_url pagination_params(since_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -25,9 +25,7 @@ class Api::V2::Admin::AccountsController < Api::V1::Admin::AccountsController
|
||||||
def translated_filter_params
|
def translated_filter_params
|
||||||
translated_params = filter_params.slice(*AccountFilter::KEYS)
|
translated_params = filter_params.slice(*AccountFilter::KEYS)
|
||||||
|
|
||||||
if params[:permissions] == 'staff'
|
translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id) if params[:permissions] == 'staff'
|
||||||
translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id)
|
|
||||||
end
|
|
||||||
|
|
||||||
translated_params
|
translated_params
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,9 +30,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
super do |resource|
|
super do |resource|
|
||||||
if resource.saved_change_to_encrypted_password?
|
resource.clear_other_sessions(current_session.session_id) if resource.saved_change_to_encrypted_password?
|
||||||
resource.clear_other_sessions(current_session.session_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -110,9 +110,7 @@ class Auth::SessionsController < Devise::SessionsController
|
||||||
def home_paths(resource)
|
def home_paths(resource)
|
||||||
paths = [about_path]
|
paths = [about_path]
|
||||||
|
|
||||||
if single_user_mode? && resource.is_a?(User)
|
paths << short_account_path(username: resource.account) if single_user_mode? && resource.is_a?(User)
|
||||||
paths << short_account_path(username: resource.account)
|
|
||||||
end
|
|
||||||
|
|
||||||
paths
|
paths
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,9 +38,7 @@ class Filters::StatusesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def action_from_button
|
def action_from_button
|
||||||
if params[:remove]
|
'remove' if params[:remove]
|
||||||
'remove'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_body_classes
|
def set_body_classes
|
||||||
|
|
|
@ -216,9 +216,7 @@ module ApplicationHelper
|
||||||
state_params[:moved_to_account] = current_account.moved_to_account
|
state_params[:moved_to_account] = current_account.moved_to_account
|
||||||
end
|
end
|
||||||
|
|
||||||
if single_user_mode?
|
state_params[:owner] = Account.local.without_suspended.where('id > 0').first if single_user_mode?
|
||||||
state_params[:owner] = Account.local.without_suspended.where('id > 0').first
|
|
||||||
end
|
|
||||||
|
|
||||||
json = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(state_params), serializer: InitialStateSerializer).to_json
|
json = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(state_params), serializer: InitialStateSerializer).to_json
|
||||||
# rubocop:disable Rails/OutputSafety
|
# rubocop:disable Rails/OutputSafety
|
||||||
|
|
|
@ -27,9 +27,7 @@ class ActivityPub::LinkedDataSignature
|
||||||
document_hash = hash(@json.without('signature'))
|
document_hash = hash(@json.without('signature'))
|
||||||
to_be_verified = options_hash + document_hash
|
to_be_verified = options_hash + document_hash
|
||||||
|
|
||||||
if creator.keypair.public_key.verify(OpenSSL::Digest.new('SHA256'), Base64.decode64(signature), to_be_verified)
|
creator if creator.keypair.public_key.verify(OpenSSL::Digest.new('SHA256'), Base64.decode64(signature), to_be_verified)
|
||||||
creator
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign!(creator, sign_with: nil)
|
def sign!(creator, sign_with: nil)
|
||||||
|
|
|
@ -50,9 +50,7 @@ class ActivityPub::Parser::MediaAttachmentParser
|
||||||
components = begin
|
components = begin
|
||||||
blurhash = @json['blurhash']
|
blurhash = @json['blurhash']
|
||||||
|
|
||||||
if blurhash.present? && /^[\w#$%*+,-.:;=?@\[\]^{|}~]+$/.match?(blurhash)
|
Blurhash.components(blurhash) if blurhash.present? && /^[\w#$%*+,-.:;=?@\[\]^{|}~]+$/.match?(blurhash)
|
||||||
Blurhash.components(blurhash)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
components.present? && components.none? { |comp| comp > 5 }
|
components.present? && components.none? { |comp| comp > 5 }
|
||||||
|
|
|
@ -27,8 +27,6 @@ class StatusFinder
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_action!
|
def verify_action!
|
||||||
unless recognized_params[:action] == 'show'
|
raise ActiveRecord::RecordNotFound unless recognized_params[:action] == 'show'
|
||||||
raise ActiveRecord::RecordNotFound
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -313,9 +313,7 @@ class Account < ApplicationRecord
|
||||||
|
|
||||||
previous = old_fields.find { |item| item['value'] == attr[:value] }
|
previous = old_fields.find { |item| item['value'] == attr[:value] }
|
||||||
|
|
||||||
if previous && previous['verified_at'].present?
|
attr[:verified_at] = previous['verified_at'] if previous && previous['verified_at'].present?
|
||||||
attr[:verified_at] = previous['verified_at']
|
|
||||||
end
|
|
||||||
|
|
||||||
fields << attr
|
fields << attr
|
||||||
end
|
end
|
||||||
|
|
|
@ -122,9 +122,7 @@ class AccountStatusesCleanupPolicy < ApplicationRecord
|
||||||
# may need to be deleted, so we'll have to start again.
|
# may need to be deleted, so we'll have to start again.
|
||||||
redis.del("account_cleanup:#{account.id}")
|
redis.del("account_cleanup:#{account.id}")
|
||||||
end
|
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}") 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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_local_account
|
def validate_local_account
|
||||||
|
@ -141,9 +139,7 @@ class AccountStatusesCleanupPolicy < ApplicationRecord
|
||||||
# has switched to snowflake IDs significantly over 2 years ago anyway.
|
# 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)
|
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 if max_id.nil? || snowflake_id < max_id
|
||||||
max_id = snowflake_id
|
|
||||||
end
|
|
||||||
|
|
||||||
Status.where(Status.arel_table[:id].lteq(max_id))
|
Status.where(Status.arel_table[:id].lteq(max_id))
|
||||||
end
|
end
|
||||||
|
|
|
@ -151,9 +151,7 @@ module AccountInteractions
|
||||||
remove_potential_friendship(other_account)
|
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.
|
# 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) if mute.hide_notifications? != notifications
|
||||||
mute.update!(hide_notifications: notifications)
|
|
||||||
end
|
|
||||||
|
|
||||||
mute
|
mute
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,9 +56,7 @@ module Omniauthable
|
||||||
user = User.new(user_params_from_auth(email, auth))
|
user = User.new(user_params_from_auth(email, auth))
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if /\A#{URI::DEFAULT_PARSER.make_regexp(%w(http https))}\z/.match?(auth.info.image)
|
user.account.avatar_remote_url = auth.info.image if /\A#{URI::DEFAULT_PARSER.make_regexp(%w(http https))}\z/.match?(auth.info.image)
|
||||||
user.account.avatar_remote_url = auth.info.image
|
|
||||||
end
|
|
||||||
rescue Mastodon::UnexpectedResponseError
|
rescue Mastodon::UnexpectedResponseError
|
||||||
user.account.avatar_remote_url = nil
|
user.account.avatar_remote_url = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -61,9 +61,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||||
store[:disabled_account_id] = object.disabled_account.id.to_s if object.disabled_account
|
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
|
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 if Rails.configuration.x.single_user_mode
|
||||||
store[:owner] = object.owner&.id&.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
store
|
store
|
||||||
end
|
end
|
||||||
|
|
|
@ -95,9 +95,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def registrations_message
|
def registrations_message
|
||||||
if Setting.closed_registrations_message.present?
|
markdown.render(Setting.closed_registrations_message) if Setting.closed_registrations_message.present?
|
||||||
markdown.render(Setting.closed_registrations_message)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def markdown
|
def markdown
|
||||||
|
|
|
@ -56,9 +56,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
|
||||||
webfinger = webfinger!("acct:#{confirmed_username}@#{confirmed_domain}")
|
webfinger = webfinger!("acct:#{confirmed_username}@#{confirmed_domain}")
|
||||||
@username, @domain = split_acct(webfinger.subject)
|
@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})" 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 Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.link('self', 'href') != @uri
|
raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.link('self', 'href') != @uri
|
||||||
rescue Webfinger::RedirectError => e
|
rescue Webfinger::RedirectError => e
|
||||||
|
|
|
@ -80,9 +80,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||||
|
|
||||||
# If a previously existing media attachment was significantly updated, mark
|
# If a previously existing media attachment was significantly updated, mark
|
||||||
# media attachments as changed even if none were added or removed
|
# media attachments as changed even if none were added or removed
|
||||||
if media_attachment_parser.significantly_changes?(media_attachment)
|
@media_attachments_changed = true if media_attachment_parser.significantly_changes?(media_attachment)
|
||||||
@media_attachments_changed = true
|
|
||||||
end
|
|
||||||
|
|
||||||
media_attachment.description = media_attachment_parser.description
|
media_attachment.description = media_attachment_parser.description
|
||||||
media_attachment.focus = media_attachment_parser.focus
|
media_attachment.focus = media_attachment_parser.focus
|
||||||
|
|
|
@ -7,9 +7,7 @@ class RemoveFromFollowersService < BaseService
|
||||||
source_account.passive_relationships.where(account_id: target_accounts).find_each do |follow|
|
source_account.passive_relationships.where(account_id: target_accounts).find_each do |follow|
|
||||||
follow.destroy
|
follow.destroy
|
||||||
|
|
||||||
if source_account.local? && !follow.account.local? && follow.account.activitypub?
|
create_notification(follow) if source_account.local? && !follow.account.local? && follow.account.activitypub?
|
||||||
create_notification(follow)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -96,9 +96,7 @@ class ResolveAccountService < BaseService
|
||||||
@webfinger = webfinger!("acct:#{confirmed_username}@#{confirmed_domain}")
|
@webfinger = webfinger!("acct:#{confirmed_username}@#{confirmed_domain}")
|
||||||
@username, @domain = split_acct(@webfinger.subject)
|
@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})" 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
|
|
||||||
rescue Webfinger::GoneError
|
rescue Webfinger::GoneError
|
||||||
@gone = true
|
@gone = true
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,9 +37,7 @@ class SearchService < BaseService
|
||||||
def perform_statuses_search!
|
def perform_statuses_search!
|
||||||
definition = parsed_query.apply(StatusesIndex.filter(term: { searchable_by: @account.id }))
|
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] }) if @options[:account_id].present?
|
||||||
definition = definition.filter(term: { account_id: @options[:account_id] })
|
|
||||||
end
|
|
||||||
|
|
||||||
if @options[:min_id].present? || @options[:max_id].present?
|
if @options[:min_id].present? || @options[:max_id].present?
|
||||||
range = {}
|
range = {}
|
||||||
|
|
|
@ -277,9 +277,7 @@ module Mastodon
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:days].present?
|
scope = scope.where('media_attachments.id > ?', Mastodon::Snowflake.id_at(options[:days].days.ago, with_random: false)) if options[:days].present?
|
||||||
scope = scope.where('media_attachments.id > ?', Mastodon::Snowflake.id_at(options[:days].days.ago, with_random: false))
|
|
||||||
end
|
|
||||||
|
|
||||||
processed, aggregate = parallelize_with_progress(scope) do |media_attachment|
|
processed, aggregate = parallelize_with_progress(scope) do |media_attachment|
|
||||||
next if media_attachment.remote_url.blank? || (!options[:force] && media_attachment.file_file_name.present?)
|
next if media_attachment.remote_url.blank? || (!options[:force] && media_attachment.file_file_name.present?)
|
||||||
|
|
|
@ -46,6 +46,4 @@ REDIS_SIDEKIQ_PARAMS = {
|
||||||
namespace: sidekiq_namespace,
|
namespace: sidekiq_namespace,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
if Rails.env.test?
|
ENV['REDIS_NAMESPACE'] = "mastodon_test#{ENV['TEST_ENV_NUMBER']}" if Rails.env.test?
|
||||||
ENV['REDIS_NAMESPACE'] = "mastodon_test#{ENV['TEST_ENV_NUMBER']}"
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
RSpec::Matchers.define :model_have_error_on_field do |expected|
|
RSpec::Matchers.define :model_have_error_on_field do |expected|
|
||||||
match do |record|
|
match do |record|
|
||||||
if record.errors.empty?
|
record.valid? if record.errors.empty?
|
||||||
record.valid?
|
|
||||||
end
|
|
||||||
|
|
||||||
record.errors.has_key?(expected)
|
record.errors.has_key?(expected)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue