refactor(federation): replace outbox hooks in dm.ts with queueDmRelay()
This commit is contained in:
@@ -21,7 +21,7 @@ import {
|
|||||||
import { sanitizeUser } from '../utils/sanitize.js';
|
import { sanitizeUser } from '../utils/sanitize.js';
|
||||||
import { deleteUploadFile, deleteAttachmentFiles } from '../utils/fileCleanup.js';
|
import { deleteUploadFile, deleteAttachmentFiles } from '../utils/fileCleanup.js';
|
||||||
import { fetchDmEmbedsForMessages, resolveEmbeds, reResolveEmbeds, embedRowToEmbed } from '../utils/embedResolver.js';
|
import { fetchDmEmbedsForMessages, resolveEmbeds, reResolveEmbeds, embedRowToEmbed } from '../utils/embedResolver.js';
|
||||||
import { appendMutationLog, queueOutboxEvent, buildRelayPayload, getDmParticipants } from '../utils/federationOutbox.js';
|
import { appendMutationLog, queueOutboxEvent, queueDmRelay } from '../utils/federationOutbox.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Batch-fetch reactions for a set of DM message IDs.
|
* Batch-fetch reactions for a set of DM message IDs.
|
||||||
@@ -971,13 +971,8 @@ export async function dmRoutes(app: FastifyInstance): Promise<void> {
|
|||||||
// Broadcast to all DM members (including those who closed the channel)
|
// Broadcast to all DM members (including those who closed the channel)
|
||||||
broadcastDmMessage(id, message);
|
broadcastDmMessage(id, message);
|
||||||
|
|
||||||
// Federation: log mutation and queue for relay
|
// Federation: queue for relay
|
||||||
appendMutationLog(messageId, id, 'create');
|
queueDmRelay(message, id, 'create');
|
||||||
const participants = getDmParticipants(id);
|
|
||||||
queueOutboxEvent(messageId, id, 'create', JSON.stringify({
|
|
||||||
message: { ...buildRelayPayload(message, message.user), attachments: [] },
|
|
||||||
participants,
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Resolve embeds asynchronously after responding
|
// Resolve embeds asynchronously after responding
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
@@ -1040,12 +1035,8 @@ export async function dmRoutes(app: FastifyInstance): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Federation: log mutation and queue for relay
|
// Federation: queue for relay
|
||||||
appendMutationLog(id, msg.dmChannelId, 'update');
|
queueDmRelay(updated, msg.dmChannelId, 'update');
|
||||||
queueOutboxEvent(id, msg.dmChannelId, 'update', JSON.stringify({
|
|
||||||
message: buildRelayPayload(updated, updated.user),
|
|
||||||
participants: getDmParticipants(msg.dmChannelId),
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Resolve new embeds asynchronously (old ones already deleted above)
|
// Resolve new embeds asynchronously (old ones already deleted above)
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user