Send an email notification out when a new message is waiting on the site for you.
This commit is contained in:
parent
a287d24f12
commit
285d61bf4c
3 changed files with 18 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
5
app/views/notifier/message_notification.rhtml
Normal file
5
app/views/notifier/message_notification.rhtml
Normal 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 %>
|
Loading…
Add table
Add a link
Reference in a new issue