Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/google_calendar/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/google_calendar",
"version": "0.5.6",
"version": "0.5.7",
"description": "Pipedream Google_calendar Components",
"main": "google_calendar.app.mjs",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
type: "source",
name: "New Created or Updated Event (Instant)",
description: "Emit new event when a Google Calendar events is created or updated (does not emit cancelled events)",
version: "0.1.13",
version: "0.1.14",
dedupe: "unique",
props: {
googleCalendar,
Expand Down Expand Up @@ -199,16 +199,18 @@ export default {
}
return new Date(min);
},
getChannelIds() {
const channelIds = [];
getCalendarIdForChannelId(incomingChannelId) {
for (const calendarId of this.calendarIds) {
const channelId = this.db.get(`${calendarId}.channelId`);
channelIds.push(channelId);
if (this.db.get(`${calendarId}.channelId`) === incomingChannelId) {
return calendarId;
}
}
return channelIds;
return null;
},
},
async run(event) {
let calendarId = null; // calendar ID matching incoming channel ID

// refresh watch
if (event.interval_seconds) {
// get time
Expand All @@ -224,9 +226,9 @@ export default {
}
} else {
// Verify channel ID
const channelIds = this.getChannelIds();
const incomingChannelId = event?.headers?.["x-goog-channel-id"];
if (!channelIds.includes(incomingChannelId)) {
calendarId = this.getCalendarIdForChannelId(incomingChannelId);
if (!calendarId) {
console.log(
`Unexpected channel ID ${incomingChannelId}. This likely means there are multiple, older subscriptions active.`,
);
Expand All @@ -252,7 +254,12 @@ export default {
}

// Fetch and emit events
for (const calendarId of this.calendarIds) {
const checkCalendarIds = calendarId
? [
calendarId,
]
: this.calendarIds;
for (const calendarId of checkCalendarIds) {
const syncToken = this.getNextSyncToken(calendarId);
let nextSyncToken = null;
let nextPageToken = null;
Expand All @@ -266,10 +273,11 @@ export default {
syncToken,
pageToken: nextPageToken,
maxResults: 2500,
validateStatus: (status) => (status >= 200 && (status < 300 || status == 410)),
});
if (syncStatus === 410) {
console.log("Sync token invalid, resyncing");
nextSyncToken = await this.googleCalendar.fullSync(this.calendarId);
nextSyncToken = await this.googleCalendar.fullSync(calendarId);
break;
}
nextPageToken = syncData.nextPageToken;
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading