diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index 0c481ae8ae7..6c56837a3c2 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -45,9 +45,15 @@ class UserNotifications < ActionMailer::Base # Don't send email unless there is content in it if @featured_topics.present? + @new_topics_since_seen = Topic.listable_topics + .where("created_at > ?", min_date).count - @featured_topics.length + + @new_topics_since_seen = 0 if @new_topics_since_seen < 0 @featured_topics, @new_topics = @featured_topics[0..4], @featured_topics[5..-1] @markdown_linker = MarkdownLinker.new(Discourse.base_url) + + build_email user.email, from_alias: I18n.t('user_notifications.digest.from', site_name: SiteSetting.title), subject: I18n.t('user_notifications.digest.subject_template', diff --git a/app/views/user_notifications/digest.html.erb b/app/views/user_notifications/digest.html.erb index ba8fa42fdf6..bffbb6b87e7 100644 --- a/app/views/user_notifications/digest.html.erb +++ b/app/views/user_notifications/digest.html.erb @@ -44,6 +44,10 @@ <%- end -%> + <%- if @new_topics_since_seen > 0 %> +

<%= t('user_notifications.digest.more_topics', last_seen_at: @last_seen_at, new_topics_since_seen: @new_topics_since_seen) %>

+ <%- end -%> + <%=raw(t :'user_notifications.digest.unsubscribe', site_link: html_site_link, diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index d0d3c607a4b..c26e83e2b74 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1360,6 +1360,7 @@ en: click_here: "click here" from: "%{site_name} digest" read_more: "Read More" + more_topics: "Also, since we last saw you on %{last_seen_at} there have been %{new_topics_since_seen} new topics posted." posts: one: "1 post"