forked from FoundKeyGang/FoundKey
server: add function to deliver multiple activities to a relay
This commit is contained in:
parent
e52cf25489
commit
383ea40704
1 changed files with 18 additions and 0 deletions
|
@ -105,3 +105,21 @@ export async function deliverToRelays(user: { id: User['id']; host: null; }, act
|
||||||
deliver(user, signed, relay.inbox);
|
deliver(user, signed, relay.inbox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function deliverMultipleToRelays(user: User, activities: any[]): Promise<void> {
|
||||||
|
if (activities.length === 0) return;
|
||||||
|
|
||||||
|
const relays = await relaysCache.fetch('');
|
||||||
|
if (relays == null || relays.length === 0) return;
|
||||||
|
|
||||||
|
const content = await Promise.all(activities.map(activity => {
|
||||||
|
const copy = structuredClone(activity);
|
||||||
|
if (!copy.to) copy.to = ['https://www.w3.org/ns/activitystreams#Public'];
|
||||||
|
|
||||||
|
return attachLdSignature(copy, user);
|
||||||
|
}));
|
||||||
|
|
||||||
|
for (const relay of relays) {
|
||||||
|
deliver(user, content, relay.inbox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue