diff --git a/app/helpers/notifier_helper.rb b/app/helpers/notifier_helper.rb index 71784a3241180f68e03d5a313a9a765d2df09f8e..25da4eb4cb0f515a04f5765c0ff9eddbc44c77d9 100644 --- a/app/helpers/notifier_helper.rb +++ b/app/helpers/notifier_helper.rb @@ -19,7 +19,7 @@ module NotifierHelper # @return [String] The truncated and formatted comment. def comment_message(comment, opts={}) opts[:length] ||= 600 - text = truncate(@comment.text, :length => opts[:length]) + text = truncate(comment.text, :length => opts[:length]) text = process_newlines(text) if opts[:process_newlines] text end diff --git a/app/mailers/notification_mailers/also_commented.rb b/app/mailers/notification_mailers/also_commented.rb new file mode 100644 index 0000000000000000000000000000000000000000..b5cbff7625399506047a6ae5c107d6bb0aedcdad --- /dev/null +++ b/app/mailers/notification_mailers/also_commented.rb @@ -0,0 +1,21 @@ +module NotificationMailers + class AlsoCommented < NotificationMailers::Base + include ActionView::Helpers::TextHelper + + attr_accessor :comment + + def set_headers(comment_id) + @comment = Comment.find_by_id(comment_id) + + if mail? + @headers[:from] = "[#{@comment.author.name} (Diaspora)] <#{AppConfig[:smtp_sender_address]}>" + @headers[:subject] = truncate(@comment.parent.comment_email_subject, :length => TRUNCATION_LEN) + @headers[:subject] = "Re: #{@headers[:subject]}" + end + end + + def mail? + @recipient && @sender && @comment + end + end +end \ No newline at end of file diff --git a/app/mailers/notification_mailers/base.rb b/app/mailers/notification_mailers/base.rb new file mode 100644 index 0000000000000000000000000000000000000000..134f900766d4760567cd21f9c8a8f64a0c71fd8b --- /dev/null +++ b/app/mailers/notification_mailers/base.rb @@ -0,0 +1,52 @@ +module NotificationMailers + TRUNCATION_LEN = 70 + + class Base + attr_accessor :recipient, :recipient_name, :sender + + def initialize(recipient_id, sender_id=nil, *args) + @headers = {} + @recipient = User.find_by_id(recipient_id) + @recipient_name = @recipient.profile.first_name + @sender = Person.find_by_id(sender_id) if sender_id.present? + + log_mail(recipient_id, sender_id, self.class.to_s.underscore) + + with_locale do + set_headers(*args) + end + end + + def headers + default_headers.merge(@headers) + end + + private + + def default_headers + headers = { + :host => "#{AppConfig[:pod_uri]}", + :to => "\"#{@recipient.name}\" <#{@recipient.email}>" + } + + headers[:from] = "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>" if @sender.present? + + headers + end + + def with_locale(&block) + I18n.with_locale(@recipient.language, &block) + end + + def log_mail(recipient_id, sender_id, type) + log_string = "event=mail mail_type=#{type} recipient_id=#{recipient_id} sender_id=#{sender_id}" + if @recipient && @sender + log_string << "models_found=true sender_handle=#{@sender.diaspora_handle} recipient_handle=#{@recipient.diaspora_handle}" + else + log_string << "models_found=false" + end + + Rails.logger.info(log_string) + end + end +end \ No newline at end of file diff --git a/app/mailers/notification_mailers/comment_on_post.rb b/app/mailers/notification_mailers/comment_on_post.rb new file mode 100644 index 0000000000000000000000000000000000000000..4dcf1bfee923d741003f8308f895abed7a01fb32 --- /dev/null +++ b/app/mailers/notification_mailers/comment_on_post.rb @@ -0,0 +1,15 @@ +module NotificationMailers + class CommentOnPost < NotificationMailers::Base + include ActionView::Helpers::TextHelper + + attr_accessor :comment + + def set_headers(comment_id) + @comment = Comment.find(comment_id) + + @headers[:from] = "[#{@comment.author.name} (Diaspora)] <#{AppConfig[:smtp_sender_address]}>" + @headers[:subject] = truncate(@comment.parent.comment_email_subject, :length => TRUNCATION_LEN) + @headers[:subject] = "Re: #{@headers[:subject]}" + end + end +end \ No newline at end of file diff --git a/app/mailers/notification_mailers/confirm_email.rb b/app/mailers/notification_mailers/confirm_email.rb new file mode 100644 index 0000000000000000000000000000000000000000..e9c1d4c6f7ff0425c60b39f06d79db4d2aabb667 --- /dev/null +++ b/app/mailers/notification_mailers/confirm_email.rb @@ -0,0 +1,8 @@ +module NotificationMailers + class ConfirmEmail < NotificationMailers::Base + def set_headers + @headers[:to] = "\"#{recipient_name}\" <#{@recipient.unconfirmed_email}>" + @headers[:subject] = I18n.t('notifier.confirm_email.subject', :unconfirmed_email => @recipient.unconfirmed_email) + end + end +end \ No newline at end of file diff --git a/app/mailers/notification_mailers/liked.rb b/app/mailers/notification_mailers/liked.rb new file mode 100644 index 0000000000000000000000000000000000000000..243e018e4d3d9cef189f0cba50940bc343469fd9 --- /dev/null +++ b/app/mailers/notification_mailers/liked.rb @@ -0,0 +1,11 @@ +module NotificationMailers + class Liked < NotificationMailers::Base + attr_accessor :like + + def set_headers(like_id) + @like = Like.find(like_id) + + @headers[:subject] = I18n.t('notifier.liked.liked', :name => @sender.name) + end + end +end \ No newline at end of file diff --git a/app/mailers/notification_mailers/mentioned.rb b/app/mailers/notification_mailers/mentioned.rb new file mode 100644 index 0000000000000000000000000000000000000000..2d0b5cd60ccbbf0392e9648335bacf677a1e06a2 --- /dev/null +++ b/app/mailers/notification_mailers/mentioned.rb @@ -0,0 +1,11 @@ +module NotificationMailers + class Mentioned < NotificationMailers::Base + attr_accessor :post + + def set_headers(target_id) + @post = Mention.find_by_id(target_id).post + + @headers[:subject] = I18n.t('notifier.mentioned.subject', :name => @sender.name) + end + end +end \ No newline at end of file diff --git a/app/mailers/notification_mailers/private_message.rb b/app/mailers/notification_mailers/private_message.rb new file mode 100644 index 0000000000000000000000000000000000000000..69823f4f32aa3a160ba0a36b7a3a90030bdeb241 --- /dev/null +++ b/app/mailers/notification_mailers/private_message.rb @@ -0,0 +1,15 @@ +module NotificationMailers + class PrivateMessage < NotificationMailers::Base + attr_accessor :message, :conversation, :participants + + def set_headers(message_id) + @message = Message.find_by_id(message_id) + @conversation = @message.conversation + @participants = @conversation.participants + + @headers[:from] = "[#{@message.author.name} (Diaspora)] <#{AppConfig[:smtp_sender_address]}>" + @headers[:subject] = @conversation.subject.strip + @headers[:subject] = "Re: #{@headers[:subject]}" if @conversation.messages.size > 1 + end + end +end \ No newline at end of file diff --git a/app/mailers/notification_mailers/reshared.rb b/app/mailers/notification_mailers/reshared.rb new file mode 100644 index 0000000000000000000000000000000000000000..c8287dd27a859a8639b17f6ae28bfeb8e5957b8f --- /dev/null +++ b/app/mailers/notification_mailers/reshared.rb @@ -0,0 +1,11 @@ +module NotificationMailers + class Reshared < NotificationMailers::Base + attr_accessor :reshare + + def set_headers(reshare_id) + @reshare = Reshare.find(reshare_id) + + @headers[:subject] = I18n.t('notifier.reshared.reshared', :name => @sender.name) + end + end +end \ No newline at end of file diff --git a/app/mailers/notification_mailers/started_sharing.rb b/app/mailers/notification_mailers/started_sharing.rb new file mode 100644 index 0000000000000000000000000000000000000000..b5922cfffc596be66a2b6ea0b5167d5183c79b57 --- /dev/null +++ b/app/mailers/notification_mailers/started_sharing.rb @@ -0,0 +1,7 @@ +module NotificationMailers + class StartedSharing < NotificationMailers::Base + def set_headers + @headers[:subject] = I18n.t('notifier.started_sharing.subject', :name => @sender.name) + end + end +end \ No newline at end of file diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index 3f6199a8c41359bebd8e668660fe127c27ae43c1..19f718f11c54e050ec1130a8f64f8f850cd6a069 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -5,11 +5,8 @@ class Notifier < ActionMailer::Base default :from => AppConfig[:smtp_sender_address] - include ActionView::Helpers::TextHelper include NotifierHelper - TRUNCATION_LEN = 70 - def self.admin(string, recipients, opts = {}) mails = [] recipients.each do |rec| @@ -27,133 +24,71 @@ class Notifier < ActionMailer::Base end def started_sharing(recipient_id, sender_id) - @receiver = User.find_by_id(recipient_id) - @sender = Person.find_by_id(sender_id) - - log_mail(recipient_id, sender_id, 'started_sharing') + @notification = NotificationMailers::StartedSharing.new(recipient_id, sender_id) - I18n.with_locale(@receiver.language) do - mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>", - :subject => I18n.t('notifier.started_sharing.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host) + with_recipient_locale do + mail(@notification.headers) end end def liked(recipient_id, sender_id, like_id) - @receiver = User.find_by_id(recipient_id) - @sender = Person.find_by_id(sender_id) - @like = Like.find(like_id) - - log_mail(recipient_id, sender_id, 'liked') + @notification = NotificationMailers::Liked.new(recipient_id, sender_id, like_id) - I18n.with_locale(@receiver.language) do - mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>", - :subject => I18n.t('notifier.liked.liked', :name => @sender.name), :host => AppConfig[:pod_uri].host) + with_recipient_locale do + mail(@notification.headers) end end def reshared(recipient_id, sender_id, reshare_id) - @receiver = User.find_by_id(recipient_id) - @sender = Person.find_by_id(sender_id) - @reshare = Reshare.find(reshare_id) + @notification = NotificationMailers::Reshared.new(recipient_id, sender_id, reshare_id) - log_mail(recipient_id, sender_id, 'reshared') - - I18n.with_locale(@receiver.language) do - mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>", - :subject => I18n.t('notifier.reshared.reshared', :name => @sender.name), :host => AppConfig[:pod_uri].host) + with_recipient_locale do + mail(@notification.headers) end end def mentioned(recipient_id, sender_id, target_id) - @receiver = User.find_by_id(recipient_id) - @sender = Person.find_by_id(sender_id) - @post = Mention.find_by_id(target_id).post - - log_mail(recipient_id, sender_id, 'mentioned') + @notification = NotificationMailers::Mentioned.new(recipient_id, sender_id, target_id) - I18n.with_locale(@receiver.language) do - mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>", - :subject => I18n.t('notifier.mentioned.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host) + with_recipient_locale do + mail(@notification.headers) end end def comment_on_post(recipient_id, sender_id, comment_id) - @receiver = User.find_by_id(recipient_id) - @sender = Person.find_by_id(sender_id) - @comment = Comment.find_by_id(comment_id) + @notification = NotificationMailers::CommentOnPost.new(recipient_id, sender_id, comment_id) - log_mail(recipient_id, sender_id, 'comment_on_post') - - I18n.with_locale(@receiver.language) do - mail(:from => "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>", - :to => "\"#{@receiver.name}\" <#{@receiver.email}>", - :subject => "Re: #{comment_email_subject}") + with_recipient_locale do + mail(@notification.headers) end end def also_commented(recipient_id, sender_id, comment_id) - @receiver = User.find_by_id(recipient_id) - @sender = Person.find_by_id(sender_id) - @comment = Comment.find_by_id(comment_id) - - if @receiver && @sender && @comment - @post_author_name = @comment.post.author.name - - - log_mail(recipient_id, sender_id, 'comment_on_post') + @notification = NotificationMailers::AlsoCommented.new(recipient_id, sender_id, comment_id) - I18n.with_locale(@receiver.language) do - mail(:from => "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>", - :to => "\"#{@receiver.name}\" <#{@receiver.email}>", - :subject => "Re: #{comment_email_subject}") - end + with_recipient_locale do + mail(@notification.headers) if @notification.mail? end end - def comment_email_subject - truncate(@comment.parent.comment_email_subject, :length => TRUNCATION_LEN) - end - def private_message(recipient_id, sender_id, message_id) - @receiver = User.find_by_id(recipient_id) - @sender = Person.find_by_id(sender_id) - @message = Message.find_by_id(message_id) - @conversation = @message.conversation - @participants = @conversation.participants - - - log_mail(recipient_id, sender_id, 'private_message') + @notification = NotificationMailers::PrivateMessage.new(recipient_id, sender_id, message_id) - subject = @conversation.subject.strip - subject = "Re: #{subject}" if @conversation.messages.size > 1 - - - I18n.with_locale(@receiver.language) do - mail(:from => "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>", - :to => "\"#{@receiver.name}\" <#{@receiver.email}>", - :subject => subject) + with_recipient_locale do + mail(@notification.headers) end end - def confirm_email(receiver_id) - @receiver = User.find_by_id(receiver_id) + def confirm_email(recipient_id) + @notification = NotificationMailers::ConfirmEmail.new(recipient_id) - I18n.with_locale(@receiver.language) do - mail(:to => "\"#{@receiver.name}\" <#{@receiver.unconfirmed_email}>", - :subject => I18n.t('notifier.confirm_email.subject', :unconfirmed_email => @receiver.unconfirmed_email), - :host => AppConfig[:pod_uri].host) + with_recipient_locale do + mail(@notification.headers) end end - private - def log_mail recipient_id, sender_id, type - log_string = "event=mail mail_type=#{type} recipient_id=#{recipient_id} sender_id=#{sender_id}" - if @receiver && @sender - log_string << "models_found=true sender_handle=#{@sender.diaspora_handle} recipient_handle=#{@receiver.diaspora_handle}" - else - log_string << "models_found=false" - end - Rails.logger.info log_string + def with_recipient_locale(&block) + I18n.with_locale(@notification.recipient.language, &block) end end diff --git a/app/views/notifier/also_commented.html.haml b/app/views/notifier/also_commented.html.haml index 9b37b4d73af8820b34048a085680d130a0d30536..1515779cc80a9f5c68c145411136cf6efa8f72e3 100644 --- a/app/views/notifier/also_commented.html.haml +++ b/app/views/notifier/also_commented.html.haml @@ -1,4 +1,4 @@ %p - = comment_message(@comment.text, :process_newlines => true) + = comment_message(@notification.comment, :process_newlines => true) %p - = link_to t('notifier.comment_on_post.reply', :name => @comment.post.author.first_name), post_url(@comment.post) + = link_to t('notifier.comment_on_post.reply', :name => @notification.comment.post.author.first_name), post_url(@notification.comment.post) diff --git a/app/views/notifier/also_commented.text.haml b/app/views/notifier/also_commented.text.haml index 7bc518d954fe70a438af4c8776ab66d2e029d2e5..2c78dcd512e4e631e525cc669bf862a5ba8b5b7a 100644 --- a/app/views/notifier/also_commented.text.haml +++ b/app/views/notifier/also_commented.text.haml @@ -1 +1 @@ -!= comment_message(@comment.text) +!= comment_message(@notification.comment) diff --git a/app/views/notifier/comment_on_post.html.haml b/app/views/notifier/comment_on_post.html.haml index 407aea0326d21d912692cc4f107ac96883ae1e2b..1ca9eee49cf2e2f240b9ebf11230bd63f852d2a8 100644 --- a/app/views/notifier/comment_on_post.html.haml +++ b/app/views/notifier/comment_on_post.html.haml @@ -1,4 +1,4 @@ %p - = comment_message(@comment.text, :process_newlines => true) + = comment_message(@notification.comment, :process_newlines => true) %p - = link_to t('notifier.comment_on_post.reply', :name => @comment.post.author.name), post_url(@comment.post) + = link_to t('notifier.comment_on_post.reply', :name => @notification.comment.post.author.name), post_url(@notification.comment.post) diff --git a/app/views/notifier/comment_on_post.text.haml b/app/views/notifier/comment_on_post.text.haml index 7bc518d954fe70a438af4c8776ab66d2e029d2e5..2c78dcd512e4e631e525cc669bf862a5ba8b5b7a 100644 --- a/app/views/notifier/comment_on_post.text.haml +++ b/app/views/notifier/comment_on_post.text.haml @@ -1 +1 @@ -!= comment_message(@comment.text) +!= comment_message(@notification.comment) diff --git a/app/views/notifier/confirm_email.html.haml b/app/views/notifier/confirm_email.html.haml index eb4f905e2a6077de687476b0fbe189e34deb0258..e4a78f32119a50b82834a5905382bf9d62ef8527 100644 --- a/app/views/notifier/confirm_email.html.haml +++ b/app/views/notifier/confirm_email.html.haml @@ -1,6 +1,7 @@ %p - = t('notifier.hello', :name => @receiver.profile.first_name) + = t('notifier.hello', :name => @notification.recipient_name) %p - != t('notifier.confirm_email.click_link', :unconfirmed_email => @receiver.unconfirmed_email) + != t('notifier.confirm_email.click_link', :unconfirmed_email => @notification.recipient.unconfirmed_email) %br - = link_to confirm_email_url(:token => @receiver.confirm_email_token), confirm_email_url(:token => @receiver.confirm_email_token) + = link_to confirm_email_url(:token => @notification.recipient.confirm_email_token), + confirm_email_url(:token => @notification.recipient.confirm_email_token) diff --git a/app/views/notifier/confirm_email.text.haml b/app/views/notifier/confirm_email.text.haml index 8ea9b8fef2d2dc03da454420c6fed73d9b056f85..3da0a897580fe77f77225d4bf6c6ca3c55324dc5 100644 --- a/app/views/notifier/confirm_email.text.haml +++ b/app/views/notifier/confirm_email.text.haml @@ -1,4 +1,4 @@ -!= t('notifier.hello', :name => @receiver.profile.first_name) +!= t('notifier.hello', :name => @notification.recipient_name) -!= t('notifier.confirm_email.click_link', :unconfirmed_email => @receiver.unconfirmed_email) -!= confirm_email_url(:token => @receiver.confirm_email_token) +!= t('notifier.confirm_email.click_link', :unconfirmed_email => @notification.recipient.unconfirmed_email) +!= confirm_email_url(:token => @notification.recipient.confirm_email_token) diff --git a/app/views/notifier/liked.html.haml b/app/views/notifier/liked.html.haml index 608412db10f227eee606db349b5e218a54d1ee1a..9e010a59be1f167302f6d25fc61708850799b4cb 100644 --- a/app/views/notifier/liked.html.haml +++ b/app/views/notifier/liked.html.haml @@ -1,8 +1,8 @@ %p - = "#{t('.liked', :name => "#{@sender.name}")}:" + = "#{t('.liked', :name => "#{@notification.sender.name}")}:" %p{:style => "font-style:italic;color:#666"} - = post_message(@like.target, :process_newlines => true) + = post_message(@notification.like.target, :process_newlines => true) %p - = link_to t('.view_post'), post_url(@like.target) + = link_to t('.view_post'), post_url(@notification.like.target) diff --git a/app/views/notifier/liked.text.haml b/app/views/notifier/liked.text.haml index 861305e6eaa700b768e6c09ac0922b9a0a63496e..f115e82164b604c508ed080f6aa059676dd8c784 100644 --- a/app/views/notifier/liked.text.haml +++ b/app/views/notifier/liked.text.haml @@ -1,3 +1,3 @@ -!= "#{t('notifier.liked.liked', :name => "#{@sender.name}")}:" -!=post_message(@like.target) +!= "#{t('notifier.liked.liked', :name => "#{@notification.sender.name}")}:" +!=post_message(@notification.like.target) diff --git a/app/views/notifier/mentioned.html.haml b/app/views/notifier/mentioned.html.haml index 81c3aedf2513aa83c052510c0893ffec3945bcb3..9107eb5de0b88aaefeba92a4eca64c458859e05f 100644 --- a/app/views/notifier/mentioned.html.haml +++ b/app/views/notifier/mentioned.html.haml @@ -1,4 +1,4 @@ %p - = post_message(@post, :process_newlines => true, :length => 600) + = post_message(@notification.post, :process_newlines => true, :length => 600) %p - = link_to t('notifier.comment_on_post.reply', :name => @post.author.name), post_url(@post) + = link_to t('notifier.comment_on_post.reply', :name => @notification.post.author.name), post_url(@notification.post) diff --git a/app/views/notifier/mentioned.text.haml b/app/views/notifier/mentioned.text.haml index 7b95ef0b363c60508152771e6dcdb9ec3d424747..e628b7f472e0bf77c06da45fcac9a6d621bc35bf 100644 --- a/app/views/notifier/mentioned.text.haml +++ b/app/views/notifier/mentioned.text.haml @@ -1 +1 @@ -!= post_message(@post, :process_newlines => true, :length => 600) +!= post_message(@notification.post, :process_newlines => true, :length => 600) diff --git a/app/views/notifier/private_message.html.haml b/app/views/notifier/private_message.html.haml index 6683576eea8b5a6bccba2e1a566e5de516d12fc0..86b1342141f394b6f8da61c42c1676306483d1a6 100644 --- a/app/views/notifier/private_message.html.haml +++ b/app/views/notifier/private_message.html.haml @@ -1,4 +1,4 @@ %p - = post_message(@message, :process_newlines => true, :length => 2000) + = post_message(@notification.message, :process_newlines => true, :length => 2000) %p - = link_to t('.reply_to_or_view'), conversations_url(:conversation_id => @conversation) + = link_to t('.reply_to_or_view'), conversations_url(:conversation_id => @notification.conversation) diff --git a/app/views/notifier/private_message.text.haml b/app/views/notifier/private_message.text.haml index 98bb94557a272db021086ce52561df1abf5567ce..8cd710e2b2027725bf690a0b5d015080b95804ad 100644 --- a/app/views/notifier/private_message.text.haml +++ b/app/views/notifier/private_message.text.haml @@ -1 +1 @@ -!= @message.text +!= @notification.message.text diff --git a/app/views/notifier/reshared.html.haml b/app/views/notifier/reshared.html.haml index 98985bd45e4fb932ee7d2098cfc7b07d73b82f3e..49c49f66d19af076ee93cf59a3f7c8b6e7ff9a01 100644 --- a/app/views/notifier/reshared.html.haml +++ b/app/views/notifier/reshared.html.haml @@ -1,8 +1,8 @@ %p - = "#{t('.reshared', :name => "#{@sender.name}")}:" + = "#{t('.reshared', :name => "#{@notification.sender.name}")}:" %p{:style => "font-style:italic;color:#666"} - = post_message(@reshare.root, :process_newlines => true) + = post_message(@notification.reshare.root, :process_newlines => true) %p - = link_to t('.view_post'), post_url(@reshare) + = link_to t('.view_post'), post_url(@notification.reshare) diff --git a/app/views/notifier/reshared.text.haml b/app/views/notifier/reshared.text.haml index ab9a73f7ddace044150f45481a11a3bf9234c33d..8b7e29e4ac1a56ce8ea208084c4097bd1f96ddff 100644 --- a/app/views/notifier/reshared.text.haml +++ b/app/views/notifier/reshared.text.haml @@ -1,3 +1,3 @@ -!= "#{t('notifier.reshared.reshared', :name => "#{@sender.name}")}:" -!=post_message(@reshare.root) +!= "#{t('notifier.reshared.reshared', :name => "#{@notification.sender.name}")}:" +!=post_message(@notification.reshare.root) diff --git a/app/views/notifier/started_sharing.html.haml b/app/views/notifier/started_sharing.html.haml index d57693356e8bb9f3935ea1d52b1d37c79006fd48..fc46992ee01e458364303f6b6f6abab5e0a617bc 100644 --- a/app/views/notifier/started_sharing.html.haml +++ b/app/views/notifier/started_sharing.html.haml @@ -1,5 +1,5 @@ %p - = @sender.name + = @notification.sender.name = t('.sharing') %p - = link_to t('.view_profile', :name => @sender.first_name), person_url(@sender) + = link_to t('.view_profile', :name => @notification.sender.first_name), person_url(@notification.sender) diff --git a/app/views/notifier/started_sharing.text.haml b/app/views/notifier/started_sharing.text.haml index b188dfebe267f5bf3382cf186b6a269c972781cb..97f1692d6530a27935a46770603512459289582c 100644 --- a/app/views/notifier/started_sharing.text.haml +++ b/app/views/notifier/started_sharing.text.haml @@ -1,4 +1,4 @@ -!= "#{@sender.name}" +!= "#{@notification.sender.name}" != t('notifier.started_sharing.sharing') -!= t('.view_profile', :name => @sender.first_name) -!= person_url(@sender) +!= t('.view_profile', :name => @notification.sender.first_name) +!= person_url(@notification.sender) diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index a4eb08d110abe805e976ac07110735f6ffbb32ac..5af7b65d18baaff7a0dd46210f743b491a38d980 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -172,8 +172,7 @@ describe Notifier do end it "FROM: contains the sender's name" do - pending - @mail.from.should == "\"#{person.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>" + @mail.from.should == "[#{@cnv.author.name} (Diaspora)] <#{AppConfig[:smtp_sender_address]}>" end it 'SUBJECT: has a snippet of the post contents' do @@ -208,8 +207,7 @@ describe Notifier do end it "FROM: contains the sender's name" do - pending - comment_mail.from.should == "\"#{person.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>" + comment_mail.from.should == "[#{eve.name} (Diaspora)] <#{AppConfig[:smtp_sender_address]}>" end it 'SUBJECT: has a snippet of the post contents' do @@ -243,15 +241,14 @@ describe Notifier do end describe ".also_commented" do - let(:comment_mail) {Notifier.also_commented(bob.id, person.id, comment.id)} + let(:comment_mail) { Notifier.also_commented(bob.id, person.id, comment.id) } it 'TO: goes to the right person' do comment_mail.to.should == [bob.email] end it 'FROM: has the name of person commenting as the sender' do - pending - comment_mail.from.should == "\"#{person.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>" + comment_mail.from.should == "[#{eve.name} (Diaspora)] <#{AppConfig[:smtp_sender_address]}>" end it 'SUBJECT: has a snippet of the post contents' do