]> git.openstreetmap.org Git - rails.git/commitdiff
Get note comment notification working again
authorTom Hughes <tom@compton.nu>
Sun, 14 Oct 2012 10:56:00 +0000 (11:56 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 14 Oct 2012 15:01:34 +0000 (16:01 +0100)
app/controllers/notes_controller.rb
app/models/notifier.rb
app/views/notifier/note_comment_notification.html.erb
app/views/notifier/note_comment_notification.text.erb [new file with mode: 0644]
config/locales/en.yml

index fe3615d7a0965e4290a21b5eb47fc00c9203ac63..95659a77157112fd3c169ecc5948efd09b343334 100644 (file)
@@ -319,11 +319,11 @@ private
       attributes[:author_name] = name + " (a)"
     end
 
       attributes[:author_name] = name + " (a)"
     end
 
-    note.comments.create(attributes, :without_protection => true)
+    comment = note.comments.create(attributes, :without_protection => true)
 
     note.comments.map { |c| c.author }.uniq.each do |user|
       if user and user != @user
 
     note.comments.map { |c| c.author }.uniq.each do |user|
       if user and user != @user
-        Notifier.deliver_note_comment_notification(comment, user)
+        Notifier.note_comment_notification(comment, user).deliver
       end
     end
   end
       end
     end
   end
index 2fb00c96f8f52255e1c1e5f8ff4f12baebca76ad..5ec401d18ea501d56e193188a8f6e6b2c971e6fa 100644 (file)
@@ -115,19 +115,17 @@ class Notifier < ActionMailer::Base
   end
 
   def note_comment_notification(comment, recipient)
   end
 
   def note_comment_notification(comment, recipient)
-    common_headers recipient
-    owner = (recipient == comment.note.author);
-    subject I18n.t('notifier.note_plain.subject_own', :commenter => comment.author_name) if owner
-    subject I18n.t('notifier.note_plain.subject_other', :commenter => comment.author_name) unless owner
-
-    body :nodeurl => url_for(:host => SERVER_URL,
-                             :controller => "browse",
-                             :action => "note",
-                             :id => comment.note_id),
-         :place => comment.note.nearby_place,
-         :comment => comment.body,
-         :owner => owner,
-         :commenter => comment.author_name
+    @locale = recipient.preferred_language_from(I18n.available_locales)
+    @noteurl = browse_note_url(comment.note, :host => SERVER_URL)
+    @place = comment.note.nearby_place
+    @comment = RichText::Text.new(comment.body)
+    @owner = recipient == comment.note.author
+    @commenter = comment.author_name
+
+    subject = I18n.t('notifier.note_comment_notification.subject_own', :commenter => comment.author_name) if @owner
+    subject = I18n.t('notifier.note_comment_notification.subject_other', :commenter => comment.author_name) unless @owner
+
+    mail :to => recipient.email, :subject => subject
   end
 
 private
   end
 
 private
index fade148d847f57e5fb0be006ff15fd3f5acfd06b..b17fe67f840102968aacc516f82f485d21d69dc1 100644 (file)
@@ -1,15 +1,13 @@
-<%= t 'notifier.note_plain.greeting' %>
+<p><%= t 'notifier.note_comment_notification.greeting' %></p>
 
 <% if @owner %>
 
 <% if @owner %>
-<%= t 'notifier.note_plain.your_note', :commenter => @commenter, :place => @place %>
+<p><%= t 'notifier.note_comment_notification.your_note', :commenter => @commenter, :place => @place %></p>
 <% else %>
 <% else %>
-<%= t 'notifier.note_plain.commented_note', :commenter => @commenter, :place => @place %>
+<p><%= t 'notifier.note_comment_notification.commented_note', :commenter => @commenter, :place => @place %></p>
 <% end %>
 
 ==
 <% end %>
 
 ==
-<%= @comment %>
+<%= @comment.to_html %>
 ==
 
 ==
 
-<%= t 'notifier.note_plain.details', :URL => @noteurl %>
-
-
+<p><%= raw t 'notifier.note_comment_notification.details', :url => link_to(@noteurl, @noteurl) %></p>
diff --git a/app/views/notifier/note_comment_notification.text.erb b/app/views/notifier/note_comment_notification.text.erb
new file mode 100644 (file)
index 0000000..7b4ccd3
--- /dev/null
@@ -0,0 +1,13 @@
+<%= t 'notifier.note_comment_notification.greeting' %>
+
+<% if @owner %>
+<%= t 'notifier.note_comment_notification.your_note', :commenter => @commenter, :place => @place %>
+<% else %>
+<%= t 'notifier.note_comment_notification.commented_note', :commenter => @commenter, :place => @place %>
+<% end %>
+
+==
+<%= @comment %>
+==
+
+<%= t 'notifier.note_comment_notification.details', :url => @noteurl %>
index 09c43fc091aaff8a71c00e627ba618a095dc8c8b..37d5c395a9d333b5ac7db428fdc3ba2405dff697 100644 (file)
@@ -1213,13 +1213,13 @@ 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."
       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."
-    note_plain:
+    note_comment_notification:
       subject_own: "[OpenStreetMap] %{commenter} has commented on one of your notes"
       subject_other: "[OpenStreetMap] %{commenter} has commented on a note you are interested in"
       greeting: "Hi,"
       your_note: "%{commenter} has left a comment on one of your map notes near %{place}."
       commented_note: "%{commenter} has left a comment on a map note you have commented on. The note is near %{place}."
       subject_own: "[OpenStreetMap] %{commenter} has commented on one of your notes"
       subject_other: "[OpenStreetMap] %{commenter} has commented on a note you are interested in"
       greeting: "Hi,"
       your_note: "%{commenter} has left a comment on one of your map notes near %{place}."
       commented_note: "%{commenter} has left a comment on a map note you have commented on. The note is near %{place}."
-      details: "More details about the note can be found at %{URL}."
+      details: "More details about the note can be found at %{url}."
   message:
     inbox:
       title: "Inbox"
   message:
     inbox:
       title: "Inbox"