From 2e652aa81c22c802e4571e6cfa443319cb862614 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Tue, 7 Feb 2023 20:25:20 -0500 Subject: Apply Rubocop Performance/RedundantSplitRegexpArgument (#23443) * Apply Rubocop Performance/RedundantSplitRegexpArgument * Update app/controllers/concerns/signature_verification.rb --- app/controllers/concerns/signature_verification.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/concerns/signature_verification.rb b/app/controllers/concerns/signature_verification.rb index a9950d21f..9c04ab4ca 100644 --- a/app/controllers/concerns/signature_verification.rb +++ b/app/controllers/concerns/signature_verification.rb @@ -227,7 +227,7 @@ module SignatureVerification end def to_header_name(name) - name.split(/-/).map(&:capitalize).join('-') + name.split('-').map(&:capitalize).join('-') end def missing_required_signature_parameters? -- cgit From f68bb52556fe90d7adad8db9ba8b801a22281f30 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Wed, 8 Feb 2023 01:07:36 -0500 Subject: Apply Rubocop Style/NegatedIfElseCondition (#23451) --- app/controllers/api/v1/streaming_controller.rb | 6 +++--- app/models/user.rb | 2 +- app/services/fetch_oembed_service.rb | 2 +- app/services/verify_link_service.rb | 2 +- lib/tasks/mastodon.rake | 12 ++++++------ 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/api/v1/streaming_controller.rb b/app/controllers/api/v1/streaming_controller.rb index 7cd60615a..b23a60170 100644 --- a/app/controllers/api/v1/streaming_controller.rb +++ b/app/controllers/api/v1/streaming_controller.rb @@ -2,10 +2,10 @@ class Api::V1::StreamingController < Api::BaseController def index - if Rails.configuration.x.streaming_api_base_url != request.host - redirect_to streaming_api_url, status: 301 - else + if Rails.configuration.x.streaming_api_base_url == request.host not_found + else + redirect_to streaming_api_url, status: 301 end end diff --git a/app/models/user.rb b/app/models/user.rb index d40044da3..c767f8984 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -265,7 +265,7 @@ class User < ApplicationRecord end def inactive_message - !approved? ? :pending : super + approved? ? super : :pending end def approve! diff --git a/app/services/fetch_oembed_service.rb b/app/services/fetch_oembed_service.rb index 7d0879c79..9851ac098 100644 --- a/app/services/fetch_oembed_service.rb +++ b/app/services/fetch_oembed_service.rb @@ -82,7 +82,7 @@ class FetchOEmbedService return if @endpoint_url.blank? body = Request.new(:get, @endpoint_url).perform do |res| - res.code != 200 ? nil : res.body_with_limit + res.code == 200 ? res.body_with_limit : nil end validate(parse_for_format(body)) if body.present? diff --git a/app/services/verify_link_service.rb b/app/services/verify_link_service.rb index f83a664d4..707aeb4e0 100644 --- a/app/services/verify_link_service.rb +++ b/app/services/verify_link_service.rb @@ -19,7 +19,7 @@ class VerifyLinkService < BaseService def perform_request! @body = Request.new(:get, @url).add_headers('Accept' => 'text/html').perform do |res| - res.code != 200 ? nil : res.body_with_limit + res.code == 200 ? res.body_with_limit : nil end end diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 876383d7f..1184e5273 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -463,10 +463,10 @@ namespace :mastodon do prompt.say 'Running `RAILS_ENV=production rails db:setup` ...' prompt.say "\n\n" - if !system(env.transform_values(&:to_s).merge({ 'RAILS_ENV' => 'production', 'SAFETY_ASSURED' => '1' }), 'rails db:setup') - prompt.error 'That failed! Perhaps your configuration is not right' - else + if system(env.transform_values(&:to_s).merge({ 'RAILS_ENV' => 'production', 'SAFETY_ASSURED' => '1' }), 'rails db:setup') prompt.ok 'Done!' + else + prompt.error 'That failed! Perhaps your configuration is not right' end end @@ -479,10 +479,10 @@ namespace :mastodon do prompt.say 'Running `RAILS_ENV=production rails assets:precompile` ...' prompt.say "\n\n" - if !system(env.transform_values(&:to_s).merge({ 'RAILS_ENV' => 'production' }), 'rails assets:precompile') - prompt.error 'That failed! Maybe you need swap space?' - else + if system(env.transform_values(&:to_s).merge({ 'RAILS_ENV' => 'production' }), 'rails assets:precompile') prompt.say 'Done!' + else + prompt.error 'That failed! Maybe you need swap space?' end end end -- cgit From 832595d1e79f9c185efd6d18741f295745ee536a Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 8 Feb 2023 17:57:25 +0100 Subject: Remove posts count and last posts from ActivityPub representation of hashtag collections (#23460) --- app/controllers/tags_controller.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 65017acba..750e15fa3 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -11,7 +11,7 @@ class TagsController < ApplicationController before_action :authenticate_user!, if: :whitelist_mode? before_action :set_local before_action :set_tag - before_action :set_statuses + before_action :set_statuses, if: -> { request.format == :rss } before_action :set_instance_presenter skip_before_action :require_functional!, unless: :whitelist_mode? @@ -44,12 +44,7 @@ class TagsController < ApplicationController end def set_statuses - case request.format&.to_sym - when :json - @statuses = cache_collection(TagFeed.new(@tag, current_account, local: @local).get(PAGE_SIZE, params[:max_id], params[:since_id], params[:min_id]), Status) - when :rss - @statuses = cache_collection(TagFeed.new(@tag, nil, local: @local).get(limit_param), Status) - end + @statuses = cache_collection(TagFeed.new(@tag, nil, local: @local).get(limit_param), Status) end def set_instance_presenter @@ -64,8 +59,6 @@ class TagsController < ApplicationController ActivityPub::CollectionPresenter.new( id: tag_url(@tag), type: :ordered, - size: @tag.statuses.count, - items: @statuses.map { |status| ActivityPub::TagManager.instance.uri_for(status) } ) end end -- cgit