Skip to content

Node.js based forum software built for the modern web

closes #5684

Barış Soner Uşaklı77894915eb01
diff --git a/src/controllers/topics.js b/src/controllers/topics.js
index ddd6fd889a..5c592f5bb3 100644
--- a/src/controllers/topics.js
+++ b/src/controllers/topics.js
@@ -49,7 +49,7 @@ topicsController.get = function (req, res, callback) {
userPrivileges = results.privileges;
- if (!userPrivileges.read || !userPrivileges['topics:read'] || (parseInt(results.topic.deleted, 10) && !userPrivileges.view_deleted)) {
+ if (!userPrivileges['topics:read'] || (parseInt(results.topic.deleted, 10) && !userPrivileges.view_deleted)) {
return helpers.notAllowed(req, res);
}
diff --git a/src/socket.io/topics/infinitescroll.js b/src/socket.io/topics/infinitescroll.js
index 1d732de2a4..17d44712ea 100644
--- a/src/socket.io/topics/infinitescroll.js
+++ b/src/socket.io/topics/infinitescroll.js
@@ -27,7 +27,7 @@ module.exports = function (SocketTopics) {
}, next);
},
function (results, next) {
- if (!results.privileges.read || (parseInt(results.topic.deleted, 10) && !results.privileges.view_deleted)) {
+ if (!results.privileges['topics:read'] || (parseInt(results.topic.deleted, 10) && !results.privileges.view_deleted)) {
return callback(new Error('[[error:no-privileges]]'));
}
diff --git a/test/topics.js b/test/topics.js
index c362ca0824..4551595fa6 100644
--- a/test/topics.js
+++ b/test/topics.js
@@ -760,13 +760,13 @@ describe('Topic\'s', function () {
it('should 401 if not allowed to read as guest', function (done) {
var privileges = require('../src/privileges');
- privileges.categories.rescind(['read'], topicData.cid, 'guests', function (err) {
+ privileges.categories.rescind(['topics:read'], topicData.cid, 'guests', function (err) {
assert.ifError(err);
request(nconf.get('url') + '/api/topic/' + topicData.slug, function (err, response, body) {
assert.ifError(err);
assert.equal(response.statusCode, 401);
assert(body);
- privileges.categories.give(['read'], topicData.cid, 'guests', done);
+ privileges.categories.give(['topics:read'], topicData.cid, 'guests', done);
});
});
});
@@ -1551,7 +1551,7 @@ describe('Topic\'s', function () {
it('should return empty array if first param is empty', function (done) {
- topics.getTeasers([], function (err, teasers) {
+ topics.getTeasers([], 1, function (err, teasers) {
assert.ifError(err);
assert.equal(0, teasers.length);
done();
@@ -1559,7 +1559,7 @@ describe('Topic\'s', function () {
});
it('should get teasers with 2 params', function (done) {
- topics.getTeasers([topic1.topicData, topic2.topicData], function (err, teasers) {
+ topics.getTeasers([topic1.topicData, topic2.topicData], 1, function (err, teasers) {
assert.ifError(err);
assert.deepEqual([undefined, undefined], teasers);
done();
@@ -1568,7 +1568,7 @@ describe('Topic\'s', function () {
it('should get teasers with first posts', function (done) {
meta.config.teaserPost = 'first';
- topics.getTeasers([topic1.topicData, topic2.topicData], function (err, teasers) {
+ topics.getTeasers([topic1.topicData, topic2.topicData], 1, function (err, teasers) {
assert.ifError(err);
assert.equal(2, teasers.length);
assert(teasers[0]);
@@ -1581,7 +1581,7 @@ describe('Topic\'s', function () {
});
it('should get teasers even if one topic is falsy', function (done) {
- topics.getTeasers([null, topic2.topicData], function (err, teasers) {
+ topics.getTeasers([null, topic2.topicData], 1, function (err, teasers) {
assert.ifError(err);
assert.equal(2, teasers.length);
assert.equal(undefined, teasers[0]);
@@ -1598,7 +1598,7 @@ describe('Topic\'s', function () {
topics.reply({ uid: adminUid, content: 'reply 1 content', tid: topic1.topicData.tid }, function (err, result) {
assert.ifError(err);
topic1.topicData.teaserPid = result.pid;
- topics.getTeasers([topic1.topicData, topic2.topicData], function (err, teasers) {
+ topics.getTeasers([topic1.topicData, topic2.topicData], 1, function (err, teasers) {
assert.ifError(err);
assert(teasers[0]);
assert(teasers[1]);
@@ -1610,7 +1610,7 @@ describe('Topic\'s', function () {
});
it('should get teasers by tids', function (done) {
- topics.getTeasersByTids([topic2.topicData.tid, topic1.topicData.tid], function (err, teasers) {
+ topics.getTeasersByTids([topic2.topicData.tid, topic1.topicData.tid], 1, function (err, teasers) {
assert.ifError(err);
assert(2, teasers.length);
assert.equal(teasers[1].content, 'reply 1 content');
@@ -1619,7 +1619,7 @@ describe('Topic\'s', function () {
});
it('should return empty array ', function (done) {
- topics.getTeasersByTids([], function (err, teasers) {
+ topics.getTeasersByTids([], 1, function (err, teasers) {
assert.ifError(err);
assert.equal(0, teasers.length);
done();
@@ -1627,7 +1627,7 @@ describe('Topic\'s', function () {
});
it('should get teaser by tid', function (done) {
- topics.getTeaser(topic2.topicData.tid, function (err, teaser) {
+ topics.getTeaser(topic2.topicData.tid, 1, function (err, teaser) {
assert.ifError(err);
assert(teaser);
assert.equal(teaser.content, 'content 2');