Documentation
¶
Overview ¶
Package usermapping provides GitHub-to-Slack user mapping functionality.
Index ¶
- type GitHubEmailLookup
- type ReverseMapping
- type ReverseService
- type Service
- func (s *Service) CacheStats() (total int, expired int)
- func (s *Service) ClearCache()
- func (s *Service) FormatUserMention(ctx context.Context, githubUsername, organization, domain string) string
- func (s *Service) FormatUserMentions(ctx context.Context, githubUsernames []string, organization, domain string) string
- func (s *Service) SetGitHubLookup(lookup GitHubEmailLookup)
- func (s *Service) SetSlackClient(client SlackAPI)
- func (s *Service) SlackHandle(ctx context.Context, githubUsername, organization, domain string) (string, error)
- func (s *Service) SlackHandles(ctx context.Context, githubUsernames []string, organization, domain string) (map[string]string, error)
- type SlackAPI
- type UserMapping
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GitHubEmailLookup ¶
type GitHubEmailLookup interface {
Lookup(ctx context.Context, username, organization string) (*ghmailto.Result, error)
Guess(ctx context.Context, username, organization string, opts ghmailto.GuessOptions) (*ghmailto.GuessResult, error)
}
GitHubEmailLookup defines the interface for GitHub email lookup operations.
type ReverseMapping ¶
type ReverseMapping struct {
CachedAt time.Time
SlackUserID string
SlackUsername string
SlackEmail string
GitHubUsername string
MatchMethod string // "email_lookup", "guess", "config_override"
Confidence int // Match confidence (0-100)
}
ReverseMapping represents a Slack-to-GitHub user mapping.
type ReverseService ¶
type ReverseService struct {
// contains filtered or unexported fields
}
ReverseService handles Slack-to-GitHub user mapping (reverse of the main Service).
func NewReverseService ¶
func NewReverseService(_ *slack.Client, githubToken string) *ReverseService
NewReverseService creates a new reverse mapping service (Slack → GitHub).
func (*ReverseService) CacheStats ¶
func (s *ReverseService) CacheStats() (total int, expired int)
CacheStats returns cache statistics for reverse mappings.
func (*ReverseService) ClearCache ¶
func (s *ReverseService) ClearCache()
ClearCache clears the reverse mapping cache.
func (*ReverseService) LookupGitHub ¶
func (s *ReverseService) LookupGitHub(ctx context.Context, slackClient SlackAPI, slackUserID, organization, domain string) (*ReverseMapping, error)
LookupGitHub attempts to find a GitHub username for a Slack user ID. It uses email matching via gh-mailto to find the best GitHub username match.
func (*ReverseService) SetOverrides ¶
func (s *ReverseService) SetOverrides(overrides map[string]string)
SetOverrides updates the manual user mapping overrides from config. Format: githubUsername -> email.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles GitHub-to-Slack user mapping.
func NewForTesting ¶
func NewForTesting(slackClient SlackAPI, githubLookup GitHubEmailLookup) *Service
NewForTesting creates a new Service with injectable dependencies for testing.
func (*Service) CacheStats ¶
CacheStats returns cache statistics.
func (*Service) ClearCache ¶
func (s *Service) ClearCache()
ClearCache clears the user mapping cache.
func (*Service) FormatUserMention ¶
func (s *Service) FormatUserMention(ctx context.Context, githubUsername, organization, domain string) string
FormatUserMention formats a GitHub username as a Slack mention if mapping exists. Falls back to @githubUsername if no Slack mapping is found.
func (*Service) FormatUserMentions ¶
func (s *Service) FormatUserMentions(ctx context.Context, githubUsernames []string, organization, domain string) string
FormatUserMentions formats multiple GitHub usernames as Slack mentions. Returns formatted string like "@slackUser1, @slackUser2" or falls back to GitHub usernames.
func (*Service) SetGitHubLookup ¶
func (s *Service) SetGitHubLookup(lookup GitHubEmailLookup)
SetGitHubLookup sets the GitHub email lookup service for testing. This is only exported for integration tests.
func (*Service) SetSlackClient ¶
SetSlackClient sets the Slack client for testing. This is only exported for integration tests.
func (*Service) SlackHandle ¶
func (s *Service) SlackHandle(ctx context.Context, githubUsername, organization, domain string) (string, error)
SlackHandle attempts to find a Slack user ID for a GitHub username. It uses email matching to find the best Slack user match and returns the Slack user ID (e.g., "U1234567890").
func (*Service) SlackHandles ¶
func (s *Service) SlackHandles(ctx context.Context, githubUsernames []string, organization, domain string) (map[string]string, error)
SlackHandles performs batch lookup of multiple GitHub users to Slack user IDs. Returns a map of GitHub username to Slack user ID (empty string if not found).