mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: add option to include topics from trust level 0 users in digest emails
This commit is contained in:
parent
9b77a1a36c
commit
213950e4cf
@ -168,7 +168,8 @@ const User = RestModel.extend({
|
|||||||
'digest_after_minutes',
|
'digest_after_minutes',
|
||||||
'new_topic_duration_minutes',
|
'new_topic_duration_minutes',
|
||||||
'auto_track_topics_after_msecs',
|
'auto_track_topics_after_msecs',
|
||||||
'like_notification_frequency'
|
'like_notification_frequency',
|
||||||
|
'include_tl0_in_digests'
|
||||||
].forEach(s => {
|
].forEach(s => {
|
||||||
data[s] = this.get(`user_option.${s}`);
|
data[s] = this.get(`user_option.${s}`);
|
||||||
});
|
});
|
||||||
|
@ -174,8 +174,10 @@
|
|||||||
<div class='controls controls-dropdown'>
|
<div class='controls controls-dropdown'>
|
||||||
{{combo-box valueAttribute="value" content=digestFrequencies value=model.user_option.digest_after_minutes}}
|
{{combo-box valueAttribute="value" content=digestFrequencies value=model.user_option.digest_after_minutes}}
|
||||||
</div>
|
</div>
|
||||||
|
{{preference-checkbox labelKey="user.include_tl0_in_digests" checked=model.user_option.include_tl0_in_digests}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
<br/>
|
||||||
<div class='controls controls-dropdown'>
|
<div class='controls controls-dropdown'>
|
||||||
<label>{{i18n 'user.email_previous_replies.title'}}</label>
|
<label>{{i18n 'user.email_previous_replies.title'}}</label>
|
||||||
{{combo-box valueAttribute="value" content=previousRepliesOptions value=model.user_option.email_previous_replies}}
|
{{combo-box valueAttribute="value" content=previousRepliesOptions value=model.user_option.email_previous_replies}}
|
||||||
|
@ -314,11 +314,14 @@ class Topic < ActiveRecord::Base
|
|||||||
.joins("LEFT OUTER JOIN users ON users.id = topics.user_id")
|
.joins("LEFT OUTER JOIN users ON users.id = topics.user_id")
|
||||||
.where(closed: false, archived: false)
|
.where(closed: false, archived: false)
|
||||||
.where("COALESCE(topic_users.notification_level, 1) <> ?", TopicUser.notification_levels[:muted])
|
.where("COALESCE(topic_users.notification_level, 1) <> ?", TopicUser.notification_levels[:muted])
|
||||||
.where("COALESCE(users.trust_level, 0) > 0")
|
|
||||||
.created_since(since)
|
.created_since(since)
|
||||||
.listable_topics
|
.listable_topics
|
||||||
.includes(:category)
|
.includes(:category)
|
||||||
|
|
||||||
|
unless user.user_option.try(:include_tl0_in_digests)
|
||||||
|
topics = topics.where("COALESCE(users.trust_level, 0) > 0")
|
||||||
|
end
|
||||||
|
|
||||||
if !!opts[:top_order]
|
if !!opts[:top_order]
|
||||||
topics = topics.joins("LEFT OUTER JOIN top_topics ON top_topics.topic_id = topics.id")
|
topics = topics.joins("LEFT OUTER JOIN top_topics ON top_topics.topic_id = topics.id")
|
||||||
.order(TopicQuerySQL.order_top_for(score))
|
.order(TopicQuerySQL.order_top_for(score))
|
||||||
|
@ -49,6 +49,8 @@ class UserOption < ActiveRecord::Base
|
|||||||
self.digest_after_minutes ||= SiteSetting.default_email_digest_frequency.to_i
|
self.digest_after_minutes ||= SiteSetting.default_email_digest_frequency.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.include_tl0_in_digests = SiteSetting.default_include_tl0_in_digests
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,7 +16,8 @@ class UserOptionSerializer < ApplicationSerializer
|
|||||||
:new_topic_duration_minutes,
|
:new_topic_duration_minutes,
|
||||||
:email_previous_replies,
|
:email_previous_replies,
|
||||||
:email_in_reply_to,
|
:email_in_reply_to,
|
||||||
:like_notification_frequency
|
:like_notification_frequency,
|
||||||
|
:include_tl0_in_digests
|
||||||
|
|
||||||
|
|
||||||
def include_edit_history_public?
|
def include_edit_history_public?
|
||||||
|
@ -23,7 +23,8 @@ class UserUpdater
|
|||||||
:auto_track_topics_after_msecs,
|
:auto_track_topics_after_msecs,
|
||||||
:email_previous_replies,
|
:email_previous_replies,
|
||||||
:email_in_reply_to,
|
:email_in_reply_to,
|
||||||
:like_notification_frequency
|
:like_notification_frequency,
|
||||||
|
:include_tl0_in_digests
|
||||||
]
|
]
|
||||||
|
|
||||||
def initialize(actor, user)
|
def initialize(actor, user)
|
||||||
|
@ -652,6 +652,7 @@ en:
|
|||||||
weekly: "weekly"
|
weekly: "weekly"
|
||||||
every_two_weeks: "every two weeks"
|
every_two_weeks: "every two weeks"
|
||||||
|
|
||||||
|
include_tl0_in_digests: "Include posts from new users in digest emails"
|
||||||
email_in_reply_to: "Include an excerpt of replied to post in emails"
|
email_in_reply_to: "Include an excerpt of replied to post in emails"
|
||||||
email_direct: "Send me an email when someone quotes me, replies to my post, mentions my @username, or invites me to a topic"
|
email_direct: "Send me an email when someone quotes me, replies to my post, mentions my @username, or invites me to a topic"
|
||||||
email_private_messages: "Send me an email when someone messages me"
|
email_private_messages: "Send me an email when someone messages me"
|
||||||
|
@ -1267,6 +1267,7 @@ en:
|
|||||||
notify_about_queued_posts_after: "If there are posts that have been waiting to be reviewed for more than this many hours, an email will be sent to the contact email. Set to 0 to disable these emails."
|
notify_about_queued_posts_after: "If there are posts that have been waiting to be reviewed for more than this many hours, an email will be sent to the contact email. Set to 0 to disable these emails."
|
||||||
|
|
||||||
default_email_digest_frequency: "How often users receive digest emails by default."
|
default_email_digest_frequency: "How often users receive digest emails by default."
|
||||||
|
default_include_tl0_in_digests: "Include posts from new users in digest emails by default. Users can change this in their preferences."
|
||||||
default_email_private_messages: "Send an email when someone messages the user by default."
|
default_email_private_messages: "Send an email when someone messages the user by default."
|
||||||
default_email_direct: "Send an email when someone quotes/replies to/mentions or invites the user by default."
|
default_email_direct: "Send an email when someone quotes/replies to/mentions or invites the user by default."
|
||||||
default_email_mailing_list_mode: "Send an email for every new post by default."
|
default_email_mailing_list_mode: "Send an email for every new post by default."
|
||||||
|
@ -1085,6 +1085,7 @@ user_preferences:
|
|||||||
default_email_digest_frequency:
|
default_email_digest_frequency:
|
||||||
enum: 'DigestEmailSiteSetting'
|
enum: 'DigestEmailSiteSetting'
|
||||||
default: 10080
|
default: 10080
|
||||||
|
default_include_tl0_in_digests: false
|
||||||
default_email_private_messages: true
|
default_email_private_messages: true
|
||||||
default_email_direct: true
|
default_email_direct: true
|
||||||
default_email_mailing_list_mode: false
|
default_email_mailing_list_mode: false
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddIncludeTl0InDigestsToUserOptions < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :user_options, :include_tl0_in_digests, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
@ -17,7 +17,6 @@ describe PostActionsController do
|
|||||||
PostAction.expects(:act).once.raises(RateLimiter::LimitExceeded.new(60, 'create_like'))
|
PostAction.expects(:act).once.raises(RateLimiter::LimitExceeded.new(60, 'create_like'))
|
||||||
expect(-> {
|
expect(-> {
|
||||||
xhr :post, :create, id: @post.id, post_action_type_id: PostActionType.types[:like]
|
xhr :post, :create, id: @post.id, post_action_type_id: PostActionType.types[:like]
|
||||||
puts response.success?
|
|
||||||
}).to change(UserHistory, :count).by(1)
|
}).to change(UserHistory, :count).by(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1303,6 +1303,16 @@ describe Topic do
|
|||||||
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to be_blank
|
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to be_blank
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns topics from TL0 users if enabled in preferences" do
|
||||||
|
new_user = Fabricate(:user, trust_level: 0)
|
||||||
|
topic = Fabricate(:topic, user_id: new_user.id)
|
||||||
|
|
||||||
|
u = Fabricate(:user)
|
||||||
|
u.user_option.include_tl0_in_digests = true
|
||||||
|
|
||||||
|
expect(Topic.for_digest(u, 1.year.ago, top_order: true)).to eq([topic])
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'secured' do
|
describe 'secured' do
|
||||||
|
Loading…
Reference in New Issue
Block a user