Fixed the double mail bug
This should fix the double mail bug
This commit is contained in:
@@ -8,7 +8,7 @@ require "open-uri"
|
|||||||
user = User.find_by_ign(w[1..-1])
|
user = User.find_by_ign(w[1..-1])
|
||||||
users << user if user && user.normal? && user.confirmed? && user.mail_mention?
|
users << user if user && user.normal? && user.confirmed? && user.mail_mention?
|
||||||
end
|
end
|
||||||
users
|
users.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_youtube(yt_name)
|
def get_youtube(yt_name)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class Threadreply < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def send_new_reply_mail(old_content = "")
|
def send_new_reply_mail(old_content = "")
|
||||||
userids = new_mentions = mentions(content) - mentions(old_content)
|
users = mentions(content) - mentions(old_content)
|
||||||
|
|
||||||
# thread + replies
|
# thread + replies
|
||||||
posts = thread.replies.to_a
|
posts = thread.replies.to_a
|
||||||
@@ -44,17 +44,17 @@ class Threadreply < ActiveRecord::Base
|
|||||||
posts.each do |post|
|
posts.each do |post|
|
||||||
# don't send mail to the author of this reply, don't send to banned/disabled users
|
# don't send mail to the author of this reply, don't send to banned/disabled users
|
||||||
if post.author != author && post.author.normal? && post.author.confirmed? # &&
|
if post.author != author && post.author.normal? && post.author.confirmed? # &&
|
||||||
userids << post.author.id if post.author.mail_other_thread_reply?
|
users << post.author if post.author.mail_other_thread_reply?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# making sure we don't send multiple mails to the same user
|
# making sure we don't send multiple mails to the same user
|
||||||
userids.uniq!
|
users.uniq!
|
||||||
|
|
||||||
mails = []
|
mails = []
|
||||||
userids.each do |uid|
|
users.each do |usr|
|
||||||
begin
|
begin
|
||||||
mails << RedstonerMailer.new_thread_reply_mail(User.find(uid), self)
|
mails << RedstonerMailer.new_thread_reply_mail(usr, self)
|
||||||
rescue => e
|
rescue => e
|
||||||
Rails.logger.error "---"
|
Rails.logger.error "---"
|
||||||
Rails.logger.error "WARNING: Failed to create new_thread_reply_mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}"
|
Rails.logger.error "WARNING: Failed to create new_thread_reply_mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}"
|
||||||
|
|||||||
Reference in New Issue
Block a user