Skip to content

Commit

Permalink
fixup! fix: make emails configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
fleboulch committed May 27, 2024
1 parent a97e47b commit 88765f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ POSTGRES_PORT=54320
POSTGRES_USER=root
SLACK_BOT_USER_O_AUTH_ACCESS_TOKEN=SLACK_BOT_USER_O_AUTH_ACCESS_TOKEN
SLACK_SIGNING_SECRET=SLACK_SIGNING_SECRET
EMAIL_PATTERNS=@manomano.com,@prt.manomano.com
EMAIL_DOMAINS=my-domain.com,ext.my-domain.com
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ Create a `.env` file containing the following variables:

![OAuth token](docs/assets/slack/oauth-token.png)

- `EMAIL_PATTERNS`
Email patterns of your organization (separated by comma),
for instance `@my.org,@contractors.my.org`.
- `EMAIL_DOMAINS`
Email domains of your organization (separated by comma),
for instance `my-domain.com,ext.my-domain.com`.
Used to find Slack users from Gitlab username.
Note that this means your org has to use the same naming scheme for emails and gitlab username.

Expand Down
6 changes: 3 additions & 3 deletions src/core/services/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { logger } from './logger';
const SLACK_BOT_USER_O_AUTH_ACCESS_TOKEN = getEnvVariable(
'SLACK_BOT_USER_O_AUTH_ACCESS_TOKEN'
);
const EMAIL_PATTERNS = getEnvVariable('EMAIL_PATTERNS');
const EMAIL_DOMAINS = getEnvVariable('EMAIL_DOMAINS');

// This client should be used for everything else.
export const slackBotWebClient = new WebClient(
Expand Down Expand Up @@ -95,8 +95,8 @@ export async function fetchSlackUserFromGitlabUser({
export async function fetchSlackUserFromGitlabUsername(
username: string
): Promise<SlackUser | undefined> {
const emails = EMAIL_PATTERNS.split(',').map(
(emailPattern) => `${username}${emailPattern}`
const emails = EMAIL_DOMAINS.split(',').map(
(emailDomain) => `${username}@${emailDomain}`
);
return fetchSlackUserFromEmails(emails);
}
Expand Down

0 comments on commit 88765f7

Please sign in to comment.