mails are now sent in the background
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
class Threadreply < ActiveRecord::Base
|
||||
|
||||
include MailerHelper
|
||||
|
||||
belongs_to :forumthread
|
||||
belongs_to :user_author, class_name: "User", foreign_key: "user_author_id"
|
||||
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
||||
@@ -34,23 +37,25 @@ class Threadreply < ActiveRecord::Base
|
||||
|
||||
# thread + replies
|
||||
(thread.replies.to_a << thread).each do |post|
|
||||
# don't send mail to the user who wrote this
|
||||
if post.author != author # && user.send_threadreply_mail (TODO)
|
||||
# don't send mail to the user who wrote this, don't send to banned/disabled users
|
||||
if post.author != author && post.author.normal? # && user.send_threadreply_mail (TODO)
|
||||
userids << post.author.id
|
||||
end
|
||||
end
|
||||
# making sure we don't send multiple mails to the same user
|
||||
userids.uniq!
|
||||
|
||||
mails = []
|
||||
userids.each do |uid|
|
||||
begin
|
||||
RedstonerMailer.thread_reply_mail(User.find(uid), self).deliver
|
||||
mails << RedstonerMailer.thread_reply_mail(User.find(uid), self)
|
||||
rescue => e
|
||||
puts "---"
|
||||
puts "WARNING: registration mail failed for user #{@user.name}, #{@user.email}"
|
||||
puts e.message
|
||||
puts "---"
|
||||
Rails.logger.error "---"
|
||||
Rails.logger.error "WARNING: Failed to create thread_reply 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
|
||||
Reference in New Issue
Block a user