mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
test(Gmail Node): Add tests for Gmail node v1 (no-changelog) (#12461)
This commit is contained in:
@@ -9,6 +9,7 @@ import type {
|
||||
ILoadOptionsFunctions,
|
||||
INode,
|
||||
INodeExecutionData,
|
||||
INodePropertyOptions,
|
||||
IPollFunctions,
|
||||
IRequestOptions,
|
||||
JsonObject,
|
||||
@@ -637,3 +638,34 @@ export async function simplifyOutput(
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the labels to display them to user so that they can select them easily
|
||||
*/
|
||||
export async function getLabels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
||||
const labels = await googleApiRequestAllItems.call(
|
||||
this,
|
||||
'labels',
|
||||
'GET',
|
||||
'/gmail/v1/users/me/labels',
|
||||
);
|
||||
|
||||
for (const label of labels) {
|
||||
returnData.push({
|
||||
name: label.name,
|
||||
value: label.id,
|
||||
});
|
||||
}
|
||||
|
||||
return returnData.sort((a, b) => {
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
/* eslint-disable n8n-nodes-base/node-param-display-name-miscased */
|
||||
import { jsonParse } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
import labels from '../fixtures/labels.json';
|
||||
import messages from '../fixtures/messages.json';
|
||||
|
||||
describe('Test Gmail Node v1', () => {
|
||||
beforeAll(() => {
|
||||
jest
|
||||
.useFakeTimers({ doNotFake: ['setImmediate', 'nextTick'] })
|
||||
.setSystemTime(new Date('2024-12-16 12:34:56.789Z'));
|
||||
|
||||
nock.disableNetConnect();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.restore();
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
describe('Messages', () => {
|
||||
const gmailNock = nock('https://www.googleapis.com/gmail');
|
||||
|
||||
beforeAll(() => {
|
||||
gmailNock
|
||||
.get('/v1/users/me/messages')
|
||||
.query({
|
||||
includeSpamTrash: 'true',
|
||||
dataPropertyAttachmentsPrefixName: 'custom_attachment_',
|
||||
maxResults: '2',
|
||||
})
|
||||
.reply(200, { messages });
|
||||
gmailNock
|
||||
.get('/v1/users/me/messages/a1b2c3d4e5f6g7h8')
|
||||
.query({
|
||||
includeSpamTrash: 'true',
|
||||
dataPropertyAttachmentsPrefixName: 'custom_attachment_',
|
||||
maxResults: '2',
|
||||
format: 'raw',
|
||||
})
|
||||
.reply(200, {
|
||||
...messages[0],
|
||||
raw: 'TUlNRS1WZXJzaW9uOiAxLjANCkRhdGU6IEZyaSwgMTMgRGVjIDIwMjQgMTE6MTU6MDEgKzAxMDANCk1lc3NhZ2UtSUQ6IDxDQUVHQVByb3d1ZEduS1h4cXJoTWpPdXhhbVRoN3lBcmp3UDdPRDlVQnEtSnBrYjBYOXdAbWFpbC5nbWFpbC5jb20-DQpTdWJqZWN0OiBUZXN0IGRyYWZ0DQpGcm9tOiBub2RlIHFhIDxub2RlOHFhQGdtYWlsLmNvbT4NClRvOiB0ZXN0QGdtYWlsLmNvbQ0KQ29udGVudC1UeXBlOiBtdWx0aXBhcnQvYWx0ZXJuYXRpdmU7IGJvdW5kYXJ5PSIwMDAwMDAwMDAwMDA5ZDU4YjYwNjI5MjQxYTIyIg0KDQotLTAwMDAwMDAwMDAwMDlkNThiNjA2MjkyNDFhMjINCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD0iVVRGLTgiDQoNCmRyYWZ0IGJvZHkNCg0KLS0wMDAwMDAwMDAwMDA5ZDU4YjYwNjI5MjQxYTIyDQpDb250ZW50LVR5cGU6IHRleHQvaHRtbDsgY2hhcnNldD0iVVRGLTgiDQoNCjxkaXYgZGlyPSJsdHIiPmRyYWZ0IGJvZHk8YnI-PC9kaXY-DQoNCi0tMDAwMDAwMDAwMDAwOWQ1OGI2MDYyOTI0MWEyMi0t',
|
||||
});
|
||||
gmailNock
|
||||
.get('/v1/users/me/messages/z9y8x7w6v5u4t3s2')
|
||||
.query({
|
||||
includeSpamTrash: 'true',
|
||||
dataPropertyAttachmentsPrefixName: 'custom_attachment_',
|
||||
maxResults: '2',
|
||||
format: 'raw',
|
||||
})
|
||||
.reply(200, {
|
||||
...messages[1],
|
||||
raw: 'TUlNRS1WZXJzaW9uOiAxLjANCkRhdGU6IEZyaSwgMTMgRGVjIDIwMjQgMTE6MTU6MDEgKzAxMDANCk1lc3NhZ2UtSUQ6IDxDQUVHQVByb3d1ZEduS1h4cXJoTWpPdXhhbVRoN3lBcmp3UDdPRDlVQnEtSnBrYjBYOXdAbWFpbC5nbWFpbC5jb20-DQpTdWJqZWN0OiBUZXN0IGRyYWZ0DQpGcm9tOiBub2RlIHFhIDxub2RlOHFhQGdtYWlsLmNvbT4NClRvOiB0ZXN0QGdtYWlsLmNvbQ0KQ29udGVudC1UeXBlOiBtdWx0aXBhcnQvYWx0ZXJuYXRpdmU7IGJvdW5kYXJ5PSIwMDAwMDAwMDAwMDA5ZDU4YjYwNjI5MjQxYTIyIg0KDQotLTAwMDAwMDAwMDAwMDlkNThiNjA2MjkyNDFhMjINCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD0iVVRGLTgiDQoNCmRyYWZ0IGJvZHkNCg0KLS0wMDAwMDAwMDAwMDA5ZDU4YjYwNjI5MjQxYTIyDQpDb250ZW50LVR5cGU6IHRleHQvaHRtbDsgY2hhcnNldD0iVVRGLTgiDQoNCjxkaXYgZGlyPSJsdHIiPmRyYWZ0IGJvZHk8YnI-PC9kaXY-DQoNCi0tMDAwMDAwMDAwMDAwOWQ1OGI2MDYyOTI0MWEyMi0t',
|
||||
});
|
||||
gmailNock.delete('/v1/users/me/messages/test').reply(200, messages[0]);
|
||||
gmailNock
|
||||
.get('/v1/users/me/messages/test')
|
||||
.query({ format: 'raw' })
|
||||
.reply(200, {
|
||||
...messages[1],
|
||||
raw: 'TUlNRS1WZXJzaW9uOiAxLjANCkRhdGU6IEZyaSwgMTMgRGVjIDIwMjQgMTE6MTU6MDEgKzAxMDANCk1lc3NhZ2UtSUQ6IDxDQUVHQVByb3d1ZEduS1h4cXJoTWpPdXhhbVRoN3lBcmp3UDdPRDlVQnEtSnBrYjBYOXdAbWFpbC5nbWFpbC5jb20-DQpTdWJqZWN0OiBUZXN0IGRyYWZ0DQpGcm9tOiBub2RlIHFhIDxub2RlOHFhQGdtYWlsLmNvbT4NClRvOiB0ZXN0QGdtYWlsLmNvbQ0KQ29udGVudC1UeXBlOiBtdWx0aXBhcnQvYWx0ZXJuYXRpdmU7IGJvdW5kYXJ5PSIwMDAwMDAwMDAwMDA5ZDU4YjYwNjI5MjQxYTIyIg0KDQotLTAwMDAwMDAwMDAwMDlkNThiNjA2MjkyNDFhMjINCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD0iVVRGLTgiDQoNCmRyYWZ0IGJvZHkNCg0KLS0wMDAwMDAwMDAwMDA5ZDU4YjYwNjI5MjQxYTIyDQpDb250ZW50LVR5cGU6IHRleHQvaHRtbDsgY2hhcnNldD0iVVRGLTgiDQoNCjxkaXYgZGlyPSJsdHIiPmRyYWZ0IGJvZHk8YnI-PC9kaXY-DQoNCi0tMDAwMDAwMDAwMDAwOWQ1OGI2MDYyOTI0MWEyMi0t',
|
||||
});
|
||||
|
||||
gmailNock
|
||||
.post('/v1/users/me/messages/send')
|
||||
.query({ userId: 'me', uploadType: 'media' })
|
||||
.reply(200, messages[0]);
|
||||
});
|
||||
|
||||
testWorkflows(['nodes/Google/Gmail/test/v1/messages.workflow.json']);
|
||||
|
||||
it('should make the correct network calls', () => {
|
||||
gmailNock.done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Labels', () => {
|
||||
const gmailNock = nock('https://www.googleapis.com/gmail');
|
||||
|
||||
beforeAll(() => {
|
||||
gmailNock
|
||||
.post('/v1/users/me/labels', {
|
||||
labelListVisibility: 'labelShow',
|
||||
messageListVisibility: 'show',
|
||||
name: 'Test Label Name',
|
||||
})
|
||||
.reply(200, labels[0]);
|
||||
gmailNock.delete('/v1/users/me/labels/test-label-id').reply(200, labels[0]);
|
||||
gmailNock.get('/v1/users/me/labels/test-label-id').reply(200, labels[0]);
|
||||
gmailNock.get('/v1/users/me/labels').reply(200, {
|
||||
labels,
|
||||
});
|
||||
});
|
||||
|
||||
testWorkflows(['nodes/Google/Gmail/test/v1/labels.workflow.json']);
|
||||
|
||||
it('should make the correct network calls', () => {
|
||||
gmailNock.done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Message Labels', () => {
|
||||
const gmailNock = nock('https://www.googleapis.com/gmail');
|
||||
|
||||
beforeAll(() => {
|
||||
gmailNock
|
||||
.post('/v1/users/me/messages/test/modify', (body) => 'addLabelIds' in body)
|
||||
.reply(200, messages[0]);
|
||||
gmailNock
|
||||
.post('/v1/users/me/messages/test/modify', (body) => 'removeLabelIds' in body)
|
||||
.reply(200, messages[0]);
|
||||
});
|
||||
|
||||
testWorkflows(['nodes/Google/Gmail/test/v1/message-labels.workflow.json']);
|
||||
|
||||
it('should make the correct network calls', () => {
|
||||
gmailNock.done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Drafts', () => {
|
||||
const gmailNock = nock('https://www.googleapis.com/gmail');
|
||||
|
||||
beforeAll(() => {
|
||||
gmailNock
|
||||
.filteringRequestBody((body) => {
|
||||
try {
|
||||
const parsedBody = jsonParse<{ message: { raw: string; threadId: string } }>(body);
|
||||
const mail = Buffer.from(parsedBody.message.raw, 'base64').toString('utf-8');
|
||||
|
||||
// Remove dynamic fields from mail
|
||||
parsedBody.message.raw = Buffer.from(
|
||||
mail
|
||||
.replace(/boundary=".*"/g, 'boundary="--test-boundary"')
|
||||
.replace(/----.*/g, '----test-boundary')
|
||||
.replace(/Message-ID:.*/g, 'Message-ID: test-message-id'),
|
||||
'utf-8',
|
||||
).toString('base64');
|
||||
|
||||
return JSON.stringify(parsedBody);
|
||||
} catch (error) {
|
||||
return body;
|
||||
}
|
||||
})
|
||||
.post('/v1/users/me/drafts', {
|
||||
message: {
|
||||
raw: 'Q29udGVudC1UeXBlOiBtdWx0aXBhcnQvbWl4ZWQ7IGJvdW5kYXJ5PSItLXRlc3QtYm91bmRhcnkiDQpDYzogdGVzdF9jY0BuOG4uaW8NCkJjYzogdGVzdF9iY2NAbjhuLmlvDQpTdWJqZWN0OiBUZXN0IFN1YmplY3QNCk1lc3NhZ2UtSUQ6IHRlc3QtbWVzc2FnZS1pZA0KRGF0ZTogTW9uLCAxNiBEZWMgMjAyNCAxMjozNDo1NiArMDAwMA0KTUlNRS1WZXJzaW9uOiAxLjANCg0KLS0tLXRlc3QtYm91bmRhcnkNCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD11dGYtOA0KQ29udGVudC1UcmFuc2Zlci1FbmNvZGluZzogN2JpdA0KDQpUZXN0IE1lc3NhZ2UNCi0tLS10ZXN0LWJvdW5kYXJ5DQpDb250ZW50LVR5cGU6IGFwcGxpY2F0aW9uL2pzb247IG5hbWU9ZmlsZS5qc29uDQpDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiBiYXNlNjQNCkNvbnRlbnQtRGlzcG9zaXRpb246IGF0dGFjaG1lbnQ7IGZpbGVuYW1lPWZpbGUuanNvbg0KDQpXM3NpWVhSMFlXTm9iV1Z1ZENJNmRISjFaWDFkDQotLS0tdGVzdC1ib3VuZGFyeQ0K',
|
||||
},
|
||||
})
|
||||
.query({ userId: 'me', uploadType: 'media' })
|
||||
.reply(200, messages[0]);
|
||||
gmailNock.delete('/v1/users/me/drafts/test').reply(200, messages[0]);
|
||||
gmailNock
|
||||
.get('/v1/users/me/drafts/test')
|
||||
.query({ format: 'raw' })
|
||||
.reply(200, {
|
||||
message: {
|
||||
...messages[0],
|
||||
raw: 'TUlNRS1WZXJzaW9uOiAxLjANCkRhdGU6IEZyaSwgMTMgRGVjIDIwMjQgMTE6MTU6MDEgKzAxMDANCk1lc3NhZ2UtSUQ6IDxDQUVHQVByb3d1ZEduS1h4cXJoTWpPdXhhbVRoN3lBcmp3UDdPRDlVQnEtSnBrYjBYOXdAbWFpbC5nbWFpbC5jb20-DQpTdWJqZWN0OiBUZXN0IGRyYWZ0DQpGcm9tOiBub2RlIHFhIDxub2RlOHFhQGdtYWlsLmNvbT4NClRvOiB0ZXN0QGdtYWlsLmNvbQ0KQ29udGVudC1UeXBlOiBtdWx0aXBhcnQvYWx0ZXJuYXRpdmU7IGJvdW5kYXJ5PSIwMDAwMDAwMDAwMDA5ZDU4YjYwNjI5MjQxYTIyIg0KDQotLTAwMDAwMDAwMDAwMDlkNThiNjA2MjkyNDFhMjINCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD0iVVRGLTgiDQoNCmRyYWZ0IGJvZHkNCg0KLS0wMDAwMDAwMDAwMDA5ZDU4YjYwNjI5MjQxYTIyDQpDb250ZW50LVR5cGU6IHRleHQvaHRtbDsgY2hhcnNldD0iVVRGLTgiDQoNCjxkaXYgZGlyPSJsdHIiPmRyYWZ0IGJvZHk8YnI-PC9kaXY-DQoNCi0tMDAwMDAwMDAwMDAwOWQ1OGI2MDYyOTI0MWEyMi0t',
|
||||
},
|
||||
});
|
||||
gmailNock
|
||||
.get('/v1/users/me/drafts')
|
||||
.query({
|
||||
maxResults: 2,
|
||||
})
|
||||
.reply(200, { drafts: messages });
|
||||
gmailNock
|
||||
.get('/v1/users/me/drafts/a1b2c3d4e5f6g7h8')
|
||||
.query({
|
||||
maxResults: 2,
|
||||
format: 'raw',
|
||||
})
|
||||
.reply(200, {
|
||||
message: {
|
||||
...messages[0],
|
||||
raw: 'TUlNRS1WZXJzaW9uOiAxLjANCkRhdGU6IEZyaSwgMTMgRGVjIDIwMjQgMTE6MTU6MDEgKzAxMDANCk1lc3NhZ2UtSUQ6IDxDQUVHQVByb3d1ZEduS1h4cXJoTWpPdXhhbVRoN3lBcmp3UDdPRDlVQnEtSnBrYjBYOXdAbWFpbC5nbWFpbC5jb20-DQpTdWJqZWN0OiBUZXN0IGRyYWZ0DQpGcm9tOiBub2RlIHFhIDxub2RlOHFhQGdtYWlsLmNvbT4NClRvOiB0ZXN0QGdtYWlsLmNvbQ0KQ29udGVudC1UeXBlOiBtdWx0aXBhcnQvYWx0ZXJuYXRpdmU7IGJvdW5kYXJ5PSIwMDAwMDAwMDAwMDA5ZDU4YjYwNjI5MjQxYTIyIg0KDQotLTAwMDAwMDAwMDAwMDlkNThiNjA2MjkyNDFhMjINCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD0iVVRGLTgiDQoNCmRyYWZ0IGJvZHkNCg0KLS0wMDAwMDAwMDAwMDA5ZDU4YjYwNjI5MjQxYTIyDQpDb250ZW50LVR5cGU6IHRleHQvaHRtbDsgY2hhcnNldD0iVVRGLTgiDQoNCjxkaXYgZGlyPSJsdHIiPmRyYWZ0IGJvZHk8YnI-PC9kaXY-DQoNCi0tMDAwMDAwMDAwMDAwOWQ1OGI2MDYyOTI0MWEyMi0t',
|
||||
},
|
||||
});
|
||||
gmailNock
|
||||
.get('/v1/users/me/drafts/z9y8x7w6v5u4t3s2')
|
||||
.query({
|
||||
maxResults: 2,
|
||||
format: 'raw',
|
||||
})
|
||||
.reply(200, {
|
||||
message: {
|
||||
...messages[1],
|
||||
raw: 'TUlNRS1WZXJzaW9uOiAxLjANCkRhdGU6IEZyaSwgMTMgRGVjIDIwMjQgMTE6MTU6MDEgKzAxMDANCk1lc3NhZ2UtSUQ6IDxDQUVHQVByb3d1ZEduS1h4cXJoTWpPdXhhbVRoN3lBcmp3UDdPRDlVQnEtSnBrYjBYOXdAbWFpbC5nbWFpbC5jb20-DQpTdWJqZWN0OiBUZXN0IGRyYWZ0DQpGcm9tOiBub2RlIHFhIDxub2RlOHFhQGdtYWlsLmNvbT4NClRvOiB0ZXN0QGdtYWlsLmNvbQ0KQ29udGVudC1UeXBlOiBtdWx0aXBhcnQvYWx0ZXJuYXRpdmU7IGJvdW5kYXJ5PSIwMDAwMDAwMDAwMDA5ZDU4YjYwNjI5MjQxYTIyIg0KDQotLTAwMDAwMDAwMDAwMDlkNThiNjA2MjkyNDFhMjINCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD0iVVRGLTgiDQoNCmRyYWZ0IGJvZHkNCg0KLS0wMDAwMDAwMDAwMDA5ZDU4YjYwNjI5MjQxYTIyDQpDb250ZW50LVR5cGU6IHRleHQvaHRtbDsgY2hhcnNldD0iVVRGLTgiDQoNCjxkaXYgZGlyPSJsdHIiPmRyYWZ0IGJvZHk8YnI-PC9kaXY-DQoNCi0tMDAwMDAwMDAwMDAwOWQ1OGI2MDYyOTI0MWEyMi0t',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
testWorkflows(['nodes/Google/Gmail/test/v1/drafts.workflow.json']);
|
||||
|
||||
it('should make the correct network calls', () => {
|
||||
gmailNock.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,446 @@
|
||||
{
|
||||
"name": "Gmail v1 test - drafts",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [980, 560],
|
||||
"id": "388c50bd-918f-48d5-8fa2-eba4d3e36ab6",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "toJson",
|
||||
"options": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.convertToFile",
|
||||
"typeVersion": 1.1,
|
||||
"position": [1420, 860],
|
||||
"id": "1c1112be-de7c-441e-865c-48044601cb40",
|
||||
"name": "Attachment"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "0a4e38fe-ed38-400e-afb1-9d430f167d54",
|
||||
"name": "attachment",
|
||||
"value": true,
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 3.4,
|
||||
"position": [1200, 860],
|
||||
"id": "381ca2b8-026a-487a-9f5f-5ef2edb9aa1d",
|
||||
"name": "Edit Fields"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"subject": "Test Subject",
|
||||
"message": "Test Message",
|
||||
"additionalFields": {
|
||||
"ccList": ["test_cc@n8n.io"],
|
||||
"bccList": ["test_bcc@n8n.io"],
|
||||
"attachmentsUi": {
|
||||
"attachmentsBinary": [
|
||||
{
|
||||
"property": "data"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [1640, 860],
|
||||
"id": "0119d458-2782-4fea-abe9-8ac8cabe77aa",
|
||||
"name": "Gmail - Drafts - Create",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "getAll",
|
||||
"limit": 2,
|
||||
"additionalFields": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [1200, 260],
|
||||
"id": "94698cf7-7ce2-4d89-8b04-51c59acf3373",
|
||||
"name": "Gmail - Drafts - All",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "delete",
|
||||
"messageId": "test"
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [1200, 460],
|
||||
"id": "2b518238-3c18-4527-8315-5d2f5d664af7",
|
||||
"name": "Gmail - Drafts - Delete",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "get",
|
||||
"messageId": "test",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [1200, 660],
|
||||
"id": "9d33ea25-6866-4e74-9a53-042fbe70655a",
|
||||
"name": "Gmail - Drafts - Get",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Gmail - Drafts - All": [
|
||||
{
|
||||
"json": {
|
||||
"date": "2024-12-13T10:15:01.000Z",
|
||||
"from": {
|
||||
"html": "<span class=\"mp_address_group\"><span class=\"mp_address_name\">node qa</span> <<a href=\"mailto:node8qa@gmail.com\" class=\"mp_address_email\">node8qa@gmail.com</a>></span>",
|
||||
"text": "\"node qa\" <node8qa@gmail.com>",
|
||||
"value": [
|
||||
{
|
||||
"address": "node8qa@gmail.com",
|
||||
"name": "node qa"
|
||||
}
|
||||
]
|
||||
},
|
||||
"headers": {
|
||||
"content-type": "Content-Type: multipart/alternative; boundary=\"0000000000009d58b60629241a22\"",
|
||||
"date": "Date: Fri, 13 Dec 2024 11:15:01 +0100",
|
||||
"from": "From: node qa <node8qa@gmail.com>",
|
||||
"message-id": "Message-ID: <CAEGAProwudGnKXxqrhMjOuxamTh7yArjwP7OD9UBq-Jpkb0X9w@mail.gmail.com>",
|
||||
"mime-version": "MIME-Version: 1.0",
|
||||
"subject": "Subject: Test draft",
|
||||
"to": "To: test@gmail.com"
|
||||
},
|
||||
"html": "<div dir=\"ltr\">draft body<br></div>\n",
|
||||
"labelIds": ["UNREAD", "CATEGORY_PROMOTIONS", "INBOX"],
|
||||
"messageId": "a1b2c3d4e5f6g7h8",
|
||||
"sizeEstimate": 67890,
|
||||
"subject": "Test draft",
|
||||
"text": "draft body\n",
|
||||
"textAsHtml": "<p>draft body</p>",
|
||||
"threadId": "a1b2c3d4e5f6g7h8",
|
||||
"to": {
|
||||
"html": "<span class=\"mp_address_group\"><a href=\"mailto:test@gmail.com\" class=\"mp_address_email\">test@gmail.com</a></span>",
|
||||
"text": "test@gmail.com",
|
||||
"value": [
|
||||
{
|
||||
"address": "test@gmail.com",
|
||||
"name": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"date": "2024-12-13T10:15:01.000Z",
|
||||
"from": {
|
||||
"html": "<span class=\"mp_address_group\"><span class=\"mp_address_name\">node qa</span> <<a href=\"mailto:node8qa@gmail.com\" class=\"mp_address_email\">node8qa@gmail.com</a>></span>",
|
||||
"text": "\"node qa\" <node8qa@gmail.com>",
|
||||
"value": [
|
||||
{
|
||||
"address": "node8qa@gmail.com",
|
||||
"name": "node qa"
|
||||
}
|
||||
]
|
||||
},
|
||||
"headers": {
|
||||
"content-type": "Content-Type: multipart/alternative; boundary=\"0000000000009d58b60629241a22\"",
|
||||
"date": "Date: Fri, 13 Dec 2024 11:15:01 +0100",
|
||||
"from": "From: node qa <node8qa@gmail.com>",
|
||||
"message-id": "Message-ID: <CAEGAProwudGnKXxqrhMjOuxamTh7yArjwP7OD9UBq-Jpkb0X9w@mail.gmail.com>",
|
||||
"mime-version": "MIME-Version: 1.0",
|
||||
"subject": "Subject: Test draft",
|
||||
"to": "To: test@gmail.com"
|
||||
},
|
||||
"html": "<div dir=\"ltr\">draft body<br></div>\n",
|
||||
"labelIds": ["UNREAD", "CATEGORY_SOCIAL", "INBOX"],
|
||||
"messageId": "z9y8x7w6v5u4t3s2",
|
||||
"sizeEstimate": 54321,
|
||||
"subject": "Test draft",
|
||||
"text": "draft body\n",
|
||||
"textAsHtml": "<p>draft body</p>",
|
||||
"threadId": "z9y8x7w6v5u4t3s2",
|
||||
"to": {
|
||||
"html": "<span class=\"mp_address_group\"><a href=\"mailto:test@gmail.com\" class=\"mp_address_email\">test@gmail.com</a></span>",
|
||||
"text": "test@gmail.com",
|
||||
"value": [
|
||||
{
|
||||
"address": "test@gmail.com",
|
||||
"name": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"Gmail - Drafts - Create": [
|
||||
{
|
||||
"json": {
|
||||
"historyId": "54321",
|
||||
"id": "a1b2c3d4e5f6g7h8",
|
||||
"internalDate": "1733405400000",
|
||||
"labelIds": ["UNREAD", "CATEGORY_PROMOTIONS", "INBOX"],
|
||||
"payload": {
|
||||
"body": {
|
||||
"size": 0
|
||||
},
|
||||
"filename": "",
|
||||
"headers": [
|
||||
{
|
||||
"name": "Delivered-To",
|
||||
"value": "exampleuser@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Received",
|
||||
"value": "by 2001:db8::abcd with SMTP id xyz123abc456; Thu, 5 Dec 2024 08:30:00 -0800 (PST)"
|
||||
},
|
||||
{
|
||||
"name": "X-Google-Smtp-Source",
|
||||
"value": "ABC12345+EXAMPLE123456789"
|
||||
},
|
||||
{
|
||||
"name": "X-Received",
|
||||
"value": "by 192.0.2.1 with SMTP id 12345abc67890; Thu, 5 Dec 2024 08:30:00 -0800 (PST)"
|
||||
},
|
||||
{
|
||||
"name": "ARC-Seal",
|
||||
"value": "i=1; a=rsa-sha256; t=1733405400; cv=none; d=example.com; s=arc-20241205; b=ABCDEFG123456="
|
||||
},
|
||||
{
|
||||
"name": "ARC-Message-Signature",
|
||||
"value": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=arc-20241205; bh=EXAMPLEHASH12345="
|
||||
},
|
||||
{
|
||||
"name": "ARC-Authentication-Results",
|
||||
"value": "i=1; mx.example.com; dkim=pass header.i=@promotion.example.com; spf=pass smtp.mailfrom=promo@promotion.example.com; dmarc=pass header.from=example.com"
|
||||
},
|
||||
{
|
||||
"name": "Return-Path",
|
||||
"value": "<promo@promotion.example.com>"
|
||||
},
|
||||
{
|
||||
"name": "Date",
|
||||
"value": "Thu, 5 Dec 2024 08:30:00 -0800"
|
||||
},
|
||||
{
|
||||
"name": "From",
|
||||
"value": "Holiday Deals <promo@promotion.example.com>"
|
||||
},
|
||||
{
|
||||
"name": "To",
|
||||
"value": "exampleuser@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Message-ID",
|
||||
"value": "<12345abc67890@promotion.example.com>"
|
||||
},
|
||||
{
|
||||
"name": "Subject",
|
||||
"value": "Exclusive Holiday Discounts!"
|
||||
},
|
||||
{
|
||||
"name": "MIME-Version",
|
||||
"value": "1.0"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "multipart/alternative; boundary=\"----=_Part_12345_67890.1733405400000\""
|
||||
}
|
||||
],
|
||||
"mimeType": "multipart/alternative",
|
||||
"partId": "",
|
||||
"parts": [
|
||||
{
|
||||
"body": {
|
||||
"data": "VGhpcyBpcyBhbiBleGFtcGxlIG1lc3NhZ2UuIFRoYW5rIHlvdSBmb3Igc2hvcHBpbmcgd2l0aCB1cy4=",
|
||||
"size": 1234
|
||||
},
|
||||
"filename": "",
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "text/plain; charset=utf-8"
|
||||
},
|
||||
{
|
||||
"name": "Content-Transfer-Encoding",
|
||||
"value": "quoted-printable"
|
||||
}
|
||||
],
|
||||
"mimeType": "text/plain",
|
||||
"partId": "0"
|
||||
},
|
||||
{
|
||||
"body": {
|
||||
"data": "PGRpdiBzdHlsZT0nZm9udC1mYW1pbHk6IEFyaWFsLCBzYW5zLXNlcmlmOyc+VGhpcyBpcyBhbiBleGFtcGxlIGh0bWwgbWVzc2FnZS4gPGI+VGhhbmsgeW91IGZvciBzaG9wcGluZyB3aXRoIHVzLjwvYj48L2Rpdj4=",
|
||||
"size": 5678
|
||||
},
|
||||
"filename": "",
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "text/html; charset=\"utf-8\""
|
||||
},
|
||||
{
|
||||
"name": "Content-Transfer-Encoding",
|
||||
"value": "quoted-printable"
|
||||
}
|
||||
],
|
||||
"mimeType": "text/html",
|
||||
"partId": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sizeEstimate": 67890,
|
||||
"snippet": "Don't miss our exclusive holiday discounts on all items! Act now before the sale ends.",
|
||||
"threadId": "a1b2c3d4e5f6g7h8"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Gmail - Drafts - Delete": [{ "json": { "success": true } }],
|
||||
"Gmail - Drafts - Get": [
|
||||
{
|
||||
"json": {
|
||||
"date": "2024-12-13T10:15:01.000Z",
|
||||
"from": {
|
||||
"html": "<span class=\"mp_address_group\"><span class=\"mp_address_name\">node qa</span> <<a href=\"mailto:node8qa@gmail.com\" class=\"mp_address_email\">node8qa@gmail.com</a>></span>",
|
||||
"text": "\"node qa\" <node8qa@gmail.com>",
|
||||
"value": [
|
||||
{
|
||||
"address": "node8qa@gmail.com",
|
||||
"name": "node qa"
|
||||
}
|
||||
]
|
||||
},
|
||||
"headers": {
|
||||
"content-type": "Content-Type: multipart/alternative; boundary=\"0000000000009d58b60629241a22\"",
|
||||
"date": "Date: Fri, 13 Dec 2024 11:15:01 +0100",
|
||||
"from": "From: node qa <node8qa@gmail.com>",
|
||||
"message-id": "Message-ID: <CAEGAProwudGnKXxqrhMjOuxamTh7yArjwP7OD9UBq-Jpkb0X9w@mail.gmail.com>",
|
||||
"mime-version": "MIME-Version: 1.0",
|
||||
"subject": "Subject: Test draft",
|
||||
"to": "To: test@gmail.com"
|
||||
},
|
||||
"html": "<div dir=\"ltr\">draft body<br></div>\n",
|
||||
"labelIds": ["UNREAD", "CATEGORY_PROMOTIONS", "INBOX"],
|
||||
"messageId": "a1b2c3d4e5f6g7h8",
|
||||
"sizeEstimate": 67890,
|
||||
"subject": "Test draft",
|
||||
"text": "draft body\n",
|
||||
"textAsHtml": "<p>draft body</p>",
|
||||
"threadId": "a1b2c3d4e5f6g7h8",
|
||||
"to": {
|
||||
"html": "<span class=\"mp_address_group\"><a href=\"mailto:test@gmail.com\" class=\"mp_address_email\">test@gmail.com</a></span>",
|
||||
"text": "test@gmail.com",
|
||||
"value": [
|
||||
{
|
||||
"address": "test@gmail.com",
|
||||
"name": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Gmail - Drafts - All",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Gmail - Drafts - Delete",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Gmail - Drafts - Get",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Edit Fields",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Attachment": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Gmail - Drafts - Create",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Edit Fields": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Attachment",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "59109e41-be89-484a-b8d0-8f5c8f0407f9",
|
||||
"meta": {
|
||||
"templateCredsSetupCompleted": true,
|
||||
"instanceId": "cb484ba7b742928a2048bf8829668bed5b5ad9787579adea888f05980292a4a7"
|
||||
},
|
||||
"id": "dbQv4DRzYXIcTNNs",
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
{
|
||||
"name": "Gmail v1 test - labels",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [520, 200],
|
||||
"id": "d52d5cac-d1df-4581-bb97-c14d559a93ad",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "label",
|
||||
"operation": "getAll",
|
||||
"limit": 2
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [740, -100],
|
||||
"id": "48634d96-92f3-430f-9063-2e3784e5ba98",
|
||||
"name": "Gmail - Labels - All",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "label",
|
||||
"operation": "delete",
|
||||
"labelId": "test-label-id"
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [740, 100],
|
||||
"id": "3ddc7641-ae81-41f1-a987-d7b517f348ea",
|
||||
"name": "Gmail - Labels - Delete",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "label",
|
||||
"operation": "get",
|
||||
"labelId": "test-label-id"
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [740, 300],
|
||||
"id": "80443d2e-f1f5-4f30-aeb2-6eea23a7d888",
|
||||
"name": "Gmail - Labels - Get",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "label",
|
||||
"name": "Test Label Name"
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [740, 500],
|
||||
"id": "41efa86b-19f7-4acc-b118-e2f605b81c24",
|
||||
"name": "Gmail - Labels - Create",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Gmail - Labels - All": [
|
||||
{
|
||||
"json": {
|
||||
"id": "CHAT",
|
||||
"labelListVisibility": "labelHide",
|
||||
"messageListVisibility": "hide",
|
||||
"name": "CHAT",
|
||||
"type": "system"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": "SENT",
|
||||
"name": "SENT",
|
||||
"type": "system"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Gmail - Labels - Get": [
|
||||
{
|
||||
"json": {
|
||||
"id": "CHAT",
|
||||
"labelListVisibility": "labelHide",
|
||||
"messageListVisibility": "hide",
|
||||
"name": "CHAT",
|
||||
"type": "system"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Gmail - Labels - Delete": [{ "json": { "success": true } }],
|
||||
"Gmail - Labels - Create": [
|
||||
{
|
||||
"json": {
|
||||
"id": "CHAT",
|
||||
"labelListVisibility": "labelHide",
|
||||
"messageListVisibility": "hide",
|
||||
"name": "CHAT",
|
||||
"type": "system"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Gmail - Labels - All",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Gmail - Labels - Delete",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Gmail - Labels - Get",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Gmail - Labels - Create",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "59109e41-be89-484a-b8d0-8f5c8f0407f9",
|
||||
"meta": {
|
||||
"templateCredsSetupCompleted": true,
|
||||
"instanceId": "cb484ba7b742928a2048bf8829668bed5b5ad9787579adea888f05980292a4a7"
|
||||
},
|
||||
"id": "dbQv4DRzYXIcTNNs",
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
{
|
||||
"name": "Gmail v1 test - message labels",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [1220, 600],
|
||||
"id": "84b20fb7-d041-4a49-b7dc-8a09c1ac0071",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "messageLabel",
|
||||
"messageId": "test",
|
||||
"labelIds": "={{ ['label1', 'label2'] }}"
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [1440, 500],
|
||||
"id": "71a7716d-344b-4050-b2b8-f9f049e46642",
|
||||
"name": "Gmail - Message Labels - Add",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "messageLabel",
|
||||
"operation": "remove",
|
||||
"messageId": "test",
|
||||
"labelIds": "={{ ['label1', 'label2'] }}"
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [1440, 700],
|
||||
"id": "c92f2d14-f4a3-48d4-b59b-917d4670163d",
|
||||
"name": "Gmail - Message Labels - Delete",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Gmail - Message Labels - Add": [
|
||||
{
|
||||
"json": {
|
||||
"historyId": "54321",
|
||||
"id": "a1b2c3d4e5f6g7h8",
|
||||
"internalDate": "1733405400000",
|
||||
"labelIds": ["UNREAD", "CATEGORY_PROMOTIONS", "INBOX"],
|
||||
"payload": {
|
||||
"body": {
|
||||
"size": 0
|
||||
},
|
||||
"filename": "",
|
||||
"headers": [
|
||||
{
|
||||
"name": "Delivered-To",
|
||||
"value": "exampleuser@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Received",
|
||||
"value": "by 2001:db8::abcd with SMTP id xyz123abc456; Thu, 5 Dec 2024 08:30:00 -0800 (PST)"
|
||||
},
|
||||
{
|
||||
"name": "X-Google-Smtp-Source",
|
||||
"value": "ABC12345+EXAMPLE123456789"
|
||||
},
|
||||
{
|
||||
"name": "X-Received",
|
||||
"value": "by 192.0.2.1 with SMTP id 12345abc67890; Thu, 5 Dec 2024 08:30:00 -0800 (PST)"
|
||||
},
|
||||
{
|
||||
"name": "ARC-Seal",
|
||||
"value": "i=1; a=rsa-sha256; t=1733405400; cv=none; d=example.com; s=arc-20241205; b=ABCDEFG123456="
|
||||
},
|
||||
{
|
||||
"name": "ARC-Message-Signature",
|
||||
"value": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=arc-20241205; bh=EXAMPLEHASH12345="
|
||||
},
|
||||
{
|
||||
"name": "ARC-Authentication-Results",
|
||||
"value": "i=1; mx.example.com; dkim=pass header.i=@promotion.example.com; spf=pass smtp.mailfrom=promo@promotion.example.com; dmarc=pass header.from=example.com"
|
||||
},
|
||||
{
|
||||
"name": "Return-Path",
|
||||
"value": "<promo@promotion.example.com>"
|
||||
},
|
||||
{
|
||||
"name": "Date",
|
||||
"value": "Thu, 5 Dec 2024 08:30:00 -0800"
|
||||
},
|
||||
{
|
||||
"name": "From",
|
||||
"value": "Holiday Deals <promo@promotion.example.com>"
|
||||
},
|
||||
{
|
||||
"name": "To",
|
||||
"value": "exampleuser@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Message-ID",
|
||||
"value": "<12345abc67890@promotion.example.com>"
|
||||
},
|
||||
{
|
||||
"name": "Subject",
|
||||
"value": "Exclusive Holiday Discounts!"
|
||||
},
|
||||
{
|
||||
"name": "MIME-Version",
|
||||
"value": "1.0"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "multipart/alternative; boundary=\"----=_Part_12345_67890.1733405400000\""
|
||||
}
|
||||
],
|
||||
"mimeType": "multipart/alternative",
|
||||
"partId": "",
|
||||
"parts": [
|
||||
{
|
||||
"body": {
|
||||
"data": "VGhpcyBpcyBhbiBleGFtcGxlIG1lc3NhZ2UuIFRoYW5rIHlvdSBmb3Igc2hvcHBpbmcgd2l0aCB1cy4=",
|
||||
"size": 1234
|
||||
},
|
||||
"filename": "",
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "text/plain; charset=utf-8"
|
||||
},
|
||||
{
|
||||
"name": "Content-Transfer-Encoding",
|
||||
"value": "quoted-printable"
|
||||
}
|
||||
],
|
||||
"mimeType": "text/plain",
|
||||
"partId": "0"
|
||||
},
|
||||
{
|
||||
"body": {
|
||||
"data": "PGRpdiBzdHlsZT0nZm9udC1mYW1pbHk6IEFyaWFsLCBzYW5zLXNlcmlmOyc+VGhpcyBpcyBhbiBleGFtcGxlIGh0bWwgbWVzc2FnZS4gPGI+VGhhbmsgeW91IGZvciBzaG9wcGluZyB3aXRoIHVzLjwvYj48L2Rpdj4=",
|
||||
"size": 5678
|
||||
},
|
||||
"filename": "",
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "text/html; charset=\"utf-8\""
|
||||
},
|
||||
{
|
||||
"name": "Content-Transfer-Encoding",
|
||||
"value": "quoted-printable"
|
||||
}
|
||||
],
|
||||
"mimeType": "text/html",
|
||||
"partId": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sizeEstimate": 67890,
|
||||
"snippet": "Don't miss our exclusive holiday discounts on all items! Act now before the sale ends.",
|
||||
"threadId": "a1b2c3d4e5f6g7h8"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Gmail - Message Labels - Delete": [
|
||||
{
|
||||
"json": {
|
||||
"historyId": "54321",
|
||||
"id": "a1b2c3d4e5f6g7h8",
|
||||
"internalDate": "1733405400000",
|
||||
"labelIds": ["UNREAD", "CATEGORY_PROMOTIONS", "INBOX"],
|
||||
"payload": {
|
||||
"body": {
|
||||
"size": 0
|
||||
},
|
||||
"filename": "",
|
||||
"headers": [
|
||||
{
|
||||
"name": "Delivered-To",
|
||||
"value": "exampleuser@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Received",
|
||||
"value": "by 2001:db8::abcd with SMTP id xyz123abc456; Thu, 5 Dec 2024 08:30:00 -0800 (PST)"
|
||||
},
|
||||
{
|
||||
"name": "X-Google-Smtp-Source",
|
||||
"value": "ABC12345+EXAMPLE123456789"
|
||||
},
|
||||
{
|
||||
"name": "X-Received",
|
||||
"value": "by 192.0.2.1 with SMTP id 12345abc67890; Thu, 5 Dec 2024 08:30:00 -0800 (PST)"
|
||||
},
|
||||
{
|
||||
"name": "ARC-Seal",
|
||||
"value": "i=1; a=rsa-sha256; t=1733405400; cv=none; d=example.com; s=arc-20241205; b=ABCDEFG123456="
|
||||
},
|
||||
{
|
||||
"name": "ARC-Message-Signature",
|
||||
"value": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=arc-20241205; bh=EXAMPLEHASH12345="
|
||||
},
|
||||
{
|
||||
"name": "ARC-Authentication-Results",
|
||||
"value": "i=1; mx.example.com; dkim=pass header.i=@promotion.example.com; spf=pass smtp.mailfrom=promo@promotion.example.com; dmarc=pass header.from=example.com"
|
||||
},
|
||||
{
|
||||
"name": "Return-Path",
|
||||
"value": "<promo@promotion.example.com>"
|
||||
},
|
||||
{
|
||||
"name": "Date",
|
||||
"value": "Thu, 5 Dec 2024 08:30:00 -0800"
|
||||
},
|
||||
{
|
||||
"name": "From",
|
||||
"value": "Holiday Deals <promo@promotion.example.com>"
|
||||
},
|
||||
{
|
||||
"name": "To",
|
||||
"value": "exampleuser@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Message-ID",
|
||||
"value": "<12345abc67890@promotion.example.com>"
|
||||
},
|
||||
{
|
||||
"name": "Subject",
|
||||
"value": "Exclusive Holiday Discounts!"
|
||||
},
|
||||
{
|
||||
"name": "MIME-Version",
|
||||
"value": "1.0"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "multipart/alternative; boundary=\"----=_Part_12345_67890.1733405400000\""
|
||||
}
|
||||
],
|
||||
"mimeType": "multipart/alternative",
|
||||
"partId": "",
|
||||
"parts": [
|
||||
{
|
||||
"body": {
|
||||
"data": "VGhpcyBpcyBhbiBleGFtcGxlIG1lc3NhZ2UuIFRoYW5rIHlvdSBmb3Igc2hvcHBpbmcgd2l0aCB1cy4=",
|
||||
"size": 1234
|
||||
},
|
||||
"filename": "",
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "text/plain; charset=utf-8"
|
||||
},
|
||||
{
|
||||
"name": "Content-Transfer-Encoding",
|
||||
"value": "quoted-printable"
|
||||
}
|
||||
],
|
||||
"mimeType": "text/plain",
|
||||
"partId": "0"
|
||||
},
|
||||
{
|
||||
"body": {
|
||||
"data": "PGRpdiBzdHlsZT0nZm9udC1mYW1pbHk6IEFyaWFsLCBzYW5zLXNlcmlmOyc+VGhpcyBpcyBhbiBleGFtcGxlIGh0bWwgbWVzc2FnZS4gPGI+VGhhbmsgeW91IGZvciBzaG9wcGluZyB3aXRoIHVzLjwvYj48L2Rpdj4=",
|
||||
"size": 5678
|
||||
},
|
||||
"filename": "",
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "text/html; charset=\"utf-8\""
|
||||
},
|
||||
{
|
||||
"name": "Content-Transfer-Encoding",
|
||||
"value": "quoted-printable"
|
||||
}
|
||||
],
|
||||
"mimeType": "text/html",
|
||||
"partId": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sizeEstimate": 67890,
|
||||
"snippet": "Don't miss our exclusive holiday discounts on all items! Act now before the sale ends.",
|
||||
"threadId": "a1b2c3d4e5f6g7h8"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Gmail - Message Labels - Add",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Gmail - Message Labels - Delete",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "59109e41-be89-484a-b8d0-8f5c8f0407f9",
|
||||
"meta": {
|
||||
"templateCredsSetupCompleted": true,
|
||||
"instanceId": "cb484ba7b742928a2048bf8829668bed5b5ad9787579adea888f05980292a4a7"
|
||||
},
|
||||
"id": "dbQv4DRzYXIcTNNs",
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,456 @@
|
||||
{
|
||||
"name": "Gmail v1 test - messages",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [-600, 340],
|
||||
"id": "c72f4b22-a803-4b57-9edb-bde633a39f8e",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "message",
|
||||
"operation": "getAll",
|
||||
"limit": 2,
|
||||
"additionalFields": {
|
||||
"dataPropertyAttachmentsPrefixName": "custom_attachment_",
|
||||
"includeSpamTrash": true
|
||||
}
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [-380, 40],
|
||||
"id": "2b668b97-4b65-4484-9f35-9f147e3db2d1",
|
||||
"name": "Gmail - Messages - All",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "message",
|
||||
"subject": "Test Subject",
|
||||
"message": "Test Message",
|
||||
"toList": ["test_to@n8n.io"],
|
||||
"additionalFields": {
|
||||
"attachmentsUi": {
|
||||
"attachmentsBinary": [
|
||||
{
|
||||
"property": "data"
|
||||
}
|
||||
]
|
||||
},
|
||||
"bccList": ["test_bcc@n8n.io"],
|
||||
"ccList": ["test_cc@n8n.io"]
|
||||
}
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [60, 640],
|
||||
"id": "45dbeae7-d365-4f50-987f-e9b43aaa84aa",
|
||||
"name": "Gmail - Messages - Send",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "message",
|
||||
"operation": "delete",
|
||||
"messageId": "test"
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [-380, 240],
|
||||
"id": "0bad13bc-b34d-4f40-a709-854bf4a264a3",
|
||||
"name": "Gmail - Messages - Delete",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "message",
|
||||
"operation": "get",
|
||||
"messageId": "test",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.gmail",
|
||||
"typeVersion": 1,
|
||||
"position": [-380, 440],
|
||||
"id": "14123413-ba9c-4226-9013-2166e42a1adc",
|
||||
"name": "Gmail - Messages - Get",
|
||||
"webhookId": "f3cbddc1-3cfa-4217-aa73-f0e5a9309661",
|
||||
"credentials": {
|
||||
"gmailOAuth2": {
|
||||
"id": "22",
|
||||
"name": "Gmail 0auth"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "toJson",
|
||||
"options": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.convertToFile",
|
||||
"typeVersion": 1.1,
|
||||
"position": [-160, 640],
|
||||
"id": "a8ff6f8b-b23c-4d5a-b926-f0d8f8bdd34d",
|
||||
"name": "Attachment"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "0a4e38fe-ed38-400e-afb1-9d430f167d54",
|
||||
"name": "attachment",
|
||||
"value": true,
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 3.4,
|
||||
"position": [-380, 640],
|
||||
"id": "03736be9-7d2e-4a06-9911-b9cde3862a83",
|
||||
"name": "Edit Fields"
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Gmail - Messages - All": [
|
||||
{
|
||||
"json": {
|
||||
"date": "2024-12-13T10:15:01.000Z",
|
||||
"from": {
|
||||
"html": "<span class=\"mp_address_group\"><span class=\"mp_address_name\">node qa</span> <<a href=\"mailto:node8qa@gmail.com\" class=\"mp_address_email\">node8qa@gmail.com</a>></span>",
|
||||
"text": "\"node qa\" <node8qa@gmail.com>",
|
||||
"value": [
|
||||
{
|
||||
"address": "node8qa@gmail.com",
|
||||
"name": "node qa"
|
||||
}
|
||||
]
|
||||
},
|
||||
"headers": {
|
||||
"content-type": "Content-Type: multipart/alternative; boundary=\"0000000000009d58b60629241a22\"",
|
||||
"date": "Date: Fri, 13 Dec 2024 11:15:01 +0100",
|
||||
"from": "From: node qa <node8qa@gmail.com>",
|
||||
"message-id": "Message-ID: <CAEGAProwudGnKXxqrhMjOuxamTh7yArjwP7OD9UBq-Jpkb0X9w@mail.gmail.com>",
|
||||
"mime-version": "MIME-Version: 1.0",
|
||||
"subject": "Subject: Test draft",
|
||||
"to": "To: test@gmail.com"
|
||||
},
|
||||
"html": "<div dir=\"ltr\">draft body<br></div>\n",
|
||||
"id": "a1b2c3d4e5f6g7h8",
|
||||
"labelIds": ["UNREAD", "CATEGORY_PROMOTIONS", "INBOX"],
|
||||
"messageId": "<CAEGAProwudGnKXxqrhMjOuxamTh7yArjwP7OD9UBq-Jpkb0X9w@mail.gmail.com>",
|
||||
"sizeEstimate": 67890,
|
||||
"subject": "Test draft",
|
||||
"text": "draft body\n",
|
||||
"textAsHtml": "<p>draft body</p>",
|
||||
"threadId": "a1b2c3d4e5f6g7h8",
|
||||
"to": {
|
||||
"html": "<span class=\"mp_address_group\"><a href=\"mailto:test@gmail.com\" class=\"mp_address_email\">test@gmail.com</a></span>",
|
||||
"text": "test@gmail.com",
|
||||
"value": [
|
||||
{
|
||||
"address": "test@gmail.com",
|
||||
"name": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"date": "2024-12-13T10:15:01.000Z",
|
||||
"from": {
|
||||
"html": "<span class=\"mp_address_group\"><span class=\"mp_address_name\">node qa</span> <<a href=\"mailto:node8qa@gmail.com\" class=\"mp_address_email\">node8qa@gmail.com</a>></span>",
|
||||
"text": "\"node qa\" <node8qa@gmail.com>",
|
||||
"value": [
|
||||
{
|
||||
"address": "node8qa@gmail.com",
|
||||
"name": "node qa"
|
||||
}
|
||||
]
|
||||
},
|
||||
"headers": {
|
||||
"content-type": "Content-Type: multipart/alternative; boundary=\"0000000000009d58b60629241a22\"",
|
||||
"date": "Date: Fri, 13 Dec 2024 11:15:01 +0100",
|
||||
"from": "From: node qa <node8qa@gmail.com>",
|
||||
"message-id": "Message-ID: <CAEGAProwudGnKXxqrhMjOuxamTh7yArjwP7OD9UBq-Jpkb0X9w@mail.gmail.com>",
|
||||
"mime-version": "MIME-Version: 1.0",
|
||||
"subject": "Subject: Test draft",
|
||||
"to": "To: test@gmail.com"
|
||||
},
|
||||
"html": "<div dir=\"ltr\">draft body<br></div>\n",
|
||||
"id": "z9y8x7w6v5u4t3s2",
|
||||
"labelIds": ["UNREAD", "CATEGORY_SOCIAL", "INBOX"],
|
||||
"messageId": "<CAEGAProwudGnKXxqrhMjOuxamTh7yArjwP7OD9UBq-Jpkb0X9w@mail.gmail.com>",
|
||||
"sizeEstimate": 54321,
|
||||
"subject": "Test draft",
|
||||
"text": "draft body\n",
|
||||
"textAsHtml": "<p>draft body</p>",
|
||||
"threadId": "z9y8x7w6v5u4t3s2",
|
||||
"to": {
|
||||
"html": "<span class=\"mp_address_group\"><a href=\"mailto:test@gmail.com\" class=\"mp_address_email\">test@gmail.com</a></span>",
|
||||
"text": "test@gmail.com",
|
||||
"value": [
|
||||
{
|
||||
"address": "test@gmail.com",
|
||||
"name": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"Gmail - Messages - Send": [
|
||||
{
|
||||
"json": {
|
||||
"historyId": "54321",
|
||||
"id": "a1b2c3d4e5f6g7h8",
|
||||
"internalDate": "1733405400000",
|
||||
"labelIds": ["UNREAD", "CATEGORY_PROMOTIONS", "INBOX"],
|
||||
"payload": {
|
||||
"body": {
|
||||
"size": 0
|
||||
},
|
||||
"filename": "",
|
||||
"headers": [
|
||||
{
|
||||
"name": "Delivered-To",
|
||||
"value": "exampleuser@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Received",
|
||||
"value": "by 2001:db8::abcd with SMTP id xyz123abc456; Thu, 5 Dec 2024 08:30:00 -0800 (PST)"
|
||||
},
|
||||
{
|
||||
"name": "X-Google-Smtp-Source",
|
||||
"value": "ABC12345+EXAMPLE123456789"
|
||||
},
|
||||
{
|
||||
"name": "X-Received",
|
||||
"value": "by 192.0.2.1 with SMTP id 12345abc67890; Thu, 5 Dec 2024 08:30:00 -0800 (PST)"
|
||||
},
|
||||
{
|
||||
"name": "ARC-Seal",
|
||||
"value": "i=1; a=rsa-sha256; t=1733405400; cv=none; d=example.com; s=arc-20241205; b=ABCDEFG123456="
|
||||
},
|
||||
{
|
||||
"name": "ARC-Message-Signature",
|
||||
"value": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=arc-20241205; bh=EXAMPLEHASH12345="
|
||||
},
|
||||
{
|
||||
"name": "ARC-Authentication-Results",
|
||||
"value": "i=1; mx.example.com; dkim=pass header.i=@promotion.example.com; spf=pass smtp.mailfrom=promo@promotion.example.com; dmarc=pass header.from=example.com"
|
||||
},
|
||||
{
|
||||
"name": "Return-Path",
|
||||
"value": "<promo@promotion.example.com>"
|
||||
},
|
||||
{
|
||||
"name": "Date",
|
||||
"value": "Thu, 5 Dec 2024 08:30:00 -0800"
|
||||
},
|
||||
{
|
||||
"name": "From",
|
||||
"value": "Holiday Deals <promo@promotion.example.com>"
|
||||
},
|
||||
{
|
||||
"name": "To",
|
||||
"value": "exampleuser@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Message-ID",
|
||||
"value": "<12345abc67890@promotion.example.com>"
|
||||
},
|
||||
{
|
||||
"name": "Subject",
|
||||
"value": "Exclusive Holiday Discounts!"
|
||||
},
|
||||
{
|
||||
"name": "MIME-Version",
|
||||
"value": "1.0"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "multipart/alternative; boundary=\"----=_Part_12345_67890.1733405400000\""
|
||||
}
|
||||
],
|
||||
"mimeType": "multipart/alternative",
|
||||
"partId": "",
|
||||
"parts": [
|
||||
{
|
||||
"body": {
|
||||
"data": "VGhpcyBpcyBhbiBleGFtcGxlIG1lc3NhZ2UuIFRoYW5rIHlvdSBmb3Igc2hvcHBpbmcgd2l0aCB1cy4=",
|
||||
"size": 1234
|
||||
},
|
||||
"filename": "",
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "text/plain; charset=utf-8"
|
||||
},
|
||||
{
|
||||
"name": "Content-Transfer-Encoding",
|
||||
"value": "quoted-printable"
|
||||
}
|
||||
],
|
||||
"mimeType": "text/plain",
|
||||
"partId": "0"
|
||||
},
|
||||
{
|
||||
"body": {
|
||||
"data": "PGRpdiBzdHlsZT0nZm9udC1mYW1pbHk6IEFyaWFsLCBzYW5zLXNlcmlmOyc+VGhpcyBpcyBhbiBleGFtcGxlIGh0bWwgbWVzc2FnZS4gPGI+VGhhbmsgeW91IGZvciBzaG9wcGluZyB3aXRoIHVzLjwvYj48L2Rpdj4=",
|
||||
"size": 5678
|
||||
},
|
||||
"filename": "",
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "text/html; charset=\"utf-8\""
|
||||
},
|
||||
{
|
||||
"name": "Content-Transfer-Encoding",
|
||||
"value": "quoted-printable"
|
||||
}
|
||||
],
|
||||
"mimeType": "text/html",
|
||||
"partId": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sizeEstimate": 67890,
|
||||
"snippet": "Don't miss our exclusive holiday discounts on all items! Act now before the sale ends.",
|
||||
"threadId": "a1b2c3d4e5f6g7h8"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Gmail - Messages - Delete": [{ "json": { "success": true } }],
|
||||
"Gmail - Messages - Get": [
|
||||
{
|
||||
"json": {
|
||||
"date": "2024-12-13T10:15:01.000Z",
|
||||
"from": {
|
||||
"html": "<span class=\"mp_address_group\"><span class=\"mp_address_name\">node qa</span> <<a href=\"mailto:node8qa@gmail.com\" class=\"mp_address_email\">node8qa@gmail.com</a>></span>",
|
||||
"text": "\"node qa\" <node8qa@gmail.com>",
|
||||
"value": [
|
||||
{
|
||||
"address": "node8qa@gmail.com",
|
||||
"name": "node qa"
|
||||
}
|
||||
]
|
||||
},
|
||||
"headers": {
|
||||
"content-type": "Content-Type: multipart/alternative; boundary=\"0000000000009d58b60629241a22\"",
|
||||
"date": "Date: Fri, 13 Dec 2024 11:15:01 +0100",
|
||||
"from": "From: node qa <node8qa@gmail.com>",
|
||||
"message-id": "Message-ID: <CAEGAProwudGnKXxqrhMjOuxamTh7yArjwP7OD9UBq-Jpkb0X9w@mail.gmail.com>",
|
||||
"mime-version": "MIME-Version: 1.0",
|
||||
"subject": "Subject: Test draft",
|
||||
"to": "To: test@gmail.com"
|
||||
},
|
||||
"html": "<div dir=\"ltr\">draft body<br></div>\n",
|
||||
"id": "z9y8x7w6v5u4t3s2",
|
||||
"labelIds": ["UNREAD", "CATEGORY_SOCIAL", "INBOX"],
|
||||
"messageId": "<CAEGAProwudGnKXxqrhMjOuxamTh7yArjwP7OD9UBq-Jpkb0X9w@mail.gmail.com>",
|
||||
"sizeEstimate": 54321,
|
||||
"subject": "Test draft",
|
||||
"text": "draft body\n",
|
||||
"textAsHtml": "<p>draft body</p>",
|
||||
"threadId": "z9y8x7w6v5u4t3s2",
|
||||
"to": {
|
||||
"html": "<span class=\"mp_address_group\"><a href=\"mailto:test@gmail.com\" class=\"mp_address_email\">test@gmail.com</a></span>",
|
||||
"text": "test@gmail.com",
|
||||
"value": [
|
||||
{
|
||||
"address": "test@gmail.com",
|
||||
"name": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Gmail - Messages - All",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Gmail - Messages - Delete",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Gmail - Messages - Get",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Edit Fields",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Attachment": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Gmail - Messages - Send",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Edit Fields": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Attachment",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "790b1b2e-c8aa-4d10-b758-017944e6cf51",
|
||||
"meta": {
|
||||
"instanceId": "cb484ba7b742928a2048bf8829668bed5b5ad9787579adea888f05980292a4a7"
|
||||
},
|
||||
"id": "dbQv4DRzYXIcTNNs",
|
||||
"tags": []
|
||||
}
|
||||
@@ -5,15 +5,17 @@ import nock from 'nock';
|
||||
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
import labels from './fixtures/labels.json';
|
||||
import messages from './fixtures/messages.json';
|
||||
import { getGmailAliases, getLabels, getThreadMessages } from '../../v2/loadOptions';
|
||||
import labels from '../fixtures/labels.json';
|
||||
import messages from '../fixtures/messages.json';
|
||||
|
||||
describe('Test Gmail Node v2', () => {
|
||||
beforeAll(() => {
|
||||
jest
|
||||
.useFakeTimers({ doNotFake: ['setImmediate', 'nextTick'] })
|
||||
.setSystemTime(new Date('2024-12-16 12:34:56.789Z'));
|
||||
|
||||
nock.disableNetConnect();
|
||||
});
|
||||
|
||||
describe('Messages', () => {
|
||||
|
||||
@@ -5,9 +5,7 @@ import {
|
||||
type IDataObject,
|
||||
type IExecuteFunctions,
|
||||
type IHttpRequestMethods,
|
||||
type ILoadOptionsFunctions,
|
||||
type INodeExecutionData,
|
||||
type INodePropertyOptions,
|
||||
type INodeType,
|
||||
type INodeTypeBaseDescription,
|
||||
type INodeTypeDescription,
|
||||
@@ -17,6 +15,7 @@ import { oldVersionNotice } from '@utils/descriptions';
|
||||
|
||||
import { draftFields, draftOperations } from './DraftDescription';
|
||||
import { labelFields, labelOperations } from './LabelDescription';
|
||||
import { getLabels } from './loadOptions';
|
||||
import { messageFields, messageOperations } from './MessageDescription';
|
||||
import { messageLabelFields, messageLabelOperations } from './MessageLabelDescription';
|
||||
import type { IEmail } from '../../../../utils/sendAndWait/interfaces';
|
||||
@@ -141,32 +140,7 @@ export class GmailV1 implements INodeType {
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
// Get all the labels to display them to user so that they can
|
||||
// select them easily
|
||||
async getLabels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const labels = await googleApiRequestAllItems.call(
|
||||
this,
|
||||
'labels',
|
||||
'GET',
|
||||
'/gmail/v1/users/me/labels',
|
||||
);
|
||||
for (const label of labels) {
|
||||
returnData.push({
|
||||
name: label.name,
|
||||
value: label.id,
|
||||
});
|
||||
}
|
||||
return returnData.sort((a, b) => {
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
},
|
||||
getLabels,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
3
packages/nodes-base/nodes/Google/Gmail/v1/loadOptions.ts
Normal file
3
packages/nodes-base/nodes/Google/Gmail/v1/loadOptions.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { getLabels } from '../GenericFunctions';
|
||||
|
||||
export { getLabels };
|
||||
@@ -1,37 +1,6 @@
|
||||
import type { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
||||
|
||||
import { googleApiRequest, googleApiRequestAllItems } from '../GenericFunctions';
|
||||
|
||||
/**
|
||||
* Get all the labels to display them to user so that they can select them easily
|
||||
*/
|
||||
export async function getLabels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
||||
const labels = await googleApiRequestAllItems.call(
|
||||
this,
|
||||
'labels',
|
||||
'GET',
|
||||
'/gmail/v1/users/me/labels',
|
||||
);
|
||||
|
||||
for (const label of labels) {
|
||||
returnData.push({
|
||||
name: label.name,
|
||||
value: label.id,
|
||||
});
|
||||
}
|
||||
|
||||
return returnData.sort((a, b) => {
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
import { googleApiRequest, getLabels } from '../GenericFunctions';
|
||||
|
||||
export async function getThreadMessages(
|
||||
this: ILoadOptionsFunctions,
|
||||
@@ -73,3 +42,5 @@ export async function getGmailAliases(
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export { getLabels };
|
||||
|
||||
Reference in New Issue
Block a user