mirror of
https://github.com/System-End/slack-end.git
synced 2026-04-19 23:22:56 +00:00
feat: POST /send-spotify
This commit is contained in:
parent
4c2510aa80
commit
9fbc022f7d
1 changed files with 52 additions and 0 deletions
|
|
@ -60,6 +60,58 @@ export const app = new App({
|
|||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/send-spotify",
|
||||
method: ["POST"],
|
||||
async handler(req, res) {
|
||||
const authHeader = req.headers["authorization"];
|
||||
if (authHeader !== process.env.AUTH) {
|
||||
res.writeHead(401).end();
|
||||
return;
|
||||
}
|
||||
// pray this works
|
||||
console.log(
|
||||
require("body-parser").json()(req, res, async () => {
|
||||
//@ts-ignore
|
||||
console.log(req.body, 1);
|
||||
|
||||
//@ts-ignore
|
||||
if (!req.body || Object.keys(req.body) == 0) {
|
||||
res.writeHead(400).end();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await app.client.chat
|
||||
.postMessage({
|
||||
channel: "C07RE4N7S4B",
|
||||
//@ts-expect-error
|
||||
text: `:new_spotify: New Song: ${req.body.songurl} - added by <@${req.body.user}>`
|
||||
})
|
||||
.then((d) => {
|
||||
app.client.chat.postMessage({
|
||||
channel: "C07RE4N7S4B",
|
||||
thread_ts: d.ts,
|
||||
text: `:thread: Responses about new song here please!`,
|
||||
}).then(() => {
|
||||
//@ts-ignore
|
||||
if (!req.body.noping) {
|
||||
app.client.chat.postMessage({
|
||||
channel: "C07RE4N7S4B",
|
||||
text: `<!subteam^S07RGTY93J8>`,
|
||||
})
|
||||
}
|
||||
res.writeHead(200);
|
||||
res.end(JSON.stringify(d));
|
||||
})
|
||||
});
|
||||
} catch (e: any) {
|
||||
res.writeHead(500);
|
||||
res.end(e.stack);
|
||||
}
|
||||
}),
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
export default app as ModifiedApp;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue