1 # this class pulls together the logic for all the old_* controllers
2 # into one place. as it turns out, the API methods for historical
3 # nodes, ways and relations are basically identical.
5 class OldController < ApiController
8 before_action :setup_user_auth, :only => [:history, :version]
9 before_action :authorize, :only => [:redact]
13 before_action :check_api_readable
14 before_action :check_api_writable, :only => [:redact]
15 around_action :api_call_handle_error, :api_call_timeout
16 before_action :lookup_old_element, :except => [:history]
17 before_action :lookup_old_element_versions, :only => [:history]
20 # the .where() method used in the lookup_old_element_versions
21 # call won't throw an error if no records are found, so we have
22 # to do that ourselves.
23 raise OSM::APINotFoundError if @elements.empty?
25 # determine visible elements
26 @elems = if show_redactions?
33 render formats: [:xml]
37 if @old_element.redacted? && !show_redactions?
41 response.last_modified = @old_element.timestamp
44 render formats: [:xml]
49 redaction_id = params["redaction"]
51 # if no redaction ID was provided, then this is an unredact
53 @old_element.redact!(nil)
55 # if a redaction ID was specified, then set this element to
56 # be redacted in that redaction.
57 redaction = Redaction.find(redaction_id.to_i)
58 @old_element.redact!(redaction)
61 # just return an empty 200 OK for success
68 current_user&.moderator? && params[:show_redactions] == "true"