From 0780491d4fded19fb62ff728ac0fb6121f14ad98 Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Sat, 3 Sep 2011 16:06:30 -0700 Subject: [PATCH] fix for 'undefined method 'post' for nil:NilClass' in Mail::AlsoCommented --- app/mailers/notifier.rb | 14 ++++++++------ app/models/job/mail/also_commented.rb | 4 +++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index eb51fd1d8..3f6199a8c 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -96,15 +96,17 @@ class Notifier < ActionMailer::Base @sender = Person.find_by_id(sender_id) @comment = Comment.find_by_id(comment_id) - @post_author_name = @comment.post.author.name + if @receiver && @sender && @comment + @post_author_name = @comment.post.author.name - log_mail(recipient_id, sender_id, 'comment_on_post') + 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}") + 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 end end diff --git a/app/models/job/mail/also_commented.rb b/app/models/job/mail/also_commented.rb index 58c1fea76..f7420eaca 100644 --- a/app/models/job/mail/also_commented.rb +++ b/app/models/job/mail/also_commented.rb @@ -3,7 +3,9 @@ module Job class AlsoCommented < Base @queue = :mail def self.perform(recipient_id, sender_id, comment_id) - Notifier.also_commented(recipient_id, sender_id, comment_id).deliver + if email = Notifier.also_commented(recipient_id, sender_id, comment_id) + email.deliver + end end end end