webhooks ???? lol ?????????????

This commit is contained in:
MeowcaTheoRange 2024-09-02 10:13:57 -05:00
parent f11d05e648
commit 27e2251555

View file

@ -226,6 +226,35 @@ app.post('/mininq/mbox/r', async (req, res) => {
switch (body.action) {
case "public":
if (process.env.MININQ_WEBHOOK != null) {
const mininq_pub = await db
.selectFrom('mininq')
.selectAll()
.where('id', '=', body.id)
.executeTakeFirst();
await fetch(process.env.MININQ_WEBHOOK, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"content": "New mininq:",
"embeds": [
{
"description": mininq_pub.msg,
"color": 12298956,
"author": mininq_pub.url != '' ? {
"name": `${mininq_pub.name} @ ${new URL(mininq_pub.url).host} sent:`,
"url": mininq_pub.url
} : {
"name": `${mininq_pub.name} sent:`
}
}
],
"attachments": []
})
});
}
await db
.updateTable('mininq')
.set({
@ -246,6 +275,43 @@ app.post('/mininq/mbox/r', async (req, res) => {
if (body.msg.length < 1) return res.status(400).send("msg is required");
if (body.msg.length > 4000) return res.status(400).send("msg must not be longer than 4000 characters");
if (process.env.MININQ_WEBHOOK != null) {
const mininq = await db
.selectFrom('mininq')
.selectAll()
.where('id', '=', body.id)
.executeTakeFirst();
await fetch(process.env.MININQ_WEBHOOK, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"content": "New mininq:",
"embeds": [
{
"description": mininq.msg,
"color": 12298956,
"author": mininq.url != '' ? {
"name": `${mininq.name} @ ${new URL(mininq.url).host} sent:`,
"url": mininq.url
} : {
"name": `${mininq.name} sent:`
}
},
{
"description": mininq.reply,
"color": 13421772,
"author": {
"name": "sysadmin reply:",
"url": `https://abtmtr.link/mininq/#${mininq.id}`
}
}
],
"attachments": []
})
});
}
await db
.updateTable('mininq')
.set({