mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(federation): ✨ Add queue to note delivery
This commit is contained in:
parent
3ef361f521
commit
8a920218ea
4 changed files with 51 additions and 16 deletions
|
|
@ -41,6 +41,7 @@ import {
|
|||
parseTextMentions,
|
||||
} from "~/classes/functions/status";
|
||||
import { config } from "~/packages/config-manager";
|
||||
import { DeliveryJobType, deliveryQueue } from "~/worker.ts";
|
||||
import { Application } from "./application.ts";
|
||||
import { Attachment } from "./attachment.ts";
|
||||
import { BaseInterface } from "./base.ts";
|
||||
|
|
@ -310,9 +311,16 @@ export class Note extends BaseInterface<typeof Notes, NoteTypeWithRelations> {
|
|||
public async federateToUsers(): Promise<void> {
|
||||
const users = await this.getUsersToFederateTo();
|
||||
|
||||
for (const user of users) {
|
||||
await this.author.federateToUser(this.toVersia(), user);
|
||||
}
|
||||
await deliveryQueue.addBulk(
|
||||
users.map((user) => ({
|
||||
data: {
|
||||
entity: this.toVersia(),
|
||||
recipientId: user.id,
|
||||
senderId: this.author.id,
|
||||
},
|
||||
name: DeliveryJobType.FederateEntity,
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1015,9 +1015,9 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
|||
},
|
||||
);
|
||||
} catch (e) {
|
||||
getLogger(["federation", "outbox"])
|
||||
getLogger(["federation", "delivery"])
|
||||
.error`Federating ${chalk.gray(entity.type)} to ${user.getUri()} ${chalk.bold.red("failed")}`;
|
||||
getLogger(["federation", "outbox"]).error`${e}`;
|
||||
getLogger(["federation", "delivery"]).error`${e}`;
|
||||
sentry?.captureException(e);
|
||||
|
||||
return { ok: false };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue