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