FIrst nonorganic posts

This commit is contained in:
aeroreyna
2022-02-16 22:28:11 -08:00
parent 117bc5833a
commit e0c6470bce
3 changed files with 57 additions and 2 deletions

View File

@@ -20,8 +20,21 @@ DB.getDB.then((DB) => {
const profileid = getProfileId(req);
let posts = await DB.getFeed(profileid);
//Add non-organic posts
return res.json(posts)
const popularProfiles = await DB.getPopularProfiles(5);
let content = "Popular users to follow:\n";
popularProfiles.forEach((p)=>{
content += "@p:" + p._id + "\n";
});
let popularProfilesPost = new Post({profileid: 1, content, nonOrganicType: "PopularUsers"});
const popularGroups = await DB.getPopularGroups(5);
content = "Popular users to follow:\n";
popularGroups.forEach((p)=>{
content += "@p:" + p._id + "\n";
});
let popularGroupsPost = new Post({profileid: 1, content, nonOrganicType: "PopularGroups"});
posts.push(popularProfilesPost);
posts.push(popularGroupsPost);
return res.json(posts);
});
router.get("/usr/:id", async (req, res) => {