diff --git a/app/controllers/request_for_comments_controller.rb b/app/controllers/request_for_comments_controller.rb index 4f647ea7..eb2305cc 100644 --- a/app/controllers/request_for_comments_controller.rb +++ b/app/controllers/request_for_comments_controller.rb @@ -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 } diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 5b1a04fe..180e9b33 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -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 diff --git a/app/views/user_mailer/send_thank_you_note.slim b/app/views/user_mailer/send_thank_you_note.slim new file mode 100644 index 00000000..fcdcdf8d --- /dev/null +++ b/app/views/user_mailer/send_thank_you_note.slim @@ -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 ) diff --git a/config/locales/de.yml b/config/locales/de.yml index 1546506c..46b52fa5 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -410,6 +410,41 @@ de: reset_password: body: 'Bitte besuchen Sie %{link}, sofern Sie Ihr Passwort zurücksetzen wollen.' subject: Anweisungen zum Zurücksetzen Ihres Passworts + send_thank_you_note: + body: | + English version below
+ _________________________
+
+ Hallo %{receiver_displayname},
+
+ %{author} hat Ihnen für Ihren Kommentar auf CodeOcean gedankt.
+
+ %{author} schreibt: %{thank_you_note}
+
+ Sie finden die Kommentaranfrage hier: %{link_to_comment}
+
+ Falls Sie beim Klick auf diesen Link eine Fehlermeldung erhalten, dass Sie nicht berechtigt wären diese Aktion auszuführen, öffnen Sie bitte eine beliebige Programmieraufgabe aus einem Kurs heraus und klicken den Link danach noch einmal.
+
+ Danke, dass Sie anderen Nutzern von CodeOcean helfen! +
+ Diese Mail wurde automatisch von CodeOcean verschickt.
+
+ _________________________
+
+ Dear %{receiver_displayname},
+
+ %{author} thanks you for your comment.
+
+ %{author} wrote: %{thank_you_note}
+
+ You can find the request for comments here: %{link_to_comment}
+
+ If you receive an error that you are not authorized to perform this action when clicking the link, please log-in through any course exercise beforehand and click the link again.
+
+ Thank you for helping other users on CodeOcean! +
+ This mail was automatically sent by CodeOcean.
+ subject: "%{author} sagt danke!" request_for_comments: click_here: Zum Kommentieren auf die Seitenleiste klicken! comments: Kommentare diff --git a/config/locales/en.yml b/config/locales/en.yml index 1e6c9684..8d5c7538 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -431,6 +431,41 @@ en: reset_password: body: 'Please visit %{link} if you want to reset your password.' subject: Password reset instructions + send_thank_you_note: + body: | + English version below
+ _________________________
+
+ Hallo %{receiver_displayname},
+
+ %{author} hat Ihnen für Ihren Kommentar auf CodeOcean gedankt.
+
+ %{author} schreibt: %{thank_you_note}
+
+ Sie finden die Kommentaranfrage hier: %{link_to_comment}
+
+ Falls Sie beim Klick auf diesen Link eine Fehlermeldung erhalten, dass Sie nicht berechtigt wären diese Aktion auszuführen, öffnen Sie bitte eine beliebige Programmieraufgabe aus einem Kurs heraus und klicken den Link danach noch einmal.
+
+ Danke, dass Sie anderen Nutzern von CodeOcean helfen! +
+ Diese Mail wurde automatisch von CodeOcean verschickt.
+
+ _________________________
+
+ Dear %{receiver_displayname},
+
+ %{author} thanks you for your comment.
+
+ %{author} wrote: %{thank_you_note}
+
+ You can find the request for comments here: %{link_to_comment}
+
+ If you receive an error that you are not authorized to perform this action when clicking the link, please log-in through any course exercise beforehand and click the link again.
+
+ Thank you for helping other users on CodeOcean! +
+ This mail was automatically sent by CodeOcean.
+ subject: "%{author} says thank you!" request_for_comments: click_here: Click on this sidebar to comment! comments: Comments