mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 19:57:52 +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
|
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
|
end
|
||||||
|
|
||||||
render json: @post
|
render json: @post
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
class UserMailer < ApplicationMailer
|
class UserMailer < ApplicationMailer
|
||||||
layout 'user_mailer'
|
|
||||||
|
|
||||||
def notify_post_owner(comment:)
|
def notify_post_owner(comment:)
|
||||||
@tenant = comment.tenant
|
Current.tenant = comment.tenant
|
||||||
Current.tenant = @tenant
|
|
||||||
@comment = comment
|
@comment = comment
|
||||||
@user = comment.post.user
|
@user = comment.post.user
|
||||||
|
|
||||||
@@ -14,8 +11,7 @@ class UserMailer < ApplicationMailer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def notify_comment_owner(comment:)
|
def notify_comment_owner(comment:)
|
||||||
@tenant = comment.tenant
|
Current.tenant = comment.tenant
|
||||||
Current.tenant = @tenant
|
|
||||||
@comment = comment
|
@comment = comment
|
||||||
@user = comment.parent.user
|
@user = comment.parent.user
|
||||||
|
|
||||||
@@ -25,25 +21,25 @@ class UserMailer < ApplicationMailer
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_followers_of_post_update(comment:)
|
def notify_follower_of_post_update(comment:, follower:)
|
||||||
@tenant = comment.tenant
|
Current.tenant = comment.tenant
|
||||||
Current.tenant = @tenant
|
|
||||||
@comment = comment
|
@comment = comment
|
||||||
|
@user = follower
|
||||||
|
|
||||||
mail(
|
mail(
|
||||||
to: comment.post.followers.pluck(:email),
|
to: follower.email,
|
||||||
subject: t('mailers.user.notify_followers_of_post_update.subject', site_name: site_name, post: comment.post.title)
|
subject: t('mailers.user.notify_follower_of_post_update.subject', site_name: site_name, post: comment.post.title)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_followers_of_post_status_change(post:)
|
def notify_follower_of_post_status_change(post:, follower:)
|
||||||
@tenant = post.tenant
|
Current.tenant = post.tenant
|
||||||
Current.tenant = @tenant
|
|
||||||
@post = post
|
@post = post
|
||||||
|
@user = follower
|
||||||
|
|
||||||
mail(
|
mail(
|
||||||
to: post.followers.pluck(:email),
|
to: follower.email,
|
||||||
subject: t('mailers.user.notify_followers_of_post_status_change.subject', site_name: site_name, post: post.title)
|
subject: t('mailers.user.notify_follower_of_post_status_change.subject', site_name: site_name, post: post.title)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,13 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<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>
|
</body>
|
||||||
</html>
|
</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>
|
<%= render 'user_mailer/opening', user_name: @user.full_name %>
|
||||||
<%= t('mailers.user.notify_comment_owner.body', user: @comment.user.full_name, post: @comment.post.title) %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<i><%= @comment.body %></i>
|
<%= t('mailers.user.notify_comment_owner.body_html', user: @comment.user.full_name, post: @comment.post.title) %>:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<%= render 'user_mailer/quoted_text', text: @comment.body %>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= link_to t('mailers.user.learn_more'), add_subdomain_to(method(:post_url), @comment.post) %>
|
<%= link_to t('mailers.user.learn_more'), add_subdomain_to(method(:post_url), @comment.post) %>
|
||||||
</p>
|
</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>
|
<%= render 'user_mailer/opening', user_name: @user.full_name %>
|
||||||
<%= t('mailers.user.notify_post_owner.body', user: @comment.user.full_name, post: @comment.post.title) %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<i><%= @comment.body %></i>
|
<%= t('mailers.user.notify_post_owner.body_html', user: @comment.user.full_name, post: @comment.post.title) %>:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<%= render 'user_mailer/quoted_text', text: @comment.body %>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= link_to t('mailers.user.learn_more'), add_subdomain_to(method(:post_url), @comment.post) %>
|
<%= link_to t('mailers.user.learn_more'), add_subdomain_to(method(:post_url), @comment.post) %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<%= render 'user_mailer/closing' %>
|
||||||
|
|
||||||
|
<%= render 'user_mailer/unsubscribe_from_post', post: @comment.post %>
|
||||||
@@ -7,7 +7,9 @@ class SendNotificationForCommentWorkflow
|
|||||||
|
|
||||||
def run
|
def run
|
||||||
if comment.is_post_update # Post update
|
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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ module App
|
|||||||
# -- all .rb files in that directory are automatically loaded after loading
|
# -- all .rb files in that directory are automatically loaded after loading
|
||||||
# the framework and any gems in your application.
|
# the framework and any gems in your application.
|
||||||
|
|
||||||
|
# For assets in mailers
|
||||||
|
config.asset_host = ENV["BASE_URL"]
|
||||||
|
|
||||||
def base_url
|
def base_url
|
||||||
ENV["BASE_URL"]
|
ENV["BASE_URL"]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ Rails.application.configure do
|
|||||||
# For Devise
|
# For Devise
|
||||||
config.action_mailer.default_url_options = { host: Rails.application.base_url }
|
config.action_mailer.default_url_options = { host: Rails.application.base_url }
|
||||||
|
|
||||||
|
# For ActionMailer previews
|
||||||
|
config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews"
|
||||||
|
|
||||||
# In the development environment your application's code is reloaded on
|
# In the development environment your application's code is reloaded on
|
||||||
# every request. This slows down response time but is perfect for development
|
# every request. This slows down response time but is perfect for development
|
||||||
# since you don't have to restart the web server when you make code changes.
|
# since you don't have to restart the web server when you make code changes.
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ de:
|
|||||||
notify_comment_owner:
|
notify_comment_owner:
|
||||||
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
||||||
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
||||||
notify_followers_of_post_update:
|
notify_follower_of_post_update:
|
||||||
subject: '[%{site_name}] New update for post "%{post}"'
|
subject: '[%{site_name}] New update for post "%{post}"'
|
||||||
body: 'There is a new update on the post you are following "%{post}"'
|
body: 'There is a new update on the post you are following "%{post}"'
|
||||||
notify_followers_of_post_status_change:
|
notify_follower_of_post_status_change:
|
||||||
subject: '[%{site_name}] Status change on post "%{post}"'
|
subject: '[%{site_name}] Status change on post "%{post}"'
|
||||||
body: 'There is a status update on the post you are following "%{post}"'
|
body: 'There is a status update on the post you are following "%{post}"'
|
||||||
activerecord:
|
activerecord:
|
||||||
|
|||||||
@@ -30,22 +30,24 @@ en:
|
|||||||
body3: "Your password won't change until you access the link above and create a new one."
|
body3: "Your password won't change until you access the link above and create a new one."
|
||||||
action: 'Change my password'
|
action: 'Change my password'
|
||||||
user:
|
user:
|
||||||
opening_greeting: 'Hello!'
|
opening_greeting: 'Hello %{name}!'
|
||||||
closing_greeting: 'Have a great day!'
|
closing_greeting: 'Have a great day!'
|
||||||
learn_more: 'Click here to learn more'
|
learn_more: 'Click here to learn more'
|
||||||
unsubscribe: 'Annoyed? You can turn off notifications here'
|
unsubscribe_from_post_html: 'Annoyed? You can turn off notifications for this post %{href}'
|
||||||
|
unsubscribe_from_site_html: 'Annoyed? You can turn off all notifications %{href}'
|
||||||
|
unsubscribe_link: 'here'
|
||||||
notify_post_owner:
|
notify_post_owner:
|
||||||
subject: '[%{site_name}] New comment on "%{post}"'
|
subject: '[%{site_name}] New comment on "%{post}"'
|
||||||
body: 'There is a new comment by "%{user}" on your post "%{post}"'
|
body_html: 'There is a new comment by <b>%{user}</b> on your post <b>%{post}</b>'
|
||||||
notify_comment_owner:
|
notify_comment_owner:
|
||||||
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
||||||
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
body_html: 'There is a new reply by <b>%{user}</b> to your comment on post <b>%{post}</b>'
|
||||||
notify_followers_of_post_update:
|
notify_follower_of_post_update:
|
||||||
subject: '[%{site_name}] New update for post "%{post}"'
|
subject: '[%{site_name}] New update for post "%{post}"'
|
||||||
body: 'There is a new update on the post you are following "%{post}"'
|
body_html: 'There is a new update on the post you are following <b>%{post}</b>'
|
||||||
notify_followers_of_post_status_change:
|
notify_follower_of_post_status_change:
|
||||||
subject: '[%{site_name}] Status change on post "%{post}"'
|
subject: '[%{site_name}] Status change on post "%{post}"'
|
||||||
body: 'There is a status update on the post you are following "%{post}"'
|
body_html: 'There is a status update on the post you are following <b>%{post}</b>'
|
||||||
activerecord:
|
activerecord:
|
||||||
models:
|
models:
|
||||||
board:
|
board:
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ es:
|
|||||||
notify_comment_owner:
|
notify_comment_owner:
|
||||||
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
||||||
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
||||||
notify_followers_of_post_update:
|
notify_follower_of_post_update:
|
||||||
subject: '[%{site_name}] New update for post "%{post}"'
|
subject: '[%{site_name}] New update for post "%{post}"'
|
||||||
body: 'There is a new update on the post you are following "%{post}"'
|
body: 'There is a new update on the post you are following "%{post}"'
|
||||||
notify_followers_of_post_status_change:
|
notify_follower_of_post_status_change:
|
||||||
subject: '[%{site_name}] Status change on post "%{post}"'
|
subject: '[%{site_name}] Status change on post "%{post}"'
|
||||||
body: 'There is a status update on the post you are following "%{post}"'
|
body: 'There is a status update on the post you are following "%{post}"'
|
||||||
activerecord:
|
activerecord:
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ fr:
|
|||||||
notify_comment_owner:
|
notify_comment_owner:
|
||||||
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
||||||
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
||||||
notify_followers_of_post_update:
|
notify_follower_of_post_update:
|
||||||
subject: '[%{site_name}] New update for post "%{post}"'
|
subject: '[%{site_name}] New update for post "%{post}"'
|
||||||
body: 'There is a new update on the post you are following "%{post}"'
|
body: 'There is a new update on the post you are following "%{post}"'
|
||||||
notify_followers_of_post_status_change:
|
notify_follower_of_post_status_change:
|
||||||
subject: '[%{site_name}] Status change on post "%{post}"'
|
subject: '[%{site_name}] Status change on post "%{post}"'
|
||||||
body: 'There is a status update on the post you are following "%{post}"'
|
body: 'There is a status update on the post you are following "%{post}"'
|
||||||
activerecord:
|
activerecord:
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ it:
|
|||||||
notify_comment_owner:
|
notify_comment_owner:
|
||||||
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
||||||
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
||||||
notify_followers_of_post_update:
|
notify_follower_of_post_update:
|
||||||
subject: '[%{site_name}] New update for post "%{post}"'
|
subject: '[%{site_name}] New update for post "%{post}"'
|
||||||
body: 'There is a new update on the post you are following "%{post}"'
|
body: 'There is a new update on the post you are following "%{post}"'
|
||||||
notify_followers_of_post_status_change:
|
notify_follower_of_post_status_change:
|
||||||
subject: '[%{site_name}] Status change on post "%{post}"'
|
subject: '[%{site_name}] Status change on post "%{post}"'
|
||||||
body: 'There is a status update on the post you are following "%{post}"'
|
body: 'There is a status update on the post you are following "%{post}"'
|
||||||
activerecord:
|
activerecord:
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ ja:
|
|||||||
notify_comment_owner:
|
notify_comment_owner:
|
||||||
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
||||||
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
||||||
notify_followers_of_post_update:
|
notify_follower_of_post_update:
|
||||||
subject: '[%{site_name}] New update for post "%{post}"'
|
subject: '[%{site_name}] New update for post "%{post}"'
|
||||||
body: 'There is a new update on the post you are following "%{post}"'
|
body: 'There is a new update on the post you are following "%{post}"'
|
||||||
notify_followers_of_post_status_change:
|
notify_follower_of_post_status_change:
|
||||||
subject: '[%{site_name}] Status change on post "%{post}"'
|
subject: '[%{site_name}] Status change on post "%{post}"'
|
||||||
body: 'There is a status update on the post you are following "%{post}"'
|
body: 'There is a status update on the post you are following "%{post}"'
|
||||||
activerecord:
|
activerecord:
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ ko:
|
|||||||
notify_comment_owner:
|
notify_comment_owner:
|
||||||
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
||||||
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
||||||
notify_followers_of_post_update:
|
notify_follower_of_post_update:
|
||||||
subject: '[%{site_name}] New update for post "%{post}"'
|
subject: '[%{site_name}] New update for post "%{post}"'
|
||||||
body: 'There is a new update on the post you are following "%{post}"'
|
body: 'There is a new update on the post you are following "%{post}"'
|
||||||
notify_followers_of_post_status_change:
|
notify_follower_of_post_status_change:
|
||||||
subject: '[%{site_name}] Status change on post "%{post}"'
|
subject: '[%{site_name}] Status change on post "%{post}"'
|
||||||
body: 'There is a status update on the post you are following "%{post}"'
|
body: 'There is a status update on the post you are following "%{post}"'
|
||||||
activerecord:
|
activerecord:
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ nl:
|
|||||||
notify_comment_owner:
|
notify_comment_owner:
|
||||||
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
||||||
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
||||||
notify_followers_of_post_update:
|
notify_follower_of_post_update:
|
||||||
subject: '[%{site_name}] New update for post "%{post}"'
|
subject: '[%{site_name}] New update for post "%{post}"'
|
||||||
body: 'There is a new update on the post you are following "%{post}"'
|
body: 'There is a new update on the post you are following "%{post}"'
|
||||||
notify_followers_of_post_status_change:
|
notify_follower_of_post_status_change:
|
||||||
subject: '[%{site_name}] Status change on post "%{post}"'
|
subject: '[%{site_name}] Status change on post "%{post}"'
|
||||||
body: 'There is a status update on the post you are following "%{post}"'
|
body: 'There is a status update on the post you are following "%{post}"'
|
||||||
activerecord:
|
activerecord:
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ pt:
|
|||||||
notify_comment_owner:
|
notify_comment_owner:
|
||||||
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
||||||
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
||||||
notify_followers_of_post_update:
|
notify_follower_of_post_update:
|
||||||
subject: '[%{site_name}] New update for post "%{post}"'
|
subject: '[%{site_name}] New update for post "%{post}"'
|
||||||
body: 'There is a new update on the post you are following "%{post}"'
|
body: 'There is a new update on the post you are following "%{post}"'
|
||||||
notify_followers_of_post_status_change:
|
notify_follower_of_post_status_change:
|
||||||
subject: '[%{site_name}] Status change on post "%{post}"'
|
subject: '[%{site_name}] Status change on post "%{post}"'
|
||||||
body: 'There is a status update on the post you are following "%{post}"'
|
body: 'There is a status update on the post you are following "%{post}"'
|
||||||
activerecord:
|
activerecord:
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ ru:
|
|||||||
notify_comment_owner:
|
notify_comment_owner:
|
||||||
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
||||||
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
||||||
notify_followers_of_post_update:
|
notify_follower_of_post_update:
|
||||||
subject: '[%{site_name}] New update for post "%{post}"'
|
subject: '[%{site_name}] New update for post "%{post}"'
|
||||||
body: 'There is a new update on the post you are following "%{post}"'
|
body: 'There is a new update on the post you are following "%{post}"'
|
||||||
notify_followers_of_post_status_change:
|
notify_follower_of_post_status_change:
|
||||||
subject: '[%{site_name}] Status change on post "%{post}"'
|
subject: '[%{site_name}] Status change on post "%{post}"'
|
||||||
body: 'There is a status update on the post you are following "%{post}"'
|
body: 'There is a status update on the post you are following "%{post}"'
|
||||||
activerecord:
|
activerecord:
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ vi:
|
|||||||
notify_comment_owner:
|
notify_comment_owner:
|
||||||
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
||||||
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
||||||
notify_followers_of_post_update:
|
notify_follower_of_post_update:
|
||||||
subject: '[%{site_name}] New update for post "%{post}"'
|
subject: '[%{site_name}] New update for post "%{post}"'
|
||||||
body: 'There is a new update on the post you are following "%{post}"'
|
body: 'There is a new update on the post you are following "%{post}"'
|
||||||
notify_followers_of_post_status_change:
|
notify_follower_of_post_status_change:
|
||||||
subject: '[%{site_name}] Status change on post "%{post}"'
|
subject: '[%{site_name}] Status change on post "%{post}"'
|
||||||
body: 'There is a status update on the post you are following "%{post}"'
|
body: 'There is a status update on the post you are following "%{post}"'
|
||||||
activerecord:
|
activerecord:
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ zh-CN:
|
|||||||
notify_comment_owner:
|
notify_comment_owner:
|
||||||
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
subject: '[%{site_name}] New reply on your comment on post "%{post}"'
|
||||||
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
body: 'There is a new reply by "%{user}" on your comment from post "%{post}"'
|
||||||
notify_followers_of_post_update:
|
notify_follower_of_post_update:
|
||||||
subject: '[%{site_name}] New update for post "%{post}"'
|
subject: '[%{site_name}] New update for post "%{post}"'
|
||||||
body: 'There is a new update on the post you are following "%{post}"'
|
body: 'There is a new update on the post you are following "%{post}"'
|
||||||
notify_followers_of_post_status_change:
|
notify_follower_of_post_status_change:
|
||||||
subject: '[%{site_name}] Status change on post "%{post}"'
|
subject: '[%{site_name}] Status change on post "%{post}"'
|
||||||
body: 'There is a status update on the post you are following "%{post}"'
|
body: 'There is a status update on the post you are following "%{post}"'
|
||||||
activerecord:
|
activerecord:
|
||||||
|
|||||||
@@ -1,6 +1,36 @@
|
|||||||
# Preview all emails at http://localhost:3000/rails/mailers/user_mailer
|
# Preview all emails at http://localhost:3000/rails/mailers/user_mailer
|
||||||
|
|
||||||
class UserMailerPreview < ActionMailer::Preview
|
class UserMailerPreview < ActionMailer::Preview
|
||||||
|
def initialize(params={})
|
||||||
|
super(params)
|
||||||
|
|
||||||
|
Current.tenant = Tenant.first
|
||||||
|
end
|
||||||
|
|
||||||
def notify_post_owner
|
def notify_post_owner
|
||||||
UserMailer.notify_post_owner(comment: Comment.first)
|
UserMailer.notify_post_owner(comment: Comment.first)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notify_comment_owner
|
||||||
|
comment = Comment.where.not(parent_id: nil).first || throw("No comment replies available")
|
||||||
|
UserMailer.notify_comment_owner(comment: comment)
|
||||||
|
end
|
||||||
|
|
||||||
|
def notify_follower_of_post_update
|
||||||
|
comment = Comment.first
|
||||||
|
if comment.post.follows.empty?
|
||||||
|
throw("No followers available")
|
||||||
|
end
|
||||||
|
follower = comment.post.follows.first.user
|
||||||
|
UserMailer.notify_follower_of_post_update(comment: comment, follower: follower)
|
||||||
|
end
|
||||||
|
|
||||||
|
def notify_follower_of_post_status_change
|
||||||
|
comment = Comment.first
|
||||||
|
if comment.post.follows.empty?
|
||||||
|
throw("No followers available")
|
||||||
|
end
|
||||||
|
follower = comment.post.follows.first.user
|
||||||
|
UserMailer.notify_follower_of_post_status_change(post: Post.first, follower: follower)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user