about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2018-12-11 19:18:29 +0100
committerEugen Rochko <eugen@zeonfederated.com>2018-12-11 19:18:29 +0100
commit720daa81435b4c632cdf7b64044cf1ee59af977a (patch)
tree17b3bb837d40d102b920120e7c185655cec67aa7 /app/controllers
parenta48fe52375f207f538b3be675a943c3dd8603541 (diff)
Add instance-wide setting to disable profile directory (#9497)
* Add instance-wide setting to disable profile directory

Fixes #9496

When the profile directory is disabled:
- The “discoverable” setting is hidden from users
- The “profile directory” link is not shown on public pages
- /explore returns 404

* Move Setting.profile_directory check to a before_action filter
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/dashboard_controller.rb1
-rw-r--r--app/controllers/admin/settings_controller.rb2
-rw-r--r--app/controllers/directories_controller.rb5
3 files changed, 8 insertions, 0 deletions
diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb
index 7be753c9b..bb923c185 100644
--- a/app/controllers/admin/dashboard_controller.rb
+++ b/app/controllers/admin/dashboard_controller.rb
@@ -28,6 +28,7 @@ module Admin
       @pam_enabled           = ENV['PAM_ENABLED'] == 'true'
       @hidden_service        = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true'
       @trending_hashtags     = TrendingTags.get(7)
+      @profile_directory     = Setting.profile_directory
     end
 
     private
diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb
index d9f261489..4a049fc23 100644
--- a/app/controllers/admin/settings_controller.rb
+++ b/app/controllers/admin/settings_controller.rb
@@ -26,6 +26,7 @@ module Admin
       show_known_fediverse_at_about_page
       preview_sensitive_media
       custom_css
+      profile_directory
     ).freeze
 
     BOOLEAN_SETTINGS = %w(
@@ -37,6 +38,7 @@ module Admin
       peers_api_enabled
       show_known_fediverse_at_about_page
       preview_sensitive_media
+      profile_directory
     ).freeze
 
     UPLOAD_SETTINGS = %w(
diff --git a/app/controllers/directories_controller.rb b/app/controllers/directories_controller.rb
index 265fd5fab..b8565af4b 100644
--- a/app/controllers/directories_controller.rb
+++ b/app/controllers/directories_controller.rb
@@ -3,6 +3,7 @@
 class DirectoriesController < ApplicationController
   layout 'public'
 
+  before_action :check_enabled
   before_action :set_instance_presenter
   before_action :set_tag, only: :show
   before_action :set_tags
@@ -18,6 +19,10 @@ class DirectoriesController < ApplicationController
 
   private
 
+  def check_enabled
+    return not_found unless Setting.profile_directory
+  end
+
   def set_tag
     @tag = Tag.discoverable.find_by!(name: params[:id].downcase)
   end