mirror of
https://github.com/System-End/site.git
synced 2026-04-19 22:05:11 +00:00
* resolve public channels by id * add live slack messages hackers, rejoyce! * fix redirect because of slash * add live indicator * block bot-spam
24 lines
616 B
JavaScript
24 lines
616 B
JavaScript
export default async function handler(req, res) {
|
|
// get a public channel name by id
|
|
const channelDataReq = await fetch(
|
|
`https://slack.com/api/conversations.info?channel=${req.query.id}`,
|
|
{
|
|
headers: {
|
|
Authorization: `Bearer ${process.env.SLACK_BOT_TOKEN}`
|
|
}
|
|
}
|
|
)
|
|
|
|
if (!channelDataReq.ok) {
|
|
console.log(await channelDataReq.text())
|
|
return res.status(503).end()
|
|
}
|
|
|
|
const channelData = await channelDataReq.json()
|
|
if (!channelData.ok) {
|
|
console.log(channelData)
|
|
return res.status(400).end()
|
|
}
|
|
|
|
res.status(200).send({ name: channelData.channel.name })
|
|
}
|