mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Discourse as a Mailing List improvements
FEATURE: context is not emailed if we previously emailed you the post FEATURE: site setting to enable_watch_new_topics , false by default. When enables users can elect to watch everything by default FIX: Custom email subjects (x quoted you in [title], x replied to [title]) was removed, this broke email grouping. TBD, include info in footer somehow FIX: topic user specs were messy, reduce side effects
This commit is contained in:
@@ -113,12 +113,21 @@ class UserNotifications < ActionMailer::Base
|
||||
notification_type = opts[:notification_type] || Notification.types[@notification.notification_type].to_s
|
||||
|
||||
context = ""
|
||||
tu = TopicUser.get(@post.topic_id, user)
|
||||
|
||||
context_posts = Post.where(topic_id: @post.topic_id)
|
||||
.where("post_number < ?", @post.post_number)
|
||||
.where(user_deleted: false)
|
||||
.order('created_at desc')
|
||||
.limit(SiteSetting.email_posts_context)
|
||||
|
||||
if tu && tu.last_emailed_post_number
|
||||
context_posts = context_posts.where("post_number > ?", tu.last_emailed_post_number)
|
||||
end
|
||||
|
||||
# make .present? cheaper
|
||||
context_posts = context_posts.to_a
|
||||
|
||||
if context_posts.present?
|
||||
context << "---\n*#{I18n.t('user_notifications.previous_discussion')}*\n"
|
||||
context_posts.each do |cp|
|
||||
@@ -157,6 +166,8 @@ class UserNotifications < ActionMailer::Base
|
||||
email_opts[:from_alias] = username
|
||||
end
|
||||
|
||||
TopicUser.change(user.id, @post.topic_id, last_emailed_post_number: @post.post_number)
|
||||
|
||||
build_email(user.email, email_opts)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user