4746 create created listener on blocklist for calendar (#5046)
Follows #5031. Closes #4746
This commit is contained in:
@ -0,0 +1,18 @@
|
||||
import { calendar_v3 as calendarV3 } from 'googleapis';
|
||||
|
||||
import { isEmailBlocklisted } from 'src/modules/calendar-messaging-participant/utils/is-email-blocklisted.util';
|
||||
|
||||
export const filterOutBlocklistedEvents = (
|
||||
events: calendarV3.Schema$Event[],
|
||||
blocklist: string[],
|
||||
) => {
|
||||
return events.filter((event) => {
|
||||
if (!event.attendees) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return event.attendees.every(
|
||||
(attendee) => !isEmailBlocklisted(attendee.email, blocklist),
|
||||
);
|
||||
});
|
||||
};
|
||||
@ -5,5 +5,5 @@ export const googleCalendarSearchFilterExcludeEmails = (
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return `email=-(${emails.join(', -')})`;
|
||||
return `-(${emails.join(', ')})`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user