FIX: Support for group everyone in tag setting (#17669)

The "everyone" group is an automatic group and GroupUser records do not
exist for it. This commit allows all users if the group everyone is one
of the groups in the setting "pm_tags_allowed_for_groups".
This commit is contained in:
Bianca Nenciu
2022-07-27 15:44:41 +03:00
committed by GitHub
parent a00b5a6aca
commit bc476978e8
2 changed files with 21 additions and 1 deletions

View File

@@ -11,8 +11,12 @@ module TagGuardian
end
def can_tag_pms?
return false if !SiteSetting.tagging_enabled
return false if @user.blank?
SiteSetting.tagging_enabled && @user == Discourse.system_user || @user.group_users.exists?(group_id: SiteSetting.pm_tags_allowed_for_groups.to_s.split("|").map(&:to_i))
return true if @user == Discourse.system_user
group_ids = SiteSetting.pm_tags_allowed_for_groups.to_s.split("|").map(&:to_i)
group_ids.include?(Group::AUTO_GROUPS[:everyone]) || @user.group_users.exists?(group_id: group_ids)
end
def can_admin_tags?