1 # frozen_string_literal: true
 
   3 module ChangesetComments
 
   4   class FeedsController < ApplicationController
 
   7     before_action :authorize_web
 
   8     before_action :set_locale
 
  10     authorize_resource :changeset_comment
 
  12     before_action -> { check_database_readable(:need_api => true) }
 
  13     around_action :web_timeout
 
  16     # Get a feed of recent changeset comments
 
  18       if params[:changeset_id]
 
  19         # Extract the arguments
 
  20         changeset_id = params[:changeset_id].to_i
 
  23         changeset = Changeset.find(changeset_id)
 
  25         # Return comments for this changeset only
 
  26         @comments = changeset.comments.includes(:author, :changeset).reverse_order
 
  27         @comments = query_limit(@comments)
 
  30         @comments = ChangesetComment.includes(:author, :changeset).where(:visible => true).order(:created_at => :desc)
 
  31         @comments = query_limit(@comments)
 
  32         @comments = @comments.preload(:changeset)
 
  36       respond_to do |format|
 
  39     rescue OSM::APIBadUserInput