FEATURE: allow user to override watched_precedence_over_muted setting (#22340)

Recently, site setting watched_precedence_over_muted was introduced - https://github.com/discourse/discourse/pull/22252

In this PR, we are allowing users to override it. The option is only displayed when the user has watched categories and muted tags, or vice versa.
This commit is contained in:
Krzysztof Kotlarek
2023-07-04 15:08:29 +10:00
committed by GitHub
parent 82d6420e31
commit 134dcdd63a
14 changed files with 107 additions and 28 deletions

View File

@@ -200,9 +200,7 @@ class PostAlerter
DiscourseEvent.trigger(:post_alerter_before_post, post, new_record, notified)
if !SiteSetting.watched_precedence_over_muted
notified = notified + category_or_tag_muters(post.topic)
end
notified = notified + category_or_tag_muters(post.topic)
if new_record
if post.topic.private_message?
@@ -275,7 +273,12 @@ class PostAlerter
UNION
SELECT user_id FROM tag_users tu JOIN topic_tags tt ON tt.tag_id = tu.tag_id AND tt.topic_id = #{topic.id} AND tu.notification_level = #{TagUser.notification_levels[:muted]}
SQL
User.where("id IN (#{user_ids_sql})")
User
.where("id IN (#{user_ids_sql})")
.joins("LEFT JOIN user_options ON user_options.user_id = users.id")
.where(
"user_options.watched_precedence_over_muted IS false OR (user_options.watched_precedence_over_muted IS NULL AND #{!SiteSetting.watched_precedence_over_muted})",
)
end
def notify_first_post_watchers(post, user_ids, notified = nil)

View File

@@ -51,6 +51,7 @@ class UserUpdater
bookmark_auto_delete_preference
sidebar_link_to_filtered_list
sidebar_show_count_of_new_items
watched_precedence_over_muted
]
NOTIFICATION_SCHEDULE_ATTRS = -> do