mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-10 01:23:04 +01:00
fix: filter out non-asserted targets when sending ap messages, diff. getter method when passed-in ID is a remote category
This commit is contained in:
@@ -8,6 +8,7 @@ const { CronJob } = require('cron');
|
||||
const request = require('../request');
|
||||
const db = require('../database');
|
||||
const meta = require('../meta');
|
||||
const categories = require('../categories');
|
||||
const posts = require('../posts');
|
||||
const messaging = require('../messaging');
|
||||
const user = require('../user');
|
||||
@@ -114,8 +115,15 @@ ActivityPub.resolveInboxes = async (ids) => {
|
||||
}
|
||||
|
||||
await ActivityPub.actors.assert(ids);
|
||||
|
||||
// Remove non-asserted targets
|
||||
const exists = await db.isSortedSetMembers('usersRemote:lastCrawled', ids);
|
||||
ids = ids.filter((_, idx) => exists[idx]);
|
||||
|
||||
const isCategory = await db.exists(ids.map(id => `categoryRemote:${id}`));
|
||||
await batch.processArray(ids, async (currentIds) => {
|
||||
const usersData = await user.getUsersFields(currentIds, ['inbox', 'sharedInbox']);
|
||||
const method = isCategory ? categories.getCategoriesFields : user.getUsersFields;
|
||||
const usersData = await method(currentIds, ['inbox', 'sharedInbox']);
|
||||
usersData.forEach((u) => {
|
||||
if (u && (u.sharedInbox || u.inbox)) {
|
||||
inboxes.add(u.sharedInbox || u.inbox);
|
||||
|
||||
Reference in New Issue
Block a user