mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Handle comma separated binary properties (Gmail) (#1711)
This commit is contained in:
@@ -325,28 +325,29 @@ export class Gmail implements INodeType {
|
||||
|
||||
if (additionalFields.attachmentsUi) {
|
||||
const attachmentsUi = additionalFields.attachmentsUi as IDataObject;
|
||||
let attachmentsBinary = [];
|
||||
const attachmentsBinary = [];
|
||||
if (!isEmpty(attachmentsUi)) {
|
||||
if (attachmentsUi.hasOwnProperty('attachmentsBinary')
|
||||
&& !isEmpty(attachmentsUi.attachmentsBinary)
|
||||
&& items[i].binary) {
|
||||
// @ts-ignore
|
||||
attachmentsBinary = attachmentsUi.attachmentsBinary.map((value) => {
|
||||
if (items[i].binary!.hasOwnProperty(value.property)) {
|
||||
const aux: IAttachments = { name: '', content: '', type: '' };
|
||||
aux.name = items[i].binary![value.property].fileName || 'unknown';
|
||||
aux.content = items[i].binary![value.property].data;
|
||||
aux.type = items[i].binary![value.property].mimeType;
|
||||
return aux;
|
||||
for (const { property } of attachmentsUi.attachmentsBinary as IDataObject[]) {
|
||||
for (const binaryProperty of (property as string).split(',')) {
|
||||
if (items[i].binary![binaryProperty] !== undefined) {
|
||||
const binaryData = items[i].binary![binaryProperty];
|
||||
attachmentsBinary.push({
|
||||
name: binaryData.fileName || 'unknown',
|
||||
content: binaryData.data,
|
||||
type: binaryData.mimeType,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
qs = {
|
||||
userId: 'me',
|
||||
uploadType: 'media',
|
||||
};
|
||||
|
||||
attachmentsList = attachmentsBinary;
|
||||
}
|
||||
}
|
||||
@@ -408,32 +409,32 @@ export class Gmail implements INodeType {
|
||||
|
||||
if (additionalFields.attachmentsUi) {
|
||||
const attachmentsUi = additionalFields.attachmentsUi as IDataObject;
|
||||
let attachmentsBinary = [];
|
||||
const attachmentsBinary = [];
|
||||
if (!isEmpty(attachmentsUi)) {
|
||||
if (attachmentsUi.hasOwnProperty('attachmentsBinary')
|
||||
&& !isEmpty(attachmentsUi.attachmentsBinary)
|
||||
&& items[i].binary) {
|
||||
// @ts-ignore
|
||||
attachmentsBinary = attachmentsUi.attachmentsBinary.map((value) => {
|
||||
if (items[i].binary!.hasOwnProperty(value.property)) {
|
||||
const aux: IAttachments = { name: '', content: '', type: '' };
|
||||
aux.name = items[i].binary![value.property].fileName || 'unknown';
|
||||
aux.content = items[i].binary![value.property].data;
|
||||
aux.type = items[i].binary![value.property].mimeType;
|
||||
return aux;
|
||||
for (const { property } of attachmentsUi.attachmentsBinary as IDataObject[]) {
|
||||
for (const binaryProperty of (property as string).split(',')) {
|
||||
if (items[i].binary![binaryProperty] !== undefined) {
|
||||
const binaryData = items[i].binary![binaryProperty];
|
||||
attachmentsBinary.push({
|
||||
name: binaryData.fileName || 'unknown',
|
||||
content: binaryData.data,
|
||||
type: binaryData.mimeType,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
qs = {
|
||||
userId: 'me',
|
||||
uploadType: 'media',
|
||||
};
|
||||
|
||||
attachmentsList = attachmentsBinary;
|
||||
}
|
||||
}
|
||||
|
||||
// if no recipient is defined then grab the one who sent the email
|
||||
if (toStr === '') {
|
||||
endpoint = `/gmail/v1/users/me/messages/${id}`;
|
||||
@@ -500,7 +501,7 @@ export class Gmail implements INodeType {
|
||||
const dataPropertyNameDownload = additionalFields.dataPropertyAttachmentsPrefixName as string || 'attachment_';
|
||||
|
||||
nodeExecutionData = await parseRawEmail.call(this, responseData, dataPropertyNameDownload);
|
||||
} else {
|
||||
} else {
|
||||
nodeExecutionData = {
|
||||
json: responseData,
|
||||
};
|
||||
@@ -628,28 +629,29 @@ export class Gmail implements INodeType {
|
||||
|
||||
if (additionalFields.attachmentsUi) {
|
||||
const attachmentsUi = additionalFields.attachmentsUi as IDataObject;
|
||||
let attachmentsBinary = [];
|
||||
const attachmentsBinary = [];
|
||||
if (!isEmpty(attachmentsUi)) {
|
||||
if (attachmentsUi.hasOwnProperty('attachmentsBinary')
|
||||
&& !isEmpty(attachmentsUi.attachmentsBinary)
|
||||
&& items[i].binary) {
|
||||
// @ts-ignore
|
||||
attachmentsBinary = attachmentsUi.attachmentsBinary.map((value) => {
|
||||
if (items[i].binary!.hasOwnProperty(value.property)) {
|
||||
const aux: IAttachments = { name: '', content: '', type: '' };
|
||||
aux.name = items[i].binary![value.property].fileName || 'unknown';
|
||||
aux.content = items[i].binary![value.property].data;
|
||||
aux.type = items[i].binary![value.property].mimeType;
|
||||
return aux;
|
||||
for (const { property } of attachmentsUi.attachmentsBinary as IDataObject[]) {
|
||||
for (const binaryProperty of (property as string).split(',')) {
|
||||
if (items[i].binary![binaryProperty] !== undefined) {
|
||||
const binaryData = items[i].binary![binaryProperty];
|
||||
attachmentsBinary.push({
|
||||
name: binaryData.fileName || 'unknown',
|
||||
content: binaryData.data,
|
||||
type: binaryData.mimeType,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
qs = {
|
||||
userId: 'me',
|
||||
uploadType: 'media',
|
||||
};
|
||||
|
||||
attachmentsList = attachmentsBinary;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user