3921 delete messagethreads after deleting connectedaccount (#3925)

* created listener

* working

---------

Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
bosiraphael
2024-02-13 14:36:55 +01:00
committed by GitHub
parent 1d1976ef22
commit ec48e66eeb
4 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,40 @@
import { Injectable, Logger } from '@nestjs/common';
import { MessageQueueJob } from 'src/integrations/message-queue/interfaces/message-queue-job.interface';
import { MessageChannelMessageAssociationService } from 'src/workspace/messaging/message-channel-message-association/message-channel-message-association.service';
export type DeleteMessageChannelMessageAssociationJobData = {
workspaceId: string;
messageChannelId: string;
};
@Injectable()
export class DeleteMessageChannelMessageAssociationJob
implements MessageQueueJob<DeleteMessageChannelMessageAssociationJobData>
{
private readonly logger = new Logger(
DeleteMessageChannelMessageAssociationJob.name,
);
constructor(
private readonly messageChannelMessageAssociationService: MessageChannelMessageAssociationService,
) {}
async handle(
data: DeleteMessageChannelMessageAssociationJobData,
): Promise<void> {
this.logger.log(
`Deleting message channel message association for message channel ${data.messageChannelId} in workspace ${data.workspaceId}`,
);
await this.messageChannelMessageAssociationService.deleteByMessageChannelId(
data.messageChannelId,
data.workspaceId,
);
this.logger.log(
`Deleted message channel message association for message channel ${data.messageChannelId} in workspace ${data.workspaceId}`,
);
}
}