mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: follower count going out of sync with real follower count
This commit is contained in:
@@ -36,8 +36,6 @@ module.exports = function (User) {
|
||||
['following:' + uid, now, theiruid],
|
||||
['followers:' + theiruid, now, uid],
|
||||
]),
|
||||
User.incrementUserFieldBy(uid, 'followingCount', 1),
|
||||
User.incrementUserFieldBy(theiruid, 'followerCount', 1),
|
||||
]);
|
||||
} else {
|
||||
if (!isFollowing) {
|
||||
@@ -48,10 +46,17 @@ module.exports = function (User) {
|
||||
['following:' + uid, theiruid],
|
||||
['followers:' + theiruid, uid],
|
||||
]),
|
||||
User.decrementUserFieldBy(uid, 'followingCount', 1),
|
||||
User.decrementUserFieldBy(theiruid, 'followerCount', 1),
|
||||
]);
|
||||
}
|
||||
|
||||
const [followingCount, followerCount] = await Promise.all([
|
||||
db.sortedSetCard('following:' + uid),
|
||||
db.sortedSetCard('followers:' + theiruid),
|
||||
]);
|
||||
await Promise.all([
|
||||
User.setUserField(uid, 'followingCount', followingCount),
|
||||
User.setUserField(theiruid, 'followerCount', followerCount),
|
||||
]);
|
||||
}
|
||||
|
||||
User.getFollowing = async function (uid, start, stop) {
|
||||
|
||||
Reference in New Issue
Block a user