X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/02628bed1e7b5c2656bc68076403467e92462b4f..26279b55cac5dc889bdfbe276d1127683a15809b:/app/controllers/message_controller.rb diff --git a/app/controllers/message_controller.rb b/app/controllers/message_controller.rb index 6c7be5e0f..73abc68cc 100644 --- a/app/controllers/message_controller.rb +++ b/app/controllers/message_controller.rb @@ -15,20 +15,25 @@ class MessageController < ApplicationController @to_user = User.find_by_display_name(params[:display_name]) if @to_user if params[:message] - @message = Message.new(params[:message]) - @message.to_user_id = @to_user.id - @message.from_user_id = @user.id - @message.sent_on = Time.now.getutc + if @user.sent_messages.count(:conditions => ["sent_on >= ?", Time.now.getutc - 1.hour]) >= APP_CONFIG['max_messages_per_hour'] + flash[:error] = t 'message.new.limit_exceeded' + else + @message = Message.new(params[:message]) + @message.to_user_id = @to_user.id + @message.from_user_id = @user.id + @message.sent_on = Time.now.getutc - if @message.save - flash[:notice] = t 'message.new.message_sent' - Notifier::deliver_message_notification(@message) - redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name + if @message.save + flash[:notice] = t 'message.new.message_sent' + Notifier::deliver_message_notification(@message) + redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name + end end else if params[:title] - # ?title= is set when someone reponds to this user's diary entry - @title = params[:title] + # ?title= is set when someone reponds to this user's diary + # entry. Then we pre-fill out the subject and the