From: Dan Karran Date: Wed, 5 Sep 2007 22:27:22 +0000 (+0000) Subject: Send an email notification out when a new message is waiting on the site for you. X-Git-Tag: live~8158 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/285d61bf4cd6cd93e6ae0f4905db9faf4a6f71f5 Send an email notification out when a new message is waiting on the site for you. --- diff --git a/app/controllers/message_controller.rb b/app/controllers/message_controller.rb index 8521d76b3..52f38e9f6 100644 --- a/app/controllers/message_controller.rb +++ b/app/controllers/message_controller.rb @@ -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 diff --git a/app/models/notifier.rb b/app/models/notifier.rb index aaad67d0e..00bec921c 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -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 diff --git a/app/views/notifier/message_notification.rhtml b/app/views/notifier/message_notification.rhtml new file mode 100644 index 000000000..79a03d0f1 --- /dev/null +++ b/app/views/notifier/message_notification.rhtml @@ -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 %> \ No newline at end of file