Skip to content
Snippets Groups Projects
Commit b5ce6b26 authored by Sabith Haneef's avatar Sabith Haneef
Browse files

Catch slack error. Only send slack if enabled.

parent 91ed1640
No related branches found
No related tags found
No related merge requests found
......@@ -540,33 +540,37 @@ module.exports = {
});
});
//SEND onboarding msg to a slack channel
try {
const message = ['#onboarding',
'```',
`STATION_ID=${stationUsername}`,
`STATION_NAME=${stationName}`,
`EMAIL=${stationEmailAddress}`,
'```'].join('\n')
const client = await slackBotUtil.getClientInstance();
const channelId = slackBotUtil.getPadmeChannelId();
await client.files.upload({
// channels can be a list of one to many strings
channels: channelId,
initial_comment: message,
file: Buffer.from(envBufferEncrypted),
filename: "env",
title: "env"
});
console.log('Slack message sent');
// Call station registry to update cache to include newly on boarded station
getStationList();
} catch (error) {
console.log(error);
//SEND onboarding msg to a slack channel if enabled
if (process.env.SLACK_INTEGRATION_ENABLED === 'true') {
try {
const message = ['#onboarding',
'```',
`STATION_ID=${stationUsername}`,
`STATION_NAME=${stationName}`,
`EMAIL=${stationEmailAddress}`,
'```'].join('\n')
const client = await slackBotUtil.getClientInstance();
const channelId = slackBotUtil.getPadmeChannelId();
await client.files.upload({
// channels can be a list of one to many strings
channels: channelId,
initial_comment: message,
file: Buffer.from(envBufferEncrypted),
filename: "env",
title: "env"
}).catch(err => {
console.log(`Unable to send slack message: ${err}`);
});
console.log('Slack message sent');
// Call station registry to update cache to include newly on boarded station
getStationList();
} catch (error) {
console.log(error);
}
}
return res.status(200).send();
......
......@@ -55,9 +55,10 @@ services:
VAULT_PORT: 8200
VAULT_ROLE_ID: ${CENTRAL_SERVICE_VAULT_ROLE_ID}
VAULT_SECRET_ID: ${CENTRAL_SERVICE_VAULT_SECRET_ID}
SLACK_BOT_TOKEN: ${CENTRAL_SERVICE_SLACK_BOT_TOKEN}
SLACK_SIGNING_SECRET: ${CENTRAL_SERVICE_SLACK_SIGNING_SECRET}
SLACK_PADME_CHANNEL_ID: ${CENTRAL_SERVICE_SLACK_CHANNEL_ID}
SLACK_BOT_TOKEN: ${CENTRAL_SERVICE_SLACK_BOT_TOKEN-}
SLACK_SIGNING_SECRET: ${CENTRAL_SERVICE_SLACK_SIGNING_SECRET-}
SLACK_PADME_CHANNEL_ID: ${CENTRAL_SERVICE_SLACK_CHANNEL_ID-}
SLACK_INTEGRATION_ENABLED: ${CENTRAL_SERVICE_SLACK_INTEGRATION_ENABLED-false}
MINIO_PORT: 9000
MINIO_ENDPOINT: "minio-$USER"
MINIO_USE_SSL: "false"
......
......@@ -37,9 +37,10 @@ services:
VAULT_PORT: 8200
VAULT_ROLE_ID: ${CENTRAL_SERVICE_VAULT_ROLE_ID}
VAULT_SECRET_ID: ${CENTRAL_SERVICE_VAULT_SECRET_ID}
SLACK_BOT_TOKEN: ${CENTRAL_SERVICE_SLACK_BOT_TOKEN}
SLACK_SIGNING_SECRET: ${CENTRAL_SERVICE_SLACK_SIGNING_SECRET}
SLACK_PADME_CHANNEL_ID: ${CENTRAL_SERVICE_SLACK_CHANNEL_ID}
SLACK_BOT_TOKEN: ${CENTRAL_SERVICE_SLACK_BOT_TOKEN-}
SLACK_SIGNING_SECRET: ${CENTRAL_SERVICE_SLACK_SIGNING_SECRET-}
SLACK_PADME_CHANNEL_ID: ${CENTRAL_SERVICE_SLACK_CHANNEL_ID-}
SLACK_INTEGRATION_ENABLED: ${CENTRAL_SERVICE_SLACK_INTEGRATION_ENABLED-false}
MINIO_PORT: 9000
MINIO_ENDPOINT: minio
MINIO_USE_SSL: "false"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment