diff --git a/backend/api/controllers/quote.ts b/backend/api/controllers/quote.ts index 2473b66c3..4ea2bf5ba 100644 --- a/backend/api/controllers/quote.ts +++ b/backend/api/controllers/quote.ts @@ -16,9 +16,12 @@ async function verifyCaptcha(captcha: string): Promise { } export async function getQuotes( - _req: MonkeyTypes.Request + req: MonkeyTypes.Request ): Promise { - const data = await NewQuotesDao.get(); + const { uid } = req.ctx.decodedToken; + let { quoteMod } = await UserDAO.getUser(uid); + if (quoteMod === true) quoteMod = "all"; + const data = await NewQuotesDao.get(quoteMod); return new MonkeyResponse("Quote submissions retrieved", data); } diff --git a/backend/dao/new-quotes.js b/backend/dao/new-quotes.js index d4e3a3ed2..bd9ad5bef 100644 --- a/backend/dao/new-quotes.js +++ b/backend/dao/new-quotes.js @@ -56,11 +56,17 @@ class NewQuotesDAO { return await db.collection("new-quotes").insertOne(quote); } - static async get() { + static async get(language) { if (!git) throw new MonkeyError(500, "Git not available."); + const where = { + approved: false, + }; + if (language !== "all") { + where.language = language; + } return await db .collection("new-quotes") - .find({ approved: false }) + .find(where) .sort({ timestamp: 1 }) .limit(10) .toArray();