Merge branch 'develop' into 'develop'

Validate before delivering to keep federation working on valid inboxes

Closes #10677

See merge request firefish/firefish!10572
This commit is contained in:
Kainoa Kanter 2023-08-17 04:41:28 +00:00
commit ed1b5afa13

View file

@ -122,19 +122,31 @@ export default class DeliverManager {
) )
.forEach((recipe) => inboxes.add(recipe.to.inbox!)); .forEach((recipe) => inboxes.add(recipe.to.inbox!));
// Validate Inboxes first
const validInboxes = [];
for (const inbox of inboxes) {
try {
validInboxes.push({
inbox,
host: new URL(inbox).host,
});
} catch (error) {
console.error(error);
console.error(`Invalid Inbox ${inbox}`);
}
}
const instancesToSkip = await skippedInstances( const instancesToSkip = await skippedInstances(
// get (unique) list of hosts // get (unique) list of hosts
Array.from( Array.from(new Set(validInboxes.map((valid) => valid.host))),
new Set(Array.from(inboxes).map((inbox) => new URL(inbox).host)),
),
); );
// deliver // deliver
for (const inbox of inboxes) { for (const valid of validInboxes) {
// skip instances as indicated // skip instances as indicated
if (instancesToSkip.includes(new URL(inbox).host)) continue; if (instancesToSkip.includes(valid.host)) continue;
deliver(this.actor, this.activity, inbox); deliver(this.actor, this.activity, valid.inbox);
} }
} }
} }