mirror of
https://github.com/PretendoNetwork/miiverse-api.git
synced 2026-08-25 01:54:11 -05:00
Added support for 'type=memo' flag in community posts
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user