@ -68,6 +68,7 @@ export class GoogleCalendarSyncService {
|
||||
public async startGoogleCalendarSync(
|
||||
workspaceId: string,
|
||||
connectedAccountId: string,
|
||||
emailOrDomainToReimport?: string,
|
||||
): Promise<void> {
|
||||
const connectedAccount = await this.connectedAccountRepository.getById(
|
||||
connectedAccountId,
|
||||
@ -137,8 +138,9 @@ export class GoogleCalendarSyncService {
|
||||
const googleCalendarEvents = await googleCalendarClient.events.list({
|
||||
calendarId: 'primary',
|
||||
maxResults: 500,
|
||||
syncToken,
|
||||
syncToken: emailOrDomainToReimport ? undefined : syncToken,
|
||||
pageToken: nextPageToken,
|
||||
q: emailOrDomainToReimport,
|
||||
showDeleted: true,
|
||||
});
|
||||
|
||||
@ -174,10 +176,19 @@ export class GoogleCalendarSyncService {
|
||||
return;
|
||||
}
|
||||
|
||||
const filteredEvents = filterOutBlocklistedEvents(
|
||||
events,
|
||||
blocklistedEmails,
|
||||
);
|
||||
let filteredEvents = filterOutBlocklistedEvents(events, blocklistedEmails);
|
||||
|
||||
if (emailOrDomainToReimport) {
|
||||
// We still need to filter the events to only keep the ones that have the email or domain we want to reimport
|
||||
// because the q parameter in the list method also filters the events that have the email or domain in their summary, description ...
|
||||
// The q parameter allows us to narrow down the events
|
||||
filteredEvents = filteredEvents.filter(
|
||||
(event) =>
|
||||
event.attendees?.some(
|
||||
(attendee) => attendee.email?.endsWith(emailOrDomainToReimport),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
const eventExternalIds = filteredEvents.map((event) => event.id as string);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user