mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 03:37:56 +01:00
Improve emails (#305)
This commit is contained in:
committed by
GitHub
parent
5ad01b0138
commit
98daafc244
@@ -89,7 +89,9 @@ class PostsController < ApplicationController
|
||||
post_status_id: @post.post_status_id
|
||||
)
|
||||
|
||||
UserMailer.notify_followers_of_post_status_change(post: @post).deliver_later
|
||||
@post.followers.each do |follower|
|
||||
UserMailer.notify_follower_of_post_status_change(post: @post, follower: follower).deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
render json: @post
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
class UserMailer < ApplicationMailer
|
||||
layout 'user_mailer'
|
||||
|
||||
def notify_post_owner(comment:)
|
||||
@tenant = comment.tenant
|
||||
Current.tenant = @tenant
|
||||
Current.tenant = comment.tenant
|
||||
@comment = comment
|
||||
@user = comment.post.user
|
||||
|
||||
@@ -14,8 +11,7 @@ class UserMailer < ApplicationMailer
|
||||
end
|
||||
|
||||
def notify_comment_owner(comment:)
|
||||
@tenant = comment.tenant
|
||||
Current.tenant = @tenant
|
||||
Current.tenant = comment.tenant
|
||||
@comment = comment
|
||||
@user = comment.parent.user
|
||||
|
||||
@@ -25,25 +21,25 @@ class UserMailer < ApplicationMailer
|
||||
)
|
||||
end
|
||||
|
||||
def notify_followers_of_post_update(comment:)
|
||||
@tenant = comment.tenant
|
||||
Current.tenant = @tenant
|
||||
def notify_follower_of_post_update(comment:, follower:)
|
||||
Current.tenant = comment.tenant
|
||||
@comment = comment
|
||||
@user = follower
|
||||
|
||||
mail(
|
||||
to: comment.post.followers.pluck(:email),
|
||||
subject: t('mailers.user.notify_followers_of_post_update.subject', site_name: site_name, post: comment.post.title)
|
||||
to: follower.email,
|
||||
subject: t('mailers.user.notify_follower_of_post_update.subject', site_name: site_name, post: comment.post.title)
|
||||
)
|
||||
end
|
||||
|
||||
def notify_followers_of_post_status_change(post:)
|
||||
@tenant = post.tenant
|
||||
Current.tenant = @tenant
|
||||
def notify_follower_of_post_status_change(post:, follower:)
|
||||
Current.tenant = post.tenant
|
||||
@post = post
|
||||
@user = follower
|
||||
|
||||
mail(
|
||||
to: post.followers.pluck(:email),
|
||||
subject: t('mailers.user.notify_followers_of_post_status_change.subject', site_name: site_name, post: post.title)
|
||||
to: follower.email,
|
||||
subject: t('mailers.user.notify_follower_of_post_status_change.subject', site_name: site_name, post: post.title)
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<div><%= yield %></div>
|
||||
<div style="margin: 16px auto; text-align: center;">
|
||||
<a href="<%= add_subdomain_to(method(:root_url)) %>">
|
||||
<%= image_tag('logo.png', alt: 'Astuto Logo', size: 64) %>
|
||||
</a>
|
||||
</div>
|
||||
<div style="max-width: 580px; margin: 0 auto; border: 1px solid rgba(0, 0, 0, 0.125); border-radius: 0.25rem; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.04),0 2px 4px -1px rgba(0, 0, 0, 0.03); padding: 24px; font-family: system-ui, sans-serif; font-size: 18px;">
|
||||
<%= yield %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<p><%= t('mailers.user.opening_greeting') %></p>
|
||||
|
||||
<div><%= yield %></div>
|
||||
|
||||
<p><%= t('mailers.user.closing_greeting') %></p>
|
||||
|
||||
<footer>
|
||||
<%=
|
||||
link_to(
|
||||
t('mailers.user.unsubscribe'),
|
||||
add_subdomain_to(method(:edit_user_registration_url))
|
||||
)
|
||||
%>.
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +0,0 @@
|
||||
<%= yield %>
|
||||
1
app/views/user_mailer/_closing.html.erb
Normal file
1
app/views/user_mailer/_closing.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<p><%= t('mailers.user.closing_greeting') %></p>
|
||||
1
app/views/user_mailer/_opening.html.erb
Normal file
1
app/views/user_mailer/_opening.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<p><%= t('mailers.user.opening_greeting', name: user_name) %></p>
|
||||
3
app/views/user_mailer/_quoted_text.html.erb
Normal file
3
app/views/user_mailer/_quoted_text.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<p style="width: 80%; margin: 32px auto; font-size: 16px; border: 1px solid rgba(0, 0, 0, 0.125); border-radius: 0.25rem; padding: 16px;">
|
||||
<%= text %>
|
||||
</p>
|
||||
11
app/views/user_mailer/_unsubscribe_from_post.html.erb
Normal file
11
app/views/user_mailer/_unsubscribe_from_post.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<footer>
|
||||
<hr style="border-top: 1px;">
|
||||
<p style="margin-bottom: 0; font-size: 14px; color: grey;">
|
||||
<%=
|
||||
t(
|
||||
'mailers.user.unsubscribe_from_post_html',
|
||||
href: link_to(t('mailers.user.unsubscribe_link'), add_subdomain_to(method(:post_url), post))
|
||||
)
|
||||
%>
|
||||
</p>
|
||||
</footer>
|
||||
11
app/views/user_mailer/_unsubscribe_from_site.html.erb
Normal file
11
app/views/user_mailer/_unsubscribe_from_site.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<footer>
|
||||
<hr style="border-top: 1px;">
|
||||
<p style="margin-bottom: 0; font-size: 14px; color: grey;">
|
||||
<%=
|
||||
t(
|
||||
'mailers.user.unsubscribe_from_site_html',
|
||||
href: link_to(t('mailers.user.unsubscribe_link'), add_subdomain_to(method(:edit_user_registration_url)))
|
||||
).html_safe
|
||||
%>
|
||||
</p>
|
||||
</footer>
|
||||
@@ -1,11 +1,15 @@
|
||||
<p>
|
||||
<%= t('mailers.user.notify_comment_owner.body', user: @comment.user.full_name, post: @comment.post.title) %>
|
||||
</p>
|
||||
<%= render 'user_mailer/opening', user_name: @user.full_name %>
|
||||
|
||||
<p>
|
||||
<i><%= @comment.body %></i>
|
||||
<%= t('mailers.user.notify_comment_owner.body_html', user: @comment.user.full_name, post: @comment.post.title) %>:
|
||||
</p>
|
||||
|
||||
<%= render 'user_mailer/quoted_text', text: @comment.body %>
|
||||
|
||||
<p>
|
||||
<%= link_to t('mailers.user.learn_more'), add_subdomain_to(method(:post_url), @comment.post) %>
|
||||
</p>
|
||||
|
||||
<%= render 'user_mailer/closing' %>
|
||||
|
||||
<%= render 'user_mailer/unsubscribe_from_site' %>
|
||||
@@ -0,0 +1,17 @@
|
||||
<%= render 'user_mailer/opening', user_name: @user.full_name %>
|
||||
|
||||
<p>
|
||||
<%= t('mailers.user.notify_follower_of_post_status_change.body_html', post: @post.title) %>:
|
||||
</p>
|
||||
|
||||
<p style="margin: 32px auto; text-align: center;">
|
||||
<span style='color: white; border-radius: 10rem; padding: 0.5rem; background-color: <%= @post.post_status.color %>;'><%= @post.post_status.name.upcase %></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= link_to t('mailers.user.learn_more'), add_subdomain_to(method(:post_url), @post) %>
|
||||
</p>
|
||||
|
||||
<%= render 'user_mailer/closing' %>
|
||||
|
||||
<%= render 'user_mailer/unsubscribe_from_post', post: @post %>
|
||||
@@ -0,0 +1,15 @@
|
||||
<%= render 'user_mailer/opening', user_name: @user.full_name %>
|
||||
|
||||
<p>
|
||||
<%= t('mailers.user.notify_follower_of_post_update.body_html', user: @comment.user.full_name, post: @comment.post.title) %>:
|
||||
</p>
|
||||
|
||||
<%= render 'user_mailer/quoted_text', text: @comment.body %>
|
||||
|
||||
<p>
|
||||
<%= link_to t('mailers.user.learn_more'), add_subdomain_to(method(:post_url), @comment.post) %>
|
||||
</p>
|
||||
|
||||
<%= render 'user_mailer/closing' %>
|
||||
|
||||
<%= render 'user_mailer/unsubscribe_from_post', post: @comment.post %>
|
||||
@@ -1,10 +0,0 @@
|
||||
<p>
|
||||
<%= t('mailers.user.notify_followers_of_post_status_change.body', post: @post.title) %>
|
||||
<span style='color: white; border-radius: 10rem; padding: 0.5rem; background-color: <%= @post.post_status.color %>;'>
|
||||
<%= @post.post_status.name.upcase %>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= link_to t('mailers.user.learn_more'), add_subdomain_to(method(:post_url), @post) %>
|
||||
</p>
|
||||
@@ -1,11 +0,0 @@
|
||||
<p>
|
||||
<%= t('mailers.user.notify_followers_of_post_update.body', user: @comment.user.full_name, post: @comment.post.title) %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<i><%= @comment.body %></i>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= link_to t('mailers.user.learn_more'), add_subdomain_to(method(:post_url), @comment.post) %>
|
||||
</p>
|
||||
@@ -1,11 +1,15 @@
|
||||
<p>
|
||||
<%= t('mailers.user.notify_post_owner.body', user: @comment.user.full_name, post: @comment.post.title) %>
|
||||
</p>
|
||||
<%= render 'user_mailer/opening', user_name: @user.full_name %>
|
||||
|
||||
<p>
|
||||
<i><%= @comment.body %></i>
|
||||
<%= t('mailers.user.notify_post_owner.body_html', user: @comment.user.full_name, post: @comment.post.title) %>:
|
||||
</p>
|
||||
|
||||
<%= render 'user_mailer/quoted_text', text: @comment.body %>
|
||||
|
||||
<p>
|
||||
<%= link_to t('mailers.user.learn_more'), add_subdomain_to(method(:post_url), @comment.post) %>
|
||||
</p>
|
||||
|
||||
<%= render 'user_mailer/closing' %>
|
||||
|
||||
<%= render 'user_mailer/unsubscribe_from_post', post: @comment.post %>
|
||||
@@ -7,7 +7,9 @@ class SendNotificationForCommentWorkflow
|
||||
|
||||
def run
|
||||
if comment.is_post_update # Post update
|
||||
UserMailer.notify_followers_of_post_update(comment: comment).deliver_later
|
||||
comment.post.followers.each do |follower|
|
||||
UserMailer.notify_follower_of_post_update(comment: comment, follower: follower).deliver_later
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user