fix: optimizations

- plugins.isActive response now cached in nconf
- public addresses filtered out of actor assertion logic during
  qualification stage
- bump mentions to fix db call with empty values
- update buildRecipients to exclude public addresses and local URIs when
  building targeting array
This commit is contained in:
Julian Lam
2026-01-21 12:04:53 -05:00
parent f9affbad58
commit e697d600d1
4 changed files with 23 additions and 8 deletions

View File

@@ -45,6 +45,9 @@ Actors.qualify = async (ids, options = {}) => {
// Filter out uids if passed in
ids = ids.filter(id => !utils.isNumber(id));
// Filter out constants
ids = ids.filter(id => !activitypub._constants.acceptablePublicAddresses.includes(id));
// Translate webfinger handles to uris
ids = (await Promise.all(ids.map(async (id) => {
const originalId = id;

View File

@@ -491,13 +491,23 @@ ActivityPub.buildRecipients = async function (object, { pid, uid, cid }) {
const targets = new Set([...followers, ...to, ...cc]);
// Remove any ids that aren't asserted actors
const exists = await db.isSortedSetMembers('usersRemote:lastCrawled', [...targets]);
Array.from(targets).forEach((uri, idx) => {
if (!exists[idx]) {
targets.delete(uri);
// Remove local uris, public addresses, and any ids that aren't asserted actors
targets.forEach((address) => {
if (address.startsWith(nconf.get('url'))) {
targets.delete(address);
}
});
ActivityPub._constants.acceptablePublicAddresses.forEach((address) => {
targets.delete(address);
});
if (targets.size) {
const exists = await db.isSortedSetMembers('usersRemote:lastCrawled', [...targets]);
Array.from(targets).forEach((uri, idx) => {
if (!exists[idx]) {
targets.delete(uri);
}
});
}
// Topic posters, post announcers and their followers
if (pid) {

View File

@@ -177,7 +177,9 @@ module.exports = function (Plugins) {
if (nconf.get('plugins:active')) {
return nconf.get('plugins:active');
}
return await db.getSortedSetRange('plugins:active', 0, -1);
const active = await db.getSortedSetRange('plugins:active', 0, -1);
nconf.set('plugins:active', active);
return active;
};
Plugins.autocomplete = async (fragment) => {