Add Google Calendar conference link (#1085)

This commit is contained in:
Ricardo Espinoza 2020-10-23 02:00:00 -04:00 committed by GitHub
parent b04769287d
commit 5eb65f8721
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 92 additions and 0 deletions

View file

@ -177,6 +177,37 @@ export const eventFields = [
default: '',
description: 'The color of the event.',
},
{
displayName: 'Conference Data',
name: 'conferenceDataUi',
placeholder: 'Add Conference',
type: 'fixedCollection',
typeOptions: {
multipleValues: false,
},
default: {},
options: [
{
displayName: 'Conference Link',
name: 'conferenceDataValues',
values: [
{
displayName: 'Type',
name: 'conferenceSolution',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getConferenceSolutations',
loadOptionsDependsOn: [
'calendar',
],
},
default: '',
},
],
},
],
description: 'Creates a conference link (Hangouts, Meet etc) and attachs it to the event',
},
{
displayName: 'Description',
name: 'description',

View file

@ -7,6 +7,15 @@ export interface IReminder {
overrides?: IDataObject[];
}
export interface IConferenceData {
createRequest?: {
requestId: string,
conferenceSolution: {
type: string,
}
};
}
export interface IEvent {
attendees?: IDataObject[];
colorId?: string;
@ -25,4 +34,5 @@ export interface IEvent {
summary?: string;
transparency?: string;
visibility?: string;
conferenceData?: IConferenceData;
}

View file

@ -27,6 +27,8 @@ import {
import * as moment from 'moment-timezone';
import * as uuid from 'uuid/v4';
export class GoogleCalendar implements INodeType {
description: INodeTypeDescription = {
displayName: 'Google Calendar',
@ -69,6 +71,38 @@ export class GoogleCalendar implements INodeType {
methods = {
loadOptions: {
// "conferenceProperties": {
// "allowedConferenceSolutionTypes": [
// "hangoutsMeet"
// ]
// Get all the calendars to display them to user so that he can
// select them easily
async getConferenceSolutations(
this: ILoadOptionsFunctions
): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const calendar = this.getCurrentNodeParameter('calendar') as string;
const posibleSolutions: IDataObject = {
'eventHangout': 'Google Hangout',
'eventNamedHangout': 'Google Hangout Classic',
'hangoutsMeet': 'Google Meet',
};
const { conferenceProperties: { allowedConferenceSolutionTypes } } = await googleApiRequest.call(
this,
'GET',
`/calendar/v3/users/me/calendarList/${calendar}`,
);
for (const solution of allowedConferenceSolutionTypes) {
returnData.push({
name: posibleSolutions[solution] as string,
value: solution,
});
}
return returnData;
},
// Get all the calendars to display them to user so that he can
// select them easily
async getCalendars(
@ -265,6 +299,23 @@ export class GoogleCalendar implements INodeType {
if (body.recurrence.length !== 0) {
body.recurrence = [`RRULE:${body.recurrence.join('')}`];
}
if (additionalFields.conferenceDataUi) {
const conferenceData = (additionalFields.conferenceDataUi as IDataObject).conferenceDataValues as IDataObject;
if (conferenceData) {
qs.conferenceDataVersion = 1;
body.conferenceData = {
createRequest: {
requestId: uuid(),
conferenceSolution: {
type: conferenceData.conferenceSolution as string,
}
},
};
}
}
responseData = await googleApiRequest.call(
this,
'POST',