1 module ChangesetComments
 
   2   class FeedsController < ApplicationController
 
   3     before_action :authorize_web
 
   4     before_action :set_locale
 
   6     authorize_resource :changeset_comment
 
   8     before_action -> { check_database_readable(:need_api => true) }
 
   9     around_action :web_timeout
 
  12     # Get a feed of recent changeset comments
 
  14       if params[:changeset_id]
 
  15         # Extract the arguments
 
  16         changeset_id = params[:changeset_id].to_i
 
  19         changeset = Changeset.find(changeset_id)
 
  21         # Return comments for this changeset only
 
  22         @comments = changeset.comments.includes(:author, :changeset).reverse_order.limit(comments_limit)
 
  25         @comments = ChangesetComment.includes(:author, :changeset).where(:visible => true).order("created_at DESC").limit(comments_limit).preload(:changeset)
 
  29       respond_to do |format|
 
  32     rescue OSM::APIBadUserInput
 
  39     # Get the maximum number of comments to return
 
  42         if params[:limit].to_i.positive? && params[:limit].to_i <= 10000
 
  45           raise OSM::APIBadUserInput, "Comments limit must be between 1 and 10000"