Compare commits

...
Author SHA1 Message Date
Sonarly Claude Code 50aad3e088 fix(messaging): use DELETED event action for handleDeletedEvent in blocklist listener
https://sonarly.com/issue/33600?type=bug

The `MessagingBlocklistListener.handleDeletedEvent` uses `DatabaseEventAction.CREATED` instead of `DatabaseEventAction.DELETED`, causing it to fire on CREATE events. The resulting `ObjectRecordCreateEvent` has no `properties.before`, causing a TypeError when the job accesses `eventPayload.properties.before.workspaceMemberId`.

Fix: Changed the `@OnDatabaseBatchEvent` decorator on `handleDeletedEvent` from `DatabaseEventAction.CREATED` to `DatabaseEventAction.DELETED` in `MessagingBlocklistListener`.

This was a copy-paste error introduced in commit `695991881f` (November 2024) when migrating from `@OnEvent('blocklist.deleted')` to the new `@OnDatabaseEvent` decorator pattern. The `handleDeletedEvent` method was incorrectly subscribed to `blocklist.created` events instead of `blocklist.deleted` events.

This caused two problems:
1. **Crash on blocklist creation**: When a blocklist item was created, `handleDeletedEvent` fired with `ObjectRecordCreateEvent` data (which has no `properties.before`), causing `TypeError: Cannot read properties of undefined (reading 'workspaceMemberId')` in `BlocklistReimportMessagesJob`.
2. **Silent functional bug**: When a blocklist item was deleted, the message reimport job never ran — previously blocked messages were never re-synced.

The fix matches the identical pattern used by `CalendarBlocklistListener` (line 44), which correctly uses `DatabaseEventAction.DELETED` for its `handleDeletedEvent`.
2026-05-02 22:33:31 +00:00
@@ -41,7 +41,7 @@ export class MessagingBlocklistListener {
);
}
@OnDatabaseBatchEvent('blocklist', DatabaseEventAction.CREATED)
@OnDatabaseBatchEvent('blocklist', DatabaseEventAction.DELETED)
async handleDeletedEvent(
payload: WorkspaceEventBatch<
ObjectRecordDeleteEvent<BlocklistWorkspaceEntity>