fix(Google Calendar Node): Errors with after/before options (#8628)

This commit is contained in:
Michael Kret
2024-02-19 16:52:21 +02:00
committed by GitHub
parent 40c7f77a35
commit bee17dd6cc
3 changed files with 75 additions and 24 deletions

View File

@@ -14,6 +14,7 @@ import moment from 'moment-timezone';
import { v4 as uuid } from 'uuid';
import {
addNextOccurrence,
addTimezoneToDate,
encodeURIComponentOnce,
getCalendars,
getTimezones,
@@ -33,7 +34,7 @@ export class GoogleCalendar implements INodeType {
name: 'googleCalendar',
icon: 'file:googleCalendar.svg',
group: ['input'],
version: 1,
version: [1, 1.1],
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume Google Calendar API',
defaults: {
@@ -69,6 +70,13 @@ export class GoogleCalendar implements INodeType {
...calendarFields,
...eventOperations,
...eventFields,
{
displayName:
'This node will use the time zone set in n8ns settings, but you can override this in the workflow settings',
name: 'useN8nTimeZone',
type: 'notice',
default: '',
},
],
};
@@ -127,9 +135,12 @@ export class GoogleCalendar implements INodeType {
const length = items.length;
const qs: IDataObject = {};
let responseData;
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
const timezone = this.getTimezone();
const nodeVersion = this.getNode().typeVersion;
for (let i = 0; i < length; i++) {
try {
if (resource === 'calendar') {
@@ -414,16 +425,16 @@ export class GoogleCalendar implements INodeType {
qs.singleEvents = options.singleEvents as boolean;
}
if (options.timeMax) {
qs.timeMax = options.timeMax as string;
qs.timeMax = addTimezoneToDate(options.timeMax as string, tz || timezone);
}
if (options.timeMin) {
qs.timeMin = options.timeMin as string;
qs.timeMin = addTimezoneToDate(options.timeMin as string, tz || timezone);
}
if (tz) {
qs.timeZone = tz;
}
if (options.updatedMin) {
qs.updatedMin = options.updatedMin as string;
qs.updatedMin = addTimezoneToDate(options.updatedMin as string, tz || timezone);
}
if (returnAll) {
responseData = await googleApiRequestAllItems.call(
@@ -458,7 +469,11 @@ export class GoogleCalendar implements INodeType {
const eventId = this.getNodeParameter('eventId', i) as string;
const useDefaultReminders = this.getNodeParameter('useDefaultReminders', i) as boolean;
const updateFields = this.getNodeParameter('updateFields', i);
const updateTimezone = updateFields.timezone as string;
let updateTimezone = updateFields.timezone as string;
if (nodeVersion > 1 && updateTimezone === undefined) {
updateTimezone = timezone;
}
if (updateFields.maxAttendees) {
qs.maxAttendees = updateFields.maxAttendees as number;