Skip to content

Commit 9108519

Browse files
committed
⚡ Deduplicate change events
1 parent e5be78b commit 9108519

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/models/controller.model.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
} from './pubsub-contacts-message.model';
3838
import { PubSubContactsChangedClient } from './pubsub-contacts-changed-client.model';
3939
import { PubSubContactChangeEventMessage } from './pubsub-contacts-changed-message.model';
40+
import { isEqual, uniqWith } from 'lodash';
4041

4142
const CONTACT_FETCH_TIMEOUT = 5000;
4243

@@ -1385,7 +1386,9 @@ export class Controller {
13851386
'',
13861387
);
13871388

1388-
changeEvents.map((changeEvent: ContactChangeEvent) => {
1389+
const deduplicatedChangeEvents = uniqWith(changeEvents, isEqual);
1390+
1391+
deduplicatedChangeEvents.map((changeEvent: ContactChangeEvent) => {
13891392
infoLogger(
13901393
'handleWebhook',
13911394
`Publishing contact change event with accountId ${changeEvent.accountId} and contactId ${changeEvent.contactId}`,

0 commit comments

Comments
 (0)