mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 12:11:16 -05:00
stop adding users to a group if they are already in the group
This commit is contained in:
parent
e82f892c2d
commit
f743bc6e74
1 changed files with 3 additions and 1 deletions
|
@ -13,7 +13,9 @@ module Jobs
|
|||
|
||||
domains = group.automatic_membership_email_domains.gsub('.', '\.')
|
||||
|
||||
User.where("email ~* '@(#{domains})$'").find_each do |user|
|
||||
User.where("email ~* '@(#{domains})$' and users.id not in (
|
||||
select user_id from group_users where group_users.group_id = ?
|
||||
)", group_id).find_each do |user|
|
||||
begin
|
||||
group.add(user)
|
||||
rescue ActiveRecord::RecordNotUnique, PG::UniqueViolation
|
||||
|
|
Loading…
Reference in a new issue