Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
KishanBagaria committed Feb 5, 2025
1 parent 6e96f83 commit 658f517
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ type config struct {
// External URI to /api
APIPrefix string `yaml:"api_prefix"`

LinearToken string `yaml:"linear_token"`
LinearToken string `yaml:"linear_token"`
LinearTokenOverride map[string]string `yaml:"linear_token_override"`

APIServerURLs map[string]string `yaml:"api_server_url"`

Expand Down
14 changes: 11 additions & 3 deletions submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,15 @@ func (s *submitServer) submitLinearIssue(ctx context.Context, p parsedPayload, l
Str("action", "submit_linear_issue").
Logger()

if len(s.cfg.LinearToken) == 0 {
// Get the appropriate Linear token - check override first, then fall back to default
linearToken := s.cfg.LinearToken
if p.VerifiedUserID != "" {
if overrideToken, ok := s.cfg.LinearTokenOverride[p.VerifiedUserID]; ok {
linearToken = overrideToken
}
}

if len(linearToken) == 0 {
return nil
}

Expand All @@ -776,7 +784,7 @@ func (s *submitServer) submitLinearIssue(ctx context.Context, p parsedPayload, l
email = p.IMAWhoami.Email
}
if email != "" {
if linearID := getLinearID(ctx, email, s.cfg.LinearToken); linearID != "" {
if linearID := getLinearID(ctx, email, linearToken); linearID != "" {
subscriberIDs = []string{linearID}
}
}
Expand Down Expand Up @@ -839,7 +847,7 @@ func (s *submitServer) submitLinearIssue(ctx context.Context, p parsedPayload, l
for backoff <= 32 {
var createResp CreateIssueResponse
err := LinearRequest(ctx, &GraphQLRequest{
Token: s.cfg.LinearToken,
Token: linearToken,
Query: mutationCreateIssue,
Variables: map[string]interface{}{
"input": map[string]interface{}{
Expand Down

0 comments on commit 658f517

Please sign in to comment.