From: Kai Krueger Date: Wed, 27 Apr 2011 18:01:52 +0000 (-0600) Subject: Send notification emails when someone comments on a map bug report X-Git-Tag: live~5677^2~189 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/b3d62bb85a03a0b68068d3d2e7801ec2cd2e3e7b Send notification emails when someone comments on a map bug report --- diff --git a/app/controllers/map_bugs_controller.rb b/app/controllers/map_bugs_controller.rb index bbde2148f..a967384b6 100644 --- a/app/controllers/map_bugs_controller.rb +++ b/app/controllers/map_bugs_controller.rb @@ -311,7 +311,18 @@ private end bug_comment.save; bug.last_changed = t - bug.save + bug.save + + sent_to = Set.new; + bug.map_bug_comment.each do | cmt | + if cmt.user + unless sent_to.include?(cmt.user) + Notifier.deliver_bug_comment_notification(bug_comment, cmt.user) unless cmt.user == @user; + sent_to.add(cmt.user); + end + end + end + end end diff --git a/app/models/notifier.rb b/app/models/notifier.rb index e6058d4b7..d3c975df9 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -95,6 +95,24 @@ class Notifier < ActionMailer::Base body :friend => friend end + def bug_comment_notification(bug_comment, recipient) + common_headers recipient + commenter_name = bug_comment.user.display_name if bug_comment.user + commenter_name = bug_comment.commenter_name unless bug_comment.user + owner = (recipient == bug_comment.map_bug.map_bug_comment[0].user); + subject I18n.t('notifier.map_bug_plain.subject_own', :commenter => commenter_name) if owner + subject I18n.t('notifier.map_bug_plain.subject_other', :commenter => commenter_name) unless owner + + body :bugurl => url_for(:host => SERVER_URL, + :controller => "browse", + :action => "bug", + :id => bug_comment.bug_id), + :place => bug_comment.map_bug.nearby_place, + :comment => bug_comment.comment, + :owner => owner, + :commenter => commenter_name + end + private def common_headers(recipient) diff --git a/app/views/notifier/bug_comment_notification.html.erb b/app/views/notifier/bug_comment_notification.html.erb new file mode 100644 index 000000000..ff8ad4265 --- /dev/null +++ b/app/views/notifier/bug_comment_notification.html.erb @@ -0,0 +1,15 @@ +<%= t 'notifier.map_bug_plain.greeting' %> + +<% if @owner %> +<%= t 'notifier.map_bug_plain.your_bug', :commenter => @commenter, :place => @place %> +<% else %> +<%= t 'notifier.map_bug_plain.commented_bug', :commenter => @commenter, :place => @place %> +<% end %> + +== +<%= @comment %> +== + +<%= t 'notifier.map_bug_plain.details', :URL => @bugurl %> + + diff --git a/config/locales/en.yml b/config/locales/en.yml index e57bbd050..667a6faeb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1176,6 +1176,14 @@ en: greeting: "Hi," hopefully_you: "Someone (possibly you) has asked for the password to be reset on this email address's openstreetmap.org account." click_the_link: "If this is you, please click the link below to reset your password." + map_bug_plain: + subject_own: "[OpenStreetMap bugs] {{commenter}} has commented on one of your bugs" + subject_other: "[OpenStreetMap bugs] {{commenter}} has commented on a bug you are interested in" + greeting: "Hi," + your_bug: "{{commenter}} has left a comment on one of your map bug reports near {{place}}." + commented_bug: "{{commenter}} has left a comment on a map bug report you have commented on. The bug is near {{place}}." + details: "More details about the bug report can be found at {{URL}}." + message: inbox: title: "Inbox"