mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
fix(Gmail Trigger Node): Filter by labels not working (#5173)
⚡️added missing getLabels loadOptions
This commit is contained in:
parent
5426690791
commit
026f3a532d
|
@ -2,13 +2,21 @@ import { IPollFunctions } from 'n8n-core';
|
|||
|
||||
import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodeExecutionData,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
LoggerProxy as Logger,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { googleApiRequest, parseRawEmail, prepareQuery, simplifyOutput } from './GenericFunctions';
|
||||
import {
|
||||
googleApiRequest,
|
||||
googleApiRequestAllItems,
|
||||
parseRawEmail,
|
||||
prepareQuery,
|
||||
simplifyOutput,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
|
@ -186,6 +194,40 @@ export class GmailTrigger implements INodeType {
|
|||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
// Get all the labels to display them to user so that he 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;
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async poll(this: IPollFunctions): Promise<INodeExecutionData[][] | null> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
let responseData;
|
||||
|
|
Loading…
Reference in a new issue