mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Use ActiveJob to send comment mails
This commit is contained in:
parent
8392fca0dc
commit
3391d09549
4 changed files with 20 additions and 12 deletions
11
app/jobs/event_comment_mail_job.rb
Normal file
11
app/jobs/event_comment_mail_job.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
class EventCommentMailJob < ActiveJob::Base
|
||||
queue_as :default
|
||||
|
||||
def perform(comment)
|
||||
conference = comment.commentable.program.conference
|
||||
|
||||
User.comment_notifiable(conference).each do |user|
|
||||
Mailbot.event_comment_mail(comment, user).deliver_now
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
class Mailbot < ActionMailer::Base
|
||||
|
||||
def registration_mail(conference, user)
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
|
|
@ -81,19 +82,15 @@ class Mailbot < ActionMailer::Base
|
|||
conference.email_settings.cfp_dates_updated_body))
|
||||
end
|
||||
|
||||
def send_notification_email_for_comment(comment)
|
||||
def event_comment_mail(comment, user)
|
||||
@comment = comment
|
||||
@event = @comment.commentable
|
||||
@conference = @event.program.conference
|
||||
recipients = User.comment_notifiable(@conference) # with scope
|
||||
recipients.each do |user|
|
||||
@user = user
|
||||
mail(to: @user.email,
|
||||
from: @conference.contact.email,
|
||||
reply_to: @conference.contact.email,
|
||||
template_path: 'admin/emails',
|
||||
template_name: 'comment_template',
|
||||
subject: "New comment has been posted for #{@event.title}")
|
||||
end
|
||||
@user = user
|
||||
|
||||
mail(to: @user.email,
|
||||
from: @conference.contact.email,
|
||||
template_name: 'comment_template',
|
||||
subject: "New comment has been posted for #{@event.title}")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -56,6 +56,6 @@ class Comment < ActiveRecord::Base
|
|||
private
|
||||
|
||||
def send_notification
|
||||
Mailbot.send_notification_email_for_comment(self).deliver_later
|
||||
EventCommentMailJob.perform_later(self)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue