-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslack.js
More file actions
34 lines (29 loc) · 938 Bytes
/
slack.js
File metadata and controls
34 lines (29 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const express = require('express');
const router = express.Router();
const whatthecommit = require('./whatthecommit');
const deniedMessage = "este comando não pode ser utilizado neste canal.";
router.get('/', (req, res) => res.redirect('https://github.com/gpedro/slack-whatthecommit/'));
router.post('/', async (req, res, next) => {
const message = await whatthecommit.get();
const target = (req.query.allowed_channels || '').split(',');
if (target && target.indexOf(req.body.channel_name) === -1) {
return res.status(200).json({
"attachments": [
{
"text": deniedMessage,
"fallback": deniedMessage
}
]
})
}
return res.status(200).json({
"response_type": "in_channel",
"attachments": [
{
"text": message,
"fallback": message
}
]
});
});
module.exports = router;