|
|
|
@ -58,12 +58,12 @@ topicsController.get = async function getTopic(req, res, next) {
|
|
|
|
|
return helpers.notAllowed(req, res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!res.locals.isAPI && (!req.params.slug || topicData.slug !== `${tid}/${req.params.slug}`) && (topicData.slug && topicData.slug !== `${tid}/`)) {
|
|
|
|
|
return helpers.redirect(res, `/topic/${topicData.slug}${postIndex ? `/${postIndex}` : ''}${generateQueryString(req.query)}`, true);
|
|
|
|
|
if (req.params.post_index === 'unread') {
|
|
|
|
|
postIndex = await topics.getUserBookmark(tid, req.uid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (postIndex === 'unread') {
|
|
|
|
|
postIndex = await topics.getUserBookmark(tid, req.uid);
|
|
|
|
|
if (!res.locals.isAPI && (!req.params.slug || topicData.slug !== `${tid}/${req.params.slug}`) && (topicData.slug && topicData.slug !== `${tid}/`)) {
|
|
|
|
|
return helpers.redirect(res, `/topic/${topicData.slug}${postIndex ? `/${postIndex}` : ''}${generateQueryString(req.query)}`, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (utils.isNumber(postIndex) && topicData.postcount > 0 && (postIndex < 1 || postIndex > topicData.postcount)) {
|
|
|
|
|