misc fixes

handle spider uids properly
This commit is contained in:
Barış Soner Uşaklı
2018-11-12 00:20:44 -05:00
parent afa84023a2
commit 69bb3293ee
30 changed files with 122 additions and 104 deletions

View File

@@ -13,7 +13,7 @@ module.exports = function (User) {
User.auth = {};
User.auth.logAttempt = function (uid, ip, callback) {
if (!parseInt(uid, 10)) {
if (parseInt(uid, 10) <= 0) {
return setImmediate(callback);
}
async.waterfall([
@@ -49,8 +49,8 @@ module.exports = function (User) {
};
User.auth.getFeedToken = function (uid, callback) {
if (!uid) {
return callback();
if (parseInt(uid, 10) <= 0) {
return setImmediate(callback);
}
var token;
async.waterfall([

View File

@@ -18,7 +18,7 @@ module.exports = function (User) {
var deletesInProgress = {};
User.delete = function (callerUid, uid, callback) {
if (!parseInt(uid, 10)) {
if (parseInt(uid, 10) <= 0) {
return setImmediate(callback, new Error('[[error:invalid-uid]]'));
}
if (deletesInProgress[uid]) {

View File

@@ -15,7 +15,7 @@ module.exports = function (User) {
};
function toggleFollow(type, uid, theiruid, callback) {
if (!parseInt(uid, 10) || !parseInt(theiruid, 10)) {
if (parseInt(uid, 10) <= 0 || parseInt(theiruid, 10) <= 0) {
return callback(new Error('[[error:invalid-uid]]'));
}
@@ -71,8 +71,8 @@ module.exports = function (User) {
};
function getFollow(uid, type, start, stop, callback) {
if (!parseInt(uid, 10)) {
return callback(null, []);
if (parseInt(uid, 10) <= 0) {
return setImmediate(callback, null, []);
}
async.waterfall([
function (next) {
@@ -93,8 +93,8 @@ module.exports = function (User) {
}
User.isFollowing = function (uid, theirid, callback) {
if (!parseInt(uid, 10) || !parseInt(theirid, 10)) {
return callback(null, false);
if (parseInt(uid, 10) <= 0 || parseInt(theirid, 10) <= 0) {
return setImmediate(callback, null, false);
}
db.isSortedSetMember('following:' + uid, theirid, callback);
};

View File

@@ -13,8 +13,8 @@ var utils = require('../utils');
var UserNotifications = module.exports;
UserNotifications.get = function (uid, callback) {
if (!parseInt(uid, 10)) {
return callback(null, { read: [], unread: [] });
if (parseInt(uid, 10) <= 0) {
return setImmediate(callback, null, { read: [], unread: [] });
}
async.waterfall([
function (next) {
@@ -177,8 +177,8 @@ UserNotifications.getDailyUnread = function (uid, callback) {
};
UserNotifications.getUnreadCount = function (uid, callback) {
if (!parseInt(uid, 10)) {
return callback(null, 0);
if (parseInt(uid, 10) <= 0) {
return setImmediate(callback, null, 0);
}
async.waterfall([
@@ -240,8 +240,8 @@ UserNotifications.getUnreadByField = function (uid, field, values, callback) {
};
UserNotifications.deleteAll = function (uid, callback) {
if (!parseInt(uid, 10)) {
return callback();
if (parseInt(uid, 10) <= 0) {
return setImmediate(callback);
}
async.parallel([
function (next) {

View File

@@ -94,7 +94,7 @@ module.exports = function (User) {
User.incrementUserFieldBy(uid, 'postcount', value, next);
},
function (newpostcount, next) {
if (!parseInt(uid, 10)) {
if (parseInt(uid, 10) <= 0) {
return next();
}
db.sortedSetAdd('users:postcount', newpostcount, uid, next);

View File

@@ -10,7 +10,7 @@ var notifications = require('../notifications');
module.exports = function (User) {
User.getSettings = function (uid, callback) {
if (!parseInt(uid, 10)) {
if (parseInt(uid, 10) <= 0) {
return onSettingsLoaded(0, {}, callback);
}
@@ -181,7 +181,7 @@ module.exports = function (User) {
};
User.setSetting = function (uid, key, value, callback) {
if (!parseInt(uid, 10)) {
if (parseInt(uid, 10) <= 0) {
return setImmediate(callback);
}