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[] = [
|
export const calendarFields: INodeProperties[] = [
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* calendar:availability */
|
/* calendar:availability */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
displayName: 'Calendar ID',
|
displayName: 'Calendar ID',
|
||||||
|
@ -136,6 +136,4 @@ export const calendarFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -356,16 +356,6 @@ export const eventFields: INodeProperties[] = [
|
||||||
default: 'opaque',
|
default: 'opaque',
|
||||||
description: 'Whether the event blocks time on the calendar',
|
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',
|
displayName: 'Visibility',
|
||||||
name: 'visibility',
|
name: 'visibility',
|
||||||
|
@ -986,16 +976,6 @@ export const eventFields: INodeProperties[] = [
|
||||||
default: 'opaque',
|
default: 'opaque',
|
||||||
description: 'Whether the event blocks time on the calendar',
|
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',
|
displayName: 'Visibility',
|
||||||
name: 'visibility',
|
name: 'visibility',
|
||||||
|
|
|
@ -181,12 +181,12 @@ export class GoogleCalendar implements INodeType {
|
||||||
let responseData;
|
let responseData;
|
||||||
const resource = this.getNodeParameter('resource', 0) as string;
|
const resource = this.getNodeParameter('resource', 0) as string;
|
||||||
const operation = this.getNodeParameter('operation', 0) as string;
|
const operation = this.getNodeParameter('operation', 0) as string;
|
||||||
|
const timezone = this.getTimezone();
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
try {
|
try {
|
||||||
if (resource === 'calendar') {
|
if (resource === 'calendar') {
|
||||||
//https://developers.google.com/calendar/v3/reference/freebusy/query
|
//https://developers.google.com/calendar/v3/reference/freebusy/query
|
||||||
if (operation === 'availability') {
|
if (operation === 'availability') {
|
||||||
const timezone = moment.tz.guess();
|
|
||||||
const calendarId = this.getNodeParameter('calendar', i) as string;
|
const calendarId = this.getNodeParameter('calendar', i) as string;
|
||||||
const timeMin = this.getNodeParameter('timeMin', i) as string;
|
const timeMin = this.getNodeParameter('timeMin', i) as string;
|
||||||
const timeMax = this.getNodeParameter('timeMax', 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 outputFormat = options.outputFormat || 'availability';
|
||||||
|
|
||||||
const body: IDataObject = {
|
const body: IDataObject = {
|
||||||
timeMin: options.timezone ? moment.tz(timeMin, options.timezone as string).utc(true).format() : timeMin,
|
timeMin: moment(timeMin).utc().format(),
|
||||||
timeMax: options.timezone ? moment.tz(timeMax, options.timezone as string).utc(true).format() : timeMax,
|
timeMax: moment(timeMax).utc().format(),
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
id: calendarId,
|
id: calendarId,
|
||||||
|
@ -240,7 +240,6 @@ export class GoogleCalendar implements INodeType {
|
||||||
'additionalFields',
|
'additionalFields',
|
||||||
i,
|
i,
|
||||||
) as IDataObject;
|
) as IDataObject;
|
||||||
const timezone = (additionalFields.timezone as string);
|
|
||||||
|
|
||||||
if (additionalFields.maxAttendees) {
|
if (additionalFields.maxAttendees) {
|
||||||
qs.maxAttendees = additionalFields.maxAttendees as number;
|
qs.maxAttendees = additionalFields.maxAttendees as number;
|
||||||
|
@ -253,12 +252,12 @@ export class GoogleCalendar implements INodeType {
|
||||||
}
|
}
|
||||||
const body: IEvent = {
|
const body: IEvent = {
|
||||||
start: {
|
start: {
|
||||||
dateTime: timezone ? moment.tz(start, timezone).utc(true).format() : start,
|
dateTime: moment.tz(start, timezone).utc().format(),
|
||||||
timeZone: timezone || moment.tz.guess(),
|
timeZone: timezone,
|
||||||
},
|
},
|
||||||
end: {
|
end: {
|
||||||
dateTime: timezone ? moment.tz(end, timezone).utc(true).format() : end,
|
dateTime: moment.tz(end, timezone).utc().format(),
|
||||||
timeZone: timezone || moment.tz.guess(),
|
timeZone: timezone,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if (additionalFields.attendees) {
|
if (additionalFields.attendees) {
|
||||||
|
@ -347,10 +346,9 @@ export class GoogleCalendar implements INodeType {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (additionalFields.repeatUntil) {
|
if (additionalFields.repeatUntil) {
|
||||||
const repeatUntil = timezone ?
|
const repeatUntil = moment(additionalFields.repeatUntil as string)
|
||||||
moment.tz(additionalFields.repeatUntil as string, timezone).utc(true).format('YYYYMMDDTHHmmss') :
|
.utc()
|
||||||
moment(additionalFields.repeatUntil as string).utc().format('YYYYMMDDTHHmmss');
|
.format('YYYYMMDDTHHmmss');
|
||||||
|
|
||||||
body.recurrence?.push(
|
body.recurrence?.push(
|
||||||
`UNTIL=${repeatUntil}Z`,
|
`UNTIL=${repeatUntil}Z`,
|
||||||
);
|
);
|
||||||
|
@ -375,7 +373,6 @@ export class GoogleCalendar implements INodeType {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await googleApiRequest.call(
|
responseData = await googleApiRequest.call(
|
||||||
this,
|
this,
|
||||||
'POST',
|
'POST',
|
||||||
|
@ -504,14 +501,14 @@ export class GoogleCalendar implements INodeType {
|
||||||
const body: IEvent = {};
|
const body: IEvent = {};
|
||||||
if (updateFields.start) {
|
if (updateFields.start) {
|
||||||
body.start = {
|
body.start = {
|
||||||
dateTime: timezone ? moment.tz(updateFields.start as string, timezone).utc(true).format() : updateFields.start as string,
|
dateTime: moment.tz(updateFields.start, timezone).utc().format(),
|
||||||
timeZone: timezone || moment.tz.guess(),
|
timeZone: timezone,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (updateFields.end) {
|
if (updateFields.end) {
|
||||||
body.end = {
|
body.end = {
|
||||||
dateTime: timezone ? moment.tz(updateFields.end as string, timezone).utc(true).format() : updateFields.end as string,
|
dateTime: moment.tz(updateFields.end, timezone).utc().format(),
|
||||||
timeZone: timezone || moment.tz.guess(),
|
timeZone: timezone,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (updateFields.attendees) {
|
if (updateFields.attendees) {
|
||||||
|
@ -594,9 +591,9 @@ export class GoogleCalendar implements INodeType {
|
||||||
body.recurrence?.push(`COUNT=${updateFields.repeatHowManyTimes};`);
|
body.recurrence?.push(`COUNT=${updateFields.repeatHowManyTimes};`);
|
||||||
}
|
}
|
||||||
if (updateFields.repeatUntil) {
|
if (updateFields.repeatUntil) {
|
||||||
const repeatUntil = timezone ?
|
const repeatUntil = moment(updateFields.repeatUntil as string)
|
||||||
moment.tz(updateFields.repeatUntil as string, timezone).utc(true).format('YYYYMMDDTHHmmss') :
|
.utc()
|
||||||
moment(updateFields.repeatUntil as string).utc().format('YYYYMMDDTHHmmss');
|
.format('YYYYMMDDTHHmmss');
|
||||||
|
|
||||||
body.recurrence?.push(
|
body.recurrence?.push(
|
||||||
`UNTIL=${repeatUntil}Z`,
|
`UNTIL=${repeatUntil}Z`,
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
IHookFunctions,
|
IHookFunctions,
|
||||||
|
JsonObject,
|
||||||
NodeApiError,
|
NodeApiError,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ export async function mailjetApiRequest(this: IExecuteFunctions | IExecuteSingle
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue