Send an email notification out when a new message is waiting on the site for you.

This commit is contained in:
Dan Karran 2007-09-05 22:27:22 +00:00
parent a287d24f12
commit 285d61bf4c
3 changed files with 18 additions and 0 deletions

View file

@ -14,6 +14,7 @@ class MessageController < ApplicationController
if @message.save
flash[:notice] = 'Message sent'
Notifier::deliver_message_notification(@message)
redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
end
end

View file

@ -37,4 +37,16 @@ class Notifier < ActionMailer::Base
@body['trace_name'] = trace.name
@body['error'] = error
end
def message_notification(message)
@from_user = User.find(message.from_user_id)
@to_user = User.find(message.to_user_id)
@recipients = @to_user.email
@from = 'abuse@openstreetmap.org'
@subject = "[OpenStreetMap] #{@from_user.display_name} sent you a new message"
@body['to_user'] = @to_user.display_name
@body['from_user'] = @from_user.display_name
@body['subject'] = message.title
@body['url'] = "http://#{SERVER_URL}/message/read/#{message.id}"
end
end

View file

@ -0,0 +1,5 @@
Hi <%= @to_user %>,
<%= @from_user %> has sent you a message through OpenStreetMap with the subject "<%= @subject %>". You can read the message at:
<%= @url %>