]> git.openstreetmap.org Git - rails.git/blob - app/controllers/api/changesets/uploads_controller.rb
Add frozen_string_literal comments to ruby files
[rails.git] / app / controllers / api / changesets / uploads_controller.rb
1 # frozen_string_literal: true
2
3 module Api
4   module Changesets
5     class UploadsController < ApiController
6       before_action :check_api_writable
7       before_action :authorize
8
9       authorize_resource :class => Changeset
10
11       before_action :require_public_data
12
13       skip_around_action :api_call_timeout
14
15       # Helper methods for checking consistency
16       include ConsistencyValidations
17
18       ##
19       # Upload a diff in a single transaction.
20       #
21       # This means that each change within the diff must succeed, i.e: that
22       # each version number mentioned is still current. Otherwise the entire
23       # transaction *must* be rolled back.
24       #
25       # Furthermore, each element in the diff can only reference the current
26       # changeset.
27       #
28       # Returns: a diffResult document, as described in
29       # http://wiki.openstreetmap.org/wiki/OSM_Protocol_Version_0.6
30       def create
31         changeset = Changeset.find(params[:changeset_id])
32         check_changeset_consistency(changeset, current_user)
33
34         diff_reader = DiffReader.new(request.raw_post, changeset)
35         Changeset.transaction do
36           result = diff_reader.commit
37           # the number of changes in this changeset has already been
38           # updated and is visible in this transaction so we don't need
39           # to allow for any more when checking the limit
40           check_rate_limit(0)
41           render :xml => result.to_s
42         end
43       end
44     end
45   end
46 end