mirror of
https://github.com/System-End/site.git
synced 2026-04-19 22:05:11 +00:00
Merge branch 'master' of https://github.com/hackclub/v3
This commit is contained in:
commit
99f72b72e9
2 changed files with 56 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
const AirtablePlus = require('airtable-plus')
|
||||
import AirtablePlus from 'airtable-plus'
|
||||
import fetch from 'isomorphic-unfetch'
|
||||
|
||||
const joinTable = new AirtablePlus({
|
||||
apiKey: process.env.AIRTABLE_API_KEY,
|
||||
|
|
@ -22,6 +23,60 @@ export default async (req, res) => {
|
|||
Student: data.teen,
|
||||
Reason: data.reason
|
||||
})
|
||||
if (data.teen) {
|
||||
let postData = {
|
||||
channel: 'G0147KPNHU0', //G0132DNFE7J
|
||||
blocks: [
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
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' })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,5 @@
|
|||
"trailingSlash": true,
|
||||
"github": {
|
||||
"silent": true
|
||||
},
|
||||
"env": {
|
||||
"AIRTABLE_API_KEY": "@airtable-api-key"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue