mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
changes bookmark storage to sortedset, gets uid from socket rather than being passed from client
This commit is contained in:
@@ -203,12 +203,11 @@ define('forum/topic', [
|
|||||||
|
|
||||||
if (!currentBookmark || parseInt(postIndex, 10) > parseInt(currentBookmark, 10)) {
|
if (!currentBookmark || parseInt(postIndex, 10) > parseInt(currentBookmark, 10)) {
|
||||||
if (app.user.uid) {
|
if (app.user.uid) {
|
||||||
var data = {
|
var payload = {
|
||||||
'tid': ajaxify.data.tid,
|
'tid': ajaxify.data.tid,
|
||||||
'uid': app.user.uid,
|
'index': postIndex
|
||||||
'postIndex': postIndex
|
};
|
||||||
}
|
socket.emit('topics.bookmark', payload, function(err) {
|
||||||
socket.emit('topics.bookmark', data, function(err) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.warn('Error saving bookmark:', err);
|
console.warn('Error saving bookmark:', err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,10 +96,9 @@ SocketTopics.postcount = function(socket, tid, callback) {
|
|||||||
topics.getTopicField(tid, 'postcount', callback);
|
topics.getTopicField(tid, 'postcount', callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketTopics.bookmark = function(socket, data, callback) {
|
SocketTopics.bookmark = function(socket, payload, callback) {
|
||||||
// data contains tid, uid, and postIndex
|
topics.setUserBookmark(payload.tid, socket.uid, payload.index, callback);
|
||||||
topics.setUserBookmark(data, callback);
|
};
|
||||||
}
|
|
||||||
|
|
||||||
SocketTopics.markAsRead = function(socket, tids, callback) {
|
SocketTopics.markAsRead = function(socket, tids, callback) {
|
||||||
if(!Array.isArray(tids) || !socket.uid) {
|
if(!Array.isArray(tids) || !socket.uid) {
|
||||||
|
|||||||
@@ -330,11 +330,11 @@ var async = require('async'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
Topics.getUserBookmark = function (tid, uid, callback) {
|
Topics.getUserBookmark = function (tid, uid, callback) {
|
||||||
db.getObjectField('topic:' + tid + ':bookmarks', uid, callback);
|
db.sortedSetScore('topic:' + tid + ':bookmarks', uid, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.setUserBookmark = function(data, callback) {
|
Topics.setUserBookmark = function(tid, uid, index, callback) {
|
||||||
db.setObjectField('topic:' + data.tid + ':bookmarks', data.uid, data.postIndex, callback);
|
db.sortedSetAdd('topic:' + tid + ':bookmarks', index, uid, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.getTopicField = function(tid, field, callback) {
|
Topics.getTopicField = function(tid, field, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user