mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-27 00:51:16 +01:00
perf: use batch in resolveInboxes
This commit is contained in:
@@ -20,6 +20,9 @@ const requestCache = ttl({
|
|||||||
max: 5000,
|
max: 5000,
|
||||||
ttl: 1000 * 60 * 5, // 5 minutes
|
ttl: 1000 * 60 * 5, // 5 minutes
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const urlHostname = nconf.get('url_parsed').hostname;
|
||||||
|
|
||||||
const ActivityPub = module.exports;
|
const ActivityPub = module.exports;
|
||||||
|
|
||||||
ActivityPub._constants = Object.freeze({
|
ActivityPub._constants = Object.freeze({
|
||||||
@@ -86,17 +89,21 @@ ActivityPub.resolveInboxes = async (ids) => {
|
|||||||
if (!meta.config.activitypubAllowLoopback) {
|
if (!meta.config.activitypubAllowLoopback) {
|
||||||
ids = ids.filter((id) => {
|
ids = ids.filter((id) => {
|
||||||
const { hostname } = new URL(id);
|
const { hostname } = new URL(id);
|
||||||
return hostname !== nconf.get('url_parsed').hostname;
|
return hostname !== urlHostname;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await ActivityPub.actors.assert(ids);
|
await ActivityPub.actors.assert(ids);
|
||||||
await Promise.all(ids.map(async (id) => {
|
await batch.processArray(ids, async (currentIds) => {
|
||||||
const { inbox, sharedInbox } = await user.getUserFields(id, ['inbox', 'sharedInbox']);
|
const usersData = await user.getUsersFields(currentIds, ['inbox', 'sharedInbox']);
|
||||||
if (sharedInbox || inbox) {
|
usersData.forEach((u) => {
|
||||||
inboxes.add(sharedInbox || inbox);
|
if (u && (u.sharedInbox || u.inbox)) {
|
||||||
}
|
inboxes.add(u.sharedInbox || u.inbox);
|
||||||
}));
|
}
|
||||||
|
});
|
||||||
|
}, {
|
||||||
|
batch: 500,
|
||||||
|
});
|
||||||
|
|
||||||
return Array.from(inboxes);
|
return Array.from(inboxes);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user