Skip to content

Commit

Permalink
feat: make support channel configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
fleboulch committed Jun 14, 2024
1 parent df38b9b commit cfa3203
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ SLACK_BOT_USER_O_AUTH_ACCESS_TOKEN=SLACK_BOT_USER_O_AUTH_ACCESS_TOKEN
SLACK_SIGNING_SECRET=SLACK_SIGNING_SECRET
EMAIL_DOMAINS=my-domain.com,ext.my-domain.com
GITLAB_URL=https://my-git.domain.com
SLACK_SUPPORT_CHANNEL_ID=C0XXXXXXXXX
SLACK_SUPPORT_CHANNEL_NAME=support-homer
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ Create a `.env` file containing the following variables:

The gitlab URL of your organization

- `SLACK_SUPPORT_CHANNEL_ID`

This slack channel id is displayed when a user enters the help command. People having trouble with homer can be helped on this support channel.

- `SLACK_SUPPORT_CHANNEL_NAME`

This slack channel name is displayed when a user enters the help command. People having trouble with homer can be helped on this support channel.

If you want Homer to connect to an **external PostgreSQL database**, you can set
the following variables:

Expand Down
7 changes: 6 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export const MERGE_REQUEST_OPEN_STATES: GitlabMergeRequestState[] = [
'opened',
'reopened',
];
export const MOES_TAVERN_CHANNEL_ID = 'C01FCCQGP3M';
export const SLACK_SUPPORT_CHANNEL_ID = getEnvVariable(
'SLACK_SUPPORT_CHANNEL_ID'
);
export const SLACK_SUPPORT_CHANNEL_NAME = getEnvVariable(
'SLACK_SUPPORT_CHANNEL_NAME'
);
export const PRIVATE_CHANNEL_ERROR_MESSAGE =
'D’oh! It looks like you tried to use me on a private channel I’m not in. Please invite me using `/invite @homer` so I can publish messages :homer-donut:';
export const REQUEST_BODY_SIZE_LIMIT = '500kb';
Expand Down
9 changes: 6 additions & 3 deletions src/core/viewBuilders/buildHelpMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { ChatPostMessageArguments } from '@slack/web-api';
import { MOES_TAVERN_CHANNEL_ID } from '@/constants';
import {
SLACK_SUPPORT_CHANNEL_ID,
SLACK_SUPPORT_CHANNEL_NAME,
} from '@/constants';

export function buildHelpMessage(channelId: string): ChatPostMessageArguments {
return {
Expand All @@ -13,7 +16,7 @@ Here are the available commands:
- /homer review <search> - Share a merge request on a channel. Searches in title and description by default. Accepts merge request URLs and merge request IDs prefixed with "!".
- /homer review list - List ongoing reviews shared in a channel.
Don't hesitate to join me on #moes-tavern-homer to take a beer!`,
Don't hesitate to join me on ${SLACK_SUPPORT_CHANNEL_NAME} to take a beer!`,
blocks: [
{
type: 'section',
Expand All @@ -28,7 +31,7 @@ Here are the available commands:
• \`/homer review <search>\` Share a merge request on a channel. Searches in title and description by default. Accepts merge request URLs and merge request IDs prefixed with "!".
• \`/homer review list\` List ongoing reviews shared in a channel.
Don't hesitate to join me on <#${MOES_TAVERN_CHANNEL_ID}> to take a :beer:!`,
Don't hesitate to join me on <#${SLACK_SUPPORT_CHANNEL_ID}> to take a :beer:!`,
},
},
],
Expand Down
4 changes: 2 additions & 2 deletions src/home/buildAppHomeView.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { View } from '@slack/web-api';
import { HOMER_GITLAB_URL, MOES_TAVERN_CHANNEL_ID } from '@/constants';
import { HOMER_GITLAB_URL, SLACK_SUPPORT_CHANNEL_ID } from '@/constants';
import type { SlackUser } from '@/core/typings/SlackUser';

export async function buildAppHomeView(user: SlackUser): Promise<View> {
Expand All @@ -15,7 +15,7 @@ export async function buildAppHomeView(user: SlackUser): Promise<View> {
text: `\
Hello *${firstName}*, I'm *Homer*, the :logo-manomano: ManoMano's :gitlab: Gitlab master!
If you want to take a :beer: with me, don't hesitate to join <#${MOES_TAVERN_CHANNEL_ID}>.
If you want to take a :beer: with me, don't hesitate to join <#${SLACK_SUPPORT_CHANNEL_ID}>.
If you want to better know me, here are some useful links:
Expand Down

0 comments on commit cfa3203

Please sign in to comment.