X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/5f2a5cadcb693b34b81a9232b8879c3b4f12843d..refs/heads/master:/app/controllers/api/messages_controller.rb diff --git a/app/controllers/api/messages_controller.rb b/app/controllers/api/messages_controller.rb index 074f87398..ea5abe8df 100644 --- a/app/controllers/api/messages_controller.rb +++ b/app/controllers/api/messages_controller.rb @@ -5,28 +5,11 @@ module Api before_action :authorize before_action :check_api_writable, :only => [:create, :update, :destroy] - before_action :check_api_readable, :except => [:create, :update, :destroy] authorize_resource - around_action :api_call_handle_error, :api_call_timeout - before_action :set_request_formats - def inbox - @skip_body = true - @messages = Message.includes(:sender, :recipient).where(:to_user_id => current_user.id) - - show_messages - end - - def outbox - @skip_body = true - @messages = Message.includes(:sender, :recipient).where(:from_user_id => current_user.id) - - show_messages - end - # Dump the details on a message given in params[:id] def show @message = Message.includes(:sender, :recipient).find(params[:id]) @@ -113,37 +96,5 @@ module Api format.json { render :action => :show } end end - - private - - def show_messages - @messages = @messages.where(:muted => false) - if params[:order].nil? || params[:order] == "newest" - @messages = @messages.where(:id => ..params[:from_id]) unless params[:from_id].nil? - @messages = @messages.order(:id => :desc) - elsif params[:order] == "oldest" - @messages = @messages.where(:id => params[:from_id]..) unless params[:from_id].nil? - @messages = @messages.order(:id => :asc) - else - raise OSM::APIBadUserInput, "Invalid order specified" - end - - limit = params[:limit] - if !limit - limit = Settings.default_message_query_limit - elsif !limit.to_i.positive? || limit.to_i > Settings.max_message_query_limit - raise OSM::APIBadUserInput, "Messages limit must be between 1 and #{Settings.max_message_query_limit}" - else - limit = limit.to_i - end - - @messages = @messages.limit(limit) - - # Render the result - respond_to do |format| - format.xml - format.json - end - end end end