1 # frozen_string_literal: true
 
   5     class ClosesController < ApiController
 
   6       before_action :check_api_writable
 
   7       before_action :authorize
 
   9       authorize_resource :class => Changeset
 
  11       before_action :require_public_data
 
  13       # Helper methods for checking consistency
 
  14       include ConsistencyValidations
 
  17       # marks a changeset as closed. this may be called multiple times
 
  18       # on the same changeset, so is idempotent.
 
  20         changeset = Changeset.find(params[:changeset_id])
 
  21         check_changeset_consistency(changeset, current_user)
 
  23         # to close the changeset, we'll just set its closed_at time to
 
  24         # now. this might not be enough if there are concurrency issues,
 
  25         # but we'll have to wait and see.
 
  26         changeset.set_closed_time_now