diff --git a/index.js b/index.js index 532c218..c388175 100644 --- a/index.js +++ b/index.js @@ -242,11 +242,13 @@ app.post('/mininq/mbox/r', async (req, res) => { { "description": mininq_pub.msg, "color": 12298956, + // TODO: make this smaller "author": mininq_pub.url != '' ? { "name": `${mininq_pub.name} @ ${new URL(mininq_pub.url).host} sent:`, - "url": mininq_pub.url + "url": `https://abtmtr.link/mininq/#${mininq.id}` } : { - "name": `${mininq_pub.name} sent:` + "name": `${mininq_pub.name} sent:`, + "url": `https://abtmtr.link/mininq/#${mininq.id}` }, "timestamp": new Date(mininq_pub.time).toISOString() } @@ -294,7 +296,7 @@ app.post('/mininq/mbox/r', async (req, res) => { "color": 12298956, "author": mininq.url != '' ? { "name": `${mininq.name} @ ${new URL(mininq.url).host} sent:`, - "url": mininq.url + "url": `https://abtmtr.link/mininq/#${mininq.id}` } : { "name": `${mininq.name} sent:` }, @@ -304,8 +306,7 @@ app.post('/mininq/mbox/r', async (req, res) => { "description": body.msg, "color": 13421772, "author": { - "name": "sysadmin reply:", - "url": `https://abtmtr.link/mininq/#${mininq.id}` + "name": "sysadmin reply:" } } ], @@ -567,6 +568,7 @@ app.get('/blurbs/send', async (req, res) => { } const postId = nanoid(32); + const timestamp = Date.now(); try { await db.insertInto('blurbs') @@ -575,7 +577,7 @@ app.get('/blurbs/send', async (req, res) => { site: body.site, blurb: body.text, verified: 0, - time: Date.now() + time: timestamp }) .executeTakeFirstOrThrow(); } catch (err) { @@ -603,14 +605,37 @@ app.get('/blurbs/check', async (req, res) => { const relationLink = dom.window.document.querySelector( `[rel=me][href="https://abtmtr.link/blurbs/#${blurbFromId.id}"]` ); - if (relationLink != null) await db - .updateTable('blurbs') - .set({ - verified: 1 - }) - .where('id', '=', body.id) - .executeTakeFirst(); - else { + if (relationLink != null) { + await db + .updateTable('blurbs') + .set({ + verified: 1 + }) + .where('id', '=', body.id) + .executeTakeFirst(); + + if (process.env.BLURBS_WEBHOOK != null) { + await fetch(process.env.BLURBS_WEBHOOK, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + "content": "New blurb:", + "embeds": [ + { + "description": blurbFromId.blurb, + "color": 12298956, + "author": { + "name": `${new URL(blurbFromId.site).host}`, + "url": `https://abtmtr.link/blurbs/#${blurbFromId.id}` + }, + "timestamp": new Date(blurbFromId.time).toISOString() + } + ], + "attachments": [] + }) + }); + } + } else { await db .updateTable('blurbs') .set({ diff --git a/views/components/page-head.ejs b/views/components/page-head.ejs index 238480f..7591766 100644 --- a/views/components/page-head.ejs +++ b/views/components/page-head.ejs @@ -7,6 +7,7 @@ + \ No newline at end of file