4747 create deleted listener on blocklist (#5067)

Closes #4747
This commit is contained in:
bosiraphael
2024-04-24 16:10:56 +02:00
committed by GitHub
parent adbc8ab96f
commit 0f47426d19
12 changed files with 364 additions and 21 deletions

View File

@ -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);