@ -3,6 +3,7 @@ import { OnEvent } from '@nestjs/event-emitter';
|
|||||||
|
|
||||||
import { ObjectRecordCreateEvent } from 'src/engine/integrations/event-emitter/types/object-record-create.event';
|
import { ObjectRecordCreateEvent } from 'src/engine/integrations/event-emitter/types/object-record-create.event';
|
||||||
import { ObjectRecordDeleteEvent } from 'src/engine/integrations/event-emitter/types/object-record-delete.event';
|
import { ObjectRecordDeleteEvent } from 'src/engine/integrations/event-emitter/types/object-record-delete.event';
|
||||||
|
import { ObjectRecordUpdateEvent } from 'src/engine/integrations/event-emitter/types/object-record-update.event';
|
||||||
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
|
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
|
||||||
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
|
||||||
import {
|
import {
|
||||||
@ -23,10 +24,10 @@ export class CalendarBlocklistListener {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
@OnEvent('blocklist.created')
|
@OnEvent('blocklist.created')
|
||||||
handleCreatedEvent(
|
async handleCreatedEvent(
|
||||||
payload: ObjectRecordCreateEvent<BlocklistObjectMetadata>,
|
payload: ObjectRecordCreateEvent<BlocklistObjectMetadata>,
|
||||||
) {
|
) {
|
||||||
this.messageQueueService.add<BlocklistItemDeleteCalendarEventsJobData>(
|
await this.messageQueueService.add<BlocklistItemDeleteCalendarEventsJobData>(
|
||||||
BlocklistItemDeleteCalendarEventsJob.name,
|
BlocklistItemDeleteCalendarEventsJob.name,
|
||||||
{
|
{
|
||||||
workspaceId: payload.workspaceId,
|
workspaceId: payload.workspaceId,
|
||||||
@ -48,4 +49,26 @@ export class CalendarBlocklistListener {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnEvent('blocklist.updated')
|
||||||
|
async handleUpdatedEvent(
|
||||||
|
payload: ObjectRecordUpdateEvent<BlocklistObjectMetadata>,
|
||||||
|
) {
|
||||||
|
await this.messageQueueService.add<BlocklistItemDeleteCalendarEventsJobData>(
|
||||||
|
BlocklistItemDeleteCalendarEventsJob.name,
|
||||||
|
{
|
||||||
|
workspaceId: payload.workspaceId,
|
||||||
|
blocklistItemId: payload.recordId,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await this.messageQueueService.add<BlocklistReimportCalendarEventsJobData>(
|
||||||
|
BlocklistReimportCalendarEventsJob.name,
|
||||||
|
{
|
||||||
|
workspaceId: payload.workspaceId,
|
||||||
|
workspaceMemberId: payload.properties.after.workspaceMember.id,
|
||||||
|
handle: payload.properties.before.handle,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import {
|
|||||||
BlocklistItemDeleteMessagesJobData,
|
BlocklistItemDeleteMessagesJobData,
|
||||||
BlocklistItemDeleteMessagesJob,
|
BlocklistItemDeleteMessagesJob,
|
||||||
} from 'src/modules/messaging/jobs/blocklist-item-delete-messages.job';
|
} from 'src/modules/messaging/jobs/blocklist-item-delete-messages.job';
|
||||||
|
import { ObjectRecordUpdateEvent } from 'src/engine/integrations/event-emitter/types/object-record-update.event';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MessagingBlocklistListener {
|
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,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user