将该行改为 topics = topics.where("topics.category_id NOT IN (?)", remove_category_ids) 似乎解决了已添加到 digest_suppress_categories 设置中的分类的问题,但还需要添加一些处理静音分类的逻辑。也许可以这样:
topics = topics.where("topics.category_id NOT IN (?)", remove_category_ids).where("topic_users.notification_level != (?)", TopicUser.notification_levels[:muted])