mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
Merge pull request #3346 from bdharrington7/bookmark2
Saves user bookmarks on server if available
This commit is contained in:
@@ -222,7 +222,8 @@ var async = require('async'),
|
||||
category: async.apply(Topics.getCategoryData, tid),
|
||||
threadTools: async.apply(plugins.fireHook, 'filter:topic.thread_tools', {topic: topicData, uid: uid, tools: []}),
|
||||
tags: async.apply(Topics.getTopicTagsObjects, tid),
|
||||
isFollowing: async.apply(Topics.isFollowing, [tid], uid)
|
||||
isFollowing: async.apply(Topics.isFollowing, [tid], uid),
|
||||
bookmark: async.apply(Topics.getUserBookmark, tid, uid)
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -233,6 +234,7 @@ var async = require('async'),
|
||||
topicData.thread_tools = results.threadTools.tools;
|
||||
topicData.tags = results.tags;
|
||||
topicData.isFollowing = results.isFollowing[0];
|
||||
topicData.bookmark = results.bookmark;
|
||||
|
||||
topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
|
||||
topicData.deleted = parseInt(topicData.deleted, 10) === 1;
|
||||
@@ -328,6 +330,14 @@ var async = require('async'),
|
||||
});
|
||||
}
|
||||
|
||||
Topics.getUserBookmark = function (tid, uid, callback) {
|
||||
db.sortedSetScore('topic:' + tid + ':bookmarks', uid, callback);
|
||||
};
|
||||
|
||||
Topics.setUserBookmark = function(tid, uid, index, callback) {
|
||||
db.sortedSetAdd('topic:' + tid + ':bookmarks', index, uid, callback);
|
||||
};
|
||||
|
||||
Topics.getTopicField = function(tid, field, callback) {
|
||||
db.getObjectField('topic:' + tid, field, callback);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user