FIX: Change notification_level back to tracking only if set by plugin.
This commit is contained in:
parent
8ad7304bdd
commit
7663268584
|
@ -232,12 +232,20 @@ SQL
|
||||||
|
|
||||||
post.publish_change_to_clients!(:revised, reload_topic: true)
|
post.publish_change_to_clients!(:revised, reload_topic: true)
|
||||||
|
|
||||||
|
if TopicUser.exists?(
|
||||||
|
user_id: assigned_to_id,
|
||||||
|
topic: @topic,
|
||||||
|
notification_level: TopicUser.notification_levels[:watching],
|
||||||
|
notifications_reason_id: TopicUser.notification_reasons[:plugin_changed]
|
||||||
|
)
|
||||||
|
|
||||||
TopicUser.change(
|
TopicUser.change(
|
||||||
assigned_to_id,
|
assigned_to_id,
|
||||||
@topic.id,
|
@topic.id,
|
||||||
notification_level: TopicUser.notification_levels[:tracking],
|
notification_level: TopicUser.notification_levels[:tracking],
|
||||||
notifications_reason_id: TopicUser.notification_reasons[:plugin_changed]
|
notifications_reason_id: TopicUser.notification_reasons[:plugin_changed]
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
assigned_user = User.find_by(id: assigned_to_id)
|
assigned_user = User.find_by(id: assigned_to_id)
|
||||||
MessageBus.publish(
|
MessageBus.publish(
|
||||||
|
|
|
@ -49,6 +49,22 @@ RSpec.describe TopicAssigner do
|
||||||
.to eq(TopicUser.notification_levels[:tracking])
|
.to eq(TopicUser.notification_levels[:tracking])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not update notification level if it is not set by the plugin' do
|
||||||
|
assigner.assign(moderator)
|
||||||
|
|
||||||
|
expect(TopicUser.find_by(user: moderator).notification_level)
|
||||||
|
.to eq(TopicUser.notification_levels[:watching])
|
||||||
|
|
||||||
|
TopicUser.change(moderator.id, topic.id,
|
||||||
|
notification_level: TopicUser.notification_levels[:muted]
|
||||||
|
)
|
||||||
|
|
||||||
|
assigner.unassign
|
||||||
|
|
||||||
|
expect(TopicUser.find_by(user: moderator, topic: topic).notification_level)
|
||||||
|
.to eq(TopicUser.notification_levels[:muted])
|
||||||
|
end
|
||||||
|
|
||||||
it "can unassign all a user's topics at once" do
|
it "can unassign all a user's topics at once" do
|
||||||
assigner.assign(moderator)
|
assigner.assign(moderator)
|
||||||
TopicAssigner.unassign_all(moderator, moderator)
|
TopicAssigner.unassign_all(moderator, moderator)
|
||||||
|
|
Loading…
Reference in New Issue