Skip to content

Commit

Permalink
Check email before checking name (#13)
Browse files Browse the repository at this point in the history
* Check email before checking name

---------

Co-authored-by: Timo Reimann <[email protected]>
  • Loading branch information
zbarahal-do and timoreimann authored Jan 19, 2024
1 parent 40583e9 commit ad424a6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ import (
type slackUsers []slackUser

func (users slackUsers) findByPDUser(pdUser pagerduty.User) *slackUser {
// check email match first since it's a distinctive identifier
for _, slackUser := range users {
if slackUser.email == pdUser.Email ||
slackUser.realName == strings.ToLower(pdUser.Name) ||
if slackUser.email == pdUser.Email {
return &slackUser
}
}

// if we couldn't find an email match, use name. this is the second choice as name is not unique in an organization
for _, slackUser := range users {
if slackUser.realName == strings.ToLower(pdUser.Name) ||
slackUser.name == strings.ToLower(pdUser.Name) {
return &slackUser
}
Expand Down

0 comments on commit ad424a6

Please sign in to comment.