Category watch state (#7109)

* feat: wip, category watch change

* feat: pass data to client

* feat: allow changing state

* fix: account page categories

* fix: show in unread if topic is followed or category is watched

* feat: add default watch state to acp

* feat: save user category watch state

* feat: update unread recent pages

* fix: remove dupe code

* fix: flip conditions

* fix: handle empty arrays

* fix: ignore/watch on others profile

* feat: upgrade script for category states

if there are any users ignoring categories set their state in new zset and delete cid:<cid>:ignorers

* fix: upgrade

* fix: tests

* fix: redis count

* fix: more tests
This commit is contained in:
Barış Soner Uşaklı
2018-12-14 16:24:17 -05:00
committed by GitHub
parent 2104877c76
commit eb7ae54f81
28 changed files with 376 additions and 136 deletions

View File

@@ -1377,6 +1377,38 @@ describe('Topic\'s', function () {
], done);
});
it('should not return topics in category you ignored/not watching', function (done) {
var ignoredCid;
var tid;
async.waterfall([
function (next) {
categories.create({
name: 'ignored category',
description: 'ignored category',
}, next);
},
function (category, next) {
ignoredCid = category.cid;
privileges.categories.rescind(['read'], category.cid, 'registered-users', next);
},
function (next) {
topics.post({ uid: adminUid, title: 'topic in private category', content: 'registered-users cant see this', cid: ignoredCid }, next);
},
function (data, next) {
tid = data.topicData.tid;
User.ignoreCategory(uid, ignoredCid, next);
},
function (next) {
topics.getUnreadTids({ uid: uid }, next);
},
function (unreadTids, next) {
unreadTids = unreadTids.map(String);
assert(!unreadTids.includes(String(tid)));
next();
},
], done);
});
it('should not return topic as unread if new post is from blocked user', function (done) {
var blockedUid;
var topic;