Add rrule parameter to Google Calendar Node (#1460)

This commit is contained in:
Ricardo Espinoza 2021-02-21 16:04:00 -05:00 committed by GitHub
parent a94703804f
commit 25dffd9904
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 55 deletions

View file

@ -48,7 +48,7 @@ export const eventOperations = [
export const eventFields = [ export const eventFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* event:ALL */ /* event:getAll */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Calendar ID', displayName: 'Calendar ID',
@ -300,6 +300,13 @@ export const eventFields = [
}, },
default: 1, default: 1,
}, },
{
displayName: 'RRULE',
name: 'rrule',
type: 'string',
default: '',
description: 'Recurrence rule. When set, the parameters Repeat Frecuency, Repeat How Many Times and Repeat Until are ignored.',
},
{ {
displayName: 'Send Updates', displayName: 'Send Updates',
name: 'sendUpdates', name: 'sendUpdates',
@ -920,6 +927,13 @@ export const eventFields = [
}, },
default: 1, default: 1,
}, },
{
displayName: 'RRULE',
name: 'rrule',
type: 'string',
default: '',
description: 'Recurrence rule. When set, the parameters Repeat Frecuency, Repeat How Many Times and Repeat Until are ignored.',
},
{ {
displayName: 'Start', displayName: 'Start',
name: 'start', name: 'start',

View file

@ -1,6 +1,6 @@
import { import {
IDataObject, IDataObject,
} from 'n8n-workflow'; } from 'n8n-workflow';
export interface IReminder { export interface IReminder {
useDefault?: boolean; useDefault?: boolean;

View file

@ -1,6 +1,6 @@
import { import {
OptionsWithUri, OptionsWithUri,
} from 'request'; } from 'request';
import { import {
IExecuteFunctions, IExecuteFunctions,
@ -47,7 +47,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
} }
} }
export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const returnData: IDataObject[] = []; const returnData: IDataObject[] = [];

View file

@ -38,7 +38,7 @@ export class GoogleCalendar implements INodeType {
description: INodeTypeDescription = { description: INodeTypeDescription = {
displayName: 'Google Calendar', displayName: 'Google Calendar',
name: 'googleCalendar', name: 'googleCalendar',
icon: 'file:googleCalendar.png', icon: 'file:googleCalendar.svg',
group: ['input'], group: ['input'],
version: 1, version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
@ -321,33 +321,37 @@ export class GoogleCalendar implements INodeType {
//exampel: RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=10;UNTIL=20110701T170000Z //exampel: RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=10;UNTIL=20110701T170000Z
//https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html //https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html
body.recurrence = []; body.recurrence = [];
if ( if (additionalFields.rrule) {
additionalFields.repeatHowManyTimes && body.recurrence = [`RRULE:${additionalFields.rrule}`];
additionalFields.repeatUntil } else {
) { if (
throw new Error( additionalFields.repeatHowManyTimes &&
`You can set either 'Repeat How Many Times' or 'Repeat Until' but not both`, additionalFields.repeatUntil
); ) {
} throw new Error(
if (additionalFields.repeatFrecuency) { `You can set either 'Repeat How Many Times' or 'Repeat Until' but not both`,
body.recurrence?.push( );
`FREQ=${(additionalFields.repeatFrecuency as string).toUpperCase()};`, }
); if (additionalFields.repeatFrecuency) {
} body.recurrence?.push(
if (additionalFields.repeatHowManyTimes) { `FREQ=${(additionalFields.repeatFrecuency as string).toUpperCase()};`,
body.recurrence?.push( );
`COUNT=${additionalFields.repeatHowManyTimes};`, }
); if (additionalFields.repeatHowManyTimes) {
} body.recurrence?.push(
if (additionalFields.repeatUntil) { `COUNT=${additionalFields.repeatHowManyTimes};`,
body.recurrence?.push( );
`UNTIL=${moment(additionalFields.repeatUntil as string) }
.utc() if (additionalFields.repeatUntil) {
.format('YYYYMMDDTHHmmss')}Z`, body.recurrence?.push(
); `UNTIL=${moment(additionalFields.repeatUntil as string)
} .utc()
if (body.recurrence.length !== 0) { .format('YYYYMMDDTHHmmss')}Z`,
body.recurrence = [`RRULE:${body.recurrence.join('')}`]; );
}
if (body.recurrence.length !== 0) {
body.recurrence = [`RRULE:${body.recurrence.join('')}`];
}
} }
if (additionalFields.conferenceDataUi) { if (additionalFields.conferenceDataUi) {
@ -565,30 +569,34 @@ export class GoogleCalendar implements INodeType {
//exampel: RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=10;UNTIL=20110701T170000Z //exampel: RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=10;UNTIL=20110701T170000Z
//https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html //https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html
body.recurrence = []; body.recurrence = [];
if (updateFields.repeatHowManyTimes && updateFields.repeatUntil) { if (updateFields.rrule) {
throw new Error( body.recurrence = [`RRULE:${updateFields.rrule}`];
`You can set either 'Repeat How Many Times' or 'Repeat Until' but not both`,
);
}
if (updateFields.repeatFrecuency) {
body.recurrence?.push(
`FREQ=${(updateFields.repeatFrecuency as string).toUpperCase()};`,
);
}
if (updateFields.repeatHowManyTimes) {
body.recurrence?.push(`COUNT=${updateFields.repeatHowManyTimes};`);
}
if (updateFields.repeatUntil) {
body.recurrence?.push(
`UNTIL=${moment(updateFields.repeatUntil as string)
.utc()
.format('YYYYMMDDTHHmmss')}Z`,
);
}
if (body.recurrence.length !== 0) {
body.recurrence = [`RRULE:${body.recurrence.join('')}`];
} else { } else {
delete body.recurrence; if (updateFields.repeatHowManyTimes && updateFields.repeatUntil) {
throw new Error(
`You can set either 'Repeat How Many Times' or 'Repeat Until' but not both`,
);
}
if (updateFields.repeatFrecuency) {
body.recurrence?.push(
`FREQ=${(updateFields.repeatFrecuency as string).toUpperCase()};`,
);
}
if (updateFields.repeatHowManyTimes) {
body.recurrence?.push(`COUNT=${updateFields.repeatHowManyTimes};`);
}
if (updateFields.repeatUntil) {
body.recurrence?.push(
`UNTIL=${moment(updateFields.repeatUntil as string)
.utc()
.format('YYYYMMDDTHHmmss')}Z`,
);
}
if (body.recurrence.length !== 0) {
body.recurrence = [`RRULE:${body.recurrence.join('')}`];
} else {
delete body.recurrence;
}
} }
responseData = await googleApiRequest.call( responseData = await googleApiRequest.call(
this, this,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 81 82" fill="#fff" fill-rule="evenodd" stroke="#000" stroke-linecap="round" stroke-linejoin="round"><use xlink:href="#A" x=".5" y=".5"/><symbol id="A" overflow="visible"><g stroke="none" fill-rule="nonzero"><path d="M61.052 18.947H18.947v42.105h42.105V18.947z"/><path d="M61.053 80L80 61.053H61.053V80z" fill="#ea4335"/><path d="M80 18.947H61.053v42.105H80V18.947z" fill="#fbbc04"/><path d="M61.052 61.053H18.947V80h42.105V61.053z" fill="#34a853"/><path d="M0 61.053v12.632C0 77.174 2.826 80 6.316 80h12.632V61.053H0z" fill="#188038"/><path d="M80 18.947V6.316C80 2.826 77.174 0 73.685 0H61.053v18.947H80z" fill="#1967d2"/><path d="M61.053 0H6.316C2.826 0 0 2.826 0 6.316v54.737h18.947V18.947h42.105V0zM27.584 51.611c-1.574-1.063-2.663-2.616-3.258-4.668l3.653-1.505c.332 1.263.911 2.242 1.737 2.937s1.821 1.037 2.989 1.037c1.195 0 2.221-.363 3.079-1.089s1.29-1.653 1.29-2.774a3.44 3.44 0 0 0-1.358-2.811c-.905-.727-2.042-1.089-3.4-1.089h-2.111v-3.616H32.1c1.168 0 2.153-.316 2.953-.947s1.2-1.495 1.2-2.595c0-.979-.358-1.758-1.074-2.342s-1.621-.879-2.721-.879c-1.074 0-1.926.284-2.558.858s-1.106 1.301-1.379 2.111l-3.616-1.505c.479-1.358 1.358-2.558 2.647-3.595s2.937-1.558 4.937-1.558c1.479 0 2.811.284 3.989.858s2.105 1.368 2.774 2.379 1 2.153 1 3.416c0 1.289-.311 2.379-.932 3.274s-1.384 1.579-2.289 2.058v.216a6.95 6.95 0 0 1 2.937 2.289c.763 1.026 1.147 2.253 1.147 3.684s-.363 2.711-1.089 3.832-1.732 2.005-3.005 2.647c-1.279.642-2.716.968-4.311.968-1.847.005-3.553-.526-5.126-1.589zm22.437-18.126l-4.01 2.9-2.005-3.042 7.195-5.189h2.758v24.479h-3.937V33.484z" fill="#4285f4"/></g></symbol></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB