diff --git a/services/calendar/pod-calendar/src/calendar.ts b/services/calendar/pod-calendar/src/calendar.ts index 3e1b75b90a..9e5627cd80 100644 --- a/services/calendar/pod-calendar/src/calendar.ts +++ b/services/calendar/pod-calendar/src/calendar.ts @@ -673,7 +673,6 @@ export class CalendarClient { } private async syncEvent (calendarId: string, event: calendar_v3.Schema$Event, accessRole: string): Promise { - console.log('SYNC EVENT CALL', calendarId, JSON.stringify(event)) if (event.id != null) { const me = await this.getMe() const calendars = this.workspace.getMyCalendars(me) @@ -681,7 +680,6 @@ export class CalendarClient { calendars.find((p) => p.externalId === event.organizer?.email) ?? calendars.find((p) => p.externalId === calendarId) ?? calendars[0] - console.log('Target space', _calendar) if (_calendar !== undefined) { const exists = (await this.client.findOne(calendar.class.Event, { eventId: event.id, @@ -697,9 +695,7 @@ export class CalendarClient { } private async updateExtEvent (event: calendar_v3.Schema$Event, current: Event): Promise { - console.log('UPDATE EVENT', current._id, JSON.stringify(event)) if (event.status === 'cancelled' && current._class !== calendar.class.ReccuringInstance) { - console.log('REMOVE EVENT', current._id) await this.client.remove(current) return } @@ -715,7 +711,6 @@ export class CalendarClient { current as ReccuringInstance ) if (Object.keys(diff).length > 0) { - console.log('UPDATE REC INSTANCE DIFF', JSON.stringify(diff), JSON.stringify(current)) await this.client.update(current, diff) } } else { @@ -731,13 +726,11 @@ export class CalendarClient { current as ReccuringEvent ) if (Object.keys(diff).length > 0) { - console.log('UPDATE REC EVENT DIFF', JSON.stringify(diff), JSON.stringify(current)) await this.client.update(current, diff) } } else { const diff = this.getDiff(data, current) if (Object.keys(diff).length > 0) { - console.log('UPDATE EVENT DIFF', JSON.stringify(diff), JSON.stringify(current)) await this.client.update(current, diff) } } @@ -827,7 +820,6 @@ export class CalendarClient { } ) await this.saveMixins(event, id) - console.log('SAVE INSTANCE', id, JSON.stringify(event)) } else if (event.status !== 'cancelled') { if (event.recurrence != null) { const parseRule = parseRecurrenceStrings(event.recurrence) @@ -847,7 +839,6 @@ export class CalendarClient { } ) await this.saveMixins(event, id) - console.log('SAVE REC EVENT', id, JSON.stringify(event)) } else { const id = await this.client.addCollection( calendar.class.Event, @@ -858,7 +849,6 @@ export class CalendarClient { data ) await this.saveMixins(event, id) - console.log('SAVE EVENT', id, JSON.stringify(event)) } } } diff --git a/services/calendar/pod-calendar/src/calendarController.ts b/services/calendar/pod-calendar/src/calendarController.ts index 55b5f2e3e6..b929ee4204 100644 --- a/services/calendar/pod-calendar/src/calendarController.ts +++ b/services/calendar/pod-calendar/src/calendarController.ts @@ -86,7 +86,7 @@ export class CalendarController { clearTimeout(timeout) clients.push(client) } catch (err) { - console.error(`Couldn't create client for ${workspace} ${token.userId}`) + console.error(`Couldn't create client for ${workspace} ${token.userId} ${token.email}`) } } for (const client of clients) { @@ -95,6 +95,7 @@ export class CalendarController { }) } void workspaceClient.sync() + console.log('Workspace started', workspace) } push (email: string, mode: 'events' | 'calendar', calendarId?: string): void { diff --git a/services/calendar/pod-calendar/src/workspaceClient.ts b/services/calendar/pod-calendar/src/workspaceClient.ts index db3151f613..f802e6db9f 100644 --- a/services/calendar/pod-calendar/src/workspaceClient.ts +++ b/services/calendar/pod-calendar/src/workspaceClient.ts @@ -86,6 +86,7 @@ export class WorkspaceClient { if (current !== undefined) return current const newClient = await CalendarClient.create(this.credentials, user, this.mongo, this.client, this) this.clients.set(user.email, newClient) + console.log('create new client', user.email, this.workspace) return newClient } @@ -151,6 +152,9 @@ export class WorkspaceClient { private getCalendarClientByCalendar (id: Ref): CalendarClient | undefined { const calendar = this.calendars.byId.get(id) + if (calendar === undefined) { + console.log("couldn't find calendar by id", id) + } return calendar != null ? this.clients.get(calendar.externalUser) : undefined } @@ -216,14 +220,17 @@ export class WorkspaceClient { this.txHandlers.push(async (...tx: Tx[]) => { await this.txEventHandler(...tx) }) + console.log('receive new events', this.workspace, newEvents.length) for (const newEvent of newEvents) { const client = this.getCalendarClientByCalendar(newEvent.calendar as Ref) if (client === undefined) { + console.log('Client not found', newEvent.calendar, this.workspace) return } await client.syncMyEvent(newEvent) await this.updateSyncTime() } + console.log('all messages synced', this.workspace) } private async txEventHandler (...txes: Tx[]): Promise {