mirror of
https://github.com/Mintplex-Labs/anything-llm
synced 2026-04-25 17:15:37 +02:00
dedupe email items based on name
This commit is contained in:
@@ -123,15 +123,20 @@ async function parseAttachment(attachment) {
|
||||
|
||||
/**
|
||||
* Collect attachments from messages and optionally parse them with user approval.
|
||||
* Specific files may not show (images) and are pre-stripped by the app script.
|
||||
* If two attachments have the same name, only the first one will be kept (handling fwd emails)
|
||||
* @param {Object} context - The handler context (this) from the aibitat function
|
||||
* @param {Array} messages - Array of message objects (single message should be wrapped in array)
|
||||
* @returns {Promise<{allAttachments: Array, parsedContent: string}>}
|
||||
*/
|
||||
async function handleAttachments(context, messages) {
|
||||
const allAttachments = [];
|
||||
const uniqueAttachments = new Set();
|
||||
messages.forEach((msg, msgIndex) => {
|
||||
if (msg.attachments?.length > 0) {
|
||||
msg.attachments.forEach((att) => {
|
||||
if (uniqueAttachments.has(att.name)) return;
|
||||
uniqueAttachments.add(att.name);
|
||||
allAttachments.push({
|
||||
...att,
|
||||
messageIndex: msgIndex + 1,
|
||||
|
||||
@@ -364,9 +364,12 @@ function isParseableMimeType(contentType) {
|
||||
*/
|
||||
async function handleAttachments(context, messages) {
|
||||
const allAttachments = [];
|
||||
const uniqueAttachments = new Set();
|
||||
messages.forEach((msg, msgIndex) => {
|
||||
if (msg.attachments?.length > 0) {
|
||||
msg.attachments.forEach((att) => {
|
||||
if (uniqueAttachments.has(att.name)) return;
|
||||
uniqueAttachments.add(att.name);
|
||||
allAttachments.push({
|
||||
...att,
|
||||
messageIndex: msgIndex + 1,
|
||||
|
||||
Reference in New Issue
Block a user