Skip to content

Commit

Permalink
Don't add to 'all' team unless actually necessary
Browse files Browse the repository at this point in the history
This rewrite does better at avoiding the awful race-condition where we
might add someone to the 'all' team immediately after they've been
removed from the Org. We check org-membership /after/ we've established
they're not in the 'all' team, and then add the user immediately, only if
they /are/ a member of the Org.

Note that membership of the 'all' team implies membership of the Org, so
no need to do the `user.isMemberOf(org)` call if the user is already a
member of the team.

hub4j/github-api#75
  • Loading branch information
rtyley committed Mar 12, 2014
1 parent 1abd9aa commit 086b342
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/lib/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ object Implicits {
lazy val allTeam = org.getTeams()("all")

def testMembership(user: GHUser): Boolean = {
val isMemberOfOrg = user.isMemberOf(org)
if (isMemberOfOrg) { allTeam.add(user) }
isMemberOfOrg
if (user.isMemberOf(allTeam)) true else {
val orgMember = user.isMemberOf(org)
if (orgMember) { allTeam.add(user) }
orgMember
}
}
}

Expand Down

0 comments on commit 086b342

Please sign in to comment.