From 6aa22c8c31adce8bee4a0bf8f22325ea77edf84f Mon Sep 17 00:00:00 2001 From: Jemma Poffinbarger Date: Mon, 10 Apr 2023 22:01:10 -0500 Subject: [PATCH] Added support for 'type=memo' flag in community posts --- src/services/miiverse-api/routes/communities.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/miiverse-api/routes/communities.js b/src/services/miiverse-api/routes/communities.js index bb4ece6..e5b2677 100644 --- a/src/services/miiverse-api/routes/communities.js +++ b/src/services/miiverse-api/routes/communities.js @@ -54,6 +54,9 @@ router.get('/:appID/posts', async function (req, res) { query.search_key = req.query.search_key; if(!req.query.allow_spoiler) query.is_spoiler = 0; + //TODO: There probably is a type for text and screenshots too, will have to investigate + if(req.query.type === 'memo') + query.painting = { $ne: null }; if(req.query.by === 'followings') { let userContent = await database.getUserContent(req.pid); query.pid = userContent.following_users; @@ -68,7 +71,7 @@ router.get('/:appID/posts', async function (req, res) { { $sort: { created_at: -1 } }, // sort by 'created_at' in descending order { $group: { _id: '$pid', doc: { $first: '$$ROOT' } } }, // remove any duplicate 'pid' elements { $replaceRoot: { newRoot: '$doc' } }, // replace the root with the 'doc' field - { $limit: (req.query.limit ? Number(req.query.limit) : 10) } // only return the top 8 results + { $limit: (req.query.limit ? Number(req.query.limit) : 10) } // only return the top 10 results ]); else posts = await POST.find(query).sort({ created_at: -1}).limit(parseInt(req.query.limit));