Suppressed category included in digest

We have an “Inappropriate” category where mods can move flagged posts, so they can still be discussed even they are not suitable for our public forum. We obviously don’t want that category included in the summary emails and it was suppressed in site settings:

Screenshot from 2021-09-12 07-39-34

However, a topic from the category was included in our recent summary. I un-selected and re-selected it in Settings and saw there was a change in the log:

14 is the id of Inappropriate. The Previous category 2 (probably “Site Feedback”) had been deleted quite some time ago, but apparently was still included in the list of suppressed categories. Could that be a bug that prevented the list from working as expected?


Just checked the summary preview and the category is actually still included.

In fact, suppressing doesn’t work for any category I’d choose.

Yes, I just tested this on my local dev site and am finding the same thing. I think the issue is with the logic that’s used here:

Changing that line to topics = topics.where("topics.category_id NOT IN (?)", remove_category_ids) seems to fix the issue with categories that have been added to the digest_suppress_categories setting, but some logic for handling muted categories will need to be added. Maybe something like:

topics = topics.where("topics.category_id NOT IN (?)",  remove_category_ids).where("topic_users.notification_level != (?)", TopicUser.notification_levels[:muted])

I think the problem is the target user has already visited that topic and a “TopicUser” model record is created for that user. So that topic passes the above condition where we check whether it’s unmuted or not. In that case, the below PR should fix this issue.