Add unsubscribe link to emails and cleanup user mailer

This commit is contained in:
Maximilian Grundke
2017-09-13 14:37:10 +02:00
parent b1f790dcde
commit 85928361cb
5 changed files with 21 additions and 18 deletions

View File

@@ -126,7 +126,7 @@ class CommentsController < ApplicationController
:user_id => commenter.id, :user_type => commenter.class.name)
subscriptions.each do |subscription|
if (subscription.subscription_type == 'author' and current_user == request_for_comment.user) or subscription.subscription_type == 'all'
UserMailer.got_new_comment_for_subscription(comment, request_for_comment, request_for_comment.user, current_user).deliver_now
UserMailer.got_new_comment_for_subscription(comment, subscription, current_user).deliver_now
end
end
end

View File

@@ -21,12 +21,13 @@ class UserMailer < ActionMailer::Base
mail(subject: t('mailers.user_mailer.got_new_comment.subject', commenting_user_displayname: @commenting_user_displayname), to: request_for_comment.user.email)
end
def got_new_comment_for_subscription(comment, request_for_comment, from_user, to_user)
@receiver_displayname = to_user.displayname
def got_new_comment_for_subscription(comment, subscription, from_user)
@receiver_displayname = subscription.user.displayname
@author_displayname = from_user.displayname
@comment_text = comment.text
@rfc_link = request_for_comment_url(request_for_comment)
mail(subject: t('mailers.user_mailer.got_new_comment_for_subscription.subject', author_displayname: @author_displayname), to: to_user.email)
@rfc_link = request_for_comment_url(subscription.request_for_comment)
@unsubscribe_link = unsubscribe_subscription_url(subscription)
mail(subject: t('mailers.user_mailer.got_new_comment_for_subscription.subject', author_displayname: @author_displayname), to: subscription.user.email)
end
def send_thank_you_note(request_for_comments, receiver)

View File

@@ -1 +1,7 @@
== t('mailers.user_mailer.got_new_comment_for_subscription.body', receiver_displayname: @receiver_displayname, link_to_comment: link_to(@rfc_link, @rfc_link), author_displayname: @author_displayname, comment_text: @comment_text, link_my_comments: link_to(t('request_for_comments.index.get_my_comment_requests'), my_request_for_comments_url), link_all_comments: link_to(t('request_for_comments.index.all'), request_for_comments_url) )
== t('mailers.user_mailer.got_new_comment_for_subscription.body',
receiver_displayname: @receiver_displayname, link_to_comment: link_to(@rfc_link, @rfc_link),
unsubscribe_link: link_to(@unsubscribe_link, @unsubscribe_link),
author_displayname: @author_displayname,
comment_text: @comment_text,
link_my_comments: link_to(t('request_for_comments.index.get_my_comment_requests'), my_request_for_comments_url),
link_all_comments: link_to(t('request_for_comments.index.all'), request_for_comments_url) )