feat(board-channels): skip Slack createChannel in dev/test mode
Mirrors the dev-mode short-circuit in invite.post.js. Without SLACK_BOT_TOKEN, board-channel create returned 500 'Slack integration not configured', breaking e2e in CI. With ALLOW_DEV_TEST_ENDPOINTS=true, generate a stub channel ID and proceed; everything DB-side still runs.
This commit is contained in:
parent
6e98720310
commit
1578055a27
1 changed files with 21 additions and 16 deletions
|
|
@ -24,22 +24,27 @@ export default defineEventHandler(async (event) => {
|
|||
let channelName = body.name
|
||||
|
||||
if (!slackChannelId) {
|
||||
const slack = getSlackAdminService()
|
||||
if (!slack) {
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: 'Slack integration not configured',
|
||||
})
|
||||
}
|
||||
try {
|
||||
const created = await slack.createChannel(body.name)
|
||||
slackChannelId = created.id
|
||||
channelName = created.name
|
||||
} catch (err) {
|
||||
throw createError({
|
||||
statusCode: 502,
|
||||
statusMessage: `Failed to create Slack channel: ${err.data?.error || err.message}`,
|
||||
})
|
||||
if (process.env.ALLOW_DEV_TEST_ENDPOINTS === 'true') {
|
||||
slackChannelId = `dev-stub-${Date.now()}`
|
||||
console.log('[slack] DEV MODE — skipping createChannel', { name: body.name, slackChannelId })
|
||||
} else {
|
||||
const slack = getSlackAdminService()
|
||||
if (!slack) {
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: 'Slack integration not configured',
|
||||
})
|
||||
}
|
||||
try {
|
||||
const created = await slack.createChannel(body.name)
|
||||
slackChannelId = created.id
|
||||
channelName = created.name
|
||||
} catch (err) {
|
||||
throw createError({
|
||||
statusCode: 502,
|
||||
statusMessage: `Failed to create Slack channel: ${err.data?.error || err.message}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue