Skip to content

Commit

Permalink
We only want memberids here, so don't call members needlessly
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbASF committed Oct 6, 2024
1 parent f12e856 commit dde24c5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/whimsy/asf/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1172,8 +1172,9 @@ def dn

# remove people from an existing group in LDAP
def remove(people)
# Removal fails if the id is not present
@members = nil # force fresh LDAP search
people = (Array(people) & members).map(&:id)
people = Array(people).map(&:id) & memberids
return if people.empty?
ASF::LDAP.modify(self.dn, [ASF::Base.mod_delete('memberUid', people)])
ensure
Expand All @@ -1182,8 +1183,9 @@ def remove(people)

# add people to an existing group in LDAP
def add(people)
# addition fails if the id is present
@members = nil # force fresh LDAP search
people = (Array(people) - members).map(&:id)
people = Array(people).map(&:id) - memberids
return if people.empty?
ASF::LDAP.modify(self.dn, [ASF::Base.mod_add('memberUid', people)])
ensure
Expand Down Expand Up @@ -1328,6 +1330,7 @@ def remove(people)

# remove people as owners of a project in LDAP
def remove_owners(people)
# Removal fails if the id is not present
@owners = nil # force fresh LDAP search
removals = (Array(people) & owners).map(&:dn)
unless removals.empty?
Expand All @@ -1339,6 +1342,7 @@ def remove_owners(people)

# remove people as members of a project in LDAP
def remove_members(people)
# Removal fails if the id is not present
@members = nil # force fresh LDAP search
removals = (Array(people) & members).map(&:dn)
unless removals.empty?
Expand All @@ -1356,6 +1360,7 @@ def add(people)

# add people as owners of a project in LDAP
def add_owners(people)
# Addition fails if the id is present
@owners = nil # force fresh LDAP search
additions = (Array(people) - owners).map(&:dn)
unless additions.empty?
Expand All @@ -1367,6 +1372,7 @@ def add_owners(people)

# add people as members of a project in LDAP
def add_members(people)
# Addition fails if the id is present
@members = nil # force fresh LDAP search
additions = (Array(people) - members).map(&:dn)
unless additions.empty?
Expand Down

0 comments on commit dde24c5

Please sign in to comment.