4746 create created listener on blocklist for calendar (#5046)
Follows #5031. Closes #4746
This commit is contained in:
@ -6,7 +6,7 @@ import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repos
|
||||
import { PersonRepository } from 'src/modules/person/repositories/person.repository';
|
||||
import { PersonObjectMetadata } from 'src/modules/person/standard-objects/person.object-metadata';
|
||||
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
|
||||
import { getFlattenedValuesAndValuesStringForBatchRawQuery } from 'src/modules/calendar/utils/getFlattenedValuesAndValuesStringForBatchRawQuery.util';
|
||||
import { getFlattenedValuesAndValuesStringForBatchRawQuery } from 'src/modules/calendar/utils/get-flattened-values-and-values-string-for-batch-raw-query.util';
|
||||
import { CalendarEventParticipant } from 'src/modules/calendar/types/calendar-event';
|
||||
import { CalendarEventParticipantRepository } from 'src/modules/calendar/repositories/calendar-event-participant.repository';
|
||||
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
|
||||
|
||||
@ -12,7 +12,6 @@ import {
|
||||
FeatureFlagKeys,
|
||||
} from 'src/engine/core-modules/feature-flag/feature-flag.entity';
|
||||
import { GoogleCalendarClientProvider } from 'src/modules/calendar/services/providers/google-calendar/google-calendar.provider';
|
||||
import { googleCalendarSearchFilterExcludeEmails } from 'src/modules/calendar/utils/google-calendar-search-filter.util';
|
||||
import { CalendarChannelEventAssociationRepository } from 'src/modules/calendar/repositories/calendar-channel-event-association.repository';
|
||||
import { CalendarChannelRepository } from 'src/modules/calendar/repositories/calendar-channel.repository';
|
||||
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
|
||||
@ -29,6 +28,7 @@ import { BlocklistObjectMetadata } from 'src/modules/connected-account/standard-
|
||||
import { CalendarEventCleanerService } from 'src/modules/calendar/services/calendar-event-cleaner/calendar-event-cleaner.service';
|
||||
import { CalendarEventParticipantService } from 'src/modules/calendar/services/calendar-event-participant/calendar-event-participant.service';
|
||||
import { CalendarEventParticipant } from 'src/modules/calendar/types/calendar-event';
|
||||
import { filterOutBlocklistedEvents } from 'src/modules/calendar/utils/filter-out-blocklisted-events.util';
|
||||
|
||||
@Injectable()
|
||||
export class GoogleCalendarSyncService {
|
||||
@ -133,7 +133,6 @@ export class GoogleCalendarSyncService {
|
||||
syncToken,
|
||||
pageToken: nextPageToken,
|
||||
showDeleted: true,
|
||||
q: googleCalendarSearchFilterExcludeEmails(blocklistedEmails),
|
||||
});
|
||||
|
||||
nextSyncToken = googleCalendarEvents.data.nextSyncToken;
|
||||
@ -168,7 +167,12 @@ export class GoogleCalendarSyncService {
|
||||
return;
|
||||
}
|
||||
|
||||
const eventExternalIds = events.map((event) => event.id as string);
|
||||
const filteredEvents = filterOutBlocklistedEvents(
|
||||
events,
|
||||
blocklistedEmails,
|
||||
);
|
||||
|
||||
const eventExternalIds = filteredEvents.map((event) => event.id as string);
|
||||
|
||||
startTime = Date.now();
|
||||
|
||||
@ -204,7 +208,7 @@ export class GoogleCalendarSyncService {
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
const formattedEvents = events
|
||||
const formattedEvents = filteredEvents
|
||||
.filter((event) => event.status !== 'cancelled')
|
||||
.map((event) =>
|
||||
formatGoogleCalendarEvent(event, iCalUIDCalendarEventIdMap),
|
||||
@ -218,7 +222,7 @@ export class GoogleCalendarSyncService {
|
||||
existingEventExternalIds.includes(event.externalId),
|
||||
);
|
||||
|
||||
const cancelledEventExternalIds = events
|
||||
const cancelledEventExternalIds = filteredEvents
|
||||
.filter((event) => event.status === 'cancelled')
|
||||
.map((event) => event.id as string);
|
||||
|
||||
@ -240,7 +244,7 @@ export class GoogleCalendarSyncService {
|
||||
|
||||
let newCalendarEventParticipants: CalendarEventParticipant[] = [];
|
||||
|
||||
if (events.length > 0) {
|
||||
if (filteredEvents.length > 0) {
|
||||
const dataSourceMetadata =
|
||||
await this.workspaceDataSourceService.connectToWorkspaceDataSource(
|
||||
workspaceId,
|
||||
|
||||
Reference in New Issue
Block a user