3 class MailboxesController < ApiController
4 before_action :authorize
6 authorize_resource :message
8 before_action :set_request_formats
13 @messages = @messages.where(:muted => false)
14 if params[:order].nil? || params[:order] == "newest"
15 @messages = @messages.where(:id => ..params[:from_id]) unless params[:from_id].nil?
16 @messages = @messages.order(:id => :desc)
17 elsif params[:order] == "oldest"
18 @messages = @messages.where(:id => params[:from_id]..) unless params[:from_id].nil?
19 @messages = @messages.order(:id => :asc)
21 raise OSM::APIBadUserInput, "Invalid order specified"
24 limit = params[:limit]
26 limit = Settings.default_message_query_limit
27 elsif !limit.to_i.positive? || limit.to_i > Settings.max_message_query_limit
28 raise OSM::APIBadUserInput, "Messages limit must be between 1 and #{Settings.max_message_query_limit}"
33 @messages = @messages.limit(limit)
36 respond_to do |format|