Make friend notification messages include a link to add a reciprocal
authorTom Hughes <tom@compton.nu>
Mon, 1 Mar 2010 12:08:11 +0000 (12:08 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 1 Mar 2010 12:08:11 +0000 (12:08 +0000)
friendship if it doesn't already exist. Closes #2754.

app/models/notifier.rb
app/views/notifier/friend_notification.html.erb
config/locales/en.yml

index 1f3d39808ecafcfd29a56debb63fe9dfc925dc7d..df30d651bd75ce4d678ee12ec799587f202b8cb8 100644 (file)
@@ -89,15 +89,9 @@ class Notifier < ActionMailer::Base
   end
 
   def friend_notification(friend)
-    befriender = User.find_by_id(friend.user_id)
-    befriendee = User.find_by_id(friend.friend_user_id)
-
-    common_headers befriendee
-    subject I18n.t('notifier.friend_notification.subject', :user => befriender.display_name, :locale => locale)
-    body :user => befriender.display_name,
-         :userurl => url_for(:host => SERVER_URL,
-                             :controller => "user", :action => "view",
-                             :display_name => befriender.display_name)
+    common_headers friend.befriendee
+    subject I18n.t('notifier.friend_notification.subject', :user => friend.befriender.display_name, :locale => locale)
+    body :friend => friend
   end
 
 private
index 8917061f1444d3e556ee824c1d374696da85a74b..ca77547570a6f543f4e7694ba7c7a0fb1da12b3f 100644 (file)
@@ -1,4 +1,20 @@
-<%= t'notifier.friend_notification.had_added_you', :user => @user %>
+<%=
+  t 'notifier.friend_notification.had_added_you',
+     :user => @friend.befriender.display_name
+%>
 
-<%= t'notifier.friend_notification.see_their_profile', :userurl => @userurl %>
+<%=
+  t 'notifier.friend_notification.see_their_profile',
+     :userurl => url_for(:host => SERVER_URL,
+                         :controller => "user", :action => "view",
+                         :display_name => @friend.befriender.display_name)
+%>
 
+<%=
+  unless @friend.befriendee.is_friends_with?(@friend.befriender)
+    t 'notifier.friend_notification.befriend_them',
+       :befriendurl => url_for(:host => SERVER_URL,
+                               :controller => "user", :action => "make_friend",
+                               :display_name => @friend.befriender.display_name)
+  end
+%>
index 139bf5775c9df628bed08b37fa0c077e0029c390..45c21f36b7cfbfdf3c937b915a37f2ef57dc0531 100644 (file)
@@ -941,7 +941,8 @@ en:
     friend_notification:
       subject: "[OpenStreetMap] {{user}} added you as a friend"
       had_added_you: "{{user}} has added you as a friend on OpenStreetMap."
-      see_their_profile: "You can see their profile at {{userurl}} and add them as a friend too if you wish."
+      see_their_profile: "You can see their profile at {{userurl}}."
+      befriend_them: "You can also add them as a friend at {{befriendurl}}."
     gpx_notification:
       greeting: "Hi,"
       your_gpx_file: "It looks like your GPX file"