import { slackrespond } from "https://esm.town/v/nate/slackrespond";
import process from "node:process";
export let slackapp = async (req, res) => {
if ("ssl_check" in req.body) return;
if (
!("api_app_id" in req.body) ||
req.body.api_app_id !== process.env.SLACK_API_APP_ID ||
!("text" in req.body) ||
!("response_url" in req.body)
) {
res.status(200);
res.set("Content-Type", "application/json");
res.send(
JSON.stringify({
text: "A parameter was invalid or missing.",
})
);
return;
}
res.status(200).send();
await slackrespond(req.body.response_url, req.body.text);
};