remove comment mention mail, use reply mail instead

This commit is contained in:
jomo
2015-02-08 01:18:09 +01:00
parent f82af96759
commit 05760b845c
6 changed files with 18 additions and 73 deletions

View File

@@ -29,16 +29,21 @@ class Comment < ActiveRecord::Base
!!user_editor_id
end
def send_new_comment_mail
userids = []
def send_new_comment_mail(old_content = "")
userids = mentions(content) - mentions(old_content)
puts "userids: #{userids}"
# post + comments
comments = blogpost.comments.to_a
comments << blogpost if blogpost.author.mail_own_blogpost_comment?
comments.each do |comment|
# don't send mail to the author of this comment, don't send to banned/disabled users
if comment.author != author && comment.author.normal? && comment.author.confirmed? # &&
userids << comment.author.id if comment.author.mail_other_blogpost_comment?
# only send "reply" mails when the comment is new
unless old_content.present?
comments.each do |comment|
# don't send mail to the author of this comment, don't send to banned/disabled users
if comment.author != author && comment.author.normal? && comment.author.confirmed? # &&
userids << comment.author.id if comment.author.mail_other_blogpost_comment?
end
end
end
# making sure we don't send multiple mails to the same user
@@ -58,19 +63,4 @@ class Comment < ActiveRecord::Base
background_mailer(mails)
end
def send_new_mention_mail(old_content = "")
new_mentions = mentions(content) - mentions(old_content)
mails = []
new_mentions.each do |user|
begin
mails << RedstonerMailer.new_post_comment_mention_mail(user, self) if user.normal? && user.confirmed? && user.mail_mention?
rescue => e
Rails.logger.error "---"
Rails.logger.error "WARNING: Failed to create new_post_comment_mention_mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}"
Rails.logger.error e.message
Rails.logger.error "---"
end
end
background_mailer(mails)
end
end