Discourse AI does not respect the "everyone" group

This is still an issue. If “AI bot allowed groups” is set to everyone, the bot does not respond.

I think the bug is here

return false if (SiteSetting.ai_bot_allowed_groups_map & post.user.group_ids).blank?

If the setting is everyone then this returns false, since 0 is not in post.user.group_ids

The correct pattern is !user.in_any_groups?(SiteSetting.ai_bot_allowed_groups_map)

which has a special case for everyone:

  def in_any_groups?(group_ids)
    group_ids.include?(Group::AUTO_GROUPS[:everyone]) ||
      (is_system_user? && (Group.auto_groups_between(:admins, :trust_level_4) & group_ids).any?) ||
      (group_ids & belonging_to_group_ids).any?
  end
4 Likes