Add `Api::V1::Instances::BaseController` base controller class (#27797)

shrike
Matt Jankowski 2023-11-10 07:46:00 -05:00 committed by GitHub
parent fba838d61a
commit ac69f90098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 16 additions and 34 deletions

View File

@ -1,12 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class Api::V1::Instances::ActivityController < Api::BaseController class Api::V1::Instances::ActivityController < Api::V1::Instances::BaseController
before_action :require_enabled_api! before_action :require_enabled_api!
skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
vary_by ''
def show def show
cache_even_if_authenticated! cache_even_if_authenticated!
render_with_cache json: :activity, expires_in: 1.day render_with_cache json: :activity, expires_in: 1.day

View File

@ -0,0 +1,8 @@
# frozen_string_literal: true
class Api::V1::Instances::BaseController < Api::BaseController
skip_before_action :require_authenticated_user!,
unless: :limited_federation_mode?
vary_by ''
end

View File

@ -1,8 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
class Api::V1::Instances::DomainBlocksController < Api::BaseController class Api::V1::Instances::DomainBlocksController < Api::V1::Instances::BaseController
skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
before_action :require_enabled_api! before_action :require_enabled_api!
before_action :set_domain_blocks before_action :set_domain_blocks

View File

@ -1,13 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
class Api::V1::Instances::ExtendedDescriptionsController < Api::BaseController class Api::V1::Instances::ExtendedDescriptionsController < Api::V1::Instances::BaseController
skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
skip_around_action :set_locale skip_around_action :set_locale
before_action :set_extended_description before_action :set_extended_description
vary_by ''
# Override `current_user` to avoid reading session cookies unless in whitelist mode # Override `current_user` to avoid reading session cookies unless in whitelist mode
def current_user def current_user
super if limited_federation_mode? super if limited_federation_mode?

View File

@ -1,13 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
class Api::V1::Instances::LanguagesController < Api::BaseController class Api::V1::Instances::LanguagesController < Api::V1::Instances::BaseController
skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
skip_around_action :set_locale skip_around_action :set_locale
before_action :set_languages before_action :set_languages
vary_by ''
def show def show
cache_even_if_authenticated! cache_even_if_authenticated!
render json: @languages, each_serializer: REST::LanguageSerializer render json: @languages, each_serializer: REST::LanguageSerializer

View File

@ -1,13 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
class Api::V1::Instances::PeersController < Api::BaseController class Api::V1::Instances::PeersController < Api::V1::Instances::BaseController
before_action :require_enabled_api! before_action :require_enabled_api!
skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
skip_around_action :set_locale skip_around_action :set_locale
vary_by ''
# Override `current_user` to avoid reading session cookies unless in whitelist mode # Override `current_user` to avoid reading session cookies unless in whitelist mode
def current_user def current_user
super if limited_federation_mode? super if limited_federation_mode?

View File

@ -1,12 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class Api::V1::Instances::PrivacyPoliciesController < Api::BaseController class Api::V1::Instances::PrivacyPoliciesController < Api::V1::Instances::BaseController
skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
before_action :set_privacy_policy before_action :set_privacy_policy
vary_by ''
def show def show
cache_even_if_authenticated! cache_even_if_authenticated!
render json: @privacy_policy, serializer: REST::PrivacyPolicySerializer render json: @privacy_policy, serializer: REST::PrivacyPolicySerializer

View File

@ -1,13 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
class Api::V1::Instances::RulesController < Api::BaseController class Api::V1::Instances::RulesController < Api::V1::Instances::BaseController
skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
skip_around_action :set_locale skip_around_action :set_locale
before_action :set_rules before_action :set_rules
vary_by ''
# Override `current_user` to avoid reading session cookies unless in whitelist mode # Override `current_user` to avoid reading session cookies unless in whitelist mode
def current_user def current_user
super if limited_federation_mode? super if limited_federation_mode?

View File

@ -1,12 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class Api::V1::Instances::TranslationLanguagesController < Api::BaseController class Api::V1::Instances::TranslationLanguagesController < Api::V1::Instances::BaseController
skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
before_action :set_languages before_action :set_languages
vary_by ''
def show def show
cache_even_if_authenticated! cache_even_if_authenticated!
render json: @languages render json: @languages