Skip to content

Commit

Permalink
Slack notification improved. (#28)
Browse files Browse the repository at this point in the history
Signed-off-by: viktor-kurchenko <[email protected]>
  • Loading branch information
viktor-kurchenko authored Jun 22, 2023
1 parent f76ef93 commit 8bd125a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type slackProvider struct {
slackChannelIDs map[string]struct{}
channelSlackID map[string]string
emailSlackID map[string]string
nameSlackID map[string]string
realNameSlackID map[string]string
normalRealNameSlackID map[string]string
displayNameSlackID map[string]string
Expand All @@ -41,6 +42,7 @@ func newSlackProvider(token, title, defaultChannel string) *slackProvider {
slackChannelIDs: make(map[string]struct{}),
channelSlackID: make(map[string]string),
emailSlackID: make(map[string]string),
nameSlackID: make(map[string]string),
realNameSlackID: make(map[string]string),
normalRealNameSlackID: make(map[string]string),
displayNameSlackID: make(map[string]string),
Expand All @@ -59,6 +61,9 @@ func (s *slackProvider) readUsers(ctx context.Context) error {
continue
}
s.slackIDs[u.ID] = struct{}{}
if u.Name != "" {
s.nameSlackID[strings.ToLower(u.Name)] = u.ID
}
profile := u.Profile
if profile.Email != "" {
s.emailSlackID[strings.ToLower(profile.Email)] = u.ID
Expand Down Expand Up @@ -144,6 +149,9 @@ func (s *slackProvider) getSlackIDByOwner(owner string) string {
if id, ok := s.normalRealNameSlackID[owner]; ok {
return id
}
if id, ok := s.nameSlackID[owner]; ok {
return id
}
return s.defaultChannel
}

Expand Down

0 comments on commit 8bd125a

Please sign in to comment.