Skip to content

Commit 3c1e96b

Browse files
committed
re-lint and fmt
1 parent 48da576 commit 3c1e96b

File tree

2 files changed

+109
-109
lines changed

2 files changed

+109
-109
lines changed

docs/admin/monitoring/notifications/slack.md

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -72,94 +72,94 @@ To build the server to receive webhooks and interact with Slack:
7272

7373
// Create a Bolt Receiver
7474
const receiver = new ExpressReceiver({
75-
signingSecret: process.env.SLACK_SIGNING_SECRET,
75+
signingSecret: process.env.SLACK_SIGNING_SECRET,
7676
});
7777
receiver.router.use(bodyParser.json());
7878

7979
// Create the Bolt App, using the receiver
8080
const app = new App({
81-
token: process.env.SLACK_BOT_TOKEN,
82-
logLevel: LogLevel.DEBUG,
83-
receiver,
81+
token: process.env.SLACK_BOT_TOKEN,
82+
logLevel: LogLevel.DEBUG,
83+
receiver,
8484
});
8585

8686
receiver.router.post("/v1/webhook", async (req, res) => {
87-
try {
88-
if (!req.body) {
89-
return res.status(400).send("Error: request body is missing");
90-
}
91-
92-
const { title, body } = req.body;
93-
if (!title || !body) {
94-
return res
95-
.status(400)
96-
.send('Error: missing fields: "title", or "body"');
97-
}
98-
99-
const payload = req.body.payload;
100-
if (!payload) {
101-
return res.status(400).send('Error: missing "payload" field');
102-
}
103-
104-
const { user_email, actions } = payload;
105-
if (!user_email || !actions) {
106-
return res
107-
.status(400)
108-
.send('Error: missing fields: "user_email", "actions"');
109-
}
110-
111-
// Get the user ID using Slack API
112-
const userByEmail = await app.client.users.lookupByEmail({
113-
email: user_email,
114-
});
115-
116-
const slackMessage = {
117-
channel: userByEmail.user.id,
118-
text: body,
119-
blocks: [
120-
{
121-
type: "header",
122-
text: { type: "plain_text", text: title },
123-
},
124-
{
125-
type: "section",
126-
text: { type: "mrkdwn", text: body },
127-
},
128-
],
129-
};
130-
131-
// Add action buttons if they exist
132-
if (actions && actions.length > 0) {
133-
slackMessage.blocks.push({
134-
type: "actions",
135-
elements: actions.map((action) => ({
136-
type: "button",
137-
text: { type: "plain_text", text: action.label },
138-
url: action.url,
139-
})),
140-
});
141-
}
142-
143-
// Post message to the user on Slack
144-
await app.client.chat.postMessage(slackMessage);
145-
146-
res.status(204).send();
147-
} catch (error) {
148-
console.error("Error sending message:", error);
149-
res.status(500).send();
150-
}
87+
try {
88+
if (!req.body) {
89+
return res.status(400).send("Error: request body is missing");
90+
}
91+
92+
const { title, body } = req.body;
93+
if (!title || !body) {
94+
return res
95+
.status(400)
96+
.send('Error: missing fields: "title", or "body"');
97+
}
98+
99+
const payload = req.body.payload;
100+
if (!payload) {
101+
return res.status(400).send('Error: missing "payload" field');
102+
}
103+
104+
const { user_email, actions } = payload;
105+
if (!user_email || !actions) {
106+
return res
107+
.status(400)
108+
.send('Error: missing fields: "user_email", "actions"');
109+
}
110+
111+
// Get the user ID using Slack API
112+
const userByEmail = await app.client.users.lookupByEmail({
113+
email: user_email,
114+
});
115+
116+
const slackMessage = {
117+
channel: userByEmail.user.id,
118+
text: body,
119+
blocks: [
120+
{
121+
type: "header",
122+
text: { type: "plain_text", text: title },
123+
},
124+
{
125+
type: "section",
126+
text: { type: "mrkdwn", text: body },
127+
},
128+
],
129+
};
130+
131+
// Add action buttons if they exist
132+
if (actions && actions.length > 0) {
133+
slackMessage.blocks.push({
134+
type: "actions",
135+
elements: actions.map((action) => ({
136+
type: "button",
137+
text: { type: "plain_text", text: action.label },
138+
url: action.url,
139+
})),
140+
});
141+
}
142+
143+
// Post message to the user on Slack
144+
await app.client.chat.postMessage(slackMessage);
145+
146+
res.status(204).send();
147+
} catch (error) {
148+
console.error("Error sending message:", error);
149+
res.status(500).send();
150+
}
151151
});
152152

153153
// Acknowledge clicks on link_button, otherwise Slack UI
154154
// complains about missing events.
155155
app.action("button_click", async ({ body, ack, say }) => {
156-
await ack(); // no specific action needed
156+
await ack(); // no specific action needed
157157
});
158158

159159
// Start the Bolt app
160160
(async () => {
161-
await app.start(port);
162-
console.log("⚡️ Coder Slack bot is running!");
161+
await app.start(port);
162+
console.log("⚡️ Coder Slack bot is running!");
163163
})();
164164
```
165165

docs/admin/monitoring/notifications/teams.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,44 +36,44 @@ The process of setting up a Teams workflow consists of three key steps:
3636

3737
```json
3838
{
39-
"type": "object",
40-
"properties": {
41-
"_version": {
42-
"type": "string"
43-
},
44-
"payload": {
45-
"type": "object",
46-
"properties": {
47-
"_version": {
48-
"type": "string"
49-
},
50-
"user_email": {
51-
"type": "string"
52-
},
53-
"actions": {
54-
"type": "array",
55-
"items": {
56-
"type": "object",
57-
"properties": {
58-
"label": {
59-
"type": "string"
60-
},
61-
"url": {
62-
"type": "string"
63-
}
64-
},
65-
"required": ["label", "url"]
66-
}
67-
}
68-
}
69-
},
70-
"title": {
71-
"type": "string"
72-
},
73-
"body": {
74-
"type": "string"
75-
}
76-
}
39+
"type": "object",
40+
"properties": {
41+
"_version": {
42+
"type": "string"
43+
},
44+
"payload": {
45+
"type": "object",
46+
"properties": {
47+
"_version": {
48+
"type": "string"
49+
},
50+
"user_email": {
51+
"type": "string"
52+
},
53+
"actions": {
54+
"type": "array",
55+
"items": {
56+
"type": "object",
57+
"properties": {
58+
"label": {
59+
"type": "string"
60+
},
61+
"url": {
62+
"type": "string"
63+
}
64+
},
65+
"required": ["label", "url"]
66+
}
67+
}
68+
}
69+
},
70+
"title": {
71+
"type": "string"
72+
},
73+
"body": {
74+
"type": "string"
75+
}
76+
}
7777
}
7878
```
7979

0 commit comments

Comments
 (0)