mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 08:31:22 +01:00
fix: isArray check
This commit is contained in:
committed by
Barış Soner Uşaklı
parent
893089709c
commit
224910b133
@@ -230,19 +230,29 @@ Actors.getLocalFollowers = async (id) => {
|
|||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
|
|
||||||
Actors.getLocalFollowCounts = async (actor) => {
|
Actors.getLocalFollowCounts = async (actors) => {
|
||||||
let followers = 0; // x local followers
|
const isArray = Array.isArray(actors);
|
||||||
let following = 0; // following x local users
|
if (!isArray) {
|
||||||
if (!activitypub.helpers.isUri(actor)) {
|
actors = [actors];
|
||||||
return { followers, following };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[followers, following] = await Promise.all([
|
const validActors = actors.filter(actor => activitypub.helpers.isUri(actor));
|
||||||
db.sortedSetCard(`followersRemote:${actor}`),
|
const followerKeys = validActors.map(actor => `followersRemote:${actor}`);
|
||||||
db.sortedSetCard(`followingRemote:${actor}`),
|
const followingKeys = validActors.map(actor => `followingRemote:${actor}`);
|
||||||
|
|
||||||
|
const [followersCounts, followingCounts] = await Promise.all([
|
||||||
|
db.sortedSetsCard(followerKeys),
|
||||||
|
db.sortedSetsCard(followingKeys),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return { followers, following };
|
const results = actors.map((actor, index) => {
|
||||||
|
if (!validActors.includes(actor)) {
|
||||||
|
return { followers: 0, following: 0 };
|
||||||
|
}
|
||||||
|
return { followers: followersCounts[index], following: followingCounts[index] };
|
||||||
|
});
|
||||||
|
|
||||||
|
return isArray ? results : results[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
Actors.remove = async (id) => {
|
Actors.remove = async (id) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user