Send e-Mail to all commenters if thank you note is given
This commit is contained in:
@@ -37,6 +37,13 @@ class RequestForCommentsController < ApplicationController
|
||||
def set_thank_you_note
|
||||
authorize!
|
||||
@request_for_comment.thank_you_note = params[:note]
|
||||
commenters = []
|
||||
@request_for_comment.comments.distinct.to_a.each {|comment|
|
||||
commenters.append comment.user
|
||||
}
|
||||
commenters = commenters.uniq {|user| user.id}
|
||||
commenters.each {|commenter| UserMailer.send_thank_you_note(@request_for_comment, commenter).deliver_now}
|
||||
|
||||
respond_to do |format|
|
||||
if @request_for_comment.save
|
||||
format.json { render :show, status: :ok, location: @request_for_comment }
|
||||
|
@@ -20,4 +20,12 @@ class UserMailer < ActionMailer::Base
|
||||
@rfc_link = request_for_comment_url(request_for_comment)
|
||||
mail(subject: t('mailers.user_mailer.got_new_comment.subject', commenting_user_displayname: @commenting_user_displayname), to: request_for_comment.user.email)
|
||||
end
|
||||
|
||||
def send_thank_you_note(request_for_comments, receiver)
|
||||
@receiver_displayname = receiver.displayname
|
||||
@author = request_for_comments.user.displayname
|
||||
@thank_you_note = request_for_comments.thank_you_note
|
||||
@rfc_link = request_for_comment_url(request_for_comments)
|
||||
mail(subject: t('mailers.user_mailer.send_thank_you_note.subject', author: @author), to: receiver.email)
|
||||
end
|
||||
end
|
||||
|
1
app/views/user_mailer/send_thank_you_note.slim
Normal file
1
app/views/user_mailer/send_thank_you_note.slim
Normal file
@@ -0,0 +1 @@
|
||||
== t('mailers.user_mailer.send_thank_you_note.body', receiver_displayname: @receiver_displayname, link_to_comment: link_to(@rfc_link, @rfc_link), author: @author, thank_you_note: @thank_you_note )
|
Reference in New Issue
Block a user