include bookmarks with topic lists

v1.18.x
Ben Lubar 9 years ago
parent 89aa06526d
commit 969e7fdbbe

@ -131,6 +131,14 @@ var social = require('./social');
hasRead: function(next) {
Topics.hasReadTopics(tids, uid, next);
},
bookmarks: function(next) {
if (!parseInt(uid, 10)) {
return next(null, tids.map(function() {
return null;
}));
}
Topics.getUserBookmarks(tids, uid, next);
},
teasers: function(next) {
Topics.getTeasers(topics, next);
},
@ -155,6 +163,7 @@ var social = require('./social');
topics[i].locked = parseInt(topics[i].locked, 10) === 1;
topics[i].deleted = parseInt(topics[i].deleted, 10) === 1;
topics[i].unread = !results.hasRead[i];
topics[i].bookmark = results.bookmarks[i];
topics[i].unreplied = !topics[i].teaser;
}
}
@ -292,6 +301,12 @@ var social = require('./social');
db.sortedSetScore('tid:' + tid + ':bookmarks', uid, callback);
};
Topics.getUserBookmarks = function(tids, uid, callback) {
db.sortedSetsScore(tids.map(function(tid) {
return 'tid:' + tid + ':bookmarks';
}), uid, callback);
};
Topics.setUserBookmark = function(tid, uid, index, callback) {
db.sortedSetAdd('tid:' + tid + ':bookmarks', index, uid, callback);
};

Loading…
Cancel
Save