1 # frozen_string_literal: true
 
   3 # this class pulls together the logic for all the old_* controllers
 
   4 # into one place. as it turns out, the API methods for historical
 
   5 # nodes, ways and relations are basically identical.
 
   7   class OldElementsController < ApiController
 
   8     before_action :setup_user_auth
 
  12     before_action :lookup_old_element, :except => [:index]
 
  13     before_action :lookup_old_element_versions, :only => [:index]
 
  15     before_action :set_request_formats
 
  18       # the .where() method used in the lookup_old_element_versions
 
  19       # call won't throw an error if no records are found, so we have
 
  20       # to do that ourselves.
 
  21       raise OSM::APINotFoundError if @elements.empty?
 
  23       # determine visible elements
 
  24       @elements = @elements.unredacted unless show_redactions?
 
  27       respond_to do |format|
 
  34       if @old_element.redacted? && !show_redactions?
 
  38         response.last_modified = @old_element.timestamp
 
  41         respond_to do |format|
 
  51       current_user&.moderator? && params[:show_redactions] == "true"