1 # frozen_string_literal: true
 
   4   module ChangesetComments
 
   5     class VisibilitiesController < ApiController
 
   6       before_action :check_api_writable
 
   7       before_action :authorize
 
   9       authorize_resource :class => :changeset_comment_visibility
 
  11       before_action :set_request_formats
 
  14       # Sets visible flag on comment to true
 
  16         # Check the arguments are sane
 
  17         raise OSM::APIBadUserInput, "No id was given" unless params[:changeset_comment_id]
 
  19         # Extract the arguments
 
  20         changeset_comment_id = params[:changeset_comment_id].to_i
 
  23         comment = ChangesetComment.find(changeset_comment_id)
 
  26         comment.update(:visible => true)
 
  28         # Return a copy of the updated changeset
 
  29         @changeset = comment.changeset
 
  31         respond_to do |format|
 
  38       # Sets visible flag on comment to false
 
  40         # Check the arguments are sane
 
  41         raise OSM::APIBadUserInput, "No id was given" unless params[:changeset_comment_id]
 
  43         # Extract the arguments
 
  44         changeset_comment_id = params[:changeset_comment_id].to_i
 
  47         comment = ChangesetComment.find(changeset_comment_id)
 
  50         comment.update(:visible => false)
 
  52         # Return a copy of the updated changeset
 
  53         @changeset = comment.changeset
 
  55         respond_to do |format|