FEATURE: show topic category in email subject

This commit is contained in:
Arpit Jalan
2014-10-03 17:14:08 +05:30
parent 96afdb173d
commit 0ae0552543
4 changed files with 33 additions and 10 deletions

View File

@@ -84,18 +84,21 @@ class UserNotifications < ActionMailer::Base
def user_replied(user, opts)
opts[:allow_reply_by_email] = true
opts[:use_site_subject] = true
opts[:show_category_in_subject] = true
notification_email(user, opts)
end
def user_quoted(user, opts)
opts[:allow_reply_by_email] = true
opts[:use_site_subject] = true
opts[:show_category_in_subject] = true
notification_email(user, opts)
end
def user_mentioned(user, opts)
opts[:allow_reply_by_email] = true
opts[:use_site_subject] = true
opts[:show_category_in_subject] = true
notification_email(user, opts)
end
@@ -103,6 +106,7 @@ class UserNotifications < ActionMailer::Base
opts[:allow_reply_by_email] = true
opts[:use_site_subject] = true
opts[:add_re_to_subject] = true
opts[:show_category_in_subject] = true
notification_email(user, opts)
end
@@ -110,6 +114,7 @@ class UserNotifications < ActionMailer::Base
opts[:allow_reply_by_email] = true
opts[:use_site_subject] = true
opts[:add_re_to_subject] = true
opts[:show_category_in_subject] = false
# We use the 'user_posted' event when you are emailed a post in a PM.
opts[:notification_type] = 'posted'
@@ -125,6 +130,7 @@ class UserNotifications < ActionMailer::Base
allow_reply_by_email: true,
use_site_subject: true,
add_re_to_subject: true,
show_category_in_subject: true,
notification_type: "posted",
user: user
)
@@ -174,6 +180,7 @@ class UserNotifications < ActionMailer::Base
allow_reply_by_email = opts[:allow_reply_by_email] unless user.suspended?
use_site_subject = opts[:use_site_subject]
add_re_to_subject = opts[:add_re_to_subject]
show_category_in_subject = opts[:show_category_in_subject]
send_notification_email(
title: title,
@@ -182,6 +189,7 @@ class UserNotifications < ActionMailer::Base
allow_reply_by_email: allow_reply_by_email,
use_site_subject: use_site_subject,
add_re_to_subject: add_re_to_subject,
show_category_in_subject: show_category_in_subject,
notification_type: notification_type,
user: user
)
@@ -198,6 +206,19 @@ class UserNotifications < ActionMailer::Base
notification_type = opts[:notification_type]
user = opts[:user]
# category name
category = Topic.find_by(id: post.topic_id).category
if opts[:show_category_in_subject] && post.topic_id && !category.uncategorized?
show_category_in_subject = category.name
# subcategory case
if !category.parent_category_id.nil?
show_category_in_subject = "#{Category.find_by(id: category.parent_category_id).name}/#{show_category_in_subject}"
end
else
show_category_in_subject = nil
end
context = ""
tu = TopicUser.get(post.topic_id, user)
context_posts = self.class.get_context_posts(post, tu)
@@ -241,6 +262,7 @@ class UserNotifications < ActionMailer::Base
allow_reply_by_email: allow_reply_by_email,
use_site_subject: use_site_subject,
add_re_to_subject: add_re_to_subject,
show_category_in_subject: show_category_in_subject,
private_reply: post.topic.private_message?,
include_respond_instructions: !user.suspended?,
template: template,