5629 update blocklist for messaging v2 (#5756)
Closes #5629 - Add subdomain support in blocklist (if @example.com is blocked, every subdomain will be blocked)
This commit is contained in:
@ -66,12 +66,14 @@ export class BlocklistItemDeleteMessagesJob
|
||||
|
||||
const rolesToDelete: ('from' | 'to')[] = ['from', 'to'];
|
||||
|
||||
await this.messageChannelMessageAssociationRepository.deleteByMessageParticipantHandleAndMessageChannelIdsAndRoles(
|
||||
handle,
|
||||
messageChannelIds,
|
||||
rolesToDelete,
|
||||
workspaceId,
|
||||
);
|
||||
for (const messageChannelId of messageChannelIds) {
|
||||
await this.messageChannelMessageAssociationRepository.deleteByMessageParticipantHandleAndMessageChannelIdAndRoles(
|
||||
handle,
|
||||
messageChannelId,
|
||||
rolesToDelete,
|
||||
workspaceId,
|
||||
);
|
||||
}
|
||||
|
||||
await this.threadCleanerService.cleanWorkspaceThreads(workspaceId);
|
||||
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
|
||||
import { MessageQueueJob } from 'src/engine/integrations/message-queue/interfaces/message-queue-job.interface';
|
||||
|
||||
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
|
||||
import { ConnectedAccountRepository } from 'src/modules/connected-account/repositories/connected-account.repository';
|
||||
import { ConnectedAccountWorkspaceEntity } from 'src/modules/connected-account/standard-objects/connected-account.workspace-entity';
|
||||
|
||||
export type BlocklistReimportMessagesJobData = {
|
||||
workspaceId: string;
|
||||
workspaceMemberId: string;
|
||||
handle: string;
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
export class BlocklistReimportMessagesJob
|
||||
implements MessageQueueJob<BlocklistReimportMessagesJobData>
|
||||
{
|
||||
private readonly logger = new Logger(BlocklistReimportMessagesJob.name);
|
||||
|
||||
constructor(
|
||||
@InjectObjectMetadataRepository(ConnectedAccountWorkspaceEntity)
|
||||
private readonly connectedAccountRepository: ConnectedAccountRepository,
|
||||
) {}
|
||||
|
||||
async handle(data: BlocklistReimportMessagesJobData): Promise<void> {
|
||||
const { workspaceId, workspaceMemberId, handle } = data;
|
||||
|
||||
this.logger.log(
|
||||
`Reimporting messages from handle ${handle} in workspace ${workspaceId} for workspace member ${workspaceMemberId}`,
|
||||
);
|
||||
|
||||
const connectedAccount =
|
||||
await this.connectedAccountRepository.getAllByWorkspaceMemberId(
|
||||
workspaceMemberId,
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
if (!connectedAccount || connectedAccount.length === 0) {
|
||||
this.logger.error(
|
||||
`No connected account found for workspace member ${workspaceMemberId} in workspace ${workspaceId}`,
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: reimplement that
|
||||
// await this.gmailMessageListFetchJob.fetchConnectedAccountThreads(
|
||||
// workspaceId,
|
||||
// connectedAccount[0].id,
|
||||
// [handle],
|
||||
// );
|
||||
|
||||
this.logger.log(
|
||||
`Reimporting messages from ${handle} in workspace ${workspaceId} for workspace member ${workspaceMemberId} done`,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user