FEATURE: like notification frequency of never
This commit is contained in:
parent
a656a672a1
commit
af577a5854
6 changed files with 21 additions and 2 deletions
app
assets/javascripts/discourse/controllers
models
services
config/locales
spec/services
|
@ -77,7 +77,8 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
||||||
|
|
||||||
likeNotificationFrequencies: [{ name: I18n.t('user.like_notification_frequency.always'), value: 0 },
|
likeNotificationFrequencies: [{ name: I18n.t('user.like_notification_frequency.always'), value: 0 },
|
||||||
{ name: I18n.t('user.like_notification_frequency.first_time_and_daily'), value: 1 },
|
{ name: I18n.t('user.like_notification_frequency.first_time_and_daily'), value: 1 },
|
||||||
{ name: I18n.t('user.like_notification_frequency.first_time'), value: 2 }],
|
{ name: I18n.t('user.like_notification_frequency.first_time'), value: 2 },
|
||||||
|
{ name: I18n.t('user.like_notification_frequency.never'), value: 3 }],
|
||||||
|
|
||||||
autoTrackDurations: [{ name: I18n.t('user.auto_track_options.never'), value: -1 },
|
autoTrackDurations: [{ name: I18n.t('user.auto_track_options.never'), value: -1 },
|
||||||
{ name: I18n.t('user.auto_track_options.immediately'), value: 0 },
|
{ name: I18n.t('user.auto_track_options.immediately'), value: 0 },
|
||||||
|
|
|
@ -12,6 +12,7 @@ class LikeNotificationFrequencySiteSetting < EnumSiteSetting
|
||||||
{ name: 'user.like_notification_frequency.always', value: 0 },
|
{ name: 'user.like_notification_frequency.always', value: 0 },
|
||||||
{ name: 'user.like_notification_frequency.first_time_and_daily', value: 1 },
|
{ name: 'user.like_notification_frequency.first_time_and_daily', value: 1 },
|
||||||
{ name: 'user.like_notification_frequency.first_time', value: 2 },
|
{ name: 'user.like_notification_frequency.first_time', value: 2 },
|
||||||
|
{ name: 'user.like_notification_frequency.never', value: 3 },
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class UserOption < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.like_notification_frequency_type
|
def self.like_notification_frequency_type
|
||||||
@like_notification_frequency_type ||= Enum.new(always: 0, first_time_and_daily: 1, first_time: 2)
|
@like_notification_frequency_type ||= Enum.new(always: 0, first_time_and_daily: 1, first_time: 2, never: 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_defaults
|
def set_defaults
|
||||||
|
|
|
@ -221,6 +221,8 @@ class PostAlerter
|
||||||
return if user.blank?
|
return if user.blank?
|
||||||
return if user.id == Discourse::SYSTEM_USER_ID
|
return if user.id == Discourse::SYSTEM_USER_ID
|
||||||
|
|
||||||
|
return if type == Notification.types[:liked] && user.user_option.like_notification_frequency == UserOption.like_notification_frequency_type[:never]
|
||||||
|
|
||||||
opts ||= {}
|
opts ||= {}
|
||||||
|
|
||||||
# Make sure the user can see the post
|
# Make sure the user can see the post
|
||||||
|
|
|
@ -634,6 +634,7 @@ en:
|
||||||
always: "Always"
|
always: "Always"
|
||||||
first_time_and_daily: "First time a post is liked and daily"
|
first_time_and_daily: "First time a post is liked and daily"
|
||||||
first_time: "First time a post is liked"
|
first_time: "First time a post is liked"
|
||||||
|
never: "Never"
|
||||||
email_previous_replies:
|
email_previous_replies:
|
||||||
title: "Include previous replies at the bottom of emails"
|
title: "Include previous replies at the bottom of emails"
|
||||||
unless_emailed: "unless previously sent"
|
unless_emailed: "unless previously sent"
|
||||||
|
|
|
@ -63,6 +63,20 @@ describe PostAlerter do
|
||||||
expect(Notification.count(post_number: 1, topic_id: post.topic_id)).to eq(1)
|
expect(Notification.count(post_number: 1, topic_id: post.topic_id)).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'notifies on does not notify when never is selected' do
|
||||||
|
ActiveRecord::Base.observers.enable :all
|
||||||
|
|
||||||
|
post = Fabricate(:post, raw: 'I love waffles')
|
||||||
|
|
||||||
|
post.user.user_option.update_columns(like_notification_frequency:
|
||||||
|
UserOption.like_notification_frequency_type[:never])
|
||||||
|
|
||||||
|
PostAction.act(evil_trout, post, PostActionType.types[:like])
|
||||||
|
|
||||||
|
|
||||||
|
expect(Notification.count(post_number: 1, topic_id: post.topic_id)).to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
it 'notifies on likes correctly' do
|
it 'notifies on likes correctly' do
|
||||||
ActiveRecord::Base.observers.enable :all
|
ActiveRecord::Base.observers.enable :all
|
||||||
|
|
||||||
|
|
Reference in a new issue