refactor(federation): replace outbox hooks in events.ts with queueDmRelay()
This commit is contained in:
@@ -11,7 +11,7 @@ import { ACTIVITY_LIMITS } from '@backspace/shared/src/activities.js';
|
|||||||
import { sanitizeUser } from '../utils/sanitize.js';
|
import { sanitizeUser } from '../utils/sanitize.js';
|
||||||
import { deleteAttachmentFiles } from '../utils/fileCleanup.js';
|
import { deleteAttachmentFiles } from '../utils/fileCleanup.js';
|
||||||
import { resolveEmbeds, reResolveEmbeds, embedRowToEmbed } from '../utils/embedResolver.js';
|
import { resolveEmbeds, reResolveEmbeds, embedRowToEmbed } from '../utils/embedResolver.js';
|
||||||
import { appendMutationLog, queueOutboxEvent, buildRelayPayload, getDmParticipants } from '../utils/federationOutbox.js';
|
import { appendMutationLog, queueOutboxEvent, queueDmRelay } from '../utils/federationOutbox.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-evaluate SPEAK permission for all participants in voice channels
|
* Re-evaluate SPEAK permission for all participants in voice channels
|
||||||
@@ -886,13 +886,8 @@ function handleDmMessageCreate(event: Record<string, unknown>, userId: string):
|
|||||||
// Broadcast to all DM members (including those who closed the channel)
|
// Broadcast to all DM members (including those who closed the channel)
|
||||||
broadcastDmMessage(dmChannelId, dmMessage);
|
broadcastDmMessage(dmChannelId, dmMessage);
|
||||||
|
|
||||||
// Federation: log mutation and queue for relay
|
// Federation: queue for relay
|
||||||
appendMutationLog(messageId, dmChannelId, 'create');
|
queueDmRelay(dmMessage, dmChannelId, 'create');
|
||||||
const participants = getDmParticipants(dmChannelId);
|
|
||||||
queueOutboxEvent(messageId, dmChannelId, 'create', JSON.stringify({
|
|
||||||
message: { ...buildRelayPayload(dmMessage, dmMessage.user), attachments: [] },
|
|
||||||
participants,
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Resolve embeds asynchronously
|
// Resolve embeds asynchronously
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
@@ -992,12 +987,8 @@ function handleDmMessageEdit(event: Record<string, unknown>, userId: string): vo
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Federation: log mutation and queue for relay
|
// Federation: queue for relay
|
||||||
appendMutationLog(messageId, msg.dmChannelId, 'update');
|
queueDmRelay(updated, msg.dmChannelId, 'update');
|
||||||
queueOutboxEvent(messageId, 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