mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 00:10:25 +01:00
fixed a bug that made topics invisible to users, also closes #47
This commit is contained in:
@@ -161,7 +161,10 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isTopicVisible(topicData, topicInfo) {
|
||||||
|
var deleted = parseInt(topicData.deleted, 10) !== 0;
|
||||||
|
return !deleted || (deleted && topicInfo.privileges.view_deleted) || topicData.uid === current_user;
|
||||||
|
}
|
||||||
|
|
||||||
for(var i=0; i<tids.length; ++i) {
|
for(var i=0; i<tids.length; ++i) {
|
||||||
|
|
||||||
@@ -181,7 +184,7 @@ var RDB = require('./redis.js'),
|
|||||||
topicData.teaser_username = topicInfo.teaserInfo.username;
|
topicData.teaser_username = topicInfo.teaserInfo.username;
|
||||||
topicData.teaser_timestamp = utils.relativeTime(topicInfo.teaserInfo.timestamp);
|
topicData.teaser_timestamp = utils.relativeTime(topicInfo.teaserInfo.timestamp);
|
||||||
|
|
||||||
if (!topicData.deleted || (topicData.deleted && topicInfo.privileges.view_deleted) || topicData.uid === current_user)
|
if (isTopicVisible(topicData, topicInfo))
|
||||||
retrieved_topics.push(topicData);
|
retrieved_topics.push(topicData);
|
||||||
else
|
else
|
||||||
--topicCountToLoad;
|
--topicCountToLoad;
|
||||||
@@ -302,6 +305,14 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Categories.setCategoryField = function(cid, field, value) {
|
||||||
|
RDB.hset('category:' + cid, field, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Categories.incrementCategoryFieldBy = function(cid, field, value) {
|
||||||
|
RDB.hincrby('category:' + cid, field, value);
|
||||||
|
}
|
||||||
|
|
||||||
Categories.getCategories = function(cids, callback, current_user) {
|
Categories.getCategories = function(cids, callback, current_user) {
|
||||||
if (cids.length === 0) {
|
if (cids.length === 0) {
|
||||||
callback({'categories' : []});
|
callback({'categories' : []});
|
||||||
|
|||||||
@@ -168,6 +168,9 @@ var RDB = require('./redis.js'),
|
|||||||
|
|
||||||
topics.setTopicField(tid, 'cid', cid);
|
topics.setTopicField(tid, 'cid', cid);
|
||||||
|
|
||||||
|
categories.incrementCategoryFieldBy(oldCid, 'topic_count', -1);
|
||||||
|
categories.incrementCategoryFieldBy(cid, 'topic_count', 1);
|
||||||
|
|
||||||
categories.getCategories([cid], function(data) {
|
categories.getCategories([cid], function(data) {
|
||||||
topics.setTopicField(tid, 'category_name', data.categories[0].name);
|
topics.setTopicField(tid, 'category_name', data.categories[0].name);
|
||||||
topics.setTopicField(tid, 'category_slug', data.categories[0].slug);
|
topics.setTopicField(tid, 'category_slug', data.categories[0].slug);
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ var express = require('express'),
|
|||||||
|
|
||||||
var category_url = cid + (req.params.slug ? '/' + req.params.slug : '');
|
var category_url = cid + (req.params.slug ? '/' + req.params.slug : '');
|
||||||
categories.getCategoryById(cid, 0, function(returnData) {
|
categories.getCategoryById(cid, 0, function(returnData) {
|
||||||
|
|
||||||
res.send(
|
res.send(
|
||||||
app.build_header(res) +
|
app.build_header(res) +
|
||||||
'\n\t<noscript>\n' + templates['noscript/header'] + templates['noscript/category'].parse(returnData) + '\n\t</noscript>' +
|
'\n\t<noscript>\n' + templates['noscript/header'] + templates['noscript/category'].parse(returnData) + '\n\t</noscript>' +
|
||||||
|
|||||||
Reference in New Issue
Block a user