FEATURE: More digest email frequency options. Digests can be sent as often as every 30 minutes.
This commit is contained in:
parent
be257225b6
commit
c1aea91d63
|
@ -68,10 +68,12 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
|||
{name: I18n.t('user.email_previous_replies.never'), value: 2}
|
||||
],
|
||||
|
||||
digestFrequencies: [{ name: I18n.t('user.email_digests.daily'), value: 1 },
|
||||
{ name: I18n.t('user.email_digests.every_three_days'), value: 3 },
|
||||
{ name: I18n.t('user.email_digests.weekly'), value: 7 },
|
||||
{ name: I18n.t('user.email_digests.every_two_weeks'), value: 14 }],
|
||||
digestFrequencies: [{ name: I18n.t('user.email_digests.every_30_minutes'), value: 30 },
|
||||
{ name: I18n.t('user.email_digests.every_hour'), value: 60 },
|
||||
{ name: I18n.t('user.email_digests.daily'), value: 1440 },
|
||||
{ name: I18n.t('user.email_digests.every_three_days'), value: 4320 },
|
||||
{ name: I18n.t('user.email_digests.weekly'), value: 10080 },
|
||||
{ name: I18n.t('user.email_digests.every_two_weeks'), value: 20160 }],
|
||||
|
||||
likeNotificationFrequencies: [{ name: I18n.t('user.like_notification_frequency.always'), value: 0 },
|
||||
{ name: I18n.t('user.like_notification_frequency.first_time_and_daily'), value: 1 },
|
||||
|
|
|
@ -165,7 +165,7 @@ const User = RestModel.extend({
|
|||
'enable_quoting',
|
||||
'disable_jump_reply',
|
||||
'automatically_unpin_topics',
|
||||
'digest_after_days',
|
||||
'digest_after_minutes',
|
||||
'new_topic_duration_minutes',
|
||||
'auto_track_topics_after_msecs',
|
||||
'like_notification_frequency'
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
{{preference-checkbox labelKey="user.email_digests.title" checked=model.user_option.email_digests}}
|
||||
{{#if model.user_option.email_digests}}
|
||||
<div class='controls controls-dropdown'>
|
||||
{{combo-box valueAttribute="value" content=digestFrequencies value=model.user_option.digest_after_days}}
|
||||
{{combo-box valueAttribute="value" content=digestFrequencies value=model.user_option.digest_after_minutes}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
|
@ -2,7 +2,7 @@ module Jobs
|
|||
|
||||
# A daily job that will enqueue digest emails to be sent to users
|
||||
class EnqueueDigestEmails < Jobs::Scheduled
|
||||
every 6.hours
|
||||
every 30.minutes
|
||||
|
||||
def execute(args)
|
||||
unless SiteSetting.disable_digest_emails?
|
||||
|
@ -13,14 +13,14 @@ module Jobs
|
|||
end
|
||||
|
||||
def target_user_ids
|
||||
# Users who want to receive emails and haven't been emailed in the last day
|
||||
# Users who want to receive digest email within their chosen digest email frequency
|
||||
query = User.real
|
||||
.where(active: true, staged: false)
|
||||
.joins(:user_option)
|
||||
.not_suspended
|
||||
.where(user_options: {email_digests: true})
|
||||
.where("COALESCE(last_emailed_at, '2010-01-01') <= CURRENT_TIMESTAMP - ('1 DAY'::INTERVAL * user_options.digest_after_days)")
|
||||
.where("COALESCE(last_seen_at, '2010-01-01') <= CURRENT_TIMESTAMP - ('1 DAY'::INTERVAL * user_options.digest_after_days)")
|
||||
.where("COALESCE(last_emailed_at, '2010-01-01') <= CURRENT_TIMESTAMP - ('1 MINUTE'::INTERVAL * user_options.digest_after_minutes)")
|
||||
.where("COALESCE(last_seen_at, '2010-01-01') <= CURRENT_TIMESTAMP - ('1 MINUTE'::INTERVAL * user_options.digest_after_minutes)")
|
||||
.where("COALESCE(last_seen_at, '2010-01-01') >= CURRENT_TIMESTAMP - ('1 DAY'::INTERVAL * #{SiteSetting.delete_digest_email_after_days})")
|
||||
|
||||
# If the site requires approval, make sure the user is approved
|
||||
|
|
|
@ -10,10 +10,12 @@ class DigestEmailSiteSetting < EnumSiteSetting
|
|||
def self.values
|
||||
@values ||= [
|
||||
{ name: 'never', value: 0 },
|
||||
{ name: 'daily', value: 1 },
|
||||
{ name: 'every_three_days', value: 3 },
|
||||
{ name: 'weekly', value: 7 },
|
||||
{ name: 'every_two_weeks', value: 14 }
|
||||
{ name: 'every_30_minutes', value: 30 },
|
||||
{ name: 'every_hour', value: 60 },
|
||||
{ name: 'daily', value: 1440 },
|
||||
{ name: 'every_three_days', value: 4320 },
|
||||
{ name: 'weekly', value: 10080 },
|
||||
{ name: 'every_two_weeks', value: 20160 }
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class UserOption < ActiveRecord::Base
|
|||
self.email_digests = false
|
||||
else
|
||||
self.email_digests = true
|
||||
self.digest_after_days ||= SiteSetting.default_email_digest_frequency.to_i
|
||||
self.digest_after_minutes ||= SiteSetting.default_email_digest_frequency.to_i
|
||||
end
|
||||
|
||||
true
|
||||
|
@ -127,7 +127,7 @@ end
|
|||
# disable_jump_reply :boolean default(FALSE), not null
|
||||
# edit_history_public :boolean default(FALSE), not null
|
||||
# automatically_unpin_topics :boolean default(TRUE), not null
|
||||
# digest_after_days :integer
|
||||
# digest_after_minutes :integer
|
||||
# auto_track_topics_after_msecs :integer
|
||||
# new_topic_duration_minutes :integer
|
||||
# last_redirected_to_top_at :datetime
|
||||
|
|
|
@ -9,7 +9,7 @@ class UserOptionSerializer < ApplicationSerializer
|
|||
:dynamic_favicon,
|
||||
:enable_quoting,
|
||||
:disable_jump_reply,
|
||||
:digest_after_days,
|
||||
:digest_after_minutes,
|
||||
:automatically_unpin_topics,
|
||||
:edit_history_public,
|
||||
:auto_track_topics_after_msecs,
|
||||
|
|
|
@ -18,7 +18,7 @@ class UserUpdater
|
|||
:disable_jump_reply,
|
||||
:edit_history_public,
|
||||
:automatically_unpin_topics,
|
||||
:digest_after_days,
|
||||
:digest_after_minutes,
|
||||
:new_topic_duration_minutes,
|
||||
:auto_track_topics_after_msecs,
|
||||
:email_previous_replies,
|
||||
|
|
|
@ -193,6 +193,8 @@ en:
|
|||
more: "More"
|
||||
less: "Less"
|
||||
never: "never"
|
||||
every_30_minutes: "every 30 minutes"
|
||||
every_hour: "every hour"
|
||||
daily: "daily"
|
||||
weekly: "weekly"
|
||||
every_two_weeks: "every two weeks"
|
||||
|
@ -639,6 +641,8 @@ en:
|
|||
never: "never"
|
||||
email_digests:
|
||||
title: "When I don't visit here, send an email digest of what's new:"
|
||||
every_30_minutes: "every 30 minutes"
|
||||
every_hour: "hourly"
|
||||
daily: "daily"
|
||||
every_three_days: "every three days"
|
||||
weekly: "weekly"
|
||||
|
|
|
@ -1070,7 +1070,7 @@ uncategorized:
|
|||
user_preferences:
|
||||
default_email_digest_frequency:
|
||||
enum: 'DigestEmailSiteSetting'
|
||||
default: 7
|
||||
default: 10080
|
||||
default_email_private_messages: true
|
||||
default_email_direct: true
|
||||
default_email_mailing_list_mode: false
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
class RenameDigestAfterDaysToDigestAfterMinutes < ActiveRecord::Migration
|
||||
def up
|
||||
rename_column :user_options, :digest_after_days, :digest_after_minutes
|
||||
execute "UPDATE user_options SET digest_after_minutes = digest_after_minutes * 1440 WHERE digest_after_minutes IS NOT NULL"
|
||||
execute "UPDATE site_settings SET value = value::integer * 1440 WHERE name = 'default_email_digest_frequency' AND value IS NOT NULL"
|
||||
end
|
||||
|
||||
def down
|
||||
rename_column :user_options, :digest_after_minutes, :digest_after_days
|
||||
execute "UPDATE user_options SET digest_after_days = digest_after_days / 1440 WHERE digest_after_days IS NOT NULL"
|
||||
execute "UPDATE site_settings SET value = value::integer / 1440 WHERE name = 'default_email_digest_frequency' AND value IS NOT NULL"
|
||||
end
|
||||
end
|
|
@ -3,11 +3,11 @@ require 'rails_helper'
|
|||
describe DigestEmailSiteSetting do
|
||||
describe 'valid_value?' do
|
||||
it 'returns true for a valid value as an int' do
|
||||
expect(DigestEmailSiteSetting.valid_value?(1)).to eq true
|
||||
expect(DigestEmailSiteSetting.valid_value?(1440)).to eq true
|
||||
end
|
||||
|
||||
it 'returns true for a valid value as a string' do
|
||||
expect(DigestEmailSiteSetting.valid_value?('1')).to eq true
|
||||
expect(DigestEmailSiteSetting.valid_value?('1440')).to eq true
|
||||
end
|
||||
|
||||
it 'returns false for an invalid value' do
|
||||
|
|
|
@ -1157,7 +1157,7 @@ describe User do
|
|||
context "when user preferences are overriden" do
|
||||
|
||||
before do
|
||||
SiteSetting.default_email_digest_frequency = 1 # daily
|
||||
SiteSetting.default_email_digest_frequency = 1440 # daily
|
||||
SiteSetting.default_email_private_messages = false
|
||||
SiteSetting.default_email_direct = false
|
||||
SiteSetting.default_email_mailing_list_mode = true
|
||||
|
@ -1183,7 +1183,7 @@ describe User do
|
|||
options = user.user_option
|
||||
expect(options.email_always).to eq(true)
|
||||
expect(options.mailing_list_mode).to eq(true)
|
||||
expect(options.digest_after_days).to eq(1)
|
||||
expect(options.digest_after_minutes).to eq(1440)
|
||||
expect(options.email_private_messages).to eq(false)
|
||||
expect(options.external_links_in_new_tab).to eq(true)
|
||||
expect(options.enable_quoting).to eq(false)
|
||||
|
|
|
@ -46,7 +46,7 @@ describe UserUpdater do
|
|||
updater.update(bio_raw: 'my new bio',
|
||||
email_always: 'true',
|
||||
mailing_list_mode: true,
|
||||
digest_after_days: "8",
|
||||
digest_after_minutes: "45",
|
||||
new_topic_duration_minutes: 100,
|
||||
auto_track_topics_after_msecs: 101,
|
||||
email_in_reply_to: false
|
||||
|
@ -56,7 +56,7 @@ describe UserUpdater do
|
|||
expect(user.user_profile.bio_raw).to eq 'my new bio'
|
||||
expect(user.user_option.email_always).to eq true
|
||||
expect(user.user_option.mailing_list_mode).to eq true
|
||||
expect(user.user_option.digest_after_days).to eq 8
|
||||
expect(user.user_option.digest_after_minutes).to eq 45
|
||||
expect(user.user_option.new_topic_duration_minutes).to eq 100
|
||||
expect(user.user_option.auto_track_topics_after_msecs).to eq 101
|
||||
expect(user.user_option.email_in_reply_to).to eq false
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue