env vars and oauth scopes

This commit is contained in:
dal 2025-07-07 11:03:40 -06:00
parent 2e4791158b
commit 32073d8c03
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
5 changed files with 14 additions and 4 deletions

View File

@ -41,11 +41,16 @@ export class SlackOAuthService {
clientSecret: this.env.SLACK_CLIENT_SECRET, clientSecret: this.env.SLACK_CLIENT_SECRET,
redirectUri: this.env.SLACK_REDIRECT_URI, redirectUri: this.env.SLACK_REDIRECT_URI,
scopes: [ scopes: [
'channels:history',
'channels:join',
'channels:manage',
'channels:read', 'channels:read',
'chat:write', 'chat:write',
'chat:write.public', 'chat:write.public',
'commands',
'channels:join', 'channels:join',
'users:read', 'users:read',
'users:read.email',
], ],
}, },
tokenStorage, tokenStorage,

View File

@ -1,4 +1,5 @@
DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:54322/postgres DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:54322/postgres
BRAINTRUST_KEY="" BRAINTRUST_KEY=""
TRIGGER_SECRET_KEY="" TRIGGER_SECRET_KEY=""
ENVIRONMENT="development" ENVIRONMENT="development"
BUSTER_URL="http://localhost:3000"

View File

@ -6,6 +6,7 @@ declare global {
TRIGGER_SECRET_KEY: string; TRIGGER_SECRET_KEY: string;
ENVIRONMENT: string; ENVIRONMENT: string;
NODE_ENV?: 'development' | 'production' | 'test'; NODE_ENV?: 'development' | 'production' | 'test';
BUSTER_URL: string;
} }
} }
} }

View File

@ -4,6 +4,7 @@ import { logger } from '@trigger.dev/sdk/v3';
export interface SlackNotificationParams { export interface SlackNotificationParams {
organizationId: string; organizationId: string;
userName: string | null; userName: string | null;
chatId: string;
summaryTitle?: string | undefined; summaryTitle?: string | undefined;
summaryMessage?: string | undefined; summaryMessage?: string | undefined;
formattedMessage?: string | null | undefined; formattedMessage?: string | null | undefined;
@ -153,6 +154,7 @@ function shouldSendSlackNotification(params: SlackNotificationParams): boolean {
*/ */
function formatSlackMessage(params: SlackNotificationParams): SlackMessage { function formatSlackMessage(params: SlackNotificationParams): SlackMessage {
const userName = params.userName || 'Unknown User'; const userName = params.userName || 'Unknown User';
const chatUrl = `${process.env.BUSTER_URL}/app/chats/${params.chatId}`;
// Case 1: Formatted message from workflow (highest priority) // Case 1: Formatted message from workflow (highest priority)
if (params.formattedMessage) { if (params.formattedMessage) {
@ -162,7 +164,7 @@ function formatSlackMessage(params: SlackNotificationParams): SlackMessage {
type: 'section', type: 'section',
text: { text: {
type: 'mrkdwn', type: 'mrkdwn',
text: `Buster flagged a chat for review:\n*<fakeLink.toEmployeeProfile.com|${userName}>*`, text: `Buster flagged a chat for review:\n*<${chatUrl}|${userName}>*`,
}, },
}, },
{ {
@ -185,7 +187,7 @@ function formatSlackMessage(params: SlackNotificationParams): SlackMessage {
type: 'section', type: 'section',
text: { text: {
type: 'mrkdwn', type: 'mrkdwn',
text: `Buster flagged a chat for review:\n*<fakeLink.toEmployeeProfile.com|${userName} - ${params.summaryTitle}>*`, text: `Buster flagged a chat for review:\n*<${chatUrl}|${userName} - ${params.summaryTitle}>*`,
}, },
}, },
{ {
@ -208,7 +210,7 @@ function formatSlackMessage(params: SlackNotificationParams): SlackMessage {
type: 'section', type: 'section',
text: { text: {
type: 'mrkdwn', type: 'mrkdwn',
text: `Buster flagged a chat for review:\n*<fakeLink.toEmployeeProfile.com|${userName} - Flagged Chat>*`, text: `Buster flagged a chat for review:\n*<${chatUrl}|${userName} - Flagged Chat>*`,
}, },
}, },
{ {

View File

@ -272,6 +272,7 @@ export const messagePostProcessingTask: ReturnType<
const slackResult = await sendSlackNotification({ const slackResult = await sendSlackNotification({
organizationId: messageContext.organizationId, organizationId: messageContext.organizationId,
userName: messageContext.userName, userName: messageContext.userName,
chatId: messageContext.chatId,
summaryTitle: dbData.summaryTitle, summaryTitle: dbData.summaryTitle,
summaryMessage: dbData.summaryMessage, summaryMessage: dbData.summaryMessage,
formattedMessage: dbData.formattedMessage, formattedMessage: dbData.formattedMessage,