mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 04:02:42 +00:00
fix(discord): add media dedup production code for messaging tool pipeline
Wire media URL tracking through the embedded agent pipeline so that media already sent via messaging tools is not delivered again by the reply dispatcher. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
c7681c3cff
commit
838259331f
@@ -95,6 +95,31 @@ export function filterMessagingToolDuplicates(params: {
|
||||
return payloads.filter((payload) => !isMessagingToolDuplicate(payload.text ?? "", sentTexts));
|
||||
}
|
||||
|
||||
export function filterMessagingToolMediaDuplicates(params: {
|
||||
payloads: ReplyPayload[];
|
||||
sentMediaUrls: string[];
|
||||
}): ReplyPayload[] {
|
||||
const { payloads, sentMediaUrls } = params;
|
||||
if (sentMediaUrls.length === 0) {
|
||||
return payloads;
|
||||
}
|
||||
const sentSet = new Set(sentMediaUrls);
|
||||
return payloads.map((payload) => {
|
||||
const mediaUrl = payload.mediaUrl;
|
||||
const mediaUrls = payload.mediaUrls;
|
||||
const stripSingle = mediaUrl && sentSet.has(mediaUrl);
|
||||
const filteredUrls = mediaUrls?.filter((u) => !sentSet.has(u));
|
||||
if (!stripSingle && (!mediaUrls || filteredUrls?.length === mediaUrls.length)) {
|
||||
return payload; // No change
|
||||
}
|
||||
return {
|
||||
...payload,
|
||||
mediaUrl: stripSingle ? undefined : mediaUrl,
|
||||
mediaUrls: filteredUrls?.length ? filteredUrls : undefined,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeAccountId(value?: string): string | undefined {
|
||||
const trimmed = value?.trim();
|
||||
return trimmed ? trimmed.toLowerCase() : undefined;
|
||||
|
||||
Reference in New Issue
Block a user