mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
fixed #30
This commit is contained in:
11
src/user.js
11
src/user.js
@@ -749,7 +749,7 @@ var utils = require('./../public/src/utils.js'),
|
||||
get: function(uid, callback) {
|
||||
async.parallel({
|
||||
unread: function(next) {
|
||||
RDB.zrangebyscore('uid:' + uid + ':notifications:unread', 0, 10, function(err, nids) {
|
||||
RDB.zrevrangebyscore('uid:' + uid + ':notifications:unread', 10, 0, function(err, nids) {
|
||||
var unread = [];
|
||||
if (nids && nids.length > 0) {
|
||||
async.eachSeries(nids, function(nid, next) {
|
||||
@@ -764,7 +764,7 @@ var utils = require('./../public/src/utils.js'),
|
||||
});
|
||||
},
|
||||
read: function(next) {
|
||||
RDB.zrangebyscore('uid:' + uid + ':notifications:read', 0, 10, function(err, nids) {
|
||||
RDB.zrevrangebyscore('uid:' + uid + ':notifications:read', 10, 0, function(err, nids) {
|
||||
var read = [];
|
||||
if (nids && nids.length > 0) {
|
||||
async.eachSeries(nids, function(nid, next) {
|
||||
@@ -779,6 +779,13 @@ var utils = require('./../public/src/utils.js'),
|
||||
});
|
||||
}
|
||||
}, function(err, notifications) {
|
||||
// While maintaining score sorting, sort by time
|
||||
notifications.read.sort(function(a, b) {
|
||||
if (a.score === b.score) return (a.datetime - b.datetime) > 0 ? -1 : 1;
|
||||
});
|
||||
notifications.unread.sort(function(a, b) {
|
||||
if (a.score === b.score) return (a.datetime - b.datetime) > 0 ? -1 : 1;
|
||||
});
|
||||
callback(notifications);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -292,6 +292,9 @@ var express = require('express'),
|
||||
app.get('/api/:method/:id*', api_method);
|
||||
|
||||
app.all('/test', function(req, res) {
|
||||
notifications.create('normal 7', 5, '/topics/1', 'fteds', function(nid) {
|
||||
notifications.push(nid, 1);
|
||||
});
|
||||
res.send();
|
||||
});
|
||||
|
||||
@@ -300,7 +303,9 @@ var express = require('express'),
|
||||
app.get('/graph/users/:username/picture', function(req, res) {
|
||||
user.get_uid_by_username(req.params.username, function(uid) {
|
||||
if (uid == null) {
|
||||
res.send('{status:0}');
|
||||
res.json({
|
||||
status: 0
|
||||
});
|
||||
return;
|
||||
}
|
||||
user.getUserField(uid, 'picture', function(picture) {
|
||||
|
||||
Reference in New Issue
Block a user