X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/017f7da76f3d59a71c3cca481e0d3a20afe1c046..45c90003c688988590e91108f2ec64a199050578:/app/controllers/api/messages_controller.rb diff --git a/app/controllers/api/messages_controller.rb b/app/controllers/api/messages_controller.rb index 886922bff..cbbd8539c 100644 --- a/app/controllers/api/messages_controller.rb +++ b/app/controllers/api/messages_controller.rb @@ -11,20 +11,6 @@ module Api 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]) @@ -111,37 +97,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