4748 create updated listener on blocklist (#5145)

Closes #4748
This commit is contained in:
bosiraphael
2024-04-25 17:39:56 +02:00
committed by GitHub
parent 6e8c6c8e58
commit 9f1818aef7
2 changed files with 48 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import {
BlocklistItemDeleteMessagesJobData,
BlocklistItemDeleteMessagesJob,
} from 'src/modules/messaging/jobs/blocklist-item-delete-messages.job';
import { ObjectRecordUpdateEvent } from 'src/engine/integrations/event-emitter/types/object-record-update.event';
@Injectable()
export class MessagingBlocklistListener {
@ -48,4 +49,26 @@ export class MessagingBlocklistListener {
},
);
}
@OnEvent('blocklist.updated')
async handleUpdatedEvent(
payload: ObjectRecordUpdateEvent<BlocklistObjectMetadata>,
) {
await this.messageQueueService.add<BlocklistItemDeleteMessagesJobData>(
BlocklistItemDeleteMessagesJob.name,
{
workspaceId: payload.workspaceId,
blocklistItemId: payload.recordId,
},
);
await this.messageQueueService.add<BlocklistReimportMessagesJobData>(
BlocklistReimportMessagesJob.name,
{
workspaceId: payload.workspaceId,
workspaceMemberId: payload.properties.after.workspaceMember.id,
handle: payload.properties.before.handle,
},
);
}
}