Added support for 'type=memo' flag in community posts

This commit is contained in:
Jemma Poffinbarger
2023-04-10 22:01:10 -05:00
parent 448736d4ae
commit 6aa22c8c31

View File

@@ -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));