Skip to content

Commit

Permalink
Post real PREreviews to the real Slack channel
Browse files Browse the repository at this point in the history
Refs #477
  • Loading branch information
thewilkybarkid committed Jul 29, 2024
1 parent d3baf2b commit ccc2a6b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Include the Bot User OAuth Token for the PREreview Community Slack (https://api.slack.com/apps/A05QSTUS8JD/oauth)
SLACK_ACCESS_TOKEN=access-token-here
SLACK_CHANNEL_ID=C05N0JHBC1Y
SLACK_SHARE_CHANNEL_ID=C05V6TXHETS

# Include an API key for OpenAI (https://platform.openai.com/api-keys)
OPENAI_API_KEY=api-key-here
Expand Down
1 change: 1 addition & 0 deletions fly.prod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ primary_region = "iad"
[env]
BULLMQ_WORKER_POLL = "30 seconds"
SLACK_CHANNEL_ID = "C05B95LEN5C"
SLACK_SHARE_CHANNEL_ID = "C05C2Q0QKQB"
REDIS_IP_VERSION = "6"

[http_service]
Expand Down
1 change: 1 addition & 0 deletions fly.sandbox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ primary_region = "iad"
[env]
BULLMQ_WORKER_POLL = "30 seconds"
SLACK_CHANNEL_ID = "C05N0JHBC1Y"
SLACK_SHARE_CHANNEL_ID = "C05V6TXHETS"
REDIS_IP_VERSION = "6"

[http_service]
Expand Down
9 changes: 8 additions & 1 deletion src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { SmtpConfig } from './Nodemailer.js'
import { OpenAiConfig } from './OpenAi.js'
import { RedisConfig } from './Redis.js'
import { SlackChannelConfig } from './ReviewRequest.js'
import { PrereviewAuthToken } from './Router.js'
import { PrereviewAuthToken, SlackShareChannelId } from './Router.js'
import type * as Slack from './Slack.js'
import { SlackApiConfig, SlackChannelId } from './Slack.js'

const slackApiConfig: Config.Config<SlackApiConfig> = Config.nested(
Expand All @@ -16,6 +17,11 @@ const slackChannelConfig: Config.Config<SlackChannelConfig> = Config.nested(
'SLACK',
)

const slackShareChannelId: Config.Config<Slack.SlackChannelId> = Config.nested(
Config.map(Config.string('SHARE_CHANNEL_ID'), SlackChannelId),
'SLACK',
)

const redisConfig: Config.Config<RedisConfig> = Config.nested(
Config.all({
url: Config.mapAttempt(Config.string('URL'), url => new URL(url)),
Expand Down Expand Up @@ -44,6 +50,7 @@ const prereviewAuthTokenConfig = Config.string('PREREVIEW_AUTH_TOKEN')

export const ConfigLive = Layer.mergeAll(
Layer.effect(SlackApiConfig, slackApiConfig),
Layer.effect(SlackShareChannelId, slackShareChannelId),
Layer.effect(SlackChannelConfig, slackChannelConfig),
Layer.effect(RedisConfig, redisConfig),
Layer.effect(PrereviewAuthToken, prereviewAuthTokenConfig),
Expand Down
4 changes: 3 additions & 1 deletion src/Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import * as Slack from './Slack.js'
import * as Temporal from './Temporal.js'
import * as Url from './Url.js'

export const SlackShareChannelId = Context.GenericTag<Slack.SlackChannelId>('SlackShareChannelId')

export const PrereviewAuthToken = Context.GenericTag<string>('PrereviewAuthToken')

class RedisTimeout extends Data.TaggedError('RedisTimeout') {
Expand Down Expand Up @@ -131,7 +133,7 @@ export const Router = HttpRouter.empty.pipe(
const prereview = yield* HttpServerRequest.schemaBodyJson(NewPrereviewSchema)

yield* Slack.chatPostMessage({
channel: Slack.SlackChannelId('C05V6TXHETS'),
channel: yield* SlackShareChannelId,
blocks: [
{
type: 'section',
Expand Down

0 comments on commit ccc2a6b

Please sign in to comment.