Skip to content

Commit

Permalink
profanity list endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Ianyourgod committed Mar 5, 2024
1 parent c21273b commit 93b4b2e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
18 changes: 18 additions & 0 deletions api/v1/routes/users/getProfanityList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = (app, utils) => {
app.get('/api/v1/users/getProfanityList', async function (req, res) {
const packet = req.query;
if (!UserManager.isCorrectCode(packet.user, packet.passcode)) {
utils.error(res, 400, "Reauthenticate")
return;
}
if (!AdminAccountUsernames.get(Cast.toString(packet.user))) {
utils.error(res, 403, "FeatureDisabledForThisAccount")
return;
}
const illegalWords = utils.UserManager.getIllegalWords();

res.status(200);
res.header("Content-Type", 'application/json');
res.json(illegalWords);
});
}
38 changes: 38 additions & 0 deletions api/v1/routes/users/setProfanityList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = (app, utils) => {
app.get('/api/v1/users/setProfanityList', async function (req, res) {
const packet = req.query;
if (!await UserManager.isCorrectCode(packet.user, packet.passcode)) {
utils.error(res, 400, "Reauthenticate")
return;
}
if (!await utils.UserManager.isAdmin(Cast.toString(packet.user))) {
utils.error(res, 403, "FeatureDisabledForThisAccount")
return;
}

const words = packet.json;
if (typeof words !== 'object') {
utils.error(res, 400, "InvalidData");
return;
}

const types = ["illegalWords", "illegalWebsites", "spacedOutWordsOnly", "potentiallyUnsafeWords", "potentiallyUnsafeWordsSpacedOut"];
for (const key in words) {
if (typeof words[key] !== 'string') {
utils.error(res, 400, "InvalidData");
return;
}

if (!types.includes(key)) {
utils.error(res, 400, "InvalidData");
return;
}

await utils.UserManager.setIllegalWords(words[key], key);
}

res.status(200);
res.header("Content-Type", 'application/json');
res.json({ "success": true });
});
}

0 comments on commit 93b4b2e

Please sign in to comment.