mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: modify notification after remove auto_watch_category (#10568)
When a category is removed from `auto_watch_category` we are removing CategoryUser. However, there are still TopicUser with notification level set to `watching` which was inherited from Category. We should move them back to `regular` unless they were modified by a user.
This commit is contained in:
committed by
GitHub
parent
e824385e64
commit
084e15b447
@@ -20,7 +20,7 @@ class Admin::SiteSettingsController < Admin::AdminController
|
||||
value = Upload.get_from_url(value) || ""
|
||||
end
|
||||
|
||||
update_existing_users = params[:updateExistingUsers].present?
|
||||
update_existing_users = params[:update_existing_user].present?
|
||||
previous_value = SiteSetting.send(id) || "" if update_existing_users
|
||||
|
||||
SiteSetting.set_and_log(id, value, current_user)
|
||||
@@ -58,7 +58,14 @@ class Admin::SiteSettingsController < Admin::AdminController
|
||||
notification_level = NotificationLevels.all[:regular]
|
||||
end
|
||||
|
||||
CategoryUser.where(category_id: (previous_category_ids - new_category_ids), notification_level: notification_level).delete_all
|
||||
categories_to_unwatch = previous_category_ids - new_category_ids
|
||||
CategoryUser.where(category_id: categories_to_unwatch, notification_level: notification_level).delete_all
|
||||
TopicUser
|
||||
.joins(:topic)
|
||||
.where(notification_level: TopicUser.notification_levels[:watching],
|
||||
notifications_reason_id: TopicUser.notification_reasons[:auto_watch_category],
|
||||
topics: { category_id: categories_to_unwatch })
|
||||
.update_all(notification_level: TopicUser.notification_levels[:regular])
|
||||
|
||||
(new_category_ids - previous_category_ids).each do |category_id|
|
||||
skip_user_ids = CategoryUser.where(category_id: category_id).pluck(:user_id)
|
||||
|
||||
Reference in New Issue
Block a user