Logs for calendar service (#7114)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-11-06 21:39:06 +05:00 committed by GitHub
parent 25445c1996
commit 43c681236b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 11 deletions

View File

@ -673,7 +673,6 @@ export class CalendarClient {
}
private async syncEvent (calendarId: string, event: calendar_v3.Schema$Event, accessRole: string): Promise<void> {
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<void> {
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))
}
}
}

View File

@ -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 {

View File

@ -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<ExternalCalendar>): 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<ExternalCalendar>)
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<void> {