mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 08:20:36 +01:00
fixed a bug that made topics invisible to users, also closes #47
This commit is contained in:
@@ -86,7 +86,7 @@
|
||||
// from http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
|
||||
isEmailValid: function(email) {
|
||||
var re = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
|
||||
return re.test(email);
|
||||
return re.test(email);
|
||||
},
|
||||
|
||||
isUserNameValid: function(name) {
|
||||
|
||||
@@ -12,7 +12,7 @@ var RDB = require('./redis.js'),
|
||||
|
||||
Categories.getCategoryData(category_id, function(categoryData) {
|
||||
|
||||
var category_name = categoryData.name;
|
||||
var category_name = categoryData.name;
|
||||
category_slug = categoryData.slug;
|
||||
|
||||
RDB.smembers('cid:' + category_id + ':active_users', function(err, active_users) {
|
||||
@@ -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) {
|
||||
|
||||
@@ -181,7 +184,7 @@ var RDB = require('./redis.js'),
|
||||
topicData.teaser_username = topicInfo.teaserInfo.username;
|
||||
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);
|
||||
else
|
||||
--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) {
|
||||
if (cids.length === 0) {
|
||||
callback({'categories' : []});
|
||||
|
||||
@@ -168,6 +168,9 @@ var RDB = require('./redis.js'),
|
||||
|
||||
topics.setTopicField(tid, 'cid', cid);
|
||||
|
||||
categories.incrementCategoryFieldBy(oldCid, 'topic_count', -1);
|
||||
categories.incrementCategoryFieldBy(cid, 'topic_count', 1);
|
||||
|
||||
categories.getCategories([cid], function(data) {
|
||||
topics.setTopicField(tid, 'category_name', data.categories[0].name);
|
||||
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 : '');
|
||||
categories.getCategoryById(cid, 0, function(returnData) {
|
||||
|
||||
res.send(
|
||||
app.build_header(res) +
|
||||
'\n\t<noscript>\n' + templates['noscript/header'] + templates['noscript/category'].parse(returnData) + '\n\t</noscript>' +
|
||||
|
||||
Reference in New Issue
Block a user