From: Andy Allan Date: Wed, 3 Jun 2020 16:29:08 +0000 (+0200) Subject: Rename friend to friendship in notifier X-Git-Tag: live~2697^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/3786366fdc691320c0a2c6982fe43a8e4b80bcc6 Rename friend to friendship in notifier Followup to #2269 --- diff --git a/app/controllers/friendships_controller.rb b/app/controllers/friendships_controller.rb index 034173e61..a983bec75 100644 --- a/app/controllers/friendships_controller.rb +++ b/app/controllers/friendships_controller.rb @@ -21,7 +21,7 @@ class FriendshipsController < ApplicationController flash[:warning] = t "friendships.make_friend.already_a_friend", :name => @new_friend.display_name elsif friendship.save flash[:notice] = t "friendships.make_friend.success", :name => @new_friend.display_name - Notifier.friend_notification(friendship).deliver_later + Notifier.friendship_notification(friendship).deliver_later else friendship.add_error(t("friendships.make_friend.failed", :name => @new_friend.display_name)) end diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index 558339889..3c794cca9 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -106,16 +106,16 @@ class Notifier < ApplicationMailer end end - def friend_notification(friend) - with_recipient_locale friend.befriendee do - @friend = friend - @viewurl = user_url(@friend.befriender) - @friendurl = make_friend_url(@friend.befriender) - @author = @friend.befriender.display_name - - attach_user_avatar(@friend.befriender) - mail :to => friend.befriendee.email, - :subject => I18n.t("notifier.friend_notification.subject", :user => friend.befriender.display_name) + def friendship_notification(friendship) + with_recipient_locale friendship.befriendee do + @friendship = friendship + @viewurl = user_url(@friendship.befriender) + @friendurl = make_friend_url(@friendship.befriender) + @author = @friendship.befriender.display_name + + attach_user_avatar(@friendship.befriender) + mail :to => friendship.befriendee.email, + :subject => I18n.t("notifier.friendship_notification.subject", :user => friendship.befriender.display_name) end end diff --git a/app/views/notifier/friend_notification.text.erb b/app/views/notifier/friend_notification.text.erb deleted file mode 100644 index e1db966ab..000000000 --- a/app/views/notifier/friend_notification.text.erb +++ /dev/null @@ -1,7 +0,0 @@ -<%= t '.had_added_you', :user => @friend.befriender.display_name %> - -<%= t '.see_their_profile', :userurl => @viewurl %> - -<% unless @friend.befriendee.is_friends_with?(@friend.befriender) -%> -<%= t '.befriend_them', :befriendurl => @friendurl %> -<% end -%> diff --git a/app/views/notifier/friend_notification.html.erb b/app/views/notifier/friendship_notification.html.erb similarity index 58% rename from app/views/notifier/friend_notification.html.erb rename to app/views/notifier/friendship_notification.html.erb index 083f8d3fc..24587a6e3 100644 --- a/app/views/notifier/friend_notification.html.erb +++ b/app/views/notifier/friendship_notification.html.erb @@ -1,9 +1,9 @@ -

<%= t ".had_added_you", :user => @friend.befriender.display_name %>

+

<%= t ".had_added_you", :user => @friendship.befriender.display_name %>

<%= message_body do %>

<%= raw t ".see_their_profile", :userurl => link_to(@viewurl, @viewurl) %>

- <% unless @friend.befriendee.is_friends_with?(@friend.befriender) -%> + <% unless @friendship.befriendee.is_friends_with?(@friendship.befriender) -%>

<%= raw t ".befriend_them", :befriendurl => link_to(@friendurl, @friendurl) %>

<% end -%> <% end %> diff --git a/app/views/notifier/friendship_notification.text.erb b/app/views/notifier/friendship_notification.text.erb new file mode 100644 index 000000000..da859d31c --- /dev/null +++ b/app/views/notifier/friendship_notification.text.erb @@ -0,0 +1,7 @@ +<%= t '.had_added_you', :user => @friendship.befriender.display_name %> + +<%= t '.see_their_profile', :userurl => @viewurl %> + +<% unless @friendship.befriendee.is_friends_with?(@friendship.befriender) -%> +<%= t '.befriend_them', :befriendurl => @friendurl %> +<% end -%> diff --git a/config/locales/en.yml b/config/locales/en.yml index 042d998b3..4f3358989 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1202,7 +1202,7 @@ en: hi: "Hi %{to_user}," header: "%{from_user} has sent you a message through OpenStreetMap with the subject %{subject}:" footer_html: "You can also read the message at %{readurl} and you can reply at %{replyurl}" - friend_notification: + friendship_notification: hi: "Hi %{to_user}," subject: "[OpenStreetMap] %{user} added you as a friend" had_added_you: "%{user} has added you as a friend on OpenStreetMap."