mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
⚡ Improvements to previous PR
* Fix timezone in google calendar * change timezone additionalFields variable name in Google.Calendar.nodes.ts from timeZone to timezone * add timezone information to formated code Signed-off-by: 5pecia1 <pdpxpd@gmail.com> * ⚡ nodelinter fixes * 🔨 fixes for incorrect timezonez * ⚡ Improvements Co-authored-by: 5pecia1 <pdpxpd@gmail.com> Co-authored-by: michael-radency <michael.k@radency.com> Co-authored-by: Jan Oberhauser <janober@users.noreply.github.com>
This commit is contained in:
parent
f73100a0bd
commit
6f9561294a
|
@ -28,7 +28,7 @@ export const calendarOperations: INodeProperties[] = [
|
|||
|
||||
export const calendarFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* calendar:availability */
|
||||
/* calendar:availability */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Calendar ID',
|
||||
|
@ -136,6 +136,4 @@ export const calendarFields: INodeProperties[] = [
|
|||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
];
|
||||
|
|
|
@ -356,16 +356,6 @@ export const eventFields: INodeProperties[] = [
|
|||
default: 'opaque',
|
||||
description: 'Whether the event blocks time on the calendar',
|
||||
},
|
||||
{
|
||||
displayName: 'Timezone',
|
||||
name: 'timezone',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTimezones',
|
||||
},
|
||||
default: '',
|
||||
description: 'The timezone the event will have set. By default events are schedule on timezone set in n8n.',
|
||||
},
|
||||
{
|
||||
displayName: 'Visibility',
|
||||
name: 'visibility',
|
||||
|
@ -986,16 +976,6 @@ export const eventFields: INodeProperties[] = [
|
|||
default: 'opaque',
|
||||
description: 'Whether the event blocks time on the calendar',
|
||||
},
|
||||
{
|
||||
displayName: 'Timezone',
|
||||
name: 'timezone',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTimezones',
|
||||
},
|
||||
default: '',
|
||||
description: 'The timezone the event will have set. By default events are schedule on n8n timezone',
|
||||
},
|
||||
{
|
||||
displayName: 'Visibility',
|
||||
name: 'visibility',
|
||||
|
|
|
@ -181,12 +181,12 @@ export class GoogleCalendar implements INodeType {
|
|||
let responseData;
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
const timezone = this.getTimezone();
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
if (resource === 'calendar') {
|
||||
//https://developers.google.com/calendar/v3/reference/freebusy/query
|
||||
if (operation === 'availability') {
|
||||
const timezone = moment.tz.guess();
|
||||
const calendarId = this.getNodeParameter('calendar', i) as string;
|
||||
const timeMin = this.getNodeParameter('timeMin', i) as string;
|
||||
const timeMax = this.getNodeParameter('timeMax', i) as string;
|
||||
|
@ -194,8 +194,8 @@ export class GoogleCalendar implements INodeType {
|
|||
const outputFormat = options.outputFormat || 'availability';
|
||||
|
||||
const body: IDataObject = {
|
||||
timeMin: options.timezone ? moment.tz(timeMin, options.timezone as string).utc(true).format() : timeMin,
|
||||
timeMax: options.timezone ? moment.tz(timeMax, options.timezone as string).utc(true).format() : timeMax,
|
||||
timeMin: moment(timeMin).utc().format(),
|
||||
timeMax: moment(timeMax).utc().format(),
|
||||
items: [
|
||||
{
|
||||
id: calendarId,
|
||||
|
@ -240,7 +240,6 @@ export class GoogleCalendar implements INodeType {
|
|||
'additionalFields',
|
||||
i,
|
||||
) as IDataObject;
|
||||
const timezone = (additionalFields.timezone as string);
|
||||
|
||||
if (additionalFields.maxAttendees) {
|
||||
qs.maxAttendees = additionalFields.maxAttendees as number;
|
||||
|
@ -253,12 +252,12 @@ export class GoogleCalendar implements INodeType {
|
|||
}
|
||||
const body: IEvent = {
|
||||
start: {
|
||||
dateTime: timezone ? moment.tz(start, timezone).utc(true).format() : start,
|
||||
timeZone: timezone || moment.tz.guess(),
|
||||
dateTime: moment.tz(start, timezone).utc().format(),
|
||||
timeZone: timezone,
|
||||
},
|
||||
end: {
|
||||
dateTime: timezone ? moment.tz(end, timezone).utc(true).format() : end,
|
||||
timeZone: timezone || moment.tz.guess(),
|
||||
dateTime: moment.tz(end, timezone).utc().format(),
|
||||
timeZone: timezone,
|
||||
},
|
||||
};
|
||||
if (additionalFields.attendees) {
|
||||
|
@ -347,10 +346,9 @@ export class GoogleCalendar implements INodeType {
|
|||
);
|
||||
}
|
||||
if (additionalFields.repeatUntil) {
|
||||
const repeatUntil = timezone ?
|
||||
moment.tz(additionalFields.repeatUntil as string, timezone).utc(true).format('YYYYMMDDTHHmmss') :
|
||||
moment(additionalFields.repeatUntil as string).utc().format('YYYYMMDDTHHmmss');
|
||||
|
||||
const repeatUntil = moment(additionalFields.repeatUntil as string)
|
||||
.utc()
|
||||
.format('YYYYMMDDTHHmmss');
|
||||
body.recurrence?.push(
|
||||
`UNTIL=${repeatUntil}Z`,
|
||||
);
|
||||
|
@ -375,7 +373,6 @@ export class GoogleCalendar implements INodeType {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
responseData = await googleApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
|
@ -504,14 +501,14 @@ export class GoogleCalendar implements INodeType {
|
|||
const body: IEvent = {};
|
||||
if (updateFields.start) {
|
||||
body.start = {
|
||||
dateTime: timezone ? moment.tz(updateFields.start as string, timezone).utc(true).format() : updateFields.start as string,
|
||||
timeZone: timezone || moment.tz.guess(),
|
||||
dateTime: moment.tz(updateFields.start, timezone).utc().format(),
|
||||
timeZone: timezone,
|
||||
};
|
||||
}
|
||||
if (updateFields.end) {
|
||||
body.end = {
|
||||
dateTime: timezone ? moment.tz(updateFields.end as string, timezone).utc(true).format() : updateFields.end as string,
|
||||
timeZone: timezone || moment.tz.guess(),
|
||||
dateTime: moment.tz(updateFields.end, timezone).utc().format(),
|
||||
timeZone: timezone,
|
||||
};
|
||||
}
|
||||
if (updateFields.attendees) {
|
||||
|
@ -594,9 +591,9 @@ export class GoogleCalendar implements INodeType {
|
|||
body.recurrence?.push(`COUNT=${updateFields.repeatHowManyTimes};`);
|
||||
}
|
||||
if (updateFields.repeatUntil) {
|
||||
const repeatUntil = timezone ?
|
||||
moment.tz(updateFields.repeatUntil as string, timezone).utc(true).format('YYYYMMDDTHHmmss') :
|
||||
moment(updateFields.repeatUntil as string).utc().format('YYYYMMDDTHHmmss');
|
||||
const repeatUntil = moment(updateFields.repeatUntil as string)
|
||||
.utc()
|
||||
.format('YYYYMMDDTHHmmss');
|
||||
|
||||
body.recurrence?.push(
|
||||
`UNTIL=${repeatUntil}Z`,
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
import {
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
JsonObject,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
|
@ -41,7 +42,7 @@ export async function mailjetApiRequest(this: IExecuteFunctions | IExecuteSingle
|
|||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue