Discourse AI respecteert de groep "iedereen" niet

It looks like this is the same known issue that causes problems with templates.
everyone-group-unable-to-see-private-templates

In this case, the ai-bot options appear, but the bot simply never responds.

2 likes

Thanks for searching for prior issues! :sunglasses: :+1:

I think the same applies here:

You can not give anonymous users access to the chat bot, so using trust_level_0 is an effective solution for your use case. :slight_smile:

8 likes

@Roman reading through the code in Discourse I think this works now.

Is it time to close this off and remove the backwards compat code?

Het is een beetje lastig. Ik heb oorspronkelijk de everyone-optie toegevoegd omdat we anonieme gebruikers gists wilden laten zien. Elke functie heeft zijn eigen regels, dus ik denk niet dat het instellen van de toegestane groepen van een Persona daarop de functie voor iedereen beschikbaar zal maken.

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
5 likes