mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
closes #2633
This commit is contained in:
@@ -124,7 +124,7 @@ SocketTopics.markTopicNotificationsRead = function(socket, tid, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SocketTopics.markAllRead = function(socket, data, callback) {
|
SocketTopics.markAllRead = function(socket, data, callback) {
|
||||||
topics.getUnreadTids(socket.uid, 0, -1, function(err, tids) {
|
topics.getLatestTidsFromSet('topics:recent', 0, -1, 'day', function(err, tids) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
@@ -182,32 +182,24 @@ SocketTopics.markAsUnreadForAll = function(socket, tids, callback) {
|
|||||||
},
|
},
|
||||||
function(cid, next) {
|
function(cid, next) {
|
||||||
user.isModerator(socket.uid, cid, next);
|
user.isModerator(socket.uid, cid, next);
|
||||||
}
|
},
|
||||||
], function(err, isMod) {
|
function(isMod, next) {
|
||||||
if (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isAdmin && !isMod) {
|
if (!isAdmin && !isMod) {
|
||||||
return next(new Error('[[error:no-privileges]]'));
|
return next(new Error('[[error:no-privileges]]'));
|
||||||
}
|
}
|
||||||
|
topics.markAsUnreadForAll(tid, next);
|
||||||
topics.markAsUnreadForAll(tid, function(err) {
|
},
|
||||||
if(err) {
|
function(next) {
|
||||||
return next(err);
|
topics.updateRecent(tid, Date.now(), next);
|
||||||
}
|
}
|
||||||
|
], next);
|
||||||
topics.updateRecent(tid, Date.now(), function(err) {
|
}, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
topics.pushUnreadCount(socket.uid);
|
topics.pushUnreadCount(socket.uid);
|
||||||
next();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}, callback);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketTopics.delete = function(socket, data, callback) {
|
SocketTopics.delete = function(socket, data, callback) {
|
||||||
|
|||||||
@@ -27,30 +27,26 @@ module.exports = function(Topics) {
|
|||||||
topics: []
|
topics: []
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.getUnreadTids(uid, start, stop, function(err, tids) {
|
async.waterfall([
|
||||||
if (err) {
|
function(next) {
|
||||||
return callback(err);
|
Topics.getUnreadTids(uid, start, stop, next);
|
||||||
}
|
},
|
||||||
|
function(tids, next) {
|
||||||
if (!tids.length) {
|
if (!tids.length) {
|
||||||
return callback(null, unreadTopics);
|
return next(null, []);
|
||||||
}
|
}
|
||||||
|
Topics.getTopicsByTids(tids, uid, next);
|
||||||
Topics.getTopicsByTids(tids, uid, function(err, topicData) {
|
},
|
||||||
if (err) {
|
function(topicData, next) {
|
||||||
return callback(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Array.isArray(topicData) || !topicData.length) {
|
if (!Array.isArray(topicData) || !topicData.length) {
|
||||||
return callback(null, unreadTopics);
|
return next(null, unreadTopics);
|
||||||
}
|
}
|
||||||
|
|
||||||
unreadTopics.topics = topicData;
|
unreadTopics.topics = topicData;
|
||||||
unreadTopics.nextStart = stop + 1;
|
unreadTopics.nextStart = stop + 1;
|
||||||
|
next(null, unreadTopics);
|
||||||
callback(null, unreadTopics);
|
}
|
||||||
});
|
], callback);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.getUnreadTids = function(uid, start, stop, callback) {
|
Topics.getUnreadTids = function(uid, start, stop, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user