mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
Disable digest emails site setting
This commit is contained in:
parent
fbd18f3b69
commit
12c82bed59
6 changed files with 39 additions and 14 deletions
|
@ -42,6 +42,10 @@ export default ObjectController.extend(CanCheckEmails, {
|
||||||
return !Discourse.SiteSettings.enable_sso && Discourse.SiteSettings.enable_local_logins;
|
return !Discourse.SiteSettings.enable_sso && Discourse.SiteSettings.enable_local_logins;
|
||||||
}.property(),
|
}.property(),
|
||||||
|
|
||||||
|
canReceiveDigest: function() {
|
||||||
|
return !this.siteSettings.disable_digest_emails
|
||||||
|
}.property(),
|
||||||
|
|
||||||
availableLocales: function() {
|
availableLocales: function() {
|
||||||
return Discourse.SiteSettings.available_locales.split('|').map( function(s) {
|
return Discourse.SiteSettings.available_locales.split('|').map( function(s) {
|
||||||
return {name: s, value: s};
|
return {name: s, value: s};
|
||||||
|
@ -166,5 +170,3 @@ export default ObjectController.extend(CanCheckEmails, {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -171,12 +171,14 @@
|
||||||
|
|
||||||
<div class="control-group pref-email-settings">
|
<div class="control-group pref-email-settings">
|
||||||
<label class="control-label">{{i18n 'user.email_settings'}}</label>
|
<label class="control-label">{{i18n 'user.email_settings'}}</label>
|
||||||
|
{{#if canReceiveDigest}}
|
||||||
{{preference-checkbox labelKey="user.email_digests.title" checked=email_digests}}
|
{{preference-checkbox labelKey="user.email_digests.title" checked=email_digests}}
|
||||||
{{#if email_digests}}
|
{{#if email_digests}}
|
||||||
<div class='controls controls-dropdown'>
|
<div class='controls controls-dropdown'>
|
||||||
{{combo-box valueAttribute="value" content=digestFrequencies value=digest_after_days}}
|
{{combo-box valueAttribute="value" content=digestFrequencies value=digest_after_days}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
{{preference-checkbox labelKey="user.email_private_messages" checked=email_private_messages}}
|
{{preference-checkbox labelKey="user.email_private_messages" checked=email_private_messages}}
|
||||||
{{preference-checkbox labelKey="user.email_direct" checked=email_direct}}
|
{{preference-checkbox labelKey="user.email_direct" checked=email_direct}}
|
||||||
{{preference-checkbox labelKey="user.mailing_list_mode" checked=mailing_list_mode}}
|
{{preference-checkbox labelKey="user.mailing_list_mode" checked=mailing_list_mode}}
|
||||||
|
|
|
@ -5,10 +5,12 @@ module Jobs
|
||||||
every 6.hours
|
every 6.hours
|
||||||
|
|
||||||
def execute(args)
|
def execute(args)
|
||||||
|
unless SiteSetting.disable_digest_emails?
|
||||||
target_user_ids.each do |user_id|
|
target_user_ids.each do |user_id|
|
||||||
Jobs.enqueue(:user_email, type: :digest, user_id: user_id)
|
Jobs.enqueue(:user_email, type: :digest, user_id: user_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def target_user_ids
|
def target_user_ids
|
||||||
# Users who want to receive emails and haven't been emailed in the last day
|
# Users who want to receive emails and haven't been emailed in the last day
|
||||||
|
|
|
@ -991,6 +991,7 @@ en:
|
||||||
digest_min_excerpt_length: "Minimum post excerpt in the email digest, in characters."
|
digest_min_excerpt_length: "Minimum post excerpt in the email digest, in characters."
|
||||||
default_digest_email_frequency: "How often users receive digest emails by default. They can change this setting in their preferences."
|
default_digest_email_frequency: "How often users receive digest emails by default. They can change this setting in their preferences."
|
||||||
suppress_digest_email_after_days: "Suppress digest emails for users not seen on the site for more than (n) days."
|
suppress_digest_email_after_days: "Suppress digest emails for users not seen on the site for more than (n) days."
|
||||||
|
disable_digest_emails: "Disable digest emails for all users."
|
||||||
default_external_links_in_new_tab: "Open external links in a new tab. Users can change this in their preferences."
|
default_external_links_in_new_tab: "Open external links in a new tab. Users can change this in their preferences."
|
||||||
|
|
||||||
detect_custom_avatars: "Whether or not to check that users have uploaded custom avatars."
|
detect_custom_avatars: "Whether or not to check that users have uploaded custom avatars."
|
||||||
|
|
|
@ -409,6 +409,9 @@ email:
|
||||||
default: 7
|
default: 7
|
||||||
enum: 'DigestEmailSiteSetting'
|
enum: 'DigestEmailSiteSetting'
|
||||||
suppress_digest_email_after_days: 365
|
suppress_digest_email_after_days: 365
|
||||||
|
disable_digest_emails:
|
||||||
|
default: false
|
||||||
|
client: true
|
||||||
email_custom_headers: 'Auto-Submitted: auto-generated'
|
email_custom_headers: 'Auto-Submitted: auto-generated'
|
||||||
email_subject: '[%{site_name}] %{optional_pm}%{optional_cat}%{topic_title}'
|
email_subject: '[%{site_name}] %{optional_pm}%{optional_cat}%{topic_title}'
|
||||||
reply_by_email_enabled: false
|
reply_by_email_enabled: false
|
||||||
|
|
|
@ -89,14 +89,29 @@ describe Jobs::EnqueueDigestEmails do
|
||||||
|
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
|
|
||||||
|
context "digest emails are enabled" do
|
||||||
before do
|
before do
|
||||||
Jobs::EnqueueDigestEmails.any_instance.expects(:target_user_ids).returns([user.id])
|
Jobs::EnqueueDigestEmails.any_instance.expects(:target_user_ids).returns([user.id])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "enqueues the digest email job" do
|
it "enqueues the digest email job" do
|
||||||
|
SiteSetting.stubs(:disable_digest_emails?).returns(false)
|
||||||
Jobs.expects(:enqueue).with(:user_email, type: :digest, user_id: user.id)
|
Jobs.expects(:enqueue).with(:user_email, type: :digest, user_id: user.id)
|
||||||
Jobs::EnqueueDigestEmails.new.execute({})
|
Jobs::EnqueueDigestEmails.new.execute({})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "digest emails are disabled" do
|
||||||
|
before do
|
||||||
|
Jobs::EnqueueDigestEmails.any_instance.expects(:target_user_ids).never
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not enqueue the digest email job" do
|
||||||
|
SiteSetting.stubs(:disable_digest_emails?).returns(true)
|
||||||
|
Jobs.expects(:enqueue).with(:user_email, type: :digest, user_id: user.id).never
|
||||||
|
Jobs::EnqueueDigestEmails.new.execute({})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue