]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/browse_controller.rb
Refactor common element version view code
[rails.git] / app / controllers / browse_controller.rb
index 50d0ae0a545e60b130331aabbbeb5764331a540c..e842d4872bf753a5c3993f7bb93455be84643c9b 100644 (file)
@@ -5,6 +5,8 @@ class BrowseController < ApplicationController
   before_action :set_locale
   before_action -> { check_database_readable(:need_api => true) }
   before_action :require_oauth
+  before_action :update_totp, :only => [:query]
+  before_action :require_moderator_for_unredacted_history, :only => [:relation_history, :way_history, :node_history]
   around_action :web_timeout
   authorize_resource :class => false
 
@@ -75,17 +77,11 @@ class BrowseController < ApplicationController
     render :action => "not_found", :status => :not_found
   end
 
-  def note
-    @type = "note"
+  def query; end
 
-    if current_user&.moderator?
-      @note = Note.find(params[:id])
-      @note_comments = @note.comments.unscope(:where => :visible)
-    else
-      @note = Note.visible.find(params[:id])
-      @note_comments = @note.comments
-    end
-  rescue ActiveRecord::RecordNotFound
-    render :action => "not_found", :status => :not_found
+  private
+
+  def require_moderator_for_unredacted_history
+    deny_access(nil) if params[:show_redactions] && !current_user&.moderator?
   end
 end