From ea6e15bf08646084f3bbfbed596b662c5c9b0945 Mon Sep 17 00:00:00 2001 From: Opliko Date: Mon, 6 May 2024 22:52:48 +0200 Subject: [PATCH] refactor: use batch.processArray for sending AP messages --- src/activitypub/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/activitypub/index.js b/src/activitypub/index.js index 89d1fa0523..5c5fbb60b8 100644 --- a/src/activitypub/index.js +++ b/src/activitypub/index.js @@ -11,6 +11,7 @@ const user = require('../user'); const utils = require('../utils'); const ttl = require('../cache/ttl'); const lru = require('../cache/lru'); +const batch = require('../batch'); const requestCache = ttl({ ttl: 1000 * 60 * 5 }); // 5 minutes const ActivityPub = module.exports; @@ -302,5 +303,8 @@ ActivityPub.send = async (type, id, targets, payload) => { ...payload, }; - await Promise.all(inboxes.map(async uri => sendMessage(uri, id, type, payload))); + await batch.processArray( + inboxes, + async inboxBatch => Promise.all(inboxBatch.map(async uri => sendMessage(uri, id, type, payload))) + ); };