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 OldElementsController < ApiController
6 before_action :check_api_writable, :only => [:redact]
7 before_action :setup_user_auth, :only => [:history, :show]
8 before_action :authorize, :only => [:redact]
12 around_action :api_call_handle_error, :api_call_timeout
13 before_action :lookup_old_element, :except => [:history]
14 before_action :lookup_old_element_versions, :only => [:history]
16 before_action :set_request_formats, :except => [:redact]
19 # the .where() method used in the lookup_old_element_versions
20 # call won't throw an error if no records are found, so we have
21 # to do that ourselves.
22 raise OSM::APINotFoundError if @elements.empty?
24 # determine visible elements
25 @elems = if show_redactions?
32 respond_to do |format|
39 if @old_element.redacted? && !show_redactions?
43 response.last_modified = @old_element.timestamp
46 respond_to do |format|
54 redaction_id = params["redaction"]
56 # if no redaction ID was provided, then this is an unredact
58 @old_element.redact!(nil)
60 # if a redaction ID was specified, then set this element to
61 # be redacted in that redaction.
62 redaction = Redaction.find(redaction_id.to_i)
63 @old_element.redact!(redaction)
66 # just return an empty 200 OK for success
73 current_user&.moderator? && params[:show_redactions] == "true"