Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

Fix event bus event processing for mutli node broadcasting

Hakan Shehu2c0c3b96bf77
diff --git a/apps/server/src/lib/event-bus.ts b/apps/server/src/lib/event-bus.ts
index ae12dd1d..31a4a5e1 100644
--- a/apps/server/src/lib/event-bus.ts
+++ b/apps/server/src/lib/event-bus.ts
@@ -47,7 +47,7 @@ export class EventBusService {
return;
}
- this.publish(envelope.event);
+ this.processEvent(envelope.event);
});
}
@@ -67,14 +67,18 @@ export class EventBusService {
}
public publish(event: Event) {
- this.subscriptions.forEach((subscription) => {
- subscription.callback(event);
- });
+ this.processEvent(event);
if (host.environment === 'production') {
redis.publish(CHANNEL_NAME, JSON.stringify({ event, hostId: host.id }));
}
}
+
+ private processEvent(event: Event) {
+ this.subscriptions.forEach((subscription) => {
+ subscription.callback(event);
+ });
+ }
}
export const eventBus = new EventBusService();