Stop duplicate moderation replies at the source

This commit is contained in:
Meta Vens 2026-05-16 04:57:28 +01:00
commit 417019abab
10 changed files with 240 additions and 8 deletions

View file

@ -16,6 +16,7 @@ const {
ensureModerationStateStore,
getModerationStateLegacyJsonPath,
getModerationStateWorkingPath,
recordModerationDeliveryReceipt,
readModerationStateCursor,
setModerationStateCursor,
} = require(coreDistPath);
@ -77,6 +78,32 @@ async function main() {
});
return;
}
case "record-delivery-receipt": {
const sentAt = args["sent-at"];
if (typeof sentAt !== "string" || sentAt.trim().length === 0) {
throw new Error("record-delivery-receipt requires --sent-at.");
}
const state = await recordModerationDeliveryReceipt(paths, {
sentAt,
mode: args.mode ?? null,
transport: args.transport ?? null,
channelId: args["channel-id"] ?? null,
replyToMessageId: args["reply-to-message-id"] ?? null,
personaName: args["persona-name"] ?? null,
personaAvatarUrl: args["persona-avatar-url"] ?? null,
contentLength: args["content-length"] ? Number.parseInt(args["content-length"], 10) : null,
chunkCount: args["chunk-count"] ? Number.parseInt(args["chunk-count"], 10) : null,
preview: args.preview ?? null,
});
writeJson({
canonicalPath,
workingPath,
cursor: state.moderation_runtime?.cursor ?? null,
recentDeliveryReceipts: state.moderation_runtime?.recent_delivery_receipts ?? [],
});
return;
}
default:
throw new Error(`Unknown moderation-state-store command "${command}".`);
}