mirror of
https://github.com/System-End/site.git
synced 2026-04-19 20:55:09 +00:00
Send to Slack
This commit is contained in:
parent
c774239032
commit
e79f3f326d
1 changed files with 54 additions and 7 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
const AirtablePlus = require('airtable-plus')
|
import AirtablePlus from 'airtable-plus'
|
||||||
import fetch from 'isomorphic-unfetch'
|
import fetch from 'isomorphic-unfetch'
|
||||||
|
|
||||||
const joinTable = new AirtablePlus({
|
const joinTable = new AirtablePlus({
|
||||||
|
|
@ -22,13 +22,60 @@ export default async (req, res) => {
|
||||||
Student: data.teen,
|
Student: data.teen,
|
||||||
Reason: data.reason
|
Reason: data.reason
|
||||||
})
|
})
|
||||||
fetch('https://hackclub-slacker.glitch.me/newmember', {
|
if (data.teen) {
|
||||||
method: 'POST',
|
let postData = {
|
||||||
body: JSON.stringify(data),
|
channel: 'G0147KPNHU0', //G0132DNFE7J
|
||||||
headers: {
|
blocks: [
|
||||||
"Content-Type": "application/json"
|
{
|
||||||
|
"type": "section",
|
||||||
|
"text": {
|
||||||
|
"type": "mrkdwn",
|
||||||
|
"text": "Someone just requested to join the Slack."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "section",
|
||||||
|
"text": {
|
||||||
|
"type": "mrkdwn",
|
||||||
|
"text": `*Full name:* ${data.name}\n*Email:* ${data.email}\n*Student:* ${data.teen ? 'true' : 'false'}\n*Reason:* ${data.reason}`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "actions",
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"type": "button",
|
||||||
|
"text": {
|
||||||
|
"type": "plain_text",
|
||||||
|
"emoji": true,
|
||||||
|
"text": "Send Invitation"
|
||||||
|
},
|
||||||
|
"style": "primary",
|
||||||
|
"action_id": "invite_member"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "button",
|
||||||
|
"text": {
|
||||||
|
"type": "plain_text",
|
||||||
|
"emoji": true,
|
||||||
|
"text": "Deny"
|
||||||
|
},
|
||||||
|
"style": "danger",
|
||||||
|
"action_id": "deny"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}).then(r => r.json())
|
fetch('https://slack.com/api/chat.postMessage', {
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': `Bearer ${process.env.SLACK_BOT_TOKEN}`
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData)
|
||||||
|
}).catch(err => console.log(err))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res.json({ status: 'success' })
|
res.json({ status: 'success' })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue