Node.js based forum software built for the modern web
fix: follower count going out of sync with real follower count
Barış Soner Uşaklı2bcf7f72d21c
diff --git a/src/user/follow.js b/src/user/follow.jsindex 9e37a62a8d..c8c281f927 100644--- a/src/user/follow.js+++ b/src/user/follow.js@@ -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) {