Skip to content

Commit

Permalink
Remove users from cache when removing them from group
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-brindley committed Dec 11, 2023
1 parent 498d7f5 commit be8be82
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion adapters/slack/usergroup/usergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,18 @@ func (u *UserGroup) Remove(ctx context.Context, emails []string) error {
}

// Iterate over the cached map of emails to Slack IDs, and only include those that aren't in the removal map.
updatedUserGroup := make([]string, 0, len(u.cache)-len(emails))
cpcty := len(u.cache) - len(emails)
if cpcty < 0 {
cpcty = 0
}
updatedUserGroup := make([]string, 0, cpcty)

for email, slackID := range u.cache {
// Only include the Slack ID if it's not in the map of emails to remove.
if !mapOfEmailsToRemove[email] {
updatedUserGroup = append(updatedUserGroup, slackID)
} else {
delete(u.cache, email)
}
}

Expand Down

0 comments on commit be8be82

Please sign in to comment.