5187 delete all emails and events from a blocklisted domain name (#5190)
Closes #5187
This commit is contained in:
@ -179,6 +179,8 @@ export class CalendarChannelEventAssociationRepository {
|
|||||||
const dataSourceSchema =
|
const dataSourceSchema =
|
||||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||||
|
|
||||||
|
const isHandleDomain = calendarEventParticipantHandle.startsWith('@');
|
||||||
|
|
||||||
await this.workspaceDataSourceService.executeRawQuery(
|
await this.workspaceDataSourceService.executeRawQuery(
|
||||||
`DELETE FROM ${dataSourceSchema}."calendarChannelEventAssociation"
|
`DELETE FROM ${dataSourceSchema}."calendarChannelEventAssociation"
|
||||||
WHERE "id" IN (
|
WHERE "id" IN (
|
||||||
@ -186,9 +188,16 @@ export class CalendarChannelEventAssociationRepository {
|
|||||||
FROM ${dataSourceSchema}."calendarChannelEventAssociation" "calendarChannelEventAssociation"
|
FROM ${dataSourceSchema}."calendarChannelEventAssociation" "calendarChannelEventAssociation"
|
||||||
JOIN ${dataSourceSchema}."calendarEvent" "calendarEvent" ON "calendarChannelEventAssociation"."calendarEventId" = "calendarEvent"."id"
|
JOIN ${dataSourceSchema}."calendarEvent" "calendarEvent" ON "calendarChannelEventAssociation"."calendarEventId" = "calendarEvent"."id"
|
||||||
JOIN ${dataSourceSchema}."calendarEventParticipant" "calendarEventParticipant" ON "calendarEvent"."id" = "calendarEventParticipant"."calendarEventId"
|
JOIN ${dataSourceSchema}."calendarEventParticipant" "calendarEventParticipant" ON "calendarEvent"."id" = "calendarEventParticipant"."calendarEventId"
|
||||||
WHERE "calendarEventParticipant"."handle" = $1 AND "calendarChannelEventAssociation"."calendarChannelId" = ANY($2)
|
WHERE "calendarEventParticipant"."handle" ${
|
||||||
|
isHandleDomain ? 'ILIKE' : '='
|
||||||
|
} $1 AND "calendarChannelEventAssociation"."calendarChannelId" = ANY($2)
|
||||||
)`,
|
)`,
|
||||||
[calendarEventParticipantHandle, calendarChannelIds],
|
[
|
||||||
|
isHandleDomain
|
||||||
|
? `%${calendarEventParticipantHandle}`
|
||||||
|
: calendarEventParticipantHandle,
|
||||||
|
calendarChannelIds,
|
||||||
|
],
|
||||||
workspaceId,
|
workspaceId,
|
||||||
transactionManager,
|
transactionManager,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -77,14 +77,24 @@ export class MessageChannelMessageAssociationRepository {
|
|||||||
const dataSourceSchema =
|
const dataSourceSchema =
|
||||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||||
|
|
||||||
|
const isHandleDomain = messageParticipantHandle.startsWith('@');
|
||||||
|
|
||||||
const messageChannelMessageAssociationIdsToDelete =
|
const messageChannelMessageAssociationIdsToDelete =
|
||||||
await this.workspaceDataSourceService.executeRawQuery(
|
await this.workspaceDataSourceService.executeRawQuery(
|
||||||
`SELECT "messageChannelMessageAssociation".id
|
`SELECT "messageChannelMessageAssociation".id
|
||||||
FROM ${dataSourceSchema}."messageChannelMessageAssociation" "messageChannelMessageAssociation"
|
FROM ${dataSourceSchema}."messageChannelMessageAssociation" "messageChannelMessageAssociation"
|
||||||
JOIN ${dataSourceSchema}."message" ON "messageChannelMessageAssociation"."messageId" = ${dataSourceSchema}."message"."id"
|
JOIN ${dataSourceSchema}."message" ON "messageChannelMessageAssociation"."messageId" = ${dataSourceSchema}."message"."id"
|
||||||
JOIN ${dataSourceSchema}."messageParticipant" "messageParticipant" ON ${dataSourceSchema}."message"."id" = "messageParticipant"."messageId"
|
JOIN ${dataSourceSchema}."messageParticipant" "messageParticipant" ON ${dataSourceSchema}."message"."id" = "messageParticipant"."messageId"
|
||||||
WHERE "messageParticipant"."handle" = $1 AND "messageParticipant"."role"= ANY($2) AND "messageChannelMessageAssociation"."messageChannelId" = ANY($3)`,
|
WHERE "messageParticipant"."handle" ${
|
||||||
[messageParticipantHandle, rolesToDelete, messageChannelIds],
|
isHandleDomain ? 'ILIKE' : '='
|
||||||
|
} $1 AND "messageParticipant"."role" = ANY($2) AND "messageChannelMessageAssociation"."messageChannelId" = ANY($3)`,
|
||||||
|
[
|
||||||
|
isHandleDomain
|
||||||
|
? `%${messageParticipantHandle}`
|
||||||
|
: messageParticipantHandle,
|
||||||
|
rolesToDelete,
|
||||||
|
messageChannelIds,
|
||||||
|
],
|
||||||
workspaceId,
|
workspaceId,
|
||||||
transactionManager,
|
transactionManager,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user