Node.js based forum software built for the modern web
fix: store remote followed users count separately from local
Julian Lame794f1d2ceb9
diff --git a/src/controllers/activitypub/index.js b/src/controllers/activitypub/index.jsindex 1ecb86a697..d23081425c 100644--- a/src/controllers/activitypub/index.js+++ b/src/controllers/activitypub/index.js@@ -132,8 +132,10 @@ Controller.follow = async (req, res) => {});const now = Date.now();- await db.sortedSetAdd(`followingRemote:${req.uid}`, now, objectId);- await recountFollowing(req.uid);+ await Promise.all([+ db.sortedSetAdd(`followingRemote:${req.uid}`, now, objectId),+ db.incrObjectField(`user:${req.uid}`, 'followingRemoteCount'),+ ]);helpers.formatApiResponse(200, res);} catch (e) {@@ -152,19 +154,13 @@ Controller.unfollow = async (req, res) => {},});- await db.sortedSetRemove(`followingRemote:${req.uid}`, objectId);- await recountFollowing(req.uid);+ await Promise.all([+ db.sortedSetRemove(`followingRemote:${req.uid}`, objectId),+ db.decrObjectField(`user:${req.uid}`, 'followingRemoteCount'),+ ]);helpers.formatApiResponse(200, res);} catch (e) {helpers.formatApiResponse(400, res, e);}};--async function recountFollowing(uid) {- const [followingCount, followingRemoteCount] = await Promise.all([- db.sortedSetCard(`following:${uid}`),- db.sortedSetCard(`followingRemote:${uid}`),- ]);- await user.setUserField(uid, 'followingCount', followingCount + followingRemoteCount);-}