UX: user invite email style should be consistent with other user notifications

This commit is contained in:
Arpit Jalan 2016-03-25 17:56:52 +05:30
parent 92551df979
commit 17afdc34cc
3 changed files with 68 additions and 37 deletions

View file

@ -173,12 +173,14 @@ class UserNotifications < ActionMailer::Base
end
def user_invited_to_private_message(user, opts)
opts[:use_template_html] = true
opts[:allow_reply_by_email] = false
opts[:use_invite_template] = true
notification_email(user, opts)
end
def user_invited_to_topic(user, opts)
opts[:use_template_html] = true
opts[:allow_reply_by_email] = false
opts[:use_invite_template] = true
opts[:show_category_in_subject] = true
notification_email(user, opts)
end
@ -273,7 +275,7 @@ class UserNotifications < ActionMailer::Base
add_re_to_subject: opts[:add_re_to_subject],
show_category_in_subject: opts[:show_category_in_subject],
notification_type: notification_type,
use_template_html: opts[:use_template_html],
use_invite_template: opts[:use_invite_template],
user: user
)
end
@ -322,9 +324,21 @@ class UserNotifications < ActionMailer::Base
.where('created_at > ?', 1.day.ago)
.count) >= (SiteSetting.max_emails_per_day_per_user-1)
topic_excerpt = ""
if opts[:use_template_html]
if opts[:use_invite_template]
if post.topic.private_message?
invite_template = "user_notifications.invited_to_private_message_body"
else
invite_template = "user_notifications.invited_to_topic_body"
end
topic_excerpt = post.excerpt.gsub("\n", " ") if post.is_first_post? && post.excerpt
message = I18n.t(invite_template, username: post.username, topic_title: title, topic_excerpt: topic_excerpt, site_title: SiteSetting.title, site_description: SiteSetting.site_description)
html = UserNotificationRenderer.new(Rails.configuration.paths["app/views"]).render(
template: 'email/invite',
format: :html,
locals: { message: PrettyText.cook(message, sanitize: false).html_safe,
classes: RTL.new(user).css_class
}
)
else
in_reply_to_post = post.reply_to_post if user.user_option.email_in_reply_to
html = UserNotificationRenderer.new(Rails.configuration.paths["app/views"]).render(
@ -337,6 +351,7 @@ class UserNotifications < ActionMailer::Base
classes: RTL.new(user).css_class
}
)
message = email_post_markdown(post) + (reached_limit ? "\n\n#{I18n.t "user_notifications.reached_limit", count: SiteSetting.max_emails_per_day_per_user}" : "");
end
template = "user_notifications.user_#{notification_type}"
@ -348,8 +363,7 @@ class UserNotifications < ActionMailer::Base
email_opts = {
topic_title: title,
topic_excerpt: topic_excerpt,
message: email_post_markdown(post) + (reached_limit ? "\n\n#{I18n.t "user_notifications.reached_limit", count: SiteSetting.max_emails_per_day_per_user}" : ""),
message: message,
url: post.url,
post_id: post.id,
topic_id: post.topic_id,

View file

@ -0,0 +1,13 @@
<div id='main' class=<%= classes %>>
<div class='header-instructions'>%{header_instructions}</div>
<% if message.present? %>
<div><%= message %></div>
<% end %>
<hr>
<div class='footer'>%{respond_instructions}</div>
<div class='footer'>%{unsubscribe_link}%{unsubscribe_via_email_link}</div>
</div>

View file

@ -2067,53 +2067,57 @@ en:
posted_by: "Posted by %{username} on %{post_date}"
invited_to_private_message_body: |
%{username} invited you to a message
> **%{topic_title}**
>
> %{topic_excerpt}
at
> %{site_title} -- %{site_description}
invited_to_topic_body: |
%{username} invited you to a discussion
> **%{topic_title}**
>
> %{topic_excerpt}
at
> %{site_title} -- %{site_description}
user_invited_to_private_message_pm:
subject_template: "[%{site_name}] %{username} invited you to a message '%{topic_title}'"
text_body_template: |
%{header_instructions}
%{username} invited you to a message
%{message}
> **%{topic_title}**
>
> %{topic_excerpt}
at
> %{site_title} -- %{site_description}
Please visit this link to view the message: %{base_url}%{url}
---
%{respond_instructions}
user_invited_to_private_message_pm_staged:
subject_template: "[%{site_name}] %{username} invited you to a message '%{topic_title}'"
text_body_template: |
%{header_instructions}
%{username} invited you to a message
%{message}
> **%{topic_title}**
>
> %{topic_excerpt}
at
> %{site_title} -- %{site_description}
Please visit this link to view the message: %{base_url}%{url}
---
%{respond_instructions}
user_invited_to_topic:
subject_template: "[%{site_name}] %{username} invited you to '%{topic_title}'"
text_body_template: |
%{header_instructions}
%{username} invited you to a discussion
%{message}
> **%{topic_title}**
>
> %{topic_excerpt}
at
> %{site_title} -- %{site_description}
Please visit this link to view the message: %{base_url}%{url}
---
%{respond_instructions}
user_replied:
subject_template: "[%{site_name}] %{topic_title}"