Merge pull request #4828 from cpradio/normal-reply-state
FEATURE: Add normal as a preference for topic subscription state when replying to a topic
This commit is contained in:
commit
6d6e208037
|
@ -124,7 +124,8 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
||||||
{ name: I18n.t('user.auto_track_options.after_10_minutes'), value: 600000 }],
|
{ name: I18n.t('user.auto_track_options.after_10_minutes'), value: 600000 }],
|
||||||
|
|
||||||
notificationLevelsForReplying: [{ name: I18n.t('topic.notifications.watching.title'), value: NotificationLevels.WATCHING },
|
notificationLevelsForReplying: [{ name: I18n.t('topic.notifications.watching.title'), value: NotificationLevels.WATCHING },
|
||||||
{ name: I18n.t('topic.notifications.tracking.title'), value: NotificationLevels.TRACKING }],
|
{ name: I18n.t('topic.notifications.tracking.title'), value: NotificationLevels.TRACKING },
|
||||||
|
{ name: I18n.t('topic.notifications.regular.title'), value: NotificationLevels.REGULAR }],
|
||||||
|
|
||||||
|
|
||||||
considerNewTopicOptions: [{ name: I18n.t('user.new_topic_duration.not_viewed'), value: -1 },
|
considerNewTopicOptions: [{ name: I18n.t('user.new_topic_duration.not_viewed'), value: -1 },
|
||||||
|
|
|
@ -15,7 +15,8 @@ class NotificationLevelWhenReplyingSiteSetting < EnumSiteSetting
|
||||||
def self.values
|
def self.values
|
||||||
@values ||= [
|
@values ||= [
|
||||||
{ name: 'topic.notifications.watching.title', value: notification_levels[:watching] },
|
{ name: 'topic.notifications.watching.title', value: notification_levels[:watching] },
|
||||||
{ name: 'topic.notifications.tracking.title', value: notification_levels[:tracking] }
|
{ name: 'topic.notifications.tracking.title', value: notification_levels[:tracking] },
|
||||||
|
{ name: 'topic.notifications.regular.title', value: notification_levels[:regular] }
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -494,6 +494,8 @@ class PostCreator
|
||||||
TopicUser.auto_notification_for_staging(@user.id, @topic.id, TopicUser.notification_reasons[:auto_watch])
|
TopicUser.auto_notification_for_staging(@user.id, @topic.id, TopicUser.notification_reasons[:auto_watch])
|
||||||
elsif @user.user_option.notification_level_when_replying === NotificationLevels.topic_levels[:watching]
|
elsif @user.user_option.notification_level_when_replying === NotificationLevels.topic_levels[:watching]
|
||||||
TopicUser.auto_notification(@user.id, @topic.id, TopicUser.notification_reasons[:created_post], NotificationLevels.topic_levels[:watching])
|
TopicUser.auto_notification(@user.id, @topic.id, TopicUser.notification_reasons[:created_post], NotificationLevels.topic_levels[:watching])
|
||||||
|
elsif @user.user_option.notification_level_when_replying === NotificationLevels.topic_levels[:regular]
|
||||||
|
TopicUser.auto_notification(@user.id, @topic.id, TopicUser.notification_reasons[:created_post], NotificationLevels.topic_levels[:regular])
|
||||||
else
|
else
|
||||||
TopicUser.auto_notification(@user.id, @topic.id, TopicUser.notification_reasons[:created_post], NotificationLevels.topic_levels[:tracking])
|
TopicUser.auto_notification(@user.id, @topic.id, TopicUser.notification_reasons[:created_post], NotificationLevels.topic_levels[:tracking])
|
||||||
end
|
end
|
||||||
|
|
|
@ -899,6 +899,23 @@ describe PostCreator do
|
||||||
topic_user = TopicUser.find_by(user_id: user.id, topic_id: post.topic_id)
|
topic_user = TopicUser.find_by(user_id: user.id, topic_id: post.topic_id)
|
||||||
expect(topic_user.notification_level).to eq(TopicUser.notification_levels[:tracking])
|
expect(topic_user.notification_level).to eq(TopicUser.notification_levels[:tracking])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "topic notification level is normal based on preference" do
|
||||||
|
user.user_option.notification_level_when_replying = 1
|
||||||
|
|
||||||
|
admin = Fabricate(:admin)
|
||||||
|
topic = PostCreator.create(admin,
|
||||||
|
title: "this is the title of a topic created by an admin for tracking notification",
|
||||||
|
raw: "this is the content of a topic created by an admin for keeping a tracking notification state on a topic ;)"
|
||||||
|
)
|
||||||
|
|
||||||
|
post = PostCreator.create(user,
|
||||||
|
topic_id: topic.topic_id,
|
||||||
|
raw: "this is a reply to set the tracking state to normal ;)"
|
||||||
|
)
|
||||||
|
topic_user = TopicUser.find_by(user_id: user.id, topic_id: post.topic_id)
|
||||||
|
expect(topic_user.notification_level).to eq(TopicUser.notification_levels[:regular])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create!' do
|
describe '#create!' do
|
||||||
|
|
Loading…
Reference in New Issue