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