From 98d3e0a2c216a068a89af385522aa865daba23d9 Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange Date: Fri, 30 Aug 2024 01:13:00 -0500 Subject: [PATCH] pd blacklist --- index.js | 21 +++++++++++++++++++++ views/pages/blurbs.ejs | 1 + 2 files changed, 22 insertions(+) diff --git a/index.js b/index.js index f241d19..cfeb136 100644 --- a/index.js +++ b/index.js @@ -19,6 +19,7 @@ const db = new Kysely({ }); rawDB.exec(`CREATE TABLE IF NOT EXISTS blurbs( 'id' TEXT, 'site' TEXT, 'blurb' TEXT, 'verified' INTEGER, 'time' INTEGER );`); +rawDB.exec(`CREATE TABLE IF NOT EXISTS blacklist( 'domain' TEXT );`); const app = express(); @@ -141,6 +142,26 @@ app.get('/blurbs/send', async (req, res) => { message: errors.join(", ") }); + try { + const domain = new URL(body.site).hostname; + const isBadSite = await db + .selectFrom('blacklist') + .selectAll() + .where('domain', '=', domain) + .executeTakeFirst(); + + if (isBadSite != null) + return res.status(403).json({ + error: "Forbidden", + message: "\u{1f595}" + }); + } catch (err) { + return res.status(500).json({ + error: "Internal Server Error", + message: "URL CONSTRUCTOR FAILED???? i think this might be your fault...." + }); + } + const postId = nanoid(32); try { diff --git a/views/pages/blurbs.ejs b/views/pages/blurbs.ejs index 9e04a84..c2a9598 100644 --- a/views/pages/blurbs.ejs +++ b/views/pages/blurbs.ejs @@ -20,6 +20,7 @@

by clicking this button and successfully submitting a blurb, you agree that your input may be displayed on this site and stored on abtmtr.link servers.

you'll also need to verify your blurb by leaving a X/HTML snippet on your site. further instructions will be given to do this after you submit your blurb. thanks!

+

rules: no slurs, no politics, no nsfw, no spam. if you break these rules outside of plausible deniability, your domain will be blacklisted.

current blurbs (<%= data.length %>)