diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index 9c845d7883..a41e83c584 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -101,10 +101,25 @@ class UserNotifications < ActionMailer::Base @preheader_text = I18n.t('user_notifications.digest.preheader', last_seen_at: @last_seen_at) - @new_topics_count = Topic.new_since_last_seen(user, min_date).count - @unread_messages = user.unread_private_messages - @unread_notifications = user.unread_notifications + # Try to find 3 interesting stats for the top of the digest + @counts = [{label_key: 'user_notifications.digest.new_topics', value: Topic.new_since_last_seen(user, min_date).count}] + value = user.unread_notifications + @counts << {label_key: 'user_notifications.digest.unread_notifications', value: value} if value > 0 + + value = user.unread_private_messages + @counts << {label_key: 'user_notifications.digest.unread_messages', value: value} if value > 0 + + if @counts.size < 3 + @counts << {label_key: 'user_notifications.digest.new_posts', value: Post.for_mailing_list(user, min_date).where("posts.post_number > ?", 1).count} + end + + if @counts.size < 3 + value = User.real.where(active: true, staged: false).not_suspended.where("created_at > ?", min_date).count + @counts << {label_key: 'user_notifications.digest.new_users', value: value } if value > 0 + end + + # Now fetch some topics and posts to show topics_for_digest = Topic.for_digest(user, min_date, limit: SiteSetting.digest_topics + 3, top_order: true).to_a @popular_topics = topics_for_digest[0,SiteSetting.digest_topics] diff --git a/app/views/user_notifications/digest.html.erb b/app/views/user_notifications/digest.html.erb index 7d32b72e86..aeb228bb89 100644 --- a/app/views/user_notifications/digest.html.erb +++ b/app/views/user_notifications/digest.html.erb @@ -58,29 +58,21 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo - +
- - - + <%- @counts.each do |count| -%> + + <%- end -%> - - - + <%- @counts.each do |count| -%> + + <%- end -%>
- <%= @new_topics_count -%> - - <%= @unread_messages -%> - - <%= @unread_notifications -%> - + <%= count[:value] -%> +
- <%=t 'user_notifications.digest.new_topics' %> - - <%=t 'user_notifications.digest.unread_messages' %> - - <%=t 'user_notifications.digest.unread_notifications' %> - + <%=t count[:label_key] -%> +
diff --git a/app/views/user_notifications/digest.text.erb b/app/views/user_notifications/digest.text.erb index b1c92a07bf..e657050854 100644 --- a/app/views/user_notifications/digest.text.erb +++ b/app/views/user_notifications/digest.text.erb @@ -3,9 +3,9 @@ site_link: site_link, last_seen_at: @last_seen_at) %> -<%= @new_topics_count -%> <%=t 'user_notifications.digest.new_topics' %> -<%= @unread_messages -%> <%=t 'user_notifications.digest.unread_messages' %> -<%= @unread_notifications -%> <%=t 'user_notifications.digest.unread_notifications' %> +<%- @counts.each do |count| -%> +<%= count[:value] -%> <%=t count[:label_key] %> +<%- end -%> -------------------------------------------------------------------------------- diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 6f0d5c1702..573685dca4 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -2432,6 +2432,8 @@ en: new_topics: "New Topics" unread_messages: "Unread Messages" unread_notifications: "Unread Notifications" + new_posts: "New Posts" + new_users: "New Users" popular_topics: "Popular Topics" follow_topic: "Follow this topic" join_the_discussion: "Read More"