mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(Gmail Trigger Node): Handle self-sent emails in inbox (#19351)
Co-authored-by: riascho <123465523+riascho@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
61029ef4f8
commit
47f1d14b66
@@ -326,8 +326,11 @@ export class GmailTrigger implements INodeType {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
if (node.typeVersion > 1.2 && fullMessage.labelIds?.includes('SENT')) {
|
node.typeVersion > 1.2 &&
|
||||||
|
fullMessage.labelIds?.includes('SENT') &&
|
||||||
|
!fullMessage.labelIds?.includes('INBOX')
|
||||||
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -379,4 +379,56 @@ describe('GmailTrigger', () => {
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not skip emails that were sent to own account', async () => {
|
||||||
|
const messageListResponse: MessageListResponse = {
|
||||||
|
messages: [createListMessage({ id: '1' }), createListMessage({ id: '2' })],
|
||||||
|
resultSizeEstimate: 2,
|
||||||
|
};
|
||||||
|
nock(baseUrl)
|
||||||
|
.get('/gmail/v1/users/me/labels')
|
||||||
|
.reply(200, {
|
||||||
|
labels: [
|
||||||
|
{ id: 'INBOX', name: 'INBOX' },
|
||||||
|
{ id: 'SENT', name: 'SENT' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
nock(baseUrl).get(new RegExp('/gmail/v1/users/me/messages?.*')).reply(200, messageListResponse);
|
||||||
|
nock(baseUrl)
|
||||||
|
.get(new RegExp('/gmail/v1/users/me/messages/1?.*'))
|
||||||
|
.reply(200, createMessage({ id: '1', labelIds: ['INBOX', 'SENT'] }));
|
||||||
|
nock(baseUrl)
|
||||||
|
.get(new RegExp('/gmail/v1/users/me/messages/2?.*'))
|
||||||
|
.reply(200, createMessage({ id: '2', labelIds: ['SENT'] }));
|
||||||
|
|
||||||
|
const { response } = await testPollingTriggerNode(GmailTrigger);
|
||||||
|
expect(response).toEqual([
|
||||||
|
[
|
||||||
|
{
|
||||||
|
binary: undefined,
|
||||||
|
json: {
|
||||||
|
attachements: undefined,
|
||||||
|
date: '2024-08-31T00:00:00.000Z',
|
||||||
|
from: {
|
||||||
|
html: 'from@example.com',
|
||||||
|
text: 'from@example.com',
|
||||||
|
value: [{ address: 'from@example.com', name: 'From' }],
|
||||||
|
},
|
||||||
|
headerlines: undefined,
|
||||||
|
headers: { headerKey: 'headerValue' },
|
||||||
|
html: '<p>test</p>',
|
||||||
|
id: '1',
|
||||||
|
labelIds: ['INBOX', 'SENT'],
|
||||||
|
sizeEstimate: 4,
|
||||||
|
threadId: 'testThreadId',
|
||||||
|
to: {
|
||||||
|
html: 'to@example.com',
|
||||||
|
text: 'to@example.com',
|
||||||
|
value: [{ address: 'to@example.com', name: 'To' }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user