DEV: Do not use hard-coded everyone group id (#15679)

Follow up to: 12f041de5d

Probably best to lookup the "everyone" group_id instead of hard-coding
it to `0`. Also now its more clear what this `0` means.
This commit is contained in:
Blake Erickson 2022-01-21 15:56:45 -07:00 committed by GitHub
parent 78852e9754
commit 4bf6789bd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -11,10 +11,11 @@ class TagUser < ActiveRecord::Base
.joins("LEFT OUTER JOIN tag_group_permissions ON tag_group_memberships.tag_group_id = tag_group_permissions.tag_group_id")
.joins("LEFT OUTER JOIN group_users on group_users.user_id = tag_users.user_id")
.where("(tag_group_permissions.group_id IS NULL
OR tag_group_permissions.group_id IN (0, group_users.group_id)
OR tag_group_permissions.group_id IN (:everyone_group_id, group_users.group_id)
OR group_users.group_id = :staff_group_id)
AND tag_users.notification_level IN (:notification_levels)",
staff_group_id: Group::AUTO_GROUPS[:staff],
everyone_group_id: Group::AUTO_GROUPS[:everyone],
notification_levels: notification_levels)
}