mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:57:10 -06:00
FEATURE: like notification frequency of never
This commit is contained in:
parent
a656a672a1
commit
af577a5854
@ -77,7 +77,8 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
||||
|
||||
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'), 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 },
|
||||
{ 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.first_time_and_daily', value: 1 },
|
||||
{ name: 'user.like_notification_frequency.first_time', value: 2 },
|
||||
{ name: 'user.like_notification_frequency.never', value: 3 },
|
||||
]
|
||||
end
|
||||
|
||||
|
@ -10,7 +10,7 @@ class UserOption < ActiveRecord::Base
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
def set_defaults
|
||||
|
@ -221,6 +221,8 @@ class PostAlerter
|
||||
return if user.blank?
|
||||
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 ||= {}
|
||||
|
||||
# Make sure the user can see the post
|
||||
|
@ -634,6 +634,7 @@ en:
|
||||
always: "Always"
|
||||
first_time_and_daily: "First time a post is liked and daily"
|
||||
first_time: "First time a post is liked"
|
||||
never: "Never"
|
||||
email_previous_replies:
|
||||
title: "Include previous replies at the bottom of emails"
|
||||
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)
|
||||
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
|
||||
ActiveRecord::Base.observers.enable :all
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user