]> git.openstreetmap.org Git - rails.git/blob - app/controllers/changeset_comments/feeds_controller.rb
Add frozen_string_literal comments to ruby files
[rails.git] / app / controllers / changeset_comments / feeds_controller.rb
1 # frozen_string_literal: true
2
3 module ChangesetComments
4   class FeedsController < ApplicationController
5     include QueryMethods
6
7     before_action :authorize_web
8     before_action :set_locale
9
10     authorize_resource :changeset_comment
11
12     before_action -> { check_database_readable(:need_api => true) }
13     around_action :web_timeout
14
15     ##
16     # Get a feed of recent changeset comments
17     def show
18       if params[:changeset_id]
19         # Extract the arguments
20         changeset_id = params[:changeset_id].to_i
21
22         # Find the changeset
23         changeset = Changeset.find(changeset_id)
24
25         # Return comments for this changeset only
26         @comments = changeset.comments.includes(:author, :changeset).reverse_order
27         @comments = query_limit(@comments)
28       else
29         # Return comments
30         @comments = ChangesetComment.includes(:author, :changeset).where(:visible => true).order(:created_at => :desc)
31         @comments = query_limit(@comments)
32         @comments = @comments.preload(:changeset)
33       end
34
35       # Render the result
36       respond_to do |format|
37         format.rss
38       end
39     rescue OSM::APIBadUserInput
40       head :bad_request
41     end
42   end
43 end