mirror of
https://github.com/PretendoNetwork/juxtaposition-ui.git
synced 2026-09-09 01:45:31 -05:00
Added support for loading community by title_id instead of community_id
This commit is contained in:
committed by
jay.poff@outlook.com
parent
9fb074bf3d
commit
7037d87948
@@ -49,6 +49,33 @@ router.get('/announcements', async function (req, res) {
|
||||
});
|
||||
});
|
||||
|
||||
router.get('/:communityID', async function (req, res) {
|
||||
let user = await database.getUserByPID(req.pid);
|
||||
if(req.params.communityID === 'announcements')
|
||||
res.redirect('/communities/announcements')
|
||||
let community = await database.getCommunityByID(req.params.communityID.toString());
|
||||
if(community === null && req.query.title_id)
|
||||
community = await database.getCommunityByTitleID(req.query.title_id)
|
||||
if(community === null)
|
||||
return res.sendStatus(404);
|
||||
let communityMap = await util.data.getCommunityHash();
|
||||
let newPosts = await database.getNumberNewCommunityPostsByID(community, 5);
|
||||
let totalNumPosts = await database.getTotalPostsByCommunity(community)
|
||||
res.render(req.directory + '/community.ejs', {
|
||||
// EJS variable and server-side variable
|
||||
moment: moment,
|
||||
community: community,
|
||||
communityMap: communityMap,
|
||||
newPosts: newPosts,
|
||||
totalNumPosts: totalNumPosts,
|
||||
user: user,
|
||||
account_server: config.account_server_domain.slice(8),
|
||||
cdnURL: config.CDN_domain,
|
||||
lang: req.lang,
|
||||
mii_image_CDN: config.mii_image_CDN
|
||||
});
|
||||
});
|
||||
|
||||
router.get('/:communityID/:type', async function (req, res) {
|
||||
let user = await database.getUserByPID(req.pid);
|
||||
if(req.params.communityID === 'announcements')
|
||||
|
||||
@@ -58,7 +58,7 @@ router.get('/show', async function (req, res) {
|
||||
let parentUser = await database.getUserByPID(req.pid);
|
||||
let user = await database.getUserByPID(userID);
|
||||
if(user === null)
|
||||
res.sendStatus(404);
|
||||
return res.sendStatus(404);
|
||||
if(parentUser === user)
|
||||
res.redirect('/users/me');
|
||||
let newPosts = await database.getNumberUserPostsByID(user.pid, 10);
|
||||
|
||||
Reference in New Issue
Block a user