node-red / node-red-web-nodes

A collection of node-red nodes aimed at web services
Apache License 2.0
226 stars 156 forks source link

Calendar events with links (Google Meet) #295

Open jorgebrunal opened 2 years ago

jorgebrunal commented 2 years ago

Proposed changes

modify the file calendar.js

Which node are you reporting an issue on?

Google Calendar out

What are the steps to reproduce?

allow the creation of events with link for Google Meet

What happens?

currently, when using an object representing the request body for an insert request does not allow to create events in Calendar with links

What do you expect to happen?

well... that when creating an event in Calendar it is allowed to create links :smile:

Please tell us about your environment:

Full example:

modify the file calendar.js, line 596

...

if (typeof msg.payload === 'object') {
    request.url = 'https://www.googleapis.com/calendar/v3/calendars/'+cal.id+'/events';

    // add the following lines
    // start
    if (msg.conferenceDataVersion){
        request.url += '?conferenceDataVersion='+msg.conferenceDataVersion;
    }
   // end

    request.body = msg.payload;
} else {
    request.url = 'https://www.googleapis.com/calendar/v3/calendars/'+cal.id+'/events/quickAdd';
    request.form = {
        text: RED.util.ensureString(msg.payload)
    };
}

...

msg.conferenceDataVersion

msg.conferenceDataVersion: 1

msg.payload

{
    "summary": "Google I/O 2015",
    "location": "800 Howard St., San Francisco, CA 94103",
    "description": "A chance to hear more about Google\"s developer products.",
    "start": {
        "dateTime": "2022-04-22T09:00:00-07:00",
        "timeZone": "America/Los_Angeles"
    },
    "end": {
        "dateTime": "2022-04-22T17:00:00-07:00",
        "timeZone": "America/Los_Angeles"
    },

    // add the following object
    // start
    "conferenceData": {
        "createRequest": {
            "requestId": "example-id", // any text, it seems
            "conferenceSolutionKey": {
                "type": "hangoutsMeet" // required
            }
        }
    },
    // end

    "reminders": {
        "useDefault": false,
        "overrides": [
            {
                "method": "popup",
                "minutes": 10
            }
        ]
    },
    "guestsCanInviteOthers": true,
    "guestsCanModify": false,
    "guestsCanSeeOtherGuests": true
}

flow example

flow code

[{"id":"875e480c83ddb182","type":"tab","label":"crear evento","disabled":false,"info":"","env":[]},{"id":"f77cdc04894bbe11","type":"google calendar out","z":"875e480c83ddb182","google":"","name":"calendar_create","calendar":"","x":690,"y":220,"wires":[]},{"id":"1995faf00e16953f","type":"inject","z":"875e480c83ddb182","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":220,"wires":[["083715e35c4a0da2"]]},{"id":"083715e35c4a0da2","type":"change","z":"875e480c83ddb182","name":"create_custom_event","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"summary\":\"Google I/O 2015\",\"location\":\"800 Howard St., San Francisco, CA 94103\",\"description\":\"A chance to hear more about Google\\\"s developer products.\",\"start\":{\"dateTime\":\"2022-04-22T09:00:00-07:00\",\"timeZone\":\"America/Los_Angeles\"},\"end\":{\"dateTime\":\"2022-04-22T17:00:00-07:00\",\"timeZone\":\"America/Los_Angeles\"},\"conferenceData\":{\"createRequest\":{\"requestId\":\"example-id\",\"conferenceSolutionKey\":{\"type\":\"hangoutsMeet\"}}},\"reminders\":{\"useDefault\":false,\"overrides\":[{\"method\":\"popup\",\"minutes\":10}]},\"guestsCanInviteOthers\":true,\"guestsCanModify\":false,\"guestsCanSeeOtherGuests\":true}","tot":"json"},{"t":"set","p":"conferenceDataVersion","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":240,"wires":[["f77cdc04894bbe11"]]}]

more info:

my apologies for the translation, I do not speak English.

thanks!

dceejay commented 2 years ago

looks good - would you like to create Pull Request for this, or wait for me to have time to cut/paste it ? Thanks