webhooks ???? lol ?????????????
This commit is contained in:
parent
f11d05e648
commit
27e2251555
1 changed files with 66 additions and 0 deletions
66
index.js
66
index.js
|
@ -226,6 +226,35 @@ app.post('/mininq/mbox/r', async (req, res) => {
|
||||||
|
|
||||||
switch (body.action) {
|
switch (body.action) {
|
||||||
case "public":
|
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
|
await db
|
||||||
.updateTable('mininq')
|
.updateTable('mininq')
|
||||||
.set({
|
.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 < 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 (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
|
await db
|
||||||
.updateTable('mininq')
|
.updateTable('mininq')
|
||||||
.set({
|
.set({
|
||||||
|
|
Loading…
Reference in a new issue